[issue25061] Add native enum support for argparse

2016-04-10 Thread leycec

leycec added the comment:

I strongly support this feature request. Unsurprisingly, I wholeheartedly agree 
with desbma's heroic persistence and wholeheartedly disagree with rhettinger's 
curt dismissal.

> IMO, this adds more complexity than it solves.

Strongly disagree. Because "argparse" fails to support the core "Enum" type 
out-of-the-box, I now have to either (A) duplicate desbma's boilerplate or (B) 
duplicate paul.j3's original "EnumType" factory or desbma's revised "EnumType" 
factory across multiple "argparse"-based CLI interfaces in multiple Python 
applications having discrete codebases.

Both approaches are noxious, substantially increasing implementation burden and 
technical debt. While obviously feasible, both approaches violate DRY, invite 
code desynchronization and concomitant bugs, inhibit maintainability, 
intelligibility, and documentability, and... the list just crawls on.

DRY violations add complexity. Avoiding DRY violations decreases complexity.

> Argparse already has more options than people can remember.

That's what front-facing documentation, queryable docstrings, and 
https://docs.python.org/3/library/argparse.html are for. No one remembers even 
a tenth of the functionality provided by "argparse" or any other reasonably 
deep module (e.g., "importlib", "subprocess") in the stdlib, yet the stdlib 
justifiably grows, improves, and strengthens with time.

This is a good thing. API memorability and mnemonics, however, are not. We have 
machine lookup. Ergo, API memorability and mnemonics are poor metrics by which 
to gauge feature creep.

I'd hoped it would be intuitively obvious that "Enum" support should be 
officially added to "argparse". Enums are a core type native to most high-level 
languages, now including Python. Enum-based argument parsing is a Pythonic 
solution for string arguments accepting only a well-known set of valid 
alternatives. The stdlib itself is internally (albeit incrementally) migrating 
from non-Enums to Enums.

This needs to happen.

--
nosy: +leycec

___
Python tracker 
<http://bugs.python.org/issue25061>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1322] Deprecate platform.dist() and platform.linux_distribution() functions

2016-04-13 Thread leycec

leycec added the comment:

Deprecating platform.linux_distribution() while retaining platform.win32_ver() 
and platform.mac_ver() is non-orthogonal, unjustifiable, and (arguably) 
discriminatory.

Platform version detection is no more a moving target under Linux than under 
Windows or OS X -- possibly less so, given the numerous significant revisions 
to platform.win32_ver() implementations over the dreary years. If Linux is 
arbitrarily unentitled to platform-specific lookup functions, then other 
platforms deserve the same.

Unlike both Windows and OS X, the overwhelming majority of Linux distributions 
provide a trivially parsable plaintext file publishing high-level platform 
metadata in "="-delimited shell variable assignment format: the 
systemd-mandated and freedesktop.org-maintained "/etc/os-release" file. Under 
edge-case Linux distributions ideologically rejecting this standard (e.g., 
Gentoo Linux), a subset of the named tuple returned by platform.uname() is 
trivially returnable.

Do not parse multiple possibly conflicting files, commands, or standards. Doing 
so is neither necessary nor desirable. If "/etc/os-release" exists, parse that; 
else, fallback to platform.uname(). Done. Fait accompli. Quite simple. No 
moving target exists.

A robust platform.linux_distribution() implementation adhering to this scheme 
is implementable in less than 50 lines of code -- possibly less than 20, 
assuming aggressive cleverness. How? If "/etc/os-release" exists, this file is 
guaranteed to be POSIX shell-compatible and hence Pythonically parsable via the 
stdlib shlex.shlex() function. (In brief: iteratively search for tokens 
containing "=", split these tokens on "=", ignore irrelevant variable names, 
and retain the remainder. That's it.) The fallback alternative is even briefer.

Removing core functionality invites third-party API explosion. This is the 
height of irresponsibility. Brace for heavyweight dependencies, end-user 
confusion, multiple competing non-standards, and poorly selected PyPi names 
conflicting with the long-standing GNU toolchain. (See nir0s' "ld", also 
referred to as "What was nir0s thinking?")

None of these are good things. Given the unremarkable simplicity of 
implementing this function correctly, this cul-de-sac of Cthulhian insanity 
needn't have happened in the first place.

It did. Now we languish.

--
nosy: +leycec

___
Python tracker 
<http://bugs.python.org/issue1322>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com