Re: [Tutor] Performance difference, ``in'' vs ``has_key()''

2005-07-17 Thread Max Noel
On Jul 17, 2005, at 20:18, Bill Campbell wrote: Is there any significant performance difference between the tests, ``key in dictionary'' and ``dictionary.has_key(key)''? I would prefer using the ``key in'' because it's a bit easier to type, and can also be used with lists in addition to

Re: [Tutor] Questions on file.read

2005-07-14 Thread Max Noel
On Jul 14, 2005, at 12:26, Negroup - wrote: To read a file's contents, call f.read(size), which reads some quantity of data and returns it as a string. size is an optional numeric argument. When size is omitted or negative, the entire contents of the file will be read and returned; it's your

Re: [Tutor] Storing Data Records in XML File

2005-07-12 Thread Max Noel
On Jul 12, 2005, at 18:44, Gooch, John wrote: I have a Python script that stores the results of the processing that it does in a database, but it has to have an alternate way of storing its data in a database-friendly way (XML)in case the database is not available ( connected down, data

Re: [Tutor] Passing Arguments

2005-07-09 Thread Max Noel
On Jul 9, 2005, at 11:17, Don Parris wrote: get_Name(prt_Name) # Calling get_Name with prt_Name as the argument produces this: C:\Python24python scripts\learning.py f function prt_Name at 0x00AEBEF0 At least it found the function. That's little shy of a miracle for me. :) However, I would

Re: [Tutor] max(len(item)) for cols

2005-06-17 Thread Max Noel
On Jun 17, 2005, at 11:58, Jnos Juhsz wrote: Dear Guys, I have a 2D array: [['1', '2 ', '3'], ['longer ', 'longer', 'sort']] How can I get what is the max(len(item)) for the columns ? I would like to get a list with the max_col_width values. I hope that, it can wrote

Re: [Tutor] can't see emacs timer in action

2005-06-14 Thread Max Noel
On Jun 14, 2005, at 22:56, Pujo Aji wrote: Hello, I tried this code in emacs. for i in range(3): time.sleep(1) print i It shows the result but total result not second per second. Any one experiance this problem pujo Works for me... How do you run it? Do you use a separate

Re: [Tutor] can't see emacs timer in action

2005-06-14 Thread Max Noel
On Jun 14, 2005, at 23:17, Pujo Aji wrote: I just use Ctrl+C Ctrl+C to run the code. The code wait for 3 second and show all i all together. I can't feel every second pass. pujo Try running your script from a terminal (outside of emacs, that is). -- Max maxnoel_fr at yahoo dot fr

Re: [Tutor] Print behaviour inside a loop?

2005-06-11 Thread Max Noel
On Jun 12, 2005, at 00:42, Simon Gerber wrote: Any hints? I looked up the python reference manual, but couldn't find any way to force print statements to draw. Should I be looking into threads, perhaps? I/O in Python is buffered -- that is, it uses RAM whenever possible to delay the

Re: [Tutor] repr()

2005-06-07 Thread Max Noel
On Jun 7, 2005, at 20:42, Bernard Lebel wrote: repr( myFunc ) Wich returns 'function myFunc at 0x009C6630' Okay then I run s = repr( myFunc() ) print s Wich returns 'None' That's perfectly normal. Your last assignment calls the function, then assigns to s the

Re: [Tutor] quick PIL question

2005-06-02 Thread Max Noel
On Jun 2, 2005, at 23:39, Terry Carroll wrote: The palette mode (P) uses a colour palette to define the actual colour for each pixel. Not sure what that means, exactly, but it looks like im.palette will get the palette of a a P-mode image, and im.putpalette will change it.

Re: [Tutor] Filtering Spreadsheet Data

2005-05-24 Thread Max Noel
On May 24, 2005, at 14:22, Mike Hansen wrote: Excel has some nice database-like queries itself. Take a look at Advanced Filter in Help. You can essentially query a worksheet and even send the results to a different worksheet. I'd imagine that once you got the query working, you could

Re: [Tutor] Python won't play wav file

2005-05-24 Thread Max Noel
On May 24, 2005, at 02:49, Joseph Quigley wrote: ... to play a .wav music file. I tried w.play() but got an error that module has no attribute 'play'. What do I use to get it to play? Thanks, The wave module is meant to read, write and manipulate (transform, filter, whatever) WAV

Re: [Tutor] looking for a pattern in a lot of files

2005-05-22 Thread Max Noel
On May 22, 2005, at 21:07, Jonas Melian wrote: for line in fileinput.input(glob.glob(os.path.join (dir_locales, *_[A-Z][A-Z]))): if re.search(locale for, line): print line If you're only looking for the occurrence of a string and not a regex pattern, you don't

Re: [Tutor] dictionary values in strings

2005-05-19 Thread Max Noel
On May 19, 2005, at 20:49, William O'Higgins wrote: I am trying to discover the syntax for call on a dictionary of lists by key and index. The data structure looks like this: dol = {'key1':['li1','li2','li3'],'key2':['li1','li2','li3'],\ 'key3':['li1'li2,'li3','']} The keys are

Re: [Tutor] diving into py question

2005-05-19 Thread Max Noel
On May 19, 2005, at 22:18, Chelan Farsight wrote: I am using the online book Dive Into Python. I ran the first program given and have run into an error on line 7 at the colon. Now I imagine that there is probably a corrections page at the site, but I am interested in knowing why it won't

Re: [Tutor] diving into py question

2005-05-19 Thread Max Noel
On May 19, 2005, at 22:46, Chelan Farsight wrote: Thanks! You were right about the double underscore, however, I am still getting the error on line 7...hrmm any other ideas? In your original code, the space between if and __main__ is also missing. This may be the source of the

Re: [Tutor] kernel serie

2005-05-19 Thread Max Noel
On May 19, 2005, at 23:28, Jonas Melian wrote: I want get the kernel serie, so 2.x only (2.6 or 2.4) info_kernel = platform.release() # get the kernel version info_kernel = '.'.join(info_kernel.split('.',2)[:2]) is there any way of get it in one line only? Based on your code, that'd

Re: [Tutor] using -i flag with '''if __name__ == __main__:'''

2005-05-19 Thread Max Noel
On May 19, 2005, at 23:05, Terry Carroll wrote: Thanks to you both. I think I may need to step up my development environment beyond emacs and a command line. Actually, if you're having problems with debugging your problem, what you should step up is your approach to debugging/testing.

Re: [Tutor] Perl equivalent of $#var

2005-05-17 Thread Max Noel
On May 17, 2005, at 22:00, Smith, Jeff wrote: Is there a more Pythonic way to get the Perl equivalent of $#var other than len(var) - 1 AFAIK, len(var) - 1 is the only way. Note, however, that the last element of a list (or of any ordered sequence) can be obtained with the

Re: [Tutor] Directory not empty :: Fast mode

2005-05-16 Thread Max Noel
On May 16, 2005, at 18:30, Jonas Melian wrote: To knowing if a directory isn't empty, I use: dir_example = /usr/foo/ if glob.glob(os.path.join(dir_example, *)): ... But, as it has to expand all files, i'm supposed that it's a little slow to simply knowing if a directory is

Re: [Tutor] How to verify all things are equal to one another

2005-05-15 Thread Max Noel
On May 15, 2005, at 06:54, Terry Carroll wrote: if (a == b a == c a == d a == e a == f a == g): do stuff Well, you can already try this: if a == b == c == d == e == f == g: do stuff -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you

Re: [Tutor] help: space formatting for multiplication table

2005-05-14 Thread Max Noel
On May 14, 2005, at 20:09, Aaron Elbaz wrote: The idea is to print out a multiplication table on the command line with numbers lining up in the ones column. I want to eventually emulate programs like top with their spacing. But this code is mostly for my amusement. How would you make this

Re: [Tutor] Simple string processing problem

2005-05-13 Thread Max Noel
On May 13, 2005, at 20:36, [EMAIL PROTECTED] wrote: Hi, i am a Biology student taking some early steps with programming. I'm currently trying to write a Python script to do some simple processing of a gene sequence file. Welcome aboard! A line in the file looks like: SCER

Re: [Tutor] Linux variable to Python

2005-05-13 Thread Max Noel
On May 13, 2005, at 21:03, Alberto Troiano wrote: os.system(fec=cam`date +%Y%m%d%H%M%S`.jpg) 0 os.system(echo $fec) 0 os.system(mv hola.txt grabacion/$fec) 0 Then I check for the file and turns out that it moved hola.txt to grabacion with the same name I think that for some

Re: [Tutor] Testing for commandline args

2005-05-13 Thread Max Noel
On May 14, 2005, at 01:30, William O'Higgins wrote: if sys.argv[1]: do stuff else: do different stuff If I have arguments, the different stuff happens beautifully, thank you very much. If I don't have arguments I get this: if sys.argv[1]: IndexError: list index out of range]

