DEV Community

IO_Node
IO_Node

Posted on

I'm not even sorry for this

verify_params=lambda p:print("Verifying the parameters of the script...") or (lambda: [print(f"Script path: {extract_full_path('python_code_checker',p[0])}"), (lambda lp: lp==2 and (fix_path_from_param(p), (lambda f:(check_outside_cwd(f), (lambda: (f.exists() or (_ for _ in ()).throw(FileNotFoundError(f"File not found: '{p[1]}'"))), (lambda: (lambda c:(lambda: c["config"])(json.load(open(f,'r',encoding='utf-8'))))((lambda: (print('Unrecognized config filename, checking for python script instead.') or (print_analyze_menu(f) if f.parts[-1].endswith('.py') else print('Unrecognized python script file')) or json.load(open(f,'r',encoding='utf-8'))))()) ) )() )() )(extract_full_path('python_code_checker',p[1]))) or (lp==3 and print('This test only supports 1 config argument')) or (lp>3 and print('Final script only supports 2 arguments')) or (lp==1 and (print('Script executed without argument, easter egg triggered'),default_config)) or (lp==0 and print('Error: system is unable to find any active script')) or (lp>0 and default_config)])(len(p)))
Enter fullscreen mode Exit fullscreen mode

yes I figured out how to play golf in python. Enjoy this cringe-fest. 1000 lines scripts? pffft more like 1 line XD

Top comments (4)

Collapse
 
ramoyald profile image
IO_Node

I can't even read my previous comment, this appears to be a bug...

So the rules of True Evil Python Golf™ should be:

  • No intentional infinite recursion / loops / OOM spam (clogging = illegal).
  • Code must actually run correctly (however unreadable).
  • Evil = abusing syntax, annotations, lambdas, import, [-1], chained ;.
  • Bonus points: misleading type hints, fake docstrings, sneaky comments.

That way we get maximum programmer psychic damage while keeping it technically clean.

Collapse
 
ramoyald profile image
IO_Node

This will be my answer to all programmers that I meet that is not kind to me.

Eldritch Abomination Toolkit™

  1. Golf Compression
  2. Unicode Doppelgängers
  3. Shadow Imports
  4. Docstring Cloaking
  5. One-Liner Hell
  6. Deceptive Types
  7. Weaponized Code Checker Hook

💀 With these, you can now:

Take perfectly good code,
Push it through the Corruption Engine,
And unleash it onto poor, innocent programmers.

Collapse
 
ramoyald profile image
IO_Node

went a bit too far and broke it by using exotic characters XD who knew python has an allergy to Unicode

def ннGщбγOёλчёπ(нщeGcTnM, *args, keep_modules=None, **kwargs):;import sys;import gc;import types;""";Executes a heavy job function with scoped imports and cleans up afterward.;Parameters:;job_func (callable): The function representing the temporary job.;*args, **kwargs: Arguments to pass to job_func.;keep_modules (set[str]): Optional set of module names to retain.;""";if кkυTyNиλгmJв is None:;кkυTyNиλгmJв = set(sys.builtin_module_names) | {'sys', 'gc', 'types'};φGμuζθ = None;try:;φGμuζθ = нщeGcTnM(*args, **kwargs);except Exception as e:;print(f'[TempJob Warning] Exception during job: {e}');ZFαμθEаXCёI = нщeGcTnM.globals;for name in list(ZFαμθEаXCёI):;if not name.startswith('__') and name not in кkυTyNиλгmJв:;del ZFαμθEаXCёI[name];for mod in list(sys.modules):;if mod not in кkυTyNиλгmJв:;sys.modules.pop(mod, None);gc.collect();return φGμuζθ;def uρUcыmкEд():;import numpy as np;import pandas as pd;mkп = np.arange(1000000);Zпχ = pd.DataFrame({'data': mkп});return Zпχ.sum().sum();(зejъх = ннGщбγOёλчёπ(uρUcыmкEд));print('Result:', зejъх)

Collapse
 
ramoyald profile image
IO_Node

json.load(open(f,'r',encoding='utf-8'))))()) ) )() )() )

chef kiss