[x3d-public] python 2.7 complains about x3d.py -- and will continue to do so

John Carlson yottzumm at gmail.com
Sun Jun 14 17:45:09 PDT 2020


What one could to do minimize porting would be to create one's own method,
say log() and the call print() or print, I guess based on a test for
python3 or not. I don't know the details of print. I do have a way for
testing for python 3 or not, if that is desirable.

John

On Sun, Jun 14, 2020 at 7:39 PM John Carlson <yottzumm at gmail.com> wrote:

> In total agreement, Vince. Sorry I did not state that sooner.  In 2.7 ()'s
> are left off the print statement.
>
> I do not know how easy it would be to restrict the number of print's so
> porting would be a minimal exercise.
>
> Python 2.7 is beyond the support window.
>
> John
>
> On Sun, Jun 14, 2020 at 5:34 PM vmarchetti at kshell.com <
> vmarchetti at kshell.com> wrote:
>
>> The refence John Carlson identified suggests using a 'processing
>> instruction' as the first line of the x3d.py file, the line would be:
>> # -*- coding: utf-8 -*-
>> and this allows the Python 2 interpreter to read the source file assuming
>> UTF-8 encoding; for the current download of x3d.py (as of 12 June 2020)
>> this works, Python 2 accepts the non-ascii character (in this case, the
>> non-ascii character is the "MULTIPLICATION_SIGN" , unicode 215, used in a
>> documentation comment.)
>>
>> However, elsewhere in the x3d.py, the print({text}) form of the Python
>> print statement is used, and that is only permitted in Python 3.
>>
>> As it is written now, x3d.py is only supported by Python 3. I think this
>> is a reasonable choice.
>>
>> Vince Marchetti
>>
>>
>> On Jun 12, 2020, at 12:31 AM, John Carlson <yottzumm at gmail.com> wrote:
>>
>> https://www.python.org/dev/peps/pep-0263/   (declaring an encoding)
>>
>> On Thu, Jun 11, 2020 at 2:20 PM Andreas Plesch <andreasplesch at gmail.com>
>> wrote:
>>
>>> $ python
>>> Python 2.7.16 (default, Oct 10 2019, 22:02:15)
>>> [GCC 8.3.0] on linux2
>>> Type "help", "copyright", "credits" or "license" for more information.
>>> >>> import x3d.x3d as x
>>> Traceback (most recent call last):
>>>  File "<stdin>", line 1, in <module>
>>>  File "/home/andreas/.local/lib/python2.7/site-packages/x3d/x3d.py",
>>> line 206
>>> SyntaxError: Non-ASCII character '\xc3' in file
>>> /home/andreas/.local/lib/python2.7/site-packages/x3d/x3d.py on line 206,
>>> but no encoding declared; see http://python.org/de
>>> v/peps/pep-0263/ for details
>>>
>>> $ cat -nA  /home/andreas/.local/lib/python2.7/site-packages/x3d/x3d.py |
>>> grep 206 | head -1
>>>   206      'SFMatrix3d', # Single Field (singleton) 3M-CM-^W3 matrix of
>>> double-precision floating point numbers$
>>>
>>> There are indeed non-ascii characters.
>>>
>>> python3 does not complain.
>>>
>>> --
>>> Andreas Plesch
>>> Waltham, MA 02453
>>> _______________________________________________
>>> x3d-public mailing list
>>> x3d-public at web3d.org
>>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>>
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200614/aca04b1d/attachment.html>


More information about the x3d-public mailing list