Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > it.comp.lang.python > #7675
| From | Riccardo Lemmi <riccardo@reflab.com> |
|---|---|
| Newsgroups | it.comp.lang.python |
| Subject | Re: Classi |
| Followup-To | it.comp.lang.python |
| Date | 2016-07-13 11:52 +0200 |
| Organization | Reflab |
| Message-ID | <nm530c$ttj$1@gioia.aioe.org> (permalink) |
| References | <47Kgz.47242$pt.15731@tornado.fastwebnet.it> |
Followups directed to: it.comp.lang.python
Smith wrote:
> Ciao a tutti,
> perchè questo script mi restituisce il messaggio d'errore:
>
> AttributeError: 'NoneType' object has no attribute 'moo'
>
> Mentre dovrei ottenere :
>
> 'python3.4'
>
> Mi potete aiutare?
> Grazie
>
>
> def foo():
> a = 'python3.4'
>
> class Foo:
> def moo():
> print(a)
> return Foo
> F = foo()
> F.moo()
foo non ritorna nulla quindi ad F è assegnato un None.
Diciamo che potresti aggiungere:
return Foo()
ma dipende da cosa vuoi ottenere, inoltre la definizione del metodo moo
è errata, deve essere almeno:
def moo(self):
ma anche qui potrebbe dipendere da cosa vuoi ottenere (@staticmethod?).
--
Riccardo Lemmi
Back to it.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
Classi Smith <smith@smith.com> - 2016-07-11 12:00 +0200
Re: Classi Riccardo Lemmi <riccardo@reflab.com> - 2016-07-13 11:52 +0200
Re: Classi Smith <smith@smith.it> - 2016-07-15 21:07 +0200
csiph-web