If One Line
Rick Johnson
rantingrickjohnson at gmail.com
Thu Dec 25 11:46:05 EST 2014
More information about the Python-list mailing list
Thu Dec 25 11:46:05 EST 2014
- Previous message (by thread): If One Line
- Next message (by thread): If One Line
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thursday, December 25, 2014 9:19:25 AM UTC-6, JC wrote:
> Hello,
>
> Is it possible in python:
>
> if ((x = a(b,c)) == 'TRUE'):
> print x
>
> Thanks.
Could you not simply rephrase:
result = foo()
if result == 'TRUE':
do_something()
Of course, another oddity is fact that you're "seemingly" using a string to represent what should be a Boolean value.
You may want to check out the contextlib, which allows you to create custom context managers utilizing the "with" statement.
path = 'C:\d\e\f\g.txt
with open(path) as f:
do_something()
- Previous message (by thread): If One Line
- Next message (by thread): If One Line
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list