Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78201
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'attribute': 0.07; 'indicated': 0.07; 'iterate': 0.09; 'method,': 0.09; 'pil': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; '23,': 0.16; '__init__,': 0.16; 'definition.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ought': 0.16; 'sad': 0.16; 'subject:PIL': 0.16; 'elements': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'possibility': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'sep': 0.31; 'class': 0.32; 'probably': 0.32; 'open': 0.33; 'raw': 0.33; 'maybe': 0.34; 'problem': 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'list,': 0.38; 'pm,': 0.38; 'rather': 0.38; 'subject:can': 0.39; 'entire': 0.61; 'show': 0.63; 'here': 0.66; 'frank': 0.68; 'skip:s 80': 0.84; 'subject:read': 0.84; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=0xcVeDT6x6I5E9HpnSjgqdVD4aVN+V//lw8AlZGFFcE=; b=UNJzPk7WI4xuzQ9vc9ar29ttNqIfHuSPfY1BC15L2Ko1bXxBPIz3BadstyUI6FZcXs hzxbbhZvXdegvlEvatMht+z8cQHCBZukXmXFAr9Ve3+fIdW2HKbbIN8XUEdIjR0YZ8Ew MOSYhr7EBfT05ak/p2wyDtGU5ASH8Y13Fm9cY2aB1moJSesgltNGk54YRvOZAgetFcSD KD1VpGLQTxZ6frfTc7ool9wzWDM7qssTM0TPhVoPjD2Kcbezcva9KAplMI6L7fj2irua JDqfAmoRydagT61BR4cfRO/mpwmitHxx8SWQq/m0xLXWNfyJd1b+GPtyoe7H5pADqY8J idFw== |
| MIME-Version | 1.0 |
| X-Received | by 10.42.92.129 with SMTP id t1mr1007813icm.59.1411461369568; Tue, 23 Sep 2014 01:36:09 -0700 (PDT) |
| In-Reply-To | <2bae5b6f-a3b9-40d8-a037-a6ff309ba71f@googlegroups.com> |
| References | <2bae5b6f-a3b9-40d8-a037-a6ff309ba71f@googlegroups.com> |
| Date | Tue, 23 Sep 2014 18:36:09 +1000 |
| Subject | Re: PIL can't read binary |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14249.1411461377.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1411461377 news.xs4all.nl 2902 [2001:888:2000:d::a6]:41333 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:78201 |
Show key headers only | View raw
On Tue, Sep 23, 2014 at 6:29 PM, Frank Liou <fk26541598fk@gmail.com> wrote: > I use PIL Image.open() > > but it show 'list' object has no attribute 'open' > > this is my code > > class Image2(): > trans = connection.begin() > session = Session() > ProductId = session.query(ProductEntity.ProductId).filter(ProductEntity.CompanyId=="2").all() > Image = session.query(ProductImageGalleryEntity).filter(ProductImageGalleryEntity.ProductId=="20").all() > PicFromDataBase = Image[0].ProductImage > try: > b = Image.open(str(PicFromDataBase)) > except Exception as e: > sad = e I suspect a lot of this ought to be in a method, probably __init__, rather than raw in the class definition. However, the problem here is that your Image is a list (as indicated by the exception), and you probably want to open just one of its elements - maybe Image[0].open(...). You may also want to iterate over the entire list, which would cope better with the possibility of having none or multiple. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PIL can't read binary Frank Liou <fk26541598fk@gmail.com> - 2014-09-23 01:29 -0700 Re: PIL can't read binary Chris Angelico <rosuav@gmail.com> - 2014-09-23 18:36 +1000 Re: PIL can't read binary Ned Batchelder <ned@nedbatchelder.com> - 2014-09-23 07:03 -0400
csiph-web