Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62968
| Path | csiph.com!usenet.pasdenom.info!aioe.org!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 | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'argument': 0.05; 'string.': 0.05; 'subject:Python': 0.06; 'imply': 0.09; 'latter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'strings.': 0.09; 'windows,': 0.09; 'jan': 0.12; '1:48': 0.16; 'integer,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:PySerial': 0.16; 'travis': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'written': 0.21; 'seems': 0.21; '(the': 0.22; 'install': 0.23; 'header:User-Agent:1': 0.23; 'byte': 0.24; 'bytes': 0.24; 'issue,': 0.24; 'unicode': 0.24; 'sort': 0.25; 'source': 0.25; 'help!': 0.26; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'statement': 0.30; 'doc': 0.31; 'file': 0.32; 'class': 0.32; 'says': 0.33; 'could': 0.34; 'but': 0.35; 'version': 0.36; 'method': 0.36; 'turn': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'according': 0.40; 'full': 0.61; 'received:173': 0.61; 'finally': 0.65; 'subject:. ': 0.67; 'serial': 0.72; 'or:': 0.84; 'received:fios.verizon.net': 0.84; 'suspicion': 0.84; 'do:': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: PySerial for Python 2 vs. Python 3 |
| Date | Wed, 01 Jan 2014 14:54:05 -0500 |
| References | <SKOwu.77170$VG.23751@fx12.iad> <CAPTjJmp8N+HHAxoeiPmto8yEftUFchKHo65On1EYCoBPuAy0xA@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-173-75-254-207.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <CAPTjJmp8N+HHAxoeiPmto8yEftUFchKHo65On1EYCoBPuAy0xA@mail.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 | <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.4784.1388606061.18130.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1388606061 news.xs4all.nl 2922 [2001:888:2000:d::a6]:41714 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:62968 |
Show key headers only | View raw
On 1/1/2014 1:48 AM, Chris Angelico wrote:
> On Wed, Jan 1, 2014 at 5:39 PM, Travis McGee <nobody@gmail.com> wrote:
What OS? If Windows, did you install the -py3k version for 3.x?
>> Anyway, I finally got it installed, but when I try to use a statement of the
>> sort ser.write("string") I get an exception which seems to imply that the
>> argument needs to be an integer, rather than a string.
According to a Stackoverflow issue, .write(n) will write n 0 bytes
because it will send bytes(n) == n * bytes(b'\0').
PySerial is written in Python, so you could look at the .write method of
the Serial class (presuming that 'ser' is an instance thereof) to see
what it does.
> Quoting the full exception would help!
>
> My suspicion is that it works with byte strings, not Unicode strings.
That is what the doc either says or implies.
> So you could do:
>
> ser.write(b"string")
>
> or:
>
> ser.write("string".encode())
>
> to turn it into a stream of bytes (the latter uses UTF-8, the former
> would use your source file encoding).
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
PySerial for Python 2 vs. Python 3 Travis McGee <nobody@gmail.com> - 2014-01-01 01:39 -0500 Re: PySerial for Python 2 vs. Python 3 Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-12-31 22:43 -0800 Re: PySerial for Python 2 vs. Python 3 Chris Angelico <rosuav@gmail.com> - 2014-01-01 17:48 +1100 Re: PySerial for Python 2 vs. Python 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-01 17:57 +1100 Re: PySerial for Python 2 vs. Python 3 Terry Reedy <tjreedy@udel.edu> - 2014-01-01 14:54 -0500
csiph-web