Python: Methods inside a method in a class -


import numpy np  class y:     def __init__(self):         return none      def f(self,x):         return x      def g(self,x):         return f(x)**2 y=y() print y.g(3) 

i know above code give error, somehow want following, there modification do?

the reason doesn't work because have f(x)**2 instead of self.f(x)**2. make change , it'll work perfectly.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -