You could think of it like a train that you watch from a tunnel entrance so that you can just see one car at a time. Or a stream of widgets coming across a conveyor belt requiring you to tighten a screw on each one before it passes by to the next person down the assembly line who has to pound it with a hammer, and so on. Or sticks floating down a river while you watch from a bridge."
Thursday, 3 May 2012
Streams
"A stream is data that you access in sequence.
You could think of it like a train that you watch from a tunnel entrance so that you can just see one car at a time. Or a stream of widgets coming across a conveyor belt requiring you to tighten a screw on each one before it passes by to the next person down the assembly line who has to pound it with a hammer, and so on. Or sticks floating down a river while you watch from a bridge."
You could think of it like a train that you watch from a tunnel entrance so that you can just see one car at a time. Or a stream of widgets coming across a conveyor belt requiring you to tighten a screw on each one before it passes by to the next person down the assembly line who has to pound it with a hammer, and so on. Or sticks floating down a river while you watch from a bridge."
Started out Working through DougHellmann.com's PrettyPrinter Lesson
Module: pprint
Purpose: Pretty-print data structures
The output is kept on a single line, if possible, and indented correctly when split across multiple lines.
PrettyPrint dictionaries & have them printed and sorted by key
pprint seems to sort the keys for you after python2.5 for both single and multi-line output
Changed in version 2.5: Dictionaries are sorted by key before the display is computed; before 2.5, a dictionary was sorted only if its display required more than one line, although that wasn’t documented.
"Generally, though, if you're writing data structures to a file and want them human-readable and writable, you might want to consider using an alternate format like YAML or JSON." [StackOverFlow Tip]
Module: pprint
Purpose: Pretty-print data structures
The output is kept on a single line, if possible, and indented correctly when split across multiple lines.
PrettyPrint dictionaries & have them printed and sorted by key
pprint seems to sort the keys for you after python2.5 for both single and multi-line output
Changed in version 2.5: Dictionaries are sorted by key before the display is computed; before 2.5, a dictionary was sorted only if its display required more than one line, although that wasn’t documented.
"Generally, though, if you're writing data structures to a file and want them human-readable and writable, you might want to consider using an alternate format like YAML or JSON." [StackOverFlow Tip]
dataObject = [ (i, { 'a':'A',
'b':'B',
'c':'C',
'd':'D',
'e':'E',
'f':'F',
'g':'G',
'h':'H',
})
for i in xrange(3)
]
How to send the output of pprint module to a log file
This suggestion
pprint.pprint(dataobject, logFile)
Makes the following code work
logFile=open('c:\\temp\\mylogfile'+'.txt', 'w')
pprint.pprint(dataobject, logFile)
logFile.close()
Tuesday, 1 May 2012
I wonder if markdown or ReST is supported by blogger. [No]
# Welcome to Markdown Syntax #
**Markdown**
###Lists
Unordered lists use asterisks, pluses, and hyphens — interchangably — as list markers:
* Star .. multiply sign
- Dash .. minus sign
+ Cross .. plus sign
+ are all equivalent
I wonder if markdown or ReST is supported by blogger.
...
Nope.
**Markdown**
###Lists
Unordered lists use asterisks, pluses, and hyphens — interchangably — as list markers:
* Star .. multiply sign
- Dash .. minus sign
+ Cross .. plus sign
+ are all equivalent
I wonder if markdown or ReST is supported by blogger.
...
Nope.
Monday, 30 April 2012
Reduce Tk-tinkering
verb (used without object)
8. to work unskillfully or clumsily at anything.
7. to busy oneself with a thing without useful results:
To reduce Tk-tinkering
Use EasyGUI
"EasyGUI is a module for very simple, very easy GUI programming in the Python programming language.... It allows you to program in a traditional linear fashion, and to put up dialogs for simple input and output when you need to. If you have not yet learned the event-driven paradigm for GUI programming, EasyGUI will allow you to be productive with very basic tasks immediately." S.Ferg.
Sunday, 29 April 2012
A tinker was originally an itinerant tinsmith, who mended household utensils.
It is part of an image that come to mind when I work with Tkinter.
Tkinter is Python's de-facto standard GUI (Graphical User Interface) package.
Thinking in Tkinter ... "I've been trying to teach myself Tkinter out of various books, and I'm finding it more difficult than I think it should be. ..." S. Ferg.
It is part of an image that come to mind when I work with Tkinter.
Tkinter is Python's de-facto standard GUI (Graphical User Interface) package.
Thinking in Tkinter ... "I've been trying to teach myself Tkinter out of various books, and I'm finding it more difficult than I think it should be. ..." S. Ferg.
Subscribe to:
Posts (Atom)