My friend Valentino has posted on his blog about a sample of code with C# and generics and he rewrote the sample in Python
Here the samples:
C# 2.0:
List integers = new List();
for(int i=1; i< =10; i++) integers.Add(i);
int sum;
integers.ForEach(delegate(int i){ sum+=i; });
vs
Python (basically any version):
sum([x for x in xrange(11)])
Generics are cool, but Python is cooler
Related posts
Anonymous said,
I hate to say it, but this works only in Python 2.3 or higher. In Python 2.2 and below you get “NameError: name ’sum’ is not defined”. Still, Python’s cooler.
RSS feed for comments on this post · TrackBack URI

