Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

class design - Foward declaration of classes in Python -


the following program can run successfully:

class simple(object):     def __init__(self, name):       self.name = name      def __add__(self, other):       c = composite()       c._members.append(self)       c._members.append(other)       return c      def __repr__(self):       return "simple('%s')" % self.name  class composite(object):     def __init__(self):       self._members = []      def __add__(self, obj):       if isinstance(obj, simple):         out = composite()         out._members = [k k in self._members] + [obj]       elif isinstance(obj, composite):         out = composite()         out._members = [k k in self._members + obj._members]       else:         raise typeerror       return out  if __name__ == "__main__":     s1 = simple('one')     s2 = simple('two')     s3 = simple('three')     c1 = s1 + s2     c2 = c1 + s3     print c1._members     print c2._members     # output:     # [simple('one'), simple('two')]     # [simple('one'), simple('two'), simple('three')] 

i keep definition of simple, composite, , __main__ in 3 different files, cannot because cannot import simple composite.py , cannot import composite simple.py.

how modify class definition such can keep separate files?

thank you.

ps. i've read several answers related "forward declaration" not find answer specific problem.

since none of references needed until methods called, circular imports can work here. trick use fully-qualified references.

import composite  class simple(object):    ...   def __add__(self, other):     c = composite.composite()     c._members.append(self)     c._members.append(other)     return c 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -