variables with dynamicly generated names

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

    #1

    variables with dynamicly generated names

    Hello

    Is it possible to use in python variables with dynamicly created names ?
    How ?


    Thanx
  • Diez B. Roggisch

    #2
    Re: variables with dynamicly generated names

    avlee schrieb:
    Hello
    >
    Is it possible to use in python variables with dynamicly created names ?
    How ?
    In such cases, use a dictionary:

    vars = {}

    for some_name, some_value in some_values_gen erating_thing() :
    vars[some_name] = some_value


    Diez

    Comment

    • Paul Rubin

      #3
      Re: variables with dynamicly generated names

      avlee <xx@wp.plwrites :
      Is it possible to use in python variables with dynamicly created names ?
      Yes, but don't.
      How ?
      You almost certainly want to use something like a dictionary instead.

      Comment

      • Gabriel Genellina

        #4
        Re: variables with dynamicly generated names

        At Thursday 14/12/2006 05:50, avlee wrote:
        >Is it possible to use in python variables with dynamicly created names ?
        >How ?
        Use a dictionary:

        d = {}
        d[almost_arbitrar y_key] = value


        --
        Gabriel Genellina
        Softlab SRL

        _______________ _______________ _______________ _____
        Correo Yahoo!
        Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
        ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar

        Comment

        Working...