definition of 'polymorphism' and python
bruno at modulix
onurb at xiludom.gro
Thu Dec 15 20:04:36 CET 2005
Gabriel Zachmann wrote:
> I understand the Wikipedia article on Polymorphism
> ( http://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29 )
> that it doesn't make sense to talk about polymorphism in a fully
> dynamically typed language
"a single polymorphic operator can act in expressions of various types"
>>> list1 = [1,2,3]
>>> list2 = [4,5,6]
>>> list1 + list2
[1, 2, 3, 4, 5, 6]
>>> int1 = 1
>>> int2 = 2
>>> int1 + int2
>>> str1 = "aaa"
>>> strb = "bbb"
>>> str1 + strb
Ok, so we have polymorphic operators (if that wasn't obvious)
"A function that can evaluate to and be applied to values of different
types is known as a polymorphic function."
Ok, so we have polymorphic functions too (if that wasn't obvious...)
"If all code is written without mention of any specific type and thus
can be used transparently with any number of new types, it is called
Well, seems that's what we (mostly) have
-- does the Python community agree?
I'm not the Python communauty, but I think you already guessed my answer !-)
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list