By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,406 Members | 1,353 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,406 IT Pros & Developers. It's quick & easy.

question from beginner

P: n/a
Hi, Im new on phyton programming.
On my GPRS modem with embedded Phyton 1.5.2+ version, I have to receive
a string from serial port and after send this one enclosed in an
e-mail.
All OK if the string is directly generated in the code. But it doesn't
works if I wait for this inside a 'while' loop. This is the simple
code:

global stringZVEI

while stringZVEI=='':
MOD.sleep(10)
a=SER.send(' sono nel while stringZVEI==st vuota')
stringZVEI = SER.readbyte()
a=SER.send(' stringZVEI=')
a=SER.send(stringZVEI)

MOD and SER are embedded class maked by third part.
From my very little debug possibility it seem that loop is executed 1

time only nevertheless stringZVEI is still empty. The line
a=SER.send(' stringZVEI=')
work correctly but

a=SER.send(stringZVEI)

doesn't work

Any suggestion?

Thanks
Dario.

Sep 7 '05 #1
Share this Question
Share on Google+
16 Replies


P: n/a
On 7 Sep 2005 07:14:37 -0700, "dario" <ke******@libero.it> declaimed the
following in comp.lang.python:
Hi, Im new on phyton programming.
On my GPRS modem with embedded Phyton 1.5.2+ version, I have to receive
a string from serial port and after send this one enclosed in an
e-mail.
All OK if the string is directly generated in the code. But it doesn't
works if I wait for this inside a 'while' loop. This is the simple
code:
First -- post the real code file would help -- the indentation of
the first two statements below is wrong.
global stringZVEI
This does nothing at the top level -- if only makes sense INSIDE a
"def" block, where it has the effect of saying "this variable is not
local to the function"
while stringZVEI=='':
MOD.sleep(10)
There is something wrong with

import time
time.sleep(<seconds>)
????
a=SER.send(' sono nel while stringZVEI==st vuota')
stringZVEI = SER.readbyte()
#for debug
print "%2X " % stringZVEI
a=SER.send(' stringZVEI=')
a=SER.send(stringZVEI)

MOD and SER are embedded class maked by third part.
From my very little debug possibility it seem that loop is executed 1 time only nevertheless stringZVEI is still empty. The line
a=SER.send(' stringZVEI=')
work correctly but

a=SER.send(stringZVEI)

What does .readbyte() do if there is no data to be read? Since your
loop is based on a totally empty string, if .readbyte returns /anything/
(even a "null" byte -- 0x00) your loop will exit; and a null byte may
not be visible on the send...

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Sep 7 '05 #2

P: n/a
Thanks Dennis. In effect stringZVEI doesn't remain empty after the
..read method, then the loop is executed 1 time.

How could be a 'while' loop to wait a no empty string from the serial
port?

Dario.

Dennis Lee Bieber ha scritto:
On 7 Sep 2005 07:14:37 -0700, "dario" <ke******@libero.it> declaimed the
following in comp.lang.python:
Hi, Im new on phyton programming.
On my GPRS modem with embedded Phyton 1.5.2+ version, I have to receive
a string from serial port and after send this one enclosed in an
e-mail.
All OK if the string is directly generated in the code. But it doesn't
works if I wait for this inside a 'while' loop. This is the simple
code:

First -- post the real code file would help -- the indentation of
the first two statements below is wrong.
global stringZVEI

This does nothing at the top level -- if only makes sense INSIDE a
"def" block, where it has the effect of saying "this variable is not
local to the function"
while stringZVEI=='':
MOD.sleep(10)


There is something wrong with

import time
time.sleep(<seconds>)
????
a=SER.send(' sono nel while stringZVEI==st vuota')
stringZVEI = SER.readbyte()


#for debug
print "%2X " % stringZVEI
a=SER.send(' stringZVEI=')
a=SER.send(stringZVEI)

MOD and SER are embedded class maked by third part.
From my very little debug possibility it seem that loop is executed 1

