Can this be easily done in Python?
Random832
random832 at fastmail.com
Tue Sep 27 16:53:47 EDT 2016
On Tue, Sep 27, 2016, at 15:58, TUA wrote:
> Is the following possible in Python?
>
> Given how the line below works
>
> TransactionTerms = 'TransactionTerms'
>
>
> have something like
>
> TransactionTerms = <some Python code here>
>
> that sets the variable TransactionTerms to its own name as string
> representation without having to specify it explicitly as in the line
> above....
What are you trying to do?
If you're trying to avoid saying it twice:
exec('%s=%r'%['TransactionTerms']*2)
If you're trying to avoid having it as a string:
def TransactionTerms(): pass
TransactionTerms = TransactionTerms.__name__
More information about the Python-list
mailing list