There are probably different (inconsistent) ways of using the term.
But the most common thing is that it's just a way to define a particular constant object. The main types you see this with in core python are strings and numbers.
But the most common thing is that it's just a way to define a particular constant object. The main types you see this with in core python are strings and numbers.
# string literals: x = "a string" # string literal # number literals: y = 5 # numeric literal (an int) z = 3.5 # float literal zz = 7 + 6j # complex literal
Quote: Couldn't I also say that a file is also literally what it says it is?You could, but we don't define files in python. So there is no literal constructor for a file.
Quote:If I make a computer class, isn't that literally what I say it is?It is, but as that's code rather than a runtime assignment, I wouldn't call that a python literal. I think the idea is to distinguish it from other constructors.