time only nevertheless stringZVEI is still empty. The line
a=SER.send(' stringZVEI=')
work correctly but

a=SER.send(stringZVEI)

What does .readbyte() do if there is no data to be read? Since your
loop is based on a totally empty string, if .readbyte returns /anything/
(even a "null" byte -- 0x00) your loop will exit; and a null byte may
not be visible on the send...

--
> ================================================== ============ <
> wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
> wu******@dm.net | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <


Sep 8 '05 #3

P: n/a
On 8 Sep 2005 09:14:15 -0700, "dario" <ke******@libero.it> declaimed the
following in comp.lang.python:
Thanks Dennis. In effect stringZVEI doesn't remain empty after the
.read method, then the loop is executed 1 time.

How could be a 'while' loop to wait a no empty string from the serial
port?

My apologies, I am having some difficulty making sense of some of
your phrases.

The first question I would have to ask is: what are the
specifications of that .readbyte() call. If it doesn't wait for a data
byte, what does it return? If it does wait for a data byte, there is NO
way to look for an "empty string".

The second question I have to ask is: .readbyte() would seem to read
only one byte at a time, is that really what you want -- one byte per
read? or do you want a "string" that ends with a <return>
-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Sep 9 '05 #4

P: n/a
Dennis, my english is not too good...

About first question this is the implementation of SER class (this is
freeware from the source www.telit.it):

#Telit Extensions
#
#Copyright 2004, DAI Telecom S.p.A.
#All rights reserved.
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions
#are met:
#
#Redistributions of source code must retain the above copyright notice,

#this list of conditions and the following disclaimer.
#
#Redistributions in binary form must reproduce the above copyright
#notice, this list of conditions and the following disclaimer in
#the documentation and/or other materials provided with the
distribution.
#
#
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS
#IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
#TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
#PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
#CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
#EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
#PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
#LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
#NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
import time
import serial

freeser = serial.Serial('COM4', 9600, timeout=0, rtscts=1)

def send(string):
global freeser
freeser.write(string)
result = 1
return result

def receive(timeout):
global freeser
sectimeout = int((timeout+5)/10)
time.sleep(sectimeout)
string = freeser.read(512)
return string

def read():
global freeser
string = freeser.read(512)
return string

def sendbyte(byte):
global freeser
string = chr(byte)
freeser.write(string)
result = 1
return result

def receivebyte(timeout):
global freeser
sectimeout = int((timeout+5)/10)
time.sleep(sectimeout)
string = freeser.read(1)
if string == '':
result = -1
else:
result = ord(string)
return result

def readbyte():
global freeser
string = freeser.read(1)
if string == '':
result = -1
else:
result = ord(string)
return result

def SetSpeed(speed):
global freeser
if speed == '9600':
freeser.setBaudrate(9600)
result = 1
elif speed == '19200':
freeser.setBaudrate(19200)
result = 1
elif speed == '115200':
freeser.setBaudrate(115200)
result = 1
else:
result = -1
return result

This is the serial class

class Serial(serialutil.FileLike):
def __init__(self,
port, #number of device, numbering
starts at
#zero. if everything fails, the
user
#can specify a device string,
note
#that this isn't portable
anymore
baudrate=9600, #baudrate
bytesize=EIGHTBITS, #number of databits
parity=PARITY_NONE, #enable parity checking
stopbits=STOPBITS_ONE, #number of stopbits
timeout=None, #set a timeout value, None to
wait forever
xonxoff=0, #enable software flow control
rtscts=0, #enable RTS/CTS flow control
):
"""initialize comm port"""

self.timeout = timeout

if type(port) == type(''): #strings are taken directly
self.portstr = port
else:
self.portstr = device(port)

