#voice-chat-text-0

1 messages ยท Page 79 of 1

chrome pewter
#

getting this error

a newer version of python 3.9 is already installed
#

could you help @somber heath

somber heath
#

But Wookie does seem to be attending you.

chrome pewter
rapid chasm
#
if member in current_players:
    return

if len(current_players) >= 10:
    await member.disconnect()
    return

current_players.append(member)```
#

If member is not in current_players and current_players is <= 10

somber heath
#
if member in current_players:
    return

elif len(current_players) >= 10:
    await member.disconnect()
    return

else:
    current_players.append(member)```As an experiment in readability.
sharp urchin
#

you can return only once as well

#

in the end

#

we can!:{

#

in a function

#

how do i make it colorful:{}

somber heath
#

!code

wise cargoBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

somber heath
#

py

sharp urchin
#

yeh it doesnt

#

matter

#

just my habit to return only once

rapid chasm
#
        if member in current_players:
            return
        
        if len(current_players) >= 10:
            await member.disconnect()
            
            if member not in queue:
                queue.append(member)
            return
        
        current_players.append(member)```
chrome pewter
#

after spending hours finally

crude bison
#

What y'all doin

stuck furnace
#

๐Ÿ‘‹

#

Sorry, I joined in the middle of things. What did you need help with?

sharp urchin
#

for matchmaking

#

i see no prblm with it though

sharp urchin
stuck furnace
#

Can you give me a summary of the requirements?

#

Oh, what is this for?

#

Ah right ok

#

The logic looks ok to me.

#

There might be a race-condition if two people join at the same time.

#

I.e. you may end up with 11 people in the game.

#

If two people leave, then two new people join at the same time, you could end up adding both people.

#

Actually, wait

#

It it's asyncio there won't be a race condition. Sorry.

#

I was thinking about threaded code for some reason.

#

So is there an issue with it currently?

#

๐Ÿ‘

#

!paste

wise cargoBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

stuck furnace
#

this If it's a single file.

rapid chasm
stuck furnace
#

Do you have a wide monitor? ๐Ÿ˜„

somber heath
#

@simple siren ๐Ÿ‘‹

simple siren
#

Hello gang...

stuck furnace
#

I usually use black (code formatter).

simple siren
#

I see people in the room but I am not hearing anyone.

stuck furnace
#

๐Ÿ‘ Just taking a look at it. I'm a bit of a slow reader so this may take a while lol

crude bison
#

rush

#

He means do not rush

stuck furnace
#

No worries ๐Ÿ˜„

simple siren
#

is anyone speaking in voice chat? I see the green light but I am not hearing anyone.

stuck furnace
#

Probably Hettinger

stuck furnace
#

Yes

simple siren
#

nope still can't hear. I can hear when I enter the chatroom just not you guys. So I know my volume is up.

crude bison
#

Im making a login/register system

stuck furnace
#
Signature: list.remove(self, value, /)
Docstring:
Remove first occurrence of value.

Raises ValueError if the value is not present.
Type:      method_descriptor
sharp urchin
#

hello whats up

#

did the code work out?

#

i was not in for a while

rapid chasm
#
        current_players.append(member)

        try:
            queue.remove(member)
        except ValueError:
            pass```
sharp urchin
#

discard?

#

sounds like delete

#

is it the same? opal?

#

i use delete by using indexes

stuck furnace
#

Are you assigning any kind of role to players?

somber heath
#

set.remove set.discard @sharp urchin

sharp urchin
#

hmmm

#

sounds sumthing new

#

an example perhaps?

#

would be helpful

#

also can it be done by using the delete function?

stuck furnace
#

Right ok

#

Yeah I know what you mean I think

#

If someone's been in the queue for a long time, they get removed?

#

Hmm, that would be an "invariant" you might want to check.

#

Erm, it essentially means something which should always be true.

#

In this case, there should never be anyone in both current_player and queue.

simple siren
#

lmao

#

need a cup of coffee?

sharp urchin
#

hello @sly yarrow

rapid chasm
#
        if member in current_players:
            try:
                queue.remove(member)
            except ValueError:
                pass
            return```
stuck furnace
rapid chasm
#

!paste

wise cargoBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

rapid chasm
stuck furnace
#

Errrm, I'd need to think about it a bit.

#

brb

simple siren
#

lmao

stuck furnace
#

Sorry dude I gtg

#

I recommend asking for help in #discord-bots if you haven't already

#

No worries, you too!

#

๐Ÿ‘‹

rapid chasm
simple siren
#

I can hear you Maro

sly yarrow
#

@sharp urchin

simple siren
#

I could use some help or point me to the direction. I have WT32-ETH01 I am trying to find a code to use this board as a portable wireless dymanic wap. I will be wiring up a 18650 battery. I want to hook it to our company's network switch to broadcast a wifi signal so I can use my cell or laptop. Github has hundreds of libraries but the readme and terminology is hard to underground.

#

I am having to youtube with example of each library to better understand it.

#

Hootoo used to have one that worked great but is no longer made. ๐Ÿ˜ฆ

somber heath
#

@barren pebble ๐Ÿ‘‹

rapid chasm
#
async def check_missing_players():
    while True:
        for member in current_players:
            if (member.voice is None or (
                    member.voice.channel and member.voice.channel.id not in [712072729406472374, 712073013947924600,
                                                                             712073052854157342])):
                last_seen = datetime.now()
                if (datetime.now() - last_seen).total_seconds() >= 60:
                    current_players.remove(member)```
somber heath
#

@pseudo talon ๐Ÿ‘‹

sharp urchin
#

hey @midnight agate

somber heath
#

@whole bear๐Ÿ‘‹

whole bear
sharp urchin
#

brb

whole bear
#

Hi

#

Yes exactly

hoary olive
#

hello bossman

sharp urchin
#

hello hello

#

lol

#

looks like opal's done for the day

#

lmao yeh

#

nothing much

verbal zenith
#
this = {"userid":"last_seen"}

def check_missing_players():
  global this
  pass
sharp urchin
#

hmm i agree

#

they all just need the access tot he real last seen time

#

in order to disconnect

#

instantly

verbal zenith
#
user_dict = {}

async def check_missing_players():
    global user_dict
    while True:
        for member in current_players:
            if (member.voice is None or (
                    member.voice.channel and member.voice.channel.id not in [712072729406472374, 712073013947924600,
                                                                                712073052854157342])):
                if user_dict.get(member.id, None):
                  user_dict[member.id] = datetime.now()
                  continue
                if (datetime.now() - last_seen).total_seconds() >= 60:
                  current_players.remove(member)
simple siren
#

gtg now. i will keep searching. getting burned out.

rapid chasm
#
async def remove_member_from_current_players(member):
    if member.voice is None or (
            member.voice.channel and member.voice.channel.id not in [712072729406472374, 712073013947924600,
                                                                     712073052854157342]):
        if member in current_players:
            current_players.remove(member)

async def on_voice_state_update(member, before, after):
    if (before.channel and before.channel.id in [712072729406472374, 712073013947924600, 712073052854157342]) and (
            after.channel is None or after.channel.id not in [712072729406472374, 712073013947924600,
                                                              712073052854157342]):
        asyncio.get_event_loop().call_later(60, remove_member_from_current_players, member)```
stuck furnace
#

Yo

#

Ah right

#

Are you working to a deadline?

#

Ah right ๐Ÿ˜„

#

The code above?

#

What's the desired behaviour? Just remove someone if they've been out of the voice channel for 60 seconds?

#

I'd probably just periodically check for idle players.

#

I think the code above may fail in some cases where someone joins and leaves a few times.

#

E.g. if they happen to be out of the channel 60s after they previously left the channel (even if they've been in the channel in the intermediate period).

#

Ah yeah

#

What I find helps is to start with a clear design spec.

#

Sure ๐Ÿ‘

rapid chasm
stuck furnace
#

Oh right

rapid chasm
stuck furnace
#

Oh right nice

#

Yo @maiden beacon

maiden beacon
stuck furnace
#

Working on his bot

maiden beacon
stuck furnace
#

?

#

Oh right

#

Mhm

maiden beacon
#

alix

stuck furnace
#

Oh right

#

Ah yep Kaggle

maiden beacon
#

@sharp urchinbtr than me

stuck furnace
#

I think so yes. I don't have much experience with it myself, but it's a good place to practice data-science stuff.

maiden beacon
#

from my limited knowledge.. basically presenting and analysing data

stuck furnace
#

Erm, so they have competitions where you are given some real data and have to develop models.

#

Yeah just get started I think ๐Ÿ‘

#

They do have some short courses too.

#

There's tonnes of ML learning material online.

#

Any course from a reputable university is going to be ok.

maiden beacon
#

@sharp urchinakhi your dopamine levels for starting this is just op

stuck furnace
#

Yeah. You just need to pick one and go with it.

maiden beacon
#

amen to that

#

@sharp urchinf for respecc

#

w overall lol

sharp urchin
#

lmao

#

ty:}

maiden beacon
#

ight thegoodlukk

#

typos ouch

#

it hurts

stuck furnace
#

What level is your mathematical education at?

maiden beacon
#

mhmm.. yep

stuck furnace
#

Sorry, I didn't understand.

maiden beacon
#

a levels

stuck furnace
#

Oh right

#

It depends how advanced you want to go ๐Ÿ˜„

#

Right

#

Solid knowledge of statistics is essential.

maiden beacon
#

regression correlation and all that jazz lol

stuck furnace
#

If you're doing research in the field, you may need more advanced mathematics.

rapid chasm
#
# Check for idle players
@tasks.loop(seconds=60)
async def check_for_idle_players():
    for member in current_players:
        if member.voice is None or (member.voice.channel and member.voice.channel.id not in [712072729406472374, 712073013947924600, 712073052854157342]):
            current_players.remove(member)```
stuck furnace
#

Hmm, you need to keep track of when each member was last in the channel I think ๐Ÿค”

sharp urchin
#

later @maiden beacon

stuck furnace
#

When a player leaves the channel, make a note of the time they left.

#

Yeah sorry ๐Ÿ˜„

rapid chasm
#
if (member.voice and member.voice.channel and 
    member.voice.channel.id not in [712072729406472374, 712073013947924600, 712073052854157342]):```
stuck furnace
#

Erm, I'm not sure I understood sorry.

rapid chasm
#
1.         if member.voice is None or (member.voice.channel and member.voice.channel.id not in [712072729406472374, 712073013947924600, 712073052854157342]):

2. if (member.voice and member.voice.channel and 
    member.voice.channel.id not in [712072729406472374, 712073013947924600, 712073052854157342]):```
true palm
#

LOL

#

i got question after youre done with them

stuck furnace
#

Erm, so here's sort of psuedocode for how you could remove players:

#
absent_players = {}
KICK_AFTER = 60

def on_leave(member):
    absent_players[member.id] = now()

def on_join(member):
    absent_players.pop(member.id)

def every_60_seconds():
    idle_players = {
        player
        for player, last_seen in absent_players.items()
        if now() - last_seen > KICK_AFTER
    }
    for player in idle_players:
        remove(player)
#

Oh

#

No it's just a sketch.

#

Right ok

sharp urchin
stuck furnace
#

Yeah so this isn't code that will actually run, but is just to illustrate an approach you could take to removing idle players.

true palm
stuck furnace
#

now() is just a function that returns some kind of time-stamp for the current time (in this example)

true palm
#

i created two module file

#

keep on getting this error

stuck furnace
#

Right, you want subtotal.subtotal().

#

You have a function called subtotal in a module called subtotal.

#

@true palm this

true palm
#

OHHH OKOK THANK THANK YOU

#

i wil try tat

stuck furnace
#

Btw, you probably don't want to call subtotal in the subtotal module.

#

As this will mean it is called every time the module is imported.

#

And generally, it's a good idea to put imports at the top of the file, outside of any function bodies.

true palm
#

alrighti take note to that

#

thank you again

stuck furnace
true palm
#

alright i have done it

#

but how do i make the variable recognize with the imported file

#

i have to make it subtotal for my assignment sadly

#

this is my prompt for my assimgnet

#

im able to create the code in one module

#

i just dont know how to seperate them into different moduel

stuck furnace
#

@terse needle ๐Ÿ‘‹

#

How goes?

#

Ah no

#

Ah did it hear you say LX lol

terse needle
#

yeah I was just saying it's a shame I'm not part of the two letter name club anymore

limpid umbra
#

ABBA

stuck furnace
#

Having an Echo is really annoying when your name is Alex, as I learned

#

Ah sorry @true palm I didn't see you'd asked another question. You might get better help asking in #1035199133436354600

sharp urchin
#

they better pay my brudda for this hard work

#

he is putting in

true palm
#

nah you good

stuck furnace
#

Have you written a design document for this?

#

It definitely helps me organise my thoughts when I'm programming.

true palm
#

BWHAHAH

limpid umbra
#

your doing some voice recognition stuff?

stuck furnace
#

Yeah, you need some way of keeping track of when they left

#

Right. Erm it's not completely clear to me what behaviour you want sorry.

stuck furnace
#

It's essentially just a short document where you describe how you want the software to behave.

#

And plan out different scenarios/use-cases.

#

@terse needle have you used lark (parsing library)?

#

Oh

#

Erm, it's just a regular old parser ๐Ÿ˜„

#

But it's pretty good. Was trying it out yesterday/today.

rapid chasm
#
    next_player = queue.popleft()
    current_players[next_player] = datetime.datetime.now()```
terse needle
#

it's very cool

stuck furnace
#

What's the context of this code sorry?

verbal zenith
terse needle
stuck furnace
#

!eval ```py
from lark import Lark

english_grammar = '''
start: sentence

sentence: noun_phrase verb_phrase
noun_phrase: DETERMINER? ADJECTIVE? NOUN prepositional_phrase?
verb_phrase: VERB noun_phrase? prepositional_phrase?
prepositional_phrase: PREPOSITION noun_phrase

NOUN: "I" | "elephant" | "pyjamas" | "time" | "arrow" | "flies" | "fruit" | "banana"
VERB: "shot" | "flies" | "like"
ADJECTIVE: "red" | "yellow" | "fruit"
DETERMINER: "the" | "a" | "an" | "this" | "that" | "my"
PREPOSITION: "in" | "on" | "like"

%import common.WS
%ignore WS
'''
parser = Lark(english_grammar, ambiguity='explicit')

sentence = 'fruit flies like a banana'
tree = parser.parse(sentence)
print(tree.pretty())

wise cargoBOT
#

@stuck furnace :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | start
002 |   _ambig
003 |     sentence
004 |       noun_phrase	fruit
005 |       verb_phrase
006 |         flies
007 |         prepositional_phrase
008 |           like
009 |           noun_phrase
010 |             a
011 |             banana
... (truncated - too many lines)

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

stuck furnace
#

@terse needle this

verbal zenith
stuck furnace
#

Ah it was already in the bot surprisingly

verbal zenith
stuck furnace
#

Anyway, that's a demo of syntactic ambiguity in the English language verycool

verbal zenith
#

Same with parsync, albeit in a much cooler way

stuck furnace
#

See also: "I shot an elephant in my pyjamas"

terse needle
verbal zenith
#

ustafa is one smart ๐Ÿช

stuck furnace
#

Yep ๐Ÿ‘€

#

Nope

#

Erm, Peter Norvig

#

Oh right yeah.

#

I think every programmer should write a parser at least once ๐Ÿ˜„

#

Mhm

limpid umbra
#

peter norvig = neat stuff

sharp urchin
#

!e ```def test(strings):
result = []
for i ,num1 in enumerate(strings):
for j ,num2 in enumerate(strings):
if num1 + num2 == 0:
result.append((i , j ))
return result

string = [1232, -20352, 12547, 12440, 741, 341, 525, 20352, 91, 20]
print(test(string)) ```

wise cargoBOT
#

@sharp urchin :white_check_mark: Your 3.11 eval job has completed with return code 0.

[(1, 7), (7, 1)]
stuck furnace
#

Ah right yep, because you're considering both cases.

#

You should check that i < j.

#

Or, only iterate over j from i+1 to n.

#

Yeah a more efficient way to do this is to use a hash-table.

#

But to make your current solution work, you need to exclude the cases where i >= j.

#

sets and dicts are hash tables.

#
def test(strings):
    result = []
    for i ,num1 in enumerate(strings):
        for j ,num2 in enumerate(strings):
            if i < j and num1 + num2 == 0:
                result.append((i , j ))
    return result
verbal zenith
#

!e

def test(strings):
    result = []
    for i ,num1 in enumerate(strings):
        for j ,num2 in enumerate(strings):
            if num1 + num2 == 0 and i>j:
                result.append((i , j ))
    return result

string = [0, 0, 1232, -20352, 12547, 12440, 741, 341, 525, 20352, 91, 20]
print(test(string)) 
wise cargoBOT
#

@verbal zenith :white_check_mark: Your 3.10 eval job has completed with return code 0.

[(1, 0), (9, 3)]
stuck furnace
#

Yeah. The problem with this approach though is that the running time grows with the square of the length of the list.

#

So if you have a long input, it will take a really long time.

#

Yep

#

Oh right?

#

๐Ÿ‘

stuck furnace
sharp urchin
#

!e ```py
def test(strings):
result = []
for i ,num1 in enumerate(strings):
for j ,num2 in enumerate(strings):
if num1 + num2 == 0 and i != j:
result.append((i , j ))
return result

strings = [1232, -20352, 12547, 12440, 741, 341, 525, 20352, 91, 20]
print(test(strings))

stuck furnace
#

```py

verbal zenith
#

```python

#

```py

stuck furnace
#

You probably did ``` py

#

Or ```
py

verbal zenith
#

```py
code
```

stuck furnace
#

Which code sorry @rapid chasm ?

#

The stack idea? pithink

#

Sorry I think I missed something

sharp urchin
#

!e ```py
def test(strings):
result = []
for i ,num1 in enumerate(strings):
for j ,num2 in enumerate(strings):
if num1 + num2 == 0 and (j,i) not in result:
result.append((i , j ))
return result

strings = [1232, -20352, 12547, 12440, 741, 341, 525, 20352, 91, 20]
print(test(strings))```

wise cargoBOT
#

@sharp urchin :white_check_mark: Your 3.11 eval job has completed with return code 0.

[(1, 7)]
sharp urchin
#

tadaaa!!

#

i got it:}

