WelcomeUser Guide
ToSPrivacyCanary
DonateBugsLicense

©2026 Poal.co

576

Turns out Python does have pass by reference, but you need to be stupidly careful with how it's implemented.

def degroup(branch, this_command): # this_command still has all the tokenizers: +, - print(this_command) to_insert = [] parent_command = this_flag = '' this_index = 0 for i, sub_flag_item in enumerate(this_command): if to_insert == [] and re.search(__FLAGS__[branch]["__REGEX__"], sub_flag_item): print(sub_flag_item) this_index = i for shorty in sub_flag_item: if shorty != '+': to_insert.append(['+' + shorty]) elif i > len(to_insert): print(f"{colorMe("ERROR", "red")}: unable to process remaining options {this_command[i:]}, not enough subflags ({this_command[0].strip('+')}) to assign to.") break elif sub_flag_item in __FLAGS__[branch]["__OPTIONS__"]: to_insert[i - (this_index + 1)].append(sub_flag_item) print("GOTTEM") else: print(f"{colorMe("ERROR", "red")}: unknown subflags {colorMe(sub_flag_item, "yellow")} for flag {colorMe(this_flag, "red")}, and command {parent_command}, skipping.") this_command[:] = to_insert

https://poal.co/static/images/2008809085858299.png

Turns out Python does have pass by reference, but you need to be stupidly careful with how it's implemented. def degroup(branch, this_command): # this_command still has all the tokenizers: +, - print(this_command) to_insert = [] parent_command = this_flag = '' this_index = 0 for i, sub_flag_item in enumerate(this_command): if to_insert == [] and re.search(__FLAGS__[branch]["__REGEX__"], sub_flag_item): print(sub_flag_item) this_index = i for shorty in sub_flag_item: if shorty != '+': to_insert.append(['+' + shorty]) elif i > len(to_insert): print(f"{colorMe("ERROR", "red")}: unable to process remaining options {this_command[i:]}, not enough subflags ({this_command[0].strip('+')}) to assign to.") break elif sub_flag_item in __FLAGS__[branch]["__OPTIONS__"]: to_insert[i - (this_index + 1)].append(sub_flag_item) print("GOTTEM") else: print(f"{colorMe("ERROR", "red")}: unknown subflags {colorMe(sub_flag_item, "yellow")} for flag {colorMe(this_flag, "red")}, and command {parent_command}, skipping.") this_command[:] = to_insert https://poal.co/static/images/2008809085858299.png

(post is archived)