#voice-chat-text-0

1 messages · Page 140 of 1

whole bear
#
mainimage = models.ImageField(null=True ,upload_to=f'{posttype}/{instance.id}/images/thumbnail')
lucid blade
vocal basin
#

does it not create the directory automatically?
or is the question specifically about templating?

whole bear
#

I think if I used this it will do it

def get_image_path(instance, filename):
    return os.path.join('images', str(instance.id), filename)
vocal basin
#

avoid using os

#

!pathlib

wise cargoBOT
#
The `pathlib` module

Python 3 comes with a new module named Pathlib. Since Python 3.6, pathlib.Path objects work nearly everywhere that os.path can be used, meaning you can integrate your new code directly into legacy code without having to rewrite anything. Pathlib makes working with paths way simpler than os.path does.

Feature spotlight:

• Normalizes file paths for all platforms automatically
• Has glob-like utilites (eg. Path.glob, Path.rglob) for searching files
• Can read and write files, and close them automatically
• Convenient syntax, utilising the / operator (e.g. Path('~') / 'Documents')
• Can easily pick out components of a path (eg. name, parent, stem, suffix, anchor)
• Supports method chaining
• Move and delete files
• And much more

More Info:

Why you should use pathlib - Trey Hunner
Answering concerns about pathlib - Trey Hunner
Official Documentation
PEP 519 - Adding a file system path protocol

vocal basin
whole bear
#

I want to store every post media in folder with its id

#

@vocal basin

vocal basin
#

upload_to may also be a callable, such as a function. This will be called to obtain the upload path, including the filename. This callable must accept two arguments and return a Unix-style path (with forward slashes) to be passed along to the storage system.

#

example:

def user_directory_path(instance, filename):
    # file will be uploaded to MEDIA_ROOT/user_<id>/<filename>
    return "user_{0}/{1}".format(instance.user.id, filename)


class MyModel(models.Model):
    upload = models.FileField(upload_to=user_directory_path)
#

I guess something like this
you'd still have to obtain posttype somehow

def upload_to(instance, filename):
    return f'{instance.posttype}/{instance.id}/images/thumbnail'

class MyModel(models.Model):
    mainimage = models.ImageField(null=True, upload_to=upload_to)
whole bear
#

Yp it in the post so it will be instance.posttype

#

I'll try it.

vocal basin
somber heath
#

Does the existence of new ton's law suggest the existence of old ton's law, thus there being two ton's laws?

vocal basin
#

(may fail on Windows)

whole bear
#

Aha ill try it on any host

whole bear
#

I work from my phone 🙂

#

Never let anything stop u

vocal basin
#

like electrons do at low temperatures

#

(pair up and allow for superconductivity)

rugged root
#

Right

vocal basin
#

I should
go clip a video about map projections

#

so bad it got into the name of the talk

mild quartz
#

Bell's theorem is a term encompassing a number of closely related results in physics, all of which determine that quantum mechanics is incompatible with local hidden-variable theories given some basic assumptions about the nature of measurement. "Local" here refers to the principle of locality, the idea that a particle can only be influenced by ...

vocal basin
lucid blade
mild quartz
#

The Meissner effect (or Meissner–Ochsenfeld effect) is the expulsion of a magnetic field from a superconductor during its transition to the superconducting state when it is cooled below the critical temperature. This expulsion will repel a nearby magnet.
The German physicists Walther Meissner and Robert Ochsenfeld discovered this phenomenon in 1...

rugged root
vocal basin
rugged root
#

So good

vocal basin
#

@brisk current did you code the NN yourself?

#

or do you use the existing library?

lucid blade
#

i heard NaN

vocal basin
#

yes, NN outputs NaNs

lucid blade
#

k

vocal basin
#

there's also "let's disclose weird stuff so people don't dig into real stuff"

lucid blade
#
WIRED

The Voice of God weapon — a device that projects voices into your head to make you think God is speaking to you — is the military’s equivalent of an urban myth. Meaning, it’s mentioned periodically at defense workshops (ironically, I first heard about it at the same defense conference where I first met Noah), […]

vocal basin
rugged root
mild quartz
#

Garry P. Nolan (born c. 1961) is an American immunologist, academic, inventor, and business executive. He holds the Rachford and Carlota A. Harris Professor Endowed Chair in the Department of Pathology at Stanford University School of Medicine.

somber heath
#

Was the Fonz an ayyylien?

lucid blade
#

oh dear 😄

rugged root
somber heath
#

Movie I loved as a child and watched the shit out of: Milo and Otis.

I watched it a number of years ago, later. I was appalled.

rugged root
drowsy island
#

Which YT channel is that.

#

Yes

#

Ah okay

vocal basin
#

solving rustlings inside the vs code browser magic

west epoch
#

Hi! Is the audio up currently on voice channel0 as I seem to have some audio issues on my end?

#

I can see gofek's screen only

whole bear
#

This code is working but ihave a problem I want the file or the image to be saved with its name and exstion like

resourepacks/images/thumbnail/image.png

Instead the image is being saved in like dp file like the image
So can you help me ?
I know I ask alot but I have searched and I couldn't find any answers.

#

Ahh I fixed it

#

I should put the {filename}

abstract ravine
#

any mod?

abstract ravine
abstract ravine
#

here

quiet star
#

Hi there 😉

abstract ravine
#

Hi Nova

verbal zenith
#

IDK but I know for a fact that when using more than 1 thread, I certainly saw it go faster

#

There's a lot of blocking elements and I definitely noted a difference between normal and threaded

#

Ah I see

#

It will only use 1 core, but threading can increase performance if you are not utilizing that core entirely

surreal cape
#

IDK if makes any difference

#
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'Darwin'
>>> platform.release()
'18.7.0'
>>>
#

it should shows you the OS version

#

how much does your PC total price cost?

tidal vessel
#

@verbal zenith u running this on one machine?

patent gyro
#

Hi

gusty sage
#

I'm sorry

#

i'm new here

#

@ebon sandal

#

15 messages only??

#

and 3 days

brisk vault
#

50 msg

gusty sage
#

oh 50

#

oh ok

#

ok thanks for the help @ebon sandal

#

i have a question! @ebon sandal

#

I'm from morocco!

#

I'm currently developing a remake of discord

#

i just started learning python 3 months ago

#

i have the fundamentals

#

but i'm looking to meet up with people that have the same interestes as me

#

@ebon sandal

#

oh ok, i'm sorry!

#

thanks for understanding me!

#

will do don't worry

#

yeah, i can send a github link, you can just chekc images

brisk vault
#

would be great

gusty sage
#

it's nothing much, it was made by pygame tho

#

which was hard definetely challenging

#

ye ye, ik but it was my first project

#

it's just for practicing my skills, but yeah what you said is definetely correct, python is a slow of a language for such big app

#

I was thinking about converting my project into GO, is that a good idea??

red peak
#

