overrides for fun and profit

Ran into an interesting problem today where I was getting ‘dict is not callable’ in a python project I was working on. The problem line looked innocent enough:

if type(foo) == string:
    doSomeStuff()

After a bit of digging, it turned out that I had accidentally overridden the built-in type function within the scope of the function I was working on:

for type in someArrayOfTypes:
    doOtherThings()

Whoops. =D

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s