Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

a question about python

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


calidion at gmail

Nov 26, 2009, 1:21 AM

Post #1 of 3 (172 views)
Permalink
a question about python

hi,
i have a question on python programming.

let file a.py has a class named a,
class a():
__G__ = "1111"

in file b.py i need to insert an attribute __C__ to class a

it would be as if class a defined in file a.py like this:
class a():
__G__ = "1111"
__C__ = "22222"

how this be done in python without inheritance?
--
http://mail.python.org/mailman/listinfo/python-list


steve at REMOVE-THIS-cybersource

Nov 26, 2009, 1:45 AM

Post #2 of 3 (173 views)
Permalink
Re: a question about python [In reply to]

On Thu, 26 Nov 2009 01:21:39 -0800, 李白,字一日 wrote:

> hi,
> i have a question on python programming.
>
> let file a.py has a class named a,
> class a():
> __G__ = "1111"


Methods with double leading and trailing underscores are reserved for
Python's special use. You should find a different naming convention.


> in file b.py i need to insert an attribute __C__ to class a
>
> it would be as if class a defined in file a.py like this:
> class a():
> __G__ = "1111"
> __C__ = "22222"
>
> how this be done in python without inheritance?


import a
a.a.__C__ = "22222"



--
Steven
--
http://mail.python.org/mailman/listinfo/python-list


calidion at gmail

Nov 26, 2009, 1:57 AM

Post #3 of 3 (166 views)
Permalink
Re: a question about python [In reply to]

thanks.

On Nov 26, 5:45 pm, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.au> wrote:
> On Thu, 26 Nov 2009 01:21:39 -0800, 李白,字一日 wrote:
> > hi,
> > i have a question on python programming.
>
> > let file a.py has a class named a,
> >   class a():
> >     __G__ = "1111"
>
> Methods with double leading and trailing underscores are reserved for
> Python's special use. You should find a different naming convention.
>
> > in file b.py i need to insert an attribute __C__ to class a
>
> > it would be as if class a defined in file a.py like this:
> >   class a():
> >     __G__ = "1111"
> >     __C__ = "22222"
>
> > how this be done in python without inheritance?
>
> import a
> a.a.__C__ = "22222"
>
> --
> Steven

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.