Re: super() doesn't get superclass

2007-09-20 Thread Marshall T. Vandegrift
Michele Simionato <[EMAIL PROTECTED]> writes: > I am not against mixins (even if I am certainly very much against the > *abuse* of mixins, such as in Zope 2). What I would advocate (but I > realize that it will never happen in Python) is single inheritance + > mixins a la Ruby. Ruby might be a ba

Re: strings (dollar.cents) into floats

2007-08-30 Thread Marshall T. Vandegrift
luca bertini <[EMAIL PROTECTED]> writes: > i have strings which look like money values (ie 34.45) > is there a way to convert them into float variables? > everytime i try I get this error: "numb = float(my_line) ValueError: > empty string for float()" > " You actually have problems here -- the

Re: list index()

2007-08-30 Thread Marshall T. Vandegrift
[EMAIL PROTECTED] writes: > What's with the index() function of lists throwing an exception on not > found? Let's hope this is rectified in Python 3. If nothing else, add > a function that doesn't throw an exception. There are a million > situations where you can have an item not be in a list and

Re: Short, crazy example: list-derived class, with __iadd__

2007-08-29 Thread Marshall T. Vandegrift
Moon <[EMAIL PROTECTED]> writes: > class Vec(list): > def __init__(self): > list.__init__(self, [0.0, 0.0]) > > def __iadd__(self, other): > assert isinstance(other, Vec) > self[0] += other[0] > self[1] += other[1] > print "right now, v is: ", self,

Re: Code design problem

2007-08-29 Thread Marshall T. Vandegrift
Marco Nawijn <[EMAIL PROTECTED]> writes: > The problem I face is that the implementation of the application class > is completely different for the local and remote case. The local case > is a straightforward implemenation using the subprocess module, the > remote case is a CORBA implementation. S

Re: Class destruction

2007-08-22 Thread Marshall T. Vandegrift
Nils Oliver Kröger <[EMAIL PROTECTED]> writes: > If you want to "reuse" the file, you will have to delete your classes > instance explicitly using the del statement ... this will also call > the destructor. Sometimes, but not always. The `del' statement simple removes the reference to the instan

Re: Encryption and hashing

2007-08-17 Thread Marshall T. Vandegrift
Kless <[EMAIL PROTECTED]> writes: > For who knows any of criptography I comment that you can use > algorithms as secure as Rijndael, Twofish, or Serpent with the CFB > cipher mode. And for hash you can use RIPEMD, SHA-2 or WHIRLPOOL. PyCrypto does includes the AES version of Rijndael as Crypto.Ci

Re: Coroutines and argument tupling

2007-08-16 Thread Marshall T. Vandegrift
Bjoern Schliessmann <[EMAIL PROTECTED]> writes: > The solution I'd use is a decorator that calls next automatically one > time after instantiation. Then you can use send normally, and don't > have to care about any initial parameters, which makes the code > clearer (initial parameters should be us

Re: Coroutines and argument tupling

2007-08-15 Thread Marshall T. Vandegrift
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Do you really need a generator or co-routine to do this? Maybe > you can just use a closure: For my trivial example, sure -- there are lots of ways to do it. Here's a slightly better example: the `read' method of a file-like object which sequent

Re: Coroutines and argument tupling

2007-08-15 Thread Marshall T. Vandegrift
Bjoern Schliessmann <[EMAIL PROTECTED]> writes: >> I'm trying to write a decorator which allows one to produce simple >> coroutines by just writing a function as a generator expression >> which re-receives it's arguments as a tuple from each yield. > > May I ask why? Passing it the same argument

Coroutines and argument tupling

2007-08-15 Thread Marshall T. Vandegrift
Hi, I'm trying to write a decorator which allows one to produce simple coroutines by just writing a function as a generator expression which re-receives it's arguments as a tuple from each yield. For example: @coroutine def nextn(n=1): values = [] for i in itertools.count

Re: encrypting files + filestreams?

2007-08-15 Thread Marshall T. Vandegrift
per9000 <[EMAIL PROTECTED]> writes: > I am trying to figure out the best way to encrypt files in python. Looking at your code and questions, you probably want to pick up a cryptography handbook of some sort (I'd recommend /Practical Cryptography/) and give it a read. > But I have some thoughts a