[Python-Dev] Object customization
Ken Manheimer
klm@digicool.com
Sun, 16 Apr 2000 18:21:59 -0400 (EDT)
On Sun, 16 Apr 2000, Skip Montanaro wrote:
>
> Ken> We haven't even seen a satisfactory approach to referring to the
> Ken> function, itself, from within the function. Maybe it's not even
> Ken> desirable to be able to do that - that's an interesting question.
>
> I hereby propose that within a function the special name __ refer to the
> function. You could have
>
> def fact(n):
> if n <= 1: return 1
> return __(n-1) * n
>
> You could also refer to function attributes through __ (presuming Barry's
> proposed patch gets adopted):
At first i thought you were kidding about using '__' because '_' was taken
- on lots of terminals that i use, there is no intervening whitespace
separating the two '_'s, so it's pretty hard to tell the difference
between it and '_'!
Now, i wouldn't mind using '_' if it's available, but guido was pretty
darned against using it in my initial designs for packages - i wanted to
use it to refer to the package containing the current module, like unix
'..'. I gathered that a serious part of the objection was in using a
character to denote non-operation syntax - python just doesn't do that.
I also like the idea of using a function instead of a magic variable -
most of python's magic variables are in packages, like os.environ.
Ken
klm@digicool.com