Lars Yencken l...@yencken.org writes:
I haven't mastered it, but there seems to be an art to testing your type
assumptions early in Python.
The art is: Don't test data type assumptions in the code.
Rather, use EAFP and duck typing, and only test type assumptions in unit
tests.
Duck typing
Hi, Ben, unit test is not the problem.
I have a sorted list. I can put in all numeric or all strs, or any
type that's orderable to all the others:
sorted_list(1, 3, 5.0, 7, 6, 4, 2.0)
[1, 2.0, 3, 4, 5.0, 6, 7]
sorted_list('a', 'c', 'e', 'd', 'b')
['a', 'b', 'c', 'd', 'e']
But if I put in an
devblog.moz.com/2013/08/mozscape-leap-from-c-to-python/
J
___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug
Javier Candeira jav...@candeira.com writes:
I have a sorted list.
What do you mean? Is this a Python builtin list that you have sorted? If
not, where did this ‘sorted_list’ come from?
I can put in all numeric or all strs, or any type that's orderable to
all the others:
sorted_list(1, 3,
Lars Yencken l...@yencken.org writes:
For example, if you are expecting to be passed in a list that you're
going to append to, or some compatible duck type
There's a misunderstanding here. “Duck typing” refers to a *principle*
to be followed in the practice of programming; it is not an