#ot1-perplexing-regexing

1 messages Β· Page 587 of 1

carmine niche
#

quantum mechanics

reef geyser
#

because wave functions ahhhh

vocal path
#

Pls don't kill cats

carmine niche
vocal path
#

I have a pet cat

odd sluice
vocal path
carmine niche
reef geyser
#

the double slit experiment, but you send the cat through instead

vocal path
#

Cat in both the state of dead and alive

#

At the same time

#

Until you observe it

carmine niche
#

rather, it's in a superposition between alive and dead, and when you open the box you force it into one or the other by collapsing the wave function, and in doing do there is a calculable probability that it will collapse one way or the other

carmine niche
vocal path
#

Yeah that

reef geyser
#

or you don't collapse it at all, and decoherence kicks in and makes both events happen anyway in different "worlds"

carmine niche
#

thinking of superposition as being in two states at the same time is less than helpful

#

rather, superposition is a state in its own right, which collapses into a concrete state when observed

#

this is made most explicit in how measuring qubits in quantum computers works

vocal path
#

Quantum stuff

carmine niche
#

i made a simple quantum entanglement program once and ran it on one of ibm's quantum computers

vocal path
#

random.randint will work better on quantum computer I guess

carmine niche
#

ibm is a very cringe company

#

typical big tech corp stuff
anticompetitive practices
bad to their employees

reef geyser
#

yeah, IBM is very big no-no

carmine niche
#

example: there was a big scandal some months back where they practically fired a guy cuz he forgot to switch to his work email before committing something to the internal git repo cuz it was "unprofessional"

#

i don't have any idea, ask in a proper python help channel maybe?

reef geyser
#

"As an IBM employee, you are not allowed to use your gmail account to work in any way on VNIC. You are not allowed to use your personal email account as a "hobby". You are an IBM employee 100% of the time. Please remove yourself completely from the maintainers file. I grant you a 1 time exception on contributions to VNIC to make this change."

Do you perhaps mean this?

#

Because yeah, this super sucked lmao

reef geyser
#

"You are an IBM employee 100% of the time" lol

reef geyser
#

now in theatres

carmine niche
#

they ordered him to remove all trace of him ever having committed a single line of code and then, it is assumed they fired him

carmine niche
spare lance
#

corporate problems bad

carmine niche
#

capitalism bad

#

anyway goodnight i need sleep i think

#

it's 02:42 am

reef geyser
#

you think >_>

carmine niche
reef geyser
#

2am is not sleeping time

#

for me at least

#

but yeah, go get ya sleep

shrewd prawn
#

when do you sleep πŸ‘€

inland wolf
#

yesterday

rough sapphire
shrewd prawn
#

i mean, last time i slept was technically yesterday

inland wolf
#

yes

spare lance
shrewd prawn
#

no i woke up yesterday

inland wolf
#

bruh

shrewd prawn
#

i went to bed yesterday too

reef geyser
shrewd prawn
#

fair

reef geyser
#

exactly dance

odd sluice
spare lance
odd sluice
#

a bazooka*

reef geyser
#

not a bazooka

#

an m32 rotary grenade launcher

spare lance
#

grenade launcher

odd sluice
#

ah i see
or more accurate I don't see

reef geyser
#

prepare to be yoinked from reality

reef geyser
spare lance
#

ur pfp seems like its eating something while yeeting people off the world.. interesting correlation with about

solid pollen
royal lakeBOT
#

:ok_hand: Added yoinked-from-reality to the names list.

reef geyser
#

back at it again with a new ot name

#

yes yes, thank you

#

I'll be here for the next 3.4 seconds

inland wolf
timid frigate
#

How do off-topic names change?

odd sluice
#

bot

#

changes it at utc 00:00

acoustic moss
#

ye

timid frigate
#

What's the list, and how are they picked?

solemn leaf
#

random

#

like mah bot 😎

odd sluice
#

!halp

#

no

#

i meant !halp

#

!halp

#

no

timid frigate
#

I mean, how are the ones that you add to the list chosen?

solemn leaf
#

await ctx.channel.edit(random.choice(json.load(f)['names']))

#

ez leaks

odd sluice
#

my eyes

solemn leaf
#

cauz i have this

odd sluice
#

are burning

solemn leaf
#

ok

timid frigate
#

why?

#

that's good code

solemn leaf
timid frigate
#

return

solemn leaf
#

asyncio.sleep(86400)

timid frigate
#

lmao

solemn leaf
#

lmao

odd sluice
#

use tasks

#

PLEASE

solemn leaf
#

ikr

odd sluice
#

MY EYEEEEEEEES

solemn leaf
timid frigate
#

I have some good code for you in a sec

solemn leaf
#

oki

spare lance
solemn leaf
#

ikr

#

well you can use sleep_until

#

better alternative for daily task

spare lance
#

!src otn

royal lakeBOT
#
Command: otname

Add or list items from the off-topic channel name rotation.

Source Code
spare lance
solemn leaf
#

await bot.sleep_until(time delta)

#

and then you need to update time delta + 1 day

#

for it to work

#

so asyncio sleep is better anyway πŸ›

edgy crest
acoustic moss
#

nerd

edgy crest
#

inb4 unshut

spare lance
edgy crest
#

no

spare lance
#

but yes

inland wolf
#

:unshu

spare lance
#

