Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33057
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <danielkleinad@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'attribute': 0.05; 'ascii': 0.07; 'completeness': 0.07; 'performs': 0.07; 'python': 0.09; 'array.': 0.09; 'encoding.': 0.09; 'friday,': 0.09; 'subject:characters': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'do,': 0.15; 'encoding': 0.15; "'address'": 0.16; 'codec': 0.16; 'delimiters': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'printing.': 0.16; 'securities,': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'string': 0.17; 'wrote:': 0.17; 'requests': 0.18; 'skip:p 30': 0.20; 'question.': 0.20; 'trying': 0.21; 'import': 0.21; 'elements': 0.23; 'this:': 0.23; "i've": 0.23; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'skip:" 20': 0.26; '(most': 0.27; 'cc:addr:gmail.com': 0.27; 'embedded': 0.27; 'guess': 0.27; 'question': 0.27; 'accuracy': 0.27; 'run': 0.28; 'record': 0.28; 'statements': 0.29; 'convert': 0.29; 'probably': 0.29; "i'm": 0.29; 'classes': 0.30; 'file': 0.32; 'addresses': 0.32; 'could': 0.32; 'traceback': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'server': 0.35; 'process,': 0.35; 'stores': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'actions': 0.36; 'characters': 0.36; 'uses': 0.37; 'skip:3 10': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'your': 0.60; 'address': 0.60; 'range': 0.60; 'back': 0.62; 'between': 0.63; 'information': 0.63; 'information,': 0.63; 'url:email': 0.63; 'within': 0.64; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; 'records': 0.68; 'city': 0.69; 'sale': 0.76; 'whereby': 0.91 |
| Newsgroups | comp.lang.python |
| Date | Fri, 9 Nov 2012 13:46:42 -0800 (PST) |
| In-Reply-To | <mailman.3517.1352496859.27098.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=108.78.40.138; posting-account=S-UcDQoAAACh3mXdFBHQR00lNytDt6nm |
| References | <3d4644f8-ab88-41c5-9a52-2a5678dd64c0@googlegroups.com> <mailman.3508.1352483285.27098.python-list@python.org> <99d5bd83-35ab-4801-b953-391c497c35bf@googlegroups.com> <mailman.3517.1352496859.27098.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-IP | 108.78.40.138 |
| MIME-Version | 1.0 |
| Subject | Re: Printing characters outside of the ASCII range |
| From | danielk <danielkleinad@gmail.com> |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | "python-list@python.org" <python-list@python.org>, danielk <danielkleinad@gmail.com> |
| 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.3519.1352497611.27098.python-list@python.org> (permalink) |
| Lines | 99 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1352497611 news.xs4all.nl 6923 [2001:888:2000:d::a6]:43395 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33057 |
Show key headers only | View raw
On Friday, November 9, 2012 4:34:19 PM UTC-5, Prasad, Ramit wrote:
> danielk wrote:
>
> >
>
> > The database I'm using stores information as a 3-dimensional array. The delimiters between elements are
>
> > chr(252), chr(253) and chr(254). So a record can look like this (example only uses one of the delimiters for
>
> > simplicity):
>
> >
>
> > name + chr(254) + address + chr(254) + city + chr(254) + st + chr(254) + zip
>
> >
>
> > The other delimiters can be embedded within each field. For example, if there were multiple addresses for 'name'
>
> > then the 'address' field would look like this:
>
> >
>
> > addr1 + chr(253) + addr2 + chr(253) + addr3 + etc ...
>
> >
>
> > I use Python to connect to the database using subprocess.Popen to run a server process. Python requests
>
> > 'actions' like 'read' and 'write' to the server process, whereby the server process performs the actions. Some
>
> > actions require that the server send back information in the form of records that contain those delimiters.
>
> >
>
> > I have __str__ and __repr__ methods in the classes but Python is choking on those characters. Surely, I could
>
> > convert those characters on the server before sending them to Python and that is what I'm probably going to do,
>
> > so guess I've answered my own question. On Python 2, it just printed the 'extended' ASCII representation.
>
> >
>
> > I guess the question I have is: How do you tell Python to use a specific encoding for 'print' statements when I
>
> > know there will be characters outside of the ASCII range of 0-127?
>
>
>
> You just need to change the string to one that is not
>
> trying to use the ASCII codec when printing.
>
>
>
> print(chr(253).decode('latin1')) # change latin1 to your
>
> # chosen encoding.
>
> ý
>
>
>
>
>
> ~Ramit
>
>
>
>
>
> This email is confidential and subject to important disclaimers and
>
> conditions including on offers for the purchase or sale of
>
> securities, accuracy and completeness of information, viruses,
>
> confidentiality, legal privilege, and legal entity disclaimers,
>
> available at http://www.jpmorgan.com/pages/disclosures/email.
D:\home\python>pytest.py
Traceback (most recent call last):
File "D:\home\python\pytest.py", line 1, in <module>
print(chr(253).decode('latin1'))
AttributeError: 'str' object has no attribute 'decode'
Do I need to import something?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Printing characters outside of the ASCII range danielk <danielkleinad@gmail.com> - 2012-11-09 09:17 -0800
Re: Printing characters outside of the ASCII range Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-09 10:34 -0700
Re: Printing characters outside of the ASCII range Andrew Berg <bahamutzero8825@gmail.com> - 2012-11-09 11:39 -0600
Re: Printing characters outside of the ASCII range Dave Angel <d@davea.name> - 2012-11-09 12:47 -0500
Re: Printing characters outside of the ASCII range danielk <danielkleinad@gmail.com> - 2012-11-09 13:17 -0800
RE: Printing characters outside of the ASCII range "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-09 21:34 +0000
Re: Printing characters outside of the ASCII range danielk <danielkleinad@gmail.com> - 2012-11-09 13:46 -0800
Re: Printing characters outside of the ASCII range Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-09 15:10 -0700
Re: Printing characters outside of the ASCII range danielk <danielkleinad@gmail.com> - 2012-11-11 05:42 -0800
Re: Printing characters outside of the ASCII range Lele Gaifax <lele@metapensiero.it> - 2012-11-11 18:09 +0100
Re: Printing characters outside of the ASCII range danielk <danielkleinad@gmail.com> - 2012-11-11 05:42 -0800
Re: Printing characters outside of the ASCII range danielk <danielkleinad@gmail.com> - 2012-11-09 13:46 -0800
Re: Printing characters outside of the ASCII range Andrew Berg <bahamutzero8825@gmail.com> - 2012-11-09 15:39 -0600
Re: Printing characters outside of the ASCII range danielk <danielkleinad@gmail.com> - 2012-11-09 13:17 -0800
Re: Printing characters outside of the ASCII range wxjmfauth@gmail.com - 2012-11-10 02:09 -0800
Re: Printing characters outside of the ASCII range Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-11-11 15:40 +0100
csiph-web