Permalink
Browse files

use array to avoid global

  • Loading branch information...
1 parent f18c4ae commit 44653c41a1cfe2ff02f9166322251b536a837cf3 @n8han n8han committed Apr 13, 2011
Showing with 3 additions and 5 deletions.
  1. +3 −5 stream.py
View
@@ -1,16 +1,14 @@
import pycurl, json
-last = ""
-
def jsonizer(event_callback):
"""Passes json dicts to the given callback"""
+ last = [""]
def consume(data):
"""Buffers data and invokes event_callback on completed lines"""
- global last
- lines = (last + data).split("\n")
+ lines = (last[0] + data).split("\n")
for l in lines[:-1]:
event_callback(json.loads(l))
- last = lines[-1]
+ last[0] = lines[-1]
conn = pycurl.Curl()
conn.setopt(pycurl.URL, "http://stream.meetup.com/2/open_events")

0 comments on commit 44653c4

Please sign in to comment.