Need to convert an arbitrary byte-pair to an int.
aleax at aleax.it
Thu Aug 7 17:12:41 CEST 2003
Graham Nicholls wrote:
>> So, in this
>> specific case, would the array module. Both struct and array are part
>> of the standard Python library and often come in handy for occasional
>> needs of low-level access, such as this.
> Trouble is, you don't know what you don't know, and my python library
> reference is at home, and I'm onsite.
The python library reference is also online -- see for example
http://www.python.org/doc/current/lib/lib.html -- and if one happens
to prefer "Python in a Nutshell", why, THAT one is too (on O'Reilly's
"safari" service -- however, after some weeks' worth of free trial, if
you want to continue accessing "safari" you'd have to subscribe to it).
> them, would be useful. Python seems to have more modules, and I do like
> lots of things about it, but Ruby _seems_ cleaner, somehow. Its an
Interesting. I'm also trying to learn Ruby in my copious spare time
and don't really see that "clean-ness" (all of those 'end' terminators
of block, how are they "cleaner" than the lack thereof in Python? How
is it "cleaner" to have regular expressions deeply mixed in the
innards of the language rather than cleanly separated into their own
library modules? Etc, etc). I _do_ see that Ruby provides more scope
for tinkering, because it lets me play with the way operations on
built-in types work -- so if I want e.g. 2+2 to evaluate to 5, I can
(or more seriously, I can perform presumably-useful modifications to
other special methods of built-in types). But I think the same key
difference that makes Ruby better for tinkering -- the total fluidity
and dinamicity of just about everything, with no "fixed posts" for
the behavior of built-in types -- may make it less suitable for the
programming of large, multi-developers, indeed multi-team application
programs. Python is highly dynamic but draws the line at modifying
behavior of built-in types; Ruby draws no such line, and thus it is
even more dynamic. To me, on the basis of my understanding of both
languages so far, THAT is the one _crucial_ language difference (the
_libraries_ may differ more broadly, but that's secondary and even
easily remedied -- the languages' philosophy regarding such dynamic
possibilities, however, are far less likely to ever change).
Other more specific tradeoffs, such as Ruby's _mutable_ strings (which
I mostly dislike, but may sometimes help performance) or the very
different style of iterators in the two languages (in Ruby you pass a
code block into the iterator, while in Python you get values out of
the iterator one by one -- so, for example, stepping over more than
one iterator in a controlled way is far easier in Python, while
other tasks are easier in Ruby -- I think, overall, the power of
the very iterators in the two languages may be very similar, with a
tiny edge to Ruby, while the simplicity and syntax cleanliness of
coding is IMHO a substantial edge to Python) -- all of these can be
discussed point by point, of course.
Still, I agree that both languages are quite good. If Python did
not exist, I believe I would most probably be using Ruby, myself.
More information about the Python-list