flying sheep <flying-sh...@web.de> added the comment:

this is annoying:

i’m creating a reindentation script that reindents any valid python script. the 
user can specify if, and how many spaces he/she wants to use per indentation 
level. `0` or leaving the option out means “one tab per level”.

if the argument is given, appended code works as intended. but in the default 
case, the code fails for any of the two default values i tried.

i would expect that one of the default values works: either `0`, if the default 
value *is* converted via the `type` function, or `"\t"` if the default value 
bypasses it.

it seems that argparse applies the `type` function to the default instantly, 
and then to the argument (be it the already-converted default or a passed 
option).

this breaks `type` functions which aren’t reflexive for values from their 
result set, i.e.: `t(x) = y => t(y) = y` must be true for all `x` that the 
function can handle

----------
nosy: +flying sheep
Added file: http://bugs.python.org/file23767/argparse_test.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12776>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to