question from beginner

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dario

    #1

    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(stri ngZVEI)

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

    a=SER.send(stri ngZVEI)

    doesn't work

    Any suggestion?

    Thanks
    Dario.

  • Dennis Lee Bieber

    #2
    Re: question from beginner

    On 7 Sep 2005 07:14:37 -0700, "dario" <keygrand@liber o.it> declaimed the
    following in comp.lang.pytho n:
    [color=blue]
    > 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:
    >[/color]
    First -- post the real code file would help -- the indentation of
    the first two statements below is wrong.
    [color=blue]
    > global stringZVEI
    >[/color]
    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"
    [color=blue]
    > while stringZVEI=='':
    > MOD.sleep(10)[/color]

    There is something wrong with

    import time
    time.sleep(<sec onds>)
    ????
    [color=blue]
    > a=SER.send(' sono nel while stringZVEI==st vuota')
    > stringZVEI = SER.readbyte()[/color]

    #for debug
    print "%2X " % stringZVEI
    [color=blue]
    > a=SER.send(' stringZVEI=')
    > a=SER.send(stri ngZVEI)
    >
    > MOD and SER are embedded class maked by third part.
    >[color=green]
    > >From my very little debug possibility it seem that loop is executed 1[/color]
    > time only nevertheless stringZVEI is still empty. The line
    > a=SER.send(' stringZVEI=')
    > work correctly but
    >
    > a=SER.send(stri ngZVEI)
    >[/color]
    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...

    --[color=blue]
    > =============== =============== =============== =============== == <
    > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
    > wulfraed@dm.net | Bestiaria Support Staff <
    > =============== =============== =============== =============== == <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]

    Comment

    • dario

      #3
      Re: question from beginner

      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:
      [color=blue]
      > On 7 Sep 2005 07:14:37 -0700, "dario" <keygrand@liber o.it> declaimed the
      > following in comp.lang.pytho n:
      >[color=green]
      > > 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:
      > >[/color]
      > First -- post the real code file would help -- the indentation of
      > the first two statements below is wrong.
      >[color=green]
      > > global stringZVEI
      > >[/color]
      > 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"
      >[color=green]
      > > while stringZVEI=='':
      > > MOD.sleep(10)[/color]
      >
      > There is something wrong with
      >
      > import time
      > time.sleep(<sec onds>)
      > ????
      >[color=green]
      > > a=SER.send(' sono nel while stringZVEI==st vuota')
      > > stringZVEI = SER.readbyte()[/color]
      >
      > #for debug
      > print "%2X " % stringZVEI
      >[color=green]
      > > a=SER.send(' stringZVEI=')
      > > a=SER.send(stri ngZVEI)
      > >
      > > MOD and SER are embedded class maked by third part.
      > >[color=darkred]
      > > >From my very little debug possibility it seem that loop is executed 1[/color]
      > > time only nevertheless stringZVEI is still empty. The line
      > > a=SER.send(' stringZVEI=')
      > > work correctly but
      > >
      > > a=SER.send(stri ngZVEI)
      > >[/color]
      > 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...
      >
      > --[color=green]
      > > =============== =============== =============== =============== == <
      > > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
      > > wulfraed@dm.net | Bestiaria Support Staff <
      > > =============== =============== =============== =============== == <
      > > Home Page: <http://www.dm.net/~wulfraed/> <
      > > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color][/color]

      Comment

      • Dennis Lee Bieber

        #4
        Re: question from beginner

        On 8 Sep 2005 09:14:15 -0700, "dario" <keygrand@liber o.it> declaimed the
        following in comp.lang.pytho n:
        [color=blue]
        > 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?
        >[/color]

        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>
        --[color=blue]
        > =============== =============== =============== =============== == <
        > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
        > wulfraed@dm.net | Bestiaria Support Staff <
        > =============== =============== =============== =============== == <
        > Home Page: <http://www.dm.net/~wulfraed/> <
        > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]

        Comment

        • dario

          #5
          Re: question from beginner

          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:
          #
          #Redistribution s of source code must retain the above copyright notice,

          #this list of conditions and the following disclaimer.
          #
          #Redistribution s 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(s tring)
          result = 1
          return result

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

          def read():
          global freeser
          string = freeser.read(51 2)
          return string

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

          def receivebyte(tim eout):
          global freeser
          sectimeout = int((timeout+5)/10)
          time.sleep(sect imeout)
          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.setBaud rate(9600)
          result = 1
          elif speed == '19200':
          freeser.setBaud rate(19200)
          result = 1
          elif speed == '115200':
          freeser.setBaud rate(115200)
          result = 1
          else:
          result = -1
          return result

          This is the serial class

          class Serial(serialut il.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=EIGHTB ITS, #number of databits
          parity=PARITY_N ONE, #enable parity checking
          stopbits=STOPBI TS_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
          ):
          """initiali ze 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.Creat eFile(self.port str,
          win32con.GENERI C_READ | win32con.GENERI C_WRITE,
          0, # exclusive access
          None, # no security
          win32con.OPEN_E XISTING,
          win32con.FILE_A TTRIBUTE_NORMAL |
          win32con.FILE_F LAG_OVERLAPPED,
          None)
          except Exception, msg:
          self.hComPort = None #'cause __del__ is called anyway
          raise serialutil.Seri alException, "could not open port: %s"
          % msg
          # Setup a 4k buffer
          win32file.Setup Comm(self.hComP ort, 4096, 4096)

          #Save original timeout values:
          self.orgTimeout s = win32file.GetCo mmTimeouts(self .hComPort)

          #Set Windows timeout values
          #timeouts is a tuple with the following items:
          #(ReadIntervalT imeout,ReadTota lTimeoutMultipl ier,
          # ReadTotalTimeou tConstant,Write TotalTimeoutMul tiplier,
          # WriteTotalTimeo utConstant)
          if timeout is None:
          timeouts = (0, 0, 0, 0, 0)
          elif timeout == 0:
          timeouts = (win32con.MAXDW ORD, 0, 0, 0, 0)
          else:
          #timeouts = (0, 0, 0, 0, 0) #timeouts are done with
          WaitForSingleOb ject
          timeouts = (0, 0, int(timeout*100 0), 0, 0)
          win32file.SetCo mmTimeouts(self .hComPort, timeouts)

          #win32file.SetC ommMask(self.hC omPort, win32file.EV_RX CHAR |
          win32file.EV_TX EMPTY |
          # win32file.EV_RX FLAG | win32file.EV_ER R)
          #~ win32file.SetCo mmMask(self.hCo mPort,
          #~ win32file.EV_RX CHAR | win32file.EV_RX FLAG |
          win32file.EV_ER R)
          win32file.SetCo mmMask(self.hCo mPort, win32file.EV_ER R)

          # Setup the connection info.
          # Get state and modify it:
          comDCB = win32file.GetCo mmState(self.hC omPort)
          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.NOPAR ITY
          comDCB.fParity = 0 # Dis/Enable Parity Check
          elif parity == PARITY_EVEN:
          comDCB.Parity = win32file.EVENP ARITY
          comDCB.fParity = 1 # Dis/Enable Parity Check
          elif parity == PARITY_ODD:
          comDCB.Parity = win32file.ODDPA RITY
          comDCB.fParity = 1 # Dis/Enable Parity Check

          if stopbits == STOPBITS_ONE:
          comDCB.StopBits = win32file.ONEST OPBIT
          elif stopbits == STOPBITS_TWO:
          comDCB.StopBits = win32file.TWOST OPBITS
          comDCB.fBinary = 1 # Enable Binary Transmission
          # Char. w/ Parity-Err are replaced with 0xff (if fErrorChar is
          set to TRUE)
          if rtscts:
          comDCB.fRtsCont rol = win32file.RTS_C ONTROL_HANDSHAK E
          comDCB.fDtrCont rol = win32file.DTR_C ONTROL_HANDSHAK E
          else:
          comDCB.fRtsCont rol = win32file.RTS_C ONTROL_ENABLE
          comDCB.fDtrCont rol = win32file.DTR_C ONTROL_ENABLE
          comDCB.fOutxCts Flow = rtscts
          comDCB.fOutxDsr Flow = rtscts
          comDCB.fOutX = xonxoff
          comDCB.fInX = xonxoff
          comDCB.fNull = 0
          comDCB.fErrorCh ar = 0
          comDCB.fAbortOn Error = 0

          win32file.SetCo mmState(self.hC omPort, comDCB)

          # Clear buffers:
          # Remove anything that was there
          win32file.Purge Comm(self.hComP ort,
          win32file.PURGE _TXCLEAR |
          win32file.PURGE _TXABORT |
          win32file.PURGE _RXCLEAR |
          win32file.PURGE _RXABORT)

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

          self._overlappe dRead = win32file.OVERL APPED()
          self._overlappe dRead.hEvent = win32event.Crea teEvent(None, 1,
          0, None)
          self._overlappe dWrite = win32file.OVERL APPED()
          self._overlappe dWrite.hEvent = win32event.Crea teEvent(None, 0,
          0, None)

          def __del__(self):
          self.close()

          def close(self):
          """close port"""
          if self.hComPort:
          #Restore original timeout values:
          win32file.SetCo mmTimeouts(self .hComPort, self.orgTimeout s)
          #Close COM-Port:
          win32file.Close Handle(self.hCo mPort)
          self.hComPort = None

          def setBaudrate(sel f, baudrate):
          """change baudrate after port is open"""
          if not self.hComPort: raise portNotOpenErro r
          # Setup the connection info.
          # Get state and modify it:
          comDCB = win32file.GetCo mmState(self.hC omPort)
          comDCB.BaudRate = baudrate
          win32file.SetCo mmState(self.hC omPort, comDCB)

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

          def read(self, size=1):
          """read num bytes from serial port"""
          if not self.hComPort: raise portNotOpenErro r
          if size > 0:
          win32event.Rese tEvent(self._ov erlappedRead.hE vent)
          flags, comstat = win32file.Clear CommError(self. hComPort)
          if self.timeout == 0:
          n = min(comstat.cbI nQue, size)
          if n > 0:
          rc, buf = win32file.ReadF ile(self.hComPo rt,
          win32file.Alloc ateReadBuffer(n ), self._overlappe dRead)

          win32event.Wait ForSingleObject (self._overlapp edRead.hEvent,
          win32event.INFI NITE)
          read = str(buf)
          else:
          read = ''
          else:
          rc, buf = win32file.ReadF ile(self.hComPo rt,
          win32file.Alloc ateReadBuffer(s ize), self._overlappe dRead)
          n = win32file.GetOv erlappedResult( self.hComPort,
          self._overlappe dRead, 1)
          read = str(buf[:n])
          else:
          read = ''
          return read

          def write(self, s):
          """write string to serial port"""
          if not self.hComPort: raise portNotOpenErro r
          #print repr(s),
          if s:
          err, n = win32file.Write File(self.hComP ort, s,
          self._overlappe dWrite)
          if err: #will be ERROR_IO_PENDIN G:
          # Wait for the write to complete.

          win32event.Wait ForSingleObject (self._overlapp edWrite.hEvent,
          win32event.INFI NITE)

          def flushInput(self ):
          if not self.hComPort: raise portNotOpenErro r
          win32file.Purge Comm(self.hComP ort, win32file.PURGE _RXCLEAR |
          win32file.PURGE _RXABORT)

          def flushOutput(sel f):
          if not self.hComPort: raise portNotOpenErro r
          win32file.Purge Comm(self.hComP ort, win32file.PURGE _TXCLEAR |
          win32file.PURGE _TXABORT)

          def sendBreak(self) :
          if not self.hComPort: raise portNotOpenErro r
          import time
          win32file.SetCo mmBreak(self.hC omPort)
          #TODO: how to set the correct duration??
          time.sleep(0.02 0)
          win32file.Clear CommBreak(self. hComPort)

          def setRTS(self,lev el=1):
          """set terminal status line"""
          if not self.hComPort: raise portNotOpenErro r
          if level:
          win32file.Escap eCommFunction(s elf.hComPort,
          win32file.SETRT S)
          else:
          win32file.Escap eCommFunction(s elf.hComPort,
          win32file.CLRRT S)

          def setDTR(self,lev el=1):
          """set terminal status line"""
          if not self.hComPort: raise portNotOpenErro r
          if level:
          win32file.Escap eCommFunction(s elf.hComPort,
          win32file.SETDT R)
          else:
          win32file.Escap eCommFunction(s elf.hComPort,
          win32file.CLRDT R)

          def getCTS(self):
          """read terminal status line"""
          if not self.hComPort: raise portNotOpenErro r
          return MS_CTS_ON & win32file.GetCo mmModemStatus(s elf.hComPort)
          != 0

          def getDSR(self):
          """read terminal status line"""
          if not self.hComPort: raise portNotOpenErro r
          return MS_DSR_ON & win32file.GetCo mmModemStatus(s elf.hComPort)
          != 0

          def getRI(self):
          """read terminal status line"""
          if not self.hComPort: raise portNotOpenErro r
          return MS_RING_ON & win32file.GetCo mmModemStatus(s elf.hComPort)
          != 0

          def getCD(self):
          """read terminal status line"""
          if not self.hComPort: raise portNotOpenErro r
          return MS_RLSD_ON & win32file.GetCo mmModemStatus(s elf.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.

          Comment

          • stri ker

            #6
            How to upgrade to 2.4.1 on Mac OS X tiger

            Has anyone here upgraded from 2.3 to 2.4 on Tiger?
            If so how'd ya do it?

            TIA,
            Kevin

            Comment

            • Dennis Lee Bieber

              #7
              Re: question from beginner

              On 9 Sep 2005 07:17:10 -0700, "dario" <keygrand@liber o.it> declaimed the
              following in comp.lang.pytho n:
              [color=blue]
              > 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):
              >[/color]
              [color=blue]
              > import time
              > import serial
              >
              > freeser = serial.Serial(' COM4', 9600, timeout=0, rtscts=1)
              >[/color]
              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...[color=blue]
              >
              > def readbyte():
              > global freeser
              > string = freeser.read(1)
              > if string == '':
              > result = -1
              > else:
              > result = ord(string)
              > return result
              >[/color]
              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(ch r(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(cli st)
              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.in waiting()) #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


              [color=blue]
              >
              >
              > 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.
              >[/color]
              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.
              --[color=blue]
              > =============== =============== =============== =============== == <
              > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
              > wulfraed@dm.net | Bestiaria Support Staff <
              > =============== =============== =============== =============== == <
              > Home Page: <http://www.dm.net/~wulfraed/> <
              > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]

              Comment

              • Robert Kern

                #8
                Re: How to upgrade to 2.4.1 on Mac OS X tiger

                stri ker wrote:[color=blue]
                > Has anyone here upgraded from 2.3 to 2.4 on Tiger?
                > If so how'd ya do it?[/color]

                You just run the official installer.



                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
                rkern@ucsd.edu

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

                Comment

                • Mike Meyer

                  #9
                  Re: How to upgrade to 2.4.1 on Mac OS X tiger

                  stri ker <striker@trip.n et> writes:[color=blue]
                  > Has anyone here upgraded from 2.3 to 2.4 on Tiger?
                  > If so how'd ya do it?[/color]

                  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 <mwm@mired.or g> http://www.mired.org/home/mwm/
                  Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

                  Comment

                  • Trent Mick

                    #10
                    Re: How to upgrade to 2.4.1 on Mac OS X tiger

                    [Mike Meyer wrote][color=blue]
                    > stri ker <striker@trip.n et> writes:[color=green]
                    > > Has anyone here upgraded from 2.3 to 2.4 on Tiger?
                    > > If so how'd ya do it?[/color]
                    >
                    > 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.[/color]

                    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
                    TrentM@ActiveSt ate.com

                    Comment

                    • Mike P.

                      #11
                      Re: How to upgrade to 2.4.1 on Mac OS X tiger

                      On Fri, 9 Sep 2005 13:55:03 -0700, Trent Mick wrote:
                      [color=blue]
                      > [Mike Meyer wrote][color=green]
                      >> stri ker <striker@trip.n et> writes:[color=darkred]
                      >>> Has anyone here upgraded from 2.3 to 2.4 on Tiger?
                      >>> If so how'd ya do it?[/color]
                      >>
                      >> 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.[/color]
                      >
                      > 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[/color]

                      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

                      Comment

                      • Robert Kern

                        #12
                        Re: How to upgrade to 2.4.1 on Mac OS X tiger

                        Mike P. wrote:
                        [color=blue]
                        > 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?[/color]

                        The official one.

                        The official home of the Python Programming Language


                        --
                        Robert Kern
                        rkern@ucsd.edu

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

                        Comment

                        • Mike Meyer

                          #13
                          Re: How to upgrade to 2.4.1 on Mac OS X tiger

                          "Mike P." <no.spam@for.me .thanks.com> writes:[color=blue]
                          > 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).[/color]

                          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.
                          [color=blue]
                          > 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?[/color]

                          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 <mwm@mired.or g> http://www.mired.org/home/mwm/
                          Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

                          Comment

                          • Robert Kern

                            #14
                            Re: How to upgrade to 2.4.1 on Mac OS X tiger

                            Mike Meyer wrote:
                            [color=blue]
                            > 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.[/color]

                            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.
                            [color=blue]
                            > 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.[/color]

                            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
                            rkern@ucsd.edu

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

                            Comment

                            • Mike Meyer

                              #15
                              Re: How to upgrade to 2.4.1 on Mac OS X tiger

                              Robert Kern <rkern@ucsd.edu > writes:[color=blue][color=green]
                              >> 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.[/color]
                              > 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.[/color]

                              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 <mwm@mired.or g> http://www.mired.org/home/mwm/
                              Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

                              Comment

                              Working...