Re: Re: How to output a complex List object to a file.

bluefisher80 bluefisher80 at gmail.com
Tue Jun 23 03:38:51 CEST 2009


Let me get my question more clear, 

I want like the "structure" object printed into another python source file, which i will use in other program.

The pickled format or even JSONed format does not fullfil my requirement, does it? 

Do i make it clear, I still need your guides.

Jim


Detail step:

#
#this object is constructed in A.py

structure=    [
{ID:'UNH',MIN:1,MAX:1,LEVEL:[
{ID:'BGM',MIN:1,MAX:1},
{ID:'DTM',MIN:1,MAX:5},
{ID:'NAD',MIN:1,MAX:5,LEVEL:[
    {ID:'CTA',MIN:0,MAX:5,LEVEL:[
        {ID:'COM',MIN:0,MAX:5},
        ]},
    ]},            
{ID:'RFF',MIN:0,MAX:5,LEVEL:[
    {ID:'DTM',MIN:0,MAX:5},
    ]},        
{ID:'CUX',MIN:0,MAX:5,LEVEL:[
    {ID:'DTM',MIN:0,MAX:5},
    ]},
{ID:'LOC',MIN:1,MAX:200000,LEVEL:[
    {ID:'DTM',MIN:0,MAX:5},
    {ID:'LIN',MIN:0,MAX:200000,LEVEL:[
        {ID:'PIA',MIN:0,MAX:5},
        {ID:'IMD',MIN:0,MAX:5},
        {ID:'RFF',MIN:0,MAX:5},
        {ID:'ALI',MIN:0,MAX:5},
        {ID:'MOA',MIN:0,MAX:5},
        {ID:'PRI',MIN:0,MAX:5},
        {ID:'QTY',MIN:0,MAX:999,LEVEL:[
            {ID:'NAD',MIN:0,MAX:1},
            ]},
        ]},
    ]},
{ID:'UNT',MIN:1,MAX:1},
]
}
]


##
#Then  I need some code to output the exactly same 

structure=    [
{ID:'UNH',MIN:1,MAX:1,LEVEL:[
{ID:'BGM',MIN:1,MAX:1},
{ID:'DTM',MIN:1,MAX:5},
{ID:'NAD',MIN:1,MAX:5,LEVEL:[
    {ID:'CTA',MIN:0,MAX:5,LEVEL:[
        {ID:'COM',MIN:0,MAX:5},
        ]},
    ]},            
{ID:'RFF',MIN:0,MAX:5,LEVEL:[
    {ID:'DTM',MIN:0,MAX:5},
    ]},        
{ID:'CUX',MIN:0,MAX:5,LEVEL:[
    {ID:'DTM',MIN:0,MAX:5},
    ]},
{ID:'LOC',MIN:1,MAX:200000,LEVEL:[
    {ID:'DTM',MIN:0,MAX:5},
    {ID:'LIN',MIN:0,MAX:200000,LEVEL:[
        {ID:'PIA',MIN:0,MAX:5},
        {ID:'IMD',MIN:0,MAX:5},
        {ID:'RFF',MIN:0,MAX:5},
        {ID:'ALI',MIN:0,MAX:5},
        {ID:'MOA',MIN:0,MAX:5},
        {ID:'PRI',MIN:0,MAX:5},
        {ID:'QTY',MIN:0,MAX:999,LEVEL:[
            {ID:'NAD',MIN:0,MAX:1},
            ]},
        ]},
    ]},
{ID:'UNT',MIN:1,MAX:1},
]
}
]

# Into second file B.py


B.py will be a file of another application. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090623/3f2b75be/attachment.html>


More information about the Python-list mailing list