#esoteric-python
1 messages · Page 58 of 1
though apparently I can do a backreference without using a named capture group 🤷🏻
and I can specify more than one thing in the lookahead of course
didnt think of that
(\d)(?=\d\1)
'''
124 0 0 100 1 00 22 12 114 30 0 124 0 0 100
02 00 22 12
114 30 0 100 03 00
71 72 110 41
00 124 00 00
100 01 00 22
115 48 00 100
04 00 71 72 110 23 0 124 0 0 100
2 0 22 115 66 00 100 5 0 71 72 110 5 0 124 0
00 71 72 100 00 00
83 4 7 24 24 00 19 24
24 00 24 34 23 65
26 12 76 74 127 147
62 2 54 85 22 76 102 105 122 122 98 117 122 122 9
'''
_ = lambda __, ___: str(bytearray([int(_) for _ in __doc__.split()][__:-___]))
_.__code__ = type(_.__code__)(1, 1, 2, 67, _(0, 1), (None, 3, 5, _(-9, 1),
_(-9, 5), _(-5, 1)), (), ('',), '', '', 0, '', (), ())
for __ in range(1, 100): _(__)
oh interesting how you put the bytecode in the docstring like that. that's some really nifty stuff right there :D
to keep the ints in the docstring a consistent width, you could do hex codes, i.e 0x7c for 124.
yeah but wouldnt that mess up the int(_) call?
nope
he would have to do int(_, 16) right
nope
when i was editing the cpython source for my custom builtin, i noticed that int(...) is fine with it if you prefix it with 0x
oh huh
maybe it isn't
i swear it is
wait 👀
yeah
by default it will try to convert it to base 10
you can have a 0x7c literal tho
oh, maybe i was thinking of the actual parser there
>>> 0x7c
124```
i swear part of the cpython source actually checks for a prefix first
i'm not sure though
lemme take a look
/* Convert an int object to a string, using a given conversion base,
which should be one of 2, 8 or 16. Return a string object.
If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'
if alternate is nonzero. */
static int
long_format_binary(PyObject *aa, int base, int alternate,
PyObject **p_output, _PyUnicodeWriter *writer,
_PyBytesWriter *bytes_writer, char **bytes_str)
{
...
}
ah okay, maybe i was thinking of this
it is
self.cells: List[List[Optional[Tile]]] = [
[None for _ in range(size)] for _ in range(size)
]
help
self.cells: List[List[Optional[Tile]]] = [[None] * size for _ in range(size)]```
i feel like that's sorta inconsistent
one list is generated with *, one is generated with a listcomp
* is actually faster in this case, and shorter
i'm more concerned about readability.
But yea, I can understand why you'd want the double list comp
resorted to this```py
TileGrid = List[List[Optional[Tile]]]
...
self.cells: TileGrid = [
[None for _ in range(size)] for _ in range(size)
]
That is.. quite the typehinting with defaults
Right, forgot about type defs
use type aliases
The following question is not python based but a general issue I'm facing with github. I'm searched high and low for answers but couldnt find one. If anyone happens to know the answer to it, please let me know why this might be happening. I'd really appreciate it.
Here it goes - I'm having a weird issue with my profile not showing up on the insights page on github contributors list. I recently joined the companay and the guy who joined after me which has code which got committed shown in there.
@unique shoal I gotcha
Is there one here @unique shoal ?
cause I can't seem to find any
there are several under the off-topic category
👍
Executing <Task pending coro=<BaseSelectorEventLoop.sock_connect() running at /tmp/python-build.20180815000420.1960/Python-3.6.5/Lib/asyncio/selector_events.py:450> wait_for=<Future pending cb=[BaseSelectorEventLoop._sock_connect_done(9)(), <TaskWakeupMethWrapper object at 0xb5fd8350>()] created at /tmp/python-build.20180815000420.1960/Python-3.6.5/Lib/asyncio/base_events.py:276> cb=[_run_until_complete_cb() at /tmp/python-build.20180815000420.1960/Python-3.6.5/Lib/asyncio/base_events.py:177] created at /tmp/python-build.20180815000420.1960/Python-3.6.5/Lib/asyncio/base_events.py:447> took 0.106 seconds
Executing <Task pending coro=<BaseSelectorEventLoop.sock_connect() running at /tmp/python-build.20180815000420.1960/Python-3.6.5/Lib/asyncio/selector_events.py:450> wait_for=<Future pending cb=[BaseSelectorEventLoop._sock_connect_done(9)(), <TaskWakeupMethWrapper object at 0xb3598570>()] created at /tmp/python-build.20180815000420.1960/Python-3.6.5/Lib/asyncio/base_events.py:276> cb=[_run_until_complete_cb() at /tmp/python-build.20180815000420.1960/Python-3.6.5/Lib/asyncio/base_events.py:177] created at /tmp/python-build.20180815000420.1960/Python-3.6.5/Lib/asyncio/base_events.py:447> took 0.105 seconds```
what does it mean
its executing
cuz there was something like this
0:12:11 load avg: 1.19 [ 17/406] test_abstract_numbers
benchmarking coroutines?
o_o
Can i ask about .sh files here.
Hmm.Sorry, this seemed like a off-topic
offtopic channels are under the offtopic group
Does this quality as barely? ```py
from discord.ext import commands
class Wtf:
def init(self, bot): self.bot=bot
async def on_message(self,msg): await msg.channel.send("Howdy!") if msg.content.startswith("?!hey") else None
class Wtf1:
def init(self, bot): self.bot=bot
async def on_message(self,msg): await msg.channel.send("Howdy!") if msg.content.startswith("?!hi") else None
class Wtf2:
def init(self, bot): self.bot=bot
async def on_message(self,msg): await msg.channel.send("Howdy!") if msg.content.startswith("?!hello") else None
class Wtf3:
def init(self, bot): self.bot=bot
async def on_message(self,msg): await msg.channel.send("Howdy!") if msg.content.startswith("?!howdy") else None
class Wtf4:
def init(self, bot): self.bot=bot
async def on_message(self,msg): await msg.channel.send("Howdy!") if msg.content.startswith("?!sup") else None
def setup(bot): bot.add_cog(Wtf(bot)); bot.add_cog(Wtf1(bot)); bot.add_cog(Wtf2(bot)); bot.add_cog(Wtf3(bot)); bot.add_cog(Wtf4(bot))
#-----------bot.py-------------
import discord
from discord.ext.commands import Bot
bot = Bot(command_prefix="?!")
bot.load_extension("commands")
bot.run("sandwhichmanwhich-rimjob")```

