Closed nielsonsantana closed 6 years ago
I only added the +=
syntax in version 0.5.0 which was a major change. This is of course implemented as the Terrascript.__add__()
method. There is actually a Terrascript.add()
method which is simply an "alias" for Terrascript.__add__()
. Since it is not documented I suggest changing the behaviour of Terrascript.add()
so it can be used as follows.
from terrascript import Terrascript
import terrascript
ts = terrascript.Terrascript()
var_access_key = ts.add(terrascript.variable('access_key'))
The Terrascript.add()
method would simply return its argument. This way you get +=
and variable assigment in one line.
I have a test case for what I suggested in my previous post: https://github.com/mjuenema/python-terrascript/blob/issue33/tests/test_issue33.py
Great!! I will use the syntax ts.add
in the docs in this case.
I should make the pull request to branch issue33?
As this syntax was implemented on branch issue33, I'm closing this issue.
I started work on documentation to upgrade to version 0.5.0, and I'm think that declare
ts +=
a bit tedious, specially when we will use the variable another time. In this case is necessary two lines.Than, my suggestion is another syntax to Terrascript. Something explicit and more easy to use. I think that is possible take advantage of multiple assign of python. We would use a setter property, for example
ts.write
orts.w
(less verbose). I'm not advocating to remove the current syntax, but add another.To apply this syntax, Is need just add some lines:
Full example for comparision
Syntax:
ts +=
Syntax:
ts.write
orts.w