Re: Difference between 'is' and '=='

2006-03-27 Thread Clemens Hepper
Dan Sommers wrote: > This does *not* also mean constants and such: > > Python 2.4.2 (#1, Feb 22 2006, 08:02:53) > [GCC 4.0.1 (Apple Computer, Inc. build 5247)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> a = 123456789 > >>> a == 123

Re: Difference between 'is' and '=='

2006-03-27 Thread Clemens Hepper
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > Joel Hedlund <[EMAIL PROTECTED]> wrote: > >> Which means that "is" comparisons in general will be faster than == >> comparisons. > > I thought that == automatically compared identify before trying to compare > the values. Or am I thinking o

Re: a problem to solve

2006-03-26 Thread Clemens Hepper
Hi, [EMAIL PROTECTED] wrote: > That's one way to do it. I did it that way because I have the > hex patterns memorized. You should be able to generate your numbers like this: number = int('001001000100100', 2) mfg - eth -- http://mail.python.org/mailman/listinfo/python-list

Re: Bitwise OR?

2006-03-26 Thread Clemens Hepper
Okay... pythons build-in methods are quite fast. so is hex(). with about 64 kb memory i can write it with a 16 bit dictionary where the dictionary generation itself is not yet optimized: def genBitList(exp): next = lambda now: [x+'0' for x in now]+[x+'1' for x in now] result = [""] for x i

Re: Bitwise OR?

2006-03-26 Thread Clemens Hepper
Adam DePrince wrote: >> BTW: Is there something like a sizeof() method for int numbers? > > import struct > help( strict.calcsize ) Mh, that doesn't do what i want. I'd like to have something like: def size(number): return sizeof(number) > Why one bit at a time? Good question... Here my new

Re: Bitwise OR?

2006-03-24 Thread Clemens Hepper
Hello, I've written a little (optimized) method to get a bit-string: def bitstringneg(number, digits=32): """optimized for negative numbers""" result = "" for a in xrange(digits): if number & 1: result += '1' else: result += '0' number >>= 1 return result def bits

Re: Bitwise OR?

2006-03-24 Thread Clemens Hepper
To look at the bit-structure i've implemented a little function: def bitstring(number, digits=32): """lsb-->msb""" result = "" for a in xrange(digits): if number & 1: result += '1' else: result += '0' number >>= 1 return result I wonder if there is something lik

Re: read/ edit line from stdin

2006-03-10 Thread Clemens Hepper
if nothing is typed 'www.gentoo.org' should be used. I just thought that extending the commandline input interface would be quite useful. I want a text field that can be edited like common GUI-TextFields on command line... mfg - eth James Stroud wrote: > Clemens Hepper

read/ edit line from stdin

2006-03-10 Thread Clemens Hepper
Hello, for my project confux (http://confux.sourceforge.net) I want to read a line from stdin. But I don't want the user to type a new line. I want so display a value which the user can edit. For example I want to ask the user for a hostname and I print "localhost", the user modified it to "locals