Coding Global Background
Coding Global

Rate my Python codestyle

python
Archived 10 months ago
10 messages
2 members
Created a year ago
Updated a year ago
Open in Discord
R
Michael

Playing Custom Status

Script Kiddie!
I'm very used to C and C++ and code in python usually destroys my eyes.
But I found some way to return these brackets in Python. The following code was written by deepseek by my instruction, was slightly edited and wasn't tested.

import sys;
import threading;


class NoGILDemo :#
  def __init__(self) :#
    self.counter = 0;
  #;

  def increment(self) :#
  #.
    # This would be thread-safe without GIL
    for _ in range(100000) :#
      self.counter += 1;
    #;
  #;
#;


def main() :#
#.
  if (sys.version_info >= (3, 14)) :#
    print("Running Python 3.14+");
#;
  else :#
    print("Python 3.14+ required for GIL-less execution");
    return;
  #;

  demo = NoGILDemo();
  threads = [];

  for i in range(10) :#
    t = threading.Thread(target=demo.increment);
    threads.append(t);
    t.start();
  #;

  for t in threads :#
    t.join();
  #;

  print(f"Final counter value: {demo.counter}");
#;


if (__name__ == "__main__") :#
  main();
#;

Replies (10)