4
votes
2answers
229 views

Should duck typing affect naming conventions?

I'm a C++/C# developer and recently I've started to learn Python. I think I understand the concept of duck typing right now except for one thing. When I'm coding in C++ or C# I sometimes create ...
7
votes
1answer
750 views

Duck typing, data validation and assertive programming in Python

About duck typing: Duck typing is aided by habitually not testing for the type of arguments in method and function bodies, relying on documentation, clear code and testing to ensure correct use. ...
2
votes
1answer
161 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
837 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 ...
30
votes
3answers
2k 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: ...