Python type() or __class__, == or is

For old-style classes, there is a difference: >>> class X: pass … >>> type(X) <type ‘classobj’> >>> X.__class__ Traceback (most recent call last): File “<stdin>”, line 1, in <module> AttributeError: class X has no attribute ‘__class__’ >>> x = X() >>> x.__class__ <class __main__.X at 0x171b5d50> >>> type(x) <type ‘instance’> The point of new-style classes … Read more

What’s the difference between a hash and hash reference in Perl?

A simple hash is close to an array. Their initializations even look similar. First the array: @last_name = ( “Ward”, “Cleaver”, “Fred”, “Flintstone”, “Archie”, “Bunker” ); Now let’s represent the same information with a hash (aka associative array): %last_name = ( “Ward”, “Cleaver”, “Fred”, “Flintstone”, “Archie”, “Bunker” ); Although they have the same name, the … Read more

Will a future version of .NET support tuples in C#?

I’ve just read this article from the MSDN Magazine: Building Tuple Here are excerpts: The upcoming 4.0 release of Microsoft .NET Framework introduces a new type called System.Tuple. System.Tuple is a fixed-size collection of heterogeneously typed data.       Like an array, a tuple has a fixed size that can’t be changed once it … Read more