Interesting Tips for Python

I am teaching myself Python. Initially looking at Python, I thought this language is a joke. No curly braces, no end statements, just indentation? REALLY?! No explicit declarations of variables, come on.

But being a patient person, I am giving it a good try. There are some good things about it, after all Google uses it for a lot of their development, as does Youtube. Python has some really nice functional aspects to it (ie. tuples, lists, map reduce/filter) and it is relatively fast for an interpretted language.


It has some decent unicode support. One thing that is rather interesting if you want to compare a unicode string with an ASCII string, it will evaluate to true. For example:

>>> s = ‘hello’
>>> u = u’hello’
>>> s == u

Google has a great class that is free for the public if you are interested in. Going through it at your own pace is wonderful, great for a beginner to Python. It was actually developed for their own employees. Thank you Google for providing some great content for the public!!! Yes, that’s right a MS fanboy is praising Google for something, it’s that good! Found below here:

Testing Python Modules

Here is something interesting, modules are objects. This is really, really cool because you can access attributes for the module. So why does this get me excited. Because it allows for some great testing of the functions. It makes test driven development very easy. At the end of your script you can test your code just by running the module. Once the module passes the tests you have set up, the module is ready to be used in another module. This is accomplished like this:

if __name__ == ‘__main__’:
<test statements here>


Have an opinion? Leave an opinion!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s