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
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
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
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_
* 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
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
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
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
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
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
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
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'
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
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
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
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
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
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
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
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
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():
> ..
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
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():
...
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
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
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
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
27 matches
Mail list logo