Re: [Tutor] First program

2010-03-13 Thread Alan Gauld
"Ray Parrish" wrote print "A %s with dimensions %sx%s has an area of %s." % (choice, height, width, width*height) Isn't it a little more understandable to use a construct like the following? print "The area of a " + Choice + "is " str(Width) + " x " + str(Height) + " equals " + str(Wi

Re: [Tutor] First program

2010-03-13 Thread Luke Paireepinart
On Sat, Mar 13, 2010 at 3:03 AM, Alan Gauld wrote: > "Ray Parrish" wrote > >>print "A %s with dimensions %sx%s has an area of %s." % (choice, >>> height, width, width*height) >>> >>> Isn't it a little more understandable to use a construct like the >> following? >> >> print "The area of a "

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

2010-03-13 Thread spir
On Sat, 13 Mar 2010 13:50:55 +1100 Steven D'Aprano wrote: > 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 p

Re: [Tutor] First program

2010-03-13 Thread yd
Thanks everyone, I am trying to figure out functions and classes right now, i will probably rewrite the program once i get that down and probably use try: and except: for error catching. ___ Tutor maillist - Tutor@python.org To unsubscribe or change sub

Re: [Tutor] Opening a dos exe

2010-03-13 Thread Ray Parrish
Emile van Sebille wrote: On 3/10/2010 11:33 AM Armstrong, Richard J. said... The problem comes in that the dos program requires three inputs (input1.txt, input2.txt and input3.txt - see attached picture) but I cannot find a way of getting this information to the dos program from python. Any idea

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

2010-03-13 Thread Steven D'Aprano
On Sat, 13 Mar 2010 08:40:31 pm spir wrote: > > The print statement understands how to directly print strings > > (byte-strings and unicode-strings) and doesn't call your __str__ > > method. > > > > http://docs.python.org/reference/simple_stmts.html#the-print-statem > >ent > > Right. But then how

Re: [Tutor] Opening a dos exe

2010-03-13 Thread Alan Gauld
"Ray Parrish" wrote but I cannot find a way of getting this information to the dos program from python. Any ideas? You could use os.system("startprogram.bat"), and create startprogram.bat to run the dos program, and feed it the files, either all at once, or one at a time via the command lin

Re: [Tutor] First program

2010-03-13 Thread Alan Gauld
"Luke Paireepinart" wrote print "The area of a " + Choice + "is " str(Width) + " x " + str(Height) + " equals " + str(Width * Height) + " square feet" One thing - you don't need all the str() calls in your example, print already calls str() for you. Also comma separators are bett

[Tutor] Escaping a single quote mark in a triple quoted string.

2010-03-13 Thread Ray Parrish
Hello, I am getting the following - >>> String = """http://www.rayslinks.com";>Ray's Links""" >>> String 'http://www.rayslinks.com";>Ray\'s Links' Note the magically appearing back slash in my result string. Now I tiry to escape the single quote. >>> String = """http://www.rayslinks.com";>Ra

Re: [Tutor] Opening a dos exe

2010-03-13 Thread Ray Parrish
Alan Gauld wrote: "Ray Parrish" wrote but I cannot find a way of getting this information to the dos program from python. Any ideas? You could use os.system("startprogram.bat"), and create startprogram.bat to run the dos program, and feed it the files, either all at once, or one at a time vi

Re: [Tutor] First program

2010-03-13 Thread Ray Parrish
Steven D'Aprano wrote: 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

Re: [Tutor] First program

2010-03-13 Thread Ray Parrish
Alan Gauld wrote: "Ray Parrish" wrote print "A %s with dimensions %sx%s has an area of %s." % (choice, height, width, width*height) Isn't it a little more understandable to use a construct like the following? print "The area of a " + Choice + "is " str(Width) + " x " + str(Height) +

Re: [Tutor] First program

2010-03-13 Thread Ray Parrish
Luke Paireepinart wrote: On Sat, Mar 13, 2010 at 3:03 AM, Alan Gauld > wrote: "Ray Parrish" mailto:c...@cmc.net>> wrote print "A %s with dimensions %sx%s has an area of %s." % (choice, height, width, width*height) Isn'

Re: [Tutor] Escaping a single quote mark in a triple quoted string.

2010-03-13 Thread Sander Sweers
On 13 March 2010 18:33, Ray Parrish wrote: > Hello, > > I am getting the following - > String = """http://www.rayslinks.com";>Ray's Links""" String > 'http://www.rayslinks.com";>Ray\'s Links' > > Note the magically appearing back slash in my result string. It is not really there. When y

Re: [Tutor] First program

2010-03-13 Thread Ray Parrish
Luke Paireepinart wrote: 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,

Re: [Tutor] Escaping a single quote mark in a triple quoted string.

