[Zope] addng a list of users

John Hunter jdhunter@ace.bsd.uchicago.edu
Tue, 14 May 2002 09:05:02 -0500


>>>>> "Bill" == Bill Kerr <kerrb@senet.com.au> writes:

    Bill> I think the list should be in square brackets not round
    Bill> brackets ie. <dtml-in "['abc', 'pdq', 'someuser']"
    Bill> prefix=user> not <dtml-in "('abc', 'pdq', 'someuser')"
    Bill> prefix=user> I've just tried your suggestion, John, but no
    Bill> joy, unfortunately (tried round brackets too but still
    Bill> didn't work) Error Type: NameError Error Value: global name
    Bill> 'user' is not defined

Parentheses, or 'round brackets', are for tuples, and square brackets
are for lists.  One of the important differences between tuples and
lists is that lists are mutable, tuples not.

  y = [1, 2, 3] # list
  print y[1]    # fine, read access permitted
  y[1] = 1      # ok, lists are mutable

  x = (1,2,3)   # tuple
  print x[1]    # also fine
  x[1] = 1      # not ok, tuples are immutable.  raises TypeError

So in my view, tuples are the natural structures to use for 'read
only' sequences, as in the example of a list of users above.  But
either will work fine.  

I tested the example code I posted and it worked as expected on
Zope-2.5.

Cheers,
John Hunter