Python vs. C#

Joe Cheng code at joecheng.com
Tue Aug 12 02:03:21 EDT 2003


> > I don't think that "static typing" (Python is strongly typed btw.,
> > just to correct your statement)
>
> It is?  Then I'm confused, because around here people keep talking about
the
> beauty of avoiding types.

Python is "strongly" typed in the sense that every object has a type.  It is
not "statically" typed in that references do not have types.  Statically
typed languages generally require you to declare variable types (some
languages infer them) and in return you get compile-time warnings when you
try to call methods that do not exist or perform casts that are semantically
impossible.

I may be wrong but I believe C is an example of a language with static weak
typing... you have to declare variable types and some types of errors can be
caught at compile time, but you can perform unsafe casts and not only will
the compiler not stop you but at runtime you won't get an exception--just a
possibly corrupted value in memory.

Java and C# have static strong typing.

Python has dynamic strong typing.  So, if you can keep the types of your
objects straight without the help of the compiler, you get the benefits of a
concise syntax while enjoying type safety at runtime.

Someone correct me if I've gotten it wrong...






More information about the Python-list mailing list