with open('com1', 'r') as f:

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Apr 5 00:24:15 CEST 2009

En Sat, 04 Apr 2009 14:11:12 -0300, gert <gert.cuykens at gmail.com> escribió:

> On Apr 4, 5:20 pm, Kushal Kumaran <kushal.kuma... at gmail.com> wrote:
>> On Fri, 03 Apr 2009 22:10:36 +0200
>> Christian Heimes <li... at cheimes.de> wrote:
>> > gert wrote:

>> > > I do understand, and I went looking into pySerial, but it is a long
>> > > way from getting compatible with python3.x and involves other libs
>> > > that are big and non pyhton3.x compatible.
>> > So don't use Python 3.0. Most people are still using Python 2.5 or
>> > 2.6.
>> Alternatively, you could look into the pySerial source and find out
>> what it does.
> I think pywin32 is the way they do the things I want. Witch is not
> python3 ready and way to much work around to do it clean. Using ctypes
> is a option but you have to really know what you are doing and what
> you are looking for.

The last pywin32 release (213) does work with Python 3.
If you can wait a few days, I'm working on a proper port of pyserial.  
Preliminary testing shows it's working fine on Windows. Basically, I've  
modified the read/write methods to use bytes instead of str, and 2to3 did  
the rest:

Python 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit  
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
p3> import serial
p3> ser = serial.Serial(2)
p3> ser.write(b"ATI7\r\n")
p3> for line in ser: print(line.rstrip().decode("ascii","replace"))

Configuration Profile...

Product type           US/Canada Internal
Options                V32bis,V.FC,V.34+
Fax Options            Class 1/Class 2.0
Clock Freq             92.0Mhz
Line Options           Caller ID,Distinctive Ring
Voice Options          Speakerphone,TAD
Eprom                  256k
Ram                    64k

EPROM date             5/13/96
DSP date               5/13/96

EPROM rev              2.0
DSP rev                2.0


Gabriel Genellina

More information about the Python-list mailing list