Basic Python Query

chandan kumar chandan_psr at yahoo.co.in
Thu Aug 22 03:53:57 EDT 2013


Hi all,

Sorry for not explaining question properly.Here Its not about threading and dont worry about any indentations.Please see below example

class Call_Constructor():
    def __init__(self):
        print "In __init__ "
       
class Test_Constructor(Call_Constructor):  
    def method(self):
       print " In Test_Constructor Class"
    
  ConstructInstance = Test_Constructor()
  
When an instace is created for Test_Constructor class ,The code flows starts __init__ in Call_Constructor class.Whys is it like that.


class Call_Constructor():
    def __init__(self):
        print "In __init__ "
       

class Test_Constructor(Call_Constructor):  
    def  __init__(self):
       print " In Test_Constructor Class"
    
  ConstructInstance = Test_Constructor()

But for the above case Code flows starts from Test_Constructor().

Whats is the difference for both cases described above.

Best Regards,
Chandan.
--------------------------------------------
On Thu, 22/8/13, Johannes Bauer <dfnsonfsduifb at gmx.de> wrote:

 Subject: Re: Basic Python Query
 To: python-list at python.org
 Date: Thursday, 22 August, 2013, 12:28 AM
 
 On 21.08.2013 11:11, Ulrich Eckhardt
 wrote:
 
 > That said, there is never a need for deriving
 > from the Thread class, you can also use it to run a
 function without
 > that. That way is IMHO clearer because the
 threading.Thread instance is
 > not the thread, just like a File instance is not a
 file. Both just
 > represent handles for manipulating the actual thing.
 
 Huh? That I find most curious.
 
 I *always* derive from threading.Thread and really like the
 way that
 thread setup works (instanciate Thread handle, call start).
 Very
 intuitive, never had the problems with clarity that you
 mentioned. Could
 you elaborate on your suggestion? I don't seem to quite get
 it I'm afraid.
 
 Best regards,
 Johannes
 
 -- 
 >> Wo hattest Du das Beben nochmal GENAU
 vorhergesagt?
 > Zumindest nicht öffentlich!
 Ah, der neueste und bis heute genialste Streich unsere
 großen
 Kosmologen: Die Geheim-Vorhersage.
  - Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$1 at speranza.aioe.org>
 -- 
 http://mail.python.org/mailman/listinfo/python-list
 



More information about the Python-list mailing list