try:
self.hComPort = win32file.CreateFile(self.portstr,
win32con.GENERIC_READ | win32con.GENERIC_WRITE,
0, # exclusive access
None, # no security
win32con.OPEN_EXISTING,
win32con.FILE_ATTRIBUTE_NORMAL |
win32con.FILE_FLAG_OVERLAPPED,
None)
except Exception, msg:
self.hComPort = None #'cause __del__ is called anyway
raise serialutil.SerialException, "could not open port: %s"
% msg
# Setup a 4k buffer
win32file.SetupComm(self.hComPort, 4096, 4096)

#Save original timeout values:
self.orgTimeouts = win32file.GetCommTimeouts(self.hComPort)

#Set Windows timeout values
#timeouts is a tuple with the following items:
#(ReadIntervalTimeout,ReadTotalTimeoutMultiplier,
# ReadTotalTimeoutConstant,WriteTotalTimeoutMultipli er,
# WriteTotalTimeoutConstant)
if timeout is None:
timeouts = (0, 0, 0, 0, 0)
elif timeout == 0:
timeouts = (win32con.MAXDWORD, 0, 0, 0, 0)
else:
#timeouts = (0, 0, 0, 0, 0) #timeouts are done with
WaitForSingleObject
timeouts = (0, 0, int(timeout*1000), 0, 0)
win32file.SetCommTimeouts(self.hComPort, timeouts)

#win32file.SetCommMask(self.hComPort, win32file.EV_RXCHAR |
win32file.EV_TXEMPTY |
# win32file.EV_RXFLAG | win32file.EV_ERR)
#~ win32file.SetCommMask(self.hComPort,
#~ win32file.EV_RXCHAR | win32file.EV_RXFLAG |
win32file.EV_ERR)
win32file.SetCommMask(self.hComPort, win32file.EV_ERR)

# Setup the connection info.
# Get state and modify it:
comDCB = win32file.GetCommState(self.hComPort)
comDCB.BaudRate = baudrate

if bytesize == FIVEBITS:
comDCB.ByteSize = 5
elif bytesize == SIXBITS:
comDCB.ByteSize = 6
elif bytesize == SEVENBITS:
comDCB.ByteSize = 7
elif bytesize == EIGHTBITS:
comDCB.ByteSize = 8

if parity == PARITY_NONE:
comDCB.Parity = win32file.NOPARITY
comDCB.fParity = 0 # Dis/Enable Parity Check
elif parity == PARITY_EVEN:
comDCB.Parity = win32file.EVENPARITY
comDCB.fParity = 1 # Dis/Enable Parity Check
elif parity == PARITY_ODD:
comDCB.Parity = win32file.ODDPARITY
comDCB.fParity = 1 # Dis/Enable Parity Check

if stopbits == STOPBITS_ONE:
comDCB.StopBits = win32file.ONESTOPBIT
elif stopbits == STOPBITS_TWO:
comDCB.StopBits = win32file.TWOSTOPBITS
comDCB.fBinary = 1 # Enable Binary Transmission
# Char. w/ Parity-Err are replaced with 0xff (if fErrorChar is
set to TRUE)
if rtscts:
comDCB.fRtsControl = win32file.RTS_CONTROL_HANDSHAKE
comDCB.fDtrControl = win32file.DTR_CONTROL_HANDSHAKE
else:
comDCB.fRtsControl = win32file.RTS_CONTROL_ENABLE
comDCB.fDtrControl = win32file.DTR_CONTROL_ENABLE
comDCB.fOutxCtsFlow = rtscts
comDCB.fOutxDsrFlow = rtscts
comDCB.fOutX = xonxoff
comDCB.fInX = xonxoff
comDCB.fNull = 0
comDCB.fErrorChar = 0
comDCB.fAbortOnError = 0

win32file.SetCommState(self.hComPort, comDCB)

# Clear buffers:
# Remove anything that was there
win32file.PurgeComm(self.hComPort,
win32file.PURGE_TXCLEAR |
win32file.PURGE_TXABORT |
win32file.PURGE_RXCLEAR |
win32file.PURGE_RXABORT)

#print win32file.ClearCommError(self.hComPort) #flags, comState
=