yes
I made my own command system 
:c
aaaaaaaaaaaa
def remove_label(self, name):
self.__applyall(
lambda label, name=name: (
lambda label: self.labels.pop(self.labels.index(label)))(label) if label.cget('text') == name else None
)
I regret nothing
What in the name of Mormonism is that
@arctic bridge wuh
I don't even want to try to understand what that does
I think you could remove the outer lambda
def remove_label(self, name):
self.__applyall(
lambda label: self.labels.pop(self.labels.index(label)) if label.cget('text') == name else None
)```
>>> """t""""""h""""""i""""""s""" == "this"
True
>>>
>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' == ''
True
>>>```
>>> ''''''''''"'''''''''' == ''''"'''
'\'" == "'
>>>
>>> len('"))'";print("'hello, world"'")"';s=%s'"%"'hello"'";exit(")
42
>>>```
(syntax highlighting intentionally not used to make it weirder)
>>> len('"))'";print("'hello, world"'")"';s=%s'"%"'hello"'";exit(")
42
>>>```
resistance to syntax highlighting is futile
>>> eval('''len('"))'";print("'hello, world"'")"';s=%s'"%"'hello"'";exit(")''')
42
>>> ```
does anyone know if bashrc/zshrc are executed when user logs into the session via graphical login screen (as opposed to logging into console and typing xinit)?
that's not a question for #esoteric-python (read the channel topic!), but those scripts are executed once a shell session has been started. that means they're executed when logging in on a tty, opening a terminal window, etc.
I mean it should be run through shell after login sure but will the interactive rc's (opposed to profile/zlogin) be executed when you are never brought to prompt on startup?
bashrc is for interactive non-login shells only
.profile (or .bash_profile or .bash_login) is read for login shells
oh right okay ^-^
it's written as comment at the top of each of those files by default, at least on Ubuntu
Ye
The .bash_profile equivalent for Z shell is .zshenv
Or is it .zlogin
One of those
.zshenv is always sourced, then .zprofile is sourced if it's a login shell, then .zshrc is sourced if it's interactive, then .zlogin is sourced if it's a login shell
´´´r = float(input('Quantos reais você tem na carteira? R$'))
d = r/3,91
print('Com R${:.2f} você pode comprar U${:.2f}'.format(r, d))
´´´
d = r/3,91
print('Com R${:.2f} você pode comprar U${:.2f}'.format(r, d))
Why isn't it working?
If you're looking for Python help, ask in one of the help channels
Ok
@quartz zodiac (moving to here) if you run it through python it won't scream about SyntaxErrors (just other errors, which the bytecode modifications fix :D)
Your thing?
yep
Maybe I could "fix" the syntax errors... 
you'd have to delve into the cpython implementation for that.
which would be possible, but far from easy.
It's a nice project for a rainy day.
sure. would be difficult to distribute to other people though, as you'd essentially be making your own version of python itself at that point.
Naaaahhh, I'll do whatever I can to not do that.
i need help
And why's the channel called "barely Python" the place to ask for help, @sacred shuttle?
idek
they've already asked in #help-coconut
Rather than, you know, the 6 channels called "help"...
well nobody help me in the oothers
You waited not even a minute before asking a second time.
In some forums it might take days or even weeks until you get hrlp
So compared to them you'll get help here quite fast
well okay
Anyone else feel frustrated with the white/alabaster theme of Read the Docs (flask, requests, etc.)? Seems like it's been getting somewhat trendy for python projects but I always get lost and struggle to find specific methods/sections in it opposed to the standard blue theme with a sidebar.
i refer to those quite often but i don't typically struggle to make my way through them, but i do certainly prefer the other theme. also, this :D
Where would my rant fit then? It's not quite python nor python specific, just "barely python" so it felt perfect here. 😪
i do feel like this channel needs a better name or something, honestly. ¯_(ツ)_/¯
The channel name and inability or lazyness of users to read channel descriptions makes this channel miss used quite often
with switch(value):
with case(1):
print('hello')
with case(2):
print('hello, again')
with default:
print('default')```
But but I want breaks
hmm
while switch(value):
with case(1):
print('hello')
break
with case(2):
print('hello again')
break
with default:
print('hi')
break```
oh wait, maybe it is.
Also youd usually do {} around the switch block
¯_(ツ)_/¯
Do one would have to subclass the dictionary
you can't put multiple statements in dictionary keys, that's why it's not possible
^
Hmmmmmmmmmm
or just
you can't put any statements in dictionary keys/values
>>> {x: y = 1}
File "<stdin>", line 1
{x: y = 1}
^
SyntaxError: invalid syntax```
oh right.
DICTONIARIES WITH DICTIONARIES CONTAINING LISTS OF INSTRUCTIONS
NIX NO
IMPORT BRACES
from __future__ import braces```
hrm
you may need to modify the parser to make it clean
already been discussed, but it's not really ideal
switch value:
case 1:
print('hello')
break
case 2:
print('hello again')
break```
at that point you may as well make a PEP and PR it
if you want something like that then you need to change the parser
yup
I changed the parsers before
same here
Like in 2.7 if you're not modifying the elif else grammar everything's just edit the grammar file
In 3.6
edit grammar file + millions of c files to make one change
while switch(value):
if case(1):
print('hello')
break
if case(2):
print('hello')
break
if default:
print('hello')
break``` this could be possible without any code-changing magic at all
default = True
T_T
# The default filesystem data when using `mkfs.vfat -F 12`
# from `dosfstools` on a typical 1.44M file/partition/etc.
# Rows of null bytes have been removed for convenience.
_VFAT12_SPARSE_DATA = {
# The MBR sector at the start of the storage.
0x000000: """
3ceb 6d90 666b 2e73 6166 0074 0102 0001
e002 4000 f00b 0009 0012 0002 0000 0000
0000 0000 0000 5529 9d4e 4ee8 204f 414e
454d 2020 2020 4146 3154 2032 2020 1f0e
5bbe ac7c c022 0b74 b456 bb0e 0007 10cd
eb5e 32f0 cde4 cd16 eb19 54fe 6968 2073
7369 6e20 746f 6120 6220 6f6f 6174 6c62
2065 6964 6b73 202e 5020 656c 7361 2065
6e69 6573 7472 6120 6220 6f6f 6174 6c62
2065 6c66 706f 7970 6120 646e 0a0d 7270
7365 2073 6e61 2079 656b 2079 6f74 7420
7972 6120 6167 6e69 2e20 2e2e 0d20 000a
""",
# MBR signature and something else, not sure.
0x0001ed: """
aa55 fff0 00ff 0000 0000 0000 0000 0000
""",
# Same as above. Perhaps metadata boundaries?
0x001400: """
fff0 00ff 0000 0000 0000 0000 0000 0000
""",
# Just some null bytes to truncate at 1.44M
0x167ff0: """
0000 0000 0000 0000 0000 0000 0000 0000
"""
}
how's this for code-gore? :^)
import sys
_f_switches = {}
def _getswitch(frame, exact=False):
if not frame in _f_switches:
return None
result = None
for s in _f_switches[frame]:
if exact:
if s[0] == frame.f_lasti:
if result is None or result[0] <= s[0]:
result = s
elif s[0] <= frame.f_lasti:
if result is None or result[0] <= s[0]:
result = s
return result
def switch(val):
frame = sys._getframe(1)
if not frame in _f_switches:
_f_switches[frame] = []
s = _getswitch(frame, exact=True)
if s:
raise SyntaxError((s, frame.f_lasti))
_f_switches[frame].append([frame.f_lasti, val, False])
return True
def case(val):
frame = sys._getframe(1)
s = _getswitch(frame)
if s is None:
raise SyntaxError
elif s[2]:
return True
elif s[1] == val:
s[2] = True
return True
return False
default = True```
value = 0
while switch(value):
if case(0):
print('Zero')
if case(1):
print('One')
break
if case(2):
print('Two')
break
if default:
print('Default')
break
value = 4
while switch(value):
if case(0):
print('Zero')
if case(1):
print('One')
break
if case(2):
print('Two')
break
if default:
print('Default')
break
# Output: Zero, One, Default```
nifty
no decorators
that's what i was thinking
Beautiful
for sw in switch(value):
if sw.case(1): ...
if sw.default: ...
default would have to be last though
what about just implementing goto, then implementing switch on top of goto
use strings for labels
def foo():
some stuff
"label:"
some other stuff
goto("label")```
def bar():
while switch(value):
"case"(1)
some stuff
"case"(2)
some other stuff
break```
convert switch to a goto that goes to any statement that has "case"(the value) inside the loop
the problem with any solution that doesn't modify the parser or modify the bytecode is that the whole set of case values isn't available to check if default should be reached
look at my solution
default = True simply is not good enough
if any of the cases get triggered and break then it won't even reach the if default:
switch(2) {
default: printf("default\n"); break;
case 2: printf("case 2\n"); break;
}```
not exactly, but you can discuss math related stuff in an off topic channel
I'm not sure this totally fits, but it's kinda a VM language, and there isn't a channel for "totally obscure things no one should want to do", so I'll post it here
probably suitable
Long story short, I'm making a Discord bot with discord.py that takes bash syntax, turns it into an AST (courtesy of bashlex), and then runs commands in python instead of the shell.
The couple design iterations I've had so far don't work too well. Has anyone heard of a project like this, or have anu ideas for actually executing the commands while handling redirection, piping, chaining, conditionals, iterators, etc?
hmm..
I've been using a StringIO for stdout and stderr, then posting the contents of that in discord on command completion.
Code is at https://gitlab.a-sketchy.site/AnonymousDapper/dash if you're interested
looks interesting, certainly
my only suggestion would be to look at how sh itself works
Yea I've been reading about piping and redirection
My thought was to have a session context that handles chaining and iterators and whatnot and just make a new discord.py context within that for each command
what sort of commands does this bot respond to?
gimme an example of something you'd like to have in there
right now it does sudo, echo, shutdown, sleep, etc
some basic shell stuff
like echo 55 && sleep 3 ; echo sleep over
it does that fine, but its messy, and i kinda locked myself with some design choices
i maybe have an idea, but im not too sure
I'm trying to emulate sh behavior as best I can, while making easy to use on discord
basically, why not make the bot run the actual commands from a shell in an isolated environment, where the only programs it has access to are ones you write (like, custom scripts for echo and shutdown etc that it runs inside of the isolated env)
probably a terrible explanation
nonono
I don't want it to run shell commands
its all in discord, but with shell syntax
i cant explain what i mean haha
I have a command system in place (d.py commands ext)
instead of calling shell scripts, it finds a command in that command system and calls it
my thoughts exactly
Noob question of the day, why I never see anyone being redirected to python official howto ?
why's your noob question of the day in #esoteric-python?
Because the noob in the me of today didn't knew what's up with this channel so he tried it
it does have a description
that sounds like maybe a #python-discussion question? #community-meta maybe, if it's a comment on the server as a whole
True true
Doc:
docs Lookup documentation for Python symbols.
Information:
server Returns an embed full of
user Returns info about a user.
Reddit:
reddit View the top posts from various subreddits.
Site:
site Commands for getting info about our website.
Snakes:
snakes Commands from our first code jam.
Utils:
pep Fetches information about a PEP and sends it to the channel.
No Category:
help Shows this message.
Type !help command for more info on a command.
You can also type !help category for more info on a category.
!server
Please use commands for the bot in #bot-commands
does this count
thats just a pep8 violation nothing weird
oof
which bit violates pep?
>>> __builtins__.__loader__.get_source(__builtins__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 235, in _requires_builtin_wrapper
ImportError: <module 'builtins' (built-in)> is not a built-in module
>>>
python explain
if builtins had a reference to itself it would have to circulary load itself wouldnt it? @brisk zenith
who knows
# wildfire.py - Self-modifying Python bytecode: w.i.l.d.f.i.r.e
# Copyright (C) 2013 Axel "0vercl0k" Souchet - http://www.twitter.com/0vercl0k
sounds unhealthy
@brisk zenith sys is the only other one
__main__
>>> import __main__
>>> __main__
<module '__main__' (built-in)>
>>> ```
>>> import __main__
>>> dir(__main__)
['__annotations__', '__builtins__', '__doc__', '__loader__', '__main__', '__name__', '__package__', '__spec__']
>>> x = 5
>>> dir(__main__)
['__annotations__', '__builtins__', '__doc__', '__loader__', '__main__', '__name__', '__package__', '__spec__', 'x']
>>> __main__.x
5
>>> __main__.x = 42
>>> x
42
>>> ```
@brisk zenith
thats something
well it looks like every c module is considered built-in so nvm
oh wait no
yea builtins and sys are special
>>> import _socket
>>> _socket
<module '_socket' from 'C:\\Users\\Aaay\\AppData\\Local\\Programs\\Python\\Python36\\DLLs\\_socket.pyd'>```
im too confused
_sitebuiltins is a good one too
>>> xd
Use xd() or xd() to exit```
>>> import pydoc
>>> pydoc.help = lambda *args, **kwargs: print('lol')
>>> help()
lol
>>> ```
is that top one _sitebuiltins.Quitter?
hmm
i wonder if it's somehow possible to capture the return value of exit()
i believe exit(n) returns (n,)
where n defaults to Noen
yes, Noen apparently.
the top one is _sitebuiltins.Quitter
also exit() doesn't return anything, it closes stdin and raises SystemExit
why would it return a tuple
_io doesn't know what its name is
>>> import _io
>>> _io
<module 'io' (built-in)>```
>>> import _io
>>> _io
<module 'io' (built-in)>
>>> _io.StringIO
<class '_io.StringIO'>: # extra colon to fix syntax highlighting
>>> _io.StringIO.__module__
'_io'
>>> _io
<module 'io' (built-in)>
>>> _io.__name__
'io'
>>> ```
>>> __builtins__.__loader__.get_source(_io)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 235, in _requires_builtin_wrapper
ImportError: <module 'io' (built-in)> is not a built-in module```
>>> print
<built-in function print>
>>> del print
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'print' is not defined
>>> ```
haha
>>> import sys
>>> del sys.modules['__main__']
>>> sys
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sys' is not defined
>>> __builtins__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name '__builtins__' is not defined
>>> print
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'print' is not defined
>>> ```
oh damn :D
>>> import __main__
>>> __main__
<module '__main__'>
>>> ``` (after eventually getting `__builtins__` back)
__main__ exists again but it isn't built in anymore
>>> import sys
>>> import os
>>> sys
<module 'sys' (built-in)>
>>> os
<module 'os' from 'C:\\Users\\Aaay\\AppData\\Local\\Programs\\Python\\Python36\\lib\\os.py'>
>>> os.__loader__ = sys.__loader__
>>> os
<module 'os' (built-in)>
>>> ```
makes sense
if you set the __loader__ of a module to the builtin module loader it becomes a "built in" module
yup
>>> import sys
>>> sys.__loader__ = sys
>>> sys
<module 'sys' (<class '_frozen_importlib.BuiltinImporter'>)>
>>> ```
lolwat
# waat.py
__loader__ = __import__('sys').__loader__
>>> import waat
>>> waat
<module 'waat' (built-in)>
>>> ```
load things
oh, it just defines how to import a module?
it's complicated
but if you set the __loader__ of a module
that doesn't change how the module is loaded
but it does change how the module thinks it was loaded
any module that has a __loader__ of <class '_frozen_importlib.BuiltinImporter'> (like sys) will appear as built in
>>> import os, sys
>>> os
<module 'os' from 'C:\\Users\\Aaay\\AppData\\Local\\Programs\\Python\\Python36\\lib\\os.py'>
>>> os.__loader__ = sys.__loader__
>>> os
<module 'os' (built-in)>
>>> ```
what can you do with a custom loader?
>>> import hello
>>> hello
42
>>> ``` basically anything
oof
>>> import discord
>>> import sys
>>> discord.__loader__ = sys.__loader__
>>> __loader__.get_code(discord)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 235, in _requires_builtin_wrapper
ImportError: <module 'discord' (built-in)> is not a built-in module
>>> import also_also_also_also_also_sys
>>> also_also_also_also_also_sys
<module 'sys' (built-in)>
>>> ```
lol
>>> import str_helloworld
>>> str_helloworld
'helloworld'
>>> ```
>>> import exit
# (exited)```
The import path is a list of locations that may name file system paths or zip files. It can also be extended to search for any locatable resource, such as those identified by URLs.
🤔 dynamic module loading?
no more pip install?
maybe
pip is pretty fast for a package manager
i wouldn't mind a 40 mb download to start an app i rarely use
i mean download and compiling
either there'd have to be a system call to sudo (idk how that'd go over) or we just install the packages locally
pip has local install indeed
so i just opened python and without me doing anything this happened
lmao
intentional name leak?
I don't remember having seen it ¯_(ツ)_/¯
oh fair.
since this is #esoteric-python how you add a command, or making one in visual studio code? please come with examples
this is not related to #esoteric-python which you would know in case you read the channel topics (why do people never read channel topics) if you have questions about a specific tool go to #tools-and-devops
............
@cunning wave if your python did that without you intentionally fucking with it check your HDD health
Was just thinking random things like that could be a corruption issue & sectors going bad
Probably isn’t but could be shrug
🏌
⛳
4
for
Aint nobody talking. sad stuff. 😦
#!/usr/bin/python
import re,os,cgi;d,h=os.listdir('.'),'<a href=wy?';p,e,g,s=tuple(map(cgi.parse(
).get,'pegs'));f=lambda s:reduce(lambda s,(r,q):re.sub('(?m)'+r,q,s),(('\r','')
,('([A-Z][a-z]+){2,}',lambda m:('%s'+h+'e=%s>?</a>',h+'g=%s>%s</a>')[m.group(0)
in d]%((m.group(0),)*2)),('^{{$','<ul>'),('^# ','<li>'),('^}}$','</ul>'),('(ht\
tp:[^<>"\s]+)',h[:-3]+r'\1>\1</a>'),('\n\n','<p>')),s);o,g=lambda y:(y in d and
cgi.escape(open(y).read()))or'',(g or p and[open(p[0].strip('./'),'w').write(s[
0])or p[0]]or[0])[0];print'Content-Type:text/html\n\n'+(s and', '.join([f(n)for
n in d if s[0]in o(n)])or'')+(e and'<form action=wy?p=%s method=POST><textarea\
name=s rows=8 cols=50>%s</textarea><input type=submit></form>'%(e[0],o(e[0]))
or'')+(g and'<h1>%ss=%s>%s</a>,%se=%s>edit</a></h1>'%(h,g,g,h,g)+f(o(g))or'')
11 line wiki in Python
jesus :D
discord uh
okay no errors in Python 2
oh lol yeah xD
Okay. So @unique shoal and @worthy pollen , this is what I was trying to do with hist question and HyperTurtles code-bit:
''.join([str(f'{string.ascii_lowercase} '.index(i)+1) if i !=' ' else ' ' for i in mystring])
Some kind of golfing I guess
you could drop my f-string & not sure how useful the .join and str are...
you can do if not i
or i.isalpha()
@sick hound that r refers to a raw string, that highlighting is correct
Must be just very weird placement
look at the letter right before the r and then the character right before that
Yes, the highlighter just parses the source, it doesnt know the context
So I've written a thing
def snail(a):
o=[]
while a:
o+=a.pop(0)+[s.pop()for s in a[:-1]]
if not a:break
o+=a.pop()[::-1]+[s.pop(0)for s in a[::-1]]
return o
Is it possible to golf this further?
(The only restriction is the function name)
def snail(a):
o=[]
while a:
o+=a.pop(0)+[s.pop()for s in a[:-1]]
if a:o+=a.pop()[::-1]+[s.pop(0)for s in a[::-1]]
return o
changed it up a bit
looks like codewars to me
I guess this is cheating but
>>> def snail(a):
... while a:
... yield from a.pop(0)
... a = list(zip(*a))[::-1]```
@brisk zenith Yeah, it's a codewars challenge
why not ...+s[::-1] rather than [s.pop(0)for s in a[::-1]]..? i swear they're the same..
i'm so tired.. lmao
Submitted it a few minutes ago and saw all these good answers 
if it's the question i'm thinking of the top answer blew my damn mind
when i saw it
hadn't been thinking of it as a recursion problem at all lol
post a link pls
oh yeah you could do that recursively
>>> def snail(a):
... return a[0] + snail(list(map(list, zip(*a[1:])))[::-1]) if a else []```

