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 7706581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:09:38+00:00 2026-06-01T00:09:38+00:00

I am editing a script, which authenticates to openstack keystone to get a token.

  • 0

I am editing a script, which authenticates to openstack keystone to get a token. The API-Call works but I want to use variables instead of the direct values to make it more readable und reusable. But the problem is that it is necessary for the values to be in quotes (“) and I can’t figure out how to do that. I found some code examples [1], [2] to use variables in strings in general but I need to use some kind of escape sequence to place the values in quotes.

At the moment my string assignment looks like this:

params = '{"auth":{"passwordCredentials":{"username":"nodermatt", "password":"feelfree"}, "tenantId":"4"}}'

As you can see the values of username, password and tenantID are in quotes and I’d like it to replace them with variables:

osuser = "nodermatt"
ospassword = "feelfree"
ostenant = "4"

params = '{"auth":{"passwordCredentials":{"username":osuser, "password":ospassword}, "tenantId":ostenant}}'

I’d be very glad if could solve this “issue”.

PS: If I missed a thread or a search result on google that matches my question, I’d be very gratefull for the link.

Thanks in advance!
Best regards,
Nicolas

[1] Subprocess in Python Add Variables

[2] http://ubuntuforums.org/showthread.php?t=786879

  • 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-06-01T00:09:40+00:00Added an answer on June 1, 2026 at 12:09 am

    The easiest solution for this particular case is to define a Python dictionary first, and then use json.dumps() to convert it to JSON:

    osuser = "nodermatt"
    ospassword = "feelfree"
    ostenant = "4"
    
    d = {"auth": 
            {"passwordCredentials": {"username": osuser, "password": ospassword},
             "tenantId": ostenant}}
    params = json.dumps(d)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that performs some simple editing which works fine, the problem
I have a small python script which i use everyday......it basically reads a file
The Question Which JavaScript framework (prototype, script.aculo.us, Mootools, MochiKit...) has decent CSS rule editing
I’m working on a homepage and will use an AJAX inline editing script for
I use emacs for text editing and script development. I use both windows and
I'm currently writing a script editing app in c# to edit game scripts. I
I have the following jqGrid script: jQuery(#editgrid).jqGrid({ url: editing.php?q=1, datatype: xml, // ... Where
I have written a python script which read from a txt file and perform
I have a js code in which an array works well when its like
I am giving TextMate a try for some quick editing of a few script

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.