self._overlappedRead = win32file.OVERLAPPED()
self._overlappedRead.hEvent = win32event.CreateEvent(None, 1,
0, None)
self._overlappedWrite = win32file.OVERLAPPED()
self._overlappedWrite.hEvent = win32event.CreateEvent(None, 0,
0, None)

def __del__(self):
self.close()

def close(self):
"""close port"""
if self.hComPort:
#Restore original timeout values:
win32file.SetCommTimeouts(self.hComPort, self.orgTimeouts)
#Close COM-Port:
win32file.CloseHandle(self.hComPort)
self.hComPort = None

def setBaudrate(self, baudrate):
"""change baudrate after port is open"""
if not self.hComPort: raise portNotOpenError
# Setup the connection info.
# Get state and modify it:
comDCB = win32file.GetCommState(self.hComPort)
comDCB.BaudRate = baudrate
win32file.SetCommState(self.hComPort, comDCB)

def inWaiting(self):
"""returns the number of bytes waiting to be read"""
flags, comstat = win32file.ClearCommError(self.hComPort)
return comstat.cbInQue

def read(self, size=1):
"""read num bytes from serial port"""
if not self.hComPort: raise portNotOpenError
if size > 0:
win32event.ResetEvent(self._overlappedRead.hEvent)
flags, comstat = win32file.ClearCommError(self.hComPort)
if self.timeout == 0:
n = min(comstat.cbInQue, size)
if n > 0:
rc, buf = win32file.ReadFile(self.hComPort,
win32file.AllocateReadBuffer(n), self._overlappedRead)

win32event.WaitForSingleObject(self._overlappedRea d.hEvent,
win32event.INFINITE)
read = str(buf)
else:
read = ''
else:
rc, buf = win32file.ReadFile(self.hComPort,
win32file.AllocateReadBuffer(size), self._overlappedRead)
n = win32file.GetOverlappedResult(self.hComPort,
self._overlappedRead, 1)
read = str(buf[:n])
else:
read = ''
return read

def write(self, s):
"""write string to serial port"""
if not self.hComPort: raise portNotOpenError
#print repr(s),
if s:
err, n = win32file.WriteFile(self.hComPort, s,
self._overlappedWrite)
if err: #will be ERROR_IO_PENDING:
# Wait for the write to complete.

win32event.WaitForSingleObject(self._overlappedWri te.hEvent,
win32event.INFINITE)

def flushInput(self):
if not self.hComPort: raise portNotOpenError
win32file.PurgeComm(self.hComPort, win32file.PURGE_RXCLEAR |
win32file.PURGE_RXABORT)

def flushOutput(self):
if not self.hComPort: raise portNotOpenError
win32file.PurgeComm(self.hComPort, win32file.PURGE_TXCLEAR |
win32file.PURGE_TXABORT)

def sendBreak(self):
if not self.hComPort: raise portNotOpenError
import time
win32file.SetCommBreak(self.hComPort)
#TODO: how to set the correct duration??
time.sleep(0.020)
win32file.ClearCommBreak(self.hComPort)

def setRTS(self,level=1):
"""set terminal status line"""
if not self.hComPort: raise portNotOpenError
if level:
win32file.EscapeCommFunction(self.hComPort,
win32file.SETRTS)
else:
win32file.EscapeCommFunction(self.hComPort,
win32file.CLRRTS)

def setDTR(self,level=1):
"""set terminal status line"""
if not self.hComPort: raise portNotOpenError
if level:
win32file.EscapeCommFunction(self.hComPort,
win32file.SETDTR)
else:
win32file.EscapeCommFunction(self.hComPort,
win32file.CLRDTR)

def getCTS(self):
"""read terminal status line"""
if not self.hComPort: raise portNotOpenError
return MS_CTS_ON & win32file.GetCommModemStatus(self.hComPort)
!= 0

