Re: function name

2010-04-29 Thread Peter Otten
Steven D'Aprano wrote: > Be aware though, that sys._getframe is marked as a private function (the > leading underscore), which means that: > > (1) It only exists in some Python implementations (CPython and possible > nothing else?); and $ jython Jython 2.2.1 on java1.6.0_0 Type "copyright", "cre

Re: function name

2010-04-28 Thread Steven D'Aprano
On Wed, 28 Apr 2010 21:03:36 +0200, Peter Otten wrote: > Richard Lamboj wrote: > >> is there any way to get the name from the actual called function, so >> that the function knows its own name? > import sys def my_name(): > ... return sys._getframe(1).f_code.co_name Be aware thou

Re: function name

2010-04-28 Thread Terry Reedy
On 4/28/2010 3:20 PM, Alf P. Steinbach wrote: * Richard Lamboj: is there any way to get the name from the actual called function, so that the function knows its own name? There was an earlier thread about this not very long ago. General consensus, as I recall, to replace function with an obj

Re: function name

2010-04-28 Thread Tim Chase
On 04/28/2010 01:50 PM, Emile van Sebille wrote: On 4/28/2010 11:44 AM Richard Lamboj said... is there any way to get the name from the actual called function, so that the function knows its own name? >>> def test():pass ... >>> dir(test) ['__call__', '__class__', '__closure__', '__code_

Re: function name

2010-04-28 Thread Alf P. Steinbach
* Richard Lamboj: is there any way to get the name from the actual called function, so that the function knows its own name? There was an earlier thread about this not very long ago. General consensus, as I recall, to replace function with an object of a class (possibly with __call__ method

Re: function name

2010-04-28 Thread Brendan Abel
On Apr 28, 11:44 am, Richard Lamboj wrote: > Hello, > > is there any way to get the name from the actual called function, so that the > function knows its own name? > > Kind Regards, > > Richi If you want to get the function name from within the function itself, check out the inspect module. http

Re: function name

2010-04-28 Thread Sridhar Ratnakumar
On 2010-04-28, at 11:50 AM, Emile van Sebille wrote: > On 4/28/2010 11:44 AM Richard Lamboj said... >> >> Hello, >> >> is there any way to get the name from the actual called function, so that the >> function knows its own name? >> >> Kind Regards, >> >> Richi > ActivePython 2.6.1.1 (ActiveSt

Re: function name

2010-04-28 Thread Peter Otten
Richard Lamboj wrote: > is there any way to get the name from the actual called function, so that > the function knows its own name? >>> import sys >>> def my_name(): ... return sys._getframe(1).f_code.co_name ... >>> def rumpelstilzchen(): ... print u"Ach, wie gut dass niemand weiß, dass

Re: function name

2010-04-28 Thread Emile van Sebille
On 4/28/2010 11:44 AM Richard Lamboj said... Hello, is there any way to get the name from the actual called function, so that the function knows its own name? Kind Regards, Richi ActivePython 2.6.1.1 (ActiveState Software Inc.) based on Python 2.6.1 (r261:67515, Dec 5 2008, 13:58:38) [MSC v

Re: Function name unchanged in error message

2010-02-01 Thread Gabriel Genellina
En Sat, 30 Jan 2010 06:28:19 -0300, Peter Otten <__pete...@web.de> escribió: Gabriel Genellina wrote: En Fri, 29 Jan 2010 13:09:40 -0300, Michele Simionato escribió: On Jan 29, 2:30 pm, andrew cooke wrote: Is there any way to change the name of the function in an error message? In the ex

Re: Function name unchanged in error message

2010-01-30 Thread Steven D'Aprano
On Sat, 30 Jan 2010 14:26:43 -0800, andrew cooke wrote: > On Jan 29, 11:50 am, exar...@twistedmatrix.com wrote: >> new.function and new.code will let you construct new objects with >> different values (and copying over whichever existing attributes you >> want to preserve). > > unfortunately new

Re: Function name unchanged in error message

2010-01-30 Thread andrew cooke
On Jan 29, 1:09 pm, Michele Simionato wrote: > On Jan 29, 2:30 pm, andrew cooke wrote: > > > Is there any way to change the name of the function in an error > > message?  In the example below I'd like the error to refer to bar(), > > for example (the motivation is related function decorators - I'

Re: Function name unchanged in error message

2010-01-30 Thread andrew cooke
On Jan 30, 7:17 pm, andrew cooke wrote: > On Jan 29, 5:37 pm, "Gabriel Genellina" > wrote: > > > The decorator module is a very fine addition to anyone's tool set -- but   > > in this case it is enough to use the wraps() function from the functools   > > standard module. > > ah, thanks!  i though

Re: Function name unchanged in error message

2010-01-30 Thread andrew cooke
On Jan 29, 11:50 am, exar...@twistedmatrix.com wrote: > new.function and new.code will let you construct new objects with > different values (and copying over whichever existing attributes you > want to preserve). unfortunately new is deprecated and dropped from 3. i can't see how the same functi

Re: Function name unchanged in error message

2010-01-30 Thread andrew cooke
On Jan 29, 5:37 pm, "Gabriel Genellina" wrote: > The decorator module is a very fine addition to anyone's tool set -- but   > in this case it is enough to use the wraps() function from the functools   > standard module. ah, thanks! i thought something like this existed in the standard lib, but c

Re: Function name unchanged in error message

2010-01-30 Thread andrew cooke
On Jan 29, 11:22 am, Peter Otten <__pete...@web.de> wrote: > The name is looked up in the code object. As that is immutable you have to > make a new one: [details snipped] thanks very much! sorry i didn't reply earlier - been travelling. (also, thanks to any other replies - i'm just reading thro

Re: Function name unchanged in error message

2010-01-30 Thread Peter Otten
Gabriel Genellina wrote: > En Fri, 29 Jan 2010 13:09:40 -0300, Michele Simionato > escribió: > >> On Jan 29, 2:30 pm, andrew cooke wrote: >>> Is there any way to change the name of the function in an error >>> message? In the example below I'd like the error to refer to bar(), >>> for example

Re: Function name unchanged in error message

2010-01-29 Thread Gabriel Genellina
En Fri, 29 Jan 2010 13:09:40 -0300, Michele Simionato escribió: On Jan 29, 2:30 pm, andrew cooke wrote: Is there any way to change the name of the function in an error message? In the example below I'd like the error to refer to bar(), for example (the motivation is related function decora

Re: Function name unchanged in error message

2010-01-29 Thread Michele Simionato
On Jan 29, 2:30 pm, andrew cooke wrote: > Is there any way to change the name of the function in an error > message?  In the example below I'd like the error to refer to bar(), > for example (the motivation is related function decorators - I'd like > the wrapper function to give the same name) Us

Re: Function name unchanged in error message

2010-01-29 Thread exarkun
On 02:10 pm, c...@rebertia.com wrote: On Fri, Jan 29, 2010 at 5:30 AM, andrew cooke wrote: Is there any way to change the name of the function in an error message? �In the example below I'd like the error to refer to bar(), for example (the motivation is related function decorators - I'd like t

Re: Function name unchanged in error message

2010-01-29 Thread Peter Otten
andrew cooke wrote: > Is there any way to change the name of the function in an error > message? In the example below I'd like the error to refer to bar(), > for example (the motivation is related function decorators - I'd like > the wrapper function to give the same name) > def foo(): > ..

Re: Function name unchanged in error message

2010-01-29 Thread Chris Rebert
On Fri, Jan 29, 2010 at 5:30 AM, andrew cooke wrote: > Is there any way to change the name of the function in an error > message?  In the example below I'd like the error to refer to bar(), > for example (the motivation is related function decorators - I'd like > the wrapper function to give the s

Re: Function name unchanged in error message

2010-01-29 Thread Jean-Michel Pichavant
andrew cooke wrote: Is there any way to change the name of the function in an error message? In the example below I'd like the error to refer to bar(), for example (the motivation is related function decorators - I'd like the wrapper function to give the same name) def foo(): ...

Re: Function name limit in Python ?

2009-02-14 Thread Steven D'Aprano
Linuxguy123 wrote: > Excuse my ignorance, but is there a limit to the size of function names > in Python ? > > I named a function getSynclientVersion() and I got an error when I > called it. No no, don't tell us what error you got! I love guessing games. I'm guessing you got either a SyntaxErr

Re: Function name limit in Python ?

2009-02-14 Thread Albert Hopkins
On Sat, 2009-02-14 at 07:45 -0700, Linuxguy123 wrote: > Excuse my ignorance, but is there a limit to the size of function names > in Python ? > > I named a function getSynclientVersion() and I got an error when I > called it. You forgot to paste the error. -- http://mail.python.org/mailman/lis

Re: Function name limit in Python ?

2009-02-14 Thread Paul McGuire
On Feb 14, 8:45 am, Linuxguy123 wrote: > Excuse my ignorance, but is there a limit to the size of function names > in Python ? > > I named a function getSynclientVersion() and I got an error when I > called it.  I renamed the same function to getSCVersion() and it called > fine. > > Why ? > Hello

Re: Function name limit in Python ?

2009-02-14 Thread MRAB
Linuxguy123 wrote: Excuse my ignorance, but is there a limit to the size of function names in Python ? I named a function getSynclientVersion() and I got an error when I called it. I renamed the same function to getSCVersion() and it called fine. Why ? Probably a just spelling mistake. Double