Re: Adding an interface to existing classes

2012-01-05 Thread Spencer Pearson
(I'm sorry for my delayed response -- I've been travelling and not had reliable Internet access.) On 2011-12-25, Ian Kelly wrote: > On Thu, Dec 22, 2011 at 1:21 AM, Spencer Pearson > wrote: >> I see a problem with this, though. The intersection of two lines is >>

Re: Adding an interface to existing classes

2012-01-05 Thread Spencer Pearson
On Dec 25 2011, 2:58 pm, Terry Reedy wrote: > On 12/24/2011 6:49 PM,SpencerPearsonwrote: > > > On Dec 23, 9:13 am, Terry Reedy  wrote: > >> On 12/22/2011 3:21 AM,SpencerPearsonwrote: > > >>> I'm writing a geometry package, with Points and Lines and Circles and > >>> so on, and eventually I want to

Re: Adding an interface to existing classes

2012-01-05 Thread Spencer Pearson
(I'm sorry for my delayed response -- I've been travelling and not had reliable Internet access.) >> Spencer, i would re-think this entire project from the >> beginning. You are trying to make an object out of everything. You >> don't need to make an object of EVERYTHING. > > Very true. I'm not s

Re: Adding an interface to existing classes

2011-12-24 Thread Spencer Pearson
On Dec 23, 9:13 am, Terry Reedy wrote: > On 12/22/2011 3:21 AM, Spencer Pearson wrote: > > > I'm writing a geometry package, with Points and Lines and Circles and > > so on, and eventually I want to be able to draw these things on the > > screen. I have two options

Adding an interface to existing classes

2011-12-22 Thread Spencer Pearson
I'm writing a geometry package, with Points and Lines and Circles and so on, and eventually I want to be able to draw these things on the screen. I have two options so far for how to accomplish this, but neither of them sits quite right with me, and I'd like the opinion of comp.lang.python's wizene

Instances' __setitem__ methods

2011-06-20 Thread Spencer Pearson
I was recently trying to implement a dict-like object which would do some fancy stuff when it was modified, and found that overriding the __setitem__ method of an instance did not act the way I expected. The help documentation (from help(dict.__setitem__)) claims that "d.__setitem__(k,v)" is equiva

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-08 Thread Spencer Pearson
All right, thank you for helping! I'd had a little voice in the back of my mind nagging me that it might not be logical to include a bunch of classes and function definitions in my startup file, but I never got around to splitting it up. The module/script distinction makes sense, and it seems more

Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Spencer Pearson
Hi! I'm writing a package with several files in it, and I've found that "isinstance" doesn't work the way I expect under certain circumstances. Short example: here are two files. # fileone.py import filetwo class AClass( object ): pass if __name__ == '__main__': a = AClass() filetwo.is_acl

Tuples vs. variable-length argument lists

2010-03-19 Thread Spencer Pearson
Hi! This might be more of a personal-preference question than anything, but here goes: when is it appropriate for a function to take a list or tuple as input, and when should it allow a varying number of arguments? It seems as though the two are always interchangeable. For a simple example... def