Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
8109 Lượt xem

e.g.


computation.py

------------------------

class A(object):

def hell(self, number)

{

----

}



b = A()




-----------------------------


sale module

sale.py


class sale_order(models.Model):

def abc(self):

# Here i wants to use that method hello() How can i use it?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Irfankhan,

You can put computation.py file in the same folder in which sale.py file is placed and You can do following code in the sale.py.

from . import computation

and you can make object of class A in the following way:

b = computation.A()

and you can call method as follow:

b.hell(13)

Regards,

Hardik

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You have to import hello()

from computation import hello

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
472
1
thg 6 25
1070
0
thg 5 25
1189
2
thg 4 25
3181
1
thg 2 25
1414