The duck-typing tag has no wiki summary.
2
votes
1answer
107 views
How should I distinguish between built-in types in Python?
I have a function that accepts either a string or a dictionary as an argument. That is, it can be called as either:
lookup_person({name: "John Smith", age: 57})
or
lookup_person("John Smith")
My ...
1
vote
1answer
172 views
How does Django turn field name strings to field name variables?
I'm very new to python and (coming from Java) am trying to think in a "pythonic" way. I'm having trouble understanding how Django turns a function (or variable) name given in string to the actual ...
23
votes
3answers
1k views
Python Forgiveness vs. Permission and Duck Typing
In Python, I often hear that it is better to "beg forgiveness" (exception catching) instead of "ask permission" (type/condition checking). In regards to enforcing duck typing in Python, is this
try:
...
4
votes
1answer
578 views
implicit vs explicit interfaces
I think I understand the actual limitations of compile-time polymorphism and run-time polymorphism. But what are the conceptual differences between explicit interfaces (run-time polymorphism. ie ...
3
votes
5answers
664 views
Are design patterns independent of programming languages?
I have been recently working on Objective C and came across use of Delegate pattern.
I had seen all the patterns theoretically in Java, thanks to the Head First book.
But at times looking at ...
11
votes
5answers
634 views
Is duck typing a subset of polymorphism
From Polymorphism on WIkipedia
In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface.
From duck ...
24
votes
12answers
5k views
Why does PHP have interfaces?
I noticed that as of PHP5, interfaces have been added to the language. However, since PHP is so loosely typed, it seems that most of the benefits of using interfaces is lost. Why is this included in ...