[Tutor] saving output data in a file

2009-12-03 Thread Prasad Mehendale
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. #programme to calculate various parame

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

2009-12-03 Thread spir
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'? Denis la vita e estrany http://spir.wikidot.com/ _

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

2009-12-03 Thread Lie Ryan
On 12/4/2009 1:22 PM, Kent Johnson wrote: max() finds the 'largest' in sort order. Strings sort in dictionary order so the max of a list strings will be the one that comes last in dictionary order.\ To prevent confusion: When Kent said "dictionary order" it means real-life dictionary, the thic

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

2009-12-03 Thread wescpy
On Dec 3, 2009, at 18:25, Hugo Arts wrote: On Fri, Dec 4, 2009 at 2:08 AM, Tony Cappellini wrote: I have a list of 2300 strings. When I call max() on the list, it returned an item with 37 characters. I am only passing 1 argument to max(). I know for a fact that the largest item has 57 c

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

2009-12-03 Thread Albert Sweigart
max() for strings returns the largest string in an alphabetical sense. So max(['z', 'aa']) would return 'z'. You need to specify an ordering function, in your case, len(): max( ['z', ''], key=len) ...which will return '' because it is ordering by key. -Al Sweigart

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

2009-12-03 Thread Hugo Arts
On Fri, Dec 4, 2009 at 2:08 AM, Tony Cappellini wrote: > > I have a list of 2300 strings. > > When I call max() on the list, it returned an item with 37 characters. I am > only passing 1 argument to max(). > I know for a fact that the largest item has 57 characters, and when I > called mylist.ind

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

2009-12-03 Thread Lie Ryan
On 12/4/2009 12:08 PM, Tony Cappellini wrote: What are the assumptions when calling max on a list of strings? Does the list need to be sorted? In my case, the list is sorted. max determines whether one is larger than the other with "<" operator. max on a list of string will determine the last

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

2009-12-03 Thread Kent Johnson
On Thu, Dec 3, 2009 at 8:08 PM, Tony Cappellini wrote: > > I have a list of 2300 strings. > > When I call max() on the list, it returned an item with 37 characters. I am > only passing 1 argument to max(). > I know for a fact that the largest item has 57 characters, and when I > called mylist.ind

Re: [Tutor] Example of use of (?P) and (?P=name) in Python regular expressions?

2009-12-03 Thread Michael Hannon
Hi, folks. I just wanted to thank Martin Walsh and Kent Johnson, both of whom furthered my education by replying (on-list) that the "P=" syntax is used to refer to a named group in the same regular expression, i.e., the one in which the "P" construct was used in the first place. This is as opp

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

2009-12-03 Thread Tony Cappellini
I have a list of 2300 strings. When I call max() on the list, it returned an item with 37 characters. I am only passing 1 argument to max(). I know for a fact that the largest item has 57 characters, and when I called mylist.index('my_57_character_string') the index was found. Printing len(mylist

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

2009-12-03 Thread Roy Hinkelman
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 does it depend on the fil

Re: [Tutor] Python at my work

2009-12-03 Thread Alan Gauld
Playing Devil's Advocate here... wrote - Clean easy to read syntax - Easy to learn But if the rest already know Perl that's not such a compelling argument. - Object Oriented as needed - Large community Yep, Perl does that too. - Multi-platform Yep, Perl too. - Fits in your head

Re: [Tutor] Python at my work

2009-12-03 Thread bob gailer
skrab...@comcast.net wrote: My dept at work is reviewing all the different programming languages that we use and Python is kind of on the chopping block because I'm the only one using it so far. Basically, it would mean that no new development would be done in Python. If most of the developers

Re: [Tutor] working with bit arrays

2009-12-03 Thread GilJohnson
Dave Angel ieee.org> writes: > Once you have an *array* of integers, you have much more than 32 bits to > work with. For example, with an array of size 10, you now have 320 bits > to work with. He's just pointing out that it's a little bit awkward to > address a group of bits that are not al

Re: [Tutor] Python at my work

2009-12-03 Thread Stefan Behnel
skrab...@comcast.net, 03.12.2009 18:46: > My dept at work is reviewing all the different programming languages > that we use and Python is kind of on the chopping block because I'm > the only one using it so far. Basically, it would mean that no new > development would be done in Python. > > What

Re: [Tutor] Python at my work

2009-12-03 Thread Kent Johnson
On Thu, Dec 3, 2009 at 12:46 PM, wrote: > What I need to do is show that Python is a good tool and it should be > in our toolbox. The other language that would be used instead of > Python is Perl. Perl is currently used more in our dept. I can't say > I'm a big fan of Perl, but I'll use if I hav

Re: [Tutor] Python at my work

2009-12-03 Thread Eric Pavey
On Thu, Dec 3, 2009 at 10:13 AM, Steve Bricker wrote: > We have Python applications for work with testing reports printed to PDF > files. Don't know if you have that needed. > > Steve Bricker > Now blogging at srbricker.blogspot.com > > On Thu 09/12/03 11:46 , skrab...@comcast.net sent: > > My de

Re: [Tutor] Python at my work

2009-12-03 Thread Steve Bricker
BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }We have Python applications for work with testing reports printed to PDF files. Don't know if you have that needed. Steve Bricker Now blogging at srbricker.blogspot.com On Thu 09/12/03 11:46 , skrab...@comcast.net sent: My de

[Tutor] Python at my work

2009-12-03 Thread skrabbit
My dept at work is reviewing all the different programming languages that we use and Python is kind of on the chopping block because I'm the only one using it so far. Basically, it would mean that no new development would be done in Python. What I need to do is show that Python is a good tool and

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

2009-12-03 Thread Christian Witts
Roy Hinkelman wrote: Your list is great. I've been lurking for the past two weeks while I learned the basics. Thanks. I am trying to loop thru 2 files and scrape some data, and the loops are not working. The script is not getting past the first URL from state_list, as the test print shows

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

2009-12-03 Thread Roy Hinkelman
Your list is great. I've been lurking for the past two weeks while I learned the basics. Thanks. I am trying to loop thru 2 files and scrape some data, and the loops are not working. The script is not getting past the first URL from state_list, as the test print shows. If someone could point me