[ python-Feature Requests-1122279 ] Option to force variables to be declared

SourceForge.net noreply at sourceforge.net
Tue Feb 15 18:57:13 CET 2005


Feature Requests item #1122279, was opened at 2005-02-14 05:40
Message generated for change (Comment added) made by jimjjewett
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1122279&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Zac Evans (karadoc)
Assigned to: Nobody/Anonymous (nobody)
Summary: Option to force variables to be declared

Initial Comment:
My most common python programming error is to spell a
variable different ways in different parts of a
program. Often this generates no warnings, and is a
difficult problem to track down.

The Zen of Python says that 'Explicit is better than
Implicit'. I would like it if I could set an option so
that I had to explicitly declare variables before I can
use them. eg.
x = 5
would generate a warning, but
x = int()
x = 5
would not.

I do believe that explicit is better than implicit with
respect to programming; and I know that this feature
would save me a _lot_ of debugging on my larger python
projects.

----------------------------------------------------------------------

Comment By: Jim Jewett (jimjjewett)
Date: 2005-02-15 12:57

Message:
Logged In: YES 
user_id=764593

For various reasons, this won't soon get into the core.

Meanwhile, there are some tools like pychecker which may 
help.

I've also found that declaring __slots__ makes the errors 
surface a little bit faster, when I'm dealing with attributes.  
(The most common reason for me to need the variable 
name in widely separated places.)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1122279&group_id=5470


More information about the Python-bugs-list mailing list