string.Template question

2010-04-05 Thread Wells Oliver
Can you use dicts with string.Template? e.g. a structure like: game = { 'home': {'team': row['home_team_full'], 'score': row['home_score'], 'record': '0-0', 'pitcher': { 'id': home_pitcher.attrib['id'], 'name': home_pitcher.attrib['last_name'], 'wins': hom

A question on scope...

2009-06-18 Thread Wells Oliver
In writing out python classes, it seems the 'self' is optional, meaning that inside a class method, "self.foo = bar" has the same effect as "foo = bar". Is this right? If so, it seems a little odd- what's the rationale? Or am I mistaken? -- Well

n00b confusion re: local variable referenced before assignment error

2009-06-19 Thread Wells Oliver
h is the "file.write(handler.read())" line.. What gives? -- Wells Oliver we...@submute.net -- http://mail.python.org/mailman/listinfo/python-list

MySQLdb and ordering of column names in list returned by keys() w/ a DictCursor

2009-07-02 Thread Wells Oliver
x27;, 'ER'] Neither alphabetical nor the order in which they were specified in the query nor... any seeming order I can suss out. Any ideas? Thanks! (cursor being a MySQLdb.cursors.DictCursor object.) -- Wells Oliver we...@submute.net -- http://mail.python.org/mailman/listinfo/python-list

Re: MySQLdb and ordering of column names in list returned by keys() w/ a DictCursor

2009-07-02 Thread Wells Oliver
I can suss out. Any ideas? Thanks! >> >> (cursor being a MySQLdb.cursors.DictCursor object.) >> > > My guess is you're experiencing the fact that dicts are unordered by nature > which allows it to return in any order it likes (usually per the internal > representation/storage). > > -tkc > > > > -- Wells Oliver we...@submute.net -- http://mail.python.org/mailman/listinfo/python-list

Question regarding style/design..

2009-07-17 Thread Wells Oliver
scope such that the preference shifts from the former to the latter? I understand the use of the __name__ == 'main' convention for building unit tests, but I'm mixed on using it in scripts/small applications. Thanks for any thoughts! -- Wells Oliver we...@submute.net -- http://mail.python.org/mailman/listinfo/python-list

RPY2 examples?

2009-07-22 Thread Wells Oliver
I am trying to find examples using RPY2 to render R graphs to PNG/PDF/etc. The only things I can find use rpy 1.x. Any references? Thanks! -- Wells Oliver we...@submute.net -- http://mail.python.org/mailman/listinfo/python-list

Sorting dict by value w/ operator.itemgetter- using key name?

2009-07-30 Thread Wells Oliver
Bit of code: print sorted(results.items(), key=operator.itemgetter(1)) Would rather use 'H9', which is the name of the key in position 1 like: print sorted(results.items(), key=operator.itemgetter('H9')) Obviously that ain't work else I wouldn't be sending th

Ordering of dict keys & values

2009-08-03 Thread Wells Oliver
on the value being in the same index as its corresponding key? -- Wells Oliver we...@submute.net -- http://mail.python.org/mailman/listinfo/python-list