Python vs. C#
Brian Quinlan
brian at sweetapp.com
Sun Aug 10 01:51:44 EDT 2003
> 4. forcing everything into a class is stupid e.g. does anyone really
> > like writing Math.sin(x) over sin(x)?
>
> Although tacky at first glance, it's not entirely stupid. I've
written
> many, many variations on sin(x) cos(x) because one often wants an
> efficient approximation for some algorithmically specific purpose.
They
> all end up with slightly funny different names, so why not namespace
'em?
Sure, putting everything in a namespace makes sense and, in C#,
everything must be in a namespace (in .NET, Math is in the System
namespace). So why force two levels of namespacing? You could have:
System.sin() AND
TableTrig.sin() AND
CORDIC.sin()
That is unambiguous without adding the extra level of indirection
through a class name. The Python system is even more flexible:
import math
math.sin(1.0)
OR:
from math import sin
sin(1.0)
OR:
from math import sin as msin
from CORDIC import sin as csin
import TableTrig
msin(1.0)
csin(1.0)
TableTrig.sin(1.0)
> And IIUC, you could simply write
>
> using Math
>
> and be done with the issue, I think.
Nope. The using statement is for namespaces not classes.
Cheers,
Brian
More information about the Python-list
mailing list