Re: [Tutor] Can't loop thru file and don't see the problem

2009-12-04 Thread Christian Witts
Roy Hinkelman wrote: Thank you very much! I had forgotten that unix URLs are case sensitive. Also, I changed my 'For' statements to your suggestion, tweaked the exception code a little, and it's working. So, there are obviously several ways to open files. Do you have a standard practice, or

Re: [Tutor] When max() doesn't work as expected

2009-12-04 Thread Alan Plum
On Fr, 2009-12-04 at 08:21 +0100, spir wrote: > By the way, is there any reason why the compare func parameter is called > 'key'? I'd guess because what you provide creates keys for the values in the collection to sort them by. What else to call it? "Comparators" compare two values, "hashes" don'

Re: [Tutor] saving output data in a file

2009-12-04 Thread Senthil Kumaran
On Fri, Dec 04, 2009 at 01:13:42PM +0530, Prasad Mehendale wrote: > I am a beginner. I want to save the output data of the following programme in > a file through the programme. Please suggest me the way. I am using Python > 2.3.3 on mandrake linux 10 and using "Idle" to save the output to a file

Re: [Tutor] saving output data in a file

2009-12-04 Thread Alan Gauld
"Prasad Mehendale" wrote I am a beginner. I want to save the output data of the following programme in a file through the programme. The easiest way is to use file redirection at run-time $ python foo.py > results.txt This will work on Linux/MacOS/Windows The alternatives are 1) open a f

Re: [Tutor] saving output data in a file

2009-12-04 Thread Alan Gauld
"Senthil Kumaran" wrote Instead of print '(Pole*RPM) product for various values of conductors/slot is: \n', polerpm You will do msg = '(Pole*RPM) product for various values of conductors/slot is: \n', polerpm You would need to do a bit more since polerpm will not automatically be appen

Re: [Tutor] saving output data in a file

2009-12-04 Thread spir
Prasad Mehendale dixit: > I am a beginner. I want to save the output data of the following programme in > a file through the programme. Please suggest me the way. I am using Python > 2.3.3 on mandrake linux 10 and using "Idle" to save the output to a file > presently. > Thanks in advance. Yo

Re: [Tutor] When max() doesn't work as expected

2009-12-04 Thread Kent Johnson
On Fri, Dec 4, 2009 at 2:21 AM, spir wrote: > Albert Sweigart dixit: > >> You need to specify an ordering function, in your case, len(): > > By the way, is there any reason why the compare func parameter is called > 'key'? It is conventional terminology - the sort key is the value the sort is d

[Tutor] How do I plot a horizontal line and a vertical line in python

2009-12-04 Thread Mkhanyisi Madlavana
How can I do this using matplotlib? The snippet of my code looks like: k = 1.195*ones((1,data[0].size)) plot(data[0], k,'--') but I get this error: Traceback (most recent call last): File "./plot_detector.py", line 26, in plot(data[0], k,'--') File "/usr/lib/pymodules/python2.6/matplotli

Re: [Tutor] Python at my work

2009-12-04 Thread skrabbit
- Original Message - From: "Alan Gauld" To: tutor@python.org Sent: Thursday, December 3, 2009 3:07:06 PM GMT -07:00 US/Canada Mountain Subject: Re: [Tutor] Python at my work Playing Devil's Advocate here... wrote > - Clean easy to read syntax > - Easy to learn But if the rest alread

[Tutor] Python equivalent to Matlab keyboard function

2009-12-04 Thread Tim Goddard
This is probably an easy one. When I was writing Matlab m-files, I really enjoyed the ability to stop the code to check how values were being stored or to 'step' into a function with the keyboard function. I have numerous 'environments'? as part of Python (x,y) including IDLE, Eclipse, and Spyder

Re: [Tutor] Python equivalent to Matlab keyboard function

2009-12-04 Thread Kent Johnson
On Fri, Dec 4, 2009 at 11:10 AM, Tim Goddard wrote: > This is probably an easy one. > > When I was writing Matlab m-files, I really enjoyed the ability to > stop the code to check how values were being stored or to 'step' into > a function with the keyboard function. > > I have numerous 'environme

