Re: [Tutor] Issue with iterating within lists, objects and functions

2007-08-03 Thread Kent Johnson
Ricardo Aráoz wrote: > Kent Johnson wrote: >> Andy Cheesman wrote: >>> for thing in ["top", "right", "bottom", "left"]: >>> eval("self." + thing).append("fish") >> You don't need to use eval() here, use getattr() instead: >> getattr(self, thing).append('fish') >> > > What if you want to do : >

[Tutor] Float and decimal spaces

2007-08-03 Thread Toon Pieton
Hey all! My memory seem to have a horrible leak. How does one limit the amount of decimal spaces for a float? I used to know that... Example: not 5.398042156, but 5.4 (if I decide to have only one place). Thanks in advance! Toon Pieton. ___ Tutor maill

Re: [Tutor] Float and decimal spaces

2007-08-03 Thread Luke Paireepinart
Toon Pieton wrote: > Hey all! > > My memory seem to have a horrible leak. How does one limit the amount > of decimal spaces for a float? I used to know that... > > Example: not 5.398042156, but 5.4 (if I decide to have only one place). Usually you do this during display, while you leave the actual

Re: [Tutor] more encoding confusion

2007-08-03 Thread Kent Johnson
Jon Crump wrote: > I'm parsing a utf-8 encoded file with lines characterized by placenames > in all caps thus: > > HEREFORD, Herefordshire. > ..other lines.. > HÉRON (LE), Normandie. > ..other lines.. > > I identify these lines for parsing using > > for line in data: > if re.match(r'[A-Z]{2

[Tutor] more encoding confusion

2007-08-03 Thread Jon Crump
I'm parsing a utf-8 encoded file with lines characterized by placenames in all caps thus: HEREFORD, Herefordshire. ..other lines.. HÉRON (LE), Normandie. ..other lines.. I identify these lines for parsing using for line in data: if re.match(r'[A-Z]{2,}', line): but of course this catches

Re: [Tutor] curses

2007-08-03 Thread alejandro varas
maybe dis is what you want to do. Ijust made some changes to the code. On 7/17/07, max baseman <[EMAIL PROTECTED]> wrote: > > hello all sorry to bother I'm working on my first curses program ive > been wanting to learn curses for a while now and now that a have a > lop top with fedora core runn

Re: [Tutor] Parsing several files

2007-08-03 Thread Luke Paireepinart
Que Prime wrote: > > With the help of a tutor I was able to get the following code to work > the way I want, but I'd like for it to parse through several files in > one folder and create one output file. > > I'm thinking I need to add something like: > > def grab_files(files = []): Default values

[Tutor] Parsing several files

2007-08-03 Thread Que Prime
With the help of a tutor I was able to get the following code to work the way I want, but I'd like for it to parse through several files in one folder and create one output file. I'm thinking I need to add something like: def grab_files(files = []): found = [] if files != None: Here is

Re: [Tutor] [OT] Re: os.path.exists(path) returns false when the path actually exists!

2007-08-03 Thread Luke Paireepinart
> >> I don't want to have to know the details of what makes my car run. All I >> want to do is drive it from one location to another. >> > > And one day your car doesn't start. So you blindly take it to a car mechanic > (or even the dealership~shudder) where they hook it up to a battery char

Re: [Tutor] Issue with iterating within lists, objects and functions

2007-08-03 Thread Andy Cheesman
Thanks for your help Kent The error was that I was trying to assign to a non-assignable reference as you highlighted. Everything works now Thanks Andy Kent Johnson wrote: > Andy Cheesman wrote: >> for thing in ["top", "right", "bottom", "left"]: >> eval("self." + thing).append("fish") > >

Re: [Tutor] Issue with iterating within lists, objects and functions

2007-08-03 Thread Kent Johnson
Andy Cheesman wrote: > for thing in ["top", "right", "bottom", "left"]: > eval("self." + thing).append("fish") You don't need to use eval() here, use getattr() instead: getattr(self, thing).append('fish') > eval("self." + thing +"_extra") > eval("self." + thing) = external_funct

[Tutor] ossaudiodev, pygtk, and flushing buffers

2007-08-03 Thread Anthony Sales
Matthew, I am also experimenting with ossaudiodev with python and was having the same problem on my laptop, but not on my desktop - the reset() method has solved this problem. However I want to be able to pause the played file before it ends, but all the controls seem to be locked until the sound

[Tutor] Issue with iterating within lists, objects and functions

2007-08-03 Thread Andy Cheesman
Dear people, Sorry for the vague title, I'm struggling to define the problem but an example will be better/clearer. If I've a list of strings, which relate to objects(lists) elsewhere in my code, I can call list action fine within the loop but I was wondering how do I apply an external function as