backslashes in lists

Fabio Gomes flgoms at hotmail.com
Mon Mar 12 16:30:59 CET 2007


Nice, Lucas.  But help me again, please. What about "echoing" the list:>>> str(alist).replace('\\\\','\\')"['a', 'b', 'c:\\some\\path']"  Because in my script I'm echoing the list to mount lists into lists, like:>>> list1 = ['name', 'test']>>> list2 = ['path', 'c:\some\path']>>> list = [list1, list2]>>> print list[['name', 'test'], ['path', 'c:\\some\\path']]  That's how it is coded in my script. What do you think. Is it possible to print "list" without the doubled backslash?  Thank again, Lucas.  Date: Mon, 12 Mar 2007 12:15:10 -0300From: lucastorri at gmail.comTo: flgoms at hotmail.comSubject: Re: backslashes in listsCC: python-list at python.orgI don't know how ugly this look like, but { print str(alist).replace('\\\\', '\\') } works...On 3/12/07, 
Fabio Gomes <flgoms at hotmail.com> wrote:





Yes, Luca.  I noticed that printing the list item will show the string as expected. But I need to print the entire list in the script I'm writing and doing that, the list will will be repr()'ed. Is there any way to print the entire list without being parsed by repr()?

 Date: Mon, 12 Mar 2007 12:00:19 -0300From: 
lucastorri at gmail.comTo: flgoms at hotmail.comSubject: Re: backslashes in listsCC: 
python-list at python.orgThe backslash is a key to enter especial characters, like breakline: '\n'There is two backslashes cause of this especial condition of this char, but if you try print the specific string you will see that only one backslash remain:
print alist[2]On 3/12/07, Fabio Gomes <flgoms at hotmail.com> wrote:






Hi list,  I'm trying to use a string with backslashes in a list. But Python parses strings in lists with repr().>>> alist = ['a', 'b', 'c:\some\path']>>> alist
['a', 'b', 'c:\\some\\path']>>> print alist['a', 'b', 'c:\\some\\path']  I already tried str() and raw (r) but it didn't work. All I want is to keep a single backslash in the string since it is a path information.
  Can anyone help me, please?  Thank you.O Windows Live Spaces está aqui! Descubra como é fácil criar seu espaço na Web e sua rede amigos. 

Confira!
--http://mail.python.org/mailman/listinfo/python-list


Busque em qualquer página da Web com alta proteção. Obtenha o Windows Live Toolbar GRATUITO ainda hoje! 
Experimente agora!
--http://mail.python.org/mailman/listinfo/python-list


_________________________________________________________________
O Windows Live Spaces está aqui! Descubra como é fácil criar seu espaço na Web e sua rede amigos.
http://spaces.live.com/signup.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070312/cb79aa79/attachment.html>


More information about the Python-list mailing list