Re: Decorating class member functions

2007-05-04 Thread Andy Terrel
Thanks Peter and 7stud. That is the solution that really works for me. -- http://mail.python.org/mailman/listinfo/python-list

Decorating class member functions

2007-05-03 Thread Andy Terrel
Okay does anyone know how to decorate class member functions? The following code gives me an error: Traceback (most recent call last): File decorators2.py, line 33, in module s.update() File decorators2.py, line 13, in __call__ retval = self.fn.__call__(*args,**kws) TypeError:

Re: Decorating class member functions

2007-05-03 Thread Andy Terrel
Oh I should mention the decorator needs to have some notion of state (such as with the above class) -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I import a variable from another module?

2007-05-03 Thread Andy Terrel
are you sure your variable isn't in some code block that wouldn't be read on import? Such as: if __name__ == __main___: actions = 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorating class member functions

2007-05-03 Thread Andy Terrel
I just need to keep the state around. I make a call to some function that is pretty expensive so I want to save it as a member during the __init__ of the decorator. Yeah I'm afraid it can't be done either, that's why I asked the group. -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorating class member functions

2007-05-03 Thread Andy Terrel
not quite as elegant but here is a workaround... Thanks Virgil for taking some time to think about it. --- class Bugger (object): def __init__ (self, module): print Entering __init__ self.module = module self.verb = 0 def instrument (module_name): def wrapper(f):

Re: c++ for python programmers

2007-02-12 Thread Andy Terrel
On Feb 12, 4:11 pm, Thomas Nelson [EMAIL PROTECTED] wrote: On Feb 12, 1:35 pm, andrew clarke [EMAIL PROTECTED] wrote: Thomas, I sent you a message off-list but it bounced due to your mailbox being full. Short answer: Subscribe to the [EMAIL PROTECTED] mailing list and ask your C/C++

Re: split string problems

2006-09-07 Thread Andy Terrel
try str(p).split()[2] your class is using the __str__ attribute to print and I am guessing that is what you are seeing. Tempo wrote: Hey. I am trying to grab the prices from the string below but I get a few errors when I try to do it: Take a look at the code and error messages below for me

Re: find, replace and save string in ascii file

2006-08-23 Thread Andy Terrel
Take your code, pretend it is in file: $ NAME='ALFA' CODE='x' $ a python functions could be: def change(filename): fp = open(filename, 'r') lines = fp.readlines() fp.close() for i in range(len(lines)): if

Re: Python bindings for picasaweb ...

2006-08-23 Thread Andy Terrel
sweet. I'll definitely be trying to use this. [EMAIL PROTECTED] wrote: Just a post to announce some python bindings for picasaweb (photo's service of google). --- PycasaWeb (GPL), http://manatlan.infogami.com/pycasaweb I think it may be usefull for linux users, because it's one of the only

Re: how do you get the name of a dictionary?

2006-08-18 Thread Andy Terrel
jojoba wrote: Hello! Does anyone know how to find the name of a python data type. Conside a dictionary: Banana = {} Then, how do i ask python for a string representing the name of the above dictionary (i.e. 'Banana')? thanks to anyone who has time to answer this nube question! jojoba

Re: how do you get the name of a dictionary?

2006-08-18 Thread Andy Terrel
can think of plenty of reasons it would fail, but it really depends on the app. Fredrik Lundh wrote: Andy Terrel wrote: for i in dir(): if eval(i) == Banana: print i (sound of head hitting desk) /F -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you get the name of a dictionary?

2006-08-18 Thread Andy Terrel
Georg Brandl wrote: Andy Terrel wrote: Why bang your head? Because there's no chance that the original request is sane. If you want your objects to know their name, give them a name as an attribute. This is true but sometimes it is just fun to hack around. -- http://mail.python.org

Re: loop until keypress (Windows XP)

2006-08-10 Thread Andy Terrel
If you did want a linux version you could just make people send a KeyboardInterupt. try: print Press ^C to stop loop except KeyboardInterrupt: some stop action or just pass -- http://mail.python.org/mailman/listinfo/python-list