Re: [Tutor] First program

2010-03-12 Thread Steven D'Aprano
On Sat, 13 Mar 2010 01:04:42 pm Ray Parrish wrote: > >     print "A %s with dimensions %sx%s has an area of %s." % > > (choice, height, width, width*height) > > Hello, > > Isn't it a little more understandable to use a > construct like the following? > > >>> print "The area of a " + Choice + "is "

Re: [Tutor] First program

2010-03-12 Thread Steven D'Aprano
On Sat, 13 Mar 2010 01:11:25 pm Ray Parrish wrote: > Here's what I get from that, could you please explain why? > >  >>> print('{0}, is not a valid choice'.format(choice)) > Traceback (most recent call last): >   File "", line 1, in > AttributeError: 'str' object has no attribute 'format' The ori

Re: [Tutor] %s %r with cutom type

2010-03-12 Thread Steven D'Aprano
On Fri, 12 Mar 2010 10:29:17 pm spir wrote: > Hello again, > > A different issue. On the custom Unicode type discussed in another > thread, I have overloaded __str__ and __repr__ to get encoded byte > strings (here with debug prints & special formats to distinguish from > builtin forms): [...] > No

Re: [Tutor] First program

2010-03-12 Thread Luke Paireepinart
On Fri, Mar 12, 2010 at 8:30 PM, Andre Engels wrote: > On Sat, Mar 13, 2010 at 3:11 AM, Ray Parrish wrote: > > Andre Engels wrote: > >> > >> On 3/12/10, yd wrote: > >>> else: > >>>raise Exception('{0}, is not a valid choice'.format(choice)) > >>> > >> > >> This will cause the program to st

Re: [Tutor] First program

2010-03-12 Thread Luke Paireepinart
Ray, please reply on-list in the future in case someone else has input. On Fri, Mar 12, 2010 at 8:01 PM, Ray Parrish wrote: > Luke Paireepinart wrote: > >print "A %s with dimensions %sx%s has an area of %s." % (choice, height, >> width, width*height) >> >> > Isn't it a little more understand

Re: [Tutor] First program

2010-03-12 Thread Andre Engels
On Sat, Mar 13, 2010 at 3:11 AM, Ray Parrish wrote: > Andre Engels wrote: >> >> On 3/12/10, yd wrote: >>>  else: >>>    raise Exception('{0}, is not a valid choice'.format(choice)) >>> >> >> This will cause the program to stop-with-error if something wrong is >> entered. I think that's quite rude

Re: [Tutor] First program

2010-03-12 Thread Ray Parrish
Luke Paireepinart wrote: On Fri, Mar 12, 2010 at 4:03 AM, yd > wrote: Hi, I am new to programming, altough i have read a few books about OOP and O'Reily's Learning Python. I would like some critique on my first program, is it normal for it to be t

Re: [Tutor] sorting algorithm

2010-03-12 Thread Dave Angel
C.T. Matsumoto wrote: I've change the code and I think I have what you were talking about. def mysort(list_): for i in xrange(0, len(list_)): pos = i for j in xrange(pos+1, len(list_)): if list_[i] > list_[j]: pos = j list_[i]

Re: [Tutor] First program

2010-03-12 Thread Ray Parrish
Andre Engels wrote: On 3/12/10, yd wrote: Hi, I am new to programming, altough i have read a few books about OOP and O'Reily's Learning Python. I would like some critique on my first program, is it normal for it to be this long to do something simple? Well, many of your lines are user

Re: [Tutor] Visual Python programming and decompilers?

2010-03-12 Thread David Hutto
--- On Fri, 3/12/10, spir wrote: > From: spir > Subject: Re: [Tutor] Visual Python programming and decompilers? > To: tutor@python.org > Date: Friday, March 12, 2010, 7:22 AM > On Fri, 12 Mar 2010 10:19:39 +0200 > Ludolph > wrote: > > > Hi Guys > > > > I posted the following message on my l

Re: [Tutor] First program

2010-03-12 Thread Alan Gauld
"yd" wrote I would like some critique on my first program, is it normal for it to be this long to do something simple? Its OK for a first program. There are many things that could be improved but its not too bad. As to length, it could be shortened a bit but this is not really a long progr

Re: [Tutor] sorting algorithm

2010-03-12 Thread Jeff Johnson
Steven D'Aprano wrote: In future, could you please trim your quoting to be a little less excessive? There's no need to included the ENTIRE history of the thread in every post. That was about four pages of quoting to add five short sentences! Thank you. Will do. I usually do just didn't

Re: [Tutor] Problem with turtle

2010-03-12 Thread Marco Rompré
The thing is that the teacher wanted us to use a while loop like in the notes but even in the notes I copied the code and it was not working either. Now, I'm more on the right track, I am able to draw the forms and the counter is almost working, the reason I say that is because turtle is doin what

Re: [Tutor] sorting algorithm

2010-03-12 Thread C.T. Matsumoto
I've change the code and I think I have what you were talking about. def mysort(list_): for i in xrange(0, len(list_)): pos = i for j in xrange(pos+1, len(list_)): if list_[i] > list_[j]: pos = j list_[i], lis