def getDSR(self):
"""read terminal status line"""
if not self.hComPort: raise portNotOpenError
return MS_DSR_ON & win32file.GetCommModemStatus(self.hComPort)
!= 0

def getRI(self):
"""read terminal status line"""
if not self.hComPort: raise portNotOpenError
return MS_RING_ON & win32file.GetCommModemStatus(self.hComPort)
!= 0

def getCD(self):
"""read terminal status line"""
if not self.hComPort: raise portNotOpenError
return MS_RLSD_ON & win32file.GetCommModemStatus(self.hComPort)
!= 0

#Nur Testfunktion!!
if __name__ == '__main__':
print __name__
s = Serial(0)

About second question I have to read a string of data from the modem
serial port but I was using .readbyte to semplify the code. In effect
..readbyte doesn't return a string type. I repeat the test with .read
method but I discovered another strange behaviour. If the string is not
'sended' to a DTE (serial not connected ot other) the .read method read
the string(s) still not 'sent'. In other words it seems that the rx and
tx serial buffer are shared.

Thanks for your time.
Dario.

Sep 9 '05 #5

P: n/a
Has anyone here upgraded from 2.3 to 2.4 on Tiger?
If so how'd ya do it?

TIA,
Kevin
Sep 9 '05 #6

P: n/a
On 9 Sep 2005 07:17:10 -0700, "dario" <ke******@libero.it> declaimed the
following in comp.lang.python:
Dennis, my english is not too good...

About first question this is the implementation of SER class (this is
freeware from the source www.telit.it):
import time
import serial

freeser = serial.Serial('COM4', 9600, timeout=0, rtscts=1)
Not the cleanest implementation -- as long as they are wrapping
serial, they should have used a class of their own <G>

Okay... According to the small documents for pyserial, "timeout=0"
means return immediately, never wait...

Now for the routine in question...
def readbyte():
global freeser
string = freeser.read(1)
if string == '':
result = -1
else:
result = ord(string)
return result
According to this, readbyte() is NOT returning characters! It is
returning an integer: 0..255 if a data byte is received, and -1 if the
port was empty. So...

import time
import SER
..
..
..
clist = []
SER.send(' sono nel while stringZVEI==st vuota')
# note, the following loop is going to give 10 seconds
# for EACH character before it breaks out
while True:
time.sleep(10) #assuming MOD.sleep() also uses seconds
byte = SER.readbyte()
if byte == -1: break # -1 indicates no data
clist.append(chr(byte)) #save CHARACTER in list
# note, I'm not testing to see if any data came in at all
# if you need to repeat the prompt and read sequence
# you need another loop
SER.send(' stringZVEI=')
cstr = "".join(clist)
SER.send(cstr)

-=-=-=-=-=-=-=-

However, it looks like the above could just as easily be done with

import serial
..
..
..
ser = serial.Serial('COM4', 9600, timeout=0, rtscts=1)
while True:
ser.write(' sono nel while stringZVEI==st vuota')
time.sleep(10) #give the use 10 seconds to type all
if ser.inwaiting() > 0:
cstr = ser.read(ser.inwaiting()) #just in case a few
#more were typed
ser.write(' stringZVEI=')
ser.write(cstr)
break #exit the loop
#note, this version will repeat the prompt and read if
#nothing was entered


About second question I have to read a string of data from the modem
serial port but I was using .readbyte to semplify the code. In effect
.readbyte doesn't return a string type. I repeat the test with .read
method but I discovered another strange behaviour. If the string is not
'sended' to a DTE (serial not connected ot other) the .read method read
the string(s) still not 'sent'. In other words it seems that the rx and
tx serial buffer are shared.
I don't see that behavior in the code -- might be something in how
the actual device is working. You may need to put in a delay slightly
longer than the expected time needed to send "x" characters.
-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Sep 9 '05 #7

P: n/a
stri ker wrote:
Has anyone here upgraded from 2.3 to 2.4 on Tiger?
If so how'd ya do it?


You just run the official installer.

