Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ellipsis
#4
I am not sure I can understand you, may be this is because I am not a native English speaker. Are you talking about passing arguments to a function, or overriding dictionary methods, e.g. dict.__getitem__? Could you provide some code: where it was used None and where you want to use Ellipsis instead. If you need to override dict.__getitem__, you need to subclass UserDict instead of dict:

from collections import UserDict

class option(UserDict):
    def __getitem__(self, key):
        if key is Ellipsis:
            print("Do some stuff")
        else:
            return super().__getitem__(key)

z = option()
z.update({'one': 1})
z[...]
Hope that helps...
Reply


Messages In This Thread
Ellipsis - by Skaperen - May-19-2019, 11:04 PM
RE: Ellipsis - by scidam - May-20-2019, 01:18 AM
RE: Ellipsis - by Skaperen - May-20-2019, 06:22 AM
RE: Ellipsis - by scidam - May-20-2019, 10:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how is Ellipsis or ... used? Skaperen 9 2,175 Oct-04-2022, 10:17 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020