Sponsored Links

Python Training Courses

www.bodenseo.com/     A leading provider in Python and programming training classes

Django/Python Development

www.tivix.com/     We build complex Web/Mobile Apps. From Idea/Spec to Deployment

Learning Python

www.lynda.com/Python     Python video tutorials taught by pros online. Get Started.

Learn Python $97

www.stoneriverelearning.com/     Order Learn Python now! No experience required

Enroll in Python Courses

www.ucsc-extension.edu/     Learn Python Programming Hands-on! Silicon Valley Online. Self-paced.

Python Questions?

www.wizpert.com/     Get instant 1-on-1 advice. Our experts love to help!

learn python (read all 10 entries…)
Typo Yields Weirdness

Dictionaries are one of the built in types that I really like in Python. (I think of them as the equivalent of dt and dd in HTML, if that helps anyone.)

But I made a typo, and that typo works. Now the typo is playing with my head. Take a look as this history from the Python Interpreter:

>>> d={} 
>>> d['key']=d
>>> d
{'key': {...}}

Yes, if this is correct, Python knows that dictionary ‘d’ has a key named ‘key’ that contains dictionary ‘d’.

What makes this example particularly cool is the {...}, which shows Python knows that there is no bottom at the end of this dictionary.

This is so cool.

These examples work too:

>>> d['key']['key']
{'key': {...}}
>>> d['key']['key']['key']['key']['key']['key']
{'key': {...}}



Comments:

wintermute1974 has gotten 1 cheer on this entry.

  • Parano cheered this 7 years ago

 

I want to:
43 Things Login