[Tutor] Dictionary Comprehensions

2009-12-04 Thread Khalid Al-Ghamdi
Hi everyone! I'm using python 3.1 and I want to to know why is it when I enter the following in a dictionary comprehension: >>> dc={y:x for y in list("khalid") for x in range(6)} I get the following: {'a': 5, 'd': 5, 'i': 5, 'h': 5, 'k': 5, 'l': 5} instead of the expected: {'a': 0, 'd': 1, 'i':

Re: [Tutor] Dictionary Comprehensions

2009-12-04 Thread Lie Ryan
On 12/5/2009 7:32 AM, Khalid Al-Ghamdi wrote: Hi everyone! I'm using python 3.1 and I want to to know why is it when I enter the following in a dictionary comprehension: >>> dc={y:x for y in list("khalid") for x in range(6)} are you sure you want this? {'a': 0, 'd': 1, 'i': 2, 'h': 3, 'k': 4

Re: [Tutor] Dictionary Comprehensions

2009-12-04 Thread Hugo Arts
On Fri, Dec 4, 2009 at 9:32 PM, Khalid Al-Ghamdi wrote: > Hi everyone! > I'm using python 3.1 and I want to to know why is it when I enter the > following in a dictionary comprehension: dc={y:x for y in list("khalid") for x in range(6)} > I get the following: > {'a': 5, 'd': 5, 'i': 5, 'h': 5

Re: [Tutor] Dictionary Comprehensions

2009-12-04 Thread Emile van Sebille
On 12/4/2009 12:32 PM Khalid Al-Ghamdi said... Hi everyone! I'm using python 3.1 and I want to to know why is it when I enter the following in a dictionary comprehension: >>> dc={y:x for y in list("khalid") for x in range(6)} Try breaking this into pieces... First see what [(x,y) for y in

Re: [Tutor] Dictionary Comprehensions

2009-12-04 Thread Dave Angel
Khalid Al-Ghamdi wrote: Hi everyone! I'm using python 3.1 and I want to to know why is it when I enter the following in a dictionary comprehension: dc={y:x for y in list("khalid") for x in range(6)} I get the following: {'a': 5, 'd': 5, 'i': 5, 'h': 5, 'k': 5, 'l': 5} instead of

Re: [Tutor] Python equivalent to Matlab keyboard function

2009-12-04 Thread Tim Goddard
> > Message: 6 > Date: Fri, 4 Dec 2009 11:57:45 -0500 > From: Kent Johnson > To: Tim Goddard > Cc: tutor@python.org > Subject: Re: [Tutor] Python equivalent to Matlab keyboard function > Message-ID: >        <1c2a2c590912040857nacae64jcd9feab87af58...@mail.gmail.com> > Content-Type: text/plain; c

Re: [Tutor] python time

2009-12-04 Thread Alan Gauld
Only just spotted this. "spir" wrote It's not C's function, it's a Unix system call. It's been part of Unix since BSD 4.2 I am confused here. That's what I first thought (there _must_ be a way to get time more precise that seconds!). But on my system (ubuntu 9.10) I cannot find the proper

Re: [Tutor] Python equivalent to Matlab keyboard function

2009-12-04 Thread Alan Gauld
"Tim Goddard" wrote My problem is I can't run the code in the interactive console. If its any consolation I couldn't get Eclipse's interactive session working well either. However... I guess I'll have to spend some time reading more about eclipse and getting the interactive feature wor

Re: [Tutor] saving output data in a file

2009-12-04 Thread Dave Kuhlman
On Fri, Dec 04, 2009 at 01:13:42PM +0530, Prasad Mehendale wrote: > I am a beginner. I want to save the output data of the following programme in > a file through the programme. Please suggest me the way. I am using Python > 2.3.3 on mandrake linux 10 and using "Idle" to save the output to a file