Copy constructor and assignment operator

2018-09-15 Thread Ajay Patel


I have created below code and i want to restrict an object copy.
What are the methods called for copy constructor and assignment operator? 
Basically i don't want to allow below operation.

p = Point(1,3)
p2 = Point(6,7)

=> How to disallow below operations?
p(p2)  
p = p2

Please point out a documentation for the same if available.


class Point:

def _init_(self, x = 0, y = 0):
self.x = x
self.y = y

def _str_(self):
return "({0},{1})".format(self.x,self.y)

def _repr_(self):
return "({0},{1})".format(self.x,self.y)

def _call_(self,other):
print("_call_")
self.x = other.x
self.y = other.y

def _setattr_(self, name, value):
print("_setattr_",name,value)
-- 
https://mail.python.org/mailman/listinfo/python-list


[no subject]

2018-09-16 Thread Ajay Patel


-- 
https://mail.python.org/mailman/listinfo/python-list


Which class method is being called when we declare below expression?

2018-09-27 Thread Ajay Patel
Hello gauys,

Which list class method will call for below codes?

L = [1,2,3]
And
L =[]

Thanks,
Ajay
-- 
https://mail.python.org/mailman/listinfo/python-list