> Each one could be rewritten (I'm curious as to the prevailing > stylistic opinions on this): I think those rewrites do not improve the code, see detailed comments below. > Could be rewritten: > if not hasattr(sys, 'ps1'): > sys.ps1 = ">>> " > if not hasattr(sys, 'ps2'): > sys.ps2 = "... " Using string literals when you mean attribute names is bad style. It just helps to trick the checker. Sometimes, you cannot avoid this style, but if you can, you should. > if globals().has_key("LC_MESSAGES"): > __all__.append("LC_MESSAGES") This combines the previous issue with the usage of globals(). I find it confusing to perform function calls to check for the presence of names. > try: > UnicodeType > except NameError: > UnicodeType = None > > Could be rewritten: > globals().setdefault('UnicodeType', None) Same issue here. If this needs to be rewritten, I'd prefer try: from types import UnicodeType except ImportError: UnicodeType = None Somebody might also change the "from types import *" to explicitly list the set of names that are requested, when changing this fragment. Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4