python Programming Glossary: self.stream
Python output buffering http://stackoverflow.com/questions/107705/python-output-buffering every call. class Unbuffered def __init__ self stream self.stream stream def write self data self.stream.write data self.stream.flush.. self stream self.stream stream def write self data self.stream.write data self.stream.flush def __getattr__ self attr return.. stream def write self data self.stream.write data self.stream.flush def __getattr__ self attr return getattr self.stream attr..
Singleton python generator? Or, pickle a python generator? http://stackoverflow.com/questions/1939015/singleton-python-generator-or-pickle-a-python-generator filenames self.window_size window_size self.filenum 0 self.stream None self.filepos 0 self.prevwords self.current_line def __iter__.. a non empty current line. while not self.current_line if self.stream is None if self.filenum len self.filenames raise StopIteration.. len self.filenames raise StopIteration else self.stream PickleableFile self.filenames self.filenum self.stream.seek..
Serialize the @property methods in a Python class http://stackoverflow.com/questions/2587119/serialize-the-property-methods-in-a-python-class queryset list_of_attributes options self.options options self.stream options.get stream StringIO self.start_serialization for obj..
How to write custom python logging handler? http://stackoverflow.com/questions/3118059/how-to-write-custom-python-logging-handler def emit self record try msg self.format record stream self.stream same_line hasattr record 'same_line' if self.on_same_line and..
Detect tap with pyaudio from live mic http://stackoverflow.com/questions/4160175/detect-tap-with-pyaudio-from-live-mic TapTester object def __init__ self self.pa pyaudio.PyAudio self.stream self.open_mic_stream self.tap_threshold INITIAL_TAP_THRESHOLD.. 1 self.quietcount 0 self.errorcount 0 def stop self self.stream.close def find_input_device self device_index None for i in.. def tapDetected self print Tap def listen self try block self.stream.read INPUT_FRAMES_PER_BLOCK except IOError e # dammit. self.errorcount..
It is possible export table sqlite3 table to csv or similiar? http://stackoverflow.com/questions/4264379/it-is-possible-export-table-sqlite3-table-to-csv-or-similiar self.writer csv.writer self.queue dialect dialect kwds self.stream f self.encoder codecs.getincrementalencoder encoding def writerow.. data self.encoder.encode data # write to the target stream self.stream.write data # empty queue self.queue.truncate 0 def writerows..
Python DictWriter writing UTF-8 encoded CSV files http://stackoverflow.com/questions/5838605/python-dictwriter-writing-utf-8-encoded-csv-files csv.DictWriter self.queue fieldnames dialect dialect kwds self.stream f self.encoder codecs.getincrementalencoder encoding def writerow.. data self.encoder.encode data # write to the target stream self.stream.write data # empty queue self.queue.truncate 0 def writerows..
The logging.handlers: How to rollover after time or maxBytes? http://stackoverflow.com/questions/6167587/the-logging-handlers-how-to-rollover-after-time-or-maxbytes the size limit we have. we are also comparing times if self.stream is None # delay was set... self.stream self._open if self.maxBytes.. times if self.stream is None # delay was set... self.stream self._open if self.maxBytes 0 # are we rolling over msg s n.. 0 # are we rolling over msg s n self.format record self.stream.seek 0 2 #due to non posix compliant Windows feature if self.stream.tell..
Python, want logging with log rotation and compression http://stackoverflow.com/questions/8467978/python-want-logging-with-log-rotation-and-compression would cause the file to exceed the size limit we have. if self.stream is None # delay was set... self.stream self._open if self.maxBytes.. limit we have. if self.stream is None # delay was set... self.stream self._open if self.maxBytes 0 # are we rolling over msg s n.. 0 # are we rolling over msg s n self.format record self.stream.seek 0 2 #due to non posix compliant Windows feature if self.stream.tell..
matplotlib animating a scatter plot http://stackoverflow.com/questions/9401658/matplotlib-animating-a-scatter-plot def __init__ self numpoints 50 self.numpoints numpoints self.stream self.data_stream # Setup the figure and axes... self.fig self.ax.. self Initial drawing of the scatter plot. x y s c next self.stream self.scat self.ax.scatter x y c c s s animated True self.ax.axis.. data def update self i Update the scatter plot. data next self.stream # Set x and y data... self.scat.set_offsets data 2 # Set sizes.....
|