[Python-de] close() und flush() (was: Problem mit os.spawnv)
Fritz Cizmarov
fritz at sol.at
Fri Mar 28 12:54:40 EST 2003
Hi Andreas,
was ist, wenn du flush() vor close() ausführst?
Gruß
Fritz
Am Fri, 28 Mar 2003 11:32:18 +0100
Schrieb Andreas Kaiser <listen at vocote.de>:
> Am Freitag, 28. März 2003 11:13 schrieb Andreas Kaiser:
> > Am Freitag, 28. März 2003 01:05 schrieb Andreas Kaiser:
> > > Nun zu meinem Problem:
> > > Wenn ich in IDLE folgendes aufrufe, funktioniert alles wie
> > > beabsichtigt:
> > >
> > > import os
> > > os.spawnv(os.P_NOWAIT, '/usr/bin/latex', ['latex',
> > > 'filename.tex'])
> > >
> > > Führe ich das Ganze in einem Programm aus, wo wxPython mit im
> > > Einsatz ist, funktioniert die ganze Geschichte nicht, LaTex bricht
> > > mit einem Fehler ab.
> >
> > Ich antworte mir mal selber :)
> > Das Problem lag daran, dass obwohl close() aufgerufen wurde, um die
> > benötigte Datei vorher zu schließen, die Datei noch leer war. Da der
> > nächste Befahl nach close() os.spawnwv(...) war, lief LaTeX ins
> > Leere. Ein flush() dazwischen und alles funktioniert wie erwartet.
> >
> KORREKTUR: mit flush() nach close() geht es nicht! Die Datei ist noch
> leer. Ich habe den os.spawnv Aufruf nun auf einen extra Button gelegt.
> Das funktioniert.
>
> Also das geht nicht:
> (Beipieldarstellung)
>
> def makeAll(self):
> f.write(text)
> f.close
> f.flush
> pid = os.spawnv(os.P_WAIT, '/usr/bin/latex', ['latex',
> 'filename.tex'])
>
> makeAll()
>
> Das geht:
>
> def writeFile(self):
> f.write(text)
> f.close
>
> def makeLatex(self):
> pid = os.spawnv(os.P_WAIT, '/usr/bin/latex', ['latex',
> 'filename.tex'])
>
> writeFile()
> makeLatex()
>
> Nach close() UND einem flush() sollte doch aber die Datei mit Inhalt
> gefüllt sein? Ist das ein Bug?
>
>
> Debian (woody), Python 2.2.1
>
> Grüße
> Andreas
>
>
> _______________________________________________
> Python-de maillist - Python-de at starship.python.net
> http://starship.python.net/mailman/listinfo/python-de
More information about the Python-de
mailing list