[Python-bugs-list] [ python-Feature Requests-622230 ] def object.new_method(self):
SourceForge.net
noreply@sourceforge.net
Fri, 27 Jun 2003 23:39:13 -0700
Feature Requests item #622230, was opened at 2002-10-12 01:04
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=622230&group_id=5470
Category: Parser/Compiler
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Dan Parisien (mathematician)
Assigned to: Nobody/Anonymous (nobody)
Summary: def object.new_method(self):
Initial Comment:
I want to be able to create functions inside objects
instead of having to do:<code>
class x:
pass
def new_method(self):
pass
x.new_method = new_method
del new_method
</code>
I want to do: <code>
class x:
pass
def x.new_method(self):
pass
</code>
Why isn't this possible? Wouldn't it be cool?
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-06-28 01:39
Message:
Logged In: YES
user_id=80475
Closed due to lack of further development or support.
----------------------------------------------------------------------
Comment By: Brett Cannon (bcannon)
Date: 2003-05-12 21:56
Message:
Logged In: YES
user_id=357491
I am with Raymond and Martin on this; I don't see this being worth the
hassle of implementing. Should we reject this or leave it open for
contemplative thought?
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-03 04:16
Message:
Logged In: YES
user_id=80475
This is an interesting idea but (from your example) the
only way to use it is when the names are already known
statically when writing the code. And, if you already know
x and newmethod, why not write:
class x:
def new_method(self):
pass
The only use case I can see is if the source for x is
unaccessible in another module:
from M import x
def x.newmethod(self):
pass
All in all, this would be a tough sell (and likely require a
PEP) because the effort to implement it, document it,
explain it and support it isn't warrented by the two line
savings over what can already be done. Further, the
current one-way-to-do-it is robust, clear, and can work
dynamically as well as at coding time.
I'm -1 on this one but do think it reflects original creative
thought.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-11-04 05:29
Message:
Logged In: YES
user_id=21627
It's simply not possible because nobody has though of that.
I personally would not consider it cool: Python expresses
nesting of definition with indentation, not with full-stop
separators. Unless you implement it yourself, I'd expect
that it is unlilkely that anybody will act on this request
in the coming years.
----------------------------------------------------------------------
Comment By: Dan Parisien (mathematician)
Date: 2002-10-12 01:08
Message:
Logged In: YES
user_id=118203
Repost with attempted better formatting:
I don't want to do:
class x:
pass
def new_method(self):
pass
x.new_method = new_method
del new_method
I want to do:
class x:
pass
def x.new_method(self):
pass
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=622230&group_id=5470