On 11/16/2014 2:57 AM, Garrett Berg wrote:
(how often have you iterated over a string?)
Often enough, but perhaps more often have written functions for which a
string is as valid an input as many other iterables.
def cross(iterable, reiterable):
for a in iterable:
for b in reiter
Garrett Berg wrote:
> I have been working with python for a few years now, and two of my
> favorite features about it are iterators and duck typing. The fact that
> every iterator under the sun can be accessed with a simple for loop is one
> of the most amazing features of python.
>
> However, th
Garrett Berg writes:
> However, there are times when I want to do type checking, and the
> builtin function *isinstance* is of great use.
I would advise that when you think you want type checking, you are
probably being overly restrictive.
> However, this function fails to be satisfactory in re
On Sun, Nov 16, 2014 at 6:57 PM, Garrett Berg wrote:
> However, there are times when I want to do type checking, and the builtin
> function isinstance is of great use. However, this function fails to be
> satisfactory in returning whether the object is a valid iterator. The call
> hasattr(obj, '__
I have been working with python for a few years now, and two of my favorite
features about it are iterators and duck typing. The fact that every
iterator under the sun can be accessed with a simple for loop is one of the
most amazing features of python.
However, there are times when I want to do t