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.

What HN saysHN links it for his article on why writing a technical book rarely pays off, and for Python posts and cyberpunk folklore.
32HN people shared it
19linked it in comments
20stories submitted
150story points
9 years agolast shared
2007people per year2026

Most-shared posts

  1. 1
    Mock
    4 people · first shared 2012
  2. 2
  3. 3
    Eliminating self with Metaclasses in Python
    3 people · 8 points · first shared 2012 · discussion on HN
  4. 4
    Eliminating self with Metaclasses in Python
    2 people · 9 points · first shared 2008 · 1 comments on HN
  5. 5
    Writing a Technical Book
    2 people · 4 points · first shared 2009 · 2 comments on HN
  6. 6
    PyPy and Psyco
    1 people · 39 points · first shared 2009 · 11 comments on HN
  7. 7
    Running Python in a linux browser with moonlight
    1 people · 16 points · first shared 2009 · 1 comments on HN
  8. 8
    Python for my Grandpa
    1 people · 10 points · first shared 2008 · 1 comments on HN
  9. 9
    Python -me: clever but useful command line hack
    1 people · 10 points · first shared 2010 · 3 comments on HN
  10. 10
    The Resolver One (Python) Challenge - $25,000
    1 people · 9 points · first shared 2008 · 8 comments on HN
  11. 11
    Anonymous Code Blocks in Python
    1 people · 8 points · first shared 2008 · 1 comments on HN
  12. 12
    Python garbage collection via weak references
    1 people · 7 points · first shared 2010 · 1 comments on HN
  13. 13
    Duck Typing in Python
    1 people · 6 points · first shared 2017 · discussion on HN
  14. 14
    Test Driven Development (Python & Ruby)
    1 people · 3 points · first shared 2007 · discussion on HN
  15. 15
    Tests that fail one day every four years
    1 people · 2 points · first shared 2012 · discussion on HN

What HN people wrote when they linked it

BobKabob · 2011-03-17
"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
btilly · 2012-09-08
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.)
douche · 2017-04-21
Writing a technical book is, as far as I was aware, well known to be a losing bet, where it's exceedingly rare that authors make back their advances. e.g. http://www.voidspace.org.uk/python/articles/technical-writing.shtml
DannoHung · 2015-06-16
Don't miss Neil Gaiman's contribution to the Matrix's folklore: http://www.voidspace.org.uk/cyberpunk/goliath.shtml
maebert · 2014-06-24
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
vivekchand19 · 2014-05-05
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
marcofucci · 2012-12-11
Quick question: why did you need to write FreezeGun? I've always used Mock http://www.voidspace.org.uk/python/mock/ to patch datetimes and I've never had any problems. You can patch pretty much anything with Mock.
herge · 2012-04-17
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.
davvid · 2012-04-06
On a related note, Michael Foord's `mock.py` was recently added to the python stdlib. http://www.voidspace.org.uk/python/mock/mock.html
kbd · 2012-03-13
Well, here's Michael Foord's (@voidspace, referenced in the slides) Mock library so you can see what extra stuff it gives you. http://www.voidspace.org.uk/python/mock/
gtani · 2010-10-17
There's another product that I've been meaning to look at, RsolverOne, mostly cause i learned a lot from the guy's python blog: http://resolversystems.com/ http://www.voidspace.org.uk/python/weblog/arch_d7_2009_11_21.shtml
jrschulz · 2009-07-12
rest2web: http://www.voidspace.org.uk/python/rest2web/ It is not very flexible, but doesn't take very much effort either.
hbien · 2009-02-26
Here's a library for it in Python: http://www.voidspace.org.uk/python/odict.html
thorax · 2008-06-03
Old school (news) but still going: http://www.pythonware.com/daily/ IronPython a bit more lately: http://www.voidspace.org.uk/python/weblog/index.shtml Reddit programming section gets some good Python (news) sometimes.
iamelgringo · 2007-12-21
masklinn · 2011-03-23
> 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?

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close