Friday, May 29, 2009

In Python you can get the current directory using the function getcwd from the os module. The output is displayed as a string. Basically corresponds to the pwd command that you can use in a Unix terminal.

Tuesday, May 5, 2009

How do you clear the terminal in Mac OS X in a similar way as you can do in Windows with the command cls?

If you use clear in the Mac OS X terminal (and also on Linux) what you get is a simple page scrolling. On the other hand, in the windows terminal the command cls works actually cleaning all the previously entered commands!

To clean the Mac-terminal the Windows-way you have to use the keyboard shortcut Command+K.
That's it! Enjoy!

repr() gives you the canonical representation of an object, i.e. the way you have to write in your file (strings must have at least apostrophes ); On the other hand, str() gives you a nice representation of an object, and this, for a string, means no apostrophes!

1 my_name="eddie"
2 print "My name is %s" %(my_name) # This is OK
3 print "My name is %s" %(my_name) # This will give you an error
4 print "My name is %s", my_name # This is OK but the output is not equal to line 2 (power of comma!!!)