[XeTeX] DVIasm

Wilfred van Rooijen wvanrooijen at yahoo.com
Tue Feb 9 01:33:08 CET 2016

Sorry to bump into this conversation, but if you want Python 2 and Python 3 compatibility, I think you also need to so something about the "%", since Python 2.6 there is the str.format() method which is more reliable then %-formatting (*). More importantly, the "%" will become deprecated in some future version of python.
There are subtle differences between Python 2 and Python 3. The most eye-catching aspects are string formatting (now via the str.format() mini-language), some statement that have become functions (the most irritating being "print" becoming a function, i.e. Python 2

print "Hello World"
becomes Python 3
print("Hello World")
and similar for other print-like statements. Finally the treatment of lists and the introduction of view-objects in Python 3, e.g. Python 2:
for elem in dictionary.keys():    do_something_with_elem
should be coded in Python 3 as:
for elem in list(dictionary.keys()):    do_something
Most of the subtleties are implicitly handled correctly, but when creating new code or debugging, it is suggested to move to Python 3 syntax "if reasonably possible". A good editor/IDE is "ninja-ide" which will give automatic tips about differences between Python 2 and Python 3.
(*) exactly what is "more reliable" is up for debate.


    On Tuesday, February 9, 2016 6:34 AM, Bruno Le Floch <blflatex at gmail.com> wrote:

 On 2/8/16, Philip Taylor <P.Taylor at rhul.ac.uk> wrote:
> P.S.  Experimenting against both versions, I found that what Python 3
> detected as syntax errors in the Version 2 source prevented the test
> from ever being evaluated, but the following three changes allow the
> diagnostic to be issue correctly for both Python 2 and Python 3 :
> def BadDVI(msg):
>  raise AttributeError, 'Bad DVI file: %s!' % msg
> ->
> def BadDVI(msg):
>  raise (AttributeError, 'Bad DVI file: %s!' % msg)
>      if q <= 0 or q >= 01000000000:
>        warning("%s---not loaded, bad scale (%d)!" % (n, q))
>      elif d <= 0 or d >= 01000000000:
> ->
>      if q <= 0 or q >= 512:
>        warning("%s---not loaded, bad scale (%d)!" % (n, q))
>      elif d <= 0 or d >= 512:
> ** Phil.

512 doesn't look like the right number (in Python 2, 012345 is octal
12345, not binary).  It may be better to use 0o1000000000 which seems
to work in both Python 2 and 3.


Subscriptions, Archive, and List information, etc.:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/xetex/attachments/20160209/c36defc3/attachment-0001.html>

More information about the XeTeX mailing list