Re: Accessing func_name from inside a function

2006-03-27 Thread Scott David Daniels
Eyal Lotem wrote: By the way, the real problem here is referencing by name, rather than using true references. Which is the result of using a textual language. The real solution would be to store real-references to the function and only present the name in a graphical interface. There is a

Re: Accessing func_name from inside a function

2006-03-27 Thread Eyal Lotem
Scott David Daniels wrote: Eyal Lotem wrote: By the way, the real problem here is referencing by name, rather than using true references. Which is the result of using a textual language. The real solution would be to store real-references to the function and only present the name in a

Re: Accessing func_name from inside a function

2006-03-26 Thread Ron Adam
Alex Martelli wrote: Personally, I'd rather have a 3.0 keyword referring to the current object (module for module toplevel code, class for classbody toplevel code, function for code within a function) -- say for the sake of argument the keyword is 'current'; this would allow current.__name__

Re: Accessing func_name from inside a function

2006-03-26 Thread Bruno Desthuilliers
James Thiele a écrit : I'd like to access the name of a function from inside the function. My first idea didn't work. def foo(): ... print func_name ... foo() Traceback (most recent call last): File stdin, line 1, in ? File stdin, line 2, in foo NameError: global name

Re: Accessing func_name from inside a function

2006-03-26 Thread Alex Martelli
Ron Adam [EMAIL PROTECTED] wrote: A Current key word would fix this. Or possibly This which would be short for This object. I think This would cause huge confusion, since in other popular language the keyword this means (a pointer/reference to) the instance variable on which the method is

Re: Accessing func_name from inside a function

2006-03-26 Thread Alex Martelli
James Thiele [EMAIL PROTECTED] wrote: I'd like to access the name of a function from inside the function. My first idea didn't work. def foo(): ... print func_name ... foo() Traceback (most recent call last): File stdin, line 1, in ? File stdin, line 2, in foo NameError:

Re: Accessing func_name from inside a function

2006-03-26 Thread Eyal Lotem
Steven D'Aprano wrote: On Sun, 26 Mar 2006 10:19:36 +1000, Ben Finney wrote: James Thiele [EMAIL PROTECTED] writes: I'd like to access the name of a function from inside the function. A function, like most other objects in Python, can have any number of names bound to it without the

Re: Accessing func_name from inside a function

2006-03-26 Thread Ron Adam
Alex Martelli wrote: Ron Adam [EMAIL PROTECTED] wrote: A Current key word would fix this. Or possibly This which would be short for This object. I think This would cause huge confusion, since in other popular language the keyword this means (a pointer/reference to) the instance variable

Accessing func_name from inside a function

2006-03-25 Thread James Thiele
I'd like to access the name of a function from inside the function. My first idea didn't work. def foo(): ... print func_name ... foo() Traceback (most recent call last): File stdin, line 1, in ? File stdin, line 2, in foo NameError: global name 'func_name' is not defined My second

Re: Accessing func_name from inside a function

2006-03-25 Thread Martin v. Löwis
James Thiele wrote: Is there a standard way of getting the name of a function from inside the function? No, there isn't. Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing func_name from inside a function

2006-03-25 Thread Kent Johnson
James Thiele wrote: I'd like to access the name of a function from inside the function. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66062 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing func_name from inside a function

2006-03-25 Thread James Thiele
OK. But that's just as ugly as my attempt. -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing func_name from inside a function

2006-03-25 Thread Ben Finney
James Thiele [EMAIL PROTECTED] writes: I'd like to access the name of a function from inside the function. A function, like most other objects in Python, can have any number of names bound to it without the object being informed. Any of those names can then be used to reference the object, and

Re: Accessing func_name from inside a function

2006-03-25 Thread Steven D'Aprano
On Sun, 26 Mar 2006 10:19:36 +1000, Ben Finney wrote: James Thiele [EMAIL PROTECTED] writes: I'd like to access the name of a function from inside the function. A function, like most other objects in Python, can have any number of names bound to it without the object being informed. Any

Re: Accessing func_name from inside a function

2006-03-25 Thread Alex Martelli
Ben Finney [EMAIL PROTECTED] wrote: James Thiele [EMAIL PROTECTED] writes: I'd like to access the name of a function from inside the function. A function, like most other objects in Python, can have any number of names bound to it without the object being informed. Any of those Yes,