osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

what's the differences: None and null?


On Sat, 14 Sep 2019 at 03:40, Random832 <random832 at fastmail.com> wrote:
> On Fri, Sep 13, 2019, at 21:22, Hongyi Zhao wrote:
> > what's the differences: None and null?
> null isn't really a concept that exists in Python...

I'd say the opposite, according to [1] "None" is just the name of the
null object.


[1]: https://docs.python.org/3/library/stdtypes.html?highlight=null#the-null-object

--
Andrea


On Sat, 14 Sep 2019 at 03:40, Random832 <random832 at fastmail.com> wrote:
>
> On Fri, Sep 13, 2019, at 21:22, Hongyi Zhao wrote:
> > what's the differences: None and null?
>
> null isn't really a concept that exists in Python... while None fills many of the same roles that null does in some other languages, it is a proper object, with __str__ and __repr__ methods (that return 'None'), __hash__ (that returns an arbitrary value), etc.
>
> NULL, the C/C++ null pointer, is used in CPython for things like error returns, things like slots or cell variables that are not initialized (as opposed to being set to None), etc. This is an implementation detail, and should never come up in Python code.
> --
> https://mail.python.org/mailman/listinfo/python-list



--
Andrea