Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37674
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <cxleung@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'skip:[ 20': 0.03; 'output': 0.04; 'subject:text': 0.05; 'attributes': 0.07; 'subject:file': 0.07; 'python': 0.09; 'aix': 0.09; 'friday,': 0.09; 'instance.': 0.09; 'subject:create': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; '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; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:[ 10': 0.26; 'am,': 0.27; 'skip:# 10': 0.27; 'object,': 0.27; 'dictionary': 0.29; 'methods.': 0.29; 'objects': 0.29; 'class': 0.29; 'file': 0.32; 'print': 0.32; 'everyone': 0.33; 'version': 0.34; "can't": 0.34; 'received:google.com': 0.34; 'text': 0.34; 'received:209.85': 0.35; 'add': 0.36; 'but': 0.36; "didn't": 0.36; 'thank': 0.36; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'object': 0.38; 'from:no real name:2**0': 0.60; 'skip:u 10': 0.60; 'save': 0.61; 'production': 0.63; 'more': 0.63; 'directly.': 0.78; '2013': 0.84; 'dict()': 0.84; 'dict.': 0.84; 'careful': 0.91; 'angel': 0.93 |
| X-Received | by 10.50.191.131 with SMTP id gy3mr1868362igc.1.1359127733199; Fri, 25 Jan 2013 07:28:53 -0800 (PST) |
| Newsgroups | comp.lang.python |
| Date | Fri, 25 Jan 2013 07:28:52 -0800 (PST) |
| In-Reply-To | <mailman.1034.1359119092.2939.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=59.149.73.103; posting-account=EbkZjwoAAAB9mySte6MUShMGsREyvBC- |
| References | <c52b8fa5-1289-40e9-92e1-66c51c6e3ef1@qi8g2000pbb.googlegroups.com> <mailman.1034.1359119092.2939.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-IP | 59.149.73.103 |
| MIME-Version | 1.0 |
| Subject | Re: create object base on text file |
| From | cxleung@gmail.com |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.1042.1359128462.2939.python-list@python.org> (permalink) |
| Lines | 154 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1359128462 news.xs4all.nl 6917 [2001:888:2000:d::a6]:46953 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:37674 |
Show key headers only | View raw
On Friday, January 25, 2013 9:04:31 PM UTC+8, Dave Angel wrote:
> 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
Thank I get the methods.
Python 2.6.2
I just leaning python , before using gawk/ksh.
#!/usr/bin/env python
a= dict()
a["PrintA"]= ["batch1","batch2","batch3"]
a["PrintB"] = ["batch4","batch5"]
a["PrintA"].append("batch6")
print a
for k in sorted(a.keys()):
for j in sorted(a[k]):
print k , j
Output
{'PrintA': ['batch1', 'batch2', 'batch3', 'batch6'], 'PrintB': ['batch4', 'batch5']}
PrintA batch1
PrintA batch2
PrintA batch3
PrintA batch6
PrintB batch4
PrintB batch5
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
create object base on text file moonhkt <moonhkt@gmail.com> - 2013-01-25 04:06 -0800
Re: create object base on text file Dave Angel <d@davea.name> - 2013-01-25 08:04 -0500
Re: create object base on text file cxleung@gmail.com - 2013-01-25 07:28 -0800
Re: create object base on text file cxleung@gmail.com - 2013-01-25 07:28 -0800
csiph-web