0

a.py looks like this:

user = '0'
xml = '<int>%s</int>'

What I'm trying to do is have it so I can use a second script, b.py like this:

import a
a.user = '4343'
print a.xml

Is this possible? Because I haven't been able to do it. I always get the first variable in the other script. I would rather hold the XML in the second script, because it's so long and makes scrolling through code annoying.

1 Answer 1

1

Yes, it's possible—and, in fact, you're doing it.

It's hard to tell, because you don't have anything that actually uses a.user. But that's easy to fix:

a.py:

user = '0'
xml = '<int>%s</int>'

def foo():
    return xml % (user,)

b.py:

import a
a.user = '4343'
print a.foo()

Now run it:

$ python b.py
<int>4343</int>

Exactly what you wanted, right?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.