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

2011-02-03 Thread Alex Hall
Thanks to all for the answers. Sounds like exceptions are most definitely the way to go, and I will definitely put them in. In fact, this should make the wrapper a bit cleaner since I am not constantly checking for errors in variables and returning empty objects. Besides, I wouldn't want my soul st

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

2011-02-03 Thread Steven D'Aprano
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 seem to find out where it installs python It probably doesn't actually install Python it is simply loading the interpreter into memory.

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

2011-02-03 Thread Steven D'Aprano
Alex Hall wrote: Hi all, 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? Raise an exception. Error flags are an anti-pattern -- a software idiom that you should not follow. The probl

Re: [Tutor] Ideas and good examples

2011-02-03 Thread Robert
On 2011-02-03 19:14:40 -0500, Alan Gauld said: "Tino Dai" wrote Finally you should check out Alan Gauld's page: http://www.freenetpages.co.uk/hp/alan.gauld/ That site has been locked for over 2 years. The new site has a lot of updates and, of course, a whole new rewrite of the tutor for v3!

Re: [Tutor] Ideas and good examples

2011-02-03 Thread David Goering
Hello, Thanks for the input so far. Alan I saw a Message about your website right after I sent away my question and it definetly looks like a good place to start... especially the sections from Advanced Topics onwards. It says v3 is Under Construction, how long do you expect it to be like this.

Re: [Tutor] RE module is working ?

2011-02-03 Thread Steven D'Aprano
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, "Doctor, every time I do this, it hurts. What sh

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

2011-02-03 Thread Emile van Sebille
On 2/3/2011 4:41 PM Alex Hall said... Hi all, 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: class c: def __init__(self): self.error=False def func(self, val):

Re: [Tutor] print "Hello, World!"

2011-02-03 Thread Steven D'Aprano
Doug Marvel wrote: [...] I am hoping for a link to a somewhat comprehensive online resource that explains from the beginning in English, plain English, as this is the only language I speak. Something to get my foot in the door would be awesome. Another very important resource to use is the Pyth

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

2011-02-03 Thread Alex Hall
Hi all, 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: class c: def __init__(self): self.error=False def func(self, val): if val!=10: self.error=True someObj=c()

Re: [Tutor] Ideas and good examples

2011-02-03 Thread Alan Gauld
"Tino Dai" wrote Finally you should check out Alan Gauld's page: http://www.freenetpages.co.uk/hp/alan.gauld/ That site has been locked for over 2 years. The new site has a lot of updates and, of course, a whole new rewrite of the tutor for v3! :-) See the sig... -- Alan Gauld Author

Re: [Tutor] Ideas and good examples

2011-02-03 Thread Alan Gauld
"David Goering" wrote 1) Does anyone have ideas for small - mid ranged projects where I could quickly pick up on the pitfalls of Python but that is also useful in some way ? Check the recent archives we had a very similar thread a week or two back. (And fairly regularly over the years!) I h

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

2011-02-03 Thread Alan Gauld
"C.Y. Ruhulessin" wrote When I load up Civilization IV, a Firaxis game, the loading screen tells me "Loading Python". However, I can't seem to find out where it installs python It probably doesn't actually install Python it is simply loading the interpreter into memory. It probably uses P

Re: [Tutor] System of ODEs Question

2011-02-03 Thread Eike Welk
Hello Eric! On Thursday 03.02.2011 08:05:13 Eric Lofgren wrote: > def eq_system(PopIn,x): > '''Defining SIR System of Equations''' > #Creating an array of equations > Eqs= np.zeros((3)) > Eqs[0]= -beta * PopIn[0]*PopIn[1] > Eqs[1]= beta * PopIn[0]*PopIn[1] - gamma*PopIn[1] >

Re: [Tutor] RE module is working ?

