A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-August/037386.html below:

A syntax for function attributes?

[Python-Dev] Re: A syntax for function attributes? [Python-Dev] Re: A syntax for function attributes?Pat Miller patmiller@llnl.gov
Thu, 31 Jul 2003 16:34:25 -0700
Mark writes:

> def heres_my_function_name(args):
>    heres_my_function_name.my_attribute = "Foo"
> 
> Without a special syntax, I think we'll see more and more abuses of __doc__, like
> 
> def heres_my_function_name(args):
>    """my_attribute = "Foo" """ 

Worse than just being yucky, it is also dangerous to count on
a function keeping the same name or being available in
its context.  Another argument for keeping the sytax
tightly bound to the declaration.

def heres_my_function_name(args):
     heres_my_function_name.my_attribute = "Foo"

callbacks = [ heres_my_function_name, something_else, and_some_more]
del heres_my_function_name

Now, heres_my_function_name fails because the name "heres_my_function_name"
is no longer in the global space.

I actually do sometimes overwrite functions (e.g. replacing a generic
function with a specialized one).





-- 
Patrick Miller | (925) 423-0309 | http://www.llnl.gov/CASC/people/pmiller

I don't want yes men around me. I want everyone to tell
the truth, even if it costs them their jobs.  -- Samuel Goldwyn




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4