Python Forum
language feature i'd like to have - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: language feature i'd like to have (/thread-8017.html)



language feature i'd like to have - Skaperen - Feb-03-2018

ages ago i wrote a macro system for IBM mainframe S/360 S/370 assembler language. one of its features was if you wanted to do a comparison for either an if test or a loop test, you could express the two data sources once, then simply express one data source thereafter and each comparison with one source would insert assembler code as if it were coded with two sources, using the missing source position from the previous comparison. i'd like to see something like that in Python.
    if data_array[data_index[usage_factor[1]]] == '(':
        ...
    elif == ')':
        ...
    elif == '|':
        ...
    else:
        ...
because of the way conditionals were separated from code structures in the system i created in that macro language, this feature could also be used on complex loops. i have heard that Python has some kind of redundancy reduction in comparisons but i have been unable to find it. so maybe this would be useful.
    if data_array[data_index[usage_factor[1]]] == '(' == 'a' or == 'b' or == 'c':
        ...
    else:
        ...
thoughts?

* Skaperen ducks behind the red couch


RE: language feature i'd like to have - buran - Feb-03-2018

that is virtually switch/case statement disguised as if...else
same reasoning apply https://www.python.org/dev/peps/pep-3103/


RE: language feature i'd like to have - Larz60+ - Feb-03-2018

Please stop trying to uglify (new word) python. Python is python, not 'C'.


RE: language feature i'd like to have - Skaperen - Feb-04-2018

then i guess i need to ask if some idea makes ugly or non-pythonic code. so it is not ugly if a complicated expression is repeated, or do i need to do the detail work myself of "caching" it in another variable myself? a compiler or interpreter can detect that the expression is the same and has no side effects and cache it itself but readers of the code then have to visually compare each expression to be sure there is no subtle difference. at least in assembly language we had no complex expressions. but i am now long past assembly language (it wasn't very portable) and more oriented to code readability and abstract expression (and hopefully, portable).


RE: language feature i'd like to have - Gribouillis - Feb-04-2018

A long time ago (2004), there was an innovative python module named "logix". With it, the very syntax of the language could be modified easily. I guess it won't run on any modern python interpreter but I have kept three links that could be of interest for you link1 link2 link3


RE: language feature i'd like to have - Skaperen - Feb-05-2018

interesting. i have to find some more time to do some reading. can you guys push stuff westward to help extend the time the earth rotates?