oops ! my mistake :-D
On 7/31/06, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> Amit Khemka wrote:
> > how about:
> >
> > vals = []
> > for val in mydict.values():
> > try: vals.extend(val)
> > except: vals.append(val)
>
> >>> l = []
> >>> l.extend((1, 2))
> >>> l
> [1, 2]
> >>> l.extend('a
David Zaret wrote:
> thanks for the many responses.
>
> i have zero control over the dict. in practice, i'm using turbogears
> which is "automatically" populating the result dict with zero-to-many
> choices from a generated list of HTML checkboxes. the user can select
> none, one, or many, and s
Paul Rubin wrote:
> Bruno Desthuilliers <[EMAIL PROTECTED]> writes:
>> Too much useless lookup IMHO...
>
> Actually, you, me, and Amit all mis-read David's original exapmle.
Actually, I plea not guilty - cf my answer to the OP !-)
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::
thanks for the many responses.
i have zero control over the dict. in practice, i'm using turbogears
which is "automatically" populating the result dict with zero-to-many
choices from a generated list of HTML checkboxes. the user can select
none, one, or many, and submit. cherrypy packs the *
Amit Khemka wrote:
> On 7/31/06, David Zaret <[EMAIL PROTECTED]> wrote:
>> i have a dict with a particular key - the values for this key will be
>> None, one valid scalar, or a list:
>>
>> {mykey, None}
>> {mykey, "foo"}
>> {mykey, ["bar", "baz"]}
>>
>> let's ignore the None
Bruno Desthuilliers <[EMAIL PROTECTED]> writes:
> Too much useless lookup IMHO...
Actually, you, me, and Amit all mis-read David's original exapmle.
What he really wanted was (let's see if I get it right this time):
if mykey in mydict:
v = mydict[mykey]
if not isinstance(v, list):
David Zaret wrote:
> i have a dict with a particular key - the values for this key will be
> None, one valid scalar, or a list:
>
> {mykey, None}
> {mykey, "foo"}
> {mykey, ["bar", "baz"]}
>
> let's ignore the None case - in the case of the one or many values, i
> want to suck the val
On 7/31/06, David Zaret <[EMAIL PROTECTED]> wrote:
> i have a dict with a particular key - the values for this key will be
> None, one valid scalar, or a list:
>
> {mykey, None}
> {mykey, "foo"}
> {mykey, ["bar", "baz"]}
>
> let's ignore the None case - in the case of the on
Paul Rubin wrote:
> David Zaret <[EMAIL PROTECTED]> writes:
>> my way is ugly. what's a better way?
>
> Untested:
>
> for key in mydict:
>if isinstance(mydict[key], list):
> vals.extend(mydict[key])
>else:
> vals.append(mydict[key])
Too much useless looku
David Zaret <[EMAIL PROTECTED]> writes:
> my way is ugly. what's a better way?
Untested:
for key in mydict:
if isinstance(mydict[key], list):
vals.extend(mydict[key])
else:
vals.append(mydict[key])
--
http://mail.python.org/mailman/listinfo/python-list
i have a dict with a particular key - the values for this key will be
None, one valid scalar, or a list:
{mykey, None}
{mykey, "foo"}
{mykey, ["bar", "baz"]}
let's ignore the None case - in the case of the one or many values, i
want to suck the values into a list. here'
11 matches
Mail list logo