msg288807 - (view) |
Author: Facundo Batista (facundobatista) *  |
Date: 2017-03-02 15:34 |
Right now: >>> Formatter().parse("mira como bebebn los peces en el {rio} {de} {la} plata") <formatteriterator object at 0x7f1fc7c7f150> >>> next(_) ('mira como bebebn los peces en el ', 'rio', '', None) This returned tuple should be a namedtuple, so it's self-explained for people exploring this (and usage of the fields become clearer) |
|
|
msg288854 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2017-03-03 04:18 |
I think this is all C coded, so it would entail making a new structseq object. |
|
|
msg288873 - (view) |
Author: Eric V. Smith (eric.smith) *  |
Date: 2017-03-03 08:28 |
It's in string.py, so it would be easy just to add a namedtuple there: class Formatter: ... def parse(self, format_string): return _string.formatter_parser(format_string) I don't see a need to add a structseq to _string, since it's a private API. |
|
|
msg288874 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2017-03-03 08:46 |
collections is a moderately heavy module with many dependencies. string is a light module, it imports only _string. I'm -1 for using namedtuple in the string module. |
|
|
msg288907 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2017-03-03 17:58 |
I would also rather see string.py left light weight. It would be better to change the upstream C code to use structseq. |
|
|
msg304533 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2017-10-17 21:02 |
I'm not convinced that a named tuple is needed here. |
|
|
msg304548 - (view) |
Author: Eric V. Smith (eric.smith) *  |
Date: 2017-10-18 00:44 |
It does seem like overkill for something that's rarely used. I'm -0 on the structseq version. |
|
|
msg304570 - (view) |
Author: Pablo Galindo Salgado (pablogsal) *  |
Date: 2017-10-18 09:29 |
IMHO this change makes things a bit more consistent. In lots of places when a tuple is returned, a `structseq` is used to improve readability on the returned result. Some examples of this are: * grp.struct_group * os.terminal_size * pwd.struct_passwd * resource.struct_rusage * signal.struct_siginfo * time.struct_time * spwd.struct_spwd * sys.float_info * sys.int_info * string.FormatterItem * sys.hash_info * sys.getwindowsversion * sys.flags * sys.version_info * sys.thread_info |
|
|
msg304571 - (view) |
Author: Pablo Galindo Salgado (pablogsal) *  |
Date: 2017-10-18 09:30 |
With the exception of string.FormatterItem, which is the change at hand. |
|
|
msg342720 - (view) |
Author: Cheryl Sabella (cheryl.sabella) *  |
Date: 2019-05-17 13:33 |
It looks like Pablo's patch for this was good, but then closed because the idea was rejected. Should this ticket also be closed as rejected? |
|
|