#esoteric-python
1 messages · Page 68 of 1
oh right
is there a way I can fix that without duplicating sum(map(int,bin(i)[2:]))?
it looks like the shortest way to fix it is to use py [j%a!=0for j in[sum(map(int,bin(i)[2:]))]for a in range(2,j)]
@gilded orchid
even if I duplicate it over into that range (or copy your thing) it just outputs the numbers 1-50
1 isn't prime
3 5 6 7 9 10 11 12 13 14 17 18 19 20 21 22 24 25 26 28 31 33 34 35 36 37 38 40 41 42 44 47 48 49 50
it should be this
your prime-checking code thinks that 1 is prime
I can just adjust the first range to ignore that, cos 1 isn't a pernicious number anyware
the powers of two have exactly one 1 in them
(in binary)
so they are pernicious iff 1 is prime
but 1 isn't prime
I can just put if j!=1 at the end to counter that
print(*(x for x in range(50)if 1^all(sum(map(int,bin(x)[2:]))%i for i in range(2,x))))
is the best i could do
i hate that i can't use something clean like reduce
[print(i)for i in range(1,51)if all([j%a for j in[sum(map(int,bin(i)[2:]))]for a in range(2,j)])and~-bin(i).count('1')]```
now that I think about it, can you use bin(x).count('1') instead of sum(map(int,bin(x)[2:]))
...yes
wow I overcomplicated that
hm, you need primes?
we're doing all the pernicious numbers from 0 to 50 ('A pernicious number is a positive number where the sum of its binary expansion is a prime number.')
[print(i)for i in range(1,51)for j in[bin(i).count('1')]if all([j%a for a in range(2,j)])and~-j]```
how on earth has someone done this in 46 characters
print(*(i for i in range(1,51) if 1^all(bin(i).count('1')%a for a in range(1,i))))
shorter
fuck
(also each one needs to be on a new line)
does it have to be a single line? (the golf)
nope
Code Golf is a game designed to let you show off your code-fu by solving problems in the least number of characters.
i can get 57 hmm
Doing https://code-golf.io/quine#python sounds like a complete nightmare
Code Golf is a game designed to let you show off your code-fu by solving problems in the least number of characters.
that quine is actually kind of easy to do if you know how to do it
@gilded orchid ' "yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.' - Williard Van Orman Quine
I guess time to apply for the V'th code jam lol
I would apply but I suck at python
Hmm
I would but I'm not sure if I should since it's (as always) right in the middle of exam block
or not exam block but the period with all my assignments due
Is there a short way to remove 1 character from the end of string? (for a code golf)
I’ve thought about a challenge to write some kind of program with only two variables
couldn't you just make those variables lists, and store in your variables in those though?
lit
@gilded orchid I mean no without that things
What might be the point of appending list to itself?
nested lists are actually really useful for some things
for example, I used one in my minesweeper a while ago, with a list that had 10 more lists inside it
nested lists aren't the same as appending a list to itself
!e ```py
thing = [1, 2, 3]
thing.append(thing)
print(thing)
@brisk zenith Your eval job has completed.
[1, 2, 3, [...]]
oh nvm lol
as for appending a list to itself, i haven't yet found a practical application for it.
Really, what is the reason?
!e
thing = [1, 2, 3]
thing.append(thing)
for _ in range(100):
thing = thing[3]
print(thing)
Sorry, but you may only use this command within #bot-commands.
Was unable to replicate this using snekbox, but
interestingly enough computers in general seem to struggle with roots
if you do ^(1/3) instead of cube root in wolframalpha it will also struggle to solve some equations
print(str().join(list(map(chr, [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])))) who can make Hello World even more weird?
import string
print(string.ascii_uppercase[7])
print(string.ascii_lowercase[4])
print(string.ascii_lowercase[11])
print(string.ascii_lowercase[11])
print(string.ascii_lowercase[14])```
Too long lol
There was a one in the pins if i remember correctly
from string import ascii_letters as a; b = a + "! "; print(str().join(b[_] for _ in [33,4,11,11,14,53,48,14,17,11,3,52]))
@shut wadi improved yours I guess
from string import ascii_letters as a
def helloWorld():
b = a + "! "
return str().join(b[_] for _ in [33,4,11,11,14,53,48,14,17,11,3,52])
print(helloWorld())```
import __hello__ :^)
from __future__ import braces
The version in the pins is for 2.7, but there's a great Python 3 version of that obfuscated hello world as well
!e
(lambda _, __, ___, ____, _____, ______, _______, ________:
getattr(
__import__(True.__class__.__name__[_] + [].__class__.__name__[__]),
().__class__.__eq__.__class__.__name__[:__] +
().__iter__().__class__.__name__[_:][_____:________]
)(
_, (lambda _, __, ___: _(_, __, ___))(
lambda _, __, ___:
bytes([___ % __]) + _(_, __, ___ // __) if ___ else
(lambda: _).__code__.co_lnotab,
_ << ________,
(((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __)
- _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ <<
__) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______
<< ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) <<
((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) <<
__) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______
<< (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) +
_) << ((((___ << __) + _) << _))) + (((_______ << __) - _) <<
(((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ <<
_))) + (_____ << ______) + (_ << ___)
)
)
)(
*(lambda _, __, ___: _(_, __, ___))(
(lambda _, __, ___:
[__(___[(lambda: _).__code__.co_nlocals])] +
_(_, __, ___[(lambda _: _).__code__.co_nlocals:]) if ___ else []
),
lambda _: _.__code__.co_argcount,
(
lambda _: _,
lambda _, __: _,
lambda _, __, ___: _,
lambda _, __, ___, ____: _,
lambda _, __, ___, ____, _____: _,
lambda _, __, ___, ____, _____, ______: _,
lambda _, __, ___, ____, _____, ______, _______: _,
lambda _, __, ___, ____, _____, ______, _______, ________: _
)
)
)
@nocturne saddle Your eval job has completed.
Hello world!
What the hell LOL
Judging from the import, is that an obfuscated import of hello?
Lol
wow discord formatting is annoying
To avoid discord formatting, is that an obfuscated version of __import__(‘__hello__’)?
Hmm
I don't know, but it's repeatable and an import should only be executed once
However, there's a whole blogpost about it: https://benkurtovic.com/2014/06/01/obfuscating-hello-world.html
No, it's using another method
So it's importing os
@nocturne saddle are you satan
Well, makes me feel I need to learn python more
Actually, I’ll try to make my own one of this kind, but shorter
>>> getattr(__import__('random'),'randint')(1,10)
5
never knew you could do getattr on an import
and they used this to replace range(1,9)
why could you not "do getattr on an import"
that's like saying "never knew you could call a variable"
idk I just never thought about doing that
import inspect
a = lambda x:print('x')
print(inspect.getsource(a))
this outputs a = lambda x:print('x')
couldn't this be used for a quine?
oh wow it can
a=lambda x:x;print(__import__('inspect').getsource(a))
outputs itself
but it doesn't work on https://code-golf.io/quine#python
Code Golf is a game designed to let you show off your code-fu by solving problems in the least number of characters.
doesnt work locally for me
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/inspect.py", line 944, in getsource
lines, lnum = getsourcelines(object)
File "/usr/lib/python3.5/inspect.py", line 931, in getsourcelines
lines, lnum = findsource(object)
File "/usr/lib/python3.5/inspect.py", line 762, in findsource
raise OSError('could not get source code')
OSError: could not get source code
has to be in a file, doesn't work in interactive shell
@gilded orchid doesnt count as quine since it uses file i/o
oh rip
self.meth(x)
type(self).meth(self, x)
type(self).meth.__get__(self, type(self))(x)
type(self.meth)(type(self).meth, self)(x)
def(((((((((Function))))))))))))
i need some help
im trying to solve https://code-golf.io/divisors#python
and im stuck at
a = [[y] for x in range(1,101) for y in range(1,101) if not x%y]
@onyx jacinth there’s an answer in #bot-commands I just did but not very esoteric
thx for help but it is really not very esoteric
That gives you somewhere to start at least
shucks my first solution is 75 74
i will come back to this tomorrow
You can change if not x%y to if x%y==0 to save a character
Also you can remove the space before the if at the end
And the space before the first for
@onyx jacinth
Also can also do range(1,i) for the last range
if~(x%y)
wait no
if(x%y-1)
if x%y==0
oh well it was a thought
x can probably just be range(101) @onyx jacinth
wait, no
it says print them, how are you printing them
for x in range(1,101):print(*[y for y in range(1,101)if x%y==0])```
@gilded orchid what would i be? if it's x, the output won't include x itself, which is unclear in the spec but different from what the code is currently doing.
Oh oops
just tried it and got 59 chars
Idea for a challenge: could we have a second version of the esolang challenge, with a restriction on the syntax of the esolang?
hm
only use list comprehensions
Sorry, but you may only use this command within #bot-commands.
is this a valid way to do if/elif in one line to imitate a ternary by exploiting short circuiting:
((not <condition1>) or (<execute1> or True)) and ((not <condition2>) or (<execute2> or True)) and ((not <condition3>) or (<execute3> or True)) and ...
ie would it be equivalent to
if <condition1>:
<execute1>
elif <condition2>:
<execute2>
elif <condition3>:
<execute3>
...
and how would i implement an else condition
why not just use ternary?
ternary doesnt do elif does it
I mean, you could chain them if you want
True if condition else (True if othercondition else (...)) or something
just replace the True/False with whatever
just seems way more readable then chaining al those short circuits, less typing too
Does readability really matter in #esoteric-python though?
This is a cute way to do infinite loops: python while ...: do_something()
well you said "less typing too"
oh, I did
@snow beacon cute but not the shortest.
while 1:
do_something()
>>> a=[];a.append(a);print(a)
[[...]]```
>>> ...
Ellipsis
What does ... actually do?
not much on its own, it's just a singleton like None and the booleans. it's used often in numpy though.
yup
so it just recieves everything? or just gives you an error?
a = []; a.append(a)
for i in range(1000):
a = a[0]
print(a)
>>> [[...]]
It is just a in a, so each a in a also contains a
If that makes sense
in the representation of lists, [...] represents a copy of the entire list
>>> a = []
>>> a.append(1)
>>> a.append(a)
>>> a.append(2)
>>> a
[1, [...], 2]```
yeah, yeah
that 1st (from 0) element, [...], represents a
but this thing is pretty much a, which contains a and so on
yeah
@sick hound but what can be the point of having a in a? Like, if you edit a, a in it will also change
So ... is a reference to Ellipsis, and Ellipsis can be assigned, whilst ... can't
>>> Ellipsis = 42
>>> ... is Ellipsis
False
wouldn't ... be 42 if it's a reference?
Hm
... isn't a reference to Ellipsis
... is a reference to an internally stored ellipsis object
Ellipsis is also a reference to that object
^
because syntax
actually
... is a LOAD_CONST
it's like 5
x = 5```
you can assign x
but you can't assign 5
how come 5 can't be assigned then? if they're both pointing to the same object
>>> __builtins__.Ellipsis
Ellipsis```
Ellipsis is just in __builtins__
like print
>>> print = 42
>>> print
42```
you actually can reassign ... if you use ctypes
>>> ...
None```
but it's not None ```py
... is None
False```
you can even flip it around and turn None into Ellipsis ```py
print(None)
Ellipsis```
ctypes is fun
I just realised you could probably use memmove and memset to make your programme ridiculously obfuscated
>>> _.value
KeyError: 'unknown symbol table entry'```
that might be the most bizarre error I've ever seen
>>> 7<<(7<<60)
Traceback (most recent call last):
File "<console>", line 1, in <module>
MemoryError
>>> 9<<(9<<99)
Traceback (most recent call last):
File "<console>", line 1, in <module>
OverflowError: too many digits in integer
🤔
Why is the last one causing OverflowError and not MemoryError?
>>> 9<<(9<<99)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t```
the number is too large to get converted to a normal C number
7<<60 can be converted into a C number
but it's still ridiculously large ```py
7<<60
8070450532247928832```
@marsh void 7<<60 can be converted to a C integer, 7<<(7<<60) is far bigger than the number of atoms in the universe
the biggest number that you can put in a C ssize_t is 9223372036854775807
>>> 2<<9223372036854775807
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
MemoryError
>>> 2<<9223372036854775808
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t```
9<<99 is 5704427701027032306735164424192, which is too big. python can't even start doing 9<<5704427701027032306735164424192
but it can try 7<<8070450532247928832, it just runs out of memory before it can finish
Okay gotcha, thanks for explaining
huh, but internally Python can handle much larger ints than 9223372036854775807. Is this only because of the << bitshift operator which is probably implemented in C?
yeah, python can literally handle 2**90000
@tropic gulch python's long types are essentially stored as arrays of C integers. when the size of this array of integers becomes larger than can be represented by the Py_ssize_t which stores the length of this array, that becomes a problem.
ah, cool
so it's not that 9223372036854775808 is too big for python integers, it's that the size of the array of integers needed to represent 2 << 9223372036854775808 is too big.
that's what i imagine it is, at least.
...Oh
that makes sense
...except for the fact that it's wrong ```py
4<<9223372036854775807
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
MemoryError
2<<9223372036854775808
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t```
>>> 1024<<9223372036854775807
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
MemoryError
>>> 1024<<9223372036854775808
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t```
@brisk zenith
i'm guessing it's just << trying to put the second number into an ssize_t
hmm fair.
so like... i haven't been able to write this in a version of python < 3.8 yet...
fn = lambda: (a := lambda: a)```
Out[43]: False```
it's making new lambdas every time you call it
verified by poking at them with hash()
what about x = fn(); x()()() is x()()()
>>> fn=(lambda x:x(x))(lambda x:lambda:x(x))```
@unique kettle
works in any python version with lambda, and it makes a new lambda every call
also LOL ```py
0<<9223372036854775807
0
0<<9223372036854775808
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t```
@sick hound i finally got that syntax into something readable... ```python
def a(x):
return x(x)
def b(x):
def c():
return x(x)
return c
fn = a(b)
but yeah it does behave as claimed
Wait, := was approved for 3.8?
Honestly it would make more sense to just make = an expression
And a=b=1 becomes a=(b=1) internally
yeah it was
a=b=1 already works?
@desert garden thats not how chained assignments work in cpython, at least not yet
>>> dis.dis('a = b = c = d = 1')
1 0 LOAD_CONST 0 (1)
2 DUP_TOP
4 STORE_NAME 0 (a)
6 DUP_TOP
8 STORE_NAME 1 (b)
10 DUP_TOP
12 STORE_NAME 2 (c)
14 STORE_NAME 3 (d)
16 LOAD_CONST 1 (None)
18 RETURN_VALUE
>>>
which causes issues when you try to do stuff like this:
>>> k = {}
>>> original_k = k
>>> k = k['test'] = [1,2,3]
Traceback (most recent call last):
File "<pyshell#92>", line 1, in <module>
k = k['test'] = [1,2,3]
TypeError: list indices must be integers or slices, not str
>>> k
[1, 2, 3]
>>> original_k
{}
>>>
basically assignment has no conventional kind of associativity
Yeah I know how the currently work
But a = (b = 1) would be a nicer way to do it
And would also mean you didn't need to add :=
Because unless I'm mistaken, we could a := (b := 1) and just replace every single occurance of = with := and nothing would change
nah, can't do stuff like a[thing] := thing
no subscripts allowed it seems
oh, and you cant use it with attributes either
>>> ((a, b) := (1, 2))
SyntaxError: cannot use named assignment with tuple
>>>
lol
@desert garden the pep states that's sorta a side effect of the syntax
It's not supposed to be used that way
It's for setting the values in for loops /similar expressions
Unless I'm not getting what your meaning in the way it's meant to be used?
Also that
I know what it's meant to do, but I just feel it'd be simpler, and kill two birds with one stone, to just make a=b an expression that evaluates to b
Maybe
Lots of programming languages do it like that.
(I can't name any, but I'm confident they exist.)
C
the side effect of doing that would be that if a = b: ... would become valid, when it's definitely a mistake people make now. that seems bad.
yes
one of the reasons they decided to not turn the current assignment into an expression
golfers everywhere probably wish it was = and not := too
damn that extra byte! 😂
@unique kettle what's that syntax
@grave rover the thing posted just before me: fn=(lambda x:x(x))(lambda x:lambda:x(x))
Sorry, but you may only use this command within #bot-commands.
It wasn't so much AE in itself, but the stress that came from the social media debates surrounding it
What're AEs?
Assignment Expressions
Ooh walrus?
!pep 572
yep
Thanks!
Sorry, but you may only use this command within #bot-commands.
challenge 09 has arrived: lolcat!
to stick with the ongoing pride event this month, we have a rainbow-themed challenge for you today! this time, you will be recreating lolcat, a simple little program that some of you may know already. don't worry if you don't though, further details and an example can be found on the repo as always :D the task will be focused on golfing, but other interesting solutions are encouraged as well.
https://github.com/python-discord/esoteric-python-challenges/tree/master/challenges/09-lolcat
hopefully we'll get some submissions this time round. :D
@brisk zenith so our task is to write code that makes the output rainbow-colored?
oh shit I had code for this
the task is to print the contents of a file but make it rainbow in the process
but it's on my friend's SSD
first attempt, straight vertical gradient and file input only
most of these agonizing 290 bytes are hsv2rgb conversion, though I could probably simplify that a lot if I modify the formula to assume constant s and v (which I do right now anyway)
Okay printing contents of a file or text (which is kinda pre-defined I’d say) would be not too hard imo
I need to remember how coloring in the terminal works since I am less used to linux because haven’t used it for a long time
https://en.wikipedia.org/wiki/ANSI_escape_code
The ones you most likely want to use are CSI (n) m coupled with the Colors section
Ava is an Xpert 
If instead of 8+8 colours you want to use 256-colour pallette you can use CSI 38;5;#COLOUR m
Yes I spent roughly twenty hours creating stupid applications abusing ANSI escape sequences
very expert
The 256-colour pallette uses the formula 16 + 36 * r + 6 * g + b
e.g. \33[38;5;248m
You can also use true RGB by doing CSI 38;2;(r);(g);(b) m
where each value r, g, b is in the range [0, 255]
Make a lib for it
So you basically have 3 options
8+8, 256 and true colour
True RGB support might be scarce though
I googled around it looks like most modern terminal emulators support true colour
more advanced version, with finer, diagonal gradients and optionally a single file argument or stdin as input
even managed to hit a nice and fitting fortune as showcase 😄
ooh spicy
sl | lolcat --seed 1 -a
@tropic gulch really cool! though, really long lines look quite weird tho(in output)
Well yeah, it does not determine your terminal width to insert additional line breaks for wrapping, and to adjust colors based on that
But that would be waaay out of scope, I think
lolcat doesn't do that either
You could pipe your input through fold -w $COLUMNS first to wrap lines around at the width of your terminal before coloring
Yeah
@tropic gulch is your solution already good for merging, or are you still working on it?
I'm done.
Could have added support for concatenating multiple input files, but... meh
maybe some other time.
i'll merge it in now then. if you want to go back and make any changes, just open a new PR :D

probably less, didn't examine the converted numbers
no it's not
Hue is measured in degrees
360 degrees in a circle
actually i'd prefer if you used 2π colours, disappointing :^)
😛
not using radians
don't you mean one Tau?
it needs a terminal capable of interpreting ANSI escapes and supporting 24bit color
i.e. not cmd.exe
can confirm it works in my terminal (termite)

but my terminal emulator doesn't have truecolor
so it doesn't work
sorry
e.g.
lol
which do you use?
i.e. would be the correct one
gnome-terminal and xterm work
I always thought i.e. is for if you're giving every example
i.e. basically means in other words
and e.g. is for if you're giving some
cmd.exe is not the only terminal that doesn't have truecolor
I don't think xterm has truecolor
it pretends it does but converts to 256color
ye that's what I thought
what the fuck is this preview image
reminds me of that dumb joke in the emoji movie
the challenges here are far less strict than PPCG's
well, it's more about the fun and creativity here than about hard byte scoring
well yeah, this is just a bit of fun and creativity.
heck
stop stealing my words
those were my words

stop having fun
i mean, you could post a hilariously long solution to a code golf challenge for all i care, as long as it's creative and interesting. like my tic-tac-toe script which was over 400MB and segfaulted the interpreter. that was nice.
yeah the requirement is to have fun while being creative and unique
seems pretty reasonable to me :D
that's not observable
04f8281 Create raincat1.py - ByteCommander
570679d Create raincat2.py - ByteCommander
7310304 Add files via upload - ByteCommander
e956747 Create readme.md - ByteCommander
021749d merge byte's solution to challenge 09 - kingdom5500
import sys;print(open(sys.argv[1]).read()) here's your cat by the way, it works on terminals that support 1 colour
now add rainbow
LOL
how do you make the colours small..?
it's a small rainbow
it consists of 1 colour
it is a list of colours comprised of 1
on a cycle
prove me wrong
Mate, just go make a normal rainbow xd
@frank hazel google said so, so you're wrong
"generally said to be"
shush, this channel has been thrown wayyyyy off the rails. i think we should stop before lemon throws us off the rails.
yeah we should tbh
it's not an off-topic channel.
the topical channels are also not
^
why is this special and not topical
Same, I don’t get what you’re saying lol
i'm not too sure actually. it just is.
why isnt it topical?
exactly
lyricly's referring to the channel categories
i think it's because #esoteric-python is different from the other channels. this is entirely recreational, and we wouldn't want people picking up bad habits from here. mixing it in with the topical channels would likely cause problems.
that's my take on it at least, but if you want a definite answer, ask in #community-meta
making languages look like other languages is always fun
it's TOPICAL CHAT/HELP
I almost made it so you can run BF in Python with only +-[]><,._
#esoteric-python helps nobody 
yeah there's no help here
but the problem is chaining
and < chain
and you can't get around it
so if you try to write like
_>_>_
it chains and you can't overload and
so there's nothing you can do
to take that over
you could overload __bool__ somehow
but doing it properly would be tricky, if not impossible
yeah I don't think it can be done
well, actually
it's easy if you use globals but that's no fun
Maybe if you had the bytecode...
For some strange reason I really want to write a python bytecode interpreter in python
absolutely pointless but it's basically a solution to number 8
it's sorta the same with the AST except AST is a slightly higher level
I’m kind of tempted to golf a brainfuck interpreter, and then right a programme in brainfuck that ‘rainbowfies’ the input given
would that be a valid solution?
I'm sure it would be.
@sick hound it's very much not pointless
i've been doing the same in another language and it's a great learning experience
if you do id recommend forking and downloading the cpython source from the repo then opening it in Visual Studio or some other IDE/editor so you can find the C++ implementations for each opcode, as examples to work off of
theyre in ceval.c https://github.com/python/cpython/blob/master/Python/ceval.c
you can search that page by itself but sometimes youll have to chase down some other implementation details elsewhere in the source and having the files open in an IDE helps with that
oh also i have a little gui project for quickly seeing the dis output of some code https://github.com/0xf0f/dis-tester
helped speed things up a lot
C++?
I thought Python was C?
Yeah same
But yeah it's probaby not pointless
It's just a lot of time that I don't have
github confirms
(github thinks .h files are cpp, ignore that)
my mistake then
What is M4? 
though c is a subset of c++ so they could technically be mixing them
g++ can compile both
not sure
clicking on it yields no results
oh actually im not sure what theyre using to compile them
I don't think C is really that interoperable with C++
wikipedia agrees
depends on what youre doing i guess
@marsh void it's a dependency of autoconf: https://en.wikipedia.org/wiki/M4_(computer_language)
m4 is a general-purpose macro processor included in all UNIX-like operating systems, and is a component of the POSIX standard.
The language was designed by Brian Kernighan and Dennis Ritchie for the original versions of UNIX. It is an extension of an earlier macro processor m...
oh ok
(C)Python written in C
The total LoC in python files are greater than LoC in C because
All of the tests written in python, most of the stdlib and tools like argument clinic that doesn't affect usage
the core part is located in Python/ directory.
also you can compile python in a c++ compile
because all of code has extend c {}
type() isn’t classified as a built-in function?
Neither are these
🤔
And only type is actually class type?? 
@last locust yup. things like int and str are types. for example, an object can be an int type or a str type, but not a print type. similarly, type is also a type; it creates other types/classes, and is therefore a metaclass. when you do py class Thing: ...
an instance of the type type is implicitly created.
Why does the second time-out?
run it on your own machine, print x in the loop and see?
On phone
That’s why I’m using the bot :p
But x is just [[...]]
So not quite sure why it’s timing out...
for every iteration you're adding a new item into the list, so you'll never reach the end of the list like that.
And this? This is adding to a[i] not a
>>> a = []
>>> a.append(a)
>>> a
[[...]]
>>> a[0].append(a)
>>> a
[[...], [...]]
>>> a[0] is a
True
>>>
a = [[...], [...]] and a[0] is [...]?
[...] is just python's way of saying "oh hey this list contains itself, let's avoid infinite nesting here"
otherwise you'd get [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ ... ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
forever, and would ultimately crash python. which is what happened in python 2, actually.
🤔
I’m so confused though
if you add [] to [] it becomes [[]]?
Yea, so why doesn’t a.append(a) work the same when a is []
yes, but that's not exactly how lists work in python. if they weren't the same list, that would happen. for example:
!e ```py
a = []
b = [] # this is a new, different list
a.append(b)
print(a)
c = []
c.append(c) # this is adding the same list to itself. so it becomes a list that contains itself, which is a list that contains itself, which is a list that contains itself... and so on.
print(c)
@brisk zenith Your eval job has completed.
001 | [[]]
002 | [[...]]
i can make a diagram for it, hold on. :D
# this is adding the same list to itself. so it becomes a list that contains itself, which is a list that contains itself, which is a list that contains itself... and so on.
Did you just kill the universe?
perhaps not haha
sure it is, give me a moment and i'll clear it up a bit
Surely because a = [] it should be the same as a.append([])?
nope
because the [] in a.append([]) is a different list in memory to a
it's the same as a, sure, but it's not the exact same object
So it doesn’t get the actual value?
Say, you use the analogy of a list being a container, say a box you can put things in. In the first example above, you're just putting one box inside of another box. Two different boxes.
In the second example, you're putting the SAME box inside of the SAME box
>>> a = []
>>> a.append(a)
>>> a
[[...]]
>>> a[0]
[[...]]
>>> a[0][0]
[[...]]
>>> a is a[0]
True
>>> a[0] is a[0][0]
True
So... to get around that you’d have to do something like this?
depends on what you want to achieve
Well, the empty list you've put in a is now in two positions
>>> a = []
>>> a.append([])
>>> a
[[]]
>>> a.append(a[0])
>>> a
[[], []]
>>> a[0].append(5)
>>> a
[[5], [5]]
Say something like this... would each element of a now contain 1?
@nocturne saddle Your eval job has completed.
[1]
So like a[0] is a[1] and a[0] is a[1][0] which is a[1][0][0]?
>>> a = []
>>> a.append([1])
>>> a
[[1]]
>>> a.append(a)
>>> a
[[1], [...]]
>>> a[0]
[1]
>>> a[1]
[[1], [...]]
>>> a[1][0]
[1]
>>> a[1][1]
[[1], [...]]
a[0] is just refering to another list, another container: [1]
a[0] is [1], a[1] is a
a[1] refers to the whole of a itself, like a Droste image
If you take the speaker on the left to be [1] and the tv to be a itself, you get the idea
Each nesting has first a reference to [1] and then a reference to the whole thing again
Making an infinite recursion into the depths of infinity
So a[0] != a[1] but a[0] == a[1][0]?
is actually
^^
not just a[0] == a[1][0], a[0] is a[1][0]
It's refering to the same list of [1]
Yea I know it’s is just easier to type == lol
!e
a = []
a.append([1])
a.append(a)
print(id(a[0]))
print(id(a[1][0]))
@nocturne saddle Your eval job has completed.
001 | 140422767086088
002 | 140422767086088
And then a[0] is a[1][0][0]?
a[1][1][0]
the first index will always point to [1], the second index will always point to the original list
At least I understand that
Lol what are ya doin? sounds like my nickname started it
^^ lol
I think I’ve finally understood this
But if you have like a=[[1,2,3]] then you do a.append(a) is a[1][0] going to be [1,2,3]?
And a[1][1][0] would be as well?
yap
This is so god damn confusing lol
Yeah lol
But I think I finally got it
well, in my example: a contains a, so when you do a[0] python says: well, it’s the same list, so it contains a too
Yeah... I think I get this
And well, if you wanna get a copy of list elements, you can do:
a = [1,2,3]
a.extend(a) # or a += a
or a.append(a.copy())
something along those lines
Anyway I just spent all my lunch break doing this so got to go now :p thanks for helping me with this lol
lol
also, to get n copies, you can do:
a = [1,2,3]
a*=n # n is integer, that you needa define
@brisk zenith where have you got this cool .append() explanation in picture? scroll up a bit
Ok thanks for sharing
not esoteric enough
How can I make subclass of a tuple that takes *args on __init__? How am I gonna do super().__init__()?
example?
class ntuple(tuple):
def __init__(self, *args):
super().__init__(args) # throws an error if I remember
oh, I meant tuple
Yeah, tuple throws TypeError: tuple expected at most 1 arguments, got 3
@brisk zenith whatcha think?
I wish to be able to do ntuple(1,2,3) for example
Oh, I should get to help channel I guess 😂
@marsh void i think you need to override __new__ for built-in types, not __init__.
It works for me
>>> class n(tuple):
... def __init_(self, *args):
... super().__init__(args)
...
>>> n((1,2,3))
(1, 2, 3)
Lol
:(
>>> class ntuple(tuple):
... def __new__(cls, *args):
... return super().__new__(cls, args)
...
>>> x = ntuple(1, 2, 3)
>>> x
(1, 2, 3)
>>> type(x)
<class '__main__.ntuple'>
>>>
as i said, override __new__
Okay cool
Should I do the same for nlist? Or just override __init__? (It works with overriding init)
i'm not sure.
Just like, I guess I should stick to one style
You can use https://docs.python.org/3/library/collections.html#collections.UserList for subclassing lists instead of subclassing the built-in
Awww collections
Why not subclassing built-in though? Are there real problems with it? (It’s ok, I’m just curious)
it's generally trickier to work with
using a UserList makes your code cleaner
and easier to maintain and all that stuff
Oki
class IndexRegister:
def __index__(self, target: list):
class RegisterMetaClass(type):
def __new__(mcs, *args):
obj = type.__new__(mcs, *args)
target.append(obj)
return obj
return RegisterMetaClass
RegisterMeta = IndexRegister()
# Usage
all_things = []
class A(metaclass=RegisterMeta[all_things]):
...
class B(A):
...
class C(metaclass=RegisterMeta[all_things]):
...
print(all_things) # => [<class '__main__.A'>, <class '__main__.B'>, <class '__main__.C'>]
I was gonna say why not a class deco but then I realised this is #esoteric-python
well, if you're enforcing a specific base class this might be really useful
Since subclasses don't automatically call the parent decorator but a metaclass works at all times
I personally use this concept in some of my projects
All I have to do is make sure the module is imported and I can use it whenever
The check to see if it can convert to an int goes beyond what it actually shows in the error? 🤔
Or it just doesn’t check that far and raises the error... since this should work
not sure if int can convert string floats
Oof you’re right
Use int(float("1.0"))
a = []
a.append(a)
a
[[...]]
How do you do from x import y in terms of __import__?
Trying to figure out if there’s a neater way to do the imports on py salt = str(__import__('uuid').uuid4()); print(__import__('hashlib').sha512((input("Enter Pass")+salt).encode()).hexdigest(), salt, sep="\n\n")
i=__import__
also no you can't really do from x import y in terms of __import__ on it's own
@wind maple what do you mean by i=__import__?
you can assign it like that to shorten the code
ye
Thanks, didn’t think of that xD
how do yall do python so good
i have a huge interest in coding but im not good at it
im trynna learn
read lots of code from other people
you'll start recognizing patterns
saying you "learnt python in a week or two" is silly. python has so many things to learn that i'd say it's impossible to "learn it" in even a few years.
I learnt the basics
That’s what I meant
Loops, functions, data types, libraries, json, csv e.t.c
Probably more things I’m forgetting right now
Oh yeah classes
You know more than I do then
So can you explain juan's hello world program?
The one with all the shifts
ah that one. it's pretty cool
The one with the empty lists converted via bool to zeros?
and/or 1s depending on the context
well that's one version of it, sure.
!e ```py
print(bytes([((not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))^(not[])<<((not[])<<(not[])^(not[])<<((not[])<<(not[])))), ((not[])^(not[])<<((not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))^(not[])<<((not[])<<(not[])^(not[])<<((not[])<<(not[])))), ((not[])<<((not[])<<(not[]))^(not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))^(not[])<<((not[])<<(not[])^(not[])<<((not[])<<(not[])))), ((not[])<<((not[])<<(not[]))^(not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))^(not[])<<((not[])<<(not[])^(not[])<<((not[])<<(not[])))), ((not[])^(not[])<<(not[])^(not[])<<((not[])<<(not[]))^(not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))^(not[])<<((not[])<<(not[])^(not[])<<((not[])<<(not[])))), ((not[])<<((not[])^(not[])<<((not[])<<(not[])))), ((not[])<<(not[])^(not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])<<((not[])<<(not[])))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))), ((not[])^(not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[]))))]).decode())
@brisk zenith Your eval job has completed.
hello :)
Yeah, that one
what on earth
Juanita isn't on earth sadly.
yeah for sure
They look down upon us from the great outdoors.
i think i understand it, but i don't like it
You can make it a bit easier to comprehend by not using the bytes and decode in there
how do you mean? like, just making individual integers?
!e
print(*(chr(n) for n in [((not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))^(not[])<<((not[])<<(not[])^(not[])<<((not[])<<(not[])))), ((not[])^(not[])<<((not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))^(not[])<<((not[])<<(not[])^(not[])<<((not[])<<(not[])))), ((not[])<<((not[])<<(not[]))^(not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))^(not[])<<((not[])<<(not[])^(not[])<<((not[])<<(not[])))), ((not[])<<((not[])<<(not[]))^(not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))^(not[])<<((not[])<<(not[])^(not[])<<((not[])<<(not[])))), ((not[])^(not[])<<(not[])^(not[])<<((not[])<<(not[]))^(not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))^(not[])<<((not[])<<(not[])^(not[])<<((not[])<<(not[])))), ((not[])<<((not[])^(not[])<<((not[])<<(not[])))), ((not[])<<(not[])^(not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])<<((not[])<<(not[])))^(not[])<<((not[])^(not[])<<((not[])<<(not[])))), ((not[])^(not[])<<((not[])^(not[])<<(not[]))^(not[])<<((not[])^(not[])<<((not[])<<(not[]))))]), sep="")
@nocturne saddle Your eval job has completed.
hello :)
oh i see
the sep in there is just ugly
But I like the bytes version better
If you want to obfuscate, that's better
i do want to make more interesting ways of obfuscating things.
inb4 juan becomes a core developer to add functionality that secretly allows them to golf more
haha i wouldn't
(but i guess that's what i would say, isn't it?)
i mean, it's possible to make any string using that method without using a list of codepoints @nocturne saddle it just gets very very very long for most strings.
I mean it's not like core devs get magic veto powers
Could alreadly just PR something like that
Don't we :(
They'll make something like jsfuck possible in python.
i'm trying to make a way of obfuscating any string in such a way that it only takes two different characters to represent everything, but it requires some nasty ctypes stuff. i think it'll be cool if i can get it working though
eh 🤔
!eval ```py
from ctypes import *
print(cast(pointer(ARRAY(3, c_longlong)(7596287720685593975, 8314039776092037230, 495958581792)), POINTER(ARRAY(24, c_char)))[0][:21].decode())
@vague gust Your eval job has completed.
we cookin on gas boys
Is there a way to make any number only using the characters ()<1?
(using left bitshifts)
I feel like ^ might be required but I'm not sure
@vague gust isn't that just a union without the union? 

i have done a bad thing ```py
print([][::][::[]][:[]:[]][[]]) # prints 11
can make any number up to 255, which means that all strings should be possible with a bit of fiddling
print(bytes([[][[]:[]:][[]::[]][:[]:[]][[]],[][[]:[]:][[]::[]][:[]:[]][::][[]],[][[]:[]:][[]::[]][[]::][:[]:[]][::][[]],[][[]:[]:][[]::[]][::][[]]]).decode())
will output "hiya"
whichever you want :D
i would have done "hello world" but i haven't made anything to generate these strings automatically yet
Is it easily chainable?
yeah
Ah so making a generator will be ez

