Python vs. C#

Simon Bayling sfb at alysseum.com
Sun Aug 10 13:28:01 EDT 2003


The interactive interpreter.
>>> for i in range(10):
        print i, i**i

Allows for some very quick testing and exploring, even moreso when 
combined with dir(object).

Tuples.
>>> def minmax(L):
        return min(L), max(L)
>>>
>>> a, b = test([4,3,1,2])
>>> a, b
(1, 4)
>>> test("bca")
('a', 'c')

A quick way to return multiple values from a function without needing to 
use 'out' or explicitly put everything into an arraylist and take it out 
again.

Lowered finger-typing - minmax() works on lists, tuples, and strings 
without needing to make:
  minmax(string s)
  minmax(list l)
  minmax(tuple t)

overloads.

Mixed type collections.
>>> L = []    # make an empty list
>>> L.append("1")
>>> L.append(1)
>>> for item in L:
        print type(item)

<type 'str'>
<type 'int'>

In C#, (I think), everything that goes into a collection is cast to 
object, and when it comes out you have to know what type you are 
expecting and cast it back.

Nothing amazing to beat C# with, just some nice points, like C# has very 
good database interfacing and (x ? a:b) support...

Cheers,
Simon.

"Brandon J. Van Every" <vanevery at 3DProgrammer.com> wrote in
news:3f357a9b at shknews01: 

> So again my question is, language-wise, what can I get done with
> Python that I can't get done with C#?  What is easy to express in
> Python, that is tedious, difficult, or impossible to express in C#?
 





More information about the Python-list mailing list