[python-win32] Null provokes unicode error.

Amit Upadhyay upadhyay at gmail.com
Tue Aug 23 12:50:15 CEST 2005


> 
> This happens when the description value is null. 
> 
> How do I avoid this problem?


You can not add string to None, 

>>> "ASd"+None
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: cannot concatenate 'str' and 'NoneType' objects
>>> 

try something like:

import win32com.client
>  objContainer = win32com.client.GetObject("
> LDAP://cn=users,dc=agri,dc=local")
>  for objChild in objContainer:
>  if not objChild.Description: objChild.Description = ''
>  print objChild.Name + '\t' + objChild.Description
> 

-- 
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9867-359-701
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20050823/0c489764/attachment.htm


More information about the Python-win32 mailing list