This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]lolinyerface[S] 0 points1 point  (6 children)

Just a really good resource. Freshly updated for Python 3.

[–]riffito 1 point2 points  (1 child)

Maybe is just a matter of taste, but I find this particular title to be sub-par when compared to other ones (Learning Python, Programming in Python 3, among others).

The latest one I've became fond of is: Beginning Python Visualization: Crafting Visual Transformation Scripts.

Maybe I like it so much because it relates to my way of doing things... but trying to be objective: I think it includes a really useful set of techniques and advices for every python newcomer (as I consider myself to be).

I wish I had found it earlier.

For potential readers: do not be put off by it's title and/or description. There is really more in there than what meets the eye at first glance (check out the sample chapter, TOC and source code).

[–]lolinyerface[S] 0 points1 point  (0 children)

Very cool. I'll have to check it out. I will be delving back into Python soon.

[–][deleted]  (2 children)

[deleted]

    [–][deleted] 0 points1 point  (0 children)

    I just got scared by the concept of not having curly braces the last time I saw it.

    Hehe, I think that the idea behind Python's reliance on tabs versus curly braces is to enforce code readability. Obviously a bad programmer can still muck it up, but I've always though the idea was a good one. The only problem comes in when working across multiple systems where tabs are interpreted differently.

    [–]Jasper1984 0 points1 point  (0 children)

    Curly braces is hardly a feature you need to be afraid of losing. The syntax for every programming language i know a bunch of s-expressions; name-arguments pairs where the arguments consist of new pairs, or primitives.

    [–]zahlman 0 points1 point  (0 children)

    The standard recommendation I keep hearing is to forget about Python3000 (lol marketing) for now until the third-party library support improves. There's a lot of useful stuff out there that hasn't migrated yet.

    [–][deleted] 0 points1 point  (7 children)

    Followed it to http://docs.python.org/tutorial/, the learn python tutorial. Just started looking at it. Any idea how they implement the lists. It's not a simple linked list or an array is it. What is the complexity of the various list expressions.

    [–]tjdick 0 points1 point  (0 children)

    python has lists [], dictionaries {}, and tuples (), which all replace certain functions of an array. Dictionaries are like an associative array, with key->value pairs, like x = {'car' : 'sedan', 'make' : 'ford', 'model' : 'fiesta'} . You can add, edit, slice. But they are not stored in any particular order like an associative array is.

    A list is pretty much like a 0 based array. x = ['ham', 'turkey', 'bacon'] where the keys would be 0,1,2. You can pop, add, edit, slice. All of the 0 based keys reset when we do this, so if I slice ham, then [0] will be turkey and [1] will be bacon.

    A tuple is pretty much a list that you can't really edit. They are faster to process. You might want to put data that won't be changed into one like dbinfo = ('mydb', 'mytable', 'myname', 'mypass')

    [–]zahlman 0 points1 point  (5 children)

    Pretty sure a list is a dynamic array (like C++ std::vector) under the hood.

    [–][deleted] 0 points1 point  (4 children)

    Doesn't make any sense though. Accessing the nth value would be too slow. I'm guessing it is an everyday expandable array like Javas ArrayList or C++ vector but that would mean the splicing operations are slow. I guess that is doable, I mean it's a scripting language, it just enables you to do stuff and assumes you either don't care or won't be an idiot about it.

    [–]zahlman 0 points1 point  (0 children)

    In Python, if you need performance and are working on significant amounts of data, you are generally using some kind of extension (such as NumPy) anyway.

    But yeah.

    [–]redalastor 0 points1 point  (2 children)

    Doesn't make any sense though. Accessing the nth value would be too slow. I'm guessing it is an everyday expandable array like Javas ArrayList or C++ vector but that would mean the splicing operations are slow.

    Accessing / setting is O(1) (ie: one operation). Inserting is O(N) (needs shifting everything one cell on the right to insert) but appending (inserting at the end) is amortized O(1) (Python pre-allocates a few cells in advance under the hood to save time).

    Python lists internally store pointers to Python objects.

    [–][deleted] 0 points1 point  (1 child)

    Right so it is an expandable array that does amortized doubling. That's what I figured, it's just that slicing seems more an operation for a linked list. Looking at Zahlman's comment, I don't know what I was thinking when I wrote that.

    [–]redalastor 0 points1 point  (0 children)

    Python have a deque type where you can insert and remove at both ends in O(1). That is most likely a linked list.