python

Something new every day...

This one's my fault for skipping through the Python docs, but I recently found __getattr__ which is incredibly useful. One of those nifty features I missed from PHP when programming Python was the $$name variables, where I could name a variable based on the content of another or retrieve variables from the string (name) stored in another variable. __getattr__ does just this, and even better - You can call functions or methods with it too!

So here's my tip of the day: Both Python and __getattr__ are awesome Laughing

Rating: 
Tags: