Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:text': 0.05; 'attributes': 0.07; 'subject:file': 0.07; 'python': 0.09; 'aix': 0.09; 'instance.': 0.09; 'subject:create': 0.09; 'file,': 0.15; 'subject:object': 0.16; 'syntax,': 0.16; 'wrote:': 0.17; 'saying': 0.18; 'file.': 0.20; 'written': 0.20; 'assignment': 0.22; 'produces': 0.22; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'object,': 0.27; 'dictionary': 0.29; 'objects': 0.29; 'class': 0.29; 'file': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'everyone': 0.33; 'version': 0.34; "can't": 0.34; 'text': 0.34; 'add': 0.36; 'but': 0.36; "didn't": 0.36; 'data': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'skip:u 10': 0.60; 'save': 0.61; 'production': 0.63; 'more': 0.63; 'received:74.208': 0.71; 'directly.': 0.78; 'dict()': 0.84; 'dict.': 0.84; 'received:74.208.4.194': 0.84; 'careful': 0.91 Date: Fri, 25 Jan 2013 08:04:31 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: python-list@python.org Subject: Re: create object base on text file References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:6AWnC7C+6WwVDqAQq7GfzkZzpHL5ETkp77eBuwIkElf hTf5P4s3rTO8ZxxyvBQLxksj+shxaukF3NeGKIyZ+xkM53sQJU 77Tg+de4A6JFWe/u5Lup1zDzyVkOJl7FoQMtTHP1jlON9QLmst k8FSsnqv5tvBTIuFVOQ7GFQUrm1DdsOSRW3oJdIj/c4SViq80z hFN3mktgry4xrFPL9lO1pQnHh6YX9FvRBZJi4Ur8UZSvewp2pP y/7Kb0uwZ+sJetibyi9sOO4lPP5qZJxmQaoBxITZAD1iS2zs+O UMQIMGnME8zH4bdAH1zwFwmxgkvwOithJOi2omLFir/6Gy9Ug= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 62 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359119092 news.xs4all.nl 6976 [2001:888:2000:d::a6]:53770 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37660 On 01/25/2013 07:06 AM, moonhkt wrote: > Hi All > > Python 2.6.x on AIX > > Data file > > PrinterA > print Production batch1 > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx > print Production batch2 > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx > print Production batch3 > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx > > PrinterB > print Production batch4 > xxxxxxxxxxxxxxxxxxxxxxxxxxx > print Production batch5 > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx > > > What to using python create object base on date file ? I know how to > read text file. > > object["PrinterA"] have batch1, batch2, batch3 > > object["PrinterB"] have batch4, batch5 > > moonhkt > What Python version are you targeting? It would save everyone a lot of time if you quoted the homework assignment directly. Also, be more careful about typos. Is it a date file, or a data file? You can create an object very easily. a = object(). You can add attributes to many objects by simply saying a.attrib = 42 Unfortunately you can't do that to an "object" class instance. So you need to clarify. Now, you used dictionary syntax, so perhaps you didn't mean create an object, but create a dict. a = dict() a["PrinterA"] = "batch1", "batch2", "batch3" print a produces {'PrinterA': ('batch1', 'batch2', 'batch3')} What part of the assignment is giving you trouble? What have you written so far? -- DaveA