Re: [Tutor] Searching in a file

2010-01-14 Thread Lie Ryan
On 01/14/10 10:29, Hugo Arts wrote: > On Thu, Jan 14, 2010 at 12:05 AM, Alan Gauld > wrote: >> > >> > I prefer the next() approach. > Rightfully so. IMO, The while loop with readline is basically the C > version of that, for the poor people who don't have iterators. I would often prefer while lo

Re: [Tutor] looking for tutor

2010-01-14 Thread Ken G.
maxwell hansen wrote: I have a decent amount of knowledge with QBASIC and am looking for a tutor who can help me learn the pythonic equivalent of QBASIC features and commands such as COLOR, LOCATE, IF...THEN, GOTO, loops, etc. as well as visual things and objects, which arent available in QBAS

Re: [Tutor] looking for tutor

2010-01-14 Thread Alan Gauld
"maxwell hansen" wrote I have a decent amount of knowledge with QBASIC and am looking for a tutor who can help me learn the pythonic equivalent of QBASIC features and commands The original version of my tutor was based on QBASIC and Python(v1.5!) It might still be useful for comparisons. The

Re: [Tutor] Keeping a list of attributes of a certain type

2010-01-14 Thread Alan Gauld
"Guilherme P. de Freitas" wrote Here is my problem. I have two classes, 'Body' and 'Member', and some attributes of 'Body' can be of type 'Member', but some may not. The precise attributes that 'Body' has depend from instance to instance, and they can be added or deleted. I need any instance o

Re: [Tutor] Searching in a file

2010-01-14 Thread Alan Gauld
"spir" wrote But a third option is to use a split and apply it to the whole file as a string thereby breaking the file into as many chunks as start with a line containing 'NEW'... Why not simply a regex pattern starting with "NEW" and ending with '\n'? Because I understood the OP had to e

Re: [Tutor] looking for tutor

2010-01-14 Thread Wayne Werner
On Wed, Jan 13, 2010 at 11:58 PM, maxwell hansen wrote: > I have a decent amount of knowledge with QBASIC and am looking for a tutor > who can help me learn the pythonic equivalent of QBASIC features and > commands such as COLOR, LOCATE, IF...THEN, GOTO, loops, etc. as well as > visual things and

Re: [Tutor] Keeping a list of attributes of a certain type

2010-01-14 Thread spir
On Wed, 13 Jan 2010 20:15:21 -0800 "Guilherme P. de Freitas" wrote: > Ok, I got something that seems to work for me. Any comments are welcome. > > > class Member(object): > def __init__(self): > pass > > > class Body(object): > def __init__(self): > self.members = [] >

Re: [Tutor] Searching in a file

2010-01-14 Thread spir
On Wed, 13 Jan 2010 23:05:11 - "Alan Gauld" wrote: > But a third option is to use a split and apply it to the whole file as > a string thereby breaking the file into as many chunks as start with > a line containing 'NEW'... Why not simply a regex pattern starting with "NEW" and ending with '

[Tutor] looking for tutor

2010-01-14 Thread maxwell hansen
I have a decent amount of knowledge with QBASIC and am looking for a tutor who can help me learn the pythonic equivalent of QBASIC features and commands such as COLOR, LOCATE, IF...THEN, GOTO, loops, etc. as well as visual things and objects, which arent available in QBASIC (due to it being mos

Re: [Tutor] Keeping a list of attributes of a certain type

2010-01-14 Thread Kent Johnson
On Wed, Jan 13, 2010 at 11:15 PM, Guilherme P. de Freitas wrote: > Ok, I got something that seems to work for me. Any comments are welcome. > > > class Member(object): >    def __init__(self): >        pass > > > class Body(object): >    def __init__(self): >        self.members = [] > >    def __

Re: [Tutor] Keeping a list of attributes of a certain type

2010-01-14 Thread Kent Johnson
On Wed, Jan 13, 2010 at 9:24 PM, Guilherme P. de Freitas wrote: > Hi everybody, > > Here is my problem. I have two classes, 'Body' and 'Member', and some > attributes of 'Body' can be of type 'Member', but some may not. The > precise attributes that 'Body' has depend from instance to instance, > a

Re: [Tutor] Keeping a list of attributes of a certain type

2010-01-14 Thread Dave Angel
(You top-posted, which puts your two comments out of order. Now the solution comes before the problem statement) Guilherme P. de Freitas wrote: Ok, I got something that seems to work for me. Any comments are welcome. class Member(object): def __init__(self): pass class Body(obj

Re: [Tutor] samples on sort method of sequence object.

2010-01-14 Thread Hugo Arts
On Thu, Jan 14, 2010 at 10:13 AM, Stefan Behnel wrote: > > Note that this won't work in Py3, where the "cmp" parameter is gone. > > Stefan And he's right again. I should've checked for that. Well, that makes a CmpInt class the only other solution: class CmpInt(int): def __lt__(self, other):

Re: [Tutor] samples on sort method of sequence object.

2010-01-14 Thread Stefan Behnel
Lie Ryan, 14.01.2010 01:47: On 01/14/10 06:56, Hugo Arts wrote: On Wed, Jan 13, 2010 at 8:21 PM, Stefan Behnel wrote: Hugo Arts, 13.01.2010 15:25: Here is my solution for the general case: from itertools import groupby def alphanum_key(string): t = [] for isdigit, group in groupby(stri