[Tutor] decorators, __call__ (able) objects

2009-07-15 Thread Todd Matsumoto
Hi, Can some one give, or point to some good examples of how @decorators work, and __call__ (able) objects? I'm having trouble getting my head around these techniques (concepts). Cheers, T -- Neu: GMX Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate für nur 19,99 Euro/mtl.!* http://portal

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread Kent Johnson
On Wed, Jul 15, 2009 at 7:41 AM, Todd Matsumoto wrote: > Hi, > > Can some one give, or point to some good examples of how @decorators work, > and __call__ (able) objects? Decorators: http://personalpages.tds.net/~kent37/kk/1.html Kent ___ Tutor mai

Re: [Tutor] How to pass command line variables to this python code...

2009-07-15 Thread vince spicer
good catch, my mistake args[1] == 'yankees' True On Wed, Jul 15, 2009 at 12:25 AM, Christian Witts wrote: > vince spicer wrote: > >> First off, selenium is a great tool and the python driver is very powerful >> >> there are numerous ways to access cli variables, >> >> the quickest >> >> import

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread vince spicer
simple example of calling a class class myKlass(object): On Wed, Jul 15, 2009 at 6:33 AM, Kent Johnson wrote: > On Wed, Jul 15, 2009 at 7:41 AM, Todd Matsumoto wrote: > > Hi, > > > > Can some one give, or point to some good examples of how @decorators > work, and __call__ (able) objects? > >

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread vince spicer
simple example of calling a class class myKlass(object): def __call__(self, *args, **kws): print "i was called" >> test = myKlass() >> test() >> i was called > > > > On Wed, Jul 15, 2009 at 6:33 AM, Kent Johnson wrote: > >> On Wed, Jul 15, 2009 at 7:41 AM, Todd Matsumoto >> wr

[Tutor] just one question

2009-07-15 Thread amrita
Hi, i want to ask one thing that suppose i have a .txt file having content like:--- 47 8 ALA H H 7.85 0.02 1 48 8 ALA HAH 2.98 0.02 1 49 8 ALA HBH 1.05 0.02 1 50 8 ALA C C179.39 0.

Re: [Tutor] just one question

2009-07-15 Thread vince spicer
one way is: import re infile = open("test.txt", "r") #: open read mode outfile = open("out.tx", "w") #: open write mode for line in infile: values = re.split("\s+", line) # split values on spaces EX: ['47', '8', 'ALA', 'H', 'H', '7.85', '0.02', '1'] outfile.write("%s %s C = %s CA = %

[Tutor] objects becoming pointers

2009-07-15 Thread chris Hynes
I guess I have to start somewhere to ask I want the user to input a name, say "Chris". I know I can use the code: name=raw_input() I now want: "Chris"=zeros((3,3)) so that when I type: print Chris the return will be an array of zero's 3x3 So that I can understand this deeper, I

Re: [Tutor] just one question

2009-07-15 Thread Rich Lovely
2009/7/15 vince spicer : > one way is: > > import re > > infile = open("test.txt", "r") #: open read mode > outfile = open("out.tx", "w") #: open write mode > > for line in infile: >     values = re.split("\s+", line) # split values on spaces EX: ['47', '8', > 'ALA', 'H', 'H', '7.85', '0.02', '1']

Re: [Tutor] objects becoming pointers

2009-07-15 Thread Rich Lovely
2009/7/15 chris Hynes : > I guess I have to start somewhere to ask > > I want the user to input a name, say "Chris". I know I can use the code: > > name=raw_input() > > I now want: > > "Chris"=zeros((3,3)) > > so that when I type: > > print Chris > > the return will be an array of zero'

Re: [Tutor] How to pass command line variables to this python code...

2009-07-15 Thread J Cook
Yeah, I figured that. I got it to work thanks, but I still don't understand how exactly. Coming from Perl I am used to a more procedural type of programming. BTW - Selenium is a great tool for web testing, and the way it will translate your web clickstream into your choice of languages rocks.

Re: [Tutor] objects becoming pointers

2009-07-15 Thread bob gailer
chris Hynes wrote: I guess I have to start somewhere to ask I want the user to input a name, say "Chris". I know I can use the code: name=raw_input() I now want: "Chris"=zeros((3,3)) This is a FAQ. In Python one is discouraged from dynamically creating variable names. Preferred

Re: [Tutor] objects becoming pointers

2009-07-15 Thread vince spicer
not sure exactly why you would want to that, but you could assign attributes to a class EX: class storage: pass >> store = Storage() >> name=raw_input() >> setattr(store, name, zeros(3,3)) >> print store.Chris On Wed, Jul 15, 2009 at 9:19 AM, chris Hynes wrote: > I guess I have to sta

Re: [Tutor] objects becoming pointers

2009-07-15 Thread Kent Johnson
On Wed, Jul 15, 2009 at 11:19 AM, chris Hynes wrote: > I guess I have to start somewhere to ask > > I want the user to input a name, say "Chris". I know I can use the code: > > name=raw_input() > > I now want: > > "Chris"=zeros((3,3)) > > so that when I type: > > print Chris > > the ret

Re: [Tutor] just one question