stuck furnace
#

Erm, I think I suggested something similar?

#

I'm not sure what you mean sorry.

rapid chasm
#
absent_players = {}
KICK_AFTER = 60

def on_leave(member):
    absent_players[member.id] = now()

def on_join(member):
    absent_players.pop(member.id)

def every_60_seconds():
    idle_players = {
        player
        for player, last_seen in absent_players.items()
        if now() - last_seen > KICK_AFTER
    }
    for player in idle_players:
        remove(player)```
stuck furnace
#

Nah. I never really parse long explanations sorry. After like 10 words my brain shuts off ๐Ÿ˜„

sharp urchin
#

lmao same with me

#

i couldnt comprehend

#

the code

#

after a while

#

also i think its a raw code isnt it?

stuck furnace
#

Yeah, I wasn't too sure about the delayed call thing.

#

Yep ๐Ÿ‘

#

You don't have to call it "every_60_seconds"

rapid chasm
#

absent_players = {}

#

absent_players = []

stuck furnace
#

Yeah, in the example it's a dictionary mapping user-ids to the timestamp they were last seen at.

#

[(memberid, last_seen), ...] vs {memberid: last_seen, ...}

#

Errrr

#

I guess you could.

#

I never have though.

#

Actually wait, I did implement a toy hash table on a course I took.

stuck furnace
#

Erm, I'm not sure sorry.

rapid chasm
#

@stuck furnace Could I use member instead of member.id for absent_players.pop(member.id)

stuck furnace
#

Which is a requirement for using a value as a key in a dictionary

#

Yep

rapid chasm
#

absent_players = []

stuck furnace
#

Using the ID, which is just a number, may be simpler.

#

Both the member object, and the ID are representations of a member.

#

In this case all you need is a representation that uniquely identifies members.

amber raptor
#

hash on member id

#

because it's also what you need to look someone up

rapid chasm
#
    next_player = queue.popleft()  # Get the next player in the queue and remove them from the deque
    current_players.append(next_player)
    await ctx.send(f'{next_player.mention} You are up next! Please join the [#712072729406472374](/guild/267624335836053506/channel/712072729406472374/) voice channel to begin your game.')
    absent_players[next_player.id] = datetime.datetime.now()```
