Válas Péter wrote:
So the trick is to define the dictionary in separate sessions, not at once.
No.
value = 42
my_dict = {'a': value, 'b': value, 'c': 23, 'd': value, 'e': 97}
will work fine too.
--
Steven
___
Tutor maillist - Tutor@python.org
On Tue, Jul 5, 2011 at 3:40 PM, Walter Prins wrote:
>> So the trick is to define the dictionary in separate sessions, not at
>> once.
>
> What do you mean, "seperate sessions, not at once"?
He means you can't say:
d = {a: "1", b: d["a"]}
Which is correct. To set one value based on another they
Hi,
7/5 Válas Péter
> So the trick is to define the dictionary in separate sessions, not at once.
>
What do you mean, "seperate sessions, not at once"?
W
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://ma
So the trick is to define the dictionary in separate sessions, not at once.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
"Válas Péter" wrote
I have a dictionary with the keys 'a' and 'b'. It is not in a class.
May I use the value of 'a' when defining the value of 'b'?
If so, what is the syntax?
single = {'a': 1,
'b': 2
}
double = { 'a': single['a'] *2,
'b' : singl
Válas Péter wrote:
> I have a dictionary with the keys 'a' and 'b'. It is not in a class. (I
> know that everything is in a class, but not explicitly.)
> May I use the value of 'a' when defining the value of 'b'? If so, what is
> the syntax?
>>> d = {}
>>> d["a"] = 1
>>> d["b"] = d["a"] + 1
>>> d
2011/7/5 Válas Péter :
> Hi,
>
> I have a dictionary with the keys 'a' and 'b'. It is not in a class. (I know
> that everything is in a class, but not explicitly.)
> May I use the value of 'a' when defining the value of 'b'? If so, what is
> the syntax?
Yes. The syntax is the same as anything invo
Hi,
I have a dictionary with the keys 'a' and 'b'. It is not in a class. (I know
that everything is in a class, but not explicitly.)
May I use the value of 'a' when defining the value of 'b'? If so, what is
the syntax?
Thx,
Péter
___
Tutor maillist -