You know you’re spending too much time on the ‘net when…

January 23rd, 2008 § 8 comments

You acci­den­tally start typ­ing “False” as Fail — and don’t notice it until some stu­pid unit test bombs out:


ERROR: test_someCoolMethod (__main__.TestScenarios)
----------------------------------------------------------------------
Traceback (most recent call last):
File "mysillytests.py", line 83, in test_someCoolMethod
self.assertEqual(resp, Fail)
NameError: global name 'Fail' is not defined

I need to make two knew types: Fail and Win. Too bad the bool class can’t be sub classed. I think a win and fail type would make things so much better:


If var is Fail:
...
elif var is Win:
...

if var is not Win:

Maybe I need stop writ­ing unit tests and go to bed.

Edit to add: Doug helped me out:

Python 2.5.1 (r251:54863, Oct 5 2007, 21:08:09)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> __builtins__.Fail=False
>>> __builtins__.Win=True
>>>
>>> x = Win
>>> y = Fail
>>>
>>> not x
False
>>> not y
True
>>> y is Win
False
>>> x is Win
True
>>>

Now all I have to do is add this to my sitecustomize.py and really trip up my teammates.

  • Doug Napoleone

    __builtins__.Fail=False
    __builtins__.Win=True

    *cough*

  • cynic

    You’re talk­ing about lolcode:

    http://lolcode.com/

    Fail and Win can be found here:

    http://lolcode.com/specs/1.2#boolean

    The fact that you didn’t know that clearly indi­cates that one of us had indeed spent far too much time on the net…and that some­one is not you : )

  • jnoller

    Nope, I know about LOLCODE — I want fail and win in Python

    It’s sad when you have ican­hazcheezburger in your RSS reader.

  • jnoller

    I think I love you.

  • requiem

    Pos­i­tively funny.

  • mob

    bwa­ha­haha — know­ing your team­mates, this should be fun!

  • http://gedmin.as Mar­ius Gedminas

    Reminds me of the old joke

    »> import __builtin__
    »> __builtin__.True, __builtin__.False = __builtin__.False, __builtin__.True

  • http://gedmin.as Mar­ius Gedminas

    Reminds me of the old joke

    »> import __builtin__
    »> __builtin__.True, __builtin__.False = __builtin__.False, __builtin__.True

What's this?

You are currently reading You know you’re spending too much time on the ‘net when… at jessenoller.com.

meta