Unlike most languages with interpolated strings, Python's formatted string literals do not allow the nesting of quotes. For example, this expression is not legal Python: f"Foo {"bar"} baz" If an interpolation requires quotes, those quotes nust differ from the quotes used by the enclosing literal. We can fix the previous example by rewriting it with single quotes: f"Foo {'bar'} baz" However, this presents a problem if there are more than two levels of nesting, as Python only has two kinds of quotes (four if the outermost string uses """ or '''): in this case, the expression becomes unspellable, and must be assigned to a local that is then used in place of the original expression. So this: f"Foo {bar[f'index {baz["qux"]}']} zed" becomes this: index = "qux" f"Foo {bar[f'index {baz[index]}']}" To put it bluntly, Python code generation reqiures register allocation, but for quotes. These changes implement exactly that. These changes also include a fix for traversals that access values that are dictionaries rather than objects, and must use indexers rather than attributes.
8 lines
217 B
Python
8 lines
217 B
Python
import pulumi
|
|
import pulumi_aws as aws
|
|
|
|
logs = aws.s3.Bucket("logs")
|
|
bucket = aws.s3.Bucket("bucket", loggings=[{
|
|
"targetBucket": logs.bucket,
|
|
}])
|
|
pulumi.export("targetBucket", bucket.loggings[0]["targetBucket"])
|