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()
#1
i want to do
class foo(): # this class doesn't return and create object (object) , only runs main function when is called
    @classmethod
    def main(cls):
          print "main function is called with using foo()"

foo()

# output #
# main function is called with using foo()
is there a way to do this ?
Moderator snippsat: Fixed code tag look at BBcode help
Reply


Messages In This Thread
How can i call classmethod with myClass() instead of using myClass.myClassMethod() - by harun2525 - Mar-23-2017, 04:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  @staticmethod and @classmethod akbarza 2 597 Jan-01-2024, 03:43 PM
Last Post: deanhystad
  How I can recognize that member is classmethod of staticmethod? AlekseyPython 0 1,883 Feb-17-2019, 07:01 AM
Last Post: AlekseyPython
  AttributeError: type object 'MyClass' has no attribute 'channel' chris0147 2 8,827 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