Dave Merrill wrote:
"anton muhin" wrote:
Or dict((key, row[key]) for key in cols).
I'm on Py 2.3.3, and neither of these appear to work.
You're probably getting the error shown. Try the change in
the line following it instead.
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
The correct syntax is:
dict([(key, row[key]) for key in cols])
i.e. the list must be enclosed in [...].
/Jean Brouwers
In article <[EMAIL PROTECTED]>, Dave Merrill
<[EMAIL PROTECTED]> wrote:
> "anton muhin" wrote:
> > Stefan Behnel wrote:
> > >
> > >
> > > shark schrieb:
> > >
> > >> ro
On Wed, 1 Dec 2004 10:23:28 -0500, Dave Merrill <[EMAIL PROTECTED]> wrote:
> "anton muhin" wrote:
> > Or dict((key, row[key]) for key in cols).
>
> I'm on Py 2.3.3, and neither of these appear to work. Can someone confirm? I
> can't see anything in the 2.4 release notes that point to where this wo
"anton muhin" wrote:
> Stefan Behnel wrote:
> >
> >
> > shark schrieb:
> >
> >> row = {"fname" : "Frank", "lname" : "Jones", "city" : "Hoboken",
> >> "state" :
> >> "Alaska"}
> >> cols = ("city", "state")
> >>
> >> Is there a best-practices way to ask for an object containing only the
> >> keys
> >
On Tue, 30 Nov 2004 21:54:46 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote:
[...]
>
>If there's an overall why for doing it at all, why not just iterate through
>keys of interest? I.e., (untested)
>
> dict( (key, row[key]) for key in cols )
>
Sorry Anton, I didn't see your post. Newsfeed delays seem
On Tue, 30 Nov 2004 15:20:19 +0100, Stefan Behnel <[EMAIL PROTECTED]> wrote:
>
>
>shark schrieb:
>> row = {"fname" : "Frank", "lname" : "Jones", "city" : "Hoboken", "state" :
>> "Alaska"}
>> cols = ("city", "state")
>>
>> Is there a best-practices way to ask for an object containing only the keys
Stefan Behnel wrote:
shark schrieb:
row = {"fname" : "Frank", "lname" : "Jones", "city" : "Hoboken",
"state" :
"Alaska"}
cols = ("city", "state")
Is there a best-practices way to ask for an object containing only the
keys
named in cols out of row? In other words, to get this:
{"city" : "Hoboken
shark schrieb:
row = {"fname" : "Frank", "lname" : "Jones", "city" : "Hoboken", "state" :
"Alaska"}
cols = ("city", "state")
Is there a best-practices way to ask for an object containing only the keys
named in cols out of row? In other words, to get this:
{"city" : "Hoboken", "state" : "Alaska"}
U
In article <[EMAIL PROTECTED]>, "shark" <[EMAIL PROTECTED]>
wrote:
> row = {"fname" : "Frank", "lname" : "Jones", "city" : "Hoboken", "state" :
> "Alaska"}
> cols = ("city", "state")
>
> Is there a best-practices way to ask for an object containing only the keys
> named in cols out of row? In ot
shark wrote:
row = {"fname" : "Frank", "lname" : "Jones", "city" : "Hoboken", "state" :
"Alaska"}
cols = ("city", "state")
Is there a best-practices way to ask for an object containing only the keys
named in cols out of row? In other words, to get this:
{"city" : "Hoboken", "state" : "Alaska"}
Why
10 matches
Mail list logo