Re: [Tutor] Am I storeing up problems ?

2005-01-02 Thread Brian van den Broek
Max Noel said unto the world upon 2005-01-02 19:43: On Jan 2, 2005, at 23:00, Danny Yoo wrote: (Aside: one nonobvious example where copying can be avoided is in Conway's Game of Life: when we calculate what cells live and die in the next generation, we can actually use the 'Command' design patter

[Tutor] Sorting/filtering data, dictionary question & Re:OT

2005-01-02 Thread Bill Burns
Hi, I have a couple of questions about a program I've been working on. Here's a overview of what the program does. Calculates the following data about HVAC/Plumbing pipe: A). Total volume of water inside the pipe (US gallons). B). The weight of the water inside the pipe. C). The actua

Re: [Tutor] dumping .pck files

2005-01-02 Thread Patric Michael
> I want to explore some mailman config files, e.g. > config.pck. Some quick searches informed me that these > contain pickled configuration info. > > My first naive attempt to dump what was in them failed: > > >>> import pickle > >>> pickle.load(open("config.pck")) > traceback > ImportError

[Tutor] dumping .pck files

2005-01-02 Thread Neal McBurnett
I want to explore some mailman config files, e.g. config.pck. Some quick searches informed me that these contain pickled configuration info. My first naive attempt to dump what was in them failed: >>> import pickle >>> pickle.load(open("config.pck")) traceback ImportError: No module named Ma

Re: [Tutor] Basic question -> How to use a class from a file?

2005-01-02 Thread Rich Krauter
Bernard Lebel wrote: Okay here comes the next question. In that class, I have 3 functions. Actually, one of them calls the two others. However when I call these functions (wich are placed before the caller in the file), I get an error saying that the global name x (the function name) is not def

Re: [Tutor] Basic question -> How to use a class from a file?

2005-01-02 Thread Bernard Lebel
Okay here comes the next question. In that class, I have 3 functions. Actually, one of them calls the two others. However when I call these functions (wich are placed before the caller in the file), I get an error saying that the global name x (the function name) is not defined. What am I doin

[Tutor] My 2nd ever .py script [XML, makedirs, copytree]

2005-01-02 Thread Rafal Kaniewski
This is my second script (if you don't include the last time I programmed (20 years ago...) it's a nasty hack but it works... --- - - http://www.filemaker.com/fmpdsoresult";> 0 Workflow01.fp7 - yourSoLuckyJob

Re: [Tutor] Am I storeing up problems ?

2005-01-02 Thread Alan Gauld
> I needed to copy this matrix to 'self.old_data', so I have been using > .deepcopy(), which works OK but is SLOW (12+ secs) Are you sure you need to copy it./ A simple reassignment should work and then reconstruct the structure using fresh lists/dictionary etc. That should work faster. Alan

Re: [Tutor] simple list query

2005-01-02 Thread Alan Gauld
> You might want to try: > > x in list Blush, I forgot about 'in'. And being in C it should be faster than the sort/loop combination. Silly me... :-( Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] simple list query

2005-01-02 Thread Alan Gauld
> I have a list consisting of about 250 items, I need to know if a > particular item is in the list. I know this is better suited to a > dictionary but thats not the way it ended up ;-) > > I could do a for loop to scan the list & compare each one, but I have a > suspission that there is a better

Re: [Tutor] Am I storeing up problems ?

