Trailing commas in python
This has tripped me off way more than I would like. For those of you who don't know adding a comma makes a variable into tuple (Yes its not the C bracket)
foo = 1,
print(type(foo))
It prints:
<class 'tuple'>
Search for a command to run...
This has tripped me off way more than I would like. For those of you who don't know adding a comma makes a variable into tuple (Yes its not the C bracket)
foo = 1,
print(type(foo))
It prints:
<class 'tuple'>
It's always good to know about the different notation types: infix, postfix and prefix. Then, it's good to know how and when your language of choice decides to enforce them! Extending your example in 3.6 at the REPL confuses me more!
>>> foo = 1,
>>> print(type(foo))
<class 'tuple'>
>>> print(type(1,))
<class 'int'>
I understand infix, prefix and postfix though I dont know what exactly python does. And BTW i tried both. And it confused me more too. I will add this too ๐๐๐
Two other titles I debated between are "Why library code should always use absolute imports" and the click bait "How I broke python using two simple (innocent) lines of code" Here is the code: import logging logger = logging.getLogger(__name__) Not...
I was writing my first app and I found a bug. The date time column in my database always had the same value. I found out that this value changed upon restarting the server. This was the problematic piece of code: def foo(param, now=datetime.now()):...