@hygull

Rishikesh Agrawani

rishikesh0014051992@gmail.com

Python developer (Senior)




@gudal

Gudal Sharma

gudal@sjainventures.com

Python developer (Junior)


1. DataFrame, Series, List, pandas, Slicing...

Python - operator overlaoding

#Python2.7, #opeartor-overloading
Please have a look at the problem at https://stackoverflow.com/questions/51625861/concat-list-and-string-in-python.

Note: You have to use operator overloading.

>>> class MyList(list):
...     def __add__(self, string):
...         self = list(self) + list(string)
...         return self
...
>>> l = MyList([9, 5, 6, 3])
>>> l + 'hello'
[9, 5, 6, 3, 'h', 'e', 'l', 'l', 'o']
>>>
>>> l2 = l + 'Python'
>>> l2
[9, 5, 6, 3, 'P', 'y', 't', 'h', 'o', 'n']
>>>
>>> type(l2)

>>>