[Python-Dev] Re: PEP: Defining Unicode Literal Encodings (revision 1.1)

Bengt Richter bokr at accessone.com
Sun Jul 15 18:32:52 EDT 2001


On Sun, 15 Jul 2001 13:29:24 -0400, Guido van Rossum <guido at digicool.com> wrote:

>> > Explain again why a directive is better than a specially marked
>> > comment, when your main goal seems to be to make it easy for
>> > non-parsing tools like editors to find it?
>> >...
>> 
>> Parsing tools do need it. The directive changes the file's semantics.
>> Both parsing and non-parsing tools need it.
>
>I understand that.
>
>> I could live with a comment but I think that that is actually harder to
>> implement so I don't understand the benefit...I'm still trying to
>> understand what tools we are protecting. compiler.py can be easily
>> fixed. The real parser/compiler can be easily fixed. The other tools
>> mostly take their cue from one of these two modules, right?
>
>I disagree with the first sentence -- I believe a comment is easier to
>implement.  The directive statement is still problematic.  Martin's
>hack falls short of doing the right thing in all cases: you can't have
>the first statement of your program be "directive = ..." or
>"directive(...)".
>
>Another argument for a comment: I expect there could be situations
>where you want to declare an encoding that doesn't affect the Python
>parser, but that does affect the editor (e.g. when you use the
>encoding only in comments and/or 8-bit strings).  A comment would
>back-port to older Python versions; a directive statement wouldn't.  I
>don't know how important this is though.
>
If the scope is always a complete file, what about just building on
the -U in #!/usr/bin/python -U, and letting all interested programs
look for flags?




More information about the Python-list mailing list