A look at Python

Okay, on Sunday I went over a list of possible programming languages to learn. It ended with me decided to learn all of them, but unsure as to what to learn first. I decided to go over each of them and figure out what I thought about them. How would I do this? What I have decided to do is see how complex it is to do the same thing in each language. What better to test out a language than to create a class?
Yesterday, I went over the Perl. Today is Python’s turn.

Python Class

class Person:
	def __init__(self, firstname, lastname, age):
		self.firstname = firstname
		self.lastname = lastname
		self.age = age

	def IntroduceYourself(self):
		return "Hello, my name is " + self.firstname + " " + self.lastname + ", and I am " + str(self.age) + " year(s) old."

Python Implementation

dan = Person("Dan", "Appleyard", 27)

print dan.IntroduceYourself()

My Thoughts

Very different than Perl, wouldn’t you agree? Seven lines of code to create the same that class that took 17 lines in Perl. I kind of like it. Indentation is key with Python. Tomorrow, I am going to go over the same class implementation in PHP. Until tomorrow then!

This entry was posted in Development, Learning, Python and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>