hehe, só vendo o ['Arquivo de configuracao da arquitetura'] da pra ver que é brasileiro =)<br><br>I didn't undestand, what didn't worked?<br><br>I've tryied this, and all went ok:<br><br>>>> list1 = ['name', 'value']
<br>>>> list2 = ['path', 'c:\some\path']<br>>>> list3 = [list1, list2]<br>>>> <br>>>> print str(list3).replace('\\\\','\\')<br>[['name', 'value'], ['path', 'c:\some\path']]
<br><br><div><span class="gmail_quote">On 3/12/07, <b class="gmail_sendername">Fabio Gomes</b> <<a href="mailto:flgoms@hotmail.com">flgoms@hotmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div>
It didn't work. I decided to submit the code in the list.<br><br>It is a script running with Jython to modify some configurations in the Websphere Application Server that has a Java like command line that interprets jython or jacl. I decided to use Jython.
<br><br>All the properties in that server are stored in hierarchy in the form of lists into lists. An exemple of one of the properties follows:<br><br>['systemProperties', [[['description', 'Arquivo de configuracao da arquitetura'], ['name', 'A_INI'], ['required', 'false'], ['value', '/xml/a_ini.xml']], [['description', 'Raiz do Ambiente'], ['name', 'A_ROOT'], ['required', 'false'], ['value', '
<a>file://D:\\A\\D9']]]</a>]<br><br>All above in a single string.<br><br>To make the things easier to me and the other people who will read that script, I decided to declare each subset of lists separatly. Something like that:
<br><br>list1 = ['name', 'value']<span class="q"><br>list2 = ['path', 'c:\some\path']<br></span>list3 = [list1, list2]<br><br>But doing that, list2 will be parsed by repr() and will receive an extra '\' when inserted int list3, messing up with the path information. I need some aproach to build that string without have to write it in one long and confuse string. Maybe hash tables will be the answer. I need to read about it.
<br><br>The entire code follows, remembering you that AdminConfig is an object present only in the WebSphere:<br><br><br>#<br># Creates the JVM custom properties A_INI and A_ROOT<br>#<br><br># Custom Properties<br>attr1_desc     = ['description', 'Arquivo de configuracao da arquitetura']
<br>attr1_name     = ['name', 'A_INI']<br>attr1_required = ['required', 'false']<br>attr1_value    = ['value', '/xml/a_ini.xml']<br>attr1_List     = [attr1_desc, attr1_name, attr1_required, attr1_value]
<br><br>attr2_desc     = ['description', 'Raiz do Ambiente']<br>attr2_name     = ['name', 'A_ROOT']<br>attr2_required = ['required', 'false']<br><br># ID of all application servers
<br>allServers = AdminConfig.getid('/Server:/')<br><br>import  java<br>lineSeparator = java.lang.System.getProperty('line.separator')<br><br>arrayAllServers = allServers.split(lineSeparator)<br><br># processing for each server
<br>for serverID in arrayAllServers:<br>  # bypass if it isn't an (real) application server<br>  if AdminConfig.showAttribute(serverID, 'name') == 'dmgr':<br>    continue<br>  if AdminConfig.showAttribute
(serverID, 'name') == 'nodeagent':<br>    continue<br>  if AdminConfig.showAttribute(serverID, 'name') == 'webserver':<br>    continue<br><br>  serverName = AdminConfig.showAttribute(serverID, 'name')
<br><br>  print 'Atualizando o servidor', serverName, '...'<br><br>  jvm = AdminConfig.list('JavaVirtualMachine', serverID)<br><br>  path = '<a>file://D:\\A\\</a>' + serverName[5:]<br>  attr2_value = ['value', path]
<br>  attr2_List  = [attr2_desc, attr2_name, attr2_required, attr2_value]<br>  attr_List   = [attr1_List, attr2_List]<br>  property    = ['systemProperties', attr_List]<br><br>  AdminConfig.modify(jvm, [property])
<br><br>print 'Salvando configuracoes...'<br>AdminConfig.save()<br><br>#EOF<br><div>
<h3 align="center"> </h3></div><br><br><blockquote style="border-left: 2px solid rgb(0, 128, 128); padding-left: 5px; margin-left: 5px; margin-right: 0px;"><hr>Date: Mon, 12 Mar 2007 13:40:58 -0300<div><span class="e" id="q_111471c8578c8eca_3">
<br>From: <a href="mailto:lucastorri@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">lucastorri@gmail.com</a><br>To: <a href="mailto:flgoms@hotmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
flgoms@hotmail.com</a><br>Subject: Re: backslashes in lists<br>CC: <a href="mailto:python-list@python.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">python-list@python.org</a><br><br>just like the same way, but replace alist -> list:
<br><br>str(list).replace('\\\\','\\')<br><br><br>as the time you call str(object) you will have an object of type string, and you can do whatever you want/could do with it...
<br><br><br>what are you trying?! isn't more interesting use a hash table?<br><br><div><span>On 3/12/07, <b>Fabio Gomes</b> <<a href="mailto:flgoms@hotmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
flgoms@hotmail.com
</a>> wrote:</span><blockquote style="padding-left: 1ex;">



<div>
Nice, Lucas.<br><br>  But help me again, please. What about "echoing" the list:<br><br>>>> str(alist).replace('\\\\','\\')<span><br>"['a', 'b', 'c:\\some\\path']"
<br><br></span>  Because in my script I'm echoing the list to mount lists into lists, like:<br><br>>>> list1 = ['name', 'test']<br>>>> list2 = ['path', 'c:\some\path']
<br>>>> list = [list1, list2]<br>>>> print list<br>[['name', 'test'], ['path', 'c:\\some\\path']]<br><br>  That's how it is coded in my script. What do you think. Is it possible to print "list" without the doubled backslash?
<br><br>  Thank again, Lucas.<br>  <br><br><blockquote style="padding-left: 5px; margin-left: 5px; margin-right: 0px;"><hr>Date: Mon, 12 Mar 2007 12:15:10 -0300<span><br>
From: <a href="mailto:lucastorri@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">lucastorri@gmail.com</a><br>To: <a href="mailto:flgoms@hotmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

flgoms@hotmail.com</a><br>Subject: Re: backslashes in lists<br>CC: <a href="mailto:python-list@python.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">python-list@python.org</a><br><br></span><span>

I don't know how ugly this look like, but { <span style="font-weight: bold;">print str(alist).replace('\\\\', '\\')</span> } works...<br><br></span><div><span><span>On 3/12/07, <b>
Fabio Gomes</b> <<a href="mailto:flgoms@hotmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">flgoms@hotmail.com</a>> wrote:</span></span><blockquote style="padding-left: 1ex;">




<div><span>
Yes, Luca.<br><br>  I noticed <span style="font-weight: bold;"></span>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()?
<br><div>
<h3 align="center"> </h3></div><br><br></span><blockquote style="padding-left: 5px; margin-left: 5px; margin-right: 0px;"><span><hr>Date: Mon, 12 Mar 2007 12:00:19 -0300<br>From: <a href="mailto:lucastorri@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">


lucastorri@gmail.com</a><br>To: <a href="mailto:flgoms@hotmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">flgoms@hotmail.com</a><br>Subject: Re: backslashes in lists<br>CC: <a href="mailto:python-list@python.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">


python-list@python.org</a></span><div><span><span><br><br>The backslash is a key to enter especial characters, like breakline: '\n'<br><br>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:
<br><br>print alist[2]<br><br></span><div><span><span>On 3/12/07, <b>Fabio Gomes</b> <<a href="mailto:flgoms@hotmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">flgoms@hotmail.com
</a>> wrote:</span>
</span><blockquote style="padding-left: 1ex;"><span>




<div>
Hi list,<br><br>  I'm trying to use a string with backslashes in a list. But Python parses strings in lists with repr().<br><br><br>>>> alist = ['a', 'b', 'c:\some\path']<br>>>> alist
<br>['a', 'b', 'c:\\some\\path']<br>>>> print alist<br>['a', 'b', 'c:\\some\\path']<br><br><br>  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.
<br><br>  Can anyone help me, please?<br><br>  Thank you.<br><br><hr>O Windows Live Spaces está aqui! Descubra como é fácil criar seu espaço na Web e sua rede amigos. <a href="http://spaces.live.com/signup.aspx" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">



Confira!</a></div>
<br>--<br></span><span><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://mail.python.org/mailman/listinfo/python-list</a>
<br></span></blockquote></div>

<br>
</span></div></blockquote><span><br><hr>Busque em qualquer página da Web com alta proteção. Obtenha o Windows Live Toolbar GRATUITO ainda hoje! <a href="http://toolbar.live.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">


Experimente agora!</a></span></div>
<br>--<span><br><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://mail.python.org/mailman/listinfo/python-list</a><br></span>
</blockquote></div>
<br>
</blockquote><span><br><hr>O Windows Live Spaces está aqui! Descubra como é fácil criar seu espaço na Web e sua rede amigos. <a href="http://spaces.live.com/signup.aspx" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

Confira!</a></span></div>
<br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div>

<br>
</span></div></blockquote><br><hr>Ligue para os seus amigos grátis. Faça chamadas de PC-para-PC pelo messenger-- GRÁTIS <a href="http://get.live.com/messenger/overview" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
Experimente agora!</a></div>
<br>--<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div>
<br>