Python Forum
How can i call classmethod with myClass() instead of using myClass.myClassMethod()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can i call classmethod with myClass() instead of using myClass.myClassMethod()
#3
You could rewrite __new__() to "forbid" creation of an object and to do some action, but why would someone sane want to do it ...
In [1]: class foo:
   ...:     def __new__(cls):
   ...:         print("foo")
   ...:         

In [2]: foo()
foo
Reply


Messages In This Thread
RE: How can i call classmethod with myClass() instead of using myClass.myClassMethod() - by zivoni - Mar-23-2017, 05:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  @staticmethod and @classmethod akbarza 2 587 Jan-01-2024, 03:43 PM
Last Post: deanhystad
  How I can recognize that member is classmethod of staticmethod? AlekseyPython 0 1,874 Feb-17-2019, 07:01 AM
Last Post: AlekseyPython
  AttributeError: type object 'MyClass' has no attribute 'channel' chris0147 2 8,801 Sep-29-2017, 06:16 PM
Last Post: chris0147

Forum Jump:

User Panel Messages

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