IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?
Twirlip2
ahrodg at googlemail.com
Wed Aug 27 11:25:08 EDT 2014
On Tuesday, 26 August 2014 23:55:51 UTC+1, Twirlip2 wrote:
> It doesn't seem immediately obvious how to get a definitive list
> of which names to avoid using (and therefore, inadvertently
> 'shadowing', as I did today).
>
> For example,
> <https://docs.python.org/3/tutorial/modules.html#standard-modules>
> doesn't list the filename 'code.py', which is the one I clashed
> with today.
>
> Of course, if all else fails, I will be sure to manually search
> the Python installation directory for possible clashes, but there
> must be a more logically secure way, one more integral to the
> language itself.
Does the interaction below (copied from an IDLE session) show a safe
and reliable way to do it?
>>> from importlib.util import find_spec
>>> find_spec('code')
ModuleSpec(name='code', loader=<_frozen_importlib.SourceFileLoader object at 0x01139330>, origin='I:\\Python34\\lib\\code.py')
>>> find_spec('ftang')
>>>
This seems to show that I can safely use the name 'ftang.py'
for a module in the search path, if I want; but might it be
dangerous in some way, or might it fail to find some module
name that I might still cause a clash with?
More information about the Python-list
mailing list