dcrespo a écrit :
I think it would be time for you to read the Fine Manual...
hi, thanks for your answer... I really did it the same way you
suggested, but I forgot to tell you that I wanted to get a better way
for doing it.
Let us know if you find one...
By the way, knowing your
dcrespo wrote:
Hi all,
How can I replace all None values with the string 'Null' in a
dictionary?
For example:
convert this:
a = {'item1': 45, 'item2': None}
into this:
a = {'item1': 45, 'item2': 'Null'}
I think it would be time for you to read the Fine Manual...
for key in a:
I think it would be time for you to read the Fine Manual...
hi, thanks for your answer... I really did it the same way you
suggested, but I forgot to tell you that I wanted to get a better way
for doing it.
By the way, knowing your wisdom, what do I have to install to get the
following code
Thanks... I did it right that way, but asked it without telling how I
did it just to see what are the occurences of others. I thing there's
no better/faster solution.
Many thanks
Daniel
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 28 Oct 2005 05:23:00 -0700, dcrespo wrote:
I think it would be time for you to read the Fine Manual...
hi, thanks for your answer... I really did it the same way you
suggested, but I forgot to tell you that I wanted to get a better way
for doing it.
What was wrong with the way you
Hi all,
How can I replace all None values with the string 'Null' in a
dictionary?
For example:
convert this:
a = {'item1': 45, 'item2': None}
into this:
a = {'item1': 45, 'item2': 'Null'}
Thanks
Daniel
--
http://mail.python.org/mailman/listinfo/python-list
Daniel How can I replace all None values with the string 'Null' in a
Daniel dictionary?
a = {'item1': 45, 'item2': None}
for key in a:
if a[key] is None:
a[key] = Null
Skip
--
http://mail.python.org/mailman/listinfo/python-list
dcrespo wrote:
Hi all,
How can I replace all None values with the string 'Null' in a
dictionary?
For example:
convert this:
a = {'item1': 45, 'item2': None}
into this:
a = {'item1': 45, 'item2': 'Null'}
for k in a:
if a[k] is None:
a[k] = 'Null'
You aren't doing this to
dcrespo [EMAIL PROTECTED] writes:
Hi all,
How can I replace all None values with the string 'Null' in a
dictionary?
Iterate over everything in the dictionary:
for key, item in mydict.items():
if item is None:
mydict[key] = 'Null'
mike
--
Mike Meyer [EMAIL PROTECTED]
On Thu, 27 Oct 2005 16:46:32 -0400, Mike Meyer [EMAIL PROTECTED] wrote:
dcrespo [EMAIL PROTECTED] writes:
Hi all,
How can I replace all None values with the string 'Null' in a
dictionary?
Iterate over everything in the dictionary:
for key, item in mydict.items():
if item is None:
Bengt Richter [EMAIL PROTECTED] wrote:
...
Which is probably more efficient than one-liner updating the dict with
mydict.update((k,'Null') for k,v in mydict.items() if v is None)
...which in turn is probably better than
_auxd = {None: Null}
newd = dict((k, _auxd.get(k, c) for k, c in
11 matches
Mail list logo