Square bracket and dot notations?

2011-06-11 Thread Asen Bozhilov
Hi all, I am beginner in Python. What is interesting for me is that Python interpreter treats in different way dot and square bracket notations. I am coming from JavaScript where both notations lead prototype chain lookup. In Python it seems square bracket and dot notations lead lookup

Re: Square bracket and dot notations?

2011-06-11 Thread Andrew Berg
On 2011.06.11 04:41 AM, Asen Bozhilov wrote: Hi all, I am beginner in Python. What is interesting for me is that Python interpreter treats in different way dot and square bracket notations. I am coming from JavaScript where both notations lead prototype chain lookup. In Python it seems

Re: Square bracket and dot notations?

2011-06-11 Thread Ben Finney
Asen Bozhilov asen.bozhi...@gmail.com writes: I am beginner in Python. What is interesting for me is that Python interpreter treats in different way dot and square bracket notations. I am coming from JavaScript where both notations lead prototype chain lookup. Run, don't walk, to the Python

Re: Square bracket and dot notations?

2011-06-11 Thread Francesco Bochicchio
On 11 Giu, 11:41, Asen Bozhilov asen.bozhi...@gmail.com wrote: Hi all, I am beginner in Python. What is interesting for me is that Python interpreter treats in different way dot and square bracket notations. I am coming from JavaScript where both notations lead prototype chain lookup

Re: Square bracket and dot notations?

2011-06-11 Thread Asen Bozhilov
? By items I mean items which are accessible trough square bracket notation. I really like Pythonic way here. Square bracket and dot notations allow me to create an object which can be true hash map and meanwhile to support independent methods from its keys. I could have an item and a property

Re: Square bracket and dot notations?

2011-06-11 Thread Terry Reedy
which are accessible trough square bracket notation. .attributes are inherited. [index-or-key] items are not. I really like Pythonic way here. Square bracket and dot notations allow me to create an object which can be true hash map and meanwhile to support independent methods from its keys. I

Re: Square bracket and dot notations?

2011-06-11 Thread Asen Bozhilov
Terry Reedy wrote: Right. d.items is a dict method. d['items'] is whatever you assign. Named tuples in the collections modules, which allow access to fields through .name as well as [index], have the name class problem. All the methods are therefore given leading underscore names to avoid