Namespaces: memory vs 'pollution'

Peter J. Holzer hjp-python at hjp.at
Sun Jul 21 09:55:59 EDT 2019


On 2019-07-21 12:02:27 +1200, DL Neil wrote:
> What do you do to (respecting purism) ensure 'everything' (necessary) is
> imported (and nothing more), preferably without relying upon (faulty, in my
> case) human-memory or reading through volumes of code/documentation?

I write tests (not as consistently as I would like).

I don't think there is much more you can do. The problem is that Python
doesn't have variable declarations, so there is no reliable way to
discover an undefined symbol except by executing the line where it is
used.

An IDE might help. Even though the problem is in general not solvable,
most uses of symbols fall into a few common categories which can be
discovered by static analysis. So an IDE (or even a syntax-highlighting
editor) could flag all symbols where it can't find the definition.

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp at hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20190721/c178a719/attachment.sig>


More information about the Python-list mailing list