How to convert a number to binary?
Lyosha
lyoshaM at gmail.com
Fri May 18 03:52:00 EDT 2007
On May 17, 11:10 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
[...]
> > That's way too complicated... Is there any way to convert it to a
> > one- liner so that I can remember it?
>
> You put in a module so you don't *have* to remember it.
>
> Then, you use it in this one-liner:
>
> foo = to_base(15, 2)
>
> Carrying a whole lot of one-liners around in your head is a waste of
> neurons. Neurons are far more valuable than disk space, screen lines,
> or CPU cycles.
While I agree with this general statement, I think remembering a
particular one-liner to convert a number to a binary is more valuable
to my brain than remembering where I placed the module that contains
this function.
I needed the one-liner not to save disk space or screen lines. It's
to save time, should I need to convert to binary when doing silly
little experiments. I would spend more time getting the module
wherever it is I stored it (and rewriting it if it got lost).
It's fun, too.
More information about the Python-list
mailing list