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


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

Migration Python 2 auf 3

From Philipp Klaus Krause <pkk@spth.de>
Newsgroups de.comp.lang.python
Subject Migration Python 2 auf 3
Date 2018-03-16 14:29 +0100
Organization solani.org
Message-ID <p8ggsi$96i$1@solani.org> (permalink)

Show all headers | 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