A Universe Set

2006-10-03 Thread jordan . nick
Has the addition of a Universe Set object ever been suggested.  Like U
= set(0), so that any object was a member of U?  Maybe this gets into
some crazy Cantorian stuff since U is in U.  But it seems like it would
be useful and would have a nice symmetry with emptyset:set([]), that
is:

for any object a:
a in set([]) returns False
a in set(0) returns True

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need help with syntax on inheritance.

2006-10-03 Thread jordan . nick

SpreadTooThin wrote:
 If you are deriving a new class from another class,
 that you must (I assume) know the initializer of the other class.

 So in myClass

 import array
 class myClass(arrary.array):
def __init__(self, now here I need to put array's constructor
 parameters..., then mine):
   array.array.__init__(self, typecode[, initializer])
   self.mine = mine

 So I'm confused...
 array has a typecode parameter and an optional initiializer...
 So could you help me with the class construction here please?

Lookup *args and **kargs in the python reference manual.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using names before they're defined

2006-07-19 Thread jordan . nick

Steve Holden wrote:
 [EMAIL PROTECTED] wrote:
  I have a problem. I'm writing a simulation program with a number of
  mechanical components represented as objects. When I create instances
  of objects, I need to reference (link) each object to the objects
  upstream and downstream of it, i.e.
 
  supply = supply()
  compressor = compressor(downstream=combustor, upstream=supply)
  combuster = combuster(downstream=turbine, upstream=compressor)
  etc.
 
  the problem with this is that I reference 'combustor' before is it
  created. If I swap the 2nd and 3rd lines I get the same problem
  (compressor is referenced before creation).
 
 
  aargh!!! any ideas on getting around this?
 
 Yes. You are building a generic data structure, so you shouldn't really
 be trying to store individual objects in variables like that. You need a
 data structure that's appropriate to your problem.

 For example, you could consider storing them in a list, so you have

 components = [supply(), compressor(), combuster()]

 Then components[n] is upstream of components[n-1] and downstream of
 components[n+1].

Unfortunately, if he wanted to make the topology more complicated, for
instance having two components downstream, it would be much more
cumbersome to inherit the list object and implement this.

 In short, your thinking about data representation might need to become a
 little more sophisticated.

That sounds a little arrogant. sorry!

 regards
   Steve
 --
 Steve Holden   +44 150 684 7255  +1 800 494 3119
 Holden Web LLC/Ltd  http://www.holdenweb.com
 Skype: holdenweb   http://holdenweb.blogspot.com
 Recent Ramblings http://del.icio.us/steve.holden

-- 
http://mail.python.org/mailman/listinfo/python-list