emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] OT: Python help


From: Giovanni Ridolfi
Subject: Re: [Orgmode] OT: Python help
Date: Tue, 20 Jul 2010 13:25:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (windows-nt)

Carsten Dominik <address@hidden> writes:

> On Jul 20, 2010, at 1:03 PM, Giovanni Ridolfi wrote:
>
>> Carsten Dominik <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]