2011-02-03 Thread Alan Gauld
"Karim" wrote Because expression = *' "" '* is in fact fact expression = ' "" '. The bold appear as stars I don't know why. Because in the days when email was always sent in plain ASCII text the way to show "bold" was to put asterisks around it. Underlining used _underscores_ like so...

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 07:47 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 11:20 PM, Dave Angel wrote: On 01/-10/-28163 02:59 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: (snip> *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (ap

Re: [Tutor] RE module is working ?

2011-02-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: (snip> *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

Re: [Tutor] Namespace variables vs. instantiation keywords - best practices

2011-02-03 Thread Tim Johnson
* Tim Johnson [110203 10:34]: > # OR (project config file) > kws = load.config("myconfig","tmpl_kws") > kws.update({"prj":"myproject","templatepath":"views"}) #Grr! The following line is wrong .. > kws = {"prj":"myproject","templatepath":"views"} Should be #content = LoadView(**kws) sorry -- Tim

Re: [Tutor] Ideas and good examples

2011-02-03 Thread Tino Dai
On Thu, Feb 3, 2011 at 2:24 PM, David Goering wrote: > Hello, > this is my first message here... and come to think of it my first Message > in a Mailing List what so ever. So a moment of epic historical importance :) > Anyway I decided I wanted to learn Python as I didn't really know any > script

[Tutor] Namespace variables vs. instantiation keywords - best practices

2011-02-03 Thread Tim Johnson
FYI: Python 2.6.5 on Linux. FYI: I am a web programmer of 24 years experience programming, 9 with python, but have never had the advantage of working with a senior programmer as a mentor. I am investigating the best practices of instantiating an object with a large amount of options. I would also r

[Tutor] Ideas and good examples

2011-02-03 Thread David Goering
Hello, this is my first message here... and come to think of it my first Message in a Mailing List what so ever. So a moment of epic historical importance :) Anyway I decided I wanted to learn Python as I didn't really know any scripting language yet and I have heard great things about Python.

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type "help", "copyright",

Re: [Tutor] Changing Python icon - 2.6 and 3.2

2011-02-03 Thread Marc Tompkins
On Thu, Feb 3, 2011 at 9:18 AM, Patty wrote: > Hello Folks - I have Python 2.6.6 on my Windows 7 system and installed > Python 3.2. Now I want to be able to differentiate between the versions and > the icon for each version of Python is the same. I figured I would change > the the four applica

Re: [Tutor] print "Hello, World!"

2011-02-03 Thread Patty
Hello Doug - My very first document I read - before I took an online course - was "A Quick, Painless Tutorial on the Python Language" by Norman Matloff from UC Davis. My copy is dated May 1, 2009 but I think he has updated it -- looks like May 2010. Here is the link, you may also want to quer

Re: [Tutor] Changing Python icon - 2.6 and 3.2

2011-02-03 Thread Bill Felton
I haven't tried this on Windows 7 yet, but what I did on my Mac was to create shortcuts and rename those. I generally launch from shortcuts, so this leaves the app names alone but gives me the information I need to launch what I intend. You should be able to do something similar on Windows. r

[Tutor] Changing Python icon - 2.6 and 3.2

2011-02-03 Thread Patty
Hello Folks - I have Python 2.6.6 on my Windows 7 system and installed Python 3.2. Now I want to be able to differentiate between the versions and the icon for each version of Python is the same. I figured I would change the the four application files in the C:\Python26 directory - python; pyt

Re: [Tutor] print "Hello, World!"

2011-02-03 Thread Doug Marvel
Holy wow! I'm going to go through all of these and see what sort of understanding I can absorb. I'm super excited that a helpful community exists for this, but I'm more excited to start learning. So I'm going to go do that now. I'm starting with Alan Gauld's tutorial, but like I said, I'm going to

Re: [Tutor] Defining Exceptions

2011-02-03 Thread Emile van Sebille
Hi Tom, First, you sent this only to me -- be sure to reply all so that the group can participate. On 2/2/2011 10:25 AM Tom Brauch said... > Thanks, Emile. > > If I replace the question marks in my script with break it throws out > everything before the break (<) and gives me the header starti

[Tutor] question about locale.setlocale

2011-02-03 Thread Rafael Durán Castañeda
Hi all, I'm new in Python, so I'm reading 3.1 tutorial and now I've got a question about locale.setlocale function. I've tryed in python idle this: import locale locale.setlocale(locale.LC_ALL, 'English_United States.1252') and i got: Traceback (most recent call last): File "", line 1, in

Re: [Tutor] RE module is working ?

2011-02-03 Thread Peter Otten
Karim wrote: > I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 > consecutives double quotes: > > * *In Python interpreter:* > > $ python > Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) > [GCC 4.4.3] on linux2 > Type "help", "copyright", "credits" or "license" for m

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

