[Zope-CMF] Must Python 2.1 compatibility be preserved for CMF 1.5?

Gregoire Weber gregweb at gmx.ch
Wed Jun 30 09:46:27 EDT 2004


.. or may I use Python 2.3 specific constructs?

For example I'd like to replace:

   if condition is not _unchanged and type(condition) == type(''):
      # blah

by: 

   if isinstance(condition, types.StringTypes):
      # blah


A possible solution may be to add the follwing at the top of the file 
or in the utils.py:

import types
try:
    def isStringType(content, StringTypes=types.StringTypes):
        return isinstance(content, StringTypes)
except AttributeError:
    def isStringType(content, StringTypes=(types.StringType, types.UnicodeType)):
        return type(content) in StringTypes

Gregoire



More information about the Zope-CMF mailing list