Answer the question
In order to leave comments, you need to log in
How to create a nested method structure in Python?
I do not think that I could correctly describe the essence of the issue in the title, I will try to explain below. It is also unclear how to properly ask a question in Google. If you send, I will be grateful.
# У меня есть класс с методами внутри. Я могу обращаться к методам вот так:
myobj = MyClass() # cоздаём экземпляр класса
myobj.my_method() # вызываем метод этого объекта
# Но хочется, чтобы можно было делать ещё и вот так:
newobj = myobj.my_method()
newobj.some_method()
import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()
Answer the question
In order to leave comments, you need to log in
Well, my_method should simply return newobj, through return
. And by the example, it’s not at all clear what is needed, conn and c are instances of different classes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question