Posts: 4,646
Threads: 1,493
Joined: Sep 2016
i am looking for some kind of object type that can be an iterator, such as in a for loop, and can also have items added to it either on the front (do it would be the next item) or on the back (so it would be the last item) or both. that and i want to be able to do this from within the body of the for loop that is currently iterating it. adding an item would make it so that look cycles longer. anyone know?
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,646
Threads: 1,493
Joined: Sep 2016
the code i have so far uses a while loop on a list made from a string, that a uses .pop() on it to get items out and [:0] to push an item back in. it works this way but i'd rather have a for loop on a genuine iterator of some kind. making one means a lot of code to add to this project.
cntl = [x for x in cstr]
while cntl:
ch = cntl.pop(0)
if ch == endch:
cntl[:0] = [ch]
break
...
...
while cntl:
ch = cntl.pop(0)
...
in the above example, the 2nd loop sees the character that ended the first loop as its first character. the real code is much larger than this but this is basically what it does
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,646
Threads: 1,493
Joined: Sep 2016
it is interpreting the string as a (compact) specialized language
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,646
Threads: 1,493
Joined: Sep 2016
Jun-13-2019, 01:36 AM
(This post was last modified: Jun-13-2019, 01:36 AM by Skaperen.)
i am not going to post the whole code. i get people responding about all kinds of other things when i do that.
but i can tell you a little more about the program. it is sorta between the Unix
cut command and the (
g)
awk command. it is a tool to specify how to reformat columns of an input file to produce an output file with more sophistication than the
cut command but not as much as the (
g)
awk command. it uses a mini scripting language that is given to it on the
command line. i actually have 2 different ideas how to do this language and i plan to try
both to compare ease of use and performance.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.