Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Python

dynamic attribute syntax

 
Jump to:  
 
castironpi
PostPosted: 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
PostPosted: 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
PostPosted: 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
PostPosted: 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
PostPosted: 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.
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

odchudzanie ubezpieczenia turystyczne książka telefoniczna osób prywatnych spa breaks poker