Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

any python experts out there?



Hi Martin,

Here's my issue...

I'm a C++ programmer and the way I like to write my OO code is to put 
each class into its own text file, naming the file after the class name 
and then bundle them all into a lib.so file. I want to do the same with 
python by creating a package which I can use the import statement to 
gain access to the python classes. The problem I get is in the python 
name space. Basically, if I create a file called A.py which contains 
class A, and I put it into a "package directory" mypackage, then to 
access my class I have to write the following code snippit..

import mypackage
AObj=mypackage.A.A()

Thus my object AObj is now of type A, but the name space is uggly. (i.e. 
there is an extra .A in the name space.) How do I avoid this? Or rather, 
can I not put one class per file, and naming the file after the class? 
Should I put all my classes in one large text file? I prefer not to have 
all the code in one big long file...

Thanks Martin.

Cheers. Steve.


Martin Owens wrote:
> You've come to the right place, I offer python training to free
> software programmers.
>
> what's your problem?
>
> Best Regards, Martin Owens
>
> On 13/05/07, Stephen Adler <adler-wRvlPVLobi1/31tCrMuHxg at public.gmane.org> wrote:
>> Hey guys,
>>
>> Any python experts out there? I'm learning python and I'm trying to get
>> something about python name spaces right...
>>
>> Cheers. Steve.
>>
>>
>> -- 
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>> _______________________________________________
>> Discuss mailing list
>> Discuss-mNDKBlG2WHs at public.gmane.org
>> http://lists.blu.org/mailman/listinfo/discuss
>>
>


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.







BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org