Convert PySerial to python 3.0
king.seth at gmail.com
Wed Feb 25 07:37:19 EST 2009
On Feb 24, 10:55 pm, Chris Rebert <c... at rebertia.com> wrote:
> On Tue, Feb 24, 2009 at 7:46 PM, Seth <king.s... at gmail.com> wrote:
> > I am just messing around trying to get pyserial to work with 3.0.
> > I am stuck on this line:
> > if type(port) in [type(''), type(u'')]
> > how can I convert this to 3.0? I tried changing the u to a d that did
> > not do anything.
> Looks like it's doing the equivalent of the pre-3.0-ism
> `isinstance(port, basestring)`, but in a roundabout way.
> However, since basestring doesn't exist in 3.0, either:
> if isinstance(port, str):
> if isinstance(port, bytes):
> would be the appropriate replacement. Depends (obviously) on whether
> 'port' is supposed to be unicode or a byte sequence.
> Without more context, I can't really say which is what you want.
> Follow the path of the Iguana...http://rebertia.com
I implemented "if isinstance(port, str): " that seems to work for now.
Currently I am running into:
err, n = win32file.WriteFile(self.hComPort, data,
TypeError: expected an object with a buffer interface
More information about the Python-list