Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    M

    Michael Foord

    voidspace.org.uk · Personal blog · on HN since 2007

    Michael Foord, a Python developer and creator of the mock library, writes about Python, testing, and technical writing.

    Visit blogHN submissions
    ProgrammingLanguages & Compilers
    What HN says

    HN links it for his article on why writing a technical book rarely pays off, and for Python posts and cyberpunk folklore.

    Stats for nerds
    32HN people shared it
    20linked in comments
    150story points
    Apr 2017last shared
    2007people per year2017

    Top posts on HN

    1. 1
      PyPy and Psyco
      1 person · 39 points · first shared 2009 · 11 comments on HN
    2. 2
      Running Python in a linux browser with moonlight
      1 person · 16 points · first shared 2009 · 1 comments on HN
    3. 3
      Current State of Unladen Swallow (Towards a Faster Python)
      3 people · 15 points · first shared 2010 · 1 comments on HN
    4. 4
      Python -me: clever but useful command line hack
      1 person · 10 points · first shared 2010 · 3 comments on HN
    5. 5
      Python for my Grandpa
      1 person · 10 points · first shared 2008 · 1 comments on HN
    6. 6
      Eliminating self with Metaclasses in Python
      2 people · 9 points · first shared 2008 · 1 comments on HN
    7. 7
      The Resolver One (Python) Challenge - $25,000
      1 person · 9 points · first shared 2008 · 8 comments on HN
    8. 8
      Eliminating self with Metaclasses in Python
      3 people · 8 points · first shared 2012 · Discussion on HN
    9. 9
      Anonymous Code Blocks in Python
      1 person · 8 points · first shared 2008 · 1 comments on HN
    10. 10
      Python garbage collection via weak references
      1 person · 7 points · first shared 2010 · 1 comments on HN

    What HN people wrote when they linked it

    • btillySep 2012

      What do you mean by "usable function literals"? Because Python has them, even if you have to do a bit of work to get them.

      def demo (n):
      def multiplier (m):
      return n * m
      return multiplier

      x5 = demo(5);
      print x5(4)

      You can do anything in the inner closure that you might want. The only surprise is scoping - if you want to modify state you need to use a mutable data type because otherwise you'll be instantiating a private variable. But that hoop is easy to handle.

      def demo ():
      counter = [0]
      def increment ():
      counter[0] += 1
      def peek ():
      return counter[0]
      return (increment, peek)

      (increment1, peek1) = demo()
      (increment2, peek2) = demo()
      increment1()
      increment1()
      increment2()
      print peek1()
      print peek2()

      So there. Function literals. They work.

      But, you say, you really want anonymous classes? Well look up metaprogramming then. Python really has quite good support for it. There is no trouble creating anonymous classes on the fly with their own attributes, functions, and so on. They can even inherit from each other. http://www.voidspace.org.uk/python/articles/metaclasses.shtml might be a good starting place on this for you.

      (Note, I do not recommend metaprogramming unless the solution you make will be reused a lot.)

    • masklinnMar 2011

      > They backported the Python 2.7 unittest module to Python 2.4

      No, unittest2 is a project by unittest's own maintainer (Michael Foord): http://www.voidspace.org.uk/python/articles/unittest2.shtml

      > and included it in Django?

      A good thing, short of depending on unittest2 itself (I don't believe Django "accepts" to depend on third-party projects as it's supposed to be self-contained).

      unittest2 is a really big improvement over the old unittest, there are new (and better) assertions, improved comparisons (which diff containers on mismatches for instance, and the equality assertions are pluggable), improved fixtures (class and module-level setup and teardown), improved cleanups (separate from teardowns), autodiscovery has finally been included and is pluggable (you can override it for your modules), etc...

      Because Django 1.2 has its own layer on top of unittest (to do basic setup and fixtures loading for the developer and integrate with management commands for instance), using unittest2 with it is a pain.

      I, for one, am very happy with this development.

      > It is getting enterprisey.

      Because they bundle a preexisting library instead of developing yet-another-unit-testing-library?

    • maebertJun 2014

      Hi, creator of the package here. If you install the pycrypto package first, jrnl should work fine on Windows, too. It only needs a gcc compiler to build from source [1], but there are even pre-compiled binaries [2] (I don't have any experience with them though - please let me know if it works) :)

      I think py2exe could work well, too! Otherwise you could create a virtual environment with virtualenv and install all the dependencies into one folder.

      [1] https://www.dlitz.net/software/pycrypto/
      [2] http://www.voidspace.org.uk/python/modules.shtml#pycrypto

    • BobKabobMar 2011

      "Any traditional OOP programmer might tell you that essential elements of OOP are encapsulation and message passing.

      The Python equivalents are namespaces and methods.

      Python doesn't subscribe to protecting the code from the programmer, like some of the more BSD languages. Python does encapsulate objects as a single namespace but it's a transluscent encapsulation."

      From: http://www.voidspace.org.uk/python/articles/OOP.shtml

    • vivekchand19May 2014

      Unit testing is all about abstracting / mocking out all the modules connected to the unit you are testing & just test your unit.

      If you are programming in python, http://www.voidspace.org.uk/python/mock/ would be the most preferred way of mocking out other external units connected to your unit under test.

      http://alexmarandon.com/articles/python_mock_gotchas/ should make you an expert on mocking

    • hergeApr 2012

      Make is better than SCons if you are not compiling C. Lots of people would use fabric instead. The stock unittest in the stdlib is quite good, especially in python 2.7+.

      For mocks, wait until mock (http://www.voidspace.org.uk/python/mock/) is in the stdlib or download it yourself.

    Related

    David Beazleydabeaz.com162 people

    (Python) Generator Tricks For Systems Programmer (pdf)

    David Beazley
    Personal · last shared 2026
    Brett Cannonsayspy.blogspot.com31 people

    A core Python committer's (very shallow) thoughts on Dart

    Brett Cannon
    Personal · last shared 2022
    Ian Bickingblog.ianbicking.org107 people

    Firefox Was Always Enough

    Ian Bicking
    Personal · last shared 2026
    Doug Hellmanndoughellmann.com44 people

    The Performance Impact of Using dict() Instead of {} in CPython 2.7

    Doug Hellmann
    Personal · last shared 2024
    Jesse Nollerjessenoller.com50 people

    A lot happens

    Jesse Noller
    Personal · last shared 2020
    Aphyraphyr.com551 people

    Hexing the technical interview (2017)

    Aphyr
    Personal · last shared 2026
    Useless Factoruseless-factor.blogspot.com16 people

    Why not mmap?

    Useless Factor
    Personal · last shared 2015
    John Regehrblog.regehr.org401 people

    Teaching C

    John Regehr
    Personal · last shared 2026