Re: [Tutor] character format

2005-05-12 Thread Max Noel
On May 12, 2005, at 02:42, Tony Meyer wrote: From the email address, chances are that this was a New Zealand cultural assumption. Ah, the French, lumping all English speakers under the American banner wink. Touché. :D -- Max ( What makes it even more unforgivable is that I'm

Re: [Tutor] character format

2005-05-12 Thread Max Noel
On May 12, 2005, at 03:00, [EMAIL PROTECTED] wrote: As was pointed out, I'm not American. I guess the problem stems from an American cultural assumption, though, in that Americans (I think) developed the ASCII character set without any thought for other languages. At that time,

Re: [Tutor] Help with Challenge number 5

2005-05-12 Thread Max Noel
On May 13, 2005, at 01:30, Jacob S. wrote: Okay, I've tried pickling, marshal, marshalling, serialization, and amazingly pi because I noticed that pickle was under the section 3.14 however, none of this worked, so, I hate to ask again but, could you go one step farther? Thanx, Jacob

Re: [Tutor] python challenges

2005-05-11 Thread Max Noel
On May 11, 2005, at 07:23, Liam Clarke wrote: Ack, banner.p eh? Can anyone explain the significance of the numbers? Are they columns? Regards, Liam Clarke As I said, read about Run-Length Encoding. -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic

Re: [Tutor] character format

2005-05-11 Thread Max Noel
On May 12, 2005, at 02:22, D. Hartley wrote: Max - yep, and the hint was BUSY (... BZ...)... Unfortunately that hint doesnt lead me anywhere (except to bz2, which involves compression, and didnt seem very likely). I went through and removed all the \x## 's that represented

Re: [Tutor] How do I squish this bug?

2005-05-09 Thread Max Noel
On May 9, 2005, at 17:57, Joseph Quigley wrote: Why do I get the error: NameError: global name 'main' is not defined when switching between the two module twice (ie: type: jargon type:back() type:jargontype:back() )? Thanks JQ Namespaces. Each module has its own

Re: [Tutor] zip question

2005-05-09 Thread Max Noel
On May 10, 2005, at 01:18, D. Hartley wrote: I admitted that my grasp of classes (and constructors) is a bit fuzzy. I did get this particular class to work, and got the first half of the problem done. However, now i'm working in another class, zipinfo. It says: Instances of the ZipInfo

Re: [Tutor] Generator function question?

2005-05-07 Thread Max Noel
On May 7, 2005, at 12:28, John Clark wrote: My question - the creation of the global variable x seems kludged - when I first started with this I thought I was going to be coding something like sys.stderr.write('\b'+neverEndingStatus()) but that just returns '\' each time and I now

Re: [Tutor] Generator function question?

2005-05-07 Thread Max Noel
On May 7, 2005, at 13:22, John Clark wrote: (Either that, or I am not following what you mean when you say: As for how to access it, use a for loop (for i in neverEndingStatus()). xrange, for example, is a generator function. Can you please provide an example of how my Test1()

Re: [Tutor] python challenges

2005-05-07 Thread Max Noel
On May 7, 2005, at 13:17, John Carmona wrote: Hi to everybody reading this thread, can anybody point me to the URL where I can find these challenges. Many thanks JC http://www.pythonchallenge.com/ -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic

Re: [Tutor] Generator function question?

2005-05-07 Thread Max Noel
On May 7, 2005, at 15:06, Max Noel wrote: Try the following code: for i in neverEndingTest(): print i Sorry, i meant for in in neverEndingStatus() (not neverEndingTest()), where neverEndingStatus is the function I gave as an example in my previous post (not your

Re: [Tutor] python challenges

2005-05-07 Thread Max Noel
On May 7, 2005, at 20:50, D. Hartley wrote: Ok, I hate to ask another question about this riddle. But I have looked and looked and looked. Where can I find more information on 'banner'? Everywhere I look it starts telling me about banner ads and so on, and that is not what I want!

Re: [Tutor] Else in list comprehension

2005-05-07 Thread Max Noel
On May 8, 2005, at 03:02, Bernard Lebel wrote: Hello, I just started using list comprehensions (loving them!) I know you can add an if statement, but can you put in there an else? I could not find an example of this. Apparently, no. I just tried: b = [i for i in range(10) if (i %

Re: [Tutor] python challenges

2005-05-06 Thread Max Noel
On May 6, 2005, at 21:40, D. Hartley wrote: I figured out what module you're supposed to use for 5, and the thing that kills me is it's a module I've actually *used* too! But I don't know what to . man this is hard to say without using a spoiler. I dont know what particular thing to

Re: [Tutor] python challenges

2005-05-06 Thread Max Noel
On May 6, 2005, at 21:57, Tim Peters wrote: What do you have against PIL wink? Nothing in particular, just no idea how to use it. simple ways has been part of the fun for me. I don't know how you solved level 7, Hint: it's a stupid and inelegant method involving a certain

Re: [Tutor] python challenges

2005-05-06 Thread Max Noel
On May 6, 2005, at 22:20, D. Hartley wrote: Yes, I realized my original guess was wrong. I think I found the target file but now none of the module commands I'm used to will do anything useful on it. I'm just getting file not found errors and the like. There's something in the big picture

Re: [Tutor] python challenges

2005-05-06 Thread Max Noel
On May 6, 2005, at 22:32, D. Hartley wrote: Maybe that's my problem. I dont know how to save this particular file onto my computer first. I can't 'reach' it from the url. It's not like a picture I can right click on and save image, or something. My first thought was i needed to use the

Re: [Tutor] Python riddles

2005-05-05 Thread Max Noel
On May 5, 2005, at 00:53, [EMAIL PROTECTED] wrote: As seen on python-announce (via Dr Dobbs): http://www.pythonchallenge.com/ Good fun! Very interesting indeed! I'm stuck on number 7, though -- looks like it requires the use of PIL, which I've never used before. -- Max maxnoel_fr

Re: [Tutor] Fwd: Python riddles

2005-05-05 Thread Max Noel
On May 5, 2005, at 19:39, D. Hartley wrote: Ok, now, I'm sure this sounds like a very dumb question. But I clicked on riddle 1, and I don't know how this thing works - about didnt give a lot of extra info. Am I trying to duplicate something on my screen that looks like the picture on the

Re: [Tutor] python challenges

2005-05-05 Thread Max Noel
On May 6, 2005, at 01:33, D. Hartley wrote: They do seem to be useful! But with all those special characters, it certainly doesnt make for an easy read. I think I'm making some progress - I got it to make me a list of all the {uppercaseuppercaseuppercaselowercaseuppercaseuppercaseuppercase}

Re: [Tutor] Psyco (Joseph Quigley)

2005-05-04 Thread Max Noel
On May 4, 2005, at 16:35, Joseph Quigley wrote: For those who use Psyco: Is it any good? I'm searching for instructions on how to use it, should I stop? I hear it's quite good at what it does. Note, however, that it only works on x86 computers (i.e. IBM PC compatibles).

Re: [Tutor] Problem with threading

2005-05-03 Thread Max Noel
On May 3, 2005, at 08:57, Danny Yoo wrote: I believe that cron has a resolution of a minute, so now it doesn't sound that cron is so viable. But how about writing a program that just continues to run as a daemon service in the background? A simple example is something like:

Re: [Tutor] Problem with threading

2005-05-03 Thread Max Noel
On May 3, 2005, at 20:52, Danny Yoo wrote: ## cron(8) examines cron entries once every minute. The time and date fields are: field allowed values - -- minute 0-59 hour

Re: [Tutor] guess the number game help

2005-04-30 Thread Max Noel
On Apr 30, 2005, at 09:49, Diana Hawksworth wrote: Hello list!   I have started teaching Python to a group of High School students. I set them the Guess the Number game as a GUI as an assignment. One of the students has passed in some script that is foreign to any tutorial work we have done. 

Re: [Tutor] guess the number game help

2005-04-30 Thread Max Noel
On Apr 30, 2005, at 19:50, Alan Gauld wrote: If my student has plagiarised - I need to know. Could you ask him(?) to explain some of the more interesting features? Maybe how he came up with the variable names? It is possible that he/she has come up with it themselves since its not really a great

Re: [Tutor] cPickle (Joseph Q.)

2005-04-29 Thread Max Noel
On Apr 29, 2005, at 04:48, Joseph Quigley wrote: Hi all, How could I have the user name his file? I learned that I type file_name = foo.bar How could I make it that the use could name it hello.hi? Thanks, Joe Well, all you have to do is have the user input a string, and use this

Fwd: [Tutor] cPickle (Joseph Q.)

2005-04-29 Thread Max Noel
Begin forwarded message: From: Joseph Quigley [EMAIL PROTECTED] Date: April 29, 2005 17:16:22 BST To: Max Noel [EMAIL PROTECTED] Subject: Re: [Tutor] cPickle (Joseph Q.) I tried that and it doesn't work! I type the name and it just sits there! Here's the code: # variables name = JOTEX versn

Re: [Tutor] Help with daemon

2005-04-28 Thread Max Noel
On Apr 28, 2005, at 23:06, Alberto Troiano wrote: I tried: import os os.system(ps --user root) and I get 0 as a return How can I get the PID and bind the command above with a variable?? I mean varusername=root os.system(ps --user varusername) works??? So in essence, what you're trying to do

Re: [Tutor] Help with daemon

2005-04-27 Thread Max Noel
On Apr 27, 2005, at 22:35, Alberto Troiano wrote: I'm gonna give you an example: The program will check for new users and to check record time every 10 seconds. But first the program will have to finish the checking process that started before so it won't be 10 seconds right? Unless I have one

Re: [Tutor] font/text in pygame

2005-04-26 Thread Max Noel
On Apr 26, 2005, at 23:57, D. Hartley wrote: But in any case, font/text will only take strings - i cant pass in a list, or an index to an item in a list (which is, in this case, a tuple), and since the items in the list will be changed and updated obviously i cant just type in the items as strings

Re: [Tutor] properties and subclasses

2005-04-26 Thread Max Noel
On Apr 26, 2005, at 22:01, Alan Gauld wrote: I had found the first thread you linked. I see what you mean about the cure -- my general belief is that *I* am unlikely to have problems for which meta-classes are really the best solution :-) Once you get used to them meta-classes are very useful.

Re: [Tutor] Highlighting instructions: pedagogical preferences

2005-04-25 Thread Max Noel
On Apr 25, 2005, at 17:03, André Roberge wrote: I'm writing a program interpreter which has two windows: a program editing window and a program output window. The interpreter can either step through the program automatically, at a slow pace, or step through the program one instruction at a

Re: [Tutor] saving?

2005-04-24 Thread Max Noel
On Apr 24, 2005, at 18:04, Gavin Bauer wrote: I've decided it would be cool to make a flashcard program. You would start by entering all of the cards and their answers, then it would ask you them in random order, with ones you get right coming up less often, and ones you consistantly get wrong

Re: [Tutor] Re: [Pythonmac-SIG] Weird import problem with PythonIDE on Mac (was 'import problem')

2005-04-23 Thread Max Noel
On Apr 22, 2005, at 11:41, Chris Smith wrote: Do you have a suggestion as to what can I give a module so it has enough information to execute a function that resides in __main__? Here is a visual of what is going on: --__main__ def y1(): pass import foo foo.run(string_from_main) #what

Re: [Tutor] Newbie Question:Regarding Command line Parsing and Run Unix Shell Command

2005-04-23 Thread Max Noel
On Apr 22, 2005, at 21:09, Prasad Kotipalli wrote: Hello evryone I am a newbie to python. I have a makefile which i can compile in UNIX/LINUX, But i I am planning to write a python script which actually does what my MAKEFILE does. Then what you want is SCons (http://www.scons.org/). Haven't

Re: [Tutor] TKinter and things over Linux

2005-04-20 Thread Max Noel
On Apr 20, 2005, at 16:52, Alberto Troiano wrote: Hey Didn't work I try the python2.3 setup.py build I couldn't print the exact error because it's a lot of pages that says mostly the same the final error says error: mysql ended exit with status 1 I run the other command python2.3 setup.py

Re: [Tutor] crash - switching between text window and graphics/gamewindow (high score)

2005-04-20 Thread Max Noel
On Apr 20, 2005, at 23:57, Alberto Troiano wrote: Hi The thing is this I get an error that says sort() has no arguments Th error is in the sentence high_score.sort(reverse=TRUE) If you put just sort() it will work but the list will show from low to high and we don't want that 'cause if you make a

Re: [Tutor] crash - switching between text window and graphics/gamewindow (high score)

2005-04-20 Thread Max Noel
On Apr 21, 2005, at 00:19, D. Hartley wrote: Max - I thought it might be a version issue as well, thanks. Also, good luck on your paper! 50 pages, whoo! Haven't done that since grad school, my condolences man. ~Denise :) Thanks... I'm almost done now, only a few more pages and all that will be

Re: [Tutor] TKinter and things over Linux

2005-04-19 Thread Max Noel
On Apr 19, 2005, at 13:49, Alberto Troiano wrote: Hi I have another problem. It seems that I manage to solve a problem and run into another The problem is that now I can't install MySQLdb (MySQL database module for Python 2.3.4) I try to ./configure and it prints a lot of crap and then says

Re: [Tutor] TKinter and things over Linux

2005-04-19 Thread Max Noel
On Apr 19, 2005, at 19:57, Alberto Troiano wrote: Thanks Danny I will try to do that and let you know how it went But one question thou, does it matter the location where I gunzip the distutil If so where should I put it??? NOTE: It's just to be sure that I'm understanding

Re: [Tutor] Dynamically composing a module name

2005-04-19 Thread Max Noel
On Apr 19, 2005, at 21:22, Tim Johnson wrote: Hello Pythonmeisters: Is it possible to dynamically compose a module name for import? Pointers to documentation or other discussions would be sufficient at this time. thanks Ah, metaprogramming. I must admit I can't think of a way. Or rather, I did

Re: [Tutor] Problems with encodings

2005-04-18 Thread Max Noel
On Apr 18, 2005, at 16:55, Olli Rajala wrote: Michael, does it help if you change the second line into: # -*- coding: iso-8859-15 -*- ? I *think* that is the correct syntax (at least it works for me). Thanks, it doesn't give the error message anymore. But non-ascii letters still don't go well from

Re: [Tutor] Of fish and foul...(aka the Perl require command)

2005-04-18 Thread Max Noel
On Apr 18, 2005, at 19:59, Smith, Jeff wrote: Is there a Python equivalent to the Perl require 5.6.0 Which enforces a minimum interpreter version? As far as I know, no. But: import sys sys.version_info (2, 3, 0, 'final', 0) (2, 4, 0) sys.version_info True (2, 2, 0) sys.version_info False

Re: [Tutor] unrelated sound error - pygame, or other?

2005-04-18 Thread Max Noel
On Apr 18, 2005, at 23:18, D. Hartley wrote: Another quick question. I tried to send a file to my friend to test it out, and it gave her the following sound-related error: Cannot load sound: data\explode2.wav Traceback (most recent call last): File D:\Python24\play w paused screen residue.py,

Re: [Tutor] Has anyone ever tried to convert the textual output of the dis module to another language

2005-04-17 Thread Max Noel
On Apr 17, 2005, at 16:51, Sean Perry wrote: R. Alan Monroe wrote: Just curious. Googling for 'python dis module convert another language ' only got two hits. So maybe no one is trying it? I was just daydreaming about a native python compiler, and wondered how feasible it would be. There is

Re: [Tutor] More Function Questions (Joseph Q.)

2005-04-17 Thread Max Noel
On Apr 17, 2005, at 17:29, Joseph Quigley wrote: So what do you use the def bar(x, y): return x + y bar(4, 5) functions for? (I just need a simple example) Whenever you have something that you may want to do more than once and/or in more than one place in your program. Here's a small

Re: [Tutor] high score lists

2005-04-15 Thread Max Noel
On Apr 15, 2005, at 03:32, [EMAIL PROTECTED] wrote: Interestingly, the key argument is the solution to this problem: arr = zip(range(10), range(10,0,-1)) arr [(0, 10), (1, 9), (2, 8), (3, 7), (4, 6), (5, 5), (6, 4), (7, 3), (8, 2), (9, 1)] arr.sort(key=lambda x: x[1]) arr [(9, 1), (8, 2), (7, 3),

Re: [Tutor] high score lists

2005-04-15 Thread Max Noel
On Apr 15, 2005, at 21:30, D. Hartley wrote: Unless you can explain what lambda x: x[1] does, in preschool-speak ;) That's an anonymous function, also known as a lambda function. Let's take an example: a = range(10) a [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] map(lambda x: 2*x, a) [0, 2, 4, 6, 8, 10,

Re: [Tutor] odd behavior within __init__

2005-04-14 Thread Max Noel
On Apr 14, 2005, at 12:58, Orri Ganel wrote: a = Node(1) b = Node(a) 12932600 12932600 1 id(b) 12960632 Any ideas on why this happens, or suggestions as to how to implement the behavior I'm looking for (in which b and a would refer to the same object, have the same id, etc.), would be greatly

Re: [Tutor] Question regarding the len function of a list while using a loop

2005-04-14 Thread Max Noel
On Apr 14, 2005, at 14:14, Ben Markwell wrote: Could somebody explain to me why the code I used to complete this exercise doesn't work. And how do you send an integer to len? Well, I think you've successfully completed that exercise. len() doesn't work on integers because integers don't have a

Re: [Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread Max Noel
On Apr 14, 2005, at 21:06, [EMAIL PROTECTED] wrote: I've seen a couple of nice tutorials on recursion, and a lot of awful ones. The latter always trot out the fibonacci and factorial examples for some reason. And that's about it! The good ones showed me how to trace through recursive calls and

Re: [Tutor] high score lists

2005-04-14 Thread Max Noel
On Apr 15, 2005, at 01:33, D. Hartley wrote: This is what I have so far: high_scorelist = [(1000,Denise), (945,Denise), (883,Denise), (823,Grant), (779,Aaron), (702,Pete), (555,Tom), (443,Tom), (442,Robin), (404,Pete)] userscore = (441,Joe) def

Re: [Tutor] when to use properties?

2005-04-13 Thread Max Noel
On Apr 12, 2005, at 23:22, Danny Yoo wrote: There was an interesting article by Phillip Eby about what conventions work and don't work when one makes a jump from Java to Python: http://dirtsimple.org/2004/12/python-is-not-java.html A very interesting read. Thanks for the link, Danny! --

Re: [Tutor] newb problem running the translator (fwd)

2005-04-09 Thread Max Noel
On Apr 9, 2005, at 10:36, Danny Yoo wrote: -- Forwarded message -- Date: Fri, 8 Apr 2005 22:03:58 EDT From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: newb problem running the translator I will try to make this quick. I am a newb to python, and programming at that, but

Re: [Tutor] quicksort using list comprehension

2005-04-09 Thread Max Noel
On Apr 9, 2005, at 21:50, Kent Johnson wrote: I think you have to return a value when len(t) = 1. You don't return anything which means you return None which can't be added to a list. Kent Yup. Here's a quicksort I did, adapting an example from the Wikipedia article on Haskell: def

Re: [Tutor] building strings of specific length

2005-04-04 Thread Max Noel
On Apr 4, 2005, at 16:04, Vines, John (Civ, ARL/CISD) wrote: Hello. I have a question regarding strings. How do I format a string to be a specific length? For example I need 'string1' to be 72 characters long. Thanks for your time, John You can use the string methods ljust, rjust and zfill:

Re: [Tutor] Self referencing within a dictionary

2005-04-02 Thread Max Noel
On Apr 2, 2005, at 12:12, Liam Clarke wrote: Hi, Out of curiosity, is it possible to create a dictionary like this - foo = {'a':1, 'b':2, 'c':foo['a']} I know that as above doesn't work, but was just wondering if it's possible, and if it's a Bad Thing? Regards, Liam Clarke It doesn't work because

Re: [Tutor] Sorting more than one list

2005-04-01 Thread Max Noel
On Apr 1, 2005, at 09:59, Alan Gauld wrote: Since the data are obviously related (since you need to keep them linked), I'd be inclined to merge the lists into a list of tuples merged = [(a,b,c,d) for a in l1 for b in l2 for c in l3 for d in l4] Then you can sort 'merged' and it should just

Re: [Tutor] max. range of list

2005-03-25 Thread Max Noel
On Mar 25, 2005, at 15:50, jrlen balane wrote: how many is the maximum member can a list have??? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor As far as I know, there is no limit hard-coded in the language. So I

Re: [Tutor] Changing a class into a subclass

2005-03-24 Thread Max Noel
On Mar 24, 2005, at 18:07, Ismael Garrido wrote: Hello. I have a program that saves/loads to/from XML. I have a main class Building, and a subclass House(Building). When I save the code I instruct each object to save itself to XML (using ElementTree), so House adds itself to the XML tree. My

Re: [Tutor] problems with dictionary

2005-03-23 Thread Max Noel
On Mar 23, 2005, at 21:55, Bill Mill wrote: In line 3 of the Conv function, you write str=The name is + str . However, str has yet to be defined, from what I can tell. Thus, Python should throw a NameError. Unforutnately, you haven't included the exception that Python gives you with this email, so

Re: [Tutor] primes

2005-03-18 Thread Max Noel
On Mar 18, 2005, at 02:15, Kent Johnson wrote: Max Noel wrote: #!/usr/bin/env python import math import timeit def primeConcise(limit): return [2] + [x for x in xrange(3, limit, 2) if not [y for y in [2] + range(3,x,2) if x%y==0]] def primeConciseOptimized(limit): return [2] + [x for x

Re: [Tutor] primes

2005-03-17 Thread Max Noel
On Mar 17, 2005, at 22:28, Gregor Lingl wrote: Hi! Who knows a more concise or equally concise but more efficient expression, which returns the same result as [x for x in range(2,100) if not [y for y in range(2,x) if x%y==0]] Gregor P.S.: ... or a more beautiful one ;-) Hmm... I don't have

Re: [Tutor] primes

2005-03-17 Thread Max Noel
On Mar 17, 2005, at 23:54, Danny Yoo wrote: Hi Gregor, Here is one that's traduced... er... adapted from material from the classic textbook Structure and Interpretation of Computer Programs: SNIP Ooh, nifty. Okay, I decided to learn how to use the timeit module, so I used it to compare my

Fwd: [Tutor] creating a tab delimited filename

2005-03-16 Thread Max Noel
Forwarding to the list -- please use Reply to All. Begin forwarded message: From: jrlen balane [EMAIL PROTECTED] Date: March 16, 2005 04:13:40 GMT To: Max Noel [EMAIL PROTECTED] Subject: Re: [Tutor] creating a tab delimited filename Reply-To: jrlen balane [EMAIL PROTECTED] why is this not working

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Max Noel
On Mar 15, 2005, at 16:44, Ron Nixon wrote: Kent: The code is below. Here's the error message. Traceback (most recent call last): File C:/Python24/reformat.py, line 5, in -toplevel- name = x.group(1) AttributeError: 'list' object has no attribute 'group' re.findall returns a list object (as

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Max Noel
On Mar 15, 2005, at 17:41, Ron Nixon wrote: Max: Thanks that seem to do the trick. One question though, how do you write a tuple out as a list to a new file like the example I have in my code Ron You mean, all the members of the list, separated by commas, with a new line at the end? Well, this

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Max Noel
On Mar 15, 2005, at 21:59, Liam Clarke wrote: On Tue, 15 Mar 2005 17:09:50 +, Max Noel [EMAIL PROTECTED] wrote: re.findall returns a list object (as the error message says). Use name = x[1] instead. (and be careful, numbering starts from 0, so this code may contain a Kenobi error

Re: [Tutor] new

2005-03-15 Thread Max Noel
On Mar 16, 2005, at 02:02, Ian Martin wrote: Hey I am new at python and i am trying to learn about it. I was wondering if you could tell me how to write a range to 100. such as 1+2+3+4+5 ect. without writing it out. Well, I'm not going to give you the full solution (that'd spoil the fun),

Re: [Tutor] creating a tab delimited filename

2005-03-15 Thread Max Noel
On Mar 16, 2005, at 03:54, jrlen balane wrote: how would i make this the correct path: filename = %s%s.txt %('C:\Documents and Settings\nyer\My Documents\Info',time.strftime(%Y%m%d%H%M)) table_file = open(os.path.normpath(filename),a) running on IDLE, i get the following error: Traceback (most

Re: [Tutor] How do you use pydoc?

2005-03-14 Thread Max Noel
On Mar 15, 2005, at 00:28, [EMAIL PROTECTED] wrote:   I have read but don't under stand how to use pydoc. here what i read can't figer out how to use it. pydoc is more or less a help browser. Think of it as man for Python. If you need documentation on a module, just type pydoc [module

Re: [Tutor] Terminology WAS Whats so good about OOP ?

2005-03-13 Thread Max Noel
On Mar 13, 2005, at 18:38, Brian van den Broek wrote: Thanks for the explanation, Sean. The reference to grammatical theory here does seem to make sense. But, relying on correspondence between the technical terms in programming/comp. sci. and other fields with similar terminology can get in the

Re: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread Max Noel
On Mar 9, 2005, at 01:13, Shitiz Bansal wrote: Whats worse, I had found that the rule is different for different versions of windows.Just proves what we all know...Windows Suxx. The Windows OS sucks! And blows! At the same time! (name the reference, get a cookie ;) ) -- Max maxnoel_fr at yahoo dot

Re: [Tutor] help

2005-03-07 Thread Max Noel
On Mar 7, 2005, at 16:46, Kent Johnson wrote: Gregory Sexton wrote: Thanks for the help! Sorry for the trivial questions, but I guess we all have to start somewhere. Beginning python student, OS Windows XP,using Python 2.4. Also novice to programming. I cant get the /a command to work. I

Fwd: [Tutor] threads

2005-02-23 Thread Max Noel
Some day I'm actually going to learn how to hit the Reply All button. I swear. Begin forwarded message: From: Max Noel [EMAIL PROTECTED] Date: February 23, 2005 18:42:37 GMT To: Shitiz Bansal [EMAIL PROTECTED] Subject: Re: [Tutor] threads On Feb 23, 2005, at 17:50, Shitiz Bansal wrote: Hi, I am

  1   2   >