Home > Blockchain >  Inputting just a comma returns strange behaviour
Inputting just a comma returns strange behaviour

Time:03-30

Today I by mistake inputted just a comma on an interactive session
Input:

,

and I noticed strangely that it did not return an error but instead:
Output

''

So I explored a bit this behaviour and tried some random stuff, and it seems like it creates tuples of strings, but it seems like these objects cannot be interacted with:

, 'foo' bar 1 x 

returns:

("'foo'", 'bar', '1', 'x')

Trying to assign those tuples or making some == checks doesn't really work but return errors.
I couldn't find any answer or documentation about this behaviour. Anyone know what's happening here?

EDIT: I am using Python 3.9.8 and running in VSCode interactive window with IPython. As someone pointed out in the comments this is not the behaviour when running from the terminal

CodePudding user response:

This is part of the enter image description here

However, this has no context because when i try to assign this "tuple" to a variable, it correctly throws an error.

enter image description here

So it looks like this "pseudo" tuple has no meaning, or at least an invalid syntax, in python...

I also note the answer from @a_guest which was just posted which adds additional clarity.

  • Related