Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.lang.python > #7676

Re: Classi

Subject Re: Classi
References <47Kgz.47242$pt.15731@tornado.fastwebnet.it> <nm530c$ttj$1@gioia.aioe.org>
Newsgroups it.comp.lang.python
From Smith <smith@smith.it>
Message-ID <57893477.4050405@smith.it> (permalink)
Date 2016-07-15 21:07 +0200

Show all headers | View raw


On 13/07/2016 11:52, Riccardo Lemmi wrote:
> 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?).
>
>
>
Grazie

Back to it.comp.lang.python | Previous | NextPrevious in thread | Find similar


Thread

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