Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Arjan Wiskerke
Arjan Wiskerke
1,680 Points

I am a puzzled, PEP 20 says "explicit is better than implicit". Jet all variables declarations are implicit declarations

I just noticed because in Fortran, the first thing to do is to turn off implicit declaration. If you refer to a non-existing variable it would be declared implicitly and you have an error that does not generate a compiler error. This can/will happen in python code as well.

1 Answer

Kristian Gausel
Kristian Gausel
14,661 Points

I don't think the PEP is refering to declaration. More like how you manually include self in method calls and stuff of that sort.

Implicit variable declaration makes sense in python if you ask me. You say "Take this value, and store it with the name X" The same sentence can be said whether X exists already or not.

Arjan Wiskerke
Arjan Wiskerke
1,680 Points

Thank you for your answer,

I agree that implicit variable declaration makes sense. How do you cope with errors because of misspelling a variable. When programming in C, I rely on the compiler to tell me I did something stupid. Maybe for Python, the help of an intelligent editor is sufficient. I assume there is no switch for explicit declaration and there is one, It is not common Python programming practice.