> Examples > > Here is an example of an interactive session exhibiting the > expected behaviour of this feature. > > >>> "12345 John Doe" / "%5d %8s" > (12345, 'John Doe') > >>> "12 34 56 7.890" / "%d %d %d %f" > (12, 34, 56, 7.8899999999999997) > >>> "12345 John Doe, Foo Bar" / "%(num)d %(n)s, %(f)s %(b)s" > {'n': 'John Doe', 'f': 'Foo', 'b': 'Bar', 'num': 12345} > >>> "1 2" / "%d %d %d" > Traceback (innermost last): > File "<stdin>", line 1, in ? > TypeError: not all arguments filled Kind of late to jump in, but this is the nature of this list. I'd like to support Peter's proposal for having *some* kind of inverse mechanism to string formatting using '%'. Now, that doesn't mean anything, of course, but no matter what the syn- tax would look like: I'd prefer having that feature over not having it and I'll give an example below. Reminding you of a thread I triggered a while ago (that went slightly astray) which was, kind of, received with suspicion, I notice that it matches quite nicely with Peter's (more ge- neral) idea. Here's the thread's summary: Grouping function for string module? http://mail.python.org/pipermail/python-list/1999-September/011875.html Combining this I'd like to see something like the following (again, maybe with a different syntax): >>> "1010000011110101" / "%4s%4s%4s%4s" ('1010', '0000', '1111', '0101') >>> "10100000111101" / "%4s%4s%4s%4s" ('1010', '0000', '1111', '01') or even: >>> "1010000011110101" / ("%4s" * 4) ('1010', '0000', '1111', '0101') ;-) Regards and Happy Easter (will be away for a week)! Dinu -- Dinu C. Gherman ReportLab Consultant - http://www.reportlab.com ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained")
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