[Tutor] What exactly does the three dots do? Why such as thing?
C W
tmrsg11 at gmail.com
Thu Aug 10 09:39:02 EDT 2017
What's a literal? The only other time I heard about it was studying
Shakespare. ;)
I don't know what literal is. So, it won't help me to understand ellipsis,
I really thought it was that oval shaped figure.
Wiki says: "Literals are often used to initialize variables"
https://en.wikipedia.org/wiki/Literal_(computer_programming)
I suppose it's just a place holder, though I don't know when I would use it
in my every day life.
On Thu, Aug 10, 2017 at 8:47 AM, Steven D'Aprano <steve at pearwood.info>
wrote:
> On Wed, Aug 09, 2017 at 12:06:37PM -0400, C W wrote:
> > Dear Python experts,
> >
> > What exactly does the three dots do?
> > > aList = ...
>
> ... is literal syntax for the Ellipsis singleton object.
>
> Ellipsis was added to the language at the express request of the numpy
> developers. Although numpy is a third-party project outside of the
> standard library, it is big enough and important enough that their
> requests carry a LOT of weight with the core Python devs. Other features
> Python has that were originally added at the request of numpy include:
>
> - extended slicing with two colons obj[a:b:c]
>
> - the @ operator used by numpy for matrix multiplication.
>
> I don't know what Ellipsis is used for by numpy, but now it makes a
> convenient pseudo-pass command:
>
> class X:
> ...
>
> def func():
> ...
>
>
> > It's an ellipsis, a spot holder to later. But what data type is it:
> vector,
> > matrix?
>
> Its a singleton object. Think of it as a sibling to None and
> NotImplemented, but with optional funny syntactic sugar ... to refer to
> it.
>
> None is a special value used as "no such value", or nil or null;
>
> NotImplemented is a special value used by operator dunder methods like
> __add__ and __mul__ to mean "I can't handle this argument";
>
> Ellipsis is a special value used by numpy to mean whatever it is that
> numpy uses it to me.
>
>
> --
> Steve
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list