Re: pymongo and attribute dictionaries

2015-02-06 Thread Ian Kelly
On Thu, Feb 5, 2015 at 6:27 AM, Anssi Saari wrote: > What I find surprising is that so many people cling so hard to their > localized keyboard layouts. I think none of those were created by > engineers and should be avoided by technical people. Or, in fact, > everyone. Even Microsoft seems to unde

Re: pymongo and attribute dictionaries

2015-02-05 Thread Anssi Saari
Steven D'Aprano writes: > Vito De Tullio wrote: > >> Steven D'Aprano wrote: >> This just does not roll of the fingers well. Too many “reach for modifier keys” in a row. >>> >>> *One* modifier key in a row is too many? >>> >>> s o m e SHIFT D o c [ ' SHIFT _ i d ' ] >> >> I'm not OP,

Re: pymongo and attribute dictionaries

2015-02-04 Thread Steven D'Aprano
Vito De Tullio wrote: > Steven D'Aprano wrote: > >>> This just does not roll of the fingers well. Too many “reach for >>> modifier keys” in a row. >> >> *One* modifier key in a row is too many? >> >> s o m e SHIFT D o c [ ' SHIFT _ i d ' ] > > I'm not OP, but as side note... not everyone has "

Re: pymongo and attribute dictionaries

2015-02-04 Thread Vito De Tullio
Steven D'Aprano wrote: >> This just does not roll of the fingers well. Too many “reach for modifier >> keys” in a row. > > *One* modifier key in a row is too many? > > s o m e SHIFT D o c [ ' SHIFT _ i d ' ] I'm not OP, but as side note... not everyone has "[" as a direct character on the keyb

Re: pymongo and attribute dictionaries

2015-02-04 Thread Steven D'Aprano
Ian Kelly wrote: >> Extending this to wrap methods of classes is also left as an exercise. >> (Hint: don't subclass. Search the ActiveState Python recipes for >> "automatic delegation" by Alex Martelli.) > > Do you mean this one? > > http://code.activestate.com/recipes/52295-automatic-delegation

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 3:38 PM, Steven D'Aprano wrote: > Travis Griggs wrote: >> This just does not roll of the fingers well. Too many “reach for modifier >> keys” in a row. > > *One* modifier key in a row is too many? > > s o m e SHIFT D o c [ ' SHIFT _ i d ' ] I think the point was meant to be

Re: pymongo and attribute dictionaries

2015-02-04 Thread Steven D'Aprano
Travis Griggs wrote: > I really like pymongo. And I really like Python. But one thing my fingers > really get tired of typing is > > someDoc[‘_’id’] I've never used pymongo, so can't comment from experience, but surely any library which encourages, if not requires, that you access private data _

Re: pymongo and attribute dictionaries

2015-02-04 Thread Rob Gaddi
On Wed, 04 Feb 2015 13:54:22 -0700, Ian Kelly wrote: > I'd prefer map (or itertools.imap in Python 2) over the inline generator > in this case: > > for doc in map(Doc, client.db.radios.find({’_id': {’$regex’: > ‘^[ABC]'}})): > pprint(doc) > > Or if you like, a utility function wrapping the s

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 1:16 PM, Travis Griggs wrote: > Yes, that is clever. So if you wanted to minimize the amount of typing you > had to do at all of your pymongo API call sites, what strategy would you use > to keep that relatively terse? > > Is the following the right approach to take? > > c

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 1:16 PM, Travis Griggs wrote: > Yes, that is clever. So if you wanted to minimize the amount of typing you > had to do at all of your pymongo API call sites, what strategy would you use > to keep that relatively terse? > > Is the following the right approach to take? > > c

Re: pymongo and attribute dictionaries

2015-02-04 Thread Gregory Ewing
Travis Griggs wrote: for doc in client.db.radios.find({’_id': {’$regex’: ‘^[ABC]'}}): pprint(doc) changes to for doc in ((Doc(d) for d in client.db.radios.find({’_id': {’$regex’: ‘^[ABC]'}})): pprint(doc) Are there other approaches? Feel free to impress me with evil abuses in the interest of a

Re: pymongo and attribute dictionaries

2015-02-04 Thread Chris Kaynor
On Wed, Feb 4, 2015 at 12:16 PM, Travis Griggs wrote: > >> On Feb 4, 2015, at 9:22 AM, Ian Kelly wrote: >> >> On Wed, Feb 4, 2015 at 9:50 AM, Travis Griggs wrote: >>> I really like pymongo. And I really like Python. But one thing my fingers >>> really get tired of typing is >>> >>> someDoc[‘_’i

Re: pymongo and attribute dictionaries

2015-02-04 Thread Travis Griggs
> On Feb 4, 2015, at 9:22 AM, Ian Kelly wrote: > > On Wed, Feb 4, 2015 at 9:50 AM, Travis Griggs wrote: >> I really like pymongo. And I really like Python. But one thing my fingers >> really get tired of typing is >> >> someDoc[‘_’id’] >> >> This just does not roll of the fingers well. Too m

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 9:50 AM, Travis Griggs wrote: > I really like pymongo. And I really like Python. But one thing my fingers > really get tired of typing is > > someDoc[‘_’id’] > > This just does not roll of the fingers well. Too many “reach for modifier > keys” in a row. I would rather use

pymongo and attribute dictionaries

2015-02-04 Thread Travis Griggs
I really like pymongo. And I really like Python. But one thing my fingers really get tired of typing is someDoc[‘_’id’] This just does not roll of the fingers well. Too many “reach for modifier keys” in a row. I would rather use someDoc._id Googling shows that I’m not the first to want to do