Re: [Tutor] Append function

2005-01-31 Thread Danny Yoo
On Sun, 30 Jan 2005, kumar s wrote: > I have a bunch of files where the first column is always the same. I > want to collect all those files, extract the second columns by file wise > and write the first column, followed by the other columns(extracted from > files) next to each other. Hi Kumar

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

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 'gr

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: http://tkinter.unpythonic.net/w

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 are

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 ne

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 di

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', 'openoffice.org-style-gnome-1.1.0-16.9.EL.

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) rel

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] prin

[Tutor] Better structure?

2005-01-31 Thread Jacob S.
I think this thing is screaming for better structure, but previous attempts at using oop for it have failed. I think Derintegral is okay, I'm focusing on FunctionGrapher5.py--but you can comment on both. (To Johan Nilsson: I haven't had time to implement Simpson's rule instead of Reimann's sum y

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, t

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

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,

[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 sli

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 ca

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 l

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 = input

[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

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 wh

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. Fo

Re: [Tutor] Dictionary Nesting

2005-01-31 Thread Alan Gauld
> 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' Yes. Sometimes it's easier with Python to just try it at the >>> prompt rather than ask t

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

[Tutor] Traffic Network simulator

2005-01-31 Thread Shitiz Bansal
Hi, 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. does anyone know where i can find something of the sort or are there any special modules available which can help me build one

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. > >

[Tutor] Comparing files, Counting Value

2005-01-31 Thread Michiyo LaBerge
Hello all, I'm very new to Python and have been trying to write a script to compare data from 2 files and getting a total. One of the two files contains x, y positions of pixels and a color value(z) of each, so it has three columns in the file. The other file has two columns; x1, y1. I'd like t

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 th

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 don't

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: http://www-1

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. I

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

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 in

[Tutor] Presentation

2005-01-31 Thread Paul Hartley
I am trying to get Python established here in the Philippines. Currently I am in charge of operations at a business based in Manila and I have asked my IT staff to start using Python (with some success).   A local university has now asked that I give a talk to their IT people on Python - so

Re: [Tutor] Presentation

2005-01-31 Thread Max Noel
On Feb 1, 2005, at 16:35, Paul Hartley wrote: When I was a member of the Forth Interest Group in the USA we learned that Forth was used on the buggy that went to mars, that it started life controlling huge radio telescopes which only had 4k (yes 4k) of memory for both language and application.  

Re: [Tutor] Presentation

2005-01-31 Thread Terry Carroll
On Tue, 1 Feb 2005, Paul Hartley wrote: > When I was a member of the Forth Interest Group in the USA we learned > that Forth was used on the buggy that went to mars, that it started life > controlling huge radio telescopes which only had 4k (yes 4k) of memory > for both language and application. >

Re: [Tutor] Better structure?

2005-01-31 Thread Jacob S.
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 What, like global radiusaxis, radiusaxis2 Simil

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 f

Re: [Tutor] Better structure?

2005-01-31 Thread Jacob S.
Ah, I like. BTW, it was a few months ago, not days... but the thought still counts. At least you remember. I was getting stumped by the difference in comparing y The check for seeing what the first word is made me slamp my forehead... Thanks! Jacob Schmidt On Mon, 31 Jan 2005, Jacob S. wrote: I

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 http://w