Access to variable from external imported module

jim-on-linux inq1ltd at verizon.net
Thu Nov 23 18:37:37 EST 2006



GinTon,

I think this is what you want.


class Kdoi:
   def __init__(self) :    
       self.Fdo()

   def Fdo(self):

     searchterm = 'help'
     print searchterm     #local 

     self.searchterm = searchterm
     print self.searchterm #used inside the class

     Kdo.searchterm = searchterm   #<<<<
     print Kdo.searchterm #used outside the class
     Kdomore()


    
class Kdomore(Kdo):
     def __init__(self) :    
         self.Fdomore()

     def Fdomore(self):
         searchterm =  Kdo.searchterm   # <<<<
         print searchterm    



jim-on-linux
http://www.inqvista.com








On Thursday 23 November 2006 17:09, GinTon wrote:
> Sorry, I mean access to local variable from a
> method
>
> import module
> method(value)
>
> I would to access to values that are created
> locally in that method
>
> Fredrik Lundh ha escrito:
> > GinTon wrote:
> > > How to access to a variable (that value is
> > > not returned) from a module imported?
> > > And the variable is set at the
> > > module-level.
> >
> >    import module
> >    print module.variable
> >
> > (have you read the Python tutorial?)
> >
> > </F>



More information about the Python-list mailing list