Follow

long, embarrassing, but funny coding story 

TIL that "type" is a built-in function in Python.

But said function would never work any time I called it, and would always give a "TypeError: 'str' object is not callable" error.

After a long debugging session, I discovered that earlier on, I had written the following:
type = "type"

Maybe I need to stay away from computers 😭

long, embarrassing, but funny coding story 

@kazooboy Since everything is an object couldn't you print it?

long, embarrassing, but funny coding story 

@gudenau I had been using print(), but I had been using it to print type() to test the type of another variable, and kept getting the same error over and over. Took a long time to realize that "type" was no longer a function but a string 😂

long, embarrassing, but funny coding story 

@kazooboy some Python linters will warn you about assignment to builtins.

long, embarrassing, but funny coding story 

@aru Yeah, I'm kinda surprised the default interpreter would let me get away with something that crazy 😅 I'll have to look into using a linter though, maybe it'll help me catch some of those rookie mistakes 👍

Sign in to participate in the conversation
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!