[Python-ideas] Python 3000 TIOBE -3%
Terry Reedy
tjreedy at udel.edu
Sat Feb 11 17:44:59 CET 2012
On 2/11/2012 5:47 AM, Paul Moore wrote:
> On 11 February 2012 00:07, Terry Reedy<tjreedy at udel.edu> wrote:
>>>> Nor is there in 3.x.
>>
>> I view that claim as FUD, at least for many users, and at least until the
>> persons making the claim demonstrate it. In particular, I claim that people
>> who use Python2 knowing nothing of unicode do not need to know much more to
>> do the same things in Python3.
>
> Concrete example, then.
>
> I have a text file, in an unknown encoding (yes, it does happen to
> me!) but opening in an editor shows it's mainly-ASCII. I want to find
> all the lines starting with a '*'. The simple
>
> with open('myfile.txt') as f:
> for line in f:
> if line.startswith('*'):
> print(line)
>
> fails with encoding errors. What do I do?
Good example. I believe adding ", encoding='latin-1'" to open() is
sufficient. (And from your response elsewhere to Stephen, you seem to
know that.) This should be in the tutorial if not already. But in
reference to what I wrote above, knowing that magic phrase is not
'knowledge of unicode'. And I include it in the 'not much more
knowledge' needed for Python 3.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list