Depends on what your goal is?

#

If it is game development I'd say go for game engines.

#

If it's to learn python then why would you switch to GO?

gusty sage
#

GO would most likely be, the way to go

red peak
gusty sage
#

Hello

#

oh no no

#

that's not what i meant

#

i meant like getting mostly all of the advanced topics

#

that you need to know as a python programmer

#

ye

gusty sage
#

don't worry buddy, you take your time

#

cpu performance

red peak
gusty sage
#

My mentor did a test between python and go, go was efficiently faster

gusty sage
red peak
gusty sage
#

you can use cython

red peak
gusty sage
#

I think python in general lacks perfomance, the fact that you can only use one cpu core, is kinda bad

#

Is Go worth learning 2023?
Overall, Go is a great choice for building web applications, cloud services, and distributed systems. It is fast, reliable, and easy to learn and use. It also has a wide range of features that make it stand out from other programming languages.

#

i searched this up, and it turns out, that go is worth learning in 2023

#

i see a lot of people starting to learn go and rust.

#

i think it might be worth it

gusty sage
#

is not ideal

uncut meteor
#

h

#

i

rugged root
smoky veldt
#

helo

#

i am gonna try to learn python

#

this 3months i think

rugged root
#

@whole bear

smoky veldt
#

but i am black so no offense

#

@rugged root when i try to join other servers it say are u human and when i click the check point box it block or kick me from image selection stuff

#

group

#

ok just froget it

rugged root
#

I just don't know what you mean by group

smoky veldt
#

let me ask you question @rugged root when you try to get or join in a server it says are u human captcha stuff right?

rugged root
#

It can but I don't think I've had it happen to me

smoky veldt
#

it does to me

#

every time

somber heath
#

'Lo.

#

What am I finding?

whole bear
#

can i ask pc build advice here lol

#

or is this not a server for that

rugged root
#

@whole bear Can you check your mic settings or turn on Krisp?

#

We're getting some weird mic feedback

somber heath
#

Ethnicity: Human.

#

Family guy colour matching card.

rugged root
#

HA

#

Forgot about that one

#

I hate that it can even be a joke

rugged root
#
from django.db import models

# Create your models here.

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField("date published")


class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

smoky veldt
#

anyone who has a real job

amber raptor
smoky veldt
#

-_-

rugged root
#

In the industry? There's plenty

#

Just not me personally

smoky veldt
#

wait are u talking to me??

rugged root
#

Yeah

#

The text one

smoky veldt
#

ok when you get interview there is CV stuff right?

rugged root
#

Usually. Although if you're wondering more about career stuff and what not, #career-advice would have better answers than I can offer. Plus there's likely folks that are from where you're from so they can give you more specific answers

smoky veldt
#

tnx

rugged root
#

Happy to help

#

So you said you were wanting to get started on learning Python? Have you decided what resources to use to get started?

smoky veldt
#

i dont know just i havent been coding over 2 months

#

so i will learn python and c++ from now on

rugged root
#

Fair enough

#

!resources

wise cargoBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

rugged root
#

We'll we've got a bunch of resources to get you back up to speed on Python

#

I typically recommend "A Byte of Python"

smoky veldt
#

are those bot??

rugged root
#

The Python bot is a bot, yeah

#

Hence the bot next to its name

smoky veldt
#

wait i will come back in just mintues

rugged root
#

For context, Google Photos does this as well, if memory serves

#

Will have to look

peak copper
rugged root
fierce stratus
#

Hello

somber heath
#

Tributaries, rivers, oceans.

#

Upside down trees.

smoky veldt
#

@rugged root can u send me youtube link pls

rugged root
#

For which?

smoky veldt
#

by link

rugged root
#

?

#

Why?

desert wolf
#

lol, what

rugged root
#

It's a weird request

smoky veldt
#

u know my country has even blocked google right and it doesnt even work

mossy cedar
#

YALL R OLD DAMN

#

65 ???

#

AVG ?

#

o 38

smoky veldt
#

what????????????

smoky veldt
#

ethiopia

mossy cedar
smoky veldt
#

cuz complicated religioun war stuff

mossy cedar
somber heath
#

Even through Discord, having the link from here wouldn't help you.

smoky veldt
#

say like ethiopian christian orthodox and abiy war

rugged root
#

The site is still the site

mossy cedar
# smoky veldt say like ethiopian christian orthodox and abiy war

Ethiopia’s Orthodox Christian Church is locked in a bitter feud with the government of Prime Minister Abiy Ahmed, the former Nobel Prize winner turned war-man.

The church claims state interference in its affairs. It threatens mass defiance, and thus a historic split looms in one of the world’s most ancient and largest Orthodox churches.

smoky veldt
#

ya but i dont have a apple account

#

i am just 13yrs old

mossy cedar
#

not android ?

smoky veldt
#

nah my family is only android

mossy cedar
smoky veldt
#

the thing is that my wifi is bad

mossy cedar
smoky veldt
#

just send me a random website link anyone

rugged root
#

You can type the link yourself and it'll turn into a hyperlink

#

Just have to do the https:// first

smoky veldt
#

oh ok

mossy cedar
smoky veldt
#

it just says untiteld and it just loads

#

it worked

#

but

mossy cedar
rugged root
#

Potentially

smoky veldt
#

like how?????????????

rugged root
#

If they're blocking VPN hosting servers then it's moot

desert wolf
smoky veldt
#

just send me a free vpn linked website for macOS pro

#

it worked BABY!!!!!!!!!!!!!!!!!!!

#

@mossy cedar utube worked

mossy cedar
#

now go watch youtube

smoky veldt
#

thanks

mossy cedar
smoky veldt
#

i dont know

#

just tag me if u want me

rugged root
#

It's just another IP to block

mossy cedar
rugged root
#

All the VPN stuff gets routed to that server

mossy cedar
smoky veldt
#

@mossy cedar @rugged root with out u i would'nt wash some cold and sigma vids

rugged root
smoky veldt
#

i hate being feminist

rugged root
#

....what?

mossy cedar
rugged root
#

That came out of nowhere

mossy cedar
#

i mean chill

somber heath
smoky veldt
#

ok-_-

#

U DONT NEED MANY FRIENDS TO WIN U NEED REAL FRIENDS TO WIN REMEBER LAMBO HAS ON 2 SEATS TO WIN IT @mossy cedar @somber heath

mossy cedar
smoky veldt
#

hel na everybody is fake

mossy cedar
smoky veldt
#

nope

mossy cedar
smoky veldt
#

wait the helll up

somber heath
#

There's a Scottish aeronautics et al company. It's called Loch Heed Martin.

smoky veldt
#

are u female??

mossy cedar
smoky veldt
#

cuzzz

mossy cedar
#

:3 maybe

smoky veldt
#

ayo

mossy cedar
#

wat

smoky veldt
#

ok who is better

