Two minor questions on Class

joy99 subhakolkata1234 at gmail.com
Fri Jul 30 13:23:44 EDT 2010


Dear Group,

Hope everyone is fine.

I was trying some examples of Python class.
I took the following example from Ubuntu forum[http://ubuntuforums.org/
showthread.php?t=578930]
class Person(object):
	def _init_(self,name,age):
		self.name=name
		self.age=age

as i wrote the code using IDLE on WinXP SP2, with Python2.6.5, I am
getting the following error:

>>> p=Person('Subha',40)

Traceback (most recent call last):
  File "<pyshell#120>", line 1, in <module>
    p=Person('Subha',40)
TypeError: object.__new__() takes no parameters

My question is, why the error is coming? Any problem in writing it?
Can arguments be passed to class (other than inheritance) directly
like this?

As I was practising some early examples on class, does Python exist
with any built in class, like the rich library of built in functions?
Any good URL to learn examples?

If any one can help, I would be grateful. As I pasted the code from
GUI to notepad, there may be slight indentation problem, sorry for the
same.

Thanks in advance,
Best Regards,
Subhabrata.



More information about the Python-list mailing list