A newbie question about some code

Chris Rebert clp2 at rebertia.com
Mon May 18 05:31:35 EDT 2009


On Mon, May 18, 2009 at 2:18 AM, Jim Qiu <bluefisher80 at gmail.com> 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?

I would guess the `out` attribute is created in _openoutenvelope(),
but you didn't include all the code, so it's impossible to be sure.

Also, I'd recommend keeping your posts in plaintext in the future
rather than relying on HTML formatting.

Cheers,
Chris
-- 
http://blog.rebertia.com



More information about the Python-list mailing list