No subject

Andreas Kostyrka andreas at kostyrka.org
Fri Jul 1 12:33:08 EDT 2005


import os as realos

Names are nothing magic in Python, and quite easily manipulated:

import os

os.write(1, "Hello World!")

class os:
    pass

o = os()

import os

os.write(1, "\n")

So basically this kind of name clashes usually do not happen in Python.


Or another usage:

os = SomeObject()

def function_that_needs_real_os():
    import os
    print os.getuid()

Am Freitag, den 01.07.2005, 15:38 +0200 schrieb Adriaan Renting:
> Adriaan Renting        | Email: renting at astron.nl
> ASTRON                 | Phone: +31 521 595 217
> P.O. Box 2             | GSM:   +31 6 24 25 17 28
> NL-7990 AA Dwingeloo   | FAX:   +31 521 597 332
> The Netherlands        | Web: http://www.astron.nl/~renting/
> >>> Tom Anderson <twic at urchin.earth.li> 07/01/05 2:50 PM >>>
> >On Fri, 1 Jul 2005, Adriaan Renting wrote:
> >> I'm not a very experienced Python programmer yet, so I might be 
> >> mistaken, but there are a few things that would make me prefer C++
> over 
> >> Python for large (over 500.000 LOC) projects.
> >
> >Hmm. I don't know C++, but here goes ...
> >
> >> - namespaces
> >
> >Aren't namespaces basically the same as packages/modules in python?
> >
> Not in the way C++ uses them. In Python if would be something like this:
> ---------------------------
> import os
> using namespace casa
> class os:
>     def open(self, file):
>         pass
> a = os.open('something')
> b = std::os.open('something')
> using namespace std
> c = casa::os.open('something')
> d = os.open('something')
> ---------------------------
> This is a realy stupid example. It's essentially an extra hierarchy
> layer to avoid naming clashes. I don't know of a way to do this in
> Python, how would you do this?
> 
> >> - templates
> >
> >These would be meaningless in python - they're part of typefulness,
> which ...
> >
> >> - strong type checking
> >
> >
> >Not that this is necessarily a good thing. I have to say that my Java 
> >roots do lead me to think that strong typing is a plus for big
> projects, 
> >since it's a way of defining and enforcing interfaces between bits of
> code 
> >written by different people (or by one person at different times!). 
> >Optional static typing in python would be nice for this.
> >
> Exactly what I my point is, see also my other post on this (the LOC
> post)
> 
> >> - data hiding
> >
> >Surely you can hide data in python?
> >
> Again, how? Is there a way to force that an external user of my lib can
> not use my internal data/methods/classes, unless he uses odd compiler
> hacks?
> 
> >> - more available libraries and more advanced developement tools.
> >
> >True. The more advanced development tools are offset to a large degree
> by 
> >the advanced crappiness of C++ as a language, though; i'd be surprised
> if 
> >a C++ programmer borged up with all the latest tools was actually more 
> >productive than a python programmer with a syntax-colouring, 
> >auto-indenting text editor. It'd be very interesting to get some real 
> >numbers on that.
> >
> I think my point is: I would be, for large projects. Just comparing my
> Borland C++Builder experience with my Eric3+QtDesigner experience. This
> is not only because of differences between C++ and Python though, a good
> IDE alone can make 50% difference but that's another subject.
> For small simple projects where I am familiar with the libs I need, I
> think I'd prefer Python.
> 
> >>> Ultimately, manageability of a project is far and away more about
> the
> >>> people involved and the techniques used than it is about any single
> >>> technology involved.
> >>
> >> Agreed.
> >
> >+1 getting to the crux of it.
> >
> Thank you
> 
> >tom
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://mail.python.org/pipermail/python-list/attachments/20050701/790c26e1/attachment.sig>


More information about the Python-list mailing list