http://python.org/ftp/python/2.4.1/M...SX-2.4.1-1.dmg

Note that this does *not* replace 2.3 which was installed by Apple.
That's a good thing. Instead, the executables get installed to
/usr/local/bin . If you want

$ python

to give you 2.4.1, then make sure that /usr/local/bin comes before
/usr/bin in your $PATH.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Sep 9 '05 #8

P: n/a
stri ker <st*****@trip.net> writes:
Has anyone here upgraded from 2.3 to 2.4 on Tiger?
If so how'd ya do it?


You don't. You install 2.4 in parallel with 2.3. You can do pretty
much whatever you want with /usr/bin/python, /usr/local/bin/python,
etc. - Tiger doesn't seem to use those. I don't remember if I replaced
one or not, but don't touch anything else about the 2.3 installtion.

I installed the darwinports version of 2.4, and have been using it
ever since for all my stuff.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Sep 9 '05 #9

P: n/a
[Mike Meyer wrote]
stri ker <st*****@trip.net> writes:
Has anyone here upgraded from 2.3 to 2.4 on Tiger?
If so how'd ya do it?


You don't. You install 2.4 in parallel with 2.3. You can do pretty
much whatever you want with /usr/bin/python, /usr/local/bin/python,
etc. - Tiger doesn't seem to use those. I don't remember if I replaced
one or not, but don't touch anything else about the 2.3 installtion.

I installed the darwinports version of 2.4, and have been using it
ever since for all my stuff.


There are also the following install options:

- ActivePython:
http://www.activestate.com/Products/ActivePython/
(disclaimer: I make this distro)

- MacPython:
http://undefined.org/python/#python
by Bob Ippolito

- fink (similar in spirit to the darwinports project) also has a Python
I believe
Trent

--
Trent Mick
Tr****@ActiveState.com
Sep 9 '05 #10

P: n/a
On Fri, 9 Sep 2005 13:55:03 -0700, Trent Mick wrote:
[Mike Meyer wrote]
stri ker <st*****@trip.net> writes:
Has anyone here upgraded from 2.3 to 2.4 on Tiger?
If so how'd ya do it?


You don't. You install 2.4 in parallel with 2.3. You can do pretty
much whatever you want with /usr/bin/python, /usr/local/bin/python,
etc. - Tiger doesn't seem to use those. I don't remember if I replaced
one or not, but don't touch anything else about the 2.3 installtion.

I installed the darwinports version of 2.4, and have been using it
ever since for all my stuff.


There are also the following install options:

- ActivePython:
http://www.activestate.com/Products/ActivePython/
(disclaimer: I make this distro)

- MacPython:
http://undefined.org/python/#python
by Bob Ippolito

- fink (similar in spirit to the darwinports project) also has a Python
I believe
Trent


I just got a Mac and was wondering the same thing as the original poster -
how to move to 2.4, but I found out there was more than one version.
So in addition to the Apple installation of 2.3, there are 4 versions of
Python 2.4 (ActivePython, MacPython, fink, darwinports).

Which one should I go for? What are other people using (i.e. which is the
most popular version)? Any particular advantages/disadvantages for each
version?

Cheers.

Mike
Sep 11 '05 #11

P: n/a
Mike P. wrote:
Which one should I go for? What are other people using (i.e. which is the
most popular version)? Any particular advantages/disadvantages for each
version?


The official one.

http://python.org/2.4.1/

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Sep 11 '05 #12

P: n/a
"Mike P." <no*****@for.me.thanks.com> writes:
I just got a Mac and was wondering the same thing as the original poster -
how to move to 2.4, but I found out there was more than one version.
So in addition to the Apple installation of 2.3, there are 4 versions of
Python 2.4 (ActivePython, MacPython, fink, darwinports).
emerge probably has one as well. And Robert Kern mentioned the
official one. The package systems may use one of the others,
especially if they are available in source form. If they all do, there
are only three distributions (ActivePython, MacPython, and the
official one), with the packages installing them in different places.
Which one should I go for? What are other people using (i.e. which is the
most popular version)? Any particular advantages/disadvantages for each
version?


