mailbox module in Python 2.3.4

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rowanbradley
    New Member
    • Jul 2007
    • 1

    mailbox module in Python 2.3.4

    I've written a script that uses the mailbox module. It works on my local machine with python 2.5. On loading it onto my web hosting provider's server it doesn't work. They are running Python 2.3.4. Is this likely to be the reason?

    I've tried loading the 2.5 version of mailbox.py onto the web server - now I get some different errors.

    When was mailbox introduced?

    Is there a version that'll run on python 2.3.4?

    If not, what changes would I have to make to get it to work - assuming that this is feasible?

    Thanks - Rowan
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Misc. Q.s Moderator, please move to the Python Forum . Thank you.

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Originally posted by rowanbradley
      I've written a script that uses the mailbox module. It works on my local machine with python 2.5. On loading it onto my web hosting provider's server it doesn't work. They are running Python 2.3.4. Is this likely to be the reason?

      I've tried loading the 2.5 version of mailbox.py onto the web server - now I get some different errors.

      When was mailbox introduced?

      Is there a version that'll run on python 2.3.4?

      If not, what changes would I have to make to get it to work - assuming that this is feasible?

      Thanks - Rowan
      It's highly feasible, but we'd need to see some code to point out where you have a compatibility issue.

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Originally posted by oreillynet
        I replaced Python 2.3's mailbox.py with the version for Python 2.5, but the following error:


        >>> import mailbox
        Traceback (most recent call last):
        File "<stdin>", line 1, in ?
        File "/usr/lib64/python2.3/mailbox.py", line 928
        return iter(sorted(int (entry) for entry in os.listdir(self ._path)
        ^
        SyntaxError: invalid syntax
        And the reply :
        Originally posted by oreillynet
        Most modules in the Python standard library aren't written to be compatible with earlier versions of Python, so that bit of code is using a generator comprehension. To use the module with Python 2.3,
        you'd have to rewrite that line to create and sort a list instead.

        Comment

        Working...