From: Stanislav Levin <slev@basealt.ru> To: ALT Linux Team development discussions <devel@lists.altlinux.org> Subject: Re: [devel] [SCM] m/mathomatic/mathomatic.spec Date: Thu, 7 Nov 2019 23:17:39 +0300 Message-ID: <2b10068e-c032-1f2a-2037-f4df9fabe3d2@basealt.ru> (raw) In-Reply-To: <20191107182156.GA1803808@portlab> [-- Attachment #1.1: Type: text/plain, Size: 5703 bytes --] 07.11.2019 21:21, Vladimir D. Seleznev пишет: > ^ Этот способ не работает. Ниже перечислены изменения сделанные утилитой 2to3 в данном пакете. --- ./mathomatic/primes/matho-sum 2019-11-07 22:34:48.543068658 +0300 +++ ./matho-sum 2019-11-07 22:42:52.909266580 +0300 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # Python program to sum many large integers separated by spaces or newlines. # The integers to sum may be entered on the command-line or into standard input. @@ -12,7 +12,7 @@ # read stdin if no command line args while True: try: - input_line = raw_input() + input_line = input() except: break; for s in string.split(input_line): @@ -21,4 +21,4 @@ # sum together the command-line args for arg in args: sum += int(arg) -print sum +print(sum) --- ./mathomatic/primes/matho-mult 2019-11-07 22:34:48.543068658 +0300 +++ matho-mult 2019-11-07 22:42:35.634259521 +0300 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # Python program to multiply many large integers separated by spaces or newlines. # The integers to multiply may be entered on the command-line or into standard input. @@ -15,7 +15,7 @@ # read stdin if no command line args while True: try: - input_line = raw_input() + input_line = input() except: break; for s in string.split(input_line): @@ -24,4 +24,4 @@ # multiply together the command-line args for arg in args: prod *= int(arg) -print prod +print(prod) --- ./mathomatic/primes/primorial 2019-11-07 22:34:48.544068659 +0300 +++ primorial 2019-11-07 22:42:58.551268884 +0300 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # This is a Python program to display large primorials. # A primorial is the product of all primes up to the given number. @@ -16,11 +16,11 @@ import sys def usage(ev): - print "This program calculates large primorials." - print - print "Usage: %s integers" % os.path.basename(sys.argv[0]) - print - print "A primorial is the product of all primes up to the given number." + print("This program calculates large primorials.") + print() + print("Usage: %s integers" % os.path.basename(sys.argv[0])) + print() + print("A primorial is the product of all primes up to the given number.") sys.exit(ev) def output_primorial(arg): @@ -36,9 +36,9 @@ for arg in args: try: if (int(arg) < 1): - print >>sys.stderr, "Number too small." + print("Number too small.", file=sys.stderr) sys.exit(1) except: - print >>sys.stderr, "Positive integer required." + print("Positive integer required.", file=sys.stderr) usage(1) output_primorial(arg) --- ./mathomatic/examples/factorial 2019-11-07 22:34:48.538068656 +0300 +++ factorial 2019-11-07 22:43:04.379271266 +0300 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # This is a Python program to display large factorials and test "fact.py". @@ -8,13 +8,13 @@ import string def usage(): - print "This program calculates large factorials." - print "Requires and tests \"fact.py\"." - print - print "Usage: %s integer_expressions" % os.path.basename(sys.argv[0]) - print - print "The integer expressions should be separated by spaces." - print "A factorial is the product of all positive integers <= a given integer." + print("This program calculates large factorials.") + print("Requires and tests \"fact.py\".") + print() + print("Usage: %s integer_expressions" % os.path.basename(sys.argv[0])) + print() + print("The integer expressions should be separated by spaces.") + print("A factorial is the product of all positive integers <= a given integer.") sys.exit(2) args = sys.argv[1:] @@ -23,8 +23,8 @@ else: try: num = eval(string.join(args)) - print "factorial(", num, ") =", factorial(num) + print("factorial(", num, ") =", factorial(num)) except: for arg in args: num = eval(arg) - print "factorial(", num, ") =", factorial(num) + print("factorial(", num, ") =", factorial(num)) Очевидно, что изменения верные. Можете сравнить их, например, с Fedora: https://src.fedoraproject.org/rpms/mathomatic/tree/master Что именно в данном случае не работает? > 2to3 в большинстве случаев _не_ генерирует рабочий код. Это утверждение требующее каких-то доказательств. Список всех багов по 2to3: https://bugs.python.org/issue?%40search_text=&ignore=file%3Acontent&title=&%40columns=title&id=&%40columns=id&stage=&creation=&creator=&activity=&%40columns=activity&%40sort=activity&actor=&nosy=&type=&components=20&versions=&dependencies=&assignee=&keywords=&priority=&status=&%40columns=status&resolution=&nosy_count=&message_count=&%40group=&%40pagesize=50&%40startwith=0&%40sortdir=on&%40action=search Да, бывают нюансы. Но бОльшую массу кода трансформирует и трансформирует в рабочий Python3 код. > после каждого > перевода их надо проверять. Безусловно (если есть понимание изменений), потому что утилита не охватывает весь функциональный спектр. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-11-07 20:17 UTC|newest] Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-07 18:21 ` Vladimir D. Seleznev 2019-11-07 20:17 ` Stanislav Levin [this message] 2019-11-08 6:18 ` Fr. Br. George 2019-11-08 7:12 ` Stanislav Levin 2019-11-08 18:24 ` [devel] [JT] " Fr. Br. George 2019-11-08 7:26 ` [devel] " Anton Farygin 2019-11-08 18:26 ` Fr. Br. George 2019-11-09 7:01 ` Anton Farygin 2019-11-15 23:04 ` [devel] О переводе модулей на python3 Dmitry V. Levin 2019-11-17 18:30 ` Anton Farygin 2019-11-17 18:30 ` Anton Farygin 2019-11-17 21:19 ` Andrey Savchenko 2019-11-18 3:52 ` Anton Farygin 2019-11-18 4:11 ` Andrey Savchenko 2019-11-18 6:33 ` Anton Farygin 2019-11-18 4:09 ` Anton Farygin 2019-11-18 4:52 ` Антон Мидюков 2019-11-18 6:39 ` Anton Farygin 2019-11-18 7:17 ` Антон Мидюков 2019-11-18 7:49 ` Denis Medvedev 2019-11-18 7:53 ` Anton Farygin 2019-11-18 11:18 ` Dmitry V. Levin 2019-11-18 11:30 ` Anton Farygin 2019-11-18 11:22 ` Dmitry V. Levin 2019-11-18 11:32 ` Anton Farygin 2019-11-18 12:25 ` Michael Shigorin 2019-11-18 12:40 ` Grigory Ustinov 2019-11-18 12:45 ` Andrey Bychkov 2019-11-18 16:06 ` Anton Farygin 2019-11-18 15:24 ` Vladimir D. Seleznev 2019-11-18 6:48 ` [devel] О переводе модулей на python3 (was: [SCM] m/mathomatic/mathomatic.spec) Stanislav Levin 2019-11-18 13:07 ` Andrey Savchenko 2019-11-18 13:14 ` [devel] qt3 Dmitry V. Levin 2019-11-18 16:03 ` [devel] О переводе модулей на python3 (was: [SCM] m/mathomatic/mathomatic.spec) Alexey V. Vissarionov 2019-11-18 16:08 ` [devel] О переводе модулей на python3 Anton Farygin 2019-11-08 18:48 ` [devel] [SCM] m/mathomatic/mathomatic.spec Fr. Br. George 2019-11-11 14:34 ` Fr. Br. George
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=2b10068e-c032-1f2a-2037-f4df9fabe3d2@basealt.ru \ --to=slev@basealt.ru \ --cc=devel@lists.altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git