Re: [Tutor] Using a dict value in the same dict

2011-07-05 Thread Steven D'Aprano
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

Re: [Tutor] Using a dict value in the same dict

2011-07-05 Thread Brett Ritter
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

Re: [Tutor] Using a dict value in the same dict

2011-07-05 Thread Walter Prins
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

Re: [Tutor] Using a dict value in the same dict

2011-07-05 Thread Válas Péter
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

Re: [Tutor] Using a dict value in the same dict

2011-07-05 Thread Alan Gauld
"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

Re: [Tutor] Using a dict value in the same dict

2011-07-05 Thread Peter Otten
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

Re: [Tutor] Using a dict value in the same dict

2011-07-05 Thread Noah Hall
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

[Tutor] Using a dict value in the same dict

2011-07-05 Thread 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? Thx, Péter ___ Tutor maillist -