[Python-de] AW: [Python-de] Anfängerfrage...
Fischer, Thomas
ThomasFischer at schmuecker.de
Thu Feb 28 10:07:53 EST 2002
Danke, war offenbar noch einfacher, als eine Anfängerfrage!
Ich schäme mich...
Thomas
-----Ursprüngliche Nachricht-----
Von: Rene Liebscher [mailto:R.Liebscher at gmx.de]
Gesendet: Donnerstag, 28. Februar 2002 10:05
An: python-de at starship.python.net
Betreff: Re: [Python-de] Anfängerfrage...
> "Fischer, Thomas" wrote:
>
> Hallo!
> Ich möchte eine Variable (StringText) innerhalb einer Klasse mit sich
> selbst addieren
> und erhalte dabei die Fehlermeldung:
> self.StringText=self.StringText+i
> TypeError: unsupported operand types for +
>
> Warum ist das so bzw. wie kann ich das Problem lösen?
>
> class Class:
> def __init__(self):
> self.StringText=None
>
> def add_string(self):
> for i in ('a','b'):
> self.StringText=self.StringText+i
>
> c=Class()
> c.add_string()
> print c.StringText
>
> Thomas
Du kannst mit None nicht 'rechnen'.
Wenn Du in __init__ self.StringText='' schreibst,
wuerde es funktionieren.
Rene
_______________________________________________
Python-de maillist - Python-de at starship.python.net
http://starship.python.net/mailman/listinfo/python-de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://starship.python.net/pipermail/python-de/attachments/20020228/c5b23dcc/attachment.htm
More information about the Python-de
mailing list