stuck furnace
#

Hey Rabbit ๐Ÿ˜„

amber raptor
#

!e python import datetime print(datetime.datetime.now())

wise cargoBOT
#

@amber raptor :white_check_mark: Your 3.11 eval job has completed with return code 0.

2023-02-12 19:01:56.188273
stuck furnace
#

@verbal zenith ๐Ÿ‘‹

#

You could probably get away with time.time().

amber raptor
#

!e python import time print(time.time())

wise cargoBOT
#

@amber raptor :white_check_mark: Your 3.11 eval job has completed with return code 0.

1676228578.7616389
stuck furnace
#

You can subtract one datetime object from another and get a timedelta.

#

But dealing with unix timestamps is probably simpler.

verbal zenith
#

!e

import datetime
from time import sleep

now = datetime.datetime.now()
sleep(2)
then = datetime.datetime.now()
print(now<then)
amber raptor
#

!e python import time import datetime a = int(time.time()) print(a) print(datetime.datetime.fromtimestamp(a))

wise cargoBOT
#

@amber raptor :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 1676228676
002 | 2023-02-12 19:04:36
#

@verbal zenith :white_check_mark: Your 3.11 eval job has completed with return code 0.

True
rapid chasm
#

int(time.time())

jagged night
#

what are you guys doing ?

stuck furnace
#

