Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44704
| From | dieter <dieter@handshake.de> |
|---|---|
| Subject | Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. |
| Date | 2013-05-04 07:56 +0200 |
| References | <mailman.1257.1367537690.3114.python-list@python.org> <518302d7$0$29971$c3e8da3$5496439d@news.astraweb.com> <CAJxoosf4NLafEKHy3CSk1GBSO2RCxk_9SsxPHraOa-JU45jByg@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1285.1367646997.3114.python-list@python.org> (permalink) |
"Mr. Joe" <titanix88@gmail.com> writes:
> ...
> Then I came to know that 'property' does not play well
> with polymorphic code. :(
Can you elaborate?
I like "polymorphic code" and decorators (such a "property")
never met a problem with the two working nicely together.
> I resorted to some lambda hacks learned from
> stackoverflow.com to solve the problem. I know that it's the correct way
> for decorators to work, but still, it would be nice to have a language
> level solution.
There are two approaches: change the language or learn how the language works.
I am very happy that the Python developers try hard to retain backward
compatible and, consequently, are very reluctant towards language changes.
I would hate should the decorator behavior change in an incompatible
way.
On the other hand, decorators are very easy to understand: they are
just syntactic sugar:
@<dec_expression>
def f(...): ...
is equivalent to:
def f(...): ...
f = <dec_expression>(f)
The "property" decorator uses an additional concept: "descriptor"s.
A "descriptor" allows you to customize attribute access.
These two concepts graped, the "property" decorator should no longer
cause surprises -- even in "polymorphic code".
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Debugging difficulty in python with __getattr__, decorated properties and AttributeError. "Mr. Joe" <titanix88@gmail.com> - 2013-05-03 05:34 +0600
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-03 00:20 +0000
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. "Mr. Joe" <titanix88@gmail.com> - 2013-05-03 13:52 +0600
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-04 06:29 +0000
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. "Mr. Joe" <titanix88@gmail.com> - 2013-05-14 21:09 +0600
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. dieter <dieter@handshake.de> - 2013-05-15 08:15 +0200
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. "Mr. Joe" <titanix88@gmail.com> - 2013-05-15 22:38 +0600
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. dieter <dieter@handshake.de> - 2013-05-04 07:56 +0200
csiph-web