Groups | Search | Server Info | Keyboard shortcuts | Login | Register


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

[Python-de] Re: PDT: Datei blockweise kopieren

From Hartmut Goebel <h.goebel@crazy-compilers.com>
Newsgroups de.comp.lang.python
Subject [Python-de] Re: PDT: Datei blockweise kopieren
Date 2024-08-18 21:18 +0200
Organization crazy-compilers.com
Message-ID <ba0fbfc9-7ea7-471f-b332-0edadc597bda@crazy-compilers.com> (permalink)
References <Copy-20240818154232@ram.dialup.fu-berlin.de>

Show all headers | View raw


Hi,

Am 18.08.24 um 16:44 schrieb Stefan Ram:
>    Das "Python-Programm des Tages" erscheint für Diskussionszwecke,
Dann vermute ich mal, Du willst Diskussionsbeiträge :-)
>      with open( src_path, 'rb' )as src_file:

Ist zwar syntaktisch korrekt, aber bei ")as" drehen sich mir die 
Zehnnägel hoch. Bitte mach ein Leerzeichen hinter die schließende Klammer.

> def compare( src_path, dest_path ):
>      print( "comparing ..." )
>      with open( src_path, 'rb' )as f1, open( dest_path, 'rb')as f2:
>          while True:
>              chunk1 = f1.read( 4096 )
>              chunk2 = f2.read( 4096 )
>              if chunk1 != chunk2: return 1
>              if not chunk1: break
>      return 0

Sollte besser True (bei Erfolg) und False (bei Fehler) zurückgeben.

> product = copy_and_compare\
> ( r"C:\example\from.txt",
>    r"C:\example\to.txt" )

Hint: Die öffnende Klammer hinter "copy_and_compare" und Du kannst Dir 
den Backslash sparen.


-- 
Regards
Hartmut Goebel

| Hartmut Goebel          |h.goebel@crazy-compilers.com                |
|www.crazy-compilers.com  | compilers which you thought are impossible |

Back to de.comp.lang.python | Previous | Next | Find similar


Thread

[Python-de] Re: PDT: Datei blockweise kopieren Hartmut Goebel <h.goebel@crazy-compilers.com> - 2024-08-18 21:18 +0200

csiph-web