[Python-checkins] python/nondist/peps pep-0008.txt,1.13,1.14

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
Tue, 04 Jun 2002 09:57:46 -0700


Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv25304

Modified Files:
	pep-0008.txt 
Log Message:
Update for all the various ways of checking for a string/unicode object
in 2.3, 2.2, 2.1/2.0.


Index: pep-0008.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** pep-0008.txt	29 May 2002 16:07:27 -0000	1.13
--- pep-0008.txt	4 Jun 2002 16:57:44 -0000	1.14
***************
*** 541,549 ****
  
        When checking if an object is a string, keep in mind that it
!       might be a unicode string too!  In Python 2.2, the types module
!       has the StringTypes type defined for that purpose, e.g.:
  
!         from types import StringTypes:
          if isinstance(strorunicodeobj, StringTypes):
  
      - For sequences, (strings, lists, tuples), use the fact that empty
--- 541,560 ----
  
        When checking if an object is a string, keep in mind that it
!       might be a unicode string too!  In Python 2.3, str and unicode
!       have a common base class, basestring, so you can do:
  
!         if isinstance(strorunicodeobj, basestring):
! 
!       In Python 2.2, the types module has the StringTypes type defined
!       for that purpose, e.g.:
! 
!         from string import StringTypes
          if isinstance(strorunicodeobj, StringTypes):
+ 
+       In Python 2.0 and 2.1, you should do:
+ 
+         from string import StringType, UnicodeType
+         if isinstance(strorunicodeobj, StringType) or \
+            isinstance(strorunicodeobj, UnicodeType) :
  
      - For sequences, (strings, lists, tuples), use the fact that empty