Re: Dynamic classes

Liste des GroupesRevenir à cl python 
Sujet : Re: Dynamic classes
De : greg.ewing (at) *nospam* canterbury.ac.nz (Greg Ewing)
Groupes : comp.lang.python
Date : 20. May 2025, 01:29:09
Autres entêtes
Message-ID : <m920mlF41dqU1@mid.individual.net>
References : 1 2
User-Agent : Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0) Gecko/20100101 Thunderbird/91.3.2
On 20/05/25 4:33 am, Stefan Ram wrote:
   So, the reason you're getting that
   TypeError is your __init__ function isn't actually hooked up
   right when you build your class with "type". You got to set up
   your init before you call "type", and then drop it into the
   class dictionary as a /function/ (not as a string).
That's what he did, or at least that's what he tried to do.
It turns out the misplaced quote was the entire problem -- by a
fluke, it didn't result in a syntax error, and ended up putting
the __init__ function into the dict under the name
'Flag3: 4, __init__'.
--
Greg

Date Sujet#  Auteur
19 May 25 * Dynamic classes3Jonathan Gossage
19 May 25 `* Re: Dynamic classes2Stefan Ram
20 May 25  `- Re: Dynamic classes1Greg Ewing

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal