
Learn Python in minutes - jurajpelikan
http://learnxinyminutes.com/docs/python/
======
ufo
"""-delimited text is not actually a comment. Its a multiline string literal

    
    
        x = """aaa
        bbb"""
    

And you can also use single quotes if you want.

    
    
        x = '''aaa'''
    

The reason this might have been confused with a comment is because triple-
quoted strings are often used for documentation strings, a Python feature that
gives special meaning to string literals that occur as the first statement in
a function or class. Those strings get associated to the function as its
documentation and can even be inspected at runtime:

    
    
        def foo():
           "my documentation string"
           return 17
    
        print help(foo)

------
xhrpost
This is exactly what I wanted a few years ago while working on a GAE project.
I had never touched Python but I knew programming and just wanted to know what
the language had and how in basic terms to use it.

I remember picking up a large book from a store shelf titled something like
"Python for Programmers". Thinking, "Oh, this is for people who already know
how to program and just want to learn Python". I open the book randomly and
start reading it's explanation on what functions are in programming and why
they're useful. I sighed and placed the book back on the shelf.

------
chrismorgan
An error: *args arrive as a tuple, not a list, so the first line that
all_the_args(1, 2, a=3, b=4) prints is not:

    
    
        [1, 2]
    

but is instead

    
    
        (1, 2)
    

The second line of that output also happens to be wrong, because printing a
dictionary uses repr() on its keys and values and str.__repr__ normally uses
single quotes, so instead of

    
    
        {"a": 3, "b": 4}
    

It will instead print

    
    
        {'a': 3, 'b': 4}
    

For that matter, I would prefer it if this guide used single quotes primarily;
that is the preferred standard in Python.

------
tveita
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.

~~~
Loadin
Author here.

I didn't want to overload the reader. Perhaps a more in-depth guide is
required.

~~~
sn0v
Hey, thanks for the guide. It's a concise read :) looking forward to the
article on Python 3.

------
thekevan
"Learn X in 30 Days" has gone to "Learn X in Minutes"

I am waiting for "Learn X While You Sleep--wake up as an expert!"

~~~
lifeisstillgood
I used to sleep with a walkman plugged in and playing german vocab - everyone
knew that was guaranteed to work

~~~
tonyplee
I put my computer on youtube's google io talk whenever I can't get to sleep.
It sures put me to sleep fast. :-)

If Michael Jackson just knew that......

~~~
camus
...he would still be alive , lol !

------
ZanderEarth32
This looks very similar to the notes I was taking on my own when going through
"learning python the hardway". Yours are much better and easier to read
though, and make more sense in terms of going from very easy to more
complicated in staggered steps.

Great stuff!

As a sidenote, how does everyone take note (if you even do) when learning
something new like a language or some kind of skill?

~~~
kaoD
I don't take notes.

I learn better when I read the same thing over and over from different
sources, which might have additional details or different points of view.

Not taking notes forces me to go back when I don't remember something, often
finding new sources.

~~~
bitsoda
What taking notes does for me -- and I assume most other people -- is that it
forces me to internalize what I just learned in a way that makes sense to my
brain and fits within previous constructs I've already developed through n
years of living.

------
wf
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.

------
btbuildem
I think you mean to say "glance over and quickly forget the basics of python
in minutes"

~~~
Loadin
Author here.

How would you improve the retention rate?

This article is meant for programmers from other languages who want to quickly
look up a language specific detail.

------
joelg236
Wow. I've only every programmed Java and this looks amazing. I'm so sorry
scripting languages, I've neglected you!

~~~
damon_c
I've been forced to use C# for the last week. I'm so sorry scripting
languages, I'll be back soon! I miss you!

------
cinbun8
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.

------
pgbovine
obligatory norvig:
[http://norvig.com/21-days.html](http://norvig.com/21-days.html)

but all snark aside, good work so far! like the concept.

------
frankcaron
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!

~~~
404error
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?

~~~
tehwebguy
Are you trying to use packages or create them?

~~~
404error
I'm trying to create packages.

I haven't been able to find a decent tutorial on creating packages. That
particular section in "Learn Python the Hard Way" was hard for ME to follow. I
was able to create a package but only after finding a link on stackoverflow
question that then redirected me to a github page containing a sample package
from an individual who also had problems. He states that his package worked
but he wasn't sure if he created the package correctly.

I've tried reading the python documentation but I'm too dumb to understand
some of the language. (No CS background, just a regular dude and a computer
here.)

------
nickpresta
The bit about exceptions, using a comma instead of as, should just be left
out. I don't imagine anyone starting out today is using Python < 2.6, and
having both in the document is confusing.

~~~
adambard
I added that after the fact because someone _did_ try to run the thing on
python 2.4, got an error and was confused about it

~~~
nickpresta
Responded in the ticket, but yeah, totally your call (obviously :D)

------
gshubert17
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

------
fs111
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.

~~~
Loadin
Author here.

Sorry for that. I know they are objects but if you consider everything an
object then really you have no primitives except object itself. Certainly this
has a place in programming philosophy but not really a helpful point in a
language-primer/cheat sheet.

~~~
ufo
I agree that "everything is an object" doesn't mean much but "primitive types"
has a strong meaning when it comes to OO programming so a different term might
be more appropriate.

------
krob
I'm usually a php guy, and recently I had to use some vendor's python api to
do some data integration and this might have come in handy. I picked up
python, or atleast the basic syntax in roughly 1 day, and was done with my
implementation within the next day.

------
cben
This might be even more useful as an ipython notebook so that people can
modify and execute any of the examples. The easiest way to host a notebook
that users can try from their browser seems to be Wakari (public viewing, free
signup needed to modify/run).

------
kunai
I don't know the efficacy of this as an educational tool, but as a Python
programmer, it's a really handy "cheat sheet" to have around whenever doing
general scripting. It's really well written as well.

Kudos to whomever wrote it.

~~~
Loadin
Author here.

Glad you find it useful!

------
ModernTypo
I would love a version of this that is incredibly comprehensive. I mean like,
go over the entire Python doc in this format. Don't get me wrong, this goes
over a lot, and but there's still a lot missing.

------
xutopia
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)"

~~~
madelfio
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.

~~~
cben
You should also mention the 1-item case where the (optional in other cases)
trailing comma is required to form a tuple: (1,)

------
fortepianissimo
One thing is missing: package importing and the related gotchas.

------
StavrosK
And something I wrote seven years ago, for Y = 10:

[http://www.stavros.io/tutorials/python/](http://www.stavros.io/tutorials/python/)

------
smortaz
awesome tutorial. if you need a free Python IDE (based on VS) to try the
exercises in, we just released PTVS 2.0 Beta:
[http://pytools.codeplex.com](http://pytools.codeplex.com).

for you gurus, it's got a cool new feature: debugging Python & C++ together:
[http://www.youtube.com/watch?v=wvJaKQ94lBY](http://www.youtube.com/watch?v=wvJaKQ94lBY)

------
ErikAugust
This comes to mind:
[http://www.youtube.com/watch?v=byEkJ3zRTcY](http://www.youtube.com/watch?v=byEkJ3zRTcY)

------
shire
Looks like Java won't make it in this part of town.

------
kumarski
I love this. Do it for ruby pretty pretty please?

~~~
davefp
I'm working on a ruby version, the WIP can be seen on this pull request:
[https://github.com/adambard/learnxinyminutes-
docs/pull/18](https://github.com/adambard/learnxinyminutes-docs/pull/18)

------
ianstallings
_Shakes body in chair_

"I know kung-fu"

------
rodolphoarruda
li[-1] #=> 3

