Python Forum
Calling a class from a function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling a class from a function
#4
jc4d Wrote:I noticed you have a pass statement at the end of the class, is that necessary?
No it is not necessary. I wrote the 'pass' in order to give a non empty body to the class definition. A better idea is to write a docstring
>>> class A:
...     """This class does nothing"""
... 
>>> 
The class body can only contain return statements in the method's definition.
Reply


Messages In This Thread
Calling a class from a function - by jc4d - Dec-15-2021, 08:04 AM
RE: Calling a class from a function - by jc4d - Dec-15-2021, 10:46 AM
RE: Calling a class from a function - by Gribouillis - Dec-15-2021, 10:51 AM
RE: Calling a class from a function - by jc4d - Dec-15-2021, 11:46 AM
RE: Calling a class from a function - by ndc85430 - Dec-17-2021, 09:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  The function of double underscore back and front in a class function name? Pedroski55 9 809 Feb-19-2024, 03:51 PM
Last Post: deanhystad
  calling external function with arguments Wimpy_Wellington 7 1,541 Jul-05-2023, 06:33 PM
Last Post: deanhystad
  Calling a function (which accesses a library) from another file mouse9095 4 862 Jun-07-2023, 08:55 PM
Last Post: deanhystad
  PyRun_SimpleFile calling multiprocessing Python Class cause endless init loop Xeno 2 1,090 Sep-19-2022, 02:32 AM
Last Post: Xeno
  TimeOut a function in a class ? Armandito 1 1,707 Apr-25-2022, 04:51 PM
Last Post: Gribouillis
Sad Iterate randint() multiple times when calling a function Jake123 2 2,121 Feb-15-2022, 10:56 PM
Last Post: deanhystad
  Calling a base class variable from an inherited class CompleteNewb 3 1,759 Jan-20-2022, 04:50 AM
Last Post: CompleteNewb
  Calling functions from within a class: PYQT6 Anon_Brown 4 3,858 Dec-09-2021, 12:40 PM
Last Post: deanhystad
  a function common to methods of a class Skaperen 7 2,705 Oct-04-2021, 07:07 PM
Last Post: Skaperen
  Tuple generator, and function/class syntax quazirfan 3 3,990 Aug-10-2021, 09:32 AM
Last Post: buran

Forum Jump:

User Panel Messages

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