mossy cedar
smoky veldt
#

T or A{

#

(hint they are tates)

somber heath
#

Grilled ginger smells amazing and goes well in cookies.

mossy cedar
smoky veldt
#

wat

red peak
#

And grilled garlic goes well with bread.

smoky veldt
#

clear it more

red peak
#

Specially with butter

somber heath
rugged root
#

God yes

#

Garlic goes with so many many things

mossy cedar
mossy cedar
#

in shwarma

somber heath
#

I had this idea you didn't like garlic.

mossy cedar
#

cheff sound

mossy cedar
somber heath
#

No, Hemlock.

smoky veldt
#

i eat a raw meat

mossy cedar
mossy cedar
peak copper
smoky veldt
#

what

#

i am expressing my opinion

somber heath
#

"It's not just a waffle house, it's a waffle home."

smoky veldt
#

who is better messi or ronaldo

mossy cedar
#

m

amber raptor
smoky veldt
#

sheesh this baby look fast

#

wait i will come back i am going to kill a rat

whole bear
#

can i get banned if i send funni memes

#

?

rugged root
#

I mean.... are you looking to get banned or trying not to?

#

And if the meme is relevant to what's going on/being discussed and it's server appropriate, then it's fine

#

Just don't spam them

whole bear
#

k

#

ig i wont then

somber heath
#

Whosa good match? Whosa fuzzy match? You are! Yes, you are!

whole bear
#

lmao

#

I'm getting into intermediate level of programming in python and im making a chess game rn with pygame. But I'm starting to think the project is going to be more complex than what pygame can do with its built in functions. I'm just wondering if continue with python or learn a new language like java or c/c++ which are more in tune for game development?

#

ps sorry if that was little long i tried talking in the career discussion chat but couldnt get anyone

#

yeah

#

ok got it

#

i also plan to get into AI so i kinda need python

#

thats the only reason i didnt go into another language

#

true

#

pygame is a super great library just wasnt sure if it would be suffecient for larger projects but i think ur right opal i should just continue in python pygame

#

alr

#

ye lmao

#

i agree

#

matt what are all the stuff u know

#

from all the projects

#

that youve done

#

thats cool

smoky veldt
#

we got it

whole bear
#

dang

smoky veldt
#

why dang

whole bear
#

in vc

smoky veldt
#

ok

whole bear
#

wow

#

thats super cool

#

guys if you wanted to keep track of say a bunch of accounts for an application, and you wanted to use files and not data bases, what kind of files would you use?

#

just curious

#

would it be like json files or?

peak copper
whole bear
#

for example usernames, passwords, and different scores theyve made overtime in a game

#

oh ok

#

ye

#

never used anything passed a list or numpy array so just was curious on that

rugged root
#

It's a fair question

whole bear
#

:)) thanks for the answer really helpful 👍

rugged root
#

For something like that, you can do a JSON, since it'd just be standard dictionary style

#

Happy to help

#

I love fielding questions like this

peak copper
rugged root
#

But at the same time, something like a simple SQLite database could work

#

One table with the columns you described

whole bear
#

ok

#

I guess like you said it really just depends on the size of your project and security reasons and stuff like that if you want to use a data base or just small files

rugged root
#

Right. Some things to keep in mind.... If you think you're going to get a fair number of users, it probably better to adopt a database earlier rather than later

#

That way you don't have to try and convert a big ass file later down the line

#

Or adjust your code to now use the database

#

The benefit of something like SQLite is that it is just a single file

#

You don't need to have a separate database server or hosting to use it

#

It's just there in place

whole bear
#

Right ok cool

rugged root
#

And there's packages/libraries for it in damn near every language

#

Python just happens to come with it

whole bear
#

you seem to have alot of knowledge this kind of stuff, can I ask what projects you did to learn all this stuff?

#

im trying to think of things I want to learn in computer science down the line

rugged root
#

So I'm not in the industry and I wasn't a comp sci major

#

I just try lots of things and see what works and doesn't

#

I've really only had one project I was proud of

#

Majority of what I know is from helping others and my little protyping things

#

I was a Computer Information Systems major

whole bear
#

oh ok neat

#

so just going around and trying stuff that you find interesting

rugged root
#

Yep, I love the pursuit

#

Not to say I wouldn't like to actually make more things

#

But I get easily distracted and lose confidence fairly quickly

#

Slowly working on that

#

But it does mean I'm well rounded with my knowledge and can at least pass that on to others

whole bear
#

relatable

whole bear
rugged root
#

IT is my true love

whole bear
#

my dad does the same thing its really cool

#

well, thanks for the info Mr. Hemlock

#

that helped alot

#

I think I know what I need to do for my project now

rugged root
#

Cool! If you have any other things you want to bounce off me I'm all ears

#

Questions, ideas, whatev

whole bear
#

Thanks man, will do 👍

violet fern
#

hello

abstract ravine
#

hello

violet fern
#

where are u from Nando ?

abstract ravine
#

Brazil

#

and you?

#

@lunar haven What do use to do the 'text-to-speech' in the page?

abstract ravine
#

Hello

patent gyro
#

Oh there is rainbow here lol

surreal cape
somber heath
#

@trail wagon 👋

#

@spice gazelle 👋

#

@prime marsh 👋

#

Alas, not I.

#

@echo slate 👋

echo slate
#

hi

#

i need a help

#

can u help me?

somber heath
#

@teal pasture 👋

teal pasture
somber heath
surreal hedge
#

@patent gyro We'd prefer if you didn't advertise those kinds of links in this server, so I've removed them 🙂

vocal basin
#

I wonder how this gets parsed actually

#

!d heapq

wise cargoBOT
#

Source code: Lib/heapq.py

This module provides an implementation of the heap queue algorithm, also known as the priority queue algorithm.

Heaps are binary trees for which every parent node has a value less than or equal to any of its children. This implementation uses arrays for which heap[k] <= heap[2*k+1] and heap[k] <= heap[2*k+2] for all k, counting elements from zero. For the sake of comparison, non-existing elements are considered to be infinite. The interesting property of a heap is that its smallest element is always the root, heap[0].

vocal basin
#

to avoid mixing ints into the stack, but requires making new nodes

class Solution:
    def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
        trees = [root]
        traversed = []
        while trees:
            tree = trees.pop()
            match tree:
                case None:
                    pass
                case TreeNode(val=val, left=None, right=right):
                    traversed.append(val)
                    trees.append(right)
                case TreeNode(val=val, left=left, right=right):
                    trees.append(TreeNode(val, None, right))
                    trees.append(left)
                case _:
                    raise TypeError
        return traversed
#

@midnight agate
if it's a stack of trees, then maybe that special case is unnecessary

vocal basin
#

(without handling root separately)

#

do the spoilers for code still work?
||

