dictionary comprehensions with Python 2.4/2.5

Discussion in 'Python' started by Iryna Feuerstein, Aug 7, 2012.

  1. Hello,

    for the program developed and maintained by our company the
    compatibility with Python 2.5 is desired. I'm developing with Python
    2.7, though I would like to use dictionary comprehensions in my code.
    The dictionary comprehensions were added to Python in version 2.7 at
    first time. Is it possible to make it compatible with Python 2.5 anyway?
    Perhaps by using the __future__ module?


    Thank you in advance!

    With regards,
    Iryna.
     
    Iryna Feuerstein, Aug 7, 2012
    #1
    1. Advertisements

  2. Iryna Feuerstein

    Paul Rubin Guest

    Iryna Feuerstein <> writes:
    > code. The dictionary comprehensions were added to Python in version
    > 2.7 at first time. Is it possible to make it compatible with Python
    > 2.5 anyway? Perhaps by using the __future__ module?


    Not back to 2.5, but they're not that important anyway. Just use:
    d = dict((k, v) for k,v in ... )
     
    Paul Rubin, Aug 7, 2012
    #2
    1. Advertisements


  3. >
    > Not back to 2.5, but they're not that important anyway. Just use:
    > d = dict((k, v) for k,v in ... )
    >


    Thank you very much! It is the perfect solution for me.

    Regards,
    Iryna.
     
    Iryna Feuerstein, Aug 7, 2012
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven Bethard

    removing list comprehensions in Python 3.0

    Steven Bethard, Jul 8, 2005, in forum: Python
    Replies:
    30
    Views:
    961
    Steven Bethard
    Jul 13, 2005
  2. Steven Bethard
    Replies:
    7
    Views:
    562
    Rocco Moretti
    Jan 20, 2006
  3. Ilias Lazaridis
    Replies:
    6
    Views:
    708
    Ilias Lazaridis
    Feb 21, 2006
  4. james_027
    Replies:
    1
    Views:
    524
    Marc 'BlackJack' Rintsch
    Aug 22, 2007
  5. Navkirat Singh
    Replies:
    6
    Views:
    5,131
    Navkirat Singh
    Jul 29, 2010
  6. Fox

    dictionary within dictionary

    Fox, Mar 8, 2005, in forum: ASP General
    Replies:
    5
    Views:
    414
    Michael D. Kersey
    Mar 13, 2005
  7. Jaewoong kim Crossbreeze
    Replies:
    1
    Views:
    260
    Jaewoong kim Crossbreeze
    Apr 17, 2009
  8. Ayushi Dalmia

    Initialise dictionary of dictionary

    Ayushi Dalmia, Jan 23, 2014, in forum: Python
    Replies:
    4
    Views:
    133
    Ayushi Dalmia
    Jan 24, 2014
Loading...