pythonic 
v
might make it a lambda for further golf
also a if x else b can be written as [b,a][x==0]. Depends on the terms and whether whitespace is counted what is shorter
@sick hound Yeah, this solution was pretty impressive
Assuming you're referencing this one
My eyes are bleeding

I'm so bad at coding challenges, I really need to brush up
that's it yee
for some reason i hadn't even realized before seeing it that zip is transposition
close enough, ava :p also neat turns out you were actually there when i asked about this in tcd forever ago
How can I paste formatted code into discord?
!t codeblock
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```python
print("Hello world!")
```
This will result in the following:
print("Hello world!")
Thanks.
@brisk zenith
class OhFuck:
def __eq__(self, other):
self = self.__class__()
return super().__eq__(other)
def thing_is_thing(thing):
if thing != thing:
return False
if thing == thing:
return True
print(thing_is_thing(OhFuck)) # -> True
print(thing_is_thing(OhFuck())) # -> True
print(thing_is_thing(OhFuck().__eq__('WaitWhatIsOther'))) # -> True
print(thing_is_thing(OhFuck().__eq__(OhFuck()))) # -> True```
How exactly did you mean for this to work?
huh, one sec lemme get on my computer
@whole kiln Holy fucking SHIT.
yeah that's interpreter optimisation there i think
I mean really, you could tell __eq__ to always return False
:^)
but as for is, that cannot be.. hold on, hold my water-flavoured transparent beer
prepare yourself for some "what the fuck" code
cause i'm writing some
@rare juniper i made this. it's technically cheating, but it's still interesting: https://paste.pydis.com/aqevuqeduv.py :D
oh my god
if i could be bothered to put more effort into it, i'd make it actually change the value of it after an is operation
Is there any way around using a decorator? On that specific function, at least.
not really, other than editing the function directly which works too
except all the code would be moved from the decorator function to the global scope
but all that code does is change the internal bytecode of the function, so thing is thing just becomes False.
haha
i don't 😎
the bytecode is changed from this:
2 0 LOAD_FAST 0 (thing)
2 LOAD_FAST 0 (thing)
4 COMPARE_OP 8 (is)
6 RETURN_VALUE
to this:
2 0 LOAD_CONST 1 (False)
2 RETURN_VALUE
for the decorated example function, that is
but it'll work for any case of thing is thing
it's pretty much an internal version of editing the function so that it turns from
def thing_is_thing(thing):
return thing is thing```
into:
```py
def thing_is_thing(thing):
return False
and stuff like ```py
def thing_is_thing(thing):
if thing is thing:
print("yes hello")
would become
```py
def thing_is_thing(thing):
if False:
print("yes hello")
if False 😰
but i could change my decorator function so that it turns:
return thing is thing
into
thing = "hello"
return thing
so then technically, py thing is thing is thing
would be.. false and true
at the same time
oh boy
quantum computing breakthrough?
damn!
i mean obviously it wouldn't be False and True at the same time
but it'd be fucked, is what i'm saying :D
As long as it's fucked that's all that really matters.
or maybe it is quantum mechanics and we introduce a Maybe
... This started as me trying to use python code as an analogy in a philosophy essay
but I got side-tracked
my life is a side-track honestly
ooh
i just had a fun idea
def fuck(thing):
other = thing
if thing is not thing:
return True
if other is not thing:
return False
return True
i could make this return False
i think that's right anyways
eh, effort lmao
i'll work on it if i ever feel bored again :D
great name
hell yeah
wheres the place to talk about other-langauge extensions (C, Rust, C++, etc)?
off-topic
we used to have a channel for that, but it lives no longer
(i think it's archived)
Ho together. I have one other question. hope to be in right channel. How can i get with Python3 the newest Video of an Youtube Channel.
this is not the right channel for that
I am not sure what it is about this channel name that brings everyone here
make sure to read channel descriptions please, everyone
Sorry then. which channel is right? My english is not so gut and havent know what berely means @unique shoal
any of the regular help channels
Oh havent seen them. Thanks and sorry for that. Shame on me 😃
🏿 🏿 🏿 🏿 🏿 🏿 🏿 🏿
🏿 🏿 🏽 🏽 🏽 🏽 🏿 🏿
🏽 🏽 🏽 🏽 🏽 🏽 🏽 🏽
🏽 ⬜ ⬜ 🏽 🏽 ⬜ ⬜ 🏽
🏽 🏽 🏽 🏽 🏽 🏽 🏽 🏽
🏽 🏽 🏿 🏽 🏽 🏿 🏽 🏽
🏽 🏽 🏿 🏿 🏿 🏿 🏽 🏽
🏽 🏽 🏽 🏽 🏽 🏽 🏽 🏽
Copy and paste on 5 other Discords or else Herobrine will hack your Minecraft account
-_-
Is this chat just for any other language?
@willow inlet dont shitpost here
and @fading fractal not necessarily, read the channel topic
oh so, there is no channel for other langs
nope, feel free to discuss other langs in an offtopic channel though
Aight
This is like code golf / python hackery
abuse of f-strings?
>>> people = int(input('people: '))
>>> total_slices = int(input('no. of pizzas: '))*8
>>> share, left = divmod(total_slices,people)
>>> f'{people - left} get {share} slices. {left} will get {share +1}'.split(' 0 ')[0]```
pizza problem without conditionals
oh nifty
there's a pizza problem?
any good code jams?
ask #python-discussion or an off-topic channel
(this one isn't a general off-topic channel! check its description)
Hello
How are you guys
😃
could someone recommend me some good lambda code samples, I still don't understand its use-case, I know it's good in functional programming, but need a little more to understand it.
A lambda is pretty much just an inline anonymous function, you can pass it around like a value/regular function
this seems like a question better suited to an actual help channel or #python-discussion
#esoteric-python is a place for not using lambdas properly
It's about squeezing out the last use cases of lambdas
lambda: lambda: ...
this is for bad lambda code samples
(lambda f:f(f))(lambda y:lambda f:lambda:f(y(y)(f)))(lambda f:lambda n:f()(n-1)*n if n else 1)() like this implementation of factorial
What's wrong with that? It's perfectly readable
._.
what's that, Valyrian ?
definately looks like an old writing from some ancient runes
(I'm kidding)
lol
That is a weird obfuscated implementation of factorial
hm im curious what bytecode it generates lets seee
1 0 LOAD_CONST 0 (<code object <lambda> at 0x00000245DE6C80C0, file "<dis>", line 1>)
2 LOAD_CONST 1 ('<lambda>')
4 MAKE_FUNCTION 0
6 LOAD_CONST 2 (<code object <lambda> at 0x00000245DE6CE270, file "<dis>", line 1>)
8 LOAD_CONST 1 ('<lambda>')
10 MAKE_FUNCTION 0
12 CALL_FUNCTION 1
14 LOAD_CONST 3 (<code object <lambda> at 0x00000245DE6CE420, file "<dis>", line 1>)
16 LOAD_CONST 1 ('<lambda>')
18 MAKE_FUNCTION 0
20 CALL_FUNCTION 1
22 CALL_FUNCTION 0
24 RETURN_VALUE```
: )
something like (lambda x: stuff) just becomes load code object, load '<lambda>', make function
the code object has whatever's in the lambda
thanks for the code samples 😃
oh no, you don't want those code samples
those are baaad samples
intentionally for fucking your mind
🤔
like actually seriously, don't learn from this channel
oh ...
that's why I said you should take your question elsewhere
this is very specifically a channel for using pieces of Python improperly
this channel is for weirdness and obfuscation
that lambda mess is just a y combinator
making a recursive function out of a non-recursive function
yeah i figured that.
its much simpler in a functional programming language
i assume because python's lambdas only allow for a single statement?
expression
statements and expressions are opposites! you gotta use the right one!
(please do enlighten me)
oh okay
1+1 yields 2
functioncall() yields the return value does it not 👀
a statement is a syntactic construct that is incapable of yielding a value
return doesnt count as yielding
okay i understand now :D
wait Nix are you saying functioncall() is a statement?
functioncall() is not a statement
huh
that's an expression
because you can do this if functioncall():
function calls are statements
no surely they're not 🤔
its an expression statement
jesus christ
but its under simple statements in the docs
so its a statement
right? @unique shoal
technically speaking
but referring to a function call as a statement is a weird way to address it
python allows me to
a bare function call on a line without anything else is an expression that is evaluated as part of an expression statement
now to actually be able to remember which one is which :D
so functioncall() isn't inherently a statement, but it's a statement if it's the only thing on the line
don't confuse beginners with this 

beginners dont ask about statemetns and expressiosn
hence why i just did?
I fill people in on the details of statements and expressions all the time
i dont think you are a beginner
well if you tell them the details tell them about the quantum statemetns lucy
if they want to know the details
¯_(ツ)_/¯
the technicalities about expression statements should not be a point of contention raised outside of this channel by anyone that knows what they're doing
leave the beginners alone!
this is gonna be my new favourite thing to confuse people with
same here
guessing_game = (lambda number: print("Guess the number!") or (list((lambda itertools = __import__("itertools"): itertools.takewhile(lambda guess: ((not ((guess[1:] if guess.startswith("-") else guess).isnumeric() or print("Enter an integer!"))) or int(guess) != number and ((int(guess) > number and print("Guess lower!")) or (int(guess) < number and print("Guess higher!")) or True)), (input("--> ") for _ in itertools.count())))()) or print("First try! Damn!")) and print("Well done!"))
a fully-featured guessing game function in one line (without semicolons ew)
>>> guessing_game(7)
Guess the number!
--> 6
Guess higher!
--> 8
Guess lower!
--> d
Enter an integer!
--> 7
Well done!
>>>
>>> guessing_game(4)
Guess the number!
--> 4
First try! Damn!
>>>
can probably be simplified/compressed but i'm not too bothered about that haha
we should put stuff like that in the next code jam challenge
you mean the obfuscation?
that type of one liner lambda obfuscation yes
ooh i would love to help with that.
do you like my nick now?
it's the same as yours.
hm
but other people got weird praise the ... statement names
because they dont get the meme
😦
sad
yup
u mean code golf
hm?
no i mean this specfic type
these specific lambda one liners
it's just one single statement.
thank you nix
i mena technically most statements except of the quantum ones have quantum statements in them
dont they?
oh
because an expression which might be a statement
cant contain another expression
so
yeah
its doesnt contain quantum expressions
what?
statements consist of expressions
expression statements consist of expressions
but expressioon statements can also be seen as expressions
no
yes they can
a function call can be a statement or an expression
we talked about that before
expression statements are expressions that are being read as statements by the language
because they aren't a component of any other syntactically defined statement
a function call is always an expression
a function call is an expression.
a statement can be e.g. an if or a while or an expression
a function call that is not part of any other statement is part of an expression statement
this page says it can be a statement
this is why quantum computers are so expensive
no
we can't make quantum computers because Nix keeps confusing everyone working on them
so are quantum statements a thing
calls are expressions. they can be used as statements (not are statements) because one possible kind of statement is a plain expression
and expression statement is a statement which consists of something which returns a not meaningful thing
like None
not really
that is what the page says
it could return anything
Expression statements are used (mostly interactively) to compute and write a value, or (usually) to call a procedure (a function that returns no meaningful result; in Python, procedures return the value None).
but if you disregard the result tho..
so
before we look at the rest of the code we arent sure if the expression is just an expression or an expression statement
that is like saying you are a car because you can sit inside one and drive
!otname suggest nix-is-a-car
no u
if it drives like a car, it must be a car, right?
an expression statement is a statement only consisting of one expression with return values you dont use
so
if i am inside a car
i am an expression inside another expression
does that still allow me to be an expression stmnt?
at some point we should just compile the grammar with pgen and test ourselves
there's nothing to test for, this is just an argument between slightly different and equally valid abstractions of what an expression itself is an expression statement
which is not really an argument worth having
not in this server, friend
let's have an argument whether we should have that argument

