Re: int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)

2007-09-15 Thread Boris Dušek
On Sep 15, 1:59 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > So you are looking for the `struct` module in the standard library instead > of doing this yourself. :-) > > If you insist on doing it yourself take a look at the built-in `ord()` > function. > Thanks Marc, both things are

int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)

2007-09-15 Thread Boris Dušek
+= int(byte) * factor factor *= 2**8 Could you please tell me how to achieve what I want in Python? (it would be straightforward in C) Thanks for any suggestions, Boris Dušek -- http://mail.python.org/mailman/listinfo/python-list

Base class for file-like objects? (a.k.a "Stream" in Java)

2007-07-24 Thread Boris Dušek
some base class to "file"-like (or "stream"-like) objects in Python? And if not, is it at least planned for Python 3.0? Thanks for any suggestions, Boris Dušek P.S.: The code should finally look in esence something like this: if isinstance(f, file): pass elif isinstance(f, string): f = urllib.urlopen(f) else: raise "..." process_stream(f) -- http://mail.python.org/mailman/listinfo/python-list

Re: Significance of "start" parameter to string method "endswith"

2007-04-19 Thread Boris Dušek
On Apr 19, 10:36 pm, subscriber123 <[EMAIL PROTECTED]> wrote: > On Apr 19, 3:58 pm, Boris Dušek <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > what is the use-case of parameter "start" in string's "endswith" > > method? &g

Significance of "start" parameter to string method "endswith"

2007-04-19 Thread Boris Dušek
Hello, what is the use-case of parameter "start" in string's "endswith" method? Consider the following minimal example: a = "testing" suffix="ing" a.endswith(suffix, 2) Significance of "end" is obvious. But not so for "start". Let's assume the "end" parameter is not used - then the function sho