take my original example: ```py
print([][::][::[]][:[]:[]][[]])
which prints `11`
This isn't default behaviour right? You've modified something?
well yeah, i've replaced the pointer to list.__getitem__
using ctypes of course
i'll try to think of interesting ways to obfuscate without use of anything like ctypes though
In your hiya example did you wrap it in a list just so you could convert to bytes or something
yeah
but there were four different numbers
representing the ascii codepoint of each character
yep.
and i always end with [[]] as an implementation detail, but it has no significance in terms of the value of the number
I am gonna be boring and give up
I tried to see if there was a correlation between binary representation of numbers and the slices but couldn't really figure it out
basically, the slices represent a binary number,
[::] is 0b000
[:[]:] is 0b010
[[]:[]:] is 0b110
and so on.
then, these binary numbers (which can go from 0 to 7) are used as powers of 2. so, with [:[]:[]] i would get 0b011 which is just 3, so the number would become 2³ which is 8. so that means i can make any binary number from 1 (which is 2¹) to 128 (which is 2⁷). then i can chain these numbers together to make any number like you would with regular binary.
[][::][::[]][:[]:[]][[]] is simply [::] + [::[]] + [:[]:[]],
which becomes, 0b000 (0) and 0b001 (1) and0b011 (3),
which then becomes 2⁰ + 2¹ + 2³, or just 11
ah I didn't think of using powers of 2
I was thkining of it sequentially
But it makes sense programtically that you'd use powers of 2
cause you can't just squish two halfs of a binary number together
I was considering endianness too lol
oh haha fair enough
here's a nice diagram for it to make up for my bad explanation :D
I understood as soon as your said powers of 2 so it's fine
oh haha nice. but it's there in case anybody else is lurking, then. :D
yeah i know, as i said i had to do some ctypes stuff beforehand to make it work
but my code is really weird and won't work properly so i'll sort it out tomorrow
Hey peeps I need some code for a unittest that will use up a lot of memory in under 2 seconds
The basic stuff I could think of will time out before it runs out of memory
"a lot" of memory is specifically more than 52428800 bytes
Ok well I decided to just look it up but if you come up with something fun then I can use that instead
Here's a question: Is there a way to exceed memory limits while avoiding MemoryError being raised?
Like disabling the mechanism for that and just letting it crash and burn

I can clarify. I need Python to exceed a memory limit set by a cgroup. The process should get killed by something else but Python kills itself beforehand
oh that explains why i got a TypeError on that slice thingy
Thanks for trying
I guess crash and burn was a bit further than what I actually had in mind
@whole kiln load a hella lot of cython modules, they crunch RAM
>>> f = -0.
>>> f
-0.0
>>> f + 0
0.0```
yay, weird float edge cases
>>> f = 0.
>>> f
0.0
>>> f - 0
0.0``` in a way this is consistent but in another way it's not
wtf floats
why is this the case?
>>> float('inf') - float('inf')
nan
>>>
What would you expect it to put out?
0
That's not how infinity works
I'd say it'd either be negative infinity or infinity, but even then both are technically wrong
It's undefined so give the number mandated by the standard for that
Then again 0 ** 0 is 1 🤔
i guess because those are integers and there's nothing in python for undefined integers? but i guess an error could be thrown or something
The most common possibilities are 1 or leaving the expression undefined, with justifications existing for each, depending on context. In algebra, combinatorics, or set theory, the generally agreed upon value is 00 = 1, whereas in mathematical analysis, the expression is generally left undefined. Computer programs also have differing ways of handling this expression.
is there a way around this? ```py
exec("stuff") # fine
exec("stuff;exec('stuff')") # fine
exec("stuff;exec('stuff;exec in here?')")
what about even higher levels of exec?```
you can use \s
exec("stuff;exec('stuff;exec(\"hello\")')")```
a \ before a character like ' (or \) tells python "ignore anything special about this character, it's just an actual character, nothing else"
a \ before a normal character like a or x tells python "this isn't an actual character, this is something else"
yes
n is just n
\n is a newline
" ends the string (if the string began with ")
\" is just "
\\ is just \
does that work for even more sublevels of exec?
or does it become \\" then \\\" etc
it should work if you add more backslashes
but i'm not entirely sure how many backslashes you'd need
and it's kind of a bit weird
perfect thanks :p
you don't need to worry about getting exactly the right number of backslashes
the python REPL can tell you
thanks 😄
>>> input()
aaaaaaa
'aaaaaaa'
>>> input()
bbbbbbb; exec('aaaaaaa')
"bbbbbbb; exec('aaaaaaa')"
>>> input()
ccccccc; exec("bbbbbbb; exec('aaaaaaa')")
'ccccccc; exec("bbbbbbb; exec(\'aaaaaaa\')")'
>>> input()
ddddddd; exec('ccccccc; exec("bbbbbbb; exec(\'aaaaaaa\')")')
'ddddddd; exec(\'ccccccc; exec("bbbbbbb; exec(\\\'aaaaaaa\\\')")\')'```
if you use input() and enter some stuff, what it prints will be the representation of that stuff, which you can then put back into code and it will be a properly \d string
ooh cool thanks
another question about this, im a bit lost. why does this give me EOL while scanning string literal? py exec('x="\n"')
wait yeah you're right
ahh ok
thanks
i keep forgetting its a string so it interprets \n and stuff before interprets the code itsself :P
Sorry, but you may only use this command within #bot-commands.
I was just about to create a stack-based brainfuck for the esolang challenge, but I just discovered it already existed (https://esolangs.org/wiki/Stacked_Brainfuck)
rip
Very brainf*cking tho
I'm writing a subleq interpreter
Sort of.
I figured it would be easy to golf the subleq interpreter, even if the subleq program itself has to be hellishly lengthy.
Quiz time: Without checking, what is the effect of the following blocks? python a = [] a[0] = [1, 2]
a = []
a[0:0] = [1, 2]```
```python
a = []
a[::] = [1, 2]```
my guess was error, error, error
- raise IndexError
- do nothing (a = [])
- a = [1, 2]
I thought: [[1, 2]], [1, 2], [1, 2]
- raise IndexError
- a = [1, 2]
- a = [1, 2]
Surprisingly, a[0:0] = [1, 2] works 
I thought it would do nothing, so opened idle to check that
>>> a = []
>>> a[0:0] = [1, 2]
>>> a
[1, 2]
The 0 slice prepends. Makes sense that way
Whereas just the colons replaces all previous values
But what if a is already initialized
Like, with some values
Huh, I guess it makes sense it still prepends
>>> a = list('xyz')
>>> a
['x', 'y', 'z']
>>> a[0:0] = [1,2]
>>> a
[1, 2, 'x', 'y', 'z']

wait of course it does
Wait
>>> a = list(range(10))
>>> a
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> a[3:6] = list(range(10,15))
>>> a
[0, 1, 2, 10, 11, 12, 13, 14, 6, 7, 8, 9]``` this feels so broken wtf
Lol
@grave rover
Why list(range(x))? Not esoteric at all.
a = [*range(10)]
much better 😂
@sick hound of course

assignment expressions make do while loops available, correct?
user_input = input("\"quit\" to quit")
while user_input != "quit":
...
user_input = input("\"quit\" to quit ")
vs
while (user_input := input("\"quit\" to quit ")) != "quit":
...
user_input = input("\"quit\" to quit ")
A do while checks the condition after executing the code in the block. So the code block always get's executed at least once. Even with assignments that will not always be the case with a while loop.
Assignment let's you make the same old while loop but without the priming statement on the previous line.
there's loads of do ... while(0) in the python interpreter source code. i sorta understand why, but it just feels weird that it has to be done that way. but that's C, not python.
Yep
Well it's like not having the loop. You'll still execute all the code in the loop once.
I think it allows them to skip any following code and jump to the end of the loop using break or continue.
oh, that kind of makes sense actually
do{
do_a_thing();
break;
dont_do_this();
} while(0)
Yep just tested it in JS, ends the loop execution. Pretty clever.
but it's C so they could just use goto or whatever
Yeah but goto is so 1980s lol
i think they use do while(0) in macros because macros can only contain one block or statement or whatever
and goto is used quite a lot in the cpython source code too
not loads and loads, but you'll notice it in places when looking through it
such as in ceval.c or something like that.
or it might be the bytecode compiler or something
just to name one example
just to name one example that I can't remember
so wait
continue in a do while doesnt check the condition?
oh nvm i misunderstood
you’re here too? @sick hound
def run(code, inp=''):
codePos = 0
pos = 0
cells = [0]
cellPos = 0
indentations = []
while True:
if code[codePos]=='[':
if cells[cellPos] == '0':
while code[codePos]!=']':
codePos += 1
codePos += 1
else:
indentations.append(cellPos)
elif code[codePos]==']':
codePos = indentations[-1]
del(indentations[-1])
elif code[codePos]=='>':
try:
cellPos += 1
cells[cellPos]
except IndexError:
cells.append(0)
elif code[cellPos]=='<':
cellPos -= 1
elif code[cellPos]=='+':
cells[cellPos] += 1
elif code[cellPos]=='-':
cells[cellPos] -= 1
elif code[codePos]=='.':
print(chr(cells[cellPos]),end='')
elif code[codePos]==',':
cells[cellPos] = ord(inp[0])
del(inp[0])
else:
continue
I'm trying to make a brainfuck interpreter, but this isn't doing anything. Any clue why?
(note that it doesn't raise an error, it just halts forever doing nothing)
nvm, turns out I just needed to add codePos += 1 at the end
Lol
It happens when you forget to put something like incrementing variable and then think why the hell nothing is working
it looks like your loops aren't quite going to work @gilded orchid
you never actually jump backwards to the beginning of the loop
def run(code, inp=''):
codePos = 0
pos = 0
cells = [0]
cellPos = 0
indentations = []
while True:
if code[codePos]=='[':
if cells[cellPos] == '0':
while code[codePos]!=']':
codePos += 1
codePos+=1
else:
indentations.append(cellPos)
elif code[codePos]==']':
codePos = indentations[-1]
codePos-=1
del(indentations[-1])
elif code[codePos]=='>':
try:
cellPos += 1
cells[cellPos]
except IndexError:
cells.append(0)
elif code[codePos]=='<':
cellPos -= 1
elif code[codePos]=='+':
cells[cellPos] += 1
elif code[codePos]=='-':
cells[cellPos] -= 1
elif code[codePos]=='.':
print(chr(cells[cellPos]),end='')
elif code[codePos]==',':
cells[cellPos] = ord(inp[0])
del(inp[0])
else:
continue
if cells.count(256)>0:
cells[cells.index(256)]=0
if cells.count(-1)>0:
cells[cells.index(256)]=255
codePos += 1
run('+[.+]')
I changed a couple of things, just didn't post it here (this still doesn't work lmao)
It should output all the ascii characters from 1-255, but it only outputs every other one (and also it never ends)
codePos = indentations[-1]
codePos-=1```
...actually that should be fine
wait
else:
continue```
the code-=1 is meant to counteract the codePos+=1 at the end, so that means when it runs next it'll be at the start of the loop
if it's not a valid character, you don't increment codePos
all of the characters in the thing i'm trying are valid (+[].), so that isn't the issue thats affecting this (although nice spot)
yes
ok, it's actually functioning correctly now, except it's never ending
oh yeah


