Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
the PHP ternary operator equivalent on Python
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Steven D'Aprano, post: 1850320"] I'm not arguing for multi-line code just for the sake of using more than one line. I'm against artificially trying to compress a algorithm that is naturally expressed in two or more lines into one line. Why do you bother to initialise dNewDataFields to an empty dict when you then populate it in the very next statement? Doesn't look like a one-liner to me. You've called Evaluate, which takes five lines by my count. Again, I am not arguing for needlessly inflating lines of code, I think your solution is fine. But just to prove it can be done: dNewDataFields['CODE'] = dOldDataFields['CODEDATA'] dNewDataFields['DATE'] = dOldDataFields['DATE'] if dOldDataFields['CONTACTTYPE'] == 2: dNewDataFields['CONTACT'] = dOldDataFields['FIRSTCONTACT'] else: dNewDataFields['CONTACT'] = dOldDataFields['SECONDCONTACT'] There. The world didn't end. *wink* [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
the PHP ternary operator equivalent on Python
Top