2011-02-03 Thread C.Y. Ruhulessin
Thanks, will check it out! 2011/2/3 Noah Hall > On Thu, Feb 3, 2011 at 11:11 AM, C.Y. Ruhulessin > wrote: > > For an application that I am designing, i'd like to achieve the same > > functionality, so the end users don't have to bother installing Python > > themselves. > > Can anybody shed thei

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
I forget something. There is no issue with python and double quotes. But I need to give it to TCL script but as TCL is shit string is only delimited by double quotes. Thus I need to escape it to not have syntax error whith nested double quotes. Regards The poor tradesman On 02/03/2011 12:45

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

2011-02-03 Thread Noah Hall
On Thu, Feb 3, 2011 at 11:11 AM, C.Y. Ruhulessin wrote: > For an application that I am designing, i'd like to achieve the same > functionality, so the end users don't have to bother installing Python > themselves. > Can anybody shed their lights on how one would program this? > kind regards, The

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
Hello Steven, I am perhaps a poor tradesman but I have to blame my thunderbird tool :-P . Because expression = *' "" '* is in fact fact expression = ' "" '. The bold appear as stars I don't know why. I need to have escapes for passing it to another language (TCL interpreter). So I will rewrit

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

2011-02-03 Thread C.Y. Ruhulessin
Hi all, When I load up Civilization IV, a Firaxis game, the loading screen tells me "Loading Python". However, I can't seem to find out where it installs python (and Python wasn't installed before I installed it myself), so I *assume *that it 'installs' and loads Python at runtime. For an applic

Re: [Tutor] print "Hello, World!"

2011-02-03 Thread Alan Gauld
"michael scott" wrote already been asked, learn from others who asked before you :) Oh yea, I once read that there are no intermediate tutorials in any programming language, because once you get past the basics, you only need to reference the "documentation" that comes with the language. Th

Re: [Tutor] byte array conversion question

2011-02-03 Thread Steven D'Aprano
Bill Allen wrote: I have found that there are a couple of ways to convert a byte array to a string in Python. Is there any advantage or disadvantage to either method? my_bytes = b'this is a test' str(my_bytes,'utf-8') yields 'this is a test' my_bytes.decode('utf-8';) yeilds 'this is a tes

Re: [Tutor] RE module is working ?

2011-02-03 Thread Steven D'Aprano
Karim wrote: Hello, I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 consecutives double quotes: You don't have to escape quotes. Just use the other sort of quote: >>> print '""' "" * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:5

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
Hello, Any news on this topic?O:-) Regards Karim On 02/02/2011 08:21 PM, Karim wrote: Hello, I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC

Re: [Tutor] print "Hello, World!"

2011-02-03 Thread Alan Gauld
"Doug Marvel" wrote - I have downloaded and installed Python 2.6.4. Successfully, I think. - I am running Windows XP SP3 (though I'm going to see if I can do this on my laptop, which has Windows 7) - I have toyed around with some tutorials, but all they really taught me is that I need a teac

Re: [Tutor] print "Hello, World!"

2011-02-03 Thread Dharmit Shah
I'd also recommend using http://www.openbookproject.net/thinkcs/python/english2e/ . Currently I am learning from it. Once u are through with it u can read the book called Dive into Python. it's for experienced users. Google it. Hope that helps. On Thu, Feb 3, 2011 at 1:20 PM, wrote: > > Seven y