Skip to content
Advertisement

How to return objects from methods in Python?

Can anyone describe how to return objects from a method on which further methods and attributes can be accessed?

Example:

JavaScript

Advertisement

Answer

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.

JavaScript

http://repl.it/WWB


Python 3 version

JavaScript

Py3 repl: https://replit.com/@f0t0n/so-25158930#main.py

Advertisement