[Zope] dtml-var render two same responses for two questions differents

Dylan Reinhardt zope@dylanreinhardt.com
Tue, 18 Feb 2003 07:51:11 -0800


First off, you need to close all these expressions with another 
double-quote after the last paren.  I'll assume that was a copy & paste typo.

Moving to the heart of the matter... the \ character may be the path 
separator in Windoze, but it doesn't have this significance to Python.  In 
Python the \ is an escape character, mostly.

E and F are the same because '\.' isn't a valid escape for anything in this 
context. Since the \ isn't a valid escape, Python is smart enough to figure 
out that you probably want the \ interpreted as a literal.  The \\ sequence 
*is* an escape... for a single \ char.  When Python interprets '\' as a 
literal, it stores it as '\\'.    That's why they come out the same... they 
*are* the same.

If that's not what you want, use the raw string format, which looks like:

foo = r'c:\windows\system\some.dll'

That lower-case r at the beginning of the string means that the \'s are 
interpreted literally, not as escapes.

A better question, though, is what difference does it make?  You aren't 
going to be calling the Windoze file system from DTML anyway.

Is there something you're having difficulty doing or are you just exploring 
how string manipulation works in DTML?

Dylan



At 06:53 AM 2/18/2003, Pascal Samuzeau wrote:
>Hi,
>
>Just a simple question, for a simple answer ( I hope so ...)
>(I'm with Zope2.6.0 under Win)
>
>I have a DTML Method as :
>
>A- <dtml-var expr="test('test.test')>
>B- <dtml-var expr="test('test\test')>
>C- <dtml-var expr="test('test..test')>
>D- <dtml-var expr="test('test\\test')>
>E- <dtml-var expr="test('test\.test')>
>F- <dtml-var expr="test('test\\.test')>
>
>
>I have a script python as, with thevar as parameter
>
><dtml-return thevar>
>
>So if I try I have these answers:
>
>A - test.test
>B - test\test
>C - test..test
>D - test\\test
>
>E - test\\.test
>F - test\\.test
>
>So my simple question : how can I recognize E from F ?
>
>What is happening ?
>
>
>Sincerily
>PS
>--------------------------------------------------
>Oreka ! Nous sommes l'internet moins cher !
>Surfez 25% moins cher avec http://www.oreka.com
>
>_______________________________________________
>Zope maillist  -  Zope@zope.org
>http://mail.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )