Share your repls and programming experiences

← Back to all posts
Inline Python Matrix Binary!
BuddyRaider (24)
hello there

Today, I challenged myself to remake a Randomized Binary print function, inspired by The Matrix!

But wait! There's more!

I did not just remake it, but I remade it in one line of Python code!

Now, I want to clarify something...

In my opinion , one liners in Python should not include any commas or semicolons, as semicolons are quite obviously cheating in Python one liners, and commas, at least, in my experience, achieve a very similar effect.

So, instead, I have to find a way to use multiple functions in one line, and to do that, I have a few different methods!

  • First of all, I default lambda attributes to functions, whether or not they return anything, for example, this:
print(lambda x = print("Hello World!"): "Bananas")())

Will print "Hello World!" and then "Bananas" (I know, it is weird)

  • My second method, which I use when I need to run a function defined in another lambda attribute, is to embed lambdas to use the parent lambda's attributes/functions, like this (I also use an inline import for this, which is very helpful):
print((lambda x = __import__("random").uniform: lambda y = x(0, 1))())

This (^) will import random.uniform() as x and then print a random float between 0 and 1 using x(0, 1)

  • Notice the print at the beginning of the previous code and how the two parentheses near the end are open, this will run the lambda when it is defined without having to set it to a variable then run it. After running, the return value of the lambda is then printed thanks to the print function enclosing the lambda! Which is very similar to this functionality:
def function(x):
	return x


Alright, I think that's about it!

Have fun watching the green binary flowing across your screen, take a look at the code in the second file ( to see the original version!

P.S. I am also releasing an Inline Calculator the same day this is coming out, you may want to check that one out as well!
edit: here is da link :P Inline Calculator
cya later!
Romulus777 (2)

Very hypnotizing...