Depends on what you want to do with it. If you favor one of the
package systems (fink, darwinports, emerge), you probably want to use
that one. That way, you won't have to worry about whether or not
another package from that system will find the one Python you
installed (and hence all the things installed by it), or will install
things again.

Otherwise, I agree with Robert - use the official one. Of course, if
one of the other two includes all the extra functionality you want,
use it.

Come to think of it, what's installed by Apple may count as a
different distribution as well. It certainly includes more than just
the official distribution.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Sep 11 '05 #13

P: n/a
Mike Meyer wrote:
Depends on what you want to do with it. If you favor one of the
package systems (fink, darwinports, emerge), you probably want to use
that one. That way, you won't have to worry about whether or not
another package from that system will find the one Python you
installed (and hence all the things installed by it), or will install
things again.

Otherwise, I agree with Robert - use the official one. Of course, if
one of the other two includes all the extra functionality you want,
use it.
One thing that should be noted is that fink's python, last time I
checked, isn't built as a framework build, so it can't talk to the
native GUI or use PyObjC. That's a shame.

darwinports' python is a framework build, but does silly things like
linking to an X11 version of Tk instead of TclTkAqua like the official
distribution.

ActiveState's python is also a framework build, but I don't see how it
adds anything beyond what's provided by the official installer besides
packaging freely available documentation.

I have no idea how emerge's python is built.

The official build is going to be the most widely used and tested. Tools
like py2app and PyObjC are guaranteed to work with it.
Come to think of it, what's installed by Apple may count as a
different distribution as well. It certainly includes more than just
the official distribution.


It's also old and probably won't be the same version in 10.5. If you
want any control over how you distribute your apps, use the official
2.4.1 binary and embed the interpreter inside your .app bundle with py2app.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Sep 11 '05 #14

P: n/a
Robert Kern <rk***@ucsd.edu> writes:
Come to think of it, what's installed by Apple may count as a
different distribution as well. It certainly includes more than just
the official distribution.

It's also old and probably won't be the same version in 10.5. If you
want any control over how you distribute your apps, use the official
2.4.1 binary and embed the interpreter inside your .app bundle with py2app.


IIRC, 10.4.2 ships with a more recent release than 2.4.1 - it comes
with 2.3.5. What I may not be recalling correctly is whether 2.3.5
postdates 2.4.1 or not.

For my uses - developing Unix server-side applications - which version
of Tk it links with is irrelevant. My Mac is a Unix laptop with
hardware support from the vendor. That it runs commercial apps under
Aqua is a nice bonus. That I can't get my favorite X wm on working on
it is unfortunate.

Come to think of it, that problem is OT for c.l.python - because my X
wm is written in Python, using python-xlib. So to post...

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Sep 13 '05 #15

P: n/a
Mike Meyer wrote:
Robert Kern <rk***@ucsd.edu> writes:
Come to think of it, what's installed by Apple may count as a
different distribution as well. It certainly includes more than just
the official distribution.


It's also old and probably won't be the same version in 10.5. If you
want any control over how you distribute your apps, use the official
2.4.1 binary and embed the interpreter inside your .app bundle with py2app.


IIRC, 10.4.2 ships with a more recent release than 2.4.1 - it comes
with 2.3.5. What I may not be recalling correctly is whether 2.3.5
postdates 2.4.1 or not.


Okay, when I said "old" I really meant "lower version."

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Sep 13 '05 #16

P: n/a
Hi Dennis, unfortunately I can only use SER class and not 'serial'
class.
This because my emebedded phyton version don't show any import
possibility to this class. It run on the Trizium modem.
Serial I attached above, was coming from the 'simulator' code installed
on my PC.
How I can simulate your code without serial class? It is better with
SER.read() than SER.readbyte() because I have to read a string.

Thanks.

Sep 13 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.