Re: [Tutor] RE module is working ?

2011-02-04 Thread Karim
By the way with your helper function algorithm Steven and Peter comments you made me think of this change: karim@Requiem4Dream:~$ echo 'prima " "' | sed -e 's/""/\\"\\"/g;s/\([^\]\)"/\1\\"/g' prima \" \" karim@Requiem4Dream:~$ echo 'prima ""' | sed -e 's/""/\\"\\"/g;s/\([^\]\)"/\1\\"/g' pr

Re: [Tutor] RE module is working ?

2011-02-04 Thread Karim
On 02/04/2011 11:26 AM, Peter Otten wrote: Karim wrote: That is not the thing I want. I want to escape any " which are not already escaped. The sed regex '/\([^\\]\)\?"/\1\\"/g' is exactly what I need (I have made regex on unix since 15 years). Can the backslash be escaped, too? If so I don't

Re: [Tutor] RE module is working ?

2011-02-04 Thread Karim
On 02/04/2011 02:36 AM, Steven D'Aprano wrote: Karim wrote: *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (appears as stars) but I don't know how to fix it yet. A man when to a doctor and said, "

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Alex Hall
I see, thanks! On 2/4/11, Bill Felton wrote: > Smalltalk is an OO programming language that had some dominance in the late > 80's through much of the 90s. It has proceeded to more or less commit > suicide through a variety of mechanisms. > By 'drop' I meant 'drop the context of the remarks', whi

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Bill Felton
Smalltalk is an OO programming language that had some dominance in the late 80's through much of the 90s. It has proceeded to more or less commit suicide through a variety of mechanisms. By 'drop' I meant 'drop the context of the remarks', which in the original post was discussing Smalltalk's d

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Alex Hall
On 2/4/11, Bill Felton wrote: > Um, yes, emphatically yes. You missed the context, which was Smalltalk, and > it is terms of Smalltalk that my reply is couched. > Yes, Python returns None. > Smalltalk returns self by default. > Given the dropped context, you are correct. > Given the context meant

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Bill Felton
Um, yes, emphatically yes. You missed the context, which was Smalltalk, and it is terms of Smalltalk that my reply is couched. Yes, Python returns None. Smalltalk returns self by default. Given the dropped context, you are correct. Given the context meant, I am. regards, Bill On Feb 4, 2011, at

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Emile van Sebille
On 2/4/2011 5:35 AM Bill Felton said... Um, not quite correct -- methods *without a specified return value* always return self, that is, the object which executed the method. Um, no. They return None. >>> class Test: ... def __init__(self):pass ... def test(self):pass ... >>> a=Test().t

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread ALAN GAULD
> > And most methods do not return the object of which they > > are a part (in Python at least, in SmallTalk they do). > That seems like it would get rather confusing... Actually, from an OOP point of view, its a very powerful default and I wish more Python methods did it. It allows you to c

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Bill Felton
On Feb 4, 2011, at 8:03 AM, Alex Hall wrote: > On 2/4/11, Alan Gauld wrote: >> "Alex Hall" wrote >> >>> I am wondering what the best way to do the following would be: throw >>> an exception, or always return an object but set an error flag if >>> something goes wrong? Here is an example: >> >

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Alex Hall
On 2/4/11, Alan Gauld wrote: > "Alex Hall" wrote > >> I am wondering what the best way to do the following would be: throw >> an exception, or always return an object but set an error flag if >> something goes wrong? Here is an example: > > Throw an exception is the short general case answer... >

Re: [Tutor] RE module is working ?

2011-02-04 Thread Peter Otten
Karim wrote: > That is not the thing I want. I want to escape any " which are not > already escaped. > The sed regex '/\([^\\]\)\?"/\1\\"/g' is exactly what I need (I have > made regex on unix since 15 years). Can the backslash be escaped, too? If so I don't think your regex does what you think

Re: [Tutor] RE module is working ?

2011-02-04 Thread Peter Otten
Karim wrote: > Recall: > > >>> re.subn(r'([^\\])?"', r'\1\\"', expression) > > Traceback (most recent call last): > File "", line 1, in > File "/home/karim/build/python/install/lib/python2.7/re.py", line > 162, in subn >return _compile(pattern, flags).subn(repl, string, count)

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Alan Gauld
"Alex Hall" wrote I am wondering what the best way to do the following would be: throw an exception, or always return an object but set an error flag if something goes wrong? Here is an example: Throw an exception is the short general case answer... class c: def __init__(self): self.error=

Re: [Tutor] Ideas and good examples

2011-02-04 Thread Alan Gauld
"David Goering" wrote It says v3 is Under Construction, how long do you expect it to be like this. The basic v3 tutor is all done except for the Case Study - which is currently about 75% complete. Its certainly usable. The Practical Python topics have not been started yet, but any v3 user wh

Re: [Tutor] 'Installing' Python at runtime? (Civilization)

2011-02-04 Thread Japhy Bartlett
a common approach is to embed python in a compiled binary On Thu, Feb 3, 2011 at 9:18 PM, Steven D'Aprano wrote: > Alan Gauld wrote: >> >> "C.Y. Ruhulessin" wrote >> >>> When I load up Civilization IV, a Firaxis game, the loading screen tells >>> me >>> "Loading Python". >>> >>> However, I can't