Re: [Python-Dev] Syntax suggestion for imports

"John" == John Barham <jbarham@gmail.com> writes:
* import readline or emptymodule
John> This I find more problematic as "emptymodule" seems too magical. John> Even now any code that wants to use a module that might not have been John> successfully imported needs to check if that's the case. E.g., a John> fuller current use-case would be: John> try: John> readline = None John> import readline John> except ImportError: John> pass John> if readline is not None: John> readline.foo() John> Conceivably emptymodule could act as a Null object but that could John> create more problems than it solves. How about import readline or None as readline This is just for cases where you don't want to trigger ImportException on import and do want the symbol set to None for later testing. A standalone "import None" could have no effect. Terry
participants (1)
-
Terry Jones