Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!panix!roy From: Roy Smith Newsgroups: comp.lang.python Subject: Re: Encapsulation, inheritance and polymorphism Date: Tue, 17 Jul 2012 09:52:59 -0400 Organization: PANIX Public Access Internet and UNIX, NYC Lines: 23 Message-ID: References: <3vnfd9-343.ln1@satorlaser.homedns.org> <-8SdnVrXGqie25jNnZ2dnUVZ7qKdnZ2d@bt.com> NNTP-Posting-Host: localhost X-Trace: reader1.panix.com 1342533180 11783 127.0.0.1 (17 Jul 2012 13:53:00 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Tue, 17 Jul 2012 13:53:00 +0000 (UTC) User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: csiph.com comp.lang.python:25500 In article <-8SdnVrXGqie25jNnZ2dnUVZ7qKdnZ2d@bt.com>, Lipska the Kat wrote: > I'm not used to using variables without declaring their type If you truly wanted to recreate this type-bondage style of programming in Python, it's easy enough to do. Where you would write in C++: // Type matching will get checked at compile-time void my_function(MassivelyParallelFrobinator& mpf, OtherThing& ot) { blah, blah, blah } you could write in Python: # Type matching will get checked at run-time def my_function(mpf, ot): assert isinstance(mpf, MassivelyParallelFrobinator) assert isinstance(ot, OtherThing) but that's just not the way people write code in Python.