473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.

Aug 17 '08 #1
4 883
On 17 Aug, 21:29, castironpi <castiro...@gmail.comwrote:
>
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:

http://www.python.org/dev/peps/pep-0363/

Paul
Aug 17 '08 #2
On Aug 17, 2:46*pm, Paul Boddie <p...@boddie.org.ukwrote:
On 17 Aug, 21:29, castironpi <castiro...@gmail.comwrote:
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:

http://www.python.org/dev/peps/pep-0363/

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.

Aug 17 '08 #3
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.

Aug 17 '08 #4
On Aug 17, 3:05*pm, Fredrik Lundh <fred...@pythonware.comwrote:
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.
Aug 17 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Greg Scharlemann | last post by:
I am attempting to populate a drop down menu based on the selection of a different drop down menu. However, it is not working correctly, I cannot figure out for the life of me what exactly happens...
4
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see...
15
by: Kapil Jain | last post by:
Dear All, What i need to achieve is : I am generating dynamic text boxes thru dhtml coding, i need onChange event of oragnistation text box i.e dynamically generated on click of "More" button in...
10
by: jaxent | last post by:
Does anyone know why IE gives the error "'document.myForm.dummy' is null or not an object" on the following page? Firefox does what I expect, creates a text box and writes "hello" in it. <html>...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.