Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: ram@zedat.fu-berlin.de (Stefan Ram) Newsgroups: de.comp.lang.python Subject: Re: PDT: Dateien kopieren und Kopien verifizieren Date: 25 Aug 2025 19:19:33 GMT Organization: Stefan Ram Lines: 61 Expires: 1 Jun 2026 11:59:58 GMT Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de tVxpZ0xEqR9KdsR+hufMOgSl3StrpeQoSR9FYa76f+dJrX Cancel-Lock: sha1:BSTtN92lQr91WYIKB/RteL8l7QI= sha256:vUObG8O576dggyHQ48IgY/OUugSGYcY6Ssu66cLeQFU= X-Copyright: (C) Copyright 2025 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed. X-No-Archive: Yes Archive: no X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access. X-No-Html: yes Content-Language: de-DE-1901 Xref: csiph.com de.comp.lang.python:6301 Hermann Riemann schrieb oder zitierte: >Warum so kompliziert? >Versuch mal: >sources1 =[ source.strip() for source in ''' > >C:\otherdir\example.txt >C:\somedir\example.txt >C:\somedir\example1.txt > >''' .strip().split( '\n' ) if source ] Ich habe mir das ".strip()" jetzt mal angesehen (nach ziemlich genau einem Jahr): Oben ist das ".strip().split( '\n' )" ja vollkommen in Ordnung. Aber bei x = ''' abc def '''.strip() würde das auch die Einrückung vor "a" entfernen. Aber diese Einrückung ist für mich manchmal wichtig. Dann könnte man: x = ''' abc def '''.strip( '\n' ) schreiben. Aber machmal sind mir auch Leerzeilen am Anfang oder am Ende wichtig, wie in: x = ''' abc def '''.strip( '\n' ) , die dann verschwinden würden. Ich möchte eben genau das eine Zeilenende nach "'''" und manchmal das eine vor "'''" entfernen, aber alles andere wörtlich übernehmen. Und dies erreiche ich genau mit "[1:]" oder "[1:-1]" wie in: x = ''' abc def '''[1:-1] . Daher ist das für mich mein allgemeines Muster um mehrzeiligen Text zu zitieren, dessen Zeilen direkt eingebettet werden, ohne "'''" zu enthalten.