473,473 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

question from beginner

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
16 2600
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
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
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
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
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
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
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
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
[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
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
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
"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: martin | last post by:
Hello, I just got the SUN Java IDE. (Netbeans IDE 3.5.1) Very very nice, and I worked myself through the tutorial (about making a colorswitch). Now, When I compile it gives no errors at all. So...
11
by: Svens | last post by:
Hey everyone! I'm a math student working on a short script involving logs. I have a function on my scientific calculator, and was wondering if there was a similar funtion in python. For example:...
4
by: IS | last post by:
At the recommendation of several people in this newsgroup I have downloaded two or three Compilers. One is the Beta version of Microsoft's Visual C++ 2005. I have entered a complete beginner code...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
12
by: uno | last post by:
Hello, I am a beginner with the programming and I have some question. I am reading manuals from Internet and some book from the library. In all those documents the C language operate wint plain...
1
by: Mike Malter | last post by:
I am just starting to work with reflection and I want to create a log that saves relevant information if a method call fails so I can call that method again later using reflection. I am...
10
by: Roman Zeilinger | last post by:
Hi I have a beginner question concerning fscanf. First I had a text file which just contained some hex numbers: 0C100012 0C100012 ....
4
by: a | last post by:
Dear all vb.net developer I want to know the time I need to master vb.net? I'm beginner
3
by: Ben Keshet | last post by:
I have a probably simple beginner's question - I have a script that I am currently able to print its output. instead, i want to write it into a file - I tried different versions of write() but...
2
by: roanhn | last post by:
Hello. I've to to write a master's thesis. Currently I deal with php, mysql, ajax. Fate decreed that I've to choose one of this subjects: 1.gdi+ library in .net technology 2.ado.net technology...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.