Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.05; 'string.': 0.05; 'subject:Python': 0.06; 'imply': 0.09; 'latter': 0.09; 'strings.': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer,': 0.16; 'subject:PySerial': 0.16; 'travis': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'seems': 0.21; '(the': 0.22; 'cc:addr:python.org': 0.22; 'byte': 0.24; 'bytes': 0.24; 'unicode': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'source': 0.25; 'help!': 0.26; 'header:In-Reply-To:1': 0.27; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'file': 0.32; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'turn': 0.37; 'pm,': 0.38; 'rather': 0.38; 'full': 0.61; 'finally': 0.65; 'subject:. ': 0.67; 'or:': 0.84; 'suspicion': 0.84; 'do:': 0.91; '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=BKU+QnWspgKBYAP4O2Nvl4Wp3c48Ya8hd6qOiMiCMyU=; b=VnKLH37qd8RzGd3KdGt73wrqG2c6wt8xvc+v2lLoO+MvOihPA6ICWQXqUubfwh+DC1 KCxrcqr66xhjnH19SU7ix5SwyaBbQurfngThwqv+Sq5icaD9w/EmO2MiOiUSMg/kMv7X TZ7HLdY2EqK8EkkMonDPhnlXrRHiSBpXOzrQJxYyQDU55R4zgVD5wpiA2Ckjo7qoHsml yoU6mYSj45h/25JpiXVzi8cvG7SknF1tVbzXtpqJBtw9SVHqszjmDG9+BKfKBBHyxzB9 lxKapufl/DiFnnSdsSybu7H757szvs+aiRq805N2/zYSDtB9JelfAKdo+JHXZ13kUVal je8Q== MIME-Version: 1.0 X-Received: by 10.68.212.163 with SMTP id nl3mr80957124pbc.25.1388558880133; Tue, 31 Dec 2013 22:48:00 -0800 (PST) In-Reply-To: References: Date: Wed, 1 Jan 2014 17:48:00 +1100 Subject: Re: PySerial for Python 2 vs. Python 3 From: Chris Angelico Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1388558890 news.xs4all.nl 2850 [2001:888:2000:d::a6]:39694 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62949 On Wed, Jan 1, 2014 at 5:39 PM, Travis McGee wrote: > 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. Quoting the full exception would help! My suspicion is that it works with byte strings, not Unicode strings. 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). ChrisA