How to convert a number to binary?
Ben Finney
bignose+hates-spam at benfinney.id.au
Fri May 18 02:10:25 EDT 2007
Lyosha <lyoshaM at gmail.com> writes:
> On May 17, 4:40 pm, Michael Bentley <mich... at jedimindworks.com> wrote:
> > On May 17, 2007, at 6:33 PM, Lyosha wrote:
> > > Is there an *easy* way to convert a number to binary?
> >
> > def to_base(number, base):
> > [function definition]
> >
> > Hope this helps,
> > Michael
>
> 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.
--
\ "Quidquid latine dictum sit, altum viditur." ("Whatever is |
`\ said in Latin, sounds profound.") -- Anonymous |
_o__) |
Ben Finney
More information about the Python-list
mailing list