2009-07-15 Thread wesley chun
On Wed, Jul 15, 2009 at 8:29 AM, Rich Lovely wrote: > 2009/7/15 vince spicer : >>: >> import re >>: >>     values = re.split("\s+", line) # split values on spaces EX: ['47', '8', > > That isn't what they're after at all. > Something more like > : >        n, pos, ala, at, sy

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread wesley chun
>>> > Can some one give, or point to some good examples of how @decorators >>> > work, and __call__ (able) objects? > > simple example of calling a class > > class myKlass(object): > > def __call__(self, *args, **kws): > print "i was called" > > >>> test = myKlass() > >>> test() > i wa

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread vince spicer
agreed much better description, thanks On Wed, Jul 15, 2009 at 1:02 PM, wesley chun wrote: > >>> > Can some one give, or point to some good examples of how @decorators > >>> > work, and __call__ (able) objects? > > > > simple example of calling a class > > > > class myKlass(object): > > > >

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread Todd Matsumoto
hi kent, thanks, i read through the link but still haven't got my head around this concept. will read on. cheers, t Original-Nachricht > Datum: Wed, 15 Jul 2009 08:33:33 -0400 > Von: Kent Johnson > An: Todd Matsumoto > CC: tutor@python.org > Betreff: Re: [Tutor] decorators,

[Tutor] reading complex data types from text file

2009-07-15 Thread Chris Castillo
I'm having some trouble reading multiple data types from a single text file. say I had a file with names and numbers: bob 100 sue 250 jim 300 I have a few problems. I know how to convert the lines into an integer but I don't know how to iterate through all the lines and just get the integers and

[Tutor] help

2009-07-15 Thread jonathan wallis
i have a duel loop that looks like thiswhile y > 0 and x > 0: i cant figure out if there is a way to make so if one loop ends it says something different than if the other loop ends. ___ Tutor maillist - Tutor@python.org http://mail.python.o

Re: [Tutor] reading complex data types from text file

2009-07-15 Thread Michiel Overtoom
Chris Castillo wrote: I don't know how to iterate through all the lines and just get the integers and store them or iterate through the lines and just get the names and store them. You could use the int() function to try to convert a line to an integer, and if that fails with a ValueError ex

Re: [Tutor] help

2009-07-15 Thread Eric Walker
> >From: jonathan wallis >To: tutor@python.org >Sent: Wednesday, July 15, 2009 12:54:16 PM >Subject: [Tutor] help > >>i have a duel loop that looks like thiswhile y > 0 and x > 0: >i cant figure out if there is a way to make so if one loop ends it says >something different than if th

Re: [Tutor] help

2009-07-15 Thread Michiel Overtoom
jonathan wallis wrote: i cant figure out if there is a way to make so if one loop ends it says something different than if the other loop ends. Maybe you could use two separate tests and break out of the loop if x or y gets too low. Because the tests are separated you could say something diff

Re: [Tutor] objects becoming pointers

2009-07-15 Thread bob gailer
Please always reply-all so a copy goes to the list. chris Hynes wrote: Ah, there you go, that's what I want to do, dynamically create variable names. Then I could interactively create as many arrays as I want to, say Chris1, Chris2, Chris3 and each of these would be different array with differ

Re: [Tutor] objects becoming pointers

2009-07-15 Thread Kent Johnson
> chris Hynes wrote: >> >> Ah, there you go, that's what I want to do, dynamically create variable >> names. Then I could interactively create as many arrays as I want to, say >> Chris1, Chris2, Chris3 and each of these would be different array with >> different results. >> >> But based on what you

[Tutor] Can't transform a list of tokens into a text

2009-07-15 Thread Eduardo Vieira
Hello, I have a file that was a resulted from a POS-Tagging program, after some transformations, I wanted to restore to it's normal form. So, I used sed to remove the POS-Tags and have something like this: --- Example begins No , thank...@+ # this +...@+ I inserted to mark paragraphs, because the

[Tutor] Fwd: The why

2009-07-15 Thread Rich Lovely
-- Forwarded message -- From: chris Hynes Date: 2009/7/15 Subject: The why To: roadier...@googlemail.com Well, I'm trying to create an interactive program, let's say I'm running the program, I ask the user to give the array a name, I then do some computations and store the result

Re: [Tutor] Can't transform a list of tokens into a text

2009-07-15 Thread Muhammad Ali
Try changing all instances of list[i + 1] to list[i] On Thu, Jul 16, 2009 at 8:33 AM, Eduardo Vieira wrote: > #=== > I tried this version to post in this forum but that gives me an error. > I don't know why I don't get an error with the code above which is > essentially the same: > # -*- coding:

Re: [Tutor] reading complex data types from text file

2009-07-15 Thread Christian Witts
Chris Castillo wrote: I'm having some trouble reading multiple data types from a single text file. say I had a file with names and numbers: bob 100 sue 250 jim 300 I have a few problems. I know how to convert the lines into an integer but I don't know how to iterate through all the lines and

Re: [Tutor] XML: changing value of elements

2009-07-15 Thread Johan Geldenhuys
I have another question about writing the xml tree to a file. Now, I have parsed and changed my xml tree, but I want to create the same tree multiple times with different values and write it to one file. Let's use this code: import xml.etree.ElementTree as ET doc = ET.parse('sig

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread Todd Matsumoto
Thanks guys, In the example the __call__ method has *args and **kws as arguments. Is that required? Also when, in what situation would you use callable objects? Cheers, T Original-Nachricht > Datum: Wed, 15 Jul 2009 12:02:05 -0700 > Von: wesley chun > An: vince spicer , tmat

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread Vince Spicer
no the __call__ function can is like any function def __call__(self, passedin): or simply def __call__(self) *args and **kws explained > http://www.saltycrane.com/blog/2008/01/how-to- use-args-and-kwargs-in-python/ On Thursday 16 July 2009 12:09:52 am Todd Matsumoto wrote: > Thanks guys,