About 119,000 results
Open links in new tab
  1. Python class returning value - Stack Overflow

    MyClass() returns a MyClass instance. If you want a list instance, just get a list instance. If the issue instead is what do these objects look like when you print them or look at them in the …

  2. Python Return Class From Function - Finxter

    Jul 27, 2023 · In Python, you can return class objects from functions just like any other data type. This can be useful in situations where you need to create an instance of a specific class based …

  3. 9. ClassesPython 3.13.3 documentation

    2 days ago · Python classes provide all the standard features of Object Oriented Programming: the class inheritance mechanism allows multiple base classes, a derived class can override …

  4. Python Classes - W3Schools

    The __str__() function controls what should be returned when the class object is represented as a string. If the __str__() function is not set, the string representation of the object is returned:

  5. Get Return Value from Function in a Class in Python

    def getScore(self): return self.score. def getEnemies(self): return self.num_enemies. def getLives(self): return self.num_lives. Learn how to get the return value from a function within a …

  6. How to return objects from methods in Python? - Stack Overflow

    Aug 6, 2014 · Create an Order class with appropriate methods and properties. After that, you'll be able to return an instance of this class from PizzaHut.order() method. class Order(object): def …

  7. 17.9. Instances as Return Values — How to Think like a Computer ...

    Apr 29, 2025 · Functions and methods can return objects. This is actually nothing new since everything in Python is an object and we have been returning values for quite some time.

  8. How to return a python class object from a basic function

    Jul 8, 2024 · This is an example of a class for data-only objects, but it’s equally easy to define a class that returns a function object by adding the def keyword to your code:,It’s also possible …

  9. Python property returning property object - Stack Overflow

    You need to make a minor change: class Foo(object): def get_bar(self): return "bar" bar = property(get_bar) print Foo().bar # prints bar The property needs to be an attribute of the …

  10. Return Object from Function in Python - Online Tutorials Library

    Learn how to return an object from a function in Python with clear examples and explanations.

  11. Some results have been removed
Refresh