On Sat, Dec 1, 2018, 4:00 PM Nils Bruin <nbr...@sfu.ca wrote:

> On Saturday, December 1, 2018 at 3:36:55 PM UTC-8, Tevian Dray wrote:
>>
>> How can I create variable names programmatically, then assign values to
>> them?
>>
>> Python doesn't make that particularly easy, and it also doesn't make
> accessing variables thus created particularly easy.
>

It actually does make both easy, via the globals() dict... :-)

I suspect the appropriate solution for you is to construct some container
> object and store the values in there, such as:
> D={}
> for i in [1..20]:
>     D[3*i+1] = "value"
>
> for i in [1..20]:
>     print(D[3*i+1])
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to