Dumb python questions
Paul Rubin
phr-n2001 at nightsong.com
Sat Aug 18 15:43:29 EDT 2001
m.faassen at vet.uu.nl (Martijn Faassen) writes:
> > I think I'm reacting not as much to language differences as to
> > differences in system maturity. Whenever I write something in Perl or
> > CL, and I need to do something like turn an array into a string,
>
> Do you mean a Python list? ''.join(mylist)
No I mean a list of character values, like (97,98,99) => "abc".
> > somebody seems to have faced that problem before and it's been taken
> > care of in some reasonably thought-out way. In Python, I often feel
> > like I'm doing something that hasn't been done much before.
>
> In part I suspect that's due to your inexperience with the language, but
> please keep pointing out the things that are missing. :)
Here's one: say I have a long int, like x = 7**77777L. How can I tell
how many bits it takes to express that number in binary? How can I
convert it into a packed character string (i.e. represent it in string
form with 8 bits/char so I can write it to a file)? The answers I can
think of involve weird kludges and/or are unacceptably slow.
Thanks.
More information about the Python-list
mailing list