Re: [Tutor] Bundle help!

2007-07-09 Thread Bill Burns
[Sara Johnson] > Sorry to be so confusing. Just realized a dumb mistake I made. It > doesn't need to be resorted alphabetically and numerically. I need one > list alphabetical and one numerical. > > > (Alphabetical) List 1, [('Fred', 20), ('Joe', 90), ('Kent', 50), > ('Sara', 80)] > >

Re: [Tutor] file methods

2007-07-09 Thread John Fouhy
On 10/07/07, bhaaluu <[EMAIL PROTECTED]> wrote: > >>> file.readlines() > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'str' object has no attribute 'readlines' This error here is caused by this earlier statement: > >>> file=open('text.txt').read() 'file' is now

Re: [Tutor] file methods

2007-07-09 Thread bhaaluu
Greetings, On 7/9/07, John Fouhy <[EMAIL PROTECTED]> wrote: > > The best way to find out what the functions do is to experiment with them. > > eg: > > >>> f = open('text.txt', 'r') > >>> f.readlines() > > and look at the output. I like that idea. I made a simple english plain text file, thus: fi

Re: [Tutor] file methods

2007-07-09 Thread John Fouhy
On 10/07/07, elis aeris <[EMAIL PROTECTED]> wrote: > from the document i know that if I want to open a text file I do: > > f = open("text.txt", "r+") > > and thus create f as an file object i can then use. > > however, i don't understand these functions > > .readline > .readlines > .read > .xlinesr

Re: [Tutor] file methods

2007-07-09 Thread Luke Paireepinart
elis aeris wrote: > python 3.9 File Objects of Python Library Reference > > > > from the document i know that if I want to open a text file I do: > > f = open("text.txt", "r+") > > and thus create f as an file object i can then use. > > however, i don't understand these functions > > .readline > .

[Tutor] file methods

2007-07-09 Thread elis aeris
python 3.9 File Objects of Python Library Reference from the document i know that if I want to open a text file I do: f = open("text.txt", "r+") and thus create f as an file object i can then use. however, i don't understand these functions .readline .readlines .read .xlinesread I have a

Re: [Tutor] Fastest way to iterate through a file

2007-07-09 Thread Tiger12506
It seems to me that what you need is this. http://www.python.net/crew/mhammond/win32/Downloads.html I think the key that you are missing here is that python does not include functions that you ask without downloading something special. Check the link, download those extensions, and read the docu

Re: [Tutor] Resource request

2007-07-09 Thread Alan Gauld
"Tony Noyeaux" <[EMAIL PROTECTED]> wrote > I am looking for a good online resource for > > the "def Menu" def is the command for defining a function. Menu, in this vcase, is the name of the function being defined. You will find functions explained in the Modules and Functions topic of my tut

[Tutor] Resource request

2007-07-09 Thread Tony Noyeaux
I am looking for a good online resource for the "def Menu" and/or "elif choice" commands. Any help would be much appreciated. _ Don't get caught with egg on your face. Play Chicktionary!   http://club.live.com/chicktiona

Re: [Tutor] Bundle help!

2007-07-09 Thread Alan Gauld
"Sara Johnson" <[EMAIL PROTECTED]> wrote > this is sort of a script that was written and I'm making > modifications to. Due to my serious lack of experience, > I'm afraid to rewrite anything. This is probably a long shot given the code you've posted so far, but I don't suppose there are an

Re: [Tutor] Bundle help!

2007-07-09 Thread Sara Johnson
Sorry, just needing to clarify. As I may have eluded to in other posts, this is sort of a script that was written and I'm making modifications to. Due to my serious lack of experience, I'm afraid to rewrite anything. However, would I accomplish the same result by copying the lists, then break

Re: [Tutor] Bundle help!

2007-07-09 Thread David Perlman
Maybe this reference will help: http://xahlee.org/perl-python/sort_list.html Just the first part of the discussion there. On Jul 9, 2007, at 9:54 AM, Sara Johnson wrote: > Sorry to be so confusing. Just realized a dumb mistake I made. It > doesn't need to be resorted alphabetically and numeri

Re: [Tutor] Bundle help!

2007-07-09 Thread Sara Johnson
Sorry to be so confusing. Just realized a dumb mistake I made. It doesn't need to be resorted alphabetically and numerically. I need one list alphabetical and one numerical. (Alphabetical) List 1, [('Fred', 20), ('Joe', 90), ('Kent', 50), ('Sara', 80)] (Numerical) List 2, [('

Re: [Tutor] Bundle help!

2007-07-09 Thread David Perlman
I think what you want to do is start from the beginning with two separate lists, sort each one however you want, and then either join them with zip() or simply reference them as (list1[n], list2[n]). I believe there's also a way to use zip() to separate your list of tuples into separate list

Re: [Tutor] Bundle help!

2007-07-09 Thread Alan Gauld
"Sara Johnson" <[EMAIL PROTECTED]> wrote >>Use append() to add more data, then sort again to get it in order: In [6]: data.append(('Joe', 90)) In [7]: data.sort() In [8]: data Out[8]: [('Fred', 20), ('Joe', 90), ('Kent', 50), ('Sara', 80)] > > What happens if I need to sort alphab

Re: [Tutor] Key Error

2007-07-09 Thread Alan Gauld
"jim stockford" <[EMAIL PROTECTED]> wrote >> (The tests at the end are poorly written too. > > If you'd be willing to share your strong words, I'd > be grateful to learn better alternatives. OK, The strong words referred to the entire piece and the biggest error was the lack of try/except or g