Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #5137

Migration Python 2 auf 3

Path csiph.com!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Philipp Klaus Krause <pkk@spth.de>
Newsgroups de.comp.lang.python
Subject Migration Python 2 auf 3
Date Fri, 16 Mar 2018 14:29:53 +0100
Organization solani.org
Lines 28
Message-ID <p8ggsi$96i$1@solani.org> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace solani.org 1521206994 9426 eJwFwYEBwDAEBMCVKF6N4yP2HyF3YVCcdAQ8NvanCuuTO+ZjbeZkldTojuklMAlGH/GUJh8aERFK (16 Mar 2018 13:29:54 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Fri, 16 Mar 2018 13:29:54 +0000 (UTC)
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0
X-Mozilla-News-Host snews://news.solani.org:563
Cancel-Lock sha1:82jgzgHoo1PuCD/qzObnkVV7qH0=
Content-Language en-US
X-NNTP-Posting-Host eJwFwQkBwDAIA0BL0BEeOwuNfwm9w5eerEhkQNAvt+6hyN7VWB2u26XuFhvnZsp36BUFxwM5HxGm
X-User-ID eJwFwQkBwDAIA0BLjEAocspT/xJ25+DHDqPT/PmDamaLTCXP2btGXU7VhG0xgZiy6IX05sUPG5QRbQ==
Xref csiph.com de.comp.lang.python:5137

Show key headers only | View raw


Guten Abend,

Beim C-Compiler SDCC finden sich im Repository 7 Python-Skripte, die vor
langer Zeit geschrieben wurden. Die Skripte funktionieren mit Python 2,
sollen aber Python 3-kompatibel werden. Leider kenne ich mich mit Python
nicht aus. Bei 3 der Skripte ist mir die Umwandlung (teils manuell,
teils mit Hilfe des in Debian enthaltenen 2to3-2.7) dennoch bereits
gelungen. Bei den anderen 4 habe ich noch Probleme.

Wie ersetze ich die folgende Verwendung von popen2 durch etwas, das
sowohl in Pathon2, als auch python 3 funktioniert?

spawn = popen2.Popen4(cmd)
spawn.wait()
output = spawn.fromchild.readlines()

gibt es auch für print mit Komma am Ende eine Alternative, die sowohl
mit Python 2 als auch 3 funktioniert?

print "%-35.35s" % base,

könnte ich in Python 3 wohl als

print("%-35.35s" % base, end=' ')

was aber wohl unter Python 2 nicht erlaubt ist.

Philipp

Back to de.comp.lang.python | Previous | NextNext in thread | Find similar


Thread

Migration Python 2 auf 3 Philipp Klaus Krause <pkk@spth.de> - 2018-03-16 14:29 +0100
  Re: [Python-de] Migration Python 2 auf 3 Christopher Arndt <chris@chrisarndt.de> - 2018-03-16 14:44 +0100
  Re: [Python-de] Migration Python 2 auf 3 Hartmut Goebel <h.goebel@crazy-compilers.com> - 2018-03-16 14:44 +0100
    Re: [Python-de] Migration Python 2 auf 3 Philipp Klaus Krause <pkk@spth.de> - 2018-03-16 15:32 +0100
  Re: Migration Python 2 auf 3 Philipp Klaus Krause <pkk@spth.de> - 2018-03-16 15:35 +0100
    Re: [Python-de] Migration Python 2 auf 3 Stefan Behnel <python-de@behnel.de> - 2018-03-16 15:46 +0100
    Re: [Python-de] Migration Python 2 auf 3 Christopher Arndt <chris@chrisarndt.de> - 2018-03-16 15:50 +0100
    Re: [Python-de] Migration Python 2 auf 3 Stefan Behnel <python-de@behnel.de> - 2018-03-16 17:05 +0100

csiph-web