Python Basics
December 23rd, 2009 --
1 Comment
If you have been reading previous blog posts, I have been using a monitoring tool called Zenoss. Under the hood there is a lot of Python stuff. So I decided to start learning Python. Python can run on Mac, Linux, Unix, and Windows. Let me show you some basic on what you can do in python.
#!/usr/bin/python firstName = "John" lastName = "Costanzo" # Lets just print out one variable print firstName # Now lets complete my name print firstName, lastName # Lets just print something random without a variable print "The sun is warm. The grass is green" # Now I will print some variables followed by some text print firstName, lastName, "Is the owner of this blog."
For more information on Python you can visit this site.
Good start. I’d start using variable interpolation next.
Also, at this point in the game you should probably stick with Python 2.6 syntax and above.
Here’s a Python 2.x way to do what you did above:
firstName = “John”
lastName = “Costanzo”
# Now I will print some variables mixed in with some text
print “%s %s Is the owner of this blog.” % (firstName, lastName)