Everything isn't fresh for me, but what are you trying to do here s.circle.area(5) is accesssing to an attribute of Object, who should also be an object beceause you try to call a method to this specific attribute.
In clear, '.' allow you to only access to an attribute or a function. For exemple
class Square:
def __init__(self, size):
self.size = size
def resize(self, new_size):
self.size = new_size
#Usage
>>> form = Square(5)
>>> print(form.size)
>>> 5 #output
>>> form.resize(120)
>>> print(form.size)
>>> 120 #output
In your code, it's really weird and don't make any sense, many confusion. You are defining a function area inside a function circle, which try to create an area attribute using the Object inexisting self.radius with an existing attribute pi.
Imaginating something like that could work, you're trying to access the function of the function, by calling a method of circle (no sense, hard to explain).
Still in our square, you access an attribute :
>>> form.size
Now you try to call a function from it :
>>> form.size.action()
In this case, you're using an integer method (int are also class containing a method)
By calling an object method :
>>> form.reshape(8) #changing the current size
>>> form.reshape(8).action()
It's calling in this way a method on the reshape's function return.
It seem that's you're not really confident with function definition (two def keyword following each other, it's possible, but not sure that's your goal), import I'm not sure if it have been choose really wisely (numpy will be imported at each object creation, usefull for you ?). Be careful with basics, more you're basic will be stronger, more you will have understand what you're doing, and in programmation, you must know what you're doing.
How do I make s.circle.area(5) work?
At least, you can do
import numpy
class Circle:
def __init__(self, area = 0):
self.area = area
def area(self, new_area):
self.area = new_area
return self.area
class Object:
pi = numpy.pi
circle = Circle()
>>> obj = Object()
>>> obj.circle.area(5)
I finally can do this action ! Many things aren't good practice, or won't have the desired behavior if it's not used wisely, you have to understand what's happening. I understand that's you're learning, and it's really nice, but don't run (and not really fast) without knowing a bit to walk. (I perhaps judge a bit to much sorry, it's for you, be careful)
P.S. : Everything I spoke about here have plenty of documentation. Class definition is really a standart in Python. Object oriented programming without creating object, it could be really paradoxal.
Here some documentation : https://docs.python.org/3.7/tutorial/classes.html#a-first-look-at-classes
object.className.atribute1.attribute1 of attribute1etc. Will definitely go trough the link you've sent