Neil Cerutti wrote:
>
> Thanks for the pointer to keyword module. I hadn't noticed it
> yet.
Bonus: you got an extremely fresh, scarcely used pointer -- I wasn't
aware of it myself till today :-)
Cheers,
John
--
http://mail.python.org/mailman/listinfo/python-list
On 2006-12-02, John Machin <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> On 2006-12-02, Michel Claveau <[EMAIL PROTECTED]> wrote:
>> > Hi!
>> >
>> > Yes.
>> >
>> > But...
>> >
>> > Try:d = {'a': 1, 'b': 2, 'def': 123}
>> >
>> > Ok, I go out...
>>
>> How to convert a list of strings into a
On Sat, 02 Dec 2006 17:00:15 -0800, John Machin wrote:
>
> Steven D'Aprano wrote:
>> On Sat, 02 Dec 2006 12:16:24 -0800, John Machin wrote:
>>
>> > The OP might consider adding code to the __init__ method to check for
>> > cases where the dictionary key is not a string containing a valid
>> > Pyt
Steven D'Aprano wrote:
> On Sat, 02 Dec 2006 12:16:24 -0800, John Machin wrote:
>
> > The OP might consider adding code to the __init__ method to check for
> > cases where the dictionary key is not a string containing a valid
> > Python identifier (not a keyword).
>
[snip]
> But if he's doing some
On Sat, 02 Dec 2006 12:16:24 -0800, John Machin wrote:
> The OP might consider adding code to the __init__ method to check for
> cases where the dictionary key is not a string containing a valid
> Python identifier (not a keyword).
If the OP is doing something like this:
attributes = {"length":
John Machin wrote:
> Any experiences of keyword-bite?
creating or manipulating CSS-styled (X)HTML using an XML binding that
exposes XML attributes as Python attributes.
(this could be viewed as an unnecessary restriction in the Python
parser; it wouldn't be too hard to allow reserved words for
Neil Cerutti wrote:
> On 2006-12-02, Michel Claveau <[EMAIL PROTECTED]> wrote:
> > Hi!
> >
> > Yes.
> >
> > But...
> >
> > Try:d = {'a': 1, 'b': 2, 'def': 123}
> >
> > Ok, I go out...
>
> How to convert a list of strings into a list of integers:
>
> a = ['82', '4', '16']
>
> ai = [int(i) for
On Fri, 01 Dec 2006 17:48:40 -0800, rieh25 wrote:
> If I have a dictionary such as:
>
> d = {'a' : 1, 'b' : 2}
>
> is there a way to convert it into an object o, such as:
>
> o.a = 1
> o.b = 2
Rather, the question could be asked the other way around: how can you
convert that object into a dict
On 2006-12-02, Michel Claveau <[EMAIL PROTECTED]> wrote:
> Hi!
>
> Yes.
>
> But...
>
> Try:d = {'a': 1, 'b': 2, 'def': 123}
>
> Ok, I go out...
How to convert a list of strings into a list of integers:
a = ['82', '4', '16']
ai = [int(i) for i in a]
Yes.
But...
Try: a = ['82', '4', '16'
Hi!
Yes.
But...
Try:d = {'a': 1, 'b': 2, 'def': 123}
Ok, I go out...
--
@-salutations
Michel Claveau
--
http://mail.python.org/mailman/listinfo/python-list
At Friday 1/12/2006 22:48, rieh25 wrote:
If I have a dictionary such as:
d = {'a' : 1, 'b' : 2}
is there a way to convert it into an object o, such as:
o.a = 1
o.b = 2
>>> class X(object):
... def __init__(self, d): self.__dict__.update(d)
...
>>> d = {'a' : 1, 'b' : 2}
>>> o=X(d)
>>> o.a
If I have a dictionary such as:
d = {'a' : 1, 'b' : 2}
is there a way to convert it into an object o, such as:
o.a = 1
o.b = 2
thanks
--
View this message in context:
http://www.nabble.com/converting-dict-to-object-tf2741429.html#a7649225
Sent from the Python - pyth
12 matches
Mail list logo