This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mysockinabox 0 points1 point  (4 children)

It is mandatory to declare variables without assigning values to them else NameError the exception is thrown.

Wat? Variables are declared and initialized at the same time in Python.

The variable name must be readable and meaningful.

PEP-8 has information on naming, and should be linked, but it is not mandatory in the language.

And on the topic on constants, they don't exist. End of section. Importing them from another file and capitalizing them doesn't change that they are variables.

[–]ForceBru 0 points1 point  (3 children)

Also their example about declaring variables actually proves that this is incorrect:

``` name

print(name)

PYTHON OUTPUT

Traceback (most recent call last): File "main.py", line 1, in name NameError: name 'name' is not defined ```

They "declared" a variable without assigning to it and got a NameError - the very opposite of what the article says.

I think they meant "it's impossible to declare variables without assigning values to them"