Hi all.
I'm wondering if it is possible to pass formatted strings to function arguments.

I'm doing something like this:
OUT_TASK = "Task_{id1}, FUNCTION, {id2}, task{id3}_types, None"
t = Task(OUT_TASK.format(id1=i, id2='doNothing', id3=i))

Any clues are much appreciated. Any other means for doing variable arguments are of interest.

What is the purpose of this?
Anyway, you can parse the input string in TASK.init method.

If you want variable arguments, then you should take a look at the *args, **kwargs function definitions.
See

What is the purpose of this?

I wonder about this to.

I'm wondering if it is possible to pass formatted strings to function arguments.

Yes a formatted string is still a string and function can take most datatypes.
I dont see the point of splitting the format option into two part.

def task(arg):
    return arg

#Why not one part,if string is to long escape with \
OUT_TASK = "Task_{id1}, FUNCTION, {id2}, task{id3}_types, None"\
.format(id1=100, id2='doNothing', id3=300)

print task(OUT_TASK)

Can do something like this with *args,but ugly and hard to understand.

def task(*args):
    return args[1]

OUT_TASK = "Task_{id1}, FUNCTION, {id2}, task{id3}_types, None"
print task(OUT_TASK, OUT_TASK.format(id1=100, id2='doNothing', id3=300))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.