Sunday, October 26, 2014

Obviously I still have a lot to learn about the language and it's application, but being exposed to it for the most part of my internship at Symph, I CAN say though that I have a pretty good grasp of the language's basics.

I greatly referred to Learn Python The Hard Way when I first started, as referred by Albert, and it's safe to say that for those interested in learning Python, their modules are the way to go. Not only have I personally experienced the course's effectiveness, but so did many of the professionals that apply the language in real-world projects when they first started out.

PizzaPy is a meetup group that gets together every month for an evening of pizza, beer and Python. Veterans and beginners freely enthuse about the language and often have a main topic to talk about every meetup. Although being aware of their gatherings for a while now, the celebration of their first anniversary was my the first time I actually participated in a PizzaPy meetup.

PizzaPy's First Anniversary celebrated at The TIDE

The whole day workshop was packed with interesting topics for both Python veterans and beginners alike. It began with a Python for Beginners talk, enough to help us survive the day at least, and then was eventually followed by A Sip From The Flask and a Crash Course on SqlAlchemy.

1) Python variables are Nametags

Many programmers visualize variables as containers of values that they want represented.

Python, instead, uses variables as similar to nametags, pointing to the objects or values they want to manipulate. Python creates the value first and then associates the variable to that value. If another variable has that same value, it is again associated to the already made value.

There is no duplication of values in Python

2) Python lists are "arrays on steroids"

As Daryl, PizzaPy organizer and first speaker, colorfully put it. Python's list is equivalent to Java's array, with a little perks. For example:

array = [1, 2, 3, 4]
and printing array[0] will obviously print 1, right? Now try printing array[-1]. Using negative numbers as indices for the array is acceptable in Python. Their output will be the nth element from the last end of the array. In this case, it's 4. Neat, right? A few other tricks:

print array[1:3]
>>> [2, 3]
print array[:2]
>>> [1, 2]
print array[2:]
>>> [4, 3]

3) Four Spaces is Best

It was in this event that I realized that in programming etiquette, when indenting your code, using four spaces is best rather than simply using TAB (which I am guilty of).

Snippet of code from a project in Sublime Text 2

Reason is that every PC has its own set of spaces for TAB, it could be five or six spaces by default. So when you use your TAB, your code may look right in your machine but when another coder views your code, it'll look totally messed up if his TAB is set in a different number of spaces.

Why is this so important in Python? It is because the language does not have any braces({}) to denote blocks. The interpreter greatly relies on the indents to identify each block of code.

4) The Difference between "..." and '...'

Basically nothing, in general. Single-quotes and double-quotes practically work the same way in Python. The difference, I learned was:

print 'someone is "happy"'
someone is "happy"
print "someone's happy"
>>> someone's happy

Use single-quotes when you want to display strings with double-quotes and use single-quotes when you want to display strings with single-quotes.

5) Flask was fun

Flask is a microframework  for Python based on Wrkzeug, Jinja 2, and good intentions. *

Steve, the second speaker, did a great job with introducing us to Flask. I used Google App Engine for Askbuildshare and I'm still a beginner at it so I'm not quite sure how it compares to Flask but Steve, when asked about Flask's scalability, said that their systems "haven't crashed yet" so I'm assuming Flask is reliable, at least for some apps that aren't heavy-duty.

My first Flask-run app, made with a lot of help

Trying it out and getting it to work was a really fun learning process for me and I'm looking to explore on it more, just to get a better sense of appreciation for the framework (then again, I still have Google App Engine to mess with so this will still be a while). If you want to learn more about Flask and it's applications, check out Steve's A Sip From The Flask. A very fun and cool intro to the framework and definitely work walking through.

So as you can see, I've only skimmed the surface of what I should have learned at the event/workshop and I definitely still am a sprout in the forest. I was quite happy to know, though, that majority of the event's participants were also beginners in Python like myself so I didn't feel too left out (although a lot of them were already masters of other languages in their line of work. meep). The event was smooth and fact-filled and was a day well spent. Hopefully I'll get to attend more PizzaPy meetups in the future and get to relate more with the hardcore programmers in events like these. 


Post a Comment

Blog Archive

Popular Posts