Re: [Tutor] files in a directory

2005-01-31 Thread Danny Yoo
Now that I am reading many files at once, I wanted, to have a tab delim file op that looks like this: My_coors Int_file 1 Int_file2 IntFile3 01:26 34 235 245.45 04:42 342.4452.445.5 02:56 45.4 34.5

Re: [Tutor] Dividing 1 by another number ?

2005-01-31 Thread Alan Gauld
What Alan meant, presumably, was this: one = 1 other = 42 result = float(one)/other Whoops! Yes indeedy! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Danny Yoo
On Sun, 30 Jan 2005, Glen wrote: As a Python/Tkinter newbie, I thought I was getting on ok... then I hit this problem. I have a canvas (c1) A group of objects are drawn on c1 and given a tag c1.addtag_all('group_A') Another group of objects are drawn, I wish to tag these

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Danny Yoo
On Mon, 31 Jan 2005, Danny Yoo wrote: I think that getting this right will take some more work. Here's a definition of a function called find_withouttag(): [Code cut] Oh! Never mind; this can be a lot simpler. According to the Gotchas section of:

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Kent Johnson
Danny Yoo wrote: Oh! Never mind; this can be a lot simpler. According to the Gotchas section of: http://tkinter.unpythonic.net/wiki/Widgets/Canvas the items in a Canvas are actually not object instances themselves, but integers. I made an assumption that canvas items were object instances,

[Tutor] help with regexps/filename parsing

2005-01-31 Thread Scott W
Hey all. I've got an issue that's been driving me a bit nuts. I'm sure it _can_ be done with a regexp, although I'm missing a piece needed to tie it together to work for all cases. I need to parse out a list of RPMs in this case, but it seems the RPM naming convention has changed, as there

Re: [Tutor] help with regexps/filename parsing

2005-01-31 Thread Scott W
Slight correction which I realized after sending, see below for version/release seperation, which I should have seen but blame lack of sleep ;-) Scott W wrote: Hey all. I've got an issue that's been driving me a bit nuts. I'm sure it _can_ be done with a regexp, although I'm missing a piece

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Kent Johnson
Kent Johnson wrote: Note that Python 2.4 has set built-in with the name 'set'. To be compatible with both you could write try: set except NameError: from sets import Set as set Clarification: you don't _have_ to do this to be compatible with 2.4. The sets module is in both 2.3 and 2.4. The

Re: [Tutor] help with regexps/filename parsing

2005-01-31 Thread Kent Johnson
This works: names = [ 'XFree86-ISO8859-15-75dpi-fonts-4.3.0-78.EL.i386.rpm', #(Note the EL embedded in name) 'xfig-3.2.3d-12.i386.rpm', #(standard naming) 'rhel-ig-ppc-multi-zh_tw-3-4.noarch.rpm', 'perl-DateManip-5.42a-0.rhel3.noarch.rpm',

Re: [Tutor] help with regexps/filename parsing

2005-01-31 Thread Karl Pflästerer
On 31 Jan 2005, [EMAIL PROTECTED] wrote: I've got an issue that's been driving me a bit nuts. I'm sure it _can_ be done with a regexp, although I'm missing a piece needed to tie it together to work for all cases. I need to parse out a list of RPMs in this case, but it seems the RPM

Re: [Tutor] help with regexps/filename parsing

2005-01-31 Thread Karl Pflästerer
On 31 Jan 2005, [EMAIL PROTECTED] wrote: Slight correction which I realized after sending, see below for version/release seperation, which I should have seen but blame lack of sleep ;-) corrected versions: 4.3.0 3.2.3d 3 5.42a 1.10 (new) releases:

Re: [Tutor] TypeError: can only concatenate list (not str) to list

2005-01-31 Thread Jacob S.
You can also do... Umm, if you're going to make nmr and pbr the values you're printing, why are you printing the values? Nevermind, look at this instead. BTW, aren't rows the horizontal things on tables? nmr = nmrows[i] pbr = cols[0] print %s\t%s % (nmr,pbr) nmr = nmrows[i] pbr = cols[0] print

