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

  • Home
  • SEARCH
  • 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 3456746
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:46:30+00:00 2026-05-18T09:46:30+00:00

Possible Duplicate: Creating or assigning variables from a dictionary in Python Hello we have

  • 0

Possible Duplicate:
Creating or assigning variables from a dictionary in Python

Hello

we have dictionary like this:

data = {'raw':'lores ipsum', 'code': 500}

how to convert this dict to strings? result must be like this:

print raw
print code
#output is 
#  lores ipsum
#  500

EDIT:
OK, so what I want is to have raw and code variable available.. one more example

data = {'raw':'lores ipsum', 'code': 500}
var1 = code
var2 = raw

it’s becomes difficult to make tons of string operations with variable, which is dict, which is in class method…
so it’s endups with this: self.data[‘raw’][0] , it’s killing me to write this everytime so to make “raw” variable is more comfortable… (imagine join and format operation with using this on every line!!!) anyway this vars will be available only in this method, so there’s no side-effects for this solution…

EDIT: deleted, nobody understands what I want

  • 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-18T09:46:30+00:00Added an answer on May 18, 2026 at 9:46 am

    This is a pretty bad idea – using dicts as intended ends up with a much less confusing solution.

    A quick hack dirty way of making the key=value pairs into non-dict string variables is as follows:

    for key in data:
      exec("{0} = '{1}'".format(key,data[key]))
    

    This is fragile and breaks with complex data types, aside from being ill-advised, but it does what you’ve asked.

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

Sidebar

Related Questions

Possible Duplicate: Creating a custom Document Library in SharePoint I have 2 users, Martin
Possible Duplicate: Is there a clean way to prevent windows.h from creating a near
Possible Duplicate: JavaScript: Class.method vs. Class.prototype.method What's the difference between creating a prototype like
Possible Duplicate: Creating constant in Python Does Python support constants that are enforced by
Possible Duplicate: Javascript: is using 'var' to declare variables optional? When creating variables in
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
Possible Duplicate: Best way to stop SQL Injection in PHP I am creating a

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.