@verbal zenith My quick attempt at making a hash table: ```py
class MyHashTable:
def init(self):
self.buckets = [[] for _ in range(20)]

def __setitem__(self, key, value):
    if key in self:
        del self[key]
    self.get_bucket(key).append((key, value))

def __getitem__(self, key):
    try:
        return next(
            v
            for k, v in self.get_bucket(key)
            if k == key
        )
    except StopIteration:
        raise KeyError

def __delitem__(self, key):
    bucket = self.get_bucket(key)
    try:
        idx = next(
            i
            for i, (k, v) in enumerate(bucket)
            if k == key
        )
    except StopIteration:
        raise KeyError
    del bucket[idx]              

def __contains__(self, key):
    return any(
        key == k
        for k, v in self.get_bucket(key)
    )

def get_bucket(self, key):
    return self.buckets[hash(key) % len(self.buckets)]
sharp urchin
#

aight imma head out

#

later guys.:}

stuck furnace
#

Yep verycool

#

It's not dynamically sizing, so performance will degrade pretty quickly.

#

Sorry, I'm being called way ๐Ÿ‘‹

verbal zenith
#

!e

class MyHashTable:
    def __init__(self):
        self.buckets = [[] for _ in range(20)]

    def __setitem__(self, key, value):
        if key in self:
            del self[key]
        self.get_bucket(key).append((key, value))

    def __getitem__(self, key):
        try:
            return next(
                v
                for k, v in self.get_bucket(key)
                if k == key
            )
        except StopIteration:
            raise KeyError

    def __delitem__(self, key):
        bucket = self.get_bucket(key)
        try:
            idx = next(
                i
                for i, (k, v) in enumerate(bucket)
                if k == key
            )
        except StopIteration:
            raise KeyError
        del bucket[idx]              

    def __contains__(self, key):
        return any(
            key == k
            for k, v in self.get_bucket(key)
        )

    def get_bucket(self, key):
        return self.buckets[hash(key) % len(self.buckets)]

x = MyHashTable()
x["test"] = 6
print(x)
print(x["test"])
stuck furnace
#

Back in a bit ๐Ÿ‘‹

wise cargoBOT
#

@verbal zenith :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | <__main__.MyHashTable object at 0x7fe40905c0d0>
002 | 6
rapid chasm
gray perch
#

what are they talking about @uncut meteor

stuck furnace
rapid chasm
tepid edge
amber raptor
#

!e ```python
import random
a = 0
while a < 30:
print(random.randint(0,1))
a += 1

wise cargoBOT
junior ermine
#

helloo

#

how are you

#

let me go trough my another account

somber heath
#

!kindling @vocal abyss

wise cargoBOT
#

Kindling Projects

The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.

somber heath
#

@whole bear I'm off to dinner, now, so hi bye. ๐Ÿ‘‹

sharp urchin
#

!voice

wise cargoBOT
#

Voice verification

Canโ€™t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

somber heath
#

@granite knoll ๐Ÿ‘‹

#

See above.

somber heath
#

@bronze sedge ๐Ÿ‘‹

#

@stoic wing ๐Ÿ‘‹

sly yarrow
#

i have a question regarding decorators:

@register.func()
def test():
    pass

if we assume that the register is a function, and the register access some element inside this function or what is this?
i have seen decorators, but it was like this

@register
def test():
    pass

without dot and etc

i got this idea from the django framework Templatetags

from django import template

register = template.Library()

@register.simple_tag()
def total_posts():
    pass 

and I want to understand the logic behind register decorator

somber heath
#

@dim raven ๐Ÿ‘‹

dim raven
#

hallo

#

i have no promissions

wise cargoBOT
#

Voice verification

Canโ€™t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

dim raven
#

i got it

somber heath
#

@jagged olive ๐Ÿ‘‹

jagged olive
sharp urchin
#

hello

hoary olive
#

hello bossman

sharp urchin
#

hello

#

brudda

chrome pewter
#

any suggestions?

sharp urchin
#

how your chat bot project go? @rapid chasm

#

hello @sly yarrow

sly yarrow
sharp urchin
#

glad to hear tht

#

:}

sly yarrow
#

!e

def test():
    variable = 2
test.__dict__
wise cargoBOT
#

@sly yarrow :warning: Your 3.11 eval job has completed with return code 0.

[No output]
rapid chasm
#

absent_players = {}
absent_players = []
absent_players = ()

sharp urchin
#

user_name : user_id

#

key value

chrome pewter
#

dictionary would be perfect for this

#

I think

#

you are welcome

somber heath
#

I've done it before, it's just my brain isn't having a bar of it right now.

sharp urchin
#

glad:}

somber heath
#

Or have I done it before?

hoary olive
#

100$ isnt that much

#

job = consistent pay

#

tip = bad

#

thats debt then

#

thats even worse

#

freelancing you mean

#

respect ๐Ÿ‘

#

not a lot of ppl would do that

somber heath
#

!e ```py
class A:
def b():
def c(func):
def d(v):
return func(v) * 2
return d
return c

@A.b()
def func(v):
return v

print(func(5))``` @sly yarrow Maybe? I can't help but feel as though the number of circumstances in which you'd use this would be limited.

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

10
hoary olive
#

๐Ÿ˜‚

hoary olive
sharp urchin
#

i like it

hoary olive
#

woops mixup

sharp urchin
#

have done questions

#

on it

#

DSA? ahh

sly yarrow
somber heath
#

!e ```py
def func():
pass

func.v = 5
print(func.v)```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

5
somber heath
#

