Re: [Tutor] broken script

2011-07-05 Thread Marc Tompkins
On Tue, Jul 5, 2011 at 3:23 PM, Martin A. Brown wrote: > I have heard people express frustration many times about how a > program(ming language) or "the computer" did not understand > something because the thing was 'missing a damned semicolon'. > > Unfortunately, these syntactical rules are quit

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] broken script

2011-07-05 Thread Martin A. Brown
Hello, : I am copy-typing the following pre-written program: : : def break_words(stuff): : """This function will break up words for us.""" : words=stuff.split(' ') : return words : : def sort_words(words): : """Sorts the words.""" : return sorted(words) : :

[Tutor] broken script

2011-07-05 Thread Lisi
I am copy-typing the following pre-written program: def break_words(stuff): """This function will break up words for us.""" words=stuff.split(' ') return words def sort_words(words): """Sorts the words.""" return sorted(words) def print_first_word(words): """Prints th

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 -

Re: [Tutor] serial device emulator

2011-07-05 Thread Edgar Almonte
got it , thanks a lot On Tue, Jul 5, 2011 at 8:18 AM, Adam Bark wrote: > What Chris is getting at is that you'll use some module, eg pyserial, to > interface with the serial port. So if you write a little module that has the > same interface then you can pretend you have a serial port attached de

Re: [Tutor] serial device emulator

2011-07-05 Thread Adam Bark
What Chris is getting at is that you'll use some module, eg pyserial, to interface with the serial port. So if you write a little module that has the same interface then you can pretend you have a serial port attached device and then switch over to an actual one without changing anything else i

Re: [Tutor] serial device emulator

2011-07-05 Thread Edgar Almonte
thanks chirs but i think i don't follow you , can you elaborate more ? Thanks On Mon, Jul 4, 2011 at 8:49 PM, Chris Fuller wrote: > > You don't need to emulate a serial port (since you're writing the code; you'd > have to emulate the port if it was standalone software), only your serial port >