2005-01-02 Thread Max Noel
On Jan 2, 2005, at 23:00, Danny Yoo wrote: (Aside: one nonobvious example where copying can be avoided is in Conway's Game of Life: when we calculate what cells live and die in the next generation, we can actually use the 'Command' design pattern to avoid making a temporary copy of the world. We

[Tutor] A not-so-basic question...

2005-01-02 Thread Patric Michael
Hi folks... I was thinking about this the other day while prepping to write up another CGI thing. It occurred to me to wonder how other folks prepare an app, script, whatever. So the question is, and I am not looking for a "right answer" here. (I doubt ther eis one, to be honest.) How do you

Re: [Tutor] Basic question -> How to use a class from a file?

2005-01-02 Thread Bernard Lebel
All righty, thanks a lot! Bernard tanja pislar wrote: hi Bernard, you have to specify the module as well: let's say your module is called rtModule.py, then in your case you'd do: import rtModule testClass = rtModule.rt() testClass.walk() or: from rtModule import rt testClass = rt() testClass.walk()

Re: [Tutor] Basic question -> How to use a class from a file?

2005-01-02 Thread tanja pislar
hi Bernard, you have to specify the module as well: let's say your module is called rtModule.py, then in your case you'd do: import rtModule testClass = rtModule.rt() testClass.walk() or: from rtModule import rt testClass = rt() testClass.walk() regards, tanja On Sun, 02 Jan 2005 17:43:07

[Tutor] Basic question -> How to use a class from a file?

2005-01-02 Thread Bernard Lebel
Hello, An easy one to start the year. Trying to write my first class, already running into problems after 3 lines! :-( So have this little class: class rt: def walk(self): print 'yeah' So if I write this in the Python shell, instantiate rt and call walk(), I get the prope

Re: [Tutor] Am I storeing up problems ?

2005-01-02 Thread Danny Yoo
On Sun, 2 Jan 2005, Dave S wrote: > My matrix 'self.data' consists of a list of 110 items, each item is a > dictionary of 250 keys, each key holds two lists, one of four items, one > of 12 items. Hi Dave, Hmmm... what kind of data is being copied here? Python's data structures are desigined f

[Tutor] Am I storeing up problems ?

2005-01-02 Thread Dave S
Hi there again, My matrix 'self.data' consists of a list of 110 items, each item is a dictionary of 250 keys, each key holds two lists, one of four items, one of 12 items. I needed to copy this matrix to 'self.old_data', so I have been using .deepcopy(), which works OK but is SLOW (12+ sec

Re: [Tutor] simple list query

2005-01-02 Thread Dave S
Patrick Hall wrote: Hi Dave, I have a list consisting of about 250 items, I need to know if a particular item is in the list. I know this is better suited to a dictionary but thats not the way it ended up ;-) I could do a for loop to scan the list & compare each one, but I have a suspis

Re: [Tutor] simple list query

2005-01-02 Thread Patrick Hall
Hi Dave, > I have a list consisting of about 250 items, I need to know if a > particular item is in the list. I know this is better suited to a > dictionary but thats not the way it ended up ;-) > I could do a for loop to scan the list & compare each one, but I have a > suspission that there is

Re: [Tutor] simple list query

2005-01-02 Thread Bill Kranec
You might want to try: x in list this will return true if, for example, list = [x,y,z,w], false if list = [y,y,y,y] Bill Dave S wrote: OK simple query, I have a list consisting of about 250 items, I need to know if a particular item is in the list. I know this is better suited to a dictionary

[Tutor] simple list query

2005-01-02 Thread Dave S
OK simple query, I have a list consisting of about 250 items, I need to know if a particular item is in the list. I know this is better suited to a dictionary but thats not the way it ended up ;-) I could do a for loop to scan the list & compare each one, but I have a suspission that there is

Re: [Tutor] doctest

2005-01-02 Thread Kent Johnson
Alan Gauld wrote: Also, anything I can do... Presently, since I'm running windows xp, I would have to hunt for the command prompt and type in the command Start->Run Type cmd, Hit OK :-) Or drag the icon from accessories into the start menu or to the desktop. Or drag the icon to the left side of th

Re: [Tutor] doctest

2005-01-02 Thread Kent Johnson
Jacob S. wrote: Even so, doctest doesn't seem to recognize the module level docstring. It will run the test inside the functions, but it says there isn't a test on the module level. I put the docstring just like in the example at the link you provided... Please post the code for the module you are

Re: [Tutor] doctest

2005-01-02 Thread Alan Gauld
> Also, anything I can do... Presently, since I'm running windows xp, I would > have to hunt for the command prompt and type in the command Start->Run Type cmd, Hit OK :-) Or drag the icon from accessories into the start menu or to the desktop. > '"C:\python24\python.exe" "C:\documents and sett

Re: [Tutor] How to substitute an element of a list asapattern forre.compile()

2005-01-02 Thread Alan Gauld
> > >>> for x in ['string', 10, True, [1,2,3] ]: > > ... print '%s' %x > > ... > > string > > 10 > > True > > [1, 2, 3] > > That's cool! I didn't know that. I guess I'm crazy... : ) > (We already knew that here.) The difference is in how the formatting details work. For numbers the format