|  | dynamic attribute syntax |  | |
| | | castironpi |  |
| Posted: Sun Aug 17, 2008 7:29 pm Post subject: dynamic attribute syntax |  |
Hi all, Thinking of a syntax for 'getattr' and 'setattr' dynamic access.
'obj.prop' has an easy access, but
att= 'prop' getattr( obj, att )
is much clumsier, while no less useful, maybe more.
What are the changes, pros and cons, involved in something like:
obj:att for a dynamic access, and obj.att for static?
Snice readability is a factor, I'm open to other markings than ':'. '$' and '?' are available, and I note that a~b, a:b, and, a!b for identifiers 'a' and 'b' are unambiguous. |
| |
| | | Fredrik Lundh |  |
| Posted: Sun Aug 17, 2008 7:29 pm Post subject: Re: dynamic attribute syntax |  |
castironpi wrote:
| Quote: | 'obj.prop' has an easy access, but
att= 'prop' getattr( obj, att )
is much clumsier, while no less useful, maybe more.
|
maybe more? ok, you *are* utterly and completely unable to post anything that makes any sense at all to anyone that uses Python. plonkeliplonk. |
| |
| | | Paul Boddie |  |
| Posted: Sun Aug 17, 2008 7:46 pm Post subject: Re: dynamic attribute syntax |  |
On 17 Aug, 21:29, castironpi <castiro...@gmail.com> wrote:
| Quote: | What are the changes, pros and cons, involved in something like:
obj:att for a dynamic access, and obj.att for static?
|
A previous proposal and discussion can be found here:
LINK
Paul |
| |
| | | castironpi |  |
| Posted: Sun Aug 17, 2008 8:05 pm Post subject: Re: dynamic attribute syntax |  |
On Aug 17, 2:46 pm, Paul Boddie <p...@boddie.org.uk> wrote:
| Quote: | On 17 Aug, 21:29, castironpi <castiro...@gmail.com> wrote:
What are the changes, pros and cons, involved in something like:
obj:att for a dynamic access, and obj.att for static?
A previous proposal and discussion can be found here:
LINK
Paul
|
Thanks for the reference. Well, check out the two alternatives, a~b and a!b, which are easy on the eyes, and weren't proposed, but don't allow expressions. (Turns out 'if a:b' is valid, so never mind that one.) I also won't let you forget that $ and ? are unused so far too. I see syntax was one of the complaints. |
| |
| | | castironpi |  |
| Posted: Sun Aug 17, 2008 8:15 pm Post subject: Re: dynamic attribute syntax |  |
On Aug 17, 3:05 pm, Fredrik Lundh <fred...@pythonware.com> wrote:
| Quote: | castironpi wrote: 'obj.prop' has an easy access, but
att= 'prop' getattr( obj, att )
is much clumsier, while no less useful, maybe more.
maybe more? ok, you *are* utterly and completely unable to post anything that makes any sense at all to anyone that uses Python. plonkeliplonk.
|
More constructive contributions on both sides there. Good one. |
| |
|
|