Hi all, this is my first post to python-dev. I see this a lot in replies to newbies on c.l.py: The newbie has used 'open' or 'list' as a variable name, and is warned not to do that because it shadows the builtin by the same name. But dir(__builtins__) tells me that it's unrealistic to expect pythoneers to avoid shadowing the builtins; there are simply too many builtins with names that are lowercase dictionary words. I could find plenty of examples from my own code, or from the standard library, e.g. in code.py: list = traceback.format_exception_only(type, value) Now scoping means that this still works, but error reporting is affected. By Murphy's law, someone is at sometime going to accidentally call a builtin when a user-defined variable was intended. weekdays = list() def list(): """lists weekdays""" return ['Mon', 'Tue', 'Wed', 'worn out already, see ya next week'] To aid in error reporting I think builtins should, all else equal, be strict about their arguments -- the fewer valid argument combinations, the better the chance that a mistaken use is flagged right away. int(), str() and list() I don't understand -- lambda:0, lambda:'' and lambda:[] communicate intent better than int, str and list. - Anders
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