guys what are web hooks >:((

jovial kelp
#

wdym?

jovial kelp
acoustic moss
#

mine's an entire cog of a discord bot heh

#

lol

jovial kelp
#

and mine would be that length, just... i don't know how to shorten if statements or classes or anything like that-

royal lakeBOT
#

@rough sapphire :white_check_mark: Your eval job has completed with return code 0.

Utah bread
acoustic moss
#

lmfao

acoustic moss
jovial kelp
royal lakeBOT
#

class type(object)``````py

class type(name, bases, dict, **kwds)```
With one argument, return the type of an *object*. The return value is a type object and generally the same object as returned by [`object.__class__`](https://docs.python.org/3/library/stdtypes.html#instance.__class__ "instance.__class__").

The [`isinstance()`](https://docs.python.org/3/library/functions.html#isinstance "isinstance") built-in function is recommended for testing the type of an object, because it takes subclasses into account.
acoustic moss
#
class A(BaseClass):
  def __init__(self, a):
    self.a = a

is equivalent to

A = type("A", (BaseClass,), {"__init__": lambda self, a: setattr(self, 'a', a)})

for example

spare lance
acoustic moss
#

my secrets have been revealed lemon_pensive

jovial kelp
acoustic moss
#

essentially a one line function with no name

jovial kelp
#

ugh i probably should tho-

royal lakeBOT
#

An anonymous inline function consisting of a single expression which is evaluated when the function is called. The syntax to create a lambda function is lambda [parameters]: expression

spare lance
acoustic moss
#

dunno

#

possibly for things like metaclasses

jovial kelp
acoustic moss
#

oh nvm

jovial kelp
spare lance
#

time to run help

acoustic moss
#

nah kwargs wouldn't be for metaclasses

spare lance
#

and spyder is dead slow

acoustic moss
jovial kelp
#

noted

#

WHAT IS A PROTOCOL

#

whaaa

royal lakeBOT
#

class typing.Protocol(Generic)```
Base class for protocol classes. Protocol classes are defined like this:

```py
class Proto(Protocol):
    def meth(self) -> int:
        ...
```  Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example...
tranquil orchid
#

What on earth is happening in here πŸ‘€

jovial kelp
#

this... isn't okay

acoustic moss
# jovial kelp how in the world-

!e

class MyMeta(type):
  def __add__(self, other):
    return 5

class A(metaclass=MyMeta): pass
class B(metaclass=MyMeta): pass

print(A + B)
royal lakeBOT
#

@acoustic moss :white_check_mark: Your eval job has completed with return code 0.

5
acoustic moss
#

no

#

inheritance is different

spare lance
#

but either way u would included them in bases right?

jovial kelp
tranquil orchid
#

He's adding the classes there, not the instances

acoustic moss
#

yeah

jovial kelp
acoustic moss
#

if a class B inherited from A, instances of B would follow the blueprint laid down by both A and B

if a class B has a metaclass A, instances of B are unaffected, but B itself follows the blueprint laid by A

spare lance
tranquil orchid
#

metaclasses allow you to change the class itself, inheritence will allow you to inherit attributes, methods etc from another class that will be reflected in the class instances

acoustic moss
#

sure

acoustic moss
tranquil orchid
#

!e

class MetaStuff:
    def __init__(*letsjustignorethis):
        print("Makin classes")
    
    def __call__(cls):
        print("Hello world")

class HelloWorld(metaclass=MetaStuff):
    ...


HelloWorld()
royal lakeBOT
#

@tranquil orchid :white_check_mark: Your eval job has completed with return code 0.

001 | Makin classes
002 | Hello world
spare lance
odd sluice
#

black formatter*

acoustic moss
#

yes

#

exactly

#

not necessarily with other classes

#

just how a class itself behaves

spare lance
#

ohh

jovial kelp
spare lance
#

interesting

tranquil orchid
#

classes are objects to, metaclasses are basically just classes... for your classes

acoustic moss
#

ye

jovial kelp
#

whoaaaa, that dunder is __radd__

acoustic moss
#

if you do a + b and there is no __add__ defined for a, it'll call __radd__ of b

#

πŸ€” are they?

#

oh fuck obv

jovial kelp
#

wait what- remthink just how many dunders are there...

acoustic moss
#

more than i can count

dire siren
#

two lots, not just one

spare lance
acoustic moss
#

i'm estimating at least 100

tranquil orchid
#

Think of it like self

spare lance
#

ah

#

hmm

tranquil orchid
#
class float(float):
    def __invert__(self):
        return f"it's about {round(self)}"

a = float(12.6234)

print(~a)
#

best dunder

jovial kelp
tranquil orchid
#

!e

class float(float):
    def __invert__(self):
        return f"it's about {round(self)}"

a = float(12.6234)

print(~a)
royal lakeBOT
#

@tranquil orchid :white_check_mark: Your eval job has completed with return code 0.

it's about 13
acoustic moss
#

lol

#

is there a default ~ for floats or is it just for ints πŸ€”

tranquil orchid
#

I don't think so

acoustic moss
#

!e ~1.1

royal lakeBOT
#

@acoustic moss :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: bad operand type for unary ~: 'float'
rough sapphire
#

Only ints

acoustic moss
#

hm

jovial kelp
acoustic moss
#

its the bitwise not operator

#

flips all bits in an int

#

in this case he implemented it to do something else but wtv

dire siren
#

:(

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

it's about 1.1
jovial kelp
dire siren
#

yay

acoustic moss
#

heh, the bitwise operators aren't that important

spare lance
acoustic moss
#

doesn't work πŸ˜”

royal lakeBOT
#

@rough sapphire :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 | TypeError: can't set attributes of built-in/extension type 'float'
acoustic moss
#

ye

jovial kelp
acoustic moss
#

mmm

spare lance
#

!e print(~1)

royal lakeBOT
#

@spare lance :white_check_mark: Your eval job has completed with return code 0.

-2
jovial kelp
#

just as i was starting to finish my to learn list it expands by 30 in one day :,>

spare lance
#

!e print(~-2)

royal lakeBOT
#

@spare lance :white_check_mark: Your eval job has completed with return code 0.

1
dire siren
#

!e

print(chr(96)*3)
royal lakeBOT
jovial kelp
#

that's true, but 30 in one day is painful πŸ₯²

dire siren
#

!e print(chr(1))

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.


#

@rough sapphire :warning: Your eval job has completed with return code 0.

[No output]
jovial kelp
jovial kelp
dire siren
#

u+001 should be null iirc

royal lakeBOT
jovial kelp
#

thank goodness I'm 15 and have tons of time muahahahahaha-

dire siren
#

!e print("```breh")

acoustic moss
royal lakeBOT
#

@dire siren :warning: Your eval job has completed with return code 0.

[No output]
royal lakeBOT
dire siren
#

never try

#

it detects output

#

not the code

acoustic moss
#

ye

spare lance
dire siren
#

!e print(chr(96)*2+"\b"+chr(96))

#

oops

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

```
dire siren
#

why are you doing this

jovial kelp
#

!e

the_meaning_of_life = ""
try:
  print(f"The meaning of life is: {the_meaning_of_life_}")
except:
  print(f"Death to all creatures who don't know {the_meaning_of_life}")
royal lakeBOT
#

@jovial kelp :white_check_mark: Your eval job has completed with return code 0.

Death to all creatures who don't know 
jovial kelp
#

WAIT WHAT

dire siren
#

name error

#

ofc

jovial kelp
#

oh- I'm slow

#

!e

the_meaning_of_life = ""
try:
  print(f"The meaning of life is: {the_meaning_of_life}")
except:
  print(f"Death to all creatures who don't know {the_meaning_of_life}")
royal lakeBOT
#

@jovial kelp :white_check_mark: Your eval job has completed with return code 0.

The meaning of life is: 
jovial kelp
#

there ya go, much better-

dire siren
royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

The answer to life is 69
spare lance
#

@royal lake Question aph

royal lakeBOT
#

@spare lance :white_check_mark: Your eval job has completed with return code 0.

is it tho <@​!611418694245154847> 
dire siren
#

python says it is so it is

dire siren
#

possible

jovial kelp
#

I was actually thinking that somebody should create a tool that would translate code from one language into another ;-;

dire siren
#

i'ma try

jovial kelp
#

then again so is creating a language as a whole...

dire siren
#

modules are different

#

impossible

jovial kelp
#

when did i say anything about a module? ;-;

dire siren
#

you need to translate it

jovial kelp
odd sluice
#

!e e

royal lakeBOT
#

@odd sluice :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'e' is not defined
odd sluice
#

cool

jovial kelp
#

!e the meaning of life

royal lakeBOT
#

@jovial kelp :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     the meaning of life
003 |         ^
004 | SyntaxError: invalid syntax
jovial kelp
#

damn

odd sluice
#

!e import this

royal lakeBOT
#

@odd sluice :white_check_mark: Your eval job has completed with return code 0.

001 | The Zen of Python, by Tim Peters
002 | 
003 | Beautiful is better than ugly.
004 | Explicit is better than implicit.
005 | Simple is better than complex.
006 | Complex is better than complicated.
007 | Flat is better than nested.
008 | Sparse is better than dense.
009 | Readability counts.
010 | Special cases aren't special enough to break the rules.
011 | Although practicality beats purity.
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/ijisutijav.txt?noredirect

jovial kelp
#

VSC calling you out... 😳 Editing lambda_assignment.py 13:50:37 elapsed

#

oh jeez that's a long time

dire siren
#

@rough sapphire i'm getting some process, how to find how many , does a string have

#

current code:

import inspect
def lambda_to_def(func):
    lines = inspect.getsource(func)
    lines[lines.find("lambda ")+7:lines.find(":")]
acoustic moss
#

string.count(",")?

dire siren
#

nvm i'm too stupid i don't even need it lol

spare lance
#

what even

jovial kelp
#

i have now fully commented my code for the first time, feels... odd.

dire siren
#

@rough sapphire
test this

import inspect
def lambda_to_def(func,name):
    lines = inspect.getsource(func)
    code = f"def {name}("+lines[lines.find("lambda ")+7:lines.find(":")]+"):\n"
    if lines[lines.find(":")+1:len(lines)-1][0] != " ":
        code+="\treturn"+lines[lines.find(":")+1:len(lines)-1]
    else:
        code+="   return"+lines[lines.find(":")+1:len(lines)-1]
    return code
#

it's not fully functional expect errors running it

#

you have to give a lambda func on func

#

tested, worked for me idk other funcs so uh

#

there's probably some weird lambda i cant fix

#

returned this:

def a_name(_):
        return_+1
#

probably the \t made it weird

#

i'ma make it just 4 spaces

dire siren
#

i'ma add a space

#

new ver:

import inspect
def lambda_to_def(func,name):
    lines = inspect.getsource(func)
    code = f"def {name}("+lines[lines.find("lambda ")+7:lines.find(":")]+"):\n"
    if lines[lines.find(":")+1:len(lines)-1][0] != " ":
        code+="    return "+lines[lines.find(":")+1:len(lines)-1]
    else:
        code+="   return "+lines[lines.find(":")+1:len(lines)-1]
    return code
#

should be working on MOST lambdas

#

idk

#

had fun playing with strings

#

works

#

the name parameter is to protect user from doing something like lambda _:_+1 without variable assignment

#

so uh

spare lance
dire siren
#

i'ma make a list comp to for loop this is fun

dire siren
#

it'll die

spare lance
#

!epy import inspect def xyz(): return "blabbers" print(inspect.getsource(xyz))

dire siren
#

@rough sapphire use this version instead

def str_lambda_to_def(func,name):
    code = f"def {name}("+func[func.find("lambda ")+7:func.find(":")]+"):\n"
    if func[func.find(":")+1:len(func)-1][0] != " ":
        code+="    return "+func[func.find(":")+1:len(func)-1]
    else:
        code+="   return "+func[func.find(":")+1:len(func)-1]
    return code
#

!?

#

it didn't work?

#

h0w

spare lance
#

!epy import inspect def xyz(): return "blabbers" print(inspect.getsource(xyz))

#

what the bot ded?

dire siren
#

sad

spare lance
#

!e print("hello")

royal lakeBOT
#

@spare lance :white_check_mark: Your eval job has completed with return code 0.

hello
dire siren
#

!e import os
print(os.listdir())

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

['Pipfile', 'Pipfile.lock', 'config', 'snekbox', 'user_base', 'tests', 'LICENSE']
dire siren
#

no it doesn't

#

ok

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

001 | /snekbox
002 | {'tests', 'config', 'snekbox', 'user_base'}
spare lance
#

#bot-commands message @dire siren help what is this

#

oh wait same error

dire siren
#

use the string version

def str_lambda_to_def(func,name):
    code = f"def {name}("+func[func.find("lambda ")+7:func.find(":")]+"):\n"
    if code 
    if func[func.find(":")+1:len(func)-1][0] != " ":
        code+="    return "+func[func.find(":")+1:len(func)]
    else:
        code+="   return "+func[func.find(":")+1:len(func)]
    return code
``` wish for testers
dire siren
#
def str_lambda_to_def(func,name):
    if func.find("lambda ") != -1:
        code = f"def {name}("+func[func.find("lambda ")+7:func.find(":")]+"):\n"
    else:
        code = f"def {name}("+func[func.find("lambda")+7:func.find(":")]+"):\n"
    if func[func.find(":")+1:len(func)-1][0] != " ":
        code+="    return "+func[func.find(":")+1:len(func)]
    else:
        code+="   return "+func[func.find(":")+1:len(func)]
    return code
#

improve

dire siren
#

and it doesn't work lol

#

it'll probably work on a single lambda, you might want to run the function twice if there's more than one

spare lance
#

@acoustic moss bro do u have the answer to that algo question u sent?

acoustic moss
#

there is no official code solution though

spare lance
#

hmm wait i have a bad soln lemme just fair it out a bit

acoustic moss
#

just give me the 3 values you got

dire siren
#

i'might do some weird replace to regex stuff later on

acoustic moss
#

whomst hath pingedeth

dire siren
#

plz give creduts

spare lance
acoustic moss
#

O

dire siren
#

yay

acoustic moss
spare lance
#

for all valid reasons.. i am assuming i am wrong

acoustic moss
#

very nice

spare lance
#

oh wait

#

fuck

acoustic moss
#

πŸ™‡

#

didst thou bruteforce

spare lance
acoustic moss
#

i bruteforced lol

#

its exponential

spare lance
#

lesser than the algo for sure

#

coding the PIE is not fun yall

#

never try it

acoustic moss
#

whats pie

spare lance
#

principle of inclusion exclusion

acoustic moss
#

oh

spare lance
#

._.

#

hsp send brute force method pls

acoustic moss
#

i ran into negatives in the first iteration so i left it

dire siren
#

wow

spare lance
dire siren
#

make a list comp to for loop next

dire siren
acoustic moss
#

imma try doing it the correct way later

spare lance
acoustic moss
spare lance
#

i wanna lowkey time it

dire siren
#

pypy might be slow in some case

#

btw is it possible to make a cython jit

#

liek pypy + cython

spare lance
#
97229.0
0.006172657012939453```
not bad
#

assuming the number of loops i have used

acoustic moss
#

LMAO

#

mine takes 3s

spare lance
#

  File "E:\Coding_stuff\Python\projects\random_stuff\aph_problem.py", line 74, in <module>
    print(f(20,1))

  File "E:\Coding_stuff\Python\projects\random_stuff\aph_problem.py", line 64, in f
    if "0, 1, 0" not in ", ".join(i):

TypeError: sequence item 0: expected str instance, int found```
#

why did i name it aph problem tho.. should be hsp

acoustic moss
#

uh yeah do .join(map(str, i))

dire siren
#

why is it named aph_problem

#

kinda scary

#

is it my problem

spare lance
#

yes

#

ur problem

#

deal with it

#

πŸ”«

dire siren
#

sad

#

what is my problem anyways

spare lance
#

oh u mean the question?

#

hmm lemme find it

#

this

dire siren
#

ok

solemn leaf
# spare lance

!e

print((lambda n,k: len([i for i in __import__('itertools').product(range(k+1),repeat = n) if '0,1,0' not in ','.join(map(str,i))]))(3,2))
royal lakeBOT
#

@solemn leaf :white_check_mark: Your eval job has completed with return code 0.

26
solemn leaf
#

😎 worst time complexity

acoustic moss
#

that'll stop working for k >= 10 lol

solemn leaf
#

where's the catch

acoustic moss
#

'010' not in ...

#

a [0, 10] would become a false positive

solemn leaf
#

damn

#

ez fix

solemn leaf
#

bruh

#

space

#

sus

#

i fixed

acoustic moss
#

ok

solemn leaf
#

ok

dire siren
#

ok

edgy crest
#

ok

inland wolf
#

ok

shrewd prawn
#

ok

acoustic moss
#

no

shrewd prawn
#

ok

spare lance
#

no

#

things i am not good at :
golfing

#

how do yall even do it

edgy crest
#

thats the neat part, i dont

royal lakeBOT
#

@rough sapphire :white_check_mark: Your eval job has completed with return code 0.

Utah bread
spare lance
#

interesting

#

now expand it :troll:

tardy rain
#

Thats the opposite of golfing lol

spare lance
#

yes exactly

#

which is technically harder if u forgot the way u golfed stuff like that

#

how the heck do u even pronounce it

#

._.

latent scaffold
#

ob fus cation

clever solstice
#

how the heck do u pronounce what???

spare lance
clever solstice
#

when i lie

latent scaffold
#

yes

clever solstice
#

currently opening python...

lunar warren
#

NO

#

SPIDEY GAY

spare lance
#

no he the old one was good >:((

lunar warren
lunar warren
#

wtf is ur name

#

who r u

#

and why do u have the same pfp as my friend

spare lance
spare lance
lunar warren
#

wait what

#

omg

#

what does ur nem mean

spare lance
#

use .catify

lunar warren
#

:?

spare lance
#

.catify

median domeBOT
#

Your catified nickname is: α˜£α˜α—’ | α˜£α˜α—’

lunar warren
spare lance
#

just type ".catify"

lunar warren
#

.catify

median domeBOT
#

Your catified nickname is: Astonator7 | 🐈

spare lance
#

why change name... catify good >:((

lunar warren
#

BRUH

#

WHO ARE U

#

u r not my friend

spare lance
#

:sadge:

lunar warren
#

ayy

#

why do i have a goat in my name

spare lance
#

its a cat sigh

#

u need sleep mate

lunar warren
#

bc wtf are u saying ;-;

#

how is it a cat

#

;-;-;-;-;-;-;

#

oHHHHHHHHHHHHH

#

catify means

#

to cat urself

spare lance
lunar warren
#

Wut

#

bruh

#

i hate you

latent scaffold
#

Don't call people that

lunar warren
#

ohno

#

how many bans before we get kicked out

shrewd prawn
#

bruh what is this kid

spare lance
lunar warren
#

i meant warnings

karmic gust
#

That isn't acceptable

lunar warren
spare lance
#

oh my god scoff is here ||hide||

shrewd prawn
spare lance
versed girder
#

rust vs modern c++?

lunar warren
rough sapphire
#

Hey please don't be an asshole

odd sluice
#

wat

#

oh nvm I just read chat

rough sapphire
rough sapphire
#

@rough sapphire Hi. Do you mind hearing my project that im working on?

#

sure

#

what are u working on

#

o

#

that sounds nice

#

is it open source

#

oo

#

i see

#

you can actually represent a hexagonal map as a 3d cube map which is what im going to try and do to code it

#

nice

#

C++ i see

#

since a hexagon map kind of has 3 axis and so does 3d space

#

So cpp your main?

#

yes it was my first language. Im coming back to it after language hopping the biggest thing ive made in code is probably tetris in lua and love2d framework

#

Lua is nice

#

Dynamic and has performance

#

Rare to find

#

but not much libraries written for it compared to python but eh i dont use libraries very often.

#

Thats Lua's only disadvantage

#

i do like it though i find its simplicity very welcoming

#

But i wish i could learn Lua

#

however i doubt i would ever be doing that

#

I have been on the verge of quiting coding in pursuit of a career. As coding is really just a hobby for me. Ive struggeled to come up with game ideas which is why i got into coding to make games, but im just not very creative. Im giving my shot at creating board games in code and hopefully have as much fun as i did with tetris

rough sapphire
#

thanks

#

have a nice night

rough sapphire
#

well

#

its actualy a good thing if u enjoy not being creative and still programming

#

cuz

#

in jobs no one is going to let u be creative shock

#

theres gonna be a prod manager

#

and he/she is going to tell u what to do

#

and u do it

#

dats about it

acoustic moss
#

become the manager's manager ez

edgy rock
#

we have a joker here

acoustic moss
#

lol

#

needs a healthy dose of copium

rough sapphire
# rough sapphire Hm

do you know when to use a static assert and when to use a regualar assert? Isnt static assert for things that might fail at compile time and that are constant? or am i wrong

#

ah i seem to be right on this

rough sapphire
# rough sapphire Hm

did you know you can scope variables to a file by declaring them in a unnamed namespace like so

namespace
{
  int instance_count = 0;
}
last mantle
#

there are lots of people who hate py for no reason whatsoever

odd sluice
#

eh it's an opinion piece

#

so I'm ok with it

#

but still

#

a lot of it is inaccurate

odd sluice
#

quite nice stereotyping, isn't it?

wise schooner
#

kekidiot did you really read that?

shrewd prawn
#

hmm, generalizing people who use certain langs

spare lance
wise schooner
#

self keywords lmfao

#

that's not even a keyword

solid elbow
#

Not unreasonable for it to be one, though. this is a keyword in many languages.

wise schooner
#

it's just a parameter name Sadge

#

albeit the only one which PEP8 allows

#

but still
that's not called a keyword

rough sapphire
#

in c++ its a pointer to a object

odd sluice
#

lmfao

rough sapphire
#

hmm is this a keyword in c++

wise schooner
odd sluice
#

I could do this:

class OK:
  def __init__(e):
    ...
wise schooner
#

and then flake8 will scream at you

#

it's still a convention tho

solid elbow
wise schooner
#

yeah

spare lance
solid elbow
#

In Python, it's explicit, and named by the programmer. In other languages it's implicit and has a keyword for the name.

#

I'm not sure either approach is necessarily better, but Python's is definitely weird.

wise schooner
#

i like that approach

#

pithink i think a lot of languages use that too

odd sluice
wise schooner
#

doesn't rust use it?

#

and lua too

spare lance
#

ohkay wait just confirming... if u dont pass self parameter.. u cannot access self.variables right.. or can u?

wise schooner
#

yeah, you need a variable to store the instance

rough sapphire
#

less error prone if the object is passed in implicitly like in c++

wise schooner
#

it may or may not be self

#

that's just a convention

#

and PEP8 says that

#

inb4 esoteric code to bypass that

acoustic moss
#

i think you're even allowed to do Class.method(x) if x isn't an instance of Class pithink

solid elbow
wise schooner
#

staticmethod (/s)

solid elbow
#

In Python, a static method is just one that doesn't bind to the instance it's called on

#

The special thing that @staticmethod does is to disable the normal descriptor behavior of the function it's decorating

wise schooner
#

And only in Python will the difference between tabs and spaces cause the interpreter to have a heart attack.
why does the person code in notepad

#

oh wait

#

even notepad++ has an option to convert tabs to spaces

rough sapphire
wise schooner
#

your editor should have an option to convert tabs to 4 spaces (unless you use notepad)
you could just click that button and it fixes that

solid elbow
#

Yeah. That's also a fair hit, I think. It's bad that code that looks correct on a user's screen might be invisibly wrong.

solid elbow
spare lance
#

nvm

wise schooner
#

sublime text and vscode also show spaces and tabs (with dots etc)

odd sluice
#

there are some valid points - some thing that actually do have a problem
but they are mixed in a load of baloney facepalm
also would help if he calmed his voice against python devs
sounds like a personal vendetta smh

wise schooner
solid elbow
#

Most? Everything from vim to notepad

odd sluice
#

aren't tabs 4 spaces

spare lance
solid elbow
#

Indent levels are usually 4 spaces, at least in Python, and you get 4 spaces of indenting when you press the tab key. Those facts are orthogonal to the question of how a tab 0x09 byte in the file is displayed.

wise schooner
#

huh... just checked, notepad++ uses 4 spaces by default for tabs

#

same for vscode and sublime

#

i dunno about vim tho

edgy crest
#

oh god i have seen projects with 2 tabs as indents ferrisballSweat

odd sluice
#

discord indents:

solid elbow
wise schooner
#

peepoS nope, i just pressed a tab lol

#

it moved forward by 4 spaces

solid elbow
#

Right, whole different thing

odd sluice
#
  tab lol
shrewd prawn
#

have you seen notepad tabs lol

odd sluice
#

2 spaces 😒

wise schooner
#

discord used 2 spaces lol

dire siren
#

my tab:

  tab
odd sluice
dire siren
#

ye two spaces

shrewd prawn
#

notepad is amazing /s

#

notepad++ is better

solid elbow
wise schooner
#

lol

#

lemme try, brb

odd sluice
#
>>> print("\te")
        e
>>>

wtf

dire siren
#

probably different font

solid elbow
#

Most editors I know will, by default, show that as an a in column 1 and a b in column 9

shrewd prawn
#

your's doesnt seem to be a monospace font, aph

solid elbow
#

Good editors will display it as an a in column 1 and a b in column 9, but the 7 blank spaces will be colored differently or have some light dots filled in so they can't be mistaken for actual spaces

odd sluice
#
    readline.redisplay()
AttributeError: module 'readline' has no attribute 'redisplay'
>>>

anaconda install is shitting itself

wise schooner
#

lemme try notepad, brb

#

peepoS notepad uses... a lot of spaces

solid elbow
#

Yep, that's what I expect.

odd sluice
#
    e

notepad^

#

huh

acoustic moss
#

even the ipython shell converts to 4 spaces if you press tab

#

interesting

wise schooner
#

notepad++ is fine tho

solid elbow
#

!e ```py
print("a\tb")

royal lakeBOT
#

@solid elbow :white_check_mark: Your eval job has completed with return code 0.

a	b
solid elbow
#

Hah, that's weird.

wise schooner
#

it's just notepad which has a problem Sadge

solid elbow
#

Run that interactively in a terminal and I bet it looks like 7 spaces.

dire siren
#

"\b" is the backspace character am i correct?

wise schooner
#

others just use 4 spaces (idk about vim)

solid elbow
#

Every terminal I know of sets tabstops every 8 characters by default.

wise schooner
#

so it's notepad (non ++ version) and terminal based IDEs monkaHmm

solid elbow
#

Not just terminal based IDEs - terminals themselves.

dire siren
#

is tab tab but not space

solid elbow
#

There's no IDE involved there. Your terminal is deciding how to display the 0x09 byte, it's choosing to display it as a bunch of blank spaces up til the next column that's a multiple of 8

wise schooner
#

yep, i could see how that's gonna be a huge problem lol

dire siren
#

what is the problem, i cant quite follow lol

wise schooner
#

8 spaces would be... like 2 indents to a python user

#

the code won't be readable anymore ig

solid elbow
#

Which are rendered differently in different environments

solid elbow
#

It's an annoying problem that often trips up beginners, though.

wise schooner
#

YEP the first thing beginners need to install is black and flake8

solid elbow
#

Python has a whole special type of SyntaxError just to tell you that you've mixed tabs and spaces in your indent.

#

Neither black nor flake8 prevent this problem

wise schooner
#

black formats it on ctrl+s tho

solid elbow
#

black would fail to parse the code because of the incorrect indenting, just like the interpreter does.

wise schooner
#

so if the code was being save regularly (when it was just tabs), it's gonna be all 4 spaces

solid elbow
#

It can't format code it can't parse

wise schooner
#

yeah, it won't fix it after it's been borked

solid elbow
#

If you write your code with tabs, then black changes it to use spaces, and then you add more tabs for indenting into it, black can't fix it a second time.

wise schooner
#

oh

solid elbow
#

In that sense fixing it on ctrl-s was worse than doing nothing at all

wise schooner
#

yes Sadge

dire siren
#

time for a new code formatter - white (i bet it wont work 2)

solid elbow
#

Because if it was all tabs, things would have been fine, too

wise schooner
#

welp... ig PyCharm has tabs -> 4 spaces by default

#

but sublime and np++ needs it to be configured

solemn leaf
#

damn we are still at tabs πŸ’―

graceful basin
#

At the same time, many beginners make mistakes with indenting things differently than what the code gets parsed as in languages without significant whitespace

wise schooner
graceful basin
#

And errors > bugs

clear plume
solemn leaf
#

meanwhile discord tab lemon_sleepy

solid elbow
dire siren
spare lance
wise schooner
#

wait

graceful basin
#

Yeah, if you have well setup tooling, both options do great

wise schooner
#

list comps are nice Sadge

dire siren
#

yes

solemn leaf
#

yes

solid elbow
#

A C or Java formatter can reindent the file to match how it's syntactically interpreted.

dire siren
#

the new code formatter makes your code worse

dire siren
clear plume
#

Jk that's coming soonℒ️

dire siren
#

use your obfuscator to obfuscate your obfuscator

clear plume
#

And I want my deoptimizer to run at max performance

solid elbow
#

It's interesting that the author of that piece chose to talk about the lack of privates, but didn't mention the descriptor protocol, which is why Python doesn't need getters and setters like the languages the author likes do

wise schooner
#

i never use __private tbf

solid elbow
#

It's also telling that the author pointed to name mangling with two underscores rather than the convention of a single underscore for private

#

The author is just wrong about name mangling being the preferred way to make privates.

graceful basin
#

Yeah, haven't seen name mangling often

solid elbow
#

Yeah, it's needed in relatively specialized cases.

wise schooner
#

where is it needed tho?

dire siren
#

i feel this ot channel is too advanced i cant fit in lol

spare lance
graceful basin
#

When making a public open class that needs private members users can't override

solid elbow
#

You need name mangling when you want to add a private attribute or method to an existing class, where there is a chance that an existing subclass of that class has already used that same name for one of its own private attributes or methods

wise schooner
#

oh

shrewd prawn
#

just do eval() on a long string of encrypted text and decrypt it lol

dire siren
#

is there a decorator for private method

solid elbow
#

Nope. Python doesn't have privates.

dire siren
#

or i can just do if __name__ != "__main__" and leave

odd sluice
solid elbow
#

The convention is to denote something that users shouldn't touch by putting a single underscore at the start of its name.

odd sluice
solid elbow
odd sluice
#

i thinkℒ️

odd sluice
solid elbow
#

You can still access it.

odd sluice
solid elbow
#

It just changes the name.

shrewd prawn
#

what does __name__ equal if it doesn't equal '__main__'

odd sluice
dire siren
#

it it doesn't equal to main that means it's imported iirc

shrewd prawn
#

ok

dire siren
#

if it's main that means it's running the file

shrewd prawn
dire siren
#

idk

graceful basin
#

It's the name of the module

#

Generally the filename without .py

odd sluice
shrewd prawn
#

ye ic

solid elbow
royal lakeBOT
#

@solid elbow :white_check_mark: Your eval job has completed with return code 0.

42
dire siren
#

pyinstaller sucks, i can just make the file format to .exe and run it with python file.exe

odd sluice
#

but the access syntax is quite weird

solid elbow
#

Sure. Its name has been changed to make conflicts unlikely.

shrewd prawn
solid elbow
#

The purpose of name mangling is to avoid choosing a name for something that conflicts with a subclass or superclass. It's got nothing to do with privacy

dire siren
odd sluice
#

also what happens if you do setattr(self, "test with space", 1)?
unrelated but Shrug

solid elbow
#

Works fine.

shrewd prawn
odd sluice
dire siren
solid elbow
#

It adds a "text with space" key to self.__dict__

spare lance
#

!e

class Foo:
    def __init__(self):
        self.x = 42

f = Foo()
print(f.x)```
royal lakeBOT
#

@spare lance :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 6, in <module>
003 | AttributeError: 'Foo' object has no attribute '__x'
spare lance
#

wait why

solid elbow
odd sluice
dire siren
#

!e print("\Foo\bar")

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

\Fooar
dire siren
#

yay backspace works

solid elbow
# spare lance wait why

Because names with two leading underscores and without two trailing underscores are name mangled.

dire siren
#

!e print(chr(96)*2+"\b"+chr(96))

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

```
dire siren
#

weered

solid elbow
#

The attribute gets a different name than the name that appears in the code.

spare lance
#

ohhhhh

#

interesting

solid elbow
#

Inside the Foo class, self.__x is automatically replaced by self._Foo__x

#

Yum

dire siren
#

yes mango is one of the sweetest fruit

clear plume
#

?

dire siren
#

i liek to delete every message i sent, so probably you didn't see something

clear plume
#

Ahh

spare lance
solid elbow
#

And the purpose of that mangling isn't to make it private - after all, the new name is totally predictable. The purpose of the mangling is to prevent the name from conflicting with a parent or child class that might want to use the same name.

shrewd prawn
#

he sent "mangoed :(" before godlygeek's "Yum"

dire siren
solid elbow
#

Mango lassi is the best Indian dessert πŸ˜„

clear plume
#

Mango lassi is one the best desserts period.

odd sluice
#

idk man i like jalebis more

spare lance
odd sluice
#

and mess it up

spare lance
#

idk i like normal lassi more than mango lassi

solid elbow
#

We do give infractions for annoying nicks, heh

solid elbow
dire siren
#

the .catify nickname annoyed dogs lovers

clear plume
#

Not really

rough sapphire
#

i like both

spare lance
clear plume
#

I personally am a dog lover and I don't give a shit about the .catify command

dire siren
#

.catify @clear plume

median domeBOT
#

@clear plume α•‚α˜α—’

spare lance
solid elbow
#

Discord really has trouble with the Unicode RTL character. It does weird things like put the "edited" in the wrong spot if you edit the message

shrewd prawn
#

i see a lot of people say why not both for cats and dogs, by why not neither lol

dire siren
#

indeed

rough sapphire
#

My main is Python πŸ˜…

#

Im going to start revising my C++ today and continue working on my video editing software(Python)

rough sapphire
dire siren
rough sapphire
#

yeah idk

solid elbow
#

Unnamed namespaces are handy. The C equivalent is file level statics

rough sapphire
#

thanks!

#

Yeah

#

i need a ton of help with cpp

#

cause

#

like,

dire siren
rough sapphire
#

its not my main

solid elbow
#

Your example with the unnamed namespaces is basically equally to
static int foo = 1;

rough sapphire
#

im comfortable with the tutorial im watching rn but, πŸ™„

#

yt tutorials πŸ™„

rough sapphire
#

i know as a python enjoyer, i would not recommend people to use Tutorials for code based tutorials

solid elbow
rough sapphire
#

logic and concept based is fine

dire siren
spare lance
rough sapphire
#

but the problem is

#

i get build warning

#

ik build warnings are good

#

but

#

but im not used to em lemon_angrysad

solid elbow
rough sapphire
#

cause python give no warnings

dire siren
rough sapphire
#

they give error or no error

#

:D

#

yeah but it is nice to have compile time errors becuase youll catch errors that would otherwise go unoticed if everything was caught at runtime

solid elbow
#

I've seen lots of bugs in Python code that would have been caught at compile time in other languages. Things like except blocks referring to variables that don't exist

#

They're not exercised when everything works fine, so it's easy to miss that they'd be broken if they run

dire siren
#

i wish try except can catch syntax error

acoustic moss
#

why

shrewd prawn
#

bruh why tho

rough sapphire
#

just switch to compiled language

dire siren
#

more fun

#

but i dont make syntax error so that's probably not a thing for me

rough sapphire
#

or a compiled scripting language. Theres elixer julia

solid elbow
#

The module importing the syntactically incorrect one can handle the syntax error and do something about it.

dire siren
#

:O

acoustic moss
#

In [24]: try:
    ...:     eval("2+")
    ...: except SyntaxError:
    ...:     print("here")
    ...:
here

hmph

solid elbow
#

Yep, or that.

#

SyntaxError is catchable, but a try block inside an a syntactically incorrect file can never run, because the interpreter fails to even parse and compile the file, so it never gets a chance to run any code inside it

rough sapphire
rough sapphire
#

If i have a type that is a alias of of a type* how do i get the base type from the pointer type?

solid elbow
#

That's an odd thing to do, though it's possible with some metaprogramming...

rough sapphire
#

huh its not decay

#

ah type_traits

#

theres add_pointer and remove_pointer

solid elbow
#

Yep, just found it myself.

#

That said, I've programmed in C++ professionally for 10 years without ever once needing that - if you're new to C++, it's definitely not something you should need.

rough sapphire
#

yeah i know the type of it. its void* so i just need void

#

i dont really need it

#

just curious

dire siren
#

this is too fun

shrewd prawn
#

smh

dire siren
#

sry

shrewd prawn
#

lol

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

SPEED RUN EVAL 15
dire siren
#

6

#

oh deleted

#

yay

solid elbow
#

That's enough of that.

dire siren
#

sry

rough sapphire
#

lol

rough sapphire
#

can i run sagemath in colab?

#

its build on python but i cannot find something which does, neither is it on pip i think.

#

or i mean what should i do?
my pc is not too good, thats why i prefer colab.

olive remnant
#

is vsc the best ide for like c++ on ubuntu?

inland wolf
#

it works but i hear clion is better

dire siren
#

edit it

#

This is a‫ message

acoustic moss
#

that is indeed a message

rough sapphire
#

This is a‫ message

dire siren
#

there's a specific unicode doing that

#

you can try to find it

#

have fun

#

!e print("‫ message")

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

‫    message
dire siren
#

yay

royal lakeBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

quick ledge
#

!raw 867328449768062986

royal lakeBOT
#
== Raw message ==

This is a‫       message
acoustic moss
#

nice try

quick ledge
#

!charinfo

royal lakeBOT
#
Missing required argument

characters

quick ledge
#

ok lemon_pensive

#

alright, keep your secrets then

drifting sage
#

lmao

solid pollen
#

!charinfo This is a‫ message

royal lakeBOT
#
Character Info

\u0054 : LATIN CAPITAL LETTER T - T
\u0068 : LATIN SMALL LETTER H - h
\u0069 : LATIN SMALL LETTER I - i
\u0073 : LATIN SMALL LETTER S - s
\u0020 : SPACE -
\u0069 : LATIN SMALL LETTER I - i
\u0073 : LATIN SMALL LETTER S - s
\u0020 : SPACE -
\u0061 : LATIN SMALL LETTER A - a
\u202b : RIGHT-TO-LEFT EMBEDDING - ‫

Full Raw Text

\u0054\u0068\u0069\u0073\u0020\u0069\u0073\u0020\u0061\u202b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065

solid pollen
#

\u202b : RIGHT-TO-LEFT EMBEDDING - ‫

inland wolf
#

this is a message too

lean summit
#

hello

spare lance
#

This is a‫ message

spare lance
dire siren
#

wdym

spare lance
#

the unicode i meant

dire siren
#

ys

#

!e print("("

royal lakeBOT
#

@dire siren :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print("("
003 |              ^
004 | SyntaxError: unexpected EOF while parsing
dire siren
#

it'll die if i do that normal

spare lance
#

wait but what is the unicode for it wotah

dire siren
spare lance
#

test message <r:\u202b>

#

no >:((

#

now the heck does this work

dire siren
#

!e print(chr(0x202b))

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

‫
dire siren
#

^ grab this char above

spare lance
#

‫‫hello‫
world‫

dire siren
#

dont you try to edit the world

spare lance
#

interesting enough it gave a new line

#

!e print("hello",chr(0x202b),"world")

royal lakeBOT
#

@spare lance :white_check_mark: Your eval job has completed with return code 0.

hello ‫ world
spare lance
#

this message is ‫ edited

dire siren
#

this message is

#

why do you even need that lol

spare lance
#

yes but

#

hello ‫ world

mellow spire
royal lakeBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

mellow spire
#

doesn't work lemon_pensive

#

hello ‫ world

dire siren
#

e

#

!e print(69+42)

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

111
dire siren
#

!e print(int("111",2))

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

7
dire siren
#

!e print(69+420)

royal lakeBOT
#

@dire siren :white_check_mark: Your eval job has completed with return code 0.

489
dire siren
#

k doesnt work for this bye

spare lance
#

!e print(int("489",16))

royal lakeBOT
#

@spare lance :white_check_mark: Your eval job has completed with return code 0.

1161
spare lance
#

!e print(int("1161",8))

royal lakeBOT
#

@spare lance :white_check_mark: Your eval job has completed with return code 0.

625
spare lance
#

ah yes here we have the number @dire siren

solemn leaf
#

What is this bot commands

winter terrace
#

fuck this

#

i give up

#

anime is officially dead

#

i probably just need a bigger dataset but i just don't care anymore

dire siren
#

r u still doing grayscale anime gen

spare lance