Re: Why keep identity-based equality comparison?

2006-01-14 Thread Noam Raphael
Mike Meyer wrote: > Noam Raphael <[EMAIL PROTECTED]> writes: > >>>>Also note that using the current behaviour, you can't easily >>>>treat objects that do define a meaningful value comparison, by >>>>identity. >>> >>>Yes you

Re: Why keep identity-based equality comparison?

2006-01-14 Thread Noam Raphael
Mike Meyer wrote: > [EMAIL PROTECTED] writes: > >>try: >>return a == b >>except TypeError: >>return a is b > > > This isn't "easy". It's an ugly hack you have to use everytime you > want to iterate through a heterogenous set doing equality tests. I wouldn't define this as an "ugly ha

Re: Using distutils 2.4 for python 2.3

2005-09-23 Thread Noam Raphael
Fredrik Lundh wrote: > > you can enable new metadata fields in older versions by assigning to > the DistributionMetadata structure: > > try: > from distutils.dist import DistributionMetadata > DistributionMetadata.package_data = None > except: > pass > > setup

Using distutils 2.4 for python 2.3

2005-09-23 Thread Noam Raphael
Hello, I want to distribute a package. It's compatible with Python 2.3. Is there a way to use distutils 2.4 feature package_data, while maintaining the distribution compatible with python 2.3 ? Thanks, Noam Raphael -- http://mail.python.org/mailman/listinfo/python-list

Re: How about "pure virtual methods"?

2004-12-31 Thread Noam Raphael
Thanks for your suggestion, but it has several problems which the added class solves: * This is a very long code just to write "you must implement this method". Having a standard way to say that is better. * You can instantiate the base class, which doesn't make sense. * You must use testing to

Re: Non blocking read from stdin on windows.

2004-12-25 Thread Noam Raphael
You can always have a thread which continually reads stdin and stores it in a string, or better, in a cStringIO.StringIO object. Then in the main thread, you can check whether something new has arrived. This, of course will work on all platforms. I hope this helped a bit, Noam -- http://mail.py

Re: How about "pure virtual methods"?

2004-12-25 Thread Noam Raphael
Thank you very much for this answer! I learned from you about unit tests, and you convinced me that "testing oriented programming" is a great way to program. You made me understand that indeed, proper unit testing solves my practical problem - how to make sure that all the methods which should

Re: How about "pure virtual methods"?

2004-12-25 Thread Noam Raphael
Mike Meyer wrote: That's what DbC languages are for. You write the contracts first, then the code to fullfill them. And get exceptions when the implementation doesn't do what the contract claims it does. Can you give me a name of one of them? This is a very interesting thing - I should lea

Re: How about "pure virtual methods"?

2004-12-23 Thread Noam Raphael
Mike Meyer wrote: Noam Raphael <[EMAIL PROTECTED]> writes: The answer is that a subclass is guaranteed to have the same *interface* as the base class. And that's what matters. This is false. For instance: class A(object): def method(self, a): print a class B(A): def method

Re: How about "pure virtual methods"?

2004-12-23 Thread Noam Raphael
Jp Calderone wrote: This lets you avoid duplicate test code as well as easily test new concrete implementations. It's an ideal approach for frameworks which mandate application-level implementations of a particular interface and want to ease the application developer's task. Jp It's a great

Re: How about "pure virtual methods"?

2004-12-21 Thread Noam Raphael
Scott David Daniels wrote: class Abstract(object): '''A class to stick anywhere in an inheritance chain''' __metaclass__ = MustImplement def notimplemented(method): '''A decorator for those who prefer the parameters declared.''' return NotImplemented I just wanted to say that I thou

Re: How about "pure virtual methods"?

2004-12-21 Thread Noam Raphael
Jeff Shannon wrote: Except that unit tests should be written to the *specification*, not the implementation. In other words, forgetting a complete method would require that you forget to write the method, *and* that you failed to translate the specification into unit tests *for that same method

Re: How about "pure virtual methods"?

2004-12-21 Thread Noam Raphael
My long post gives all the philosophy, but I'll give here the short answers. Mike Meyer wrote: +0 Python doesn't use classes for typing. As Alex Martelli puts it, Python uses protocols. So the client expecting a concrete subclass of your abstract class may get an instantiation of a class that doesn

Re: How about "pure virtual methods"?

2004-12-21 Thread Noam Raphael
Steve Holden wrote: Even if you can do it, how would you then implement a class hierarchy where the ultimate base class had virtual methods, and you wanted to derive from that class another class, to be used as a base class for usable classes, which implemented only a subset of the virtual metho

Re: How about "pure virtual methods"?

2004-12-21 Thread Noam Raphael
Thank you all, especially Alex for your enlightening discussion, and Scott for your implementation. I'm sorry that I can't be involved in a daily manner - but I did read all of the posts in this thread. They helped me understand the situation better, and convinced me that indeed this feature is

How about "pure virtual methods"?

2004-12-18 Thread Noam Raphael
a file named filename. """ pass class RealClass(BaseClass): def save_data(self, filename): open(filename).write(self.data) == then if I try to instantiate BaseClass I would get an exception, but instantiating RealClass will be ok.