G
G
ge2021-02-11 19:14:22
Python
ge, 2021-02-11 19:14:22

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()

What you need on the example of working with sqlite3:

import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()

Tell me what it's called and what to learn / read on the topic.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2021-02-11
@gedev

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.

E
Eugene, 2017-09-13
@eGenius18

rebuild the menu through walker'a. when connected, you can specify it. you can take from /wp-includes/class-walker-nav-menu.php - rename, include and specify as your class and painlessly edit ... you can google examples

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question