I have a really hard time understanding where methods are defined in python classes. My first contact with programming was with C++ and Java and even if I was messing with them in a very amateurish level, I could find where each class was defined and what methods were defined inside them. Everything was clear and comprehensive. With python everything looks like magic. Methods and properties appearing out of nowhere and somehow easing the task at hand. I am not complaining for their existence but I really can't understand how and what is defined so I can use it.

Enough ranting and let me give an example of what I mean.

Let's have a look at the pygeocoder library located here:
http://code.xster.net/pygeocoder/src/8888c863f907f8a706545fa9b27959595f45f8c5/pygeolib.py?at=default

and a short tutorial on usage by someone unrelated to the author located here: http://www.pixelite.co.nz/article/validate-and-clean-user-submitted-address-data-pygeocoder?&ei=518KU5mcFeim4ASG34Fo?&usg=AFQjCNFgMx8s7wPP6R6CyLLoSAE-Ohh51Q?&sig2=afBUF9yuxbZYB9fcfK9Lmw?&bvm=bv.61725948,d.bGE

The tutorial basicaly says in code that once we obtain the data we can do:

print "address.valid_address: ", address.valid_address
print "address.street_number: ", address.street_number
print "address.route: ", address.route
print "address.sublocality: ", address.sublocality
print "address.locality: ", address.locality
print "address.administrative_area_level_1: ", address.administrative_area_level_1
print "address.country: ", address.country
print "address.postal_code: ", address.postal_code
print "address.coordinates: ", address.coordinates
print "address.formatted_address: ", address.formatted_address

Some properties I can see them defined but some others like sublocality or administrative_area_level_1 I don't see them defined anywhere. Also in the comments in the source code the author says

#You can also choose a different property to display for each lookup #type.
#    Example:
#        result.country__short_name

but I can't understand where that __short_name comes from

I hope I didn't bore you with this long text but this is really confusing for me and I hope someone can help me understand these things.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to