class Solution:
    def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
        nodes = []
        def push(tree):
            if tree is not None:
                nodes.append(tree)
        push(root)
        traversed = []
        while nodes:
            node = nodes.pop()
            match node:
                case TreeNode(val=val, left=None, right=right):
                    traversed.append(val)
                    push(right)
                case TreeNode(val=val, left=left, right=right):
                    push(TreeNode(val, None, right))
                    push(left)
                case _:
                    raise TypeError
        return traversed

||

warped raft
#

@midnight agate are you free

#

@vocal basin , @whole bear , @rugged root hello all of you

#

how is it going

#

@midnight agate hello

vocal basin
#
while let Some(node) = nodes.pop() {
    ...
}
vocal basin
#

but more memory expensive than Vec<Box<Node>>

rugged root
somber heath
#

Hey, Sha.

#

@quick galleon 👋

quick galleon
#

sup @somber heath

somber heath
#

Yes, well, Hemlock, you made the mistake of showing you were around in chat.

quick galleon
#

hi

somber heath
#

Also, happy garbage collection month!

quick galleon
#

wow it's tough to be able to speak in this channel btw

somber heath
#

A small negative to eliminate a far greater negative.

warped raft
#

hello @somber heath and @quick galleon

#

how are you all doing

somber heath
#

It's...been a day. 😁

#

@wary coral 👋

quick galleon
#

what are you guys doing rn?

somber heath
#

The crafty mines.

#

Playing more or less with just Create. Giving Fabric a whirl, vs Forge.

#

Because apparently it's better, but most of the stuff I enjoy is on Forge, but if people never use Fabric, there won't be an impetus to migrate

quick galleon
#

i'm solving system of non-linear equations on python, lot's of fun...

somber heath
#

Haven't done a runthrough with create.

#

So I'm learning as I go.

#

I gave someone else a lol

vocal basin
#

