Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7040875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:58:13+00:00 2026-05-28T01:58:13+00:00

I have defined a dictionary in python: tal:define=dic python:{‘a’:’1′, ‘b’:’2′}; I have another variable

  • 0

I have defined a dictionary in python:

tal:define="dic python:{'a':'1', 'b':'2'};"

I have another variable defined using tal:define called var, which is either ‘a’ or ‘b’.
I get an error when I try to do:

tal:define="foo python:dic['${var}'];"

(foo would then be ‘1’ or ‘2’)
I get KeyError: '${var}'. I’ve tried dic[$var], dic[var], etc and they all don’t work. How do I use a variable defined previously using tal:define as a key to a dictionary to get its value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:58:14+00:00Added an answer on May 28, 2026 at 1:58 am

    DonCallisto’s dic[var] does work

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dictionary that I am using to define the ratings of copper
I have a ComponentResourceKey defined in my resource dictionary like this: <Style x:Key={ComponentResourceKey TypeInTargetAssembly={x:Type
I have a database table that is a dictionary of defined terms -- key,
In Python, I want to have a class attribute, a dictionary, with initialized values.
I have defined a dictionary that I would like to pass around to various
I have a singleton object and have a dictionary defined in it. public class
I have create a Class named EngDictionary. and Then i define a dictionary in
I have four level data structure defined like this: Dictionary<Type1, Dictionary<Type2, Dictionary<Type3, List<Type4>>>> The
I have a dispatch map defined as such: private Dictionary<string, Func<DynamicEntity, DynamicEntity, IEnumerable<DynamicEntity>, string>>
I have dictionary that is defined as: Dictionary<string, object> d = new Dictionary<string, object>();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.