__new__() does not return anything, on singletong pattern

Ethan Furman ethan at stoneleaf.us
Wed Mar 11 19:47:32 EDT 2015


On 03/11/2015 04:33 PM, Mario Figueiredo wrote:

> The following code runs just fine. But PyCharm flags the assignment
> with a warning telling me that generate() does not return anything and
> the I lose code completion on the mmap variable.
> 
> if __name__ == '__main__':
>     mmap = Map.generate(12, 24)
>     print(mmap.width, mmap.height, mmap.author)
> 
> I need to understand if this is just a glitch of the IDE or I am doing
> indeed something that is frowned upon and ended up caught in a
> misleading static analysis warning.

You're code is good.  The only question is if you /really/ need a singleton -- and only you can answer that (although
plenty of folks will tell you you don't ;) .

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20150311/54d83375/attachment.sig>


More information about the Python-list mailing list