2010-03-13 Thread Steven D'Aprano
On Sun, 14 Mar 2010 04:33:57 am Ray Parrish wrote: > Hello, > > I am getting the following - > > >>> String = """http://www.rayslinks.com";>Ray's Links""" > >>> String > 'http://www.rayslinks.com";>Ray\'s Links' > > Note the magically appearing back slash in my result string. You are confusing t

Re: [Tutor] First program

2010-03-13 Thread Ray Parrish
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 stop-with-error if something wrong is entered. I t

Re: [Tutor] Escaping a single quote mark in a triple quoted string.

2010-03-13 Thread Ray Parrish
Sander Sweers wrote: On 13 March 2010 18:33, Ray Parrish wrote: Hello, I am getting the following - String = """http://www.rayslinks.com";>Ray's Links""" String 'http://www.rayslinks.com";>Ray\'s Links' Note the magically appearing back slash in my result string.

[Tutor] Problem with little program

2010-03-13 Thread Marco Rompré
Hello I have a little problem, I am trying to define a function ligneCar(n, ca) that would print n times the caracters ca. For now I have the user entering a short sentence corresponding to ca. Here is my code: def ligneCar(n,ca): c=0 while c___

Re: [Tutor] First program

2010-03-13 Thread Alan Gauld
"Ray Parrish" wrote As far as the capitalizations, it's just a habit I've held over from my Visual Basic days, and earlier programming. It's a little easier for me to pick out the individual words in a variable like ThisPerson as opposed to thisperson. thisPerson is fine for a variable

Re: [Tutor] Problem with little program

2010-03-13 Thread Alan Gauld
"Marco Rompré" wrote def ligneCar(n,ca): c=0 while c The bottom two lines are not part of the function, they will be executed when you import the file - is that really what you wantr? then in another python file I want to recall my function ligne_Car but it is not working. So show

Re: [Tutor] First program

2010-03-13 Thread Ken G.
I am using Ubuntu 9.04 and I have versions 2.6.2 and 3.0.1+ installed. Look for IDLE in Add/Remove Applications. Perhaps, you may have a different version of Ubuntu. Ken Ray Parrish wrote: Yes, I'm using 2.45.2 as that is the highest version available in the Ubuntu repositories, and I'd l

Re: [Tutor] First program

2010-03-13 Thread Luke Paireepinart
On Sat, Mar 13, 2010 at 12:04 PM, Ray Parrish wrote: > Luke Paireepinart wrote: > >> >> Your version creates at least 10 intermediate strings before outputting. >> Remember strings are immutable in Python. So you're constructing strings >> The area of a >> The area of a rectangle >> The area of a

Re: [Tutor] First program

2010-03-13 Thread Ray Parrish
Ken G. wrote: I am using Ubuntu 9.04 and I have versions 2.6.2 and 3.0.1+ installed. Look for IDLE in Add/Remove Applications. Perhaps, you may have a different version of Ubuntu. Ken Ray Parrish wrote: Yes, I'm using 2.45.2 as that is the highest version available in the Ubuntu repositorie

Re: [Tutor] Escaping a single quote mark in a triple quoted string.

2010-03-13 Thread Ray Parrish
Steven D'Aprano wrote: On Sun, 14 Mar 2010 04:33:57 am Ray Parrish wrote: Hello, I am getting the following - >>> String = """http://www.rayslinks.com";>Ray's Links""" >>> String 'http://www.rayslinks.com";>Ray\'s Links' Note the magically appearing back slash in my result string.

[Tutor] Declaring a compound dictionary structure.

2010-03-13 Thread Ray Parrish
Hello, I am stuck on the following - # Define the Dates{} dictionary structure as a dictionary # containing two dictionaries, each of which contains a list. Dates = {Today:{ThisIPAddress:[]}, Tomorrow:{ThisIPAddress:[]}} How do I pas

Re: [Tutor] Problem with little program

2010-03-13 Thread C M Caine
That's an easy mistake to make. Simply use raw_input instead of input. The former will always return a string, the latter treats whatever you enter as executable python code. You almost never want to use input. raw_input is safer. On 13 March 2010 18:56, Marco Rompré wrote: > > Hello I have a li

Re: [Tutor] Declaring a compound dictionary structure.

2010-03-13 Thread Steven D'Aprano
On Sun, 14 Mar 2010 10:06:49 am Ray Parrish wrote: > Hello, > > I am stuck on the following - > > # Define the Dates{} > dictionary structure as a dictionary > # containing two dictionaries, > each of which contains a list. > Dates = > {To

Re: [Tutor] Problem with little program

2010-03-13 Thread Alan Gauld
"C M Caine" wrote That's an easy mistake to make. Simply use raw_input instead of input. The former will always return a string, the latter treats whatever you enter as executable python code. Whilst I agree with the general principle to use raw_input, I don't see how we can say that it is t