Fabric is more lightweight; but, afaik, the "bloat" that Forge has is quite heavily relied upon in some mods (because it's all the integration and cross-mod compatibility systems)

quick galleon
#

just for the uni assignment

#

btw can somebody give me an advice with db modelling?

vocal basin
#

I recently attempted helping someone with smoothing the graph like this

vocal basin
quick galleon
#

general i'd say

#

i have to create a website for booking tickets in the cinema

somber heath
#

Yes, drapey.

#

I did say gentle.

vocal basin
quick galleon
#

yep the problem is that for each movie there are sessions (let's say 18:30, 20:30 and so on) and i want to implement seat booking foe each session but it seems like i have to create a new db every time i create new session as an admin. Is it a good practice?

vocal basin
#

no, creating new tables/dbs per some data point often is not a good practice

#

the more common and simple approach is to add a column specifying what session a ticket refers to

#

with a separate table listing all existing sessions

#

per each ticket:
(session, seat) pair is unique
session is a foreign key to a table of all sessions

quick galleon
#

i haven't thought about it. thanks!!! i really had no clue what should i do

vocal basin
#

that would be a check not a foreign key, I think

#

there is another way though

#

to duplicate theatre in ticket

#

(session, theatre, seat) contained in a ticket
(session, theatre) foreign key to sessions table
(theatre, seat) foreign key to seats table

#

ticket reservation system has a certain other aspect which makes things difficult
that timer thingy which is a temporary mutex (and how fine-grained it is depends on the specific case)

quick galleon
#

have to finish it till Monday 😦

#

anyway thanks for helping guys! i'll go and try to do it

vocal basin
rugged root
#

Fair

#

Although I still relational could work

#

We just have to condense our thinking

#

Crap, I have to focus on work

#

You guys are too interesting

serene condor
#

Hello guys I need a help in preparing javascript algorithm anyone here who can help me out,I highly appreciate if anyone of you could hellp me,Thanks

serene condor
#

For a given sentence, find occurrences of given character set. Pick filtered words and generate permutations. (SENTENCE AND CHARACTER SET ONLY CAN HAVE UPPERCASE LETTERS)

Show selected words & permutations

Example :

Inputs sentence = "THIS IS AN ISSUE FROM GIHAN" word = "IS"

Output { words : ["THIS", "IS", "ISSUE"], permutations : [["THIS","IS","ISSUE"], ["IS","THIS","ISSUE"], ["ISSUE","THIS","IS"], ["THIS","ISSUE","IS"], ["IS","ISSUE","THIS"], ["ISSUE","IS","THIS"]] }

vocal basin
#

the desrcibed problem has two distinct parts to it

#

or, rather three

#

split into words
filter words
permute words

serene condor
#

can you build an algo for the above case

vocal basin
serene condor
vocal basin
#

JavaScript, right?

serene condor
#

yep

vocal basin
#

you don't need an algorithm for the first two steps

#

these are done using built-in JavaScript methods

#

(of arrays and strings)

serene condor
#

this is the assignment

#

ok

#

put me in right direction

rugged root
vocal basin
#

step 3 is difficult, idk how to solve it

rugged root
serene condor
#

This is going to be my assesment for the trainee position for web developer,They told me to do the assesment even with the help of chatgpt they dont want to know how i do it,they are just expecting the correct answer thats all

#

Please help me

#

@rugged root please help me

vocal basin
vocal basin
serene condor
#

I started with python in 2020 but due to addiction to online games i couldnt stay focused

vocal basin
serene condor
#

can you help with this one please

vocal basin
#

do you know how push to an array in JavaScript?

serene condor
#

@rugged root Please help me build it

serene condor
#

I tried 2 days

#

without sleep

#

today is last day thats why

vocal basin
#

sleeping is necessary

rugged root
#

Pro is my usual push

#

But if you're not using it for dev

#

Then gaming

serene condor
rugged root
#

Just do 11

#

11 is fine

serene condor
#

I searched the web and tried my level best even chatgpt is not giving correct output

vocal basin
#

or, another option:
solve it without pattern

#

can you make it return this?

[["o", "o", "o", "o", "o"],
 ["o", "o", "o", "o", "o"],
 ["o", "o", "o", "o", "o"],
 ["o", "o", "o", "o", "o"],
 ["o", "o", "o", "o", "o"]]
#

without "x"s at first

serene condor
#

i think i can

#

@rugged tundra can you help me PLEASE PLEASE PLEASE?

vocal basin
#

what if
what if I installed IJavascript kernel in Jupyter

somber heath
#

@serene condor Can this be a Python problem?

serene condor
#

no its JS

vocal basin
somber heath
#

@serene condor Do you know what a for loop is in Python?

serene condor
#

yes

vocal basin
#

solution in python is quite easily translated into js

serene condor
#

can you give me a python solution even

somber heath
#

Have you used range to get numbers?

#

Combined with for.

#

@rugged root "We're called managers for a reason, sweetheart."

vocal basin
#

(potentially)

#

or just done

somber heath
#

You have faith in people?

vocal basin
#

this is not right, right?

serene condor
#

GUYS PLEASE HELPPPPP MEEEE PLEASEEE THIS IS LIKE BETWEEN LIFE AND DEATH SITUATION

vocal basin
rugged root
#

Stop begging, we've given you the pieces you'd need, we've also told you that we're not doing this for you.

somber heath
#

@serene condor

vocal basin
#

I did the thing

serene condor
vocal basin
#

JS/TS kernels in Jupyter

serene condor
#

Oh great

vocal basin
serene condor
#

Thank you that you are trying to help me

vocal basin
somber heath
#

Nobody:
You: A is better than B.
Us: But A is awful!
You: It's just like, a comparison, man.

vocal basin
uncut meteor
#

my condolences

rugged root
#

"Dearly beloved, we have gathered here today to mourn the loss of Fredrik's headset..."

somber heath
#

I expect the majority of research papers would be black and white.

#

The anime cage?

sturdy panther
#

Trying to distract myself from work!

vocal basin
sturdy panther
#

A little. Deadline and all that.

#

Also doesn't help that my manager is supposed to do quarterly reviews.

#

We still haven't done the first one for the year!

#

They do tell me I am doing well. Would be good to have it recorded formally.

somber heath
#

!voice @serene condor

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
#

Is there a reason you're join/leaving a lot?

#

@serene condor

rugged root
#

Back shortly

sturdy panther
somber heath
#

Association is not apostasy.

vocal basin
#

if you want to set the whole place on fire, do it just after the review, so people forget it by the time the next review comes

somber heath
#

Nor am I religiously inclined...kind of the opposite. But I think that you could ask yourself a question: Does Allah know your heart? Take comfort in the answer.

#

It might not matter what position you're in...but some positions may be more hazardous than others!

#

Laying down seems to carry at least one risk.

pale sigil
#

Dombra instrument

wind raptor
pale sigil
burnt swift
#

Becomes even harder when your team goes above and beyond because the entire point is to acknowledge strengths and find areas to improve. Hard to tell someone where they can improve when they're already above and beyond.

#

Just makes me feel like a d*ckhead. /rant

lucid blade
sturdy panther
#

My manager tells us to write up what we think we can improve on, preferably things we can act on by the next review, and then he paraphrases it for the reports.

burnt swift
#

Ngl, seems a bit lazy, no?

sturdy panther
#

Perhaps. He is not particularly well-versed in giving solid feedback.

lucid blade
peak copper
pale sigil
#
rugged root
#

Mmmm... remoting into my work machine from the dealership

#

Yay

rugged root
#

Because I still have work to do

#

And I'd rather connect to our VPN and remote in rather than do the work directly on my lappy

somber heath
#

Have you heard about the new mechanised watercraft?

#

They're called rowbots.

pale sigil
lucid blade
#
#
wind raptor
#

g2g, cheers

lucid blade
#

peace dude

somber heath
#

I was the second in the session.

pale sigil
#
somber heath
#

Or I think I was.

#

I've just been here, listening.

#

Ew.

#

mhm

lucid blade
#

@pale sigil already subd 😉

pale sigil
#

Yeah I just found him😅

worldly vine
#

Hi everyone. Are all voice chats empty or I just can't see/listen members because I'm new in that community and don't have enough rep?

gentle flint
#

you can always join

turbid sandal
#

!code

wise cargoBOT
#
Formatting code on discord

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.

For long code samples, you can use our pastebin.

turbid sandal
#

This is semi pseudocode for a file explorer back-end

def handel(name, extesnsion, task):
    task = task
    match task:
        case "create":
            with open(f"{name}.{extesnsion}", "w") as f:
                f.write()
        case "delete":
            pass
        case _:
            return False
    
def push(type: int = 0, name: str = None):
    match name:
        case None:
            return "Error+name"
        case _:
            match type:
                case 0: # file
                    handel(name, "create")
                case 1: # folder
                    handel(name, "create")
                case _:
                    return "Error+type"

# file/folder parent
class content:
    def __init__(self) -> None:
        pass

# file child
class file(content):
    def __init__(self, name) -> None:
        super().__init__()
        self.name = name
        
    @classmethod
    def create_file(self, extesnsion):
        name = f"{self.name}"
        push(name, 0, extesnsion)
        
    @classmethod
    def delete_file(self, extension):
        handel(self.name, extension, "delete")

# folder child
class folder(content):
    def __init__(self, name) -> None:
        super().__init__()
        self.name = name
        
    @classmethod
    def create_folder(self, extesnsion):
        name = f"{self.name}"
        push(name, 1, extesnsion)
    
    @classmethod
    def delete_file(self, extension):
        handel(self.name, extension, "delete")

The idea is that there is a parent class called content that is curently not in use, and that the children classes are file and folder that that have methods to delete and to create that will be handed by the handel ** (File and Folder Handler used to manage the files) **

|I!i @vocal basin i!I|

vocal basin
#

don't shadow built-ins

#

type -> path_type

#

don't use magic constants

#
FILE = 0
DIRECTORY = 1
#

there's also

#

!d enum

wise cargoBOT
vocal basin
#

name: str = None
strictly, it's name: str | None = None

#

probably better to just avoid passing None into the functiion

#

!pathlib has quite a good system of abstractions for paths

wise cargoBOT
#
The `pathlib` module

Python 3 comes with a new module named Pathlib. Since Python 3.6, pathlib.Path objects work nearly everywhere that os.path can be used, meaning you can integrate your new code directly into legacy code without having to rewrite anything. Pathlib makes working with paths way simpler than os.path does.

Feature spotlight:

• Normalizes file paths for all platforms automatically
• Has glob-like utilites (eg. Path.glob, Path.rglob) for searching files
• Can read and write files, and close them automatically
• Convenient syntax, utilising the / operator (e.g. Path('~') / 'Documents')
• Can easily pick out components of a path (eg. name, parent, stem, suffix, anchor)
• Supports method chaining
• Move and delete files
• And much more

More Info:

Why you should use pathlib - Trey Hunner
Answering concerns about pathlib - Trey Hunner
Official Documentation
PEP 519 - Adding a file system path protocol

fierce stratus
#

pseudo

vocal basin
#

!pep8

wise cargoBOT
#
PEP 8

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
PEP 8 document
Our PEP 8 song! :notes:

vocal basin
#

@classmethod+self don't mix well too

#

!d pathlib.Path.unlink

wise cargoBOT
#

Path.unlink(missing_ok=False)```
Remove this file or symbolic link. If the path points to a directory, use [`Path.rmdir()`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.rmdir "pathlib.Path.rmdir") instead.

If *missing\_ok* is false (the default), [`FileNotFoundError`](https://docs.python.org/3/library/exceptions.html#FileNotFoundError "FileNotFoundError") is raised if the path does not exist.

If *missing\_ok* is true, [`FileNotFoundError`](https://docs.python.org/3/library/exceptions.html#FileNotFoundError "FileNotFoundError") exceptions will be ignored (same behavior as the POSIX `rm -f` command).

Changed in version 3.8: The *missing\_ok* parameter was added.
vocal basin
#

!d pathlib.Path.rmdir

wise cargoBOT
vocal basin
#

these two

turbid sandal
#

try:

vocal basin
#

methods inside BaseException class

#

Exception is specifically for non-exit exceptions

#

!e

print(f'{issubclass(Exception, BaseException)=}')
print(f'{issubclass(SystemExit, BaseException)=}')
print(f'{issubclass(SystemExit, Exception)=}')
print(f'{issubclass(ValueError, Exception)=}')
wise cargoBOT
#

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

001 | issubclass(Exception, BaseException)=True
002 | issubclass(SystemExit, BaseException)=True
003 | issubclass(SystemExit, Exception)=False
004 | issubclass(ValueError, Exception)=True
vocal basin
#

!e

print(dir(Exception))
wise cargoBOT
#

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

['__cause__', '__class__', '__context__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__suppress_context__', '__traceback__', 'add_note', 'args', 'with_traceback']
vocal basin
#

@warm atlas each exception needs to have certain methods

turbid sandal
vocal basin
#

ChatGPT lies and makes stuff up

#

don't trust it

willow light
#

That’s an understatement

whole bear
vocal basin
willow light
#

Reminder that chatgpt doesn’t make code, chatgpt makes text that superficially resembles code

vocal basin
#

!e

class FakeException:
    pass

e = FakeException()
e.add_note("some note")
wise cargoBOT
#

@vocal basin :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 5, in <module>
003 |     e.add_note("some note")
004 |     ^^^^^^^^^^
005 | AttributeError: 'FakeException' object has no attribute 'add_note'
warm atlas
#

The Exception class is the base class for all built-in exceptions in Python. By inheriting from this class, your custom exception inherits all the essential properties and behaviors of an exception. It ensures that your custom exception is compatible with the existing exception hierarchy and can be handled correctly by the exception handling mechanisms .

vocal basin
#

this answer is not specific to exceptions

#

The Fruit class is the base class for all built-in fruits. By inheriting from this class, your custom fruits inherits all the essential properties and behaviors of a fruit. It ensures that your custom fruit is compatible with the existing fruit hierarchy and can be handled correctly by the fruit handling mechanisms.

#

it's just a Ctrl+H type answer

willow light
#

Job security: people think chatgpt isn’t just making text that resembles code and thus use it as a crutch instead of actually learning skills. This allows those of us who actually put in honest work to get ahead.

vocal basin
wise cargoBOT
#

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

[No output]
vocal basin
#

.add_note is something that you as a programmer are actually supposed to use directly unlike the other Exception methods

#

so, since 3.11, you can demonstrate that necessity in code without digging into special methods

#

@turbid sandal it's very good at giving fake references

#

@whole bear PHP becomes less garbage with each year passing

whole bear
#

how the syntax its horrible

vocal basin
#

wtf did you say?
React as a competitor to PHP??

vocal basin
#

@whole bear you can't use React as a back-end

#

> JavaScript power
lol

whole bear
#

my bad

vocal basin
#

Next.js if you mean React-specific

willow light
#

Did someone mention JavaScript

whole bear
#

!e

n = 4
for a in range(1, n+1):
    for b in range(n, 0 ,-1):
        if b != a:
            print(b, end="")
        else:
            print('*', end="")
    print("")
wise cargoBOT
#

@whole bear :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 432*
002 | 43*1
003 | 4*21
004 | *321
whole bear
vocal basin
#

PHP has some same issues as JS

#

type coercion, very easy to get wrong, etc.

turbid sandal
#

@vocal basin did you mute me or what?

vocal basin
#

not yet

whole bear
#

lol

willow light
#

Give it time

turbid sandal
#

why are you still not voice verevied?

#

!voice

whole bear
#

cuz she joined server recentttly

turbid sandal
#

she has been here for more than three days

whole bear
turbid sandal
#

it took me 3 days

#

lol

vocal basin
#

even if I verify, I wouldn't speak anyway

#

fun fact: ctrl+shift+arrow text selection is broken in Discord

willow light
#

Those who speak loudest usually have the least to say

turbid sandal
#

🧐

vocal basin
#

it goes character-by-character instead of word-by-word

warm atlas
#
#Answer 1 : Exception class is used because in the custom exception we have to create a class
# and it needs to have the needed properties to use the raise keyword for an exception to raise
#

is it good?

whole bear
willow light
turbid sandal
#

TOS

whole bear
#

who care

warm atlas
#

TOS

turbid sandal
#

TOS

willow light
#

!rule 5

wise cargoBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

turbid sandal
#

!rule

willow light
#

!rule 2

wise cargoBOT
vocal basin
#

as in you can actually get banned by Discord

#

there were cases

turbid sandal
#

!rule 3

whole bear
#

hahhaa well im using it for 2 years

willow light
#

Three rules broken just by using betterdiscord. And you can get banned for using it.

turbid sandal
#

!rule 3

wise cargoBOT
#

3. Respect staff members and listen to their instructions.

vocal basin
turbid sandal
#

me?

willow light
#

Be glad hemlock isn’t here, although at most he’ll warn you.

whole bear
turbid sandal
#

@whole bear why you leave

whole bear
vocal basin
#

you understand it's a comment, right?

willow light
#

We can ping the mods and find out real quick what this server’s policy is

whole bear
willow light
#

Yes

vocal basin
#

also, "it IS against discord tos" just as the comment says

whole bear
#

where did i said u to install it?

willow light
#

Mentioning something called “Better Discord” is inherent promotion

whole bear
#

ohk then if u say so im sorry then

vocal basin
# vocal basin https://discord.com/developers/docs/policies-and-agreements/developer-terms-of-s...

section a:
[You will not (and will not attempt to or permit or enable others to)] reverse engineer or otherwise derive source code, trade secrets, or know-how from the APIs, except to the extent this restriction is prohibited by applicable laws

section b:
[You will not (and will not attempt to or permit or enable others to)] modify, create derivative works, copy, reproduce, redistribute, rent, lease, sell, or syndicate access to the APIs

section c.i:
[You will not (and will not attempt to or permit or enable others to)] access or use the APIs in any way that is not in accordance with the applicable Documentation

#

"except to the extent this restriction is prohibited by applicable laws"
^ that clause is there because in some jurisdictions you're allowed to reverse-engineer the source code, but not allowed to publish the results

willow light
#

You are contributing to the spread

vocal basin
#

"not enough 'non-'s in that sentence"

whole bear
#

anyway thnx for the info

warm atlas
#

@vocal basin

vocal basin
#

what?

somber heath
warm atlas
#

can you help me writing the code for printing hierarchy of Exceptions clas

#

*class

#

just let me figure it out

#

and help me

vocal basin
somber heath
#

!e py print(ValueError.mro())

wise cargoBOT
#

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

[<class 'ValueError'>, <class 'Exception'>, <class 'BaseException'>, <class 'object'>]
somber heath
#

?

willow light
warm atlas
#

hierarchy of all the exception error has according to its priority

vocal basin
#

very expressive dependency section

vocal basin
vocal basin
warm atlas
#

means

#

like first which error will be detected

vocal basin
somber heath
#

Expression / line evaluation order and whatever exception happens first, there?

vocal basin
warm atlas
#

but can you help me printing it?

somber heath
#

Yes, well...just so.

vocal basin
#

why......

#

wait, Whitespace has versions?

somber heath
#

I could tell you the order, but programmatically, not so much.

warm atlas
#

i have googled it maybe can be achieved by inspect module

vocal basin
#

what is an example input-output for what you're trying to do?

#

python's notion of error/exception isn't really about errors and/or exceptions

#

StopIteration isn't an error, neither is it an exceptional situation

#

even though it derives from Exception

#

!e

it = iter([0, 1, 2])
print(next(it))
print(next(it))
print(next(it))
print(next(it))
wise cargoBOT
#

@vocal basin :x: Your 3.11 eval job has completed with return code 1.

001 | 0
002 | 1
003 | 2
004 | Traceback (most recent call last):
005 |   File "/home/main.py", line 5, in <module>
006 |     print(next(it))
007 |           ^^^^^^^^
008 | StopIteration
vocal basin
#

but

#

uncaught StopIteration is an error

#

it becomes an error when you fail to catch it

#

semantically, it's not an error

#

it is an exception, in Python terms

vocal basin
#

so, you just want a class hierarchy of errors, right?

warm atlas
#

---> Exception
------> TypeError
---------> MultipartConversionError
---------> FloatOperation
------> StopAsyncIteration
------> StopIteration
------> ImportError
---------> ModuleNotFoundError
---------> ZipImportError
------> OSError
---------> ConnectionError
------------> BrokenPipeError
------------> ConnectionAbortedError
------------> ConnectionRefusedError
------------> ConnectionResetError
--------------> RemoteDisconnected

vocal basin
#

!e

def hierarchy(type_, depth=0):
    print(' ' * depth + type_.__name__)
    for subtype in type_.__subclasses__():
        hierarchy(subtype, depth + 2)
hierarchy(BaseException)
wise cargoBOT
#

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

001 | BaseException
002 |   BaseExceptionGroup
003 |     ExceptionGroup
004 |   Exception
005 |     ArithmeticError
006 |       FloatingPointError
007 |       OverflowError
008 |       ZeroDivisionError
009 |     AssertionError
010 |     AttributeError
011 |     BufferError
... (truncated - too many lines)

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

vocal basin
#

yes, recursion

#

!e

class SomeClass: pass
print(SomeClass.__name__)
wise cargoBOT
#

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

SomeClass
vocal basin
#

BaseException includes certain "exit" exceptions, as well as normal exceptions

#

Exception is supposed to hold only "non-exit" exceptions

#

!e

try:
    exit(1)
except SystemExit as e:
    print(e)
    raise
wise cargoBOT
#

@vocal basin :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 2, in <module>
003 |     exit(1)
004 |     ^^^^
005 | NameError: name 'exit' is not defined
vocal basin
#

eh

#

doesn't work here

#

there are two most common exit exceptions:
SystemExit and KeyboardInterrupt

#

first happens on exit() call

#

second happens on Ctrl+C and/or when SIGINT signal is received

vocal basin
wise cargoBOT
#

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

001 | BaseException
002 |   BaseExceptionGroup
003 |     ExceptionGroup
004 |   Exception
005 |     ArithmeticError
006 |       FloatingPointError
007 |       OverflowError
008 |       ZeroDivisionError
009 |     AssertionError
010 |     AttributeError
011 |     BufferError
... (truncated - too many lines)

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

vocal basin
#

for example, another exception appeared: CancelledError

#

generally, you're not supposed to catch and ignore/suppress exit exceptions

#

except block with them would almost always end with an empty raise (which re-raises that same exception)

#

... unless you're really trying to mess with the control flow

#
try:
    ...
except BaseException as e:
    handle_the_error()
    raise
#

in this case raise is almost the same as raise e

#

!e

try:
    1 / 0
except BaseException as e:
    print(f"caught {e.__class__.__name__}: {e}")
    raise
wise cargoBOT
#

@vocal basin :x: Your 3.11 eval job has completed with return code 1.

001 | caught ZeroDivisionError: division by zero
002 | Traceback (most recent call last):
003 |   File "/home/main.py", line 2, in <module>
004 |     1 / 0
005 |     ~~^~~
006 | ZeroDivisionError: division by zero
vocal basin
#

!e

try:
    1 / 0
except BaseException as e:
    print(f"caught {e.__class__.__name__}: {e}")
    raise e
wise cargoBOT
#

@vocal basin :x: Your 3.11 eval job has completed with return code 1.

001 | caught ZeroDivisionError: division by zero
002 | Traceback (most recent call last):
003 |   File "/home/main.py", line 5, in <module>
004 |     raise e
005 |   File "/home/main.py", line 2, in <module>
006 |     1 / 0
007 |     ~~^~~
008 | ZeroDivisionError: division by zero
vocal basin
#

these produce a similar result

#

the difference is:

vocal basin
#

that's why raise line doesn't appear in the traceback

#

this part is shown only in the second case

003 |   File "/home/main.py", line 5, in <module>
004 |     raise e
#

!e

try:
    1 / 0
except:
    raise
wise cargoBOT
#

@vocal basin :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 2, in <module>
003 |     1 / 0
004 |     ~~^~~
005 | ZeroDivisionError: division by zero
vocal basin
#

yes, it adds an extra line to the traceback when raise something is used

#

(regardless of whether something was caught previously)

vocal basin
#

though empty except is generally not a good practice

knotty dome
#

#include <stdio.h>

int main() {
int N;
int count = 1;

printf("Enter number of rows between 2 and 9: ");
scanf("%d", &N);

if (N < 2 || N > 9){
    printf("ERROR: enter a number within range.");
    return 1;
}else{

    for (int i = 0; i < N; i++){

        for (int j = 0; j < N - i; j++){
            printf("%2d ", 0);
        }


        for (int j = 0; j < N; j++){
        printf("%2d ", count);
        count++;
        }
        for (int j = 0; j < i + 1; j++){
        printf("%2d ", 0);
        }
        printf("\n");
    }
}
return 0;

}

vocal basin
robust bone
#

hey 👋

copper night
#

None

ebon mist
jolly terrace
#

"""
def is_float(string):
try:
float(string) # try to convert the string to a float
return True # if successful, return True
except ValueError: # if there is a ValueError, it means the string is not a valid float
return False # return False
"""

ebon mist
vocal basin
#

is 0.00.01 a version?

#

Git is partially made to avoid having versions as directories

#

there are tags and branches for this

#

tags for versions
branches for major versions

#

(because you might want to update major versions separately)

#

tts?

#

google cloud text-to-speech isn't free, afaik

#

google translate text-to-speech is questionably legitimate

#

because it's undocumented

#

there is pyttsx3 which is offline

#

@ebon mist if it's just notes and not a Python file, you can make it a .md file (Markdown) to make it clear

#

if you're using VS Code / PyCharm, you'll be able to see the preview of it too

ebon mist
#

???

#

@vocal basin what

ebon mist
vocal basin
#

multiple references to the same node exist at times

rocky dome
#

@lunar haven 👋

vocal basin
#

if right is not None, this pushes two references to right into the stack

push(right)
stack.append((Visit.VALUE, node))
#

if the algorithm doesn't need to "consume" the tree as it traverses it, then fine

vocal basin
open jetty
#

If anyone needs a Curse word detection for their discord bot Then DM me

vocal basin
#

if there's a restriction on having types uniform, then probably not much to be improved with this

open jetty
#

it was easy to make

#

check your dms instead @midnight agate

vocal basin
open jetty
#

@midnight agate check DMs

#

np

vocal basin
#

it took so long...

#

but I can run Rust in Jupyter now

#

even allows doing ? unwrapping
(probably just has blanket From<T: Display> for the error)

#

from the example the docs give:

vocal basin
lavish rover
#

i wonder if you could do something like <script>alert()</script> inside the display function

vocal basin
#

it works, so don't run on untrusted data

lavish rover
#

amazing, but now I'd be paranoid of people providing "debug method" that is secretly mining bitcoin

#

this seems... way too complicated

vocal basin
lavish rover
#
def in_order(self, root: Optional[TreeNode]) -> List[int]:
    result = []
    def run(node):
        if node:
            run(node.left)
            result.append(node.value)
            run(node.right)
    run(root)
    return result
vocal basin
#

I still think handling root separately is unnecessary

class Solution:
    def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
        inorder = []
        stack = []
        def push(node):
            if node is not None:
                stack.append((Visit.BRANCHES, node))
        push(root)
        ...
lavish rover
#

cheeky "technically":

def in_order(self, root: Optional[TreeNode]) -> List[int]:
    def run(node):
        if node:
            yield from run(node.left)
            yield node.value
            yield from run(node.right)
    result = []
    for val in run(root): result.append(val)
    return result
vocal basin
#

if root is None is extra

lavish rover
#

what really is recursion if not spicy loops

vocal basin
lavish rover
#

I don't think it optimizes anything I just didn't want to rewrite it

#

the "technically" was from me collecting the values in the final loop

#

lol my bad, yield node.value

vocal basin
lavish rover
#

but i have loop!!!!

#

/s

#

I'd probably just do something like (have not run it):

def in_order(root):
    stack = [root]
    result = []
    while stack:
        cur = stack.pop()
        match cur:
            case TreeNode(): stack.extend([cur.right, cur.val, cur.left])
            case int(): result.append(cur)
    return result
vocal basin
#

last time I did it was
||
```py
code
```
||

||

code

||

lavish rover
#

when in rome

vocal basin
#

for some reason cc was broken and pointing nowhere

lavish rover
#

You technically already have a list with different types in it, you just also store an extra enum instead of just checking the type, feels equivalent to me

#

(list of tuples but w/e)

vocal basin
#

it does

vocal basin
lavish rover
#

oh right you always store the node, not the value

#

i guess that works

#

personally, if I'm using a dynamic language I'd rather use the dynamic language

#

(within limited scope, this isn't a full-scale program)

#

I am not a fan of iterative approach in this case tbh, asymptotically it uses more memory and the logic is more annoying

#

I originally did isinstance() but changed it to match to line up with your version a little more

#

how though?

#

fair enough, just check if it's non-null

#

unless you also want to collect None, at which point I tell you I don't care enough

#

you have mentioned this many, many, many times

#

maybe go take some code off my github and refactor that to make it cleaner if you really fancy 🙂

#

aecor definitely needs some cleaning

#

my programming language

vocal basin
#
class Solution:
    def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
        inorder = []
        stack = []
        def push(node):
            if node is not None:
                stack.append(([], [node]))
        push(root)
        while stack:
            values, nodes = stack.pop()
            inorder.extend(values)
            for node in nodes:
                push(node.right)
                stack.append(([node.val], []))
                push(node.left)
        return inorder
#

in Rust if would be unnecessary
you can just collect an Option into a Vec

vocal basin
#

the most cryptic version I came up with so far

class Solution:
    def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
        inorder = []
        stack = [([],filter(bool,[root]))]
        while stack:
            values, nodes = stack.pop()
            inorder.extend(values)
            for node in nodes:
                stack.extend([([],filter(bool,[node.right])),([node.val],[]),([],filter(bool,[node.left]))])
        return inorder
#

though I know how to make it worse

vocal basin
# vocal basin though I know how to make it worse

the "worse":

class Solution:
    def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
        inorder = []
        stack = [filter(bool,[root]),[]]
        while stack:
            inorder.extend(stack.pop())
            for node in stack.pop():
                stack.extend([filter(bool,[node.right]),[node.val],filter(bool,[node.left]),[]])
        return inorder
#
class Solution:
    def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
        from collections import deque
        q = deque([None, filter(bool,[root]),[]])
        try:
            while True:
                q.extendleft(q.pop())
                for node in q.pop():
                    q.extend([filter(bool,[node.left]),[node.val],filter(bool,[node.right]),[]])
        except:
            return list(q)
#

similar idea but without try-except

class Solution:
    def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
        from collections import deque
        q = deque([float('nan'),filter(bool,[root]),[]])
        while q[-1]==q[-1]:
            q.extendleft(q.pop())
            for node in q.pop():
                q.extend([filter(bool,[node.left]),[node.val],filter(bool,[node.right]),[]])
        return list(q)[:-1]
#

at this point it is complete opposite of trying to get uniform types in a list

wind raptor
#

@whole bear here

whole bear
#

hey

#

i am making a s/e/x thing

#

i dont know how

#

like this

#

see

#

wanna see my version

#

no

#

just like

#

yeah

#

and i need a domain

#

? @midnight agate

#

?

#

@wind raptor can we go to dm

#

private vc

#

can you go to my dm

#

i mentioned you

jade yew
#

heyo does anyone know how to use pygame?

wind raptor
#

@midnight agate he was showing a discord thing, it's not like it's lewd or anything

whole bear
#

cant you unmute me @wind raptor

#

your a mod

wind raptor
#

I asked what it was

whole bear
#

can we go to dm

#

private chat i mentioned you

wind raptor
#

You're not even in vc

#

lol that's what I was trying to figure out

whole bear
#

i mentioned you twice

#

oh come on

#

its getting abusing

#

that i cant talk