[Zope] Stupid Question Time

2000-07-11 Thread Terry Babbey

I think if I can get an answer to a stupid question it may go along
way to opening my eyes to Zope.

I need to understand the use of ',",(),[].
I think when you use single quote ' - it means to take as literal -
don't interpret.
Eg. 'A+R' is taken as A+R and is not calculated.
But as for the others, I do not know how or when to use them.

Anybody have the patience to answer this?

Terry
--
__
Terry Babbey
Technical Support Specialist
Lambton College, Sarnia, Ontario, Canada
__



___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Stupid Question Time

2000-07-11 Thread Jerome ALET

On Tue, Jul 11, 2000 at 04:00:26PM -0400, Terry Babbey wrote:
 I think if I can get an answer to a stupid question it may go along
 way to opening my eyes to Zope.
 
 I need to understand the use of ',",(),[].
 I think when you use single quote ' - it means to take as literal -
 don't interpret.

all of these come directly from the Python language.

you should read the Python tutorial (find it on python.org) and you'll
understand them all.

in short: 

' and " are equivalent
() are for functions or methods
[] are for arrays (aka list, aka tables) or dictionnaries (aka mappings)

bye,

Jerome Alet

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Stupid Question Time

2000-07-11 Thread R. David Murray

On Tue, 11 Jul 2000, Jerome ALET wrote:
 ' and " are equivalent

Not quite true.  dtml only recognizes " for surrounding dtml expressions.
But you are right that they are equivalent in python.

 () are for functions or methods

To call functions or methods: blah(somearg).  But also used for
grouping in expressions: a * (b+c), and for delimiting immutable sequences:
('thing', 'secondthing').

 [] are for arrays (aka list, aka tables) or dictionnaries (aka mappings)

[] can be used to index into sequences: a[3], or to slice out a
portion of a sequence: a[2:4] (see the python guide for more).
Also key lookup out of dictionaries/mappings.  But to *define*
dictionaries you use {}:  {'key1': 'val1', 'key2': 'val2'}.

The most confusing part is the interface between dtml and python.
in an expr, inside the quotes you are in python and things follow
python syntax rules.  This gets really confusing when you have
dtml variables that have hyphens in them, since in python that's
the subtraction symbol.  So inside a python expression, you have
to look up such symbols in the dtml name space.  The dtlm namespace
is named '_', and is a mapping.  So you have things like:

dtml-var expr="_['sequence-index']+1"

which prints out a number one greater than the current sequence-index.

You can leave off the 'expr=' above, and because of the "s, dtml
will assume it.  This is the way most dtml is written, with the
expr= or name= left out, and that can be very confusing when you
don't know the rules; see the dtml guide.

This is but the briefest introduction to this topic, but hopefully
it will make a few things clearer.

--RDM


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )