[Tutor] taking a tuple with input

2013-10-26 Thread Sven Hennig
Hey Guys, i'm running Python 3.3.2 on Windows 7 64 Bit I am writing a little script for practice and got a little problem. I wrote a class which got two points in the constructor (p1 and p2). With the function distanceOf from my class i measure the distance between these two points. Everything wo

Re: [Tutor] taking a tuple with input

2013-10-26 Thread Mark Lawrence
On 26/10/2013 04:09, Sven Hennig wrote: Hey Guys, i'm running Python 3.3.2 on Windows 7 64 Bit I am writing a little script for practice and got a little problem. I wrote a class which got two points in the constructor (p1 and p2). With the function distanceOf from my class i measure the distan

Re: [Tutor] taking a tuple with input

2013-10-26 Thread Alan Gauld
On 26/10/13 04:09, Sven Hennig wrote: So how can i get an int tuple with input? You can't. input() reads strings. (assuming Python v3) You need to convert the string yourself. For simple floats you just call float() but there isn't an equivalent conversion function for tuples. You probably wa

Re: [Tutor] Python and memory allocation

2013-10-26 Thread Steven D'Aprano
On Thu, Oct 24, 2013 at 05:21:56PM +, Dave Angel wrote: > If you > want a surprise, try the following simple program some time. > > import sys > print(sys.modules) > > when I tried that interactively on 2.7, it printed some 240+ names. Wow. What were you doing? Ah, I bet you had imported nu

Re: [Tutor] Python and memory allocation

2013-10-26 Thread Mark Lawrence
On 26/10/2013 13:20, Steven D'Aprano wrote: On Thu, Oct 24, 2013 at 05:21:56PM +, Dave Angel wrote: If you want a surprise, try the following simple program some time. import sys print(sys.modules) when I tried that interactively on 2.7, it printed some 240+ names. Wow. What were you do

[Tutor] why does platform.architecture default to sys.executable?

2013-10-26 Thread Albert-Jan Roskam
Hi, Why does the "executable" parameter default to sys.executable? Yesterday I was surprised to see platform.architecture return "32bit" on a 64-bit system, just because a 32-bit Python interpreter was installed. Wouldn't this make more sense: import sys, platform pf = sys.platform.lower()[:3

Re: [Tutor] why does platform.architecture default to sys.executable?

2013-10-26 Thread Amit Saha
On Sun, Oct 27, 2013 at 2:39 AM, Albert-Jan Roskam wrote: > Hi, > > Why does the "executable" parameter default to sys.executable? Yesterday I > was surprised to see platform.architecture return "32bit" on a 64-bit > system, just because a 32-bit Python interpreter was installed. Wouldn't > this m

Re: [Tutor] why does platform.architecture default to sys.executable?

2013-10-26 Thread Amit Saha
On Oct 27, 2013 2:51 AM, "Amit Saha" wrote: > > On Sun, Oct 27, 2013 at 2:39 AM, Albert-Jan Roskam wrote: > > Hi, > > > > Why does the "executable" parameter default to sys.executable? Yesterday I > > was surprised to see platform.architecture return "32bit" on a 64-bit > > system, just because a

Re: [Tutor] why does platform.architecture default to sys.executable?

2013-10-26 Thread Albert-Jan Roskam
--- On Sat, 10/26/13, Amit Saha wrote: Subject: Re: [Tutor] why does platform.architecture default to sys.executable? To: "Albert-Jan Roskam" Cc: "Python Mailing List" Date: Saturday, October 26, 2013, 6:51 PM On Sun, Oct 27, 2013 at 2:39 AM, Alb

Re: [Tutor] why does platform.architecture default to sys.executable?

2013-10-26 Thread Alan Gauld
On 26/10/13 18:13, Amit Saha wrote: a 64-bit system. Then, you can read /proc/cpuinfo and look for the lm flag. If it is present, it is a 64-bit system, But that will only work on *nix systems I assume? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.fli

Re: [Tutor] why does platform.architecture default to sys.executable?

2013-10-26 Thread eryksun
On Sat, Oct 26, 2013 at 12:39 PM, Albert-Jan Roskam wrote: > > Why does the "executable" parameter default to sys.executable? In general platform.architecture() parses the output of the UNIX "file" command. But on Windows the linkage is hard coded to 'WindowsPE', and bits is the default value cal

[Tutor] taking a tuple with input

2013-10-26 Thread Siva Cn
p1 = tuple([float(ele) for ele in input('Please type ...').split()]) p2 = tuple([float(ele) for ele in input('Please type ...').split()]) # input format is : 25.0 30.0 - *Siva Cn* *Python Developer* *http://www.cnsiva.com* -

[Tutor] Question about conditions and empty values

2013-10-26 Thread Shelby Martin
For the program below, if I enter "0" at the prompt, it provides the reply "Please, sit. It may be a while". However, if I just press the Enter key, it shuts the program down without a reply from the Maitre D'. My question is this - the author of this exercise states the condition is False if eith

Re: [Tutor] Question about conditions and empty values

2013-10-26 Thread Alan Gauld
On 26/10/13 20:13, Shelby Martin wrote: My question is this - the author of this exercise states the condition is False if either zero or "empty" is the value. I'm assuming he means that empty is just pressing Enter without entering a number? Normally that would be correct but... money = in

Re: [Tutor] taking a tuple with input

2013-10-26 Thread Mark Lawrence
On 26/10/2013 20:32, Siva Cn wrote: p1 = tuple([float(ele) for ele in input('Please type ...').split()]) p2 = tuple([float(ele) for ele in input('Please type ...').split()]) # input format is : 25.0 30.0 - *Siva Cn* *Python Developer* *http://www.cnsiva.com* ---

Re: [Tutor] taking a tuple with input

2013-10-26 Thread Alan Gauld
On 26/10/13 20:32, Siva Cn wrote: p1 = tuple([float(ele) for ele in input('Please type ...').split()]) If you do it all in one line like that you dpn;t need the [] inside the tuple() call. The generator expressoion will work directly. But of course a single line like that will be hard to de

Re: [Tutor] why does platform.architecture default to sys.executable?

2013-10-26 Thread Amit Saha
On Sun, Oct 27, 2013 at 7:46 AM, Alan Gauld wrote: > On 26/10/13 18:13, Amit Saha wrote: > >> a 64-bit system. Then, you can read /proc/cpuinfo and look for the lm >> flag. If it is present, it is a 64-bit system, > > > But that will only work on *nix systems I assume? Indeed, both my answers ass