RE: [Tutor] Diffing two files.

2005-01-31 Thread Ertl, John
Thanks, So simple...DAA just do an equivalency on the list...no need to do sets or step through each line. John -Original Message- From: Kent Johnson [mailto:[EMAIL PROTECTED] Sent: Saturday, January 29, 2005 06:05 Cc: Tutor@python.org Subject: Re: [Tutor] Diffing two files. OK,

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Glen
On Mon, 2005-01-31 at 12:34, Kent Johnson wrote: Kent Johnson wrote: Note that Python 2.4 has set built-in with the name 'set'. To be compatible with both you could write try: set except NameError: from sets import Set as set Clarification: you don't _have_ to do this to be

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Glen
On Mon, 2005-01-31 at 09:06, Danny Yoo wrote Here's a small example with sets to make it more clear how this set manipulation stuff will work: ### from sets import Set numbers = range(20) primes = [2, 3, 5, 7, 11, 13, 17, 19] Set(numbers) - Set(primes) Set([0, 1, 4, 6, 8, 9, 10,

[Tutor] How to sum rows and columns of a matrix?

2005-01-31 Thread Gregor Lingl
Hi all of you, I'm representing a 4x4 matrix as a 16-element list, e.g. m=range(16) first 4 elements first row, second four elements second row etc. I want to sum rows and columns like i-th row: sum(m[4*i:4*i+4]) and ith column: sum(m[i::4]) This seems to be slow because of the formation of the

Re: [Tutor] How to sum rows and columns of a matrix?

2005-01-31 Thread Liam Clarke
There's a specific package for arrays http://www.stsci.edu/resources/software_hardware/numarray that implements array mathematics. I use it for pixel map manipulation in pygame, so it's relatively fast. On Mon, 31 Jan 2005 19:09:59 +0100, Gregor Lingl [EMAIL PROTECTED] wrote: Hi all of you,

Re: [Tutor] Better structure?

2005-01-31 Thread Alan Gauld
def start(): lots of lines... global xaxis global yaxis Its traditional to put global statements at the top of the function. Also you only need one line to list all of the global variables global radiusaxis global radiusaxis2 Similarly here., and again you can

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Glen
On Mon, 2005-01-31 at 18:20, Kent Johnson wrote: In 2.4 I tried 'from sets import set' should be 'from sets import Set' - the class in the sets module is called Set, the builtin class is set. I tried it as 'set' and 'Set' but got the same result Traceback (most recent call last):

Re: [Tutor] Control flow

2005-01-31 Thread Gilbert Tsang
Thanks for the enthusiasm on how input/raw_input() works - my original intention was to ask a question on control flow so I didn't spend that much time testing out this piece of input code besides typing. But I did learn a lot. Thanks! Gilbert Jacob S. wrote: I noticed that too, Liam. b =

[Tutor] Dictionary Nesting

2005-01-31 Thread jhomme
-Original message- From: Orri Ganel [EMAIL PROTECTED] Date: Sat, 29 Jan 2005 17:22:48 -0500 To: Kent Johnson [EMAIL PROTECTED] Subject: Re: Fwd: [Tutor] Control flow Kent Johnson wrote: Bob Gailer wrote: At 04:43 AM 1/29/2005, Liam Clarke wrote: erk, to the list, to the

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Danny Yoo
Now I've just got to work out how to tag a list of id's... There doesn't seem to be a way to tag a known id, it has to be tagged by reference from an id above or below which seems odd! Hi Glen, Have you tried the addtag_withtag() method? It looks like it should be able to do what you're

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Kent Johnson
Danny Yoo wrote: Now I've just got to work out how to tag a list of id's... There doesn't seem to be a way to tag a known id, it has to be tagged by reference from an id above or below which seems odd! Hi Glen, Have you tried the addtag_withtag() method? It looks like it should be able to do

Re: [Tutor] Dictionary Nesting

2005-01-31 Thread Kent Johnson
jhomme wrote: Hi, If I want to put a dictionary in a dictionary, does the syntax for assigning and getting at the stuff in the inner dictionary look something like this: outer_dictionary[inner_dictionary][key] = 'value' ? If inner_dictionary is the key to outer_dictionary, then that is right.

Re: [Tutor] How to sum rows and columns of a matrix?

2005-01-31 Thread Orri Ganel
Gregor Lingl wrote: Hi all of you, I'm representing a 4x4 matrix as a 16-element list, e.g. m=range(16) first 4 elements first row, second four elements second row etc. I want to sum rows and columns like i-th row: sum(m[4*i:4*i+4]) and ith column: sum(m[i::4]) This seems to be slow because of the

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Glen
Have you tried the addtag_withtag() method? It looks like it should be able to do what you're thinking of. The documentation here: http://tkinter.unpythonic.net/pydoc/Tkinter.Canvas.html should talk about addtag_withtag(). itemconfig() also looks promising.

Re: [Tutor] carriage return on windows

2005-01-31 Thread Victor Rex
Orri Ganel wrote: Jacob S. wrote: Thanks Kent and Max! Wow, I didn't know it did that. I'm too dumb to figure it out on my own I guess... Oh well! I found a cool new thing to play with at least! Thanks, Jacob On Jan 30, 2005, at 02:40, Jacob S. wrote: I don't think that's what he wants. I

Re: [Tutor] Comparing files, Counting Value

2005-01-31 Thread Bill Mill
Michiyo, When you ask a question to the list, you should be more careful to highlight your problem so that it doesn't seem like you're asking people to write a script for you. I don't think that's what you were doing, but just try to reduce your problem to a minimal example in the future. I

Re: [Tutor] Traffic Network simulator

2005-01-31 Thread Guillermo Fernandez Castellanos
Hi, Don't know if there's any network simulator. But I know about SimPy: http://simpy.sourceforge.net/ Looks well documented. Check the examples, it seems you can do pretty robust things with not toomuch code. I readed about it in the charming python section of IBM developers works:

Re: [Tutor] carriage return on windows

2005-01-31 Thread Kent Johnson
Victor Rex wrote: I played around with this output issue and I love the way it works. Now, how do you do this in *nix? I tried the same approach and I get a blank line for 5 seconds (or whatever number of cycles you have on your example) and the a final line with the last value of the iterable.

Re: [Tutor] Comparing files, Counting Value

2005-01-31 Thread Danny Yoo
Hi Michiyo, Ok, let's take a look at the code. i=open(file 1) #value data o=open(file 2) #look-up file l=open(result, 'w')#result We strongly recommend renaming these names to ones that aren't single characters. It's difficult to tell here what 'i', 'o', and 'l' mean, outside of the

Re: [Tutor] Better structure?

2005-01-31 Thread Danny Yoo
On Mon, 31 Jan 2005, Jacob S. wrote: I think this thing is screaming for better structure, but previous attempts at using oop for it have failed. Hi Jacob, Ok, I see one big refactoring that should help things quite a bit. There's a large case-analysis off if/elif/elif statements that

Re: [Tutor] Traffic Network simulator

2005-01-31 Thread Alan Gauld
I need a traffic network simulator(for roads) for my project work.I would prefer the simulator to be in python so that i can reprogram/modify it according to my needs. I don't jnow of anything ready made. But a Google search may find someting somewhere... does anyone know where i can find

Re: [Tutor] Traffic Network simulator

2005-01-31 Thread Andrew McNamara
I need a traffic network simulator(for roads) for my project work.I would prefer the simulator to be in python so that i can reprogram/modify it according to my needs. Have you looked at SimPy: http://simpy.sourceforge.net/ -- Andrew McNamara, Senior Developer, Object Craft