0

I know of the shortest Python quine (shortest python quine?) but it looks like a winner of a Python obfuscation challenge. It is cryptic.

Is there a Python quine that is easy to understand for a beginner: with variables, IFs, loops, but that doesnot rely on special exotic features of Python? The one that you don't "just memorize, consider it a password", but you can actually derive?


One can use any tools from a typical "Python. One hour crash course". Nope, %s and %r doesnot belong there. While my_string.replace("foo","bar") does.

Stepan
  • 1,391
  • 18
  • 40
  • 1
    Here's a slightly de-obfuscated version. It still requires `!r` though: `magic = 'magic = {!r}; print(magic.format(magic))'; print(magic.format(magic))` – 0x5453 Sep 15 '22 at 14:19
  • haha - those are just outdated - they used to be the only way to do string formatting! but sounds like fun. you might enjoy [codegolf.se]! – Michael Delgado Sep 15 '22 at 14:28
  • @0x5453 this is still some obfuscated stuff. Looks like a password, that I have to memorize. No, I've never used `!r` in the real life. Can it be written in a human readable code? – Stepan Sep 15 '22 at 15:09
  • @michaelDelgano https://codegolf.stackexchange.com/questions/tagged/python+quine no relevant hits. – Stepan Sep 15 '22 at 15:10

1 Answers1

1

This solution abuses how lists are printed

s = ["print('s =', s, ';', s[0])"] ; print('s =', s, ';', s[0])
mhovd
  • 3,724
  • 2
  • 21
  • 47