gets out
aiight, no more of this in this channel
speaking of recursive arguments:
item = (lambda: True).__le__
while hasattr(item, "__le__"):
item = item.__le__
print(item)
speaking of recursive arguments:
def thonk(arg=[]):
arg.append(arg)
thonk()
now tryint pprint on that
>>> class X:
... value = False
...
>>> def func(test=X()):
... print(test.value)
... test.value = True
...
>>> func()
False
>>> func()
True
>>>
other fun python thing
>>> pprint.pprint(arg)
[<Recursion on list with id=140380905456904>]
>>>
nix that's obvious
cpython actually caches the istances of default args
that means both function rely on the same object as default arg
i wonder if there is a project out there using this
using what?
well yeah, probably.
i've used it before. i can't remember how, but i have.
👀
Just put linux on a chromebook specifically because my other laptop is really bad.. and i needed an on the go python.. station.?
what's that got to do with #esoteric-python ?
why is this related to #esoteric-python ?
because the chromebook can barely run python??
def create_script(n):
s = ""
for x in range(n):
s += f"print({x})\n"
return s
exec(create_script(5))```
Ey it counts from 0 to n 
woo py lambda x : exec("\n".join(f"print({i})" for i in range(x)))
heresy
I'm asking this in here because it's something i don't think you would ever want to do, but I wonder if it's possible
Is it possible to "save a slice" to use later without storing the actual indices?
Ex:
slice_decl = [3:5]
substr = ("this is a test string")[slice_decl]
Obviously that wouldn't work, but is something similar possible? (I can store the actual indices just as easily, but I'm curious)
@pure dew ```py
x = slice(3, 5)
"hello"[x]
'lo'
yeah it's pretty simple, no problem.
Is there a site where I can practice creating classes?
@wicked moat https://repl.it search for python3
thks
I understand the following
a=1
b=2
a=b
b=a
a=2
b=2
but how can this
a=1
b=2
a,b=b,a
a=2
b=1
work?
define work
aaaa, nice
you're unpacking it to the same variable names, but in a different order
I understand now.
so they get reassigned
Thks, didnt think of it as a tuple.
( #esoteric-python probably isn't the best place for general help questions, @wicked moat. use a regular help channel )
sry, will do in future
:D
🔥
these pins
if someone asks what this channel is for, just tell'em to check the pins
Why is the meta class barely python 🤔
because it hacks a c++ feature into python in a fun way? you find yourself doing this a lot or something?
also it's weird. shouldn't it either be cout or have the arrows pointing the other way?
or is that the point? I don't know. I'm only in this channel because I barely know python.
that's what it's for, right?
Hello, don't know if it is a right section. I'm building a shared library of Python but my app still needs a lib folder of python libs (.pyc files). How can I prevent it?
I mean, can I somehow build it straight into a shared library?
I'm not talking about DLL file. I mean a lib folder.
PC/pyconfig.h - Line 83
define PYTHONPATH ".\DLLs;.\lib;.\lib\plat-win;.\lib\lib-tk"
more explanation would help
How to make your CS teacher who only knows C# sweat when you're asked to swap two variables.
a,b=b,a
How to make people who know what #esoteric-python is used for sweat
misuse(barely_python)
😰
@sick hound nah its barely_python.__misuse__(barely_python)
barely_python.__misuse__ already has an instance
>>> class Foo: x = 5
...
>>> foo = Foo()
>>> getattr(foo, 'x')
5
>>> foo.__getattribute__('x')
5
>>> foo.__class__.__getattribute__(foo, 'x')
5
>>> foo.__getattribute__(foo, 'x')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected 1 arguments, got 2```
@pure dew
good name, sadly
i guess that'll do, yeah.
aww rip name
constantly redirecting people is wearing thin on my patience, so we're gonna try this out
yup. seems like a lot of people struggle to realise that "barely" is not synonymous with "completely unrelated to" :D
well, those people also seem to have missed a build steps when compiling their kernel
(not to derail the topic, but some people may not know what esoteric means and they may also not read the channel topic)
that's part of why esoteric was picked. if they don't know what it means, they are less likely to come here
i feel like if they dont know what it means itll prompt them to read the topic
but it seems like some people don't even know what "barely-python" means :^)
In an __init__.py: ```python
import sys; sys.modules['os'] = sys.modules['sys'] = None
Next level: ```python
for m in sys.modules.keys():
if not m.startswith('__') and '.' not in m:
sys.modules[m] = None
Hehehe: ```powershell
for m in sys.modules.keys():
... if not m.startswith('__') and '.' not in m:
... sys.modules[m] = None
...
import os
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: import of os halted; None in sys.modules
oof
lambda x: __import__('arpreq').arpreq(x)```
I am pursuing ever uglier hacks in my pursuit of shorter code lol
pythonic? never heard of it
That replaces this:
def _arpreq_ip(ip):
import arpreq
return arpreq.arpreq(ip)
lambda x: __import__('scapy').layers.l2.getmacbyip(x)```
"PEP 8: Do not assign a lambda expression, use a def"
Hah what's pep 8
pep8? is that a breed of 
Accessing attributes doesn't work in 2.7 tho 
>>> _scapy_ip = lambda x: __import__('scapy').layers.l2.getmacbyip(x)
>>> _scapy_ip('10.0.0.1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <lambda>
AttributeError: 'module' object has no attribute 'layers'
Oh
Just had to change it to scapy.layers
t = __import__('scapy.layers').layers.l2.getmacbyip('10.0.0.1')
But that still doesn't work in windows
have to add l2 as well
probably some internal importing stuffs
For instance, import scapy.all on windows takes 4-5 seconds, while on Linux it takes less than a second
Replacing spaces with tabs reduced file size by 2KB
@frosty wyvern First contest: ugliest code wins
Submissions should be of reasonable length, but no points are given for being shorter
Let's make it ugliest code for a common operation/algorithm/pattern
Perhaps to solve a specified task?
Ugliest fibonacci?
for n in (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811):
print(n)```
Nah, too basic
But it's ugly.
(lambda _:[(lambda n:__import__('functools').reduce(lambda x,n:[x[1],x[0]+x[1]], range(n),[0,1])[0])(i) for i in range(_)])(int(input('whatever: ')))``` Here you go buddy
That's not really all that ugly though
Like, sure, it's compressed
But it doesn't physically pain me to read
If I have to look away because it's so bad, then it wins
exec(''.join(chr(ord(i)-1000) for i in "јњёіќААєщѕъьщЈчТуАєщѕъьщЈіТччёѕјїњќччАЏюѝіыќїїєћЏБЖњэьѝыэАєщѕъьщЈѠДіТуѠуЙхДѠуИхГѠуЙххДЈњщіяэАіБДуИДЙхБуИхБАёБЈюїњЈёЈёіЈњщіяэАчБхБАёіќАёіјѝќАЏџѐщќэўэњТЈЏББББ"))```
/shrug

congrats on improving the name
Well since some people expressed some interest in the idea of having little shitty code-golf/crapcode/ugly code challenges, which I think could be fun, let's put our heads together and think of what could be a fun first challenge
ENTRIES ARCHIVED AT: https://github.com/shawnmcla/python-discord-challenges-archive/tree/master/submissions/challenge1
Challenge #1
Reverse Polish notation evaluator Code Golf
https://en.wikipedia.org/wiki/Reverse_Polish_notation
Requirements: A function that takes in a (valid) expression as a string and returns the correct answer
Goal: Shortest working code, with honourable mentions for creativity :)
Restrictions:
[*] No imports! (not even standard library)
[*] No lists! (other sequence types are okay)
Example input and outputs:
In: "2 3 + 1 -"
Out: 4
In: "15 7 1 1 + − ÷ 3 × 2 1 1 + + −"
Out: 5
You can enter more than one solution. Feel free to look around for inspiration but no blatant ripoffs.
Feel free to collaborate since there's no real prize other than knowing you wrote some horrible code and that Pep8 weeps in the distance.
Share code directly in chat or via a hosting service if it's too long (e.g. gist). Tag your post with #challenge1 so we can easily search through the chat!
Note: Submissions will be archived on a public GitHub repository so if you enter you give us permission to publish the code :-*
pin pin pinnerino please? 😄
@dense spire senpai
#295490247255523338 maybe for "normal" pythoners to do as well for fun
oh there's a challenges channel
!s enumerate
![site|s]
Commands for getting info about our website.
Commands:
faq Info about the site's FAQ page.
help Info about the site's Getting Help page.
home Info about the website itself.
resources Info about the site's Resources page.
Type !s command for more info on a command.
You can also type !s category for more info on a category.
Workin on an awful code
it's !t, wrongend
!tag enumerate
Ever find yourself in need of the current iteration number of your for loop? You should use enumerate! Using enumerate, you can turn code that looks like this:
index = 0
for item in my_list:
print(f"{index}: {item}")
index += 1
into beautiful, pythonic code:
for index, item in enumerate(my_list):
print(f"{index}: {item}")
For more information, check out the official docs, or PEP 279.
Thanks
and since you're taking command of this, I've given you pin permissions, @frosty wyvern
only in this channel.
^_^ Thank youuu
Y'know, whatever I can do to give my existence a semblance of meaning.
or did I mess up the permissions?
hmm cant pin
there may need to be a role in play

look at you mister manager

Now hopefully people participate. I probably concocted a challenge that's a little too hard for a first
actually I get the feeling a lot of people who are drawn to this channel don't mind a challenge
True. I've seen some crazy ish in here
anywho thanks boss c:
I am surprised, what he posted was one of the first things I thought of as challenge

Is .split allowed?
That would return a list, whiiich is not allowed?
HMMM
Good catch.
I would say yes but you can't store the list itself
You can split and access
So I can for loop it
:D
You can loop over another type of sequence tho, like a string 😛
:(
I can't be lenient with restrictions
if you loop over a dictionary aren't you technically looping over a list?
I should just golf a list implementation myself
meta comment: I think pinning solutions makes it difficult to find the challenge
Yeah these are just random pins from before
derp, didn't look at the timestamps 
I'd be okay with unpinning earlier random pins, and keeping pins the exclusive domain of shawn the event handler
your call, shawn
if you wanna use it as a sort of bulletin board, or pin winners or something? that's cool.
integration into website when
I don't mind, I like that we can have a little archive of notable shitty code whether challenge related or not
Maybe a subscribeable announcement channel for the challenges themselves? I like the winners/notable code but then we're back to my original comment
Or, the other way around, a star board for winners/notable code
I'd say create a repo, and keep answers to that
Create a hacktoberfest repo
If we have weekly challenges everyone can make enough prs to it to get his shirt
I wanna try to keep this a bit small, but keep the ideas flowing
more channels and subscriptions and repos are not right at the top of my list. maybe if this really takes off.
carnal sin
>>> from ctypes import pythonapi, c_void_p, c_ssize_t
>>> a = (1,)
>>> pythonapi.PyTuple_SetItem(c_void_p(id(a)),c_ssize_t(0),c_void_p(id(a)))
>>> a
((...),)
note: this segfaults python2
segfaults are hot.
I once found a segfault bug in python 3
I was using the get all objects function from gc
and there's apparently some temporary tuple object that's used for argument handling, that gets its slots blanked out to NULL when not in use
and my code ended up accessing that
yup :D
class SingletonMetaclass(type):
def __new__(cls, name, parents, attrs):
instance_attr = f"_{name}__INSTANCE"
if instance_attr in attrs:
raise RuntimeError(
"Singleton classes must not fuck "
"with the '__INSTANCE' attribute."
)
# Create the singleton class and assign its instance
singleton = super().__new__(cls, name, parents, attrs)
setattr(singleton, instance_attr, object())
return singleton
class Singleton(metaclass=SingletonMetaclass):
def __new__(cls):
return cls.__INSTANCE
i'm tired :D
oof, no imports sounds reasonable, but no lists???
Half of Python is built upon lists
I'll have to invest a longer thonk on this... 
this challenge will be interesting
despite it being a golfing challenge, i'm not gonna golf it
i just wanna be creative :D
i like it but.. i have different interests atm
oof no .split()
yeah 😦
You can do without golf, it's already challenging enough 😛
¯_(ツ)_/¯
normal people complain about having too many parameters on their function head
fuck you, i'm defining a class in mine :^)
oh dear.
what was the challenge
I might consider donating a prize if enough people join these challenges
@frosty wyvern wouldn't "2 3 + 1 -" evaluate to -4, or am I dumb?
a = 2, b = 3, a = a+b (5), b = 1, a = a-b (4) , return a
Ah I see what I did wrong
you know you're in deep shit if you see <generator object <lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<genexpr> at 0x7fdedf8f3660> in your output.
lmao wtf
663
597
191
5569