Posts: 4,647
Threads: 1,494
Joined: Sep 2016
in my print_object() function, which has, so far, succeeded in outputting valid Python code, i am wanting to output ints in hexadecimal as an inline comment after the decimal output. an alternative idea is to output it like
123456789+0*0x75bcd15
or
123456789+0x75bcd15*0
. your thoughts?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
my function is printing a large value, possibly over many lines, or on a very long line (depending on caller's end= option). that can be a large tree of lists, tuples, and dictionaries, with leafs of whatever that might be ints. if it is an int, that is when i want to also show the hexadecimal in addition to the decimal, no matter how large the int value is. the intent is that all the output be valid Python3 source code that could be embedded in a source file to be assigned or used in line. the only way to have a function is a lambda as a leaf node. the output is one big structure.
i'm thinking about more options, such as directing the function to return a string or generate the output one unit at a time, and what base to use for ints.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
Jul-10-2019, 05:24 AM
(This post was last modified: Jul-10-2019, 05:24 AM by Skaperen.)
defining any function "somewhere else" is not a option. this function outputs the value alone, as source. it has to work with its output placed anywhere in the source code it is being inserted in. a future version will get the created source as a string, either one big string of everything, or node by node from a generator (likely only depth-first since that is how source code does it).
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
that's what i have been doing (multi-line output) up to now. but i have had cases where single line would be very useful. maybe i'll just not do the hexadecimal in the one line case. the one line case is not for human reading, anyway.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
i like it.
(366 or 'the number of days in a leap year')
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.