Sep-29-2018, 08:04 AM
Let's say I have this class:
class MyNewClass: def func1(self): print('something to do') def func2(self): print('other thin to do')The normal syntax to call methods of this class is:
obj = MyNewClass() obj.func1() obj.func2()I would like to do exactly the same thing but without having to rewrite 'obj.' on each line as in this imaginary syntax:
obj = MyNewClass() using obj: func1() func2()Does Python allow you to write this kind of code?