On Tue, Oct 25, 2016 at 05:15:58PM +0200, Mikhail V wrote:
[...]
> >Or it can take a mapping (usually a dict) that maps either characters or
> >ordinal numbers to a new string (not just a single character, but an
> >arbitrary string) or ordinal numbers.
> >
> > str.maketrans({'a': 'A', 98: 66, 0x63: 0x:43})
>
> >(or None, to delete them). Note the flexibility: you don't need to
>
> Good. But of course if I do it with big tables, I would anyway
> need to parse them from some table file. Typing all values
> direct in code is not a comfortable way.
Why not? What is the difference between typing
123: 456
124: 457
125: 458
# two hundred more lines
in a "table.txt" file, and typing:
{
123: 456,
124: 457,
125: 458,
# two hundred more lines
}
in a "table.py" file? The difference is insignificant. And the Python
version can be cleaned up:
for i in range(123, 333):
table[i] = 456 - 123 + i
Not all data whould be written as code, especially if you expect
unskilled users to edit it, but generating data directly in code is a
very powerful technique, and the strict syntax of the programming
language helps prevent some errors.
[...]
> Motivation is that those can be optimised for speed
That's not a motivation. Why are you talking about "optimizing for
speed" functions that we have not yet established are needed?
That reminds me of a story I once heard of somebody who was driving
across the desert in the US once. One of his passengers noticed the
highway signs and said "Wait, aren't we going the wrong way?" The driver
replied "Who cares, we're making fantastic time!"
Optimizing a function you don't need is not an optimization. It is a
waste of time.
--
Steve
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/