emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Giovanni Ridolfi <giovanni.ridolfi@yahoo.it>
To: Carsten Dominik <dominik@uva.nl>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: OT: Python help
Date: Tue, 20 Jul 2010 13:25:11 +0200	[thread overview]
Message-ID: <83r5iy1jl4.fsf@yahoo.it> (raw)
In-Reply-To: <606EFD47-1329-43F8-8496-1A0B0A2390E9@uva.nl> (Carsten Dominik's message of "Tue, 20 Jul 2010 13:13:04 +0200")

Carsten Dominik <dominik@uva.nl> writes:

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

      parent reply	other threads:[~2010-07-20 11:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-20 10:47 OT: Python help Carsten Dominik
2010-07-20 11:03 ` Giovanni Ridolfi
2010-07-20 11:13   ` Carsten Dominik
2010-07-20 11:20     ` Puneeth
2010-07-20 11:25       ` Carsten Dominik
2010-07-20 11:28       ` Puneeth
2010-07-20 13:08         ` Peter Westlake
2010-07-20 13:12           ` Carsten Dominik
2010-07-20 18:03           ` Xiao-Yong Jin
2010-07-20 11:25     ` Giovanni Ridolfi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83r5iy1jl4.fsf@yahoo.it \
    --to=giovanni.ridolfi@yahoo.it \
    --cc=dominik@uva.nl \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).