Jim Qiu wrote:
Hi everyone.
I am reading a python library code and found something i can not understand.
Please help!
class Envelope(object):
def __init__(self,ta_info):
self.ta_info = ta_info
def writefilelist(self,ta_list,tofile):
for filename in ta_list:
fromfile = botslib.botsopendata(filename,
'rb',self.ta_info['charset'])
shutil.copyfileobj(fromfile,tofile)
fromfile.close()
def convertfilelist(self,ta_list):
return [botslib.botsgetabspathdata(filename) for filename in
ta_list]
class myxmlenvelop(Envelope):
def __init__(self,ta_info,ta_list):
''' class for (test) xml envelope. There is no standardised
XML-envelope!
writes a new XML-tree; uses places-holders for XML-files to
include; real enveloping is done by ElementTree's include'''
self.ta_info = ta_info
self._openoutenvelope()
#~ self.out.put({'BOTSID':'root','xmlns:xi':"
http://www.w3.org/2001/XInclude"}) #works, but attribute is not removed
bij ETI.include
self.out.put({'BOTSID':'root'})
ta_list = self.convertfilelist(ta_list)
for filename in ta_list:
self.out.put({'BOTSID':'root'},{'BOTSID':'{
http://www.w3.org/2001/XInclude}include','parse':"xml",'href':filename})
self.out.envelopewrite(self.out.root
Please check the blue highlighted part, I don't understand how the object
get the property?
Jim
Now that you tell us you want to know where the out property is coming
from, I can respond.
Clearly, you don't have the whole class listed here. Where's the
_openoutenvelop() method, for example? I'd guess it creates the out
attribute. Since it gets called from __init__(), and before the
reference to self.out, that's what makes the most sense.
--
http://mail.python.org/mailman/listinfo/python-list