Live data from Hacker News

Learn Python in minutes

learnxinyminutes.com

11–20 of 59 posts

Re: Learn Python in minutes

#11
Nice and concise. It would be complemented nicely by a list of Python "gotchas".

E.g., off the top of my head, mutable default arguments, or trying to catch multiple exceptions with "except Exception1, Exception2:". That's the kind of thing people new to the language can spend a lot of time debugging when they first run into it.

Edit: and any introduction to tuples should probably show how to write empty and one-element tuples, since that can be non-intuitive. Writing (1) instead of (1,) is also a fairly common gotcha.

Re: Learn Python in minutes

#12
While I see value in a cheat sheet that helps you remember a language's features, using the words 'Learn X in minutes' is a bit stretching it. It takes a good few weeks to get comfortable building something in a new language.

This is a good cheat sheet.

Re: Learn Python in minutes

#13
post #9

What does he mean by "# Tuples are created by default if you leave out the parentheses". With or without the parens I'm getting the same result for "a, b, c = (1, 2, 3)"

You get a list if you do "object_a = [1, 2, 3]" and a tuple if you do "object_b = (1, 2, 3)". Then try "object_c = 1, 2, 3" and you'll also get the tuple.

Re: Learn Python in minutes

#14
I added a couple of lines to fix errors I ran into with Python 2.7.3:

Add about line 89, before assignment to some_var,

    a, b = 3, 4
Added a try-except around line 186, to guard the KeyError,

    try:   
        filled_dict["four"] #=> KeyError
    except KeyError:
        print "Raises a KeyError"
Added a definition of foo around 320, so calls would work

    def foo(*seq, **dict): pass

Re: Learn Python in minutes

#15
What this needs is Rap Genius style annotations, so people can make comments and additions. I recently (re:yesterday) decided to pick up and try out python for a small project and this is a great quick and dirty start.

Re: Learn Python in minutes

#18
int, boolean, float etc. are not _primitive_ data types in python. If you say that, you really have no idea, what you are talking about. They are objects like everything else. You can inherit from them and do all the good OO stuff.

Sorry for the nitpicking, but calling them primitive types, is just plain wrong.

Re: Learn Python in minutes

#20
post #4

Having just recently learned Python the "hard" way, I really wish I would've seen this beforehand. Even having done some hands-on work and a lot of Googling, I picked up a few new things from this I hadn't seen before. Thanks!

Same here, I just went through the same course. (Learn Python the hard way). Coming from a php background I had (and am having) problems wrapping my head around the packaging section. I started to lose interest because of it. It's as if I hit a wall. Can any Python hackers offer some good resources for learning more about packaging?

Are you trying to use packages or create them?
Post reply on HN