Brain Goo

Carpe Crap ‘em

Brain Goo header image 4

Entries Tagged as 'python'

HOW TO detect STDIN with Python

July 25th, 2011 · No Comments

In Python, as with most languages, STDIN is treated like a file. You can read from it any time, but knowing what kind of file it is lets us know if someone passed us something via STDIN or if we are going to prompt them for it. import os, sys if os.isatty(file.fileno(sys.stdin)):     print “Reading list [...]

[Read more →]

Tags: How Tos · Programming · python

Python HOWTO Push a Dict on to a List (push a hash on to an array)

April 23rd, 2010 · No Comments

One of my more popular posts is How to Push a Hash on to an Array in PERL, but how do you push a dict on to a list in Python? Lists are one-dimensional arrays and dicts are associative arrays or hash arrays.  This means we can do the same thing we do in other [...]

[Read more →]

Tags: How Tos · Programming · python · Software