On Jul 27, Zachary Borschuk <zachary.borsc...@gmail.com> wrote:

> I'm quite new to python, so this may be a trivial question, but,
> what type does 'person.currentRole' return, it doesn't seem to be
> a string,

You're right, it's not a string/unicode, even if it behaves a
lot like them (for compatibility with a time when it really was a
unicode string).

As documented in README.currentRole [1] can be a Character or a
Person instance.
It can also be an instance of the RolesList class, which behaves
like a normal Python list to handle multiple roles/characters (the only
difference with lists is that the conversion to unicode is prettier),
or it can be None, meaning that there's no role.

> since I receive an error about type when attempting to autoadd it
> as a charfield type.  How can I alter it so that it is a string?

Once you've checked that it's not empty ("if obj.currentRole:" is enough),
you can get a unicode with a simple:
  roleInUnicode = unicode(obj.currentRole)

Notice that I'm talking about unicode and not string, and I assume
you know the difference and how to handle them.  If this is not the
case, see README.utf8 [2] as a brief introduction (there are also
links to reference material about unicode and strings).

Hope this helps - if you've other questions and/or you need some
example (or want to submit a snippet of your code), feel free to ask.


+++
[1] http://imdbpy.sourceforge.net/docs/README.currentRole.txt
[2] http://imdbpy.sourceforge.net/docs/README.utf8.txt
-- 
Davide Alberani <davide.alber...@gmail.com> [GPG KeyID: 0x465BFD47]
http://erlug.linux.it/~da/

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Imdbpy-help mailing list
Imdbpy-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-help

Reply via email to