Structure accessible by attribute name or index options
Posted
by Bruno DeGoia
on Stack Overflow
See other posts from Stack Overflow
or by Bruno DeGoia
Published on 2010-03-25T01:55:29Z
Indexed on
2010/03/25
2:03 UTC
Read the original article
Hit count: 288
python
|data-structures
I am very new to Python, and trying to figure out how to create an object that has values that are accessible either by attribute name, or by index. For example, the way os.stat() returns a stat_result or pwd.getpwnam() returns a struct_passwd.
In trying to figure it out, I've only come across C implementations of the above types. Nothing specifically in Python. What is the Python native way to create this kind of object?
I apologize if this has been widely covered already. In searching for an answer, I must be missing some fundamental concept that is excluding me from finding an answer.
© Stack Overflow or respective owner