Am 25.09.2012 01:39 schrieb Dwight Hutto:

It's not the simpler solution I'm referring to, it's the fact that if
you're learning, then you should be able to design the built-in, not
just use it.

In some simpler cases you are right here. But the fact that you are able to design it doesn't necessarily mean that you should actually use your self-designed version.

But what you post suggests is important as well: if using the neat fancy built-in simplifications, you should always be aware what overhead they imply.

An example:

    Let l be a big, big list.

    for i in <some source>:
        if i in l: <do something>

This looks neat and simple and doesn't look as expensive as it really is.

If l is converted to a set beforehand, it nearly looks the same, but it is simpler.

So even if you use builtins, be aware what they do.


You don't always know all the built-ins, so the builtin is simpler,
but knowing how to code it yourself is the priority of learning to
code in a higher level language, which should be simpler to the user
of python.

When learning Python, it often happend me to re-inven the wheel. But as soon as I saw the presence of something I re-wrote, I skipped my re-written version and used the built-in.


Thomas
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to