Other articles

  1. Python Closures and Free Variables

    April 10 2014

    Today, friends, we will continue to dissect functional programming concepts in Python. We're going to try to figure out what the hell is going on in this chunk of code:

    >>> def make_contains_function(x):
    ...     def contains(s):
    ...             return x in s
    ...     return contains

    What happens when we pass make_contains_function a ...

    tags: python python internals functional programming closures

  2. What's the deal with __builtins__ vs __builtin__

    March 23 2014

    Seriously, what's the difference? When you first fire up the Python interpreter, __builtins__ is in your namespace for free:

    >>> globals().keys()
    ['__builtins__', '__name__', '__doc__', '__package__']
    >>> __builtins__
    <module '__builtin__' (built-in)>

    But it appears to be the __builtin__ module (singular)! If you:

    >>> import __builtin__
    >>> __builtin__ is __builtins__

    Hrm. So they ...

    tags: python builtins hacker school python internals

  3. Page 1 / 1