Re: [Tutor] Recommendations on Workshops, Courses, Live Online Training

2010-03-12 Thread Hansen, Mike
> -Original Message- > From: tutor-bounces+mike.hansen=atmel@python.org > [mailto:tutor-bounces+mike.hansen=atmel@python.org] On > Behalf Of Tino Dai > Sent: Thursday, March 11, 2010 12:29 PM > To: Alan Gauld > Cc: tutor@python.org > Subject: Re: [Tutor] Recommendations on Worksho

Re: [Tutor] use of __new__

2010-03-12 Thread spir
On Fri, 12 Mar 2010 22:56:37 +1100 Steven D'Aprano wrote: > You might be tempted to change the first reference to Unicode to cls as > well, but sadly that does not work. The reason is complicated, and to > be honest I don't remember it, but you will probably find it by > googling for "python s

Re: [Tutor] sorting algorithm

2010-03-12 Thread Steven D'Aprano
On Fri, 12 Mar 2010 11:04:13 pm C.T. Matsumoto wrote: [snip 269 lines of quoted text] > Thanks Jeff. Indeed when I kept the code as is and added a doubled > element to the input list, it went into an infinite loop. For running > the swap it doesn't matter if the elements are equal. Catching equal

Re: [Tutor] Visual Python programming and decompilers?

2010-03-12 Thread spir
On Fri, 12 Mar 2010 10:19:39 +0200 Ludolph wrote: > Hi Guys > > I posted the following message on my local pug mailing list and > someone recommended I post it here. > > At work I have been exposed to a Agile Platform called OutSystems. It > allows you to visually program your web applications

Re: [Tutor] sorting algorithm

2010-03-12 Thread C.T. Matsumoto
Dave Angel wrote: C.T. Matsumoto wrote: Dave Angel wrote: (You forgot to do a Reply-All, so your message went to just me, rather than to me and the list ) C.T. Matsumoto wrote: Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the

Re: [Tutor] sorting algorithm

2010-03-12 Thread C.T. Matsumoto
Jeff Johnson wrote: C.T. Matsumoto wrote: Dave Angel wrote: (You forgot to do a Reply-All, so your message went to just me, rather than to me and the list ) C.T. Matsumoto wrote: Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the

Re: [Tutor] use of __new__

2010-03-12 Thread Steven D'Aprano
I've taken the liberty of replying back to the list rather than in private. Denis, if you mean to deliberately reply privately, please say so at the start of the email, otherwise I will assume it was an accident. On Fri, 12 Mar 2010 09:56:11 pm spir wrote: > Side-question: Why use super() whe

[Tutor] %s %r with cutom type

2010-03-12 Thread spir
Hello again, A different issue. On the custom Unicode type discussed in another thread, I have overloaded __str__ and __repr__ to get encoded byte strings (here with debug prints & special formats to distinguish from builtin forms): class Unicode(unicode): ENCODING = "utf8" def __new__(

Re: [Tutor] First program

2010-03-12 Thread Andre Engels
On 3/12/10, yd wrote: > Hi, > I am new to programming, altough i have read a few books about OOP and > O'Reily's Learning Python. > I would like some critique on my first program, is it normal for it to be > this long to do something simple? Well, many of your lines are user interface. Writing tw

Re: [Tutor] First program

2010-03-12 Thread Luke Paireepinart
On Fri, Mar 12, 2010 at 4:03 AM, yd wrote: > Hi, > I am new to programming, altough i have read a few books about OOP and > O'Reily's Learning Python. > I would like some critique on my first program, is it normal for it to be > this long to do something simple? > I know i could have turned some

[Tutor] First program

2010-03-12 Thread yd
Hi, I am new to programming, altough i have read a few books about OOP and O'Reily's Learning Python. I would like some critique on my first program, is it normal for it to be this long to do something simple? I know i could have turned some of these things into classes and functions but i don't kn

Re: [Tutor] use of __new__

2010-03-12 Thread spir
On Fri, 12 Mar 2010 12:27:02 +1100 Steven D'Aprano wrote: > On Fri, 12 Mar 2010 11:53:16 am Steven D'Aprano wrote: > > > I have tried to match the behaviour of the built-in unicode as close > > as I am able. See here: > > http://docs.python.org/library/functions.html#unicode > > And by doing so

Re: [Tutor] trouble with dates and python and databases

2010-03-12 Thread Alan Gauld
"Christopher Spears" wrote My problem is I'm not sure how to store and retrieve the dates. I assume the best way to record the date is to use datetime.date. If you are using a database I'd just use the database date functions. There should be functions to generate and store dates via SQL.

[Tutor] Visual Python programming and decompilers?

2010-03-12 Thread Ludolph
Hi Guys I posted the following message on my local pug mailing list and someone recommended I post it here. At work I have been exposed to a Agile Platform called OutSystems. It allows you to visually program your web applications http://i.imgur.com/r2F0i.png and I find the idea very intriguing.