!e ```py
def func():
func.v = 5

func()
print(func.v)
print(dir(func))```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 5
002 | ['__annotations__', '__builtins__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__getstate__', '__globals__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'v']
somber heath
#

!e ```py
def func():
pass

func.a, func.b, func.c = 1, 2, 3
print(func.dict)```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

{'a': 1, 'b': 2, 'c': 3}
sly yarrow
#

!e


def test():
    s = 32
    try:
        print(variable)
    except NameError as e:
        pass
    
test.__dict__["variable"] = "hello"
test()

somber heath
#

!e ```py
def func():
pass

func.dict['a'] = 5
print(func.a)```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

5
sharp urchin
#
s = s.replace("IV", "IIII").replace("IX", "VIIII").replace("XL", "XXXX").replace("XC", "LXXXX").replace("CD", "CCCC").replace("CM", "DCCCC")```
#
class Solution:
    def romanToInt(self, s: str) -> int:
        roman_to_integer = {
            'I': 1,
            'V': 5,
            'X': 10,
            'L': 50,
            'C': 100,
            'D': 500,
            'M': 1000,
        }
        s = s.replace("IV", "IIII").replace("IX", "VIIII").replace("XL", "XXXX").replace("XC", "LXXXX").replace("CD", "CCCC").replace("CM", "DCCCC")
        return sum(map(lambda x: roman_to_integer[x], s))
sly yarrow
#
class Solution(object):
    def romanToInt(self, s):
        dict_of_num = {
            'I':1,
            'V':5,
            'X':10,
            'L':50,
            'C':100,
            'D':500,
            'M':1000,
        }
        n = 0
        tmp = dict_of_num[s[0]]
        for i in s:
            if dict_of_num[i] > tmp:
                n += dict_of_num[i] - (2*tmp)
            else:
                n += dict_of_num[i]
            
            tmp = dict_of_num[i] 

        return n

somber heath
#

!zen

wise cargoBOT
#
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

sharp urchin
#

i will take the win then

#

thank you

#

:}

#

ly opal < 3

#

yes yes

#

i win

#

:{}

#

thanks opal

#

your a lovely guy

#

:}

#

yes yes:{}

#

yes it does

#

ty:}

rapid chasm
#
def estimate_mmr_from_tier_and_rank(tier_and_rank):
    mapping = {
        "Unranked": 1300,
        "Iron 4": 1100,
        "Iron 3": 1125,
        "Iron 2": 1150,
        "Iron 1": 1175,
        "Bronze 4": 1200,
        "Bronze 3": 1225,
        "Bronze 2": 1250,
        "Bronze 1": 1275,
        "Silver 4": 1400,
        "Silver 3": 1425,
        "Silver 2": 1450,
        "Silver 1": 1475,
        "Gold 4": 1600,
        "Gold 3": 1625,
        "Gold 2": 1650,
        "Gold 1": 1675,
        "Platinum 4": 1800,
        "Platinum 3": 1825,
        "Platinum 2": 1850,
        "Platinum 1": 1875,
        "Diamond 4": 2000,
        "Diamond 3": 2025,
        "Diamond 2": 2050,
        "Diamond 1": 2075,
        "Master 4": 2200,
        "Master 3": 2225,
        "Master 2": 2250,
        "Master 1": 2275,
        "Grandmaster 4": 2400,
        "Grandmaster 3": 2425,
        "Grandmaster 2": 2450,
        "Grandmaster 1": 2475,
        "Challenger 4": 2600,
        "Challenger 3": 2625,
        "Challenger 2": 2650,
        "Challenger 1": 2675
    }
    return mapping.get(tier_and_rank)```
sly yarrow
#

@chrome pewter

rapid chasm
#
def estimate_mmr_from_tier_and_rank(tier_and_rank):
    with open("mapping.json", "r") as f:
        mapping = json.load(f)
    return mapping.get(tier_and_rank)```
#
{
    "Unranked": 1300,
    "Iron 4": 1100,
    "Iron 3": 1125,
    "Iron 2": 1150,
    "Iron 1": 1175,
    "Bronze 4": 1200,
    "Bronze 3": 1225,
...........
}```
somber heath
#
with open("mapping.json") as f:
    mapping = json.load(f)

#Then every time you'd call estimate_mmr_from_tier_and_rank, instead...
mapping.get(tier_and_rank)```
#

Plus, loading it up from a file within the def means it reads it every time.

#

@royal reef ๐Ÿ‘‹

royal reef
#

๐Ÿ––

wise cargoBOT
#

Voice verification

Canโ€™t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

somber heath
#

@whole bear ๐Ÿ‘‹

sharp urchin
#

๐Ÿ˜ถโ€๐ŸŒซ๏ธ

sharp urchin
#

"WE ARE NICE"

#

lol

chrome pewter
sharp urchin
#

@rapid chasm being nice doesnt mean leaving vc

#

:{}

chrome pewter
sharp urchin
obsidian dragon
#
import discord
from discord.ext import commands


class Select(discord.ui.Select):
    def __init__(self):
        options=[
            discord.SelectOption(label="Blue", emoji="๐ŸŸฆ", description="Blue role"),
            discord.SelectOption(label="Red", emoji="๐ŸŸฅ", description="Red role"),
            discord.SelectOption(label="Green", emoji="๐ŸŸฉ", description="Green role"),
        ]
        super().__init__(placeholder="Choose your team", max_values=1, min_values=1, options=options)

    async def callback(self, interaction: discord.Interaction):
        print(1)
        user = interaction.user
        print(user)
        print(2)
        guild = interaction.guild
        print(3)
        if self.values[0] == "Blue":
            print(4)
            role = await guild.create_role(name="Blue", color=discord.Color.blue())
            print(5)
            print(role)
            await user.edit(roles=[role])
            print(6)
            await interaction.response.send_message("Team Blue", ephemeral = True)
            print(7)
        elif self.values[0] == "Red":
            role = await guild.create_role(name="Red", color=discord.Color.red())
            await user.edit(roles=[role])
            await interaction.response.send_message("Team Red", ephemeral = True)
        elif self.values[0] == "Green":
            role = await guild.create_role(name="Green", color=discord.Color.green())
            await user.edit(roles=[role])
            await interaction.response.send_message("Team Green", ephemeral = True)

class SelectView(discord.ui.View):
    def __init__(self, *, timeout=30):
        super().__init__(timeout=timeout)
        self.add_item(Select())

class Role(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    async def role(self, ctx):
        await ctx.send("Pick a role", view=SelectView(), delete_after=15)

async def setup(bot):
    await bot.add_cog(Role(bot))
sharp urchin
#

"good"

rapid chasm
#

!paste

wise cargoBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

obsidian dragon
#
1
Osyra#5781
2
3
4
5
Blue
sharp urchin
#

i see a traffic signal!!!

#

up there

somber heath
#

5Blue1Brown

sharp urchin
#

:{}

#

later

#
 for i in range(len(strs[0])):
        if strs[0][i] == strs[-1][i]:
            prefix += strs[0][i]```
chrome pewter
#

or```py
a = [[1,2],3]

somber heath
#

!e py strs = 'abc', 'defg', 'hijkl' print(strs[0])

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

abc
somber heath
#
len('abc')```
chrome pewter
#

!e

strs = ['abc','efg']
print(strs[0][1])
wise cargoBOT
#

@chrome pewter :white_check_mark: Your 3.11 eval job has completed with return code 0.

b
sharp urchin
#

ty

#

:}

somber heath
#

!e py text = "apple" for i in range(len(text)): print(text[i])However...

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | a
002 | p
003 | p
004 | l
005 | e
somber heath
#

!e py text = "apple" for letter in text: print(letter)

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | a
002 | p
003 | p
004 | l
005 | e
somber heath
#

!e py text = "apple" for i, letter in enumerate(text): print(i, letter)

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 0 a
002 | 1 p
003 | 2 p
004 | 3 l
005 | 4 e
chrome pewter
#

!e

text = "Opal"
for i in range(len(text)):
    print(text[i])
wise cargoBOT
#

@chrome pewter :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | O
002 | p
003 | a
004 | l
somber heath
#

!e py text = "apple" for i, _ in enumerate(text): print(text[i], text[-i])

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | a a
002 | p e
003 | p l
004 | l p
005 | e p
somber heath
#

!e py text = "apple" for a, b in zip(text, text[::-1]): print(a, b)

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | a e
002 | p l
003 | p p
004 | l p
005 | e a
chrome pewter
#

!e

exit()
wise cargoBOT
#

@chrome pewter :x: Your 3.11 eval job has completed with return code 1.

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

!e py import sys sys.exit()

wise cargoBOT
#

@somber heath :warning: Your 3.11 eval job has completed with return code 0.

[No output]
somber heath
#

!e py import sys sys.exit(9001)

wise cargoBOT
#

@somber heath :warning: Your 3.11 eval job has completed with return code 41.

[No output]
somber heath
#

41? Boo hiss.

#

The thing with the Python bot's Python environment, Snekbox, it's all sandboxed and built and torn down each time.

#

So importing sys is not a security issue.

hoary olive
#

!e

dir()
wise cargoBOT
#

@hoary olive :warning: Your 3.11 eval job has completed with return code 0.

[No output]
hoary olive
#

!e

print(dir())
wise cargoBOT
#

@hoary olive :white_check_mark: Your 3.11 eval job has completed with return code 0.

['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__']
hoary olive
#

!e

print(__builtins__)
wise cargoBOT
#

@hoary olive :white_check_mark: Your 3.11 eval job has completed with return code 0.

<module 'builtins' (built-in)>
hoary olive
#

!e

__builtins__.__dict__['dir'] = None
print(dir)
wise cargoBOT
#

@hoary olive :white_check_mark: Your 3.11 eval job has completed with return code 0.

None
chrome pewter
#

!e

import os
os.system('/shutdown')
hoary olive
#

ah

#

perhaps

wise cargoBOT
#

@chrome pewter :warning: Your 3.11 eval job has completed with return code 0.

[No output]
#
Missing required argument

code

hoary olive
#

!e

_builtins__.__dict__['abs'] = None
print(abs(-100))
wise cargoBOT
#

@hoary olive :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name '_builtins__' is not defined. Did you mean: '__builtins__'?
hoary olive
#

fuck you stupid bot

sharp urchin
#

hello sir hemlock

#

ohk imma go now....catch yall later!

#

byee:}

obsidian dragon
#

!e

wise cargoBOT
#
Missing required argument

code

#
Command Help

!eval [python_version] <code, ...>
Can also use: e

Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside of them.

By default your code is run on Python's 3.11 beta release, to assist with testing. If you run into issues related to this Python version, you can request the bot to use Python 3.10 by specifying the python_version arg and setting it to 3.10.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!

#

@obsidian dragon :white_check_mark: Your 3.11 eval job has completed with return code 0.

hello world
obsidian dragon
#

!e

print(1/0)
wise cargoBOT
#

