Re: [Tutor] Practice Exercises for Beginner ?

2016-06-02 Thread boB Stepp
On Thu, Jun 2, 2016 at 3:43 PM, Andrei Colta wrote: > Anyone can recommend practical work on learning python.. seems reading and > reading does not helping. The usual advice: Find one or more projects that interest you and start trying to accomplish them, learning more

Re: [Tutor] Tkinter and threading

2016-06-02 Thread Marco Soldavini
Thanks for you answers! On Thu, Jun 2, 2016 at 6:39 PM, Peter Otten <__pete...@web.de> wrote: >> For example a state machine with a var state which can have some >> discrete string values (like RUNNING, STOPPED, PAUSED, ABORTED, IDLE) >> and a text element on the gui that reports that state. >>

[Tutor] Practice Exercises for Beginner ?

2016-06-02 Thread Andrei Colta
Hi, Anyone can recommend practical work on learning python.. seems reading and reading does not helping. Thanks in advance, Andrei ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Semantic Error: Trying to access elements of list and append to empty list with for loop

2016-06-02 Thread Alex Hall
Use lst.extend() instead of lst.append() and you should get what you're after. On Thu, Jun 2, 2016 at 1:05 PM, Olaoluwa Thomas wrote: > Hi Tutor, > > I'm trying to parse words in a file line by line and place all words into > another list but I keep getting a list with

Re: [Tutor] Semantic Error: Trying to access elements of list and append to empty list with for loop

2016-06-02 Thread Oscar Benjamin
On 2 June 2016 at 19:19, Olaoluwa Thomas wrote: > Thanks, everyone, for your help. > > The objective was to extract all words from each line and place them in a > list IF they didn't already exist in it. > I sorted it out by adding little bits of everyone's suggestions.

Re: [Tutor] Semantic Error: Trying to access elements of list and append to empty list with for loop

2016-06-02 Thread Olaoluwa Thomas
Thanks, everyone, for your help. The objective was to extract all words from each line and place them in a list IF they didn't already exist in it. I sorted it out by adding little bits of everyone's suggestions. Here's the code that fixed it. fname = raw_input('Enter file name:\n') try:

Re: [Tutor] Semantic Error: Trying to access elements of list and append to empty list with for loop

2016-06-02 Thread Steven D'Aprano
On Thu, Jun 02, 2016 at 06:05:43PM +0100, Olaoluwa Thomas wrote: > fname = raw_input('Enter file name:\n') > try: > fhand = open(fname) > except: > print 'File cannot be found or opened:', fname > exit() > lst = list() > for line in fhand: > words = line.split() > #print words

Re: [Tutor] Semantic Error: Trying to access elements of list and append to empty list with for loop

2016-06-02 Thread Alan Gauld via Tutor
On 02/06/16 18:05, Olaoluwa Thomas wrote: > lst = list() > for line in fhand: > words = line.split() words is now a list of words a test that a portion of my code was working) > lst.append(words) So you append that list to lst and get a list of lists. Try using + instead: lst +=

[Tutor] Semantic Error: Trying to access elements of list and append to empty list with for loop

2016-06-02 Thread Olaoluwa Thomas
Hi Tutor, I'm trying to parse words in a file line by line and place all words into another list but I keep getting a list with nested lists. I would normally pore over it and go to google and fix my problems but this one escapes me and frankly, I'm tired of being stuck in the same place for

Re: [Tutor] Tkinter and threading

2016-06-02 Thread Peter Otten
Marco Soldavini wrote: > Hello, > probably this is a very naive question, but I've read some stuff on > Tkinter and its infinite loop. > > Then about how can i bind actions to elements, for example buttons. > > What if I want to run another loop beside the graphical interface in > the same

Re: [Tutor] Tkinter and threading

2016-06-02 Thread Alan Gauld via Tutor
On 02/06/16 14:40, Marco Soldavini wrote: > What if I want to run another loop beside the graphical interface in > the same python script? You need to do it in a separate thread. Keep the Tkinter loop on your main thread and use it to trigger actions. > For example a state machine with a var

[Tutor] Tkinter and threading

2016-06-02 Thread Marco Soldavini
Hello, probably this is a very naive question, but I've read some stuff on Tkinter and its infinite loop. Then about how can i bind actions to elements, for example buttons. What if I want to run another loop beside the graphical interface in the same python script? For example a state machine

Re: [Tutor] OrderedDict?

2016-06-02 Thread Alex Hall
Thanks. I've never used that module before, and didn't realize it's not imported by default, which must be why my first tries failed. I've got it working now. > On Jun 1, 2016, at 18:45, Alan Gauld via Tutor wrote: > > On 01/06/16 16:36, Alex Hall wrote: > >> I'm trying to