From mboxrd@z Thu Jan 1 00:00:00 1970 From: Giovanni Ridolfi Subject: Re: OT: Python help Date: Tue, 20 Jul 2010 13:25:11 +0200 Message-ID: <83r5iy1jl4.fsf@yahoo.it> References: <97ED60B0-D01C-47DB-9B5E-10F1B39E3892@uva.nl> <83vd8a1kkv.fsf@yahoo.it> <606EFD47-1329-43F8-8496-1A0B0A2390E9@uva.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=53603 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObAwm-0002HV-9O for emacs-orgmode@gnu.org; Tue, 20 Jul 2010 07:25:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ObAwk-0003BN-LH for emacs-orgmode@gnu.org; Tue, 20 Jul 2010 07:25:16 -0400 Received: from slim-2c.inet.it ([213.92.5.123]:53197) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObAwk-0003B3-8h for emacs-orgmode@gnu.org; Tue, 20 Jul 2010 07:25:14 -0400 In-Reply-To: <606EFD47-1329-43F8-8496-1A0B0A2390E9@uva.nl> (Carsten Dominik's message of "Tue, 20 Jul 2010 13:13:04 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: emacs-org list Carsten Dominik writes: > On Jul 20, 2010, at 1:03 PM, Giovanni Ridolfi wrote: > >> Carsten Dominik writes: >> >> >>> a python question: How do I prefix every line in a multiline string >>> with a string. For example, I would like to add "> " before all >>> lines >>> in a string.... >> >> how about replacing "\n" with "\n > " ? > > Please show me the full line of code, I am currently editing a python > script without any knowledge of python... > > :( Carsten , I do not know python as well :-/ I found: 1. from python docs: http://docs.python.org/library/string.html string.replace(str, old, new[, maxreplace]) Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxreplace is given, the first maxreplace occurrences are replaced. 2. while googling: "Python like this: python -c 'import sys; print sys.stdin.read().replace("\n", " ")' < days.txt" http://linux.dsplabs.com.au/rmnl-remove-new-line-characters-tr-awk-perl-sed-c-cpp-bash-python-xargs-ghc-ghci-haskell-sam-ssam-p65/ 3. also: http://bytes.com/topic/python/answers/721547-replace-characters-string # >>> s = "sex_m-designer_bw-size_42" # >>> s = s.replace('_', '=') # >>> s = s.replace('-', '&') # >>> s # 'sex=m&designer=bw&size=42' 4. http://stackoverflow.com/questions/930303/python-string-cleanup-manipulation-accented-characters name-of-the-string.replace(' ', '.') # replace spaces with periods hth Giovanni