Problem with importing in Python

Adnan Sadzak sadzak at gmail.com
Fri Jan 11 23:25:24 CET 2013


Python is case sensitive.
Circle and circle is not same.




/* sent from android */
On Jan 11, 2013 11:22 PM, "su29090" <129km09 at gmail.com> wrote:

> I'm trying to import a python file it keeps saying:
>
> ImportError: cannot import name Circle
>
> Here is the file I'm trying to import:
>
> Circle.py
>
> import math
>
> class circle:
>     #Construct a circle object
>     def __init__(self, radius = 1):
>         self.radius = radius
>
>     def getPerimeter(self):
>         return 2 * self.radius * math.pi
>
>     def getArea(self):
>         return self.radius * self.radius * math.pi
>
>     def setRadius(self, radius):
>         self.radius = radius
>
> from Circle import Circle
>
> def main():
>     #Create a circle with a radius 1
>     circle1 = Circle()
>     print("The area of the circle of radius",
>           circle1.radius, "is" , circle1.getArea())
>
>     #Create a circle with a radius 25
>     circle2 = Circle(25)
>     print("The area of the circle of radius",
>           circle2.radius, "is" , circle2.getArea())
>
>     #Create a circle with a radius 125
>     circle3 = Circle(125)
>     print("The area of the circle of radius",
>           circle3.radius, "is" , circle3.getArea())
>
>     #Modify circle radius
>     circle2.radius = 100 # or Circle2.setRadius(100)
>     print("The area of the circle of radius",
>           circle2.radius, "is" , circle2.getArea())
>
>     main() # Call the main function
>
> How can I solve this problem?
>
> Thanks in advance.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130111/4276f9f8/attachment.html>


More information about the Python-list mailing list