@obsidian dragon :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | ZeroDivisionError: division by zero
obsidian dragon
#

!e

print(dir("../"))
wise cargoBOT
#

@obsidian dragon :white_check_mark: Your 3.11 eval job has completed with return code 0.

['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
obsidian dragon
#

!e

print(dir("../../../../../../"))
wise cargoBOT
#

@obsidian dragon :white_check_mark: Your 3.11 eval job has completed with return code 0.

['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
somber heath
#

@stark osprey ๐Ÿ‘‹

obsidian dragon
#

!e

import socket
hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
 
print("Your Computer Name is:" + hostname)
print("Your Computer IP Address is:" + IPAddr)
wise cargoBOT
#

@obsidian dragon :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 3, in <module>
003 | socket.gaierror: [Errno -3] Temporary failure in name resolution
#

@obsidian dragon :warning: Your 3.11 eval job has completed with return code 0.

[No output]
somber heath
#

!e py import os print(os.listdir('/'))

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

['usr', 'snekbox', 'lib64', 'lib', 'etc']
obsidian dragon
#

!e

import os
print(os.listdir('/../'))
wise cargoBOT
#

@obsidian dragon :white_check_mark: Your 3.11 eval job has completed with return code 0.

['usr', 'snekbox', 'lib64', 'lib', 'etc']
obsidian dragon
#

!e

import os
print(os.listdir('/../../'))
wise cargoBOT
#

@obsidian dragon :white_check_mark: Your 3.11 eval job has completed with return code 0.

['local', 'lib']
obsidian dragon
#

!e

import os
print(os.listdir('/../../'))
wise cargoBOT
#

@obsidian dragon :white_check_mark: Your 3.11 eval job has completed with return code 0.

['usr', 'snekbox', 'lib64', 'lib', 'etc']
obsidian dragon
#

!e

wise cargoBOT
#
Missing required argument

code

#
Command Help

!eval [python_version] <code, ...>
Can also use: e

Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside of them.

By default your code is run on Python's 3.11 beta release, to assist with testing. If you run into issues related to this Python version, you can request the bot to use Python 3.10 by specifying the python_version arg and setting it to 3.10.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!

obsidian dragon
#

!e

import sys
if sys.platform == 'win32':
  import win32_sysinfo as sysinfo
elif sys.platform == 'darwin':
  import mac_sysinfo as sysinfo
elif 'linux' in sys.platform:
  import linux_sysinfo as sysinfo
#etc

print 'Memory available:', sysinfo.memory_available()
wise cargoBOT
#

@obsidian dragon :x: Your 3.11 eval job has completed with return code 1.

001 |   File "<string>", line 10
002 |     print 'Memory available:', sysinfo.memory_available()
003 |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
004 | SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
obsidian dragon
#

!e

import sys
if sys.platform == 'win32':
  import win32_sysinfo as sysinfo
elif sys.platform == 'darwin':
  import mac_sysinfo as sysinfo
elif 'linux' in sys.platform:
  import linux_sysinfo as sysinfo
#etc

print('Memory available:', sysinfo.memory_available())
wise cargoBOT
#

@obsidian dragon :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 7, in <module>
003 | ModuleNotFoundError: No module named 'linux_sysinfo'
pallid hazel
#

arggg... my current iteration of a script makes calls to an api to get historical data.. ive compounded the requests as much as possible i think, how ever is like 10requests per device.. running almost 1k devices atm the api has slowed my script down from 5 to 10mins.. such a pain.

obsidian dragon
#

!e

import sys


print(sys.platform)
wise cargoBOT
#

@obsidian dragon :white_check_mark: Your 3.11 eval job has completed with return code 0.

linux
pallid hazel
#

not really, just venting

obsidian dragon
vocal basin
#

still trying to do something with the same algorithm

obsidian dragon
#

rainbow

vocal basin
#

those two were after I added multiprocessing (and did it incorrectly)

obsidian dragon
#

!e

import os
os.system('sudo apk add nodejs npm')
wise cargoBOT
#

@obsidian dragon :warning: Your 3.11 eval job has completed with return code 0.

[No output]
vocal basin
#

then I added primitive post-processing (median to reduce noise)

somber heath
#

!d subprocess

wise cargoBOT
#

Source code: Lib/subprocess.py

The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace several older modules and functions:

os.system
os.spawn*
```  Information about how the [`subprocess`](https://docs.python.org/3/library/subprocess.html#module-subprocess "subprocess: Subprocess management.") module can be used to replace these modules and functions can be found in the following sections.
somber heath
#

"connect to their input/output/error pipes"

vocal basin
#

also, I changed the algorithm in such way that it has .1% chance to overwrite the node it's already visited but it's not very noticeable

pallid hazel
somber heath
#

@jade surge ๐Ÿ‘‹

obsidian dragon
vocal basin
#

I just realised why using normal distribution in colour mutation was kind of a correct choice

self.colour += k * np.random.normal(0, 1.0, size=C)
vocal basin
vocal basin
#

discord.py has colour as default, iirc
with color aliased to it

rapid chasm
#
            timeout_task = timeout_dict.get(member)
            if timeout_task:
                timeout_task.cancel()```
somber heath
#

@devout agate ๐Ÿ‘‹

vocal basin
#

{}/dict() is good for in-memory storage depending on what you store

somber heath
wise cargoBOT
#

@somber heath :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'cancel'
vocal basin
#

time data may be better stored in a database

#

it's against the rules to sell anything

vocal basin
#

!paste

wise cargoBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

rapid chasm
#
async def remove_player_after_timeout(member):
    await asyncio.sleep(10)
    current_players.remove(member)
    del timeout_dict[member]

@client.event
async def on_voice_state_update(member, before, after):
    # Check the customs voice channels
    if (before.channel is None or before.channel.id not in [1067853227237851177, 1067853355688402995, 1067853377435869335]) and (after.channel and after.channel.id in [1067853227237851177, 1067853355688402995, 1067853377435869335]):
        
        if member in current_players:
            # Member is already in current_players, so cancel their previous timeout task
            timeout_task = timeout_dict.get(member)
            if timeout_task:
                timeout_task.cancel()
            return
        
        if len(current_players) >= 2:
            # There are already 2 players in current_players, so disconnect the new member
            await member.move_to(None)
            return

        # Member is not in current_players and there's room, so add them to current_players
        current_players.append(member)

    if (before.channel and before.channel.id in [1067853227237851177, 1067853355688402995, 1067853377435869335]) and (after.channel is None or (after.channel and after.channel.id not in [1067853227237851177, 1067853355688402995, 1067853377435869335])):
        if member in current_players:
            # Member has left one of the voice channels, so start a timeout task
            timeout_task = asyncio.create_task(remove_player_after_timeout(member))
            timeout_dict[member] = timeout_task```
vocal basin
#

replace (before.channel and before.channel.id in [1067853227237851177, 1067853355688402995, 1067853377435869335]) and (after.channel is None or (after.channel and after.channel.id not in [1067853227237851177, 1067853355688402995, 1067853377435869335])) with a function/method call

#
if joined(before) and not joined(after):
    if member in current_players:
        timeout_dict[member] = asyncio.create_task(remove_player_after_timeout(member))
#
def joined(state):
    return state.channel and state.channel.id in [1067853227237851177, 1067853355688402995, 1067853377435869335]
#

almost each place the code has comments, they're either useless or the code can be improved to make them useless

#

explanatory comments are rarely useful for telling what the code does

#

("imperative comments"?)

#

idk how to name that species of comments

#

the code should have documentation not comments

#

comments of this style indicate you can extract a method/function

# do <name of a block>
...
  ...
...
...
  ...
    ...
#

like

#
# check if user left the call
...
...
...
...
result = ...
...
#

encoding?

vocal basin
rugged root
#

Been rushing around like a madman. Still not fully here yet

#

Also, if it hasn't already been mentioned, I'd make the list of channel IDs as a tuple constant at the top of the file

#

Since it seems to be the same ones each time

vocal basin
#

multi-line comments
"no
there aren't
it's a lie"

#

ah, also given constant timeout it can just be a queue

#

and a single task

#

line 0 of how to write a comment:
don't

vocal basin
obsidian dragon
#

!e

\`\`\`
testing
out 
lines
\`\`\`
wise cargoBOT
#

@obsidian dragon :x: Your 3.11 eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     \`\`\`
003 |      ^
004 | SyntaxError: unexpected character after line continuation character
vocal basin
#

!e

"""
doc
string
"""
wise cargoBOT
#

@vocal basin :warning: Your 3.11 eval job has completed with return code 0.

[No output]
rugged root
#

Doc strings are the closest we have

#

But in fairness, they're just string literals that aren't assigned to anything and so they get tossed

vocal basin
#

` is not valid in python as a syntactical element in any context, iirc

rugged root
#

Correct

#

It is for JS

vocal basin
#

it's easier to embed JS in C#

#

"go embed some XML in VB"

vocal basin
somber heath
#
โ€‹`โ€‹``
vocal basin
#

zws or zwj?

somber heath
#

The former.

vocal basin
#

Ubuntu is derived from Debian

#

Debian is fine

#

I use Ubuntu to get more bloatware

sharp urchin
#

hello

obsidian dragon
#

UWUbuntu

rapid chasm
vocal basin
#

uwubuntu
sounds Lithuanian

obsidian dragon
rugged root
vocal basin
# vocal basin I use Ubuntu to get more bloatware

"hey, do you want to install kubernetes that will do nothing and eat 5% of all your CPU power?"
yes
"do you want to install nextcloud incorrectly?"
yes
"do you want to install portainer incorrectly?"
yes

#

I wouldn't be surprised if they started to suggest installing a full gitlab instance just for fun

#

I don't use leetcode myself
I did play around with codewars for some time

#

I think both allow to put the problem away for later

vocal basin
vocal basin
#

bookmark the problem to save for later

sharp urchin
#

i dont get it

vocal basin
sharp urchin
#

ohh ok

vocal basin
#

and solve other problems

#

then go back to what you haven't solved and try again

somber heath
#

โ€!e py print("Hello, world.")

#

!e py v = "a" while True: v += v

wise cargoBOT
#

@somber heath :warning: Your 3.11 eval job timed out or ran out of memory.

[No output]
sharp urchin
#

@vocal basin well ig i understood what to do...ty :}

#

bookmark and solve it in other ways

#

if possible

#

right?

vocal basin
#

leetcode should probably have such an option

#

I'm not sure if the alpha channel is working

#

seems like it does

#

I've raised the number of colour channels to 100

#

that didn't increase the time complexity in any noticeable way

#

now I need a way to generate a continuous mapping from 100 channels to 3

rugged root
#

I've only been here for an hour and a half and I have achieved much

#

Hey folks

#

Not yet

#

โค๏ธ

#

๐ŸŽถ I don't miss Hemlock, he smells like pooooooo ๐ŸŽถ

vocal basin
#

but, I think, it doesn't actually allow N+2 to N

rugged root
#

Boss walked in

#

Sorry

#

Had to talk to her

#

In theory another step closer

#

The insurance adjuster still hasn't been by to assess the value of the things damaged

#

So we're kind of stuck until they do their thing

#

Well

#

That I'm not sure of

#

Everyone has been slammed due to tax season

#

So I don't know what has or hasn't been scheduled

#

I'm easy to please/easy to adapt

#

So I don't mind this, just bummed I can't talk to you guys as much

#

@lavish rover Nerd

#

Neeerrrrrddddd

#

I'm okay, Beer

vocal basin
rugged root
#

Funky smooth

#

Take it easy

somber heath
#

Cube lube, keyboard lube... WHERE DOES IT END?!

rugged root
#

Not Master Card?

#

No u

#

Noooooooooooooooooooooooo

#

Padame!!!

#

Oh god no

#

NO

#

On the fly

#

Not pre-written

#

So you have no guarantee that you'll get the same article with the same prompt twice

stuck furnace
vocal basin
#

make it come up with article names too

rugged root
#

Yeah, I just like the idea it's different for different people

#

No no no

#

Still whatever the term you're looking for is

#

Just that some people may get that Columbus sailed the ocean blue in 1492 and another saying that he conquered Mars in the great lizard wars of 1885

somber heath
#

@cunning hull ๐Ÿ‘‹

rugged root
#

@lavish roverI don't speak y'alls frenchy french moon language

#

Such a good episode

#

And honestly the only one that comes to mind

#

Oh wait

#

There is one other episode that I remember

#

I think THAT one is my fave

#

Amazing

#

One sec

#

The difference is the ergonomics for me

#

The keys themselves.. eh

#

That's fair

#

If you bottom out your keystrokes anyway, that means that you really don't feel any difference

somber heath
#

Keyboard subscription packages.

rugged root
#

One key a month

somber heath
#

Like your keyboard just stops working if you stop paying for it.

rugged root
#

Ohhhh

#

Thought you mean like a keyboard of the month club

#

But if you're on a budget

#

You get one key at a time

lavish rover
#

There's probably a thing that sends you different switches a month lmao

vocal basin
rugged root
#

Possible yeah

#

I don't think I've ever passed an online course in college

#

I just always forget that it exists

#

I straight up can't

vocal basin
#

I changed the source-to-colour mapping

#

@somber heath
these are with an increased overwrite chance (1%, 2%, 1%)

rugged root
#

Getting my steps in today, that's for sure

vocal basin
rugged root
#

How

vocal basin
rugged root
#

Oh also, the 10k steps they recommend isn't actually based on anything

#

It just sounded good as a number

#

@pure shale You'll want an accountant

#

You'll have to Czech what the rules are where you're at

somber heath
#

@whole bear๐Ÿ‘‹

rugged root
#

Relocation bonus I think

#

And how old the people are

#

Could just be that old people don't want to break the old ways

#

Or something

#

France ca - yep

#

Bingo

#

I heard jerks not Turks

#

No no I know

#

Just cracked me up

#

"Bunch of d-bags coming in here..."

#

@tidal shard Sup

#

There's always going to be people who exploit a system

#

But the folks who benefit from it and need it make it important to have

#

Don't fall for how the US does things

#

I forgot what your degree was in Delta

#

I'm too risk adverse to get into it

stuck furnace
rugged root
#

Just that much twerking

lavish rover
#

I don't think I could run that much if I tried

rugged root
#

Misread as steps

lavish rover
#

Kinda just kept walking around with someone and lost track

rugged root
#

Potential love interest someone?

lavish rover
#

No comment

rugged root
#

I have to make sure they have good intentions for my baby boy

cunning hull
#

I joined vc to at least calm me a little while I'm playing Faith

#

and it worked

somber heath
#

Then I am pleased.

cunning hull
vocal basin
#

(those two were generated with different scaling)

whole bear
#

nice

vocal basin
#

if it manages not to lose all $100 or more, that's already a success

south cloud
#

hello everyone, i am new and i just learned that i have to text in here in order to get veryfied. ๐Ÿคญ

vocal basin
somber heath
#

High frequency traders, like they were just vibrating...which I suppose we all are, really.

vocal basin
pallid hazel
#

been forever since ive been to an ihop... heres to the end of breakfast in bed.

somber heath
#

@silk tartan ๐Ÿ‘‹

vocal basin
#

(doesn't actually reflect the "lost more than they had" but at least demonstrates the scale in some form)

rugged root
#

I just realized that joke won't hit

#

Oh well

tidal shard
#

gtg

abstract pike
#

Anyone familiar with open-cv?

#

@ everyone lol

vocal basin
#

(or what is the question/problem)

abstract pike
#

I am using to do some preprocessing on an image. Specifically a microscopic image taken of a piece of metal. I am trying to auto mate the process of counting how many times a random line passes through a granular structure on the image. Basically I can this n times by looking at the intensity plot of the pixels.

#

My question: Is anyone here familiar or have used open cv

#

prolly should add this message into another chat channel specific for cv2.

rugged root
#

Busy busy busy

#

Hey Cruiser

#

How goes it

#

Nice

#

Now to see if I can - nope, of course

#

Back later

#

Sorry

hoary olive
#

woops

#

hi hem

pallid hazel
#

would it be acceptable practice with a large list, to recheck the value and break the loop to stop excessive looping?

large_list = [1,2,3,4,...]
getnum = 3
for i, v in enumerate(large_list):
    if v = getnum:
        ... do stuff
    if v = getnum:
        break
silk tartan
ashen wasp
#

Why I can't talk in voice chat?

sharp urchin
#

!voice

wise cargoBOT
#

Voice verification

Canโ€™t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

rugged root
#

That'll tell you what you need to know about the voice gate

#

Happens

silk tartan
rugged root
#

See link above

#

Wasn't meant to be snippy, I just got lazy

ashen wasp
#

Ok

rugged root
#

Hmm?

#

Wasn't sure what ATP meant in this case

ashen wasp
#

I from Russia I don't know how say (thank) short

rugged root
#

Ah fair

#

ty works for thank you

ashen wasp
#

Oy ty

rugged root
#

Happy to help

#

Yo

#

How goes it

#

Fair enough then

ashen wasp
#

It me?

rugged root
#

No no

#

Someone else, sorry

#

@whole bear Over here

whole bear
#

hi

rugged root
#

How's it going

whole bear
#

good u

rugged root
#

Decent enough

#

Just workin'

whole bear
#

cool

rugged root
#

Cool cool. What're you learning right now?

ancient lily
#

@rugged root wait why arent you admin ??

rugged root
#

Very cool. What resources you using? Site, book, youtube...

#

Hell yeah

#

Oh yeah yeah

#

Yeah I've heard of his stuff

rugged root
ashen wasp
#

Have you ever studied Russian is very difficult even for us

rugged root
#

I'm not in my regular office so I can't talk.

#

Hey Moonie, hey Akon

#

@unique swallow How're - and she's gone

#

@silk tartan How's it going

rugged root
#

Eh, I suppose

#

How're you?

#

I'm alright, yourself?

#

No, not personally

#

Just been staff on it for a long time

#

Since we had like.... 2k or so members?

#

So what're you folks working on?

#

Fair

#

Sort of

#

Mainly actual work stuff, which sadly isn't programming

#

I work in IT

#

Oh very cool

#

Ehhh... kind of just inhouse stuff. I work at an accounting firm. So it's mostly "Why isn't this working?" "Can you come fix this?" "The printer isn't working" etc

silk tartan
rugged root
#

Yeah, just general basic IT stuff

#

@silk tartan Check out the #voice-verification channel. That'll tell you what you need to know about the voice gate system

#

There are days I wish I had more programming related duties at work

unique swallow
#

you have to be on the server for at least 3 days i think

rugged root
#

But when I look at how the tech sector is fluctuating... kind of got me spooked

#

Well I guess mainly in big tech companies. But like the massive layoffs, restructuring of business, etc.

#

@dim raven Yo

rugged root
#

How goes it

dim raven
#

good, just get the day off

#

u=

rugged root
#

Kind of. I have an associates of liberal arts degree, but it basically just means I completed my general education credits. I moved around a lot, went to 6 different colleges across 3 different states

#

So many of my courses got turned into elective credits.

#

Just broke down at one point

#

You?

#

Neat

dim raven
#

me too

rugged root
#

You've got some weird background rumble in your mic, Moonie

#

No worries. Catch you later

dim raven
#

bye

rugged root
#

Hey Rab

#

Hey Kiwi

#

Har dee har

#

You what now? Sorry, didn't catch that

amber raptor
#

I had dental work done and Iโ€™m half numb

rugged root
#

Niiiiiiice

#

Whelp, now to get you to do tongue twisters

amber raptor
#

I also wrote code this weekend.

stuck furnace
#

You're nu (I'll see myself out)

dim raven
#

i heard about it, to be half numb, luckly i never got it

rugged root
#

Code on what?

#

Python?

#

What year? 2022?

whole bear
#

is my mic working

rugged root
#

HA

rugged root
#

@terse needle Yo

rugged root
#

Wait, is that STILL processing?

dim raven
#

what kind of messinng bus dou you use?

rugged root
#

Or how long did it take

#

@whole bear Yo

#

Fair

stuck furnace
#

Oh that's not bad.

rugged root
#

Your idea of fun is much different than mine

amber raptor
rugged root
#

Devops and fun do not make - ah fair enough

amber raptor
rugged root
#

Wait wait wait

#

So part of it is left to random?

#

Sure

#

You're a madman

#

And I love it

stuck furnace
#

If it works ยฏ_(ใƒ„)_/ยฏ

silk tartan
#

please someone tell me how to verified my voice

rugged root
stuck furnace
#

Yeah, don't test it on our ears please.

#

Hmm

rugged root
#

Settings > Voice and Video > Let's Check

#

Oh yeah that's fair

rugged root
#

I did say that, yes

dim raven
#

that sound great the messaging system

terse needle
#

@whole bear a lambda calculus interpreter

amber raptor
rugged root
#

Ooo nifty

#

Last update June 2020

#

Huh

#

@mild quartz Yo

mild quartz
#

hi

rugged root
#

How goes it

mild quartz
#

aight

rugged root
#

Yeah that's fair

#

If it ain't broke

#

@willow lynx Yo

amber raptor
#

Itโ€™s extremely simple messaging system design for high speed

rugged root
#

@silk tartan There's a good reason for it. We had a series of what I call hit and run trolls. They would join the server, join voice chat, scream, and then leave. This was happening around 6 or so times a day.

#

The voice gate has made it not an issue anymore

amber raptor
#

But unlike ZeroMQ, doesnโ€™t have some of its limitations.

rugged root
#

@mild quartz What new ground breaking and life changing things are you working on today

mild quartz
#

just monitoring some experiments

#

theyre

#

fine

rugged root
#

Like.... fine or "fine"

#

Or (fine:1.4)

mild quartz
#

just alright

#

the curves are not quite the curves i like

#

but they will do

rugged root
#

Self training still feels weird to me

#

Ship it off to boarding school

#

@stuck furnace What're you up to?

stuck furnace
rugged root
#

Fair

#

@blazing tulip Hello

stuck furnace
rugged root
#

So what is everyone doing? Just so that I'm not pestering everyone individually

rugged root
willow lynx
#

Are you all married if you don't mind me asking

blazing tulip
rugged root
#

I think most folks aren't

stuck furnace
rugged root
#

It does

#

But I typically do a 10 and 2

#

And it's noonish right now

#

@mild quartz Tee hee.... sharted...

stuck furnace
#

Oh ok

rugged root
#

@willow lynx Why do you ask?

willow lynx
#

It's my marriage in next two days

rugged root
#

I am yeah.

stuck furnace
#

Is this for work (Anokhi)?

high acorn
#

hello guys

willow lynx
#

So idk I am just asking

rugged root
#

5 year anniversary was not too long ago

mild quartz
#

yeah

rugged root
#

Hey penny

silk tartan
#

why I have to need 3 day for Voice talking