#python-discussion

1 messages Β· Page 445 of 1

tame vapor
#

someone who doesnt want coding needs stuff to be fun or else they just give up , close coding and gg

slow gust
#

Tysm!! Ill search that up 🀩

velvet trout
#

Inside list literal [] it takes expressions for items, where items are separated by a comma.

dusk adder
#

The Usualβ„’ (Β©Mickrosoft)

pastel sluice
tame vapor
#

if you try to teach them stuff perfectly with all the good practices , they are just gonna get bored and quit
because you have to learn lots of boilerplate and boring things to do all the "best practices" from the start (typehinting for example)

raven urchin
slow gust
#

Oh okay tysm bro I appreciate it and also.could a game made with Python be exported into the App store?

velvet trout
slow gust
slow gust
dusk adder
slow gust
raven urchin
velvet trout
pastel sluice
flint jewel
dusk adder
tame vapor
#

if someone is asking for python editor
i am here to spread the logo_pycharm pycharm propaganda
use it , it is good ducky_bike

slow gust
inland karma
raven urchin
velvet trout
pastel sluice
golden mortar
velvet trout
slow gust
bronze dragon
dusk adder
tame vapor
slow gust
stray field
#

Note to self: update the readme more often

pastel sluice
inland karma
inland karma
flint jewel
#

odd_numbers = [range(1,20,2)]
for odd_number in odd_numbers:
print(odd_number)
odd_numbers = range(1,20,2)
for odd_number in odd_numbers:
print(odd_number)

edgy krakenBOT
#

Hey @flint jewel!

Please edit your message to use a code block

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

This will result in the following:

print('Hello, world!')```
flint jewel
#

can you run it here ?

slow gust
bronze dragon
#

it doesn't become a string, it stays as a range object.

flint jewel
inland karma
slow gust
inland karma
slow gust
flint jewel
inland karma
inland karma
bronze dragon
flint jewel
#

where should I dm you

slow gust
dusk adder
inland karma
slow gust
inland karma
#

make a help channel

flint jewel
bronze dragon
slow gust
inland karma
inland karma
bronze dragon
#

it does not become a string

dusk adder
slow gust
bronze dragon
#

it is a range object

pastel sluice
#

@flint jewel if you say
[range(1,20,2)]
that isn't a comprehension. that's a list with one object in it, a range object.
a comprehension is when you use the comprehension syntax:
[x for x in range(1,20,2)]

inland karma
slow gust
bronze dragon
#

whose representation, upon being printed, looks like range(1, 20, 2)

slow gust
dusk adder
inland karma
slow gust
flint jewel
#

so it doesn't become a string

dusk adder
flint jewel
#

rather it just prints the representation

slow gust
gleaming knoll
inland karma
slow gust
flint jewel
#

too many channels

inland karma
slow gust
raven urchin
#

@flint jewel
Can you open a thread on #1035199133436354600 so we can discuss it without disrupting the chat? I want to help u too :3

inland karma
#

do you use windows, mac or linux @slow gust ?

slow gust
raven urchin
velvet trout
#

πŸ˜‹

gleaming knoll
#

range is not a generator, but yes, [range(x)] is indeed a list with a single range object inside, not a list of the numbers in this range

stray field
#

range is range

inland karma
#

range is a sequence

velvet trout
#

wait was i learning wrong my whole life

inland karma
inland karma
stray field
#

!e print(type(range(0, 10, 2)))

velvet trout
edgy krakenBOT
slow gust
velvet trout
#

All that text wall was wrong...

inland karma
steady rain
#

@velvet trout range is basically a lazy sequence, because it can just use math to get the nth element (or whatever operation you want to do), instead of storing them all in memory

slow gust
gleaming knoll
inland karma
slow gust
slow gust
inland karma
velvet trout
#

Oh no its not

inland karma
stray field
#

range uses __getitem__ iteration, right?

velvet trout
#

Its lazy right

slow gust
velvet trout
#

Or not

steady rain
slow gust
inland karma
raven urchin
flint jewel
#

opened a thread in help

inland karma
bronze dragon
slow gust
velvet trout
velvet trout
steady rain
velvet trout
#

How can i write a text wall so confidentially incorrect?

steady rain
inland karma
slow gust
velvet trout
bronze dragon
dusk adder
stray field
#
class Iterable[T](Protocol):
  def __iter__(self) -> Iterator[T]: ... # returns a new iterator each call
class Iterator[T](Protocol):
  def __iter__(self) -> Iterator[T]: ... # return self
  def __next__(self) -> T: ... # raises StopIteration when empty
edgy krakenBOT
#

Objects/rangeobject.c line 822

range_iter,             /* tp_iter */```
velvet trout
#

Well learnt something new today, just like every other day

steady rain
#

@velvet trout don't worry about it. it makes sense why you'd think range is a generator.

velvet trout
slow gust
inland karma
wicked comet
#

Generators have yield in them right?

inland karma
inland karma
steady rain
slow gust
steady rain
inland karma
gleaming knoll
steady rain
#

!e

print('This is a short script')
a = 5 * 2
print(a)
edgy krakenBOT
slow gust
steady rain
magic herald
#

Hello, everyone. I am going to start learning python. Do you know any good free websties to strat off with or ytoyutube?

steady rain
#

!slorb

edgy krakenBOT
#
Go-to beginner resources

Here are the top free resources we recommend for people who are new to programming:

For a full, curated list of educational resources we recommend, please see our resources page!

pastel sluice
wicked comet
slow gust
inland karma
steady rain
gleaming knoll
slow gust
inland karma
slow gust
gleaming knoll
slow gust
slow gust
gleaming knoll
# stray field It's new

is the code that people have been writing for iOS cross-platform compatible with the new android stuff?

inland karma
velvet trout
#

Should i repost my text wall to Seraj with correction? pithink

stray field
# gleaming knoll is the code that people have been writing for iOS cross-platform compatible with...

From the release notes:

Swift 6.3 includes the first official release of the Swift SDK for Android. With this SDK, you can start developing native Android programs in Swift, update your Swift packages to support building for Android, and use Swift Java and Swift Java JNI Core to integrate Swift code into existing Android applications written in Kotlin/Java. This is a significant milestone that opens new opportunities for cross-platform development in Swift.

slow gust
gleaming knoll
#

interesting

frozen pasture
#

Is there anyone looking for python dev?

velvet trout
#

De javu?

#

I think you asked this before too pithink

pastel sluice
#

we aren't a job search or recruitment board

quick needle
tawdry galleon
#

Hello!

velvet trout
#

Cats are so careless and happy. They don't have to worry about programming or naming conventions

tawdry galleon
velvet trout
#

πŸ˜”

tawdry galleon
velvet trout
velvet trout
#
>>> range(5)[0]
0
>>> range(5)[1]
1
>>> range(5)[4]
4
>>> range(5)[5]
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    range(5)[5]
    ~~~~~~~~^^^
IndexError: range object index out of range
>>>

what's the appropriate use case for subscripting range would be?

#

Why would someone need it to do that ?

dry pike
#

All sequences subscriptable

#

I don't think there is a case where you should genuinely do it tho

velvet trout
#

But why make it a Sequence?

#

like actual reason and usecase

#

Keeping it an Iterable was enough, was it not?

dry pike
#

well it used to be a list

#

it breaks less if it stays a sequence

autumn forge
#

I've done range(len(seq))[::-1] to iterate over the indices of a list in reverse, but it was in some #hacky code

velvet trout
#

Oh so backward compatibility!

slender urchin
#

It's pretty free to add the functionality

velvet trout
#

can we access start, stop, step from range(...) ?

dry pike
#

Yes

#

cannot modify tho

velvet trout
#

Oh we can ! :D

velvet trout
#

It has index and count too.

dry pike
#

having count is funny

novel gust
#

So guys I do understand why you were recommending Python as my first language instead of C

And I adhered to it.

BUT
My only mistake was to start with a ✨Introductory✨ course for Computer Science, which has some C in it.

And it's very first problem set has absolutely ragebaited me.
Why? Seems so simple, but God knows the solution.

And I think I need to conquer this C first before python.

Or I consider myself dumb.

velvet trout
silver plover
velvet trout
bronze dragon
novel gust
#

That Mario PSet

novel gust
silver plover
#

You picked the general one, which includes multiple languages

velvet trout
#

range(0,0,0)
Traceback (most recent call last):
File "<python-input-24>", line 1, in <module>
range(0,0,0)

~~~~~^^^^^^^

ValueError: range() arg 3 must not be zero

Tho Would it still make sense to set step=0 since start and stop are zeroes too? pithink

novel gust
slender urchin
#

instead of range with 0 use repeat

velvet trout
#

right

crisp jay
#

coding in c++ is the worst thing someone could do

novel gust
#

Remove ++

bronze dragon
silver plover
velvet trout
#

--C

silver plover
#

Cflat

velvet trout
#

C$

C# but american.

fiery yarrow
velvet trout
silver plover
#

That's just b++

gleaming knoll
autumn forge
#

Cβ™­

velvet trout
#

Why were they playing ABCD back when naming programming languages?

#

πŸ˜‚

silver plover
novel gust
#

commanding a computer

surreal knot
#

case in point APL = A programming language

silver plover
#

And yacc

velvet trout
novel gust
#

computer is dumb

velvet trout
#

I barely used yaml

#

Toml supremacy

silver plover
charred tusk
#

Yaint

velvet trout
gleaming knoll
bronze dragon
#

there are a lot of "yet another" style names in tech

velvet trout
velvet trout
gleaming knoll
fiery yarrow
velvet trout
#

Oh

fiery yarrow
#

i do

charred tusk
autumn forge
#

you're just hating smh πŸ™„

velvet trout
#

Tom's obvious markup language

fiery yarrow
#

i see toml as equivalent to muskl or bezosl, but not quite as bad

gleaming knoll
autumn pelican
#

Thuri loves me

#

We're gonna get beers together one day

fiery yarrow
#

thuri is not buying your current charade, cert

autumn pelican
#

Bruh

#

I just ate like 5 servings of spaghetti

velvet trout
gleaming knoll
velvet trout
autumn pelican
#

Thought I'd switch it up yk

#

To defeat your enemy you must first become them
--Sun tzu, the art of war

velvet trout
#

😭 no loyalty

gleaming knoll
#

to become your first you must defeat enemy
-- war, sun art of the tzu

velvet trout
charred tusk
#

Huh, this dude this founded Gravatar

velvet trout
#

The thread in python-help channel is closed after last message gets one hour old?

velvet trout
#

So its like:

β€’ Incoming thread message:
β€’ thread.messages.append(message)
β€’ thread.reschedule_auto_close()

?

#

How discord servers do it

flint jewel
#

odd_numbers = [range(1,20,2),range(1,20)]
for value in odd_numbers:
print (*odd_numbers[value]) why is this wrong ?

velvet trout
#

Reschedule or queue reschedules

grave tree
velvet trout
#

!source

edgy krakenBOT
velvet trout
#

Gotta check and learn

velvet trout
velvet trout
flint jewel
#

I thought value is an iretator

velvet trout
#

Nope, value is the item of list

flint jewel
#

oh, cool

undone grove
#

python drones

dull dune
#

lists are iterables

undone grove
#

you can fly them

dull dune
flint jewel
dull dune
#

odd_numbers is a list, which is Iterable

lament terrace
dull dune
#

value is a range object, with is also iterable

undone grove
#

you can use python to fly the drones

flint jewel
#

ok so why are those different numbers = [1,2,3,4,5,6] same_numbers = numbers my_own_copy = numbers[:]

#

and why does this only print two names players = ['sam','carl','demitery','samson','compenhagen','marteniz']\

print(*players[:2])

runic flower
flint jewel
#

isn't the index start at 0

runic flower
flint jewel
runic flower
flint jewel
#

it should start at zero

#

oh wait

runic flower
flint jewel
#

so, when I do a slice like this number[0:2] it leaves the number at index 2?

slender urchin
#

It's up to 2, not up to and including

flint jewel
#

oh ok

runic flower
flint jewel
#

oh makes perfect sense

velvet trout
runic flower
# flint jewel oh ok

for slicing, [:2] => [0:2:1] => start at 0, increment by 1, until you reach 2, stop at 2, do not include it.

velvet trout
runic flower
flint jewel
velvet trout
#

Some things starts at zero, end is exclusive

#

Programming 101

runic flower
# flint jewel yeah, thanks for clarification

one of the cool things you can do here, is use a variable and you end up with the same.

x = [ 1,2,3 ... 97,98,99 ]  # note ... is not a thing here, I'm just abbreiating
y = x[:50] + x[50:]

x and y abre both 1-99

flint jewel
#

well in C I have to explicitly say if it's exclusive or not

runic flower
flint jewel
#

it's not programming 101 lol

velvet trout
#

πŸ˜”

runic flower
#

next up, using numpy. πŸ™‚

novel gust
#

@bronze dragon Have you completed CS50?

steel whale
#

I got the openwrt one router and holy shit this is so buttery smooth

#

when using it in a client+ap config there's basically zero lag

runic flower
steel whale
#

data gets sent in the same millisecond

steel whale
#

it has an nvme port which is really overkill but I like it

runic flower
steel whale
#

no ed25519 on ssh auth

#

tho using the imagebuilder you could add ed25519 support, not sure

chilly whale
#

1 millisecond is a very, very long time for a computer

steel whale
#

lots of lag

chilly whale
#

Jesus.

steel whale
#

apparently because it has to switch some interface control thing? idk

steel whale
#

though in practice its not really noticeable

#

I watch Netflix on 4k just fine

chilly whale
#

That's more about bandwidth than latency

runic flower
steel whale
#

as long as using the internet on it is fine I'm happy

#

sad that my phone nor my PC can use WiFi 6

#

my laptop has no 5ghz support unfortunately

runic flower
#

Made sure my router had wifi6 support for wireless VR to my computer.

solar axle
#

i am trying to save an object as a json file. the object has list fields that hold other objects from a different class. how do i approach this? the objects that the list holds are added into the list from the class of that object.

sorry if that doesnt mkae sense

chilly whale
#

150ms is enough to get from New York to Australia and back. It's pretty shocking for it to take several ms for the data to leave your living room, haha

runic flower
runic flower
solar axle
solar axle
chilly whale
#

JSON is a text format, so for every field in your object, you'd need to define how to represent that field in text

stray field
runic flower
stray field
solar axle
solar axle
#

what method?

runic flower
vital musk
#

Hi, I’ve been interested in ai recently as it’s one of the biggest industry’s in the past few years and wanted to start learning python. So I’m curious, how hard is it to start to learn the basics and how long can I expect to spend until I get a good grasp on it?

cerulean ravine
stray field
civic tree
#

If I have a JSON list of scraped listing of laptops, but the descriptions and titles were messy, how can I reliably extract specs, model name, CPU etc from the listing?

runic flower
# solar axle thanks for the resouce!

np, it might be easier for you to play with pickle for now.
you could also consider using dataclasses which can encode and decode into json pretty easily.
lastly, when you get a bit more complex you could conside saving your data into sqlite3 which is not hard to use once you get there.

solar axle
#

but how does that help to serialize it and write into a json file?

runic flower
stray field
jagged nacelle
runic flower
stray field
solar axle
jagged nacelle
stray field
solar axle
#

would this be difficult to read back and convert back into an object?

#

i can kind of see what youre saying but dont fully get it

civic tree
#

Won't I have to use some kind of LLM

stray field
solar axle
#

ah so what xelf was saying about using pickle basically

#

aka using something else

runic flower
# jagged nacelle dataclasses are able to be serialized?

You can use asdict to serialize and object hook to deserialize.
Quick example:

@dataclass
class Weapon:
    name: str
    damage_type: str
    damage_dice: int
    dice: int

weapon_json = '''
[
    {"name": "Rapier", "damage_type": "Piercing", "damage_dice": 2, "dice": 6},
    {"name": "LSword", "damage_type": "Slashing", "damage_dice": 1, "dice": 8}
]
'''

weapons = json.loads(weapon_json, object_hook=lambda r:Weapon(**r))

for w in weapons:
    print(w, json.dumps(asdict(w)))
solar axle
#

is the way ive designed my classes poor, or is this simply just a limitation of json

stray field
#

!pip dataclasses-json

edgy krakenBOT
runic flower
stray field
runic flower
runic flower
runic flower
stray field
#

I had a problem so I tried using regexp. Now I have s/^[+-]?[0-9]+$/g problems.

solar axle
#

pickle marshall or pydantic or the dataclasses-json?

cerulean ravine
stray field
#

Pydantic has more advanced validation features, good for user input.

runic flower
solar axle
#

if i go with the dataclass approach, is it easy to read back from the file?

#

im trying to find an approach that works both ways

stray field
wise imp
#

ahhhh, I see

runic flower
civic tree
solar axle
#

thanks fo rall your help guys im gonna do some research and then decide finally

wraith shore
#

good afternoon

cerulean ravine
charred tusk
#

Apparently a couple of my repos never had Dependabot security updates enabled and I have 50-something security alerts
RIP my "inbox 0" 😭

#

PyPI dark mode when??

#

It is kinda annoying that I have 16 "high" alerts just on this one repo alone, which is a ... static site hosted on GitHub Pages though
the alert fatigue is real

wraith shore
flint jewel
#

Anyone cares to explain what is a dictionary?

pastel sluice
#

in a list, you locate items by their index position (a number). in a dictionary, you can use a number, a string, or a whole variety of other things

crisp jay
steel whale
flint jewel
#

it is

pastel sluice
#

!e

d = {"x":1, "y":2, "z":3}
print (d["x"])
edgy krakenBOT
flint jewel
#

oh nice

#

I'll watch a youtube video then

cerulean ravine
cerulean ravine
dry pike
#

what link?

runic flower
flint jewel
#

it's helpfull

flint jewel
#

so it's basically a struct

cerulean ravine
#

you don't have to know the keys ahead of time

flint jewel
#

oh, so they have their own methods?

cerulean ravine
cerulean ravine
pallid garden
slow rivet
red quartz
#

Salut

cerulean ravine
dry pike
#

Salad

pallid garden
#

every time i see an interesting bug i wonder to myself if claude would have been able to catch it

signal whale
#

Hi

pallid garden
stray field
mystic wagon
civic tree
pallid garden
#

not much, i would say

civic tree
#

Hmm

#

I'm debating on how I should move forward

timid ember
frosty oriole
charred tusk
frosty oriole
#

you could probably also train your own model to extract specs from those descriptions

#

might be fun

charred tusk
#

Oh hey look pycryptodome in Pythonhelp
surely not malware
…right?

shrewd pine
charred tusk
#

Woah
Don’t drop 26billionwithab parameters in your lap
They’ll crush you

shrewd pine
#

purely llm generated contributions with no relevant human in the loop is a rude thing to impose on a human maintainer

civic tree
#

Since this is just a hobby project I'd rather not spend money

shrewd pine
#

isn't qwen 2.5 pretty garbage at code?

civic tree
jagged jolt
civic tree
#

And can't run anything more than that or my MacBook will self destruct

shrewd pine
jagged jolt
shrewd pine
autumn pelican
#

lmfao

jagged jolt
real leaf
#

Hi

shrewd pine
sullen dust
#

Would ffmpeg be able to compress a 30GB video?

silver plover
dry pike
#

to what extent, unknown

sullen dust
#

Maybe that was a stupid question, How can i know what file size i can compress it to

sullen dust
dry pike
#

just try it

silver plover
muted rampart
shrewd pine
sullen dust
shrewd pine
#

You will have a lot of knobs you could tune wrt quality/formats/whatever

silver plover
#

So, the real question is; how much can I compress this video while still retaining good enough quality.

#

And, that depends on your video.

vale wasp
rare gazelle
#

i worked on something, almost finished, but abandoned that for the time bbeing

#

(that uses ffmpeg)

brisk gazelle
#

Give me lossless compression or give me death.

rare gazelle
#

but again, all the tools are pretty bad in my opinion

#

(the ones i've used at least)

granite wyvern
rare gazelle
#

also one codec might provide you better quality with smaller size, compared to another

granite wyvern
#

That too. The bitrate * frames predicts the size, the codec will get you btter/worse video for the bitrate

rare gazelle
#

maybe i'll finish it one day, but i have other things in mind for the time being

granite wyvern
#

You can see the defaults I chose at the top of the script above: 200k, a desired video scale (scaled down from full HD 1920x1080), h265 for the video codec.

vale wasp
granite wyvern
#

True. But the encoder should try to achieve the requested bitrate regardess, possibly at the expense of video frame perceived quality.

#

And I belive you can get ffmpeg to make 2 passes.

vale wasp
#

Definitely. But It will give higher perceived quality for a relatively still person talking in front of a static background than it will for something with a lot of motion.

rare gazelle
#

i have a feeling that when i'll return to that project i've made about it, seeing the code will just disgust me

#

anyone else has this feeling of returning to an old project

rare gazelle
#

yea!

vale wasp
#

I'd like to think I'm a better engineer than I was a year ago.

rare gazelle
#

thats a positive way to look at it i guess

#

i look at it like i was shit a year ago

#

(and every year it repeats itself xD... as you've said i guess)

vale wasp
#

I doubt that. But you have more experience now and you would do things differently.

rare gazelle
#

yea definitely

#

i'll take what you said though, thats a sign of progress

vale wasp
#

.topic

verbal wedgeBOT
#
**In what ways has Python Discord helped you with Python?**

Suggest more topics here!

dry pike
#

dot topic

vale wasp
#

I learned about .topic πŸ˜‰

hot glen
#
a = "asdf"
b = "jkl;"
print (a and b)``` just realized u cant use and with print only commas
vale wasp
# verbal wedge

I learned things I hadn't known. I've gotten better at explaining things and gauging people's levels.

dry pike
hot glen
#

vro

granite wyvern
granite wyvern
#

A comma works, if you want a space between the strings.

hot glen
granite wyvern
#

print wirtes each of its arguments converted to a string with a space between each

rare gazelle
#

whats the question then i dont understand

#

a and b is valid

hot glen
#

but and should print both

silver plover
rare gazelle
#

nope

granite wyvern
#

a + b withh write the strings with no space between

rare gazelle
#

and doesn't mean that

granite wyvern
rare gazelle
#

every string that is not empty is truthy

granite wyvern
#

That's what I mean by "it doesn't mean what you expected"

rare gazelle
#

try:

a = ""
b = "hello"
print(a and b)
#

afterwards try:

a = "a"
b = "hello"
print(a and b)
vale wasp
granite wyvern
# hot glen wont work

Well, it does something. "won't work" only has meaning in terms of the outcome you wanted. Which you never actually specified.

silver plover
granite wyvern
vale wasp
vale wasp
rare gazelle
pallid garden
#

it's crazy how no one found this obscure bug until now

rare gazelle
#

but maybe only i'm feeling it i dont know

granite wyvern
rare gazelle
#

i'd like to think i'm not the only one

vale wasp
vale wasp
pallid garden
#

apparently error notifications have been broken since like feb

hot glen
rare gazelle
vale wasp
pallid garden
granite wyvern
pallid garden
#

so no one reported it

rare gazelle
vale wasp
pallid garden
rare gazelle
#

well πŸ€·β€β™‚οΈ

pallid garden
#

it just so happens that there were no errors

vale wasp
rare gazelle
#

its not just code btw

#

i dont know its just a feeling haha

pallid garden
#
    // redux-state-sync relies on BroadcastChannel, which only supports
    // objects that are clonable by `structuredClone`
    if (typeof action === 'function') {
      return false;
    }
```ah yes, of course, if the object is not a function, it cannot contain a function
granite wyvern
edgy krakenBOT
pallid garden
vale wasp
rare gazelle
#

yea burn it

granite wyvern
rare gazelle
#

if there was any

vale wasp
swift sparrow
granite wyvern
rare gazelle
#

yea i can see that

vale wasp
granite wyvern
#

I use it a lot in exception messages too.

vale wasp
#

It rocks for logging.

granite wyvern
rare gazelle
granite wyvern
#

!e

print(f'{3=}:{3 = }:')
edgy krakenBOT
rare gazelle
#

oh, interesting

spice hill
#

:3

granite wyvern
#

Probably solves the spaces-around-= styling wish.

hot glen
#

ill go sleep

rare gazelle
#

good night astral, i think i'll go as well, good night everybbody, thank you for the conversation

vale wasp
#

g'night!

#

.topic

verbal wedgeBOT
#
**What standard library module is really underrated?**

Suggest more topics here!

raven urchin
#

CSV module

vale wasp
#

argparse.

raven urchin
#

I saw a whole video about making code pythonic with an example that read and wrote csv files, and the mf didn't even mention the csv module

limber aurora
#

Hello guys

swift sparrow
raven urchin
raven urchin
vale wasp
limber aurora
raven urchin
limber aurora
raven urchin
granite wyvern
limber aurora
white knot
#

hey is the runtime stack same as the call stack

vale wasp
granite wyvern
# swift sparrow I've found myself using tempfile a bit recently

I have an atomic_filename(target_filename,....) context manager whose purpose is to podivde a NamedTemporaryFile to ... something , and to rename it to the target name if no exception occurs. It's great! The file's complete when it appears, and discarded cleanly if something goes wrong.

white knot
limber aurora
#

Hello I am still new learning python so far I have learned list and variable and strings I am still learning and I hope to apply some of my knowledge in pharmacy

swift sparrow
vale wasp
granite wyvern
swift sparrow
limber aurora
#

When I need help I will reach out

vale wasp
edgy krakenBOT
#

lib/python/cs/fileutils.py line 1597

def atomic_filename(```
swift sparrow
# granite wyvern Just grab it from my `cs.fileutils` package.

I have a pyside GUI where you can drag a pixmap widget into an explorer window and it will create an image file, but it has to generate the image as a tempfile first in order to be able to relocate it when the drag finishes. This is a really nice way to clean up that file if the drag doesn't successfully complete

granite wyvern
swift sparrow
swift sparrow
white knot
#

what is a calling sequence

granite wyvern
#

usually it means some things which have to happen in a particular oder, or what have happened in some order

granite wyvern
swift sparrow
#

also smart. I have an ffmpeg thing too but I just did the manual cleanup. A context wrapper sounds perfect

white knot
# granite wyvern more context needed
When designing calling sequences and the layout of activation record, the following
principles are helpful:

5. Value communicated between caller and callee generally placed at the caller
beginning of the callee’s activation record, so they as close as possible to
the caller’s activation record.
6. Fixed length items generally placed in the middle. Such items typically
include the control link, the access link, and the machine status field.
7. Items whose size may not be known early enough placed at the end of the
activation record.
8. We must locate the top of the stack pointer judiciously. A common approach
is to have it point to the end of fixed length fields in the activation is to have
it point to fix the end of fixed length fields in the activation record. Fixed
length data can then be accessed by fixed offsets, known to the intermediate
code generator, relative to the top of the stack pointer.```

am pretty confused
#

. Value communicated between caller and callee generally placed at the caller
beginning of the callee’s activation record, so they as close as possible to
the caller’s activation record.

granite wyvern
# vale wasp Maybe? But it's usually worth the effort to use argparse if only for the `--help...

I work through a wrapper which does this for me.

[~/hg/css(hg:default)]fleet2*> fstags help -l tag
Recursive help with the -r option.
Usage: fstags [common-options...] [-o ontology] [-P] subcommand [...]
  Work with fstags.
  Common options:
    --dry-run         Dry run, aka no action.
    -e ssh-exe        An ssh-like command to use for remote command execution.
                      The string is a shell-like command string parsable by shlex.split.
    -n                No action, aka dry run.
    -O ontology-path  Ontology path.
    -P                Physical. Resolve pathnames through symlinks.
    -q                Quiet.
    -v                Verbose.
  Subcommand:
    tag [common-options...] {-|path} {tag[=value]|-tag}...
      Tag a path with multiple tags.
      With the form "-tag", remove that tag from the direct tags.
      A path named "-" indicates that paths should be read from the
      standard input.
vale wasp
granite wyvern
vale wasp
#

Wow... I didn't think this would last long enough for me to finish typing.

granite wyvern
grave tree
#

!clban 1485549162614358116 scam thing

edgy krakenBOT
#

:incoming_envelope: :ok_hand: applied ban to @severe turtle permanently.

granite wyvern
white knot
chilly whale
granite wyvern
#

The precise details vary from language to language an the implementation. A lot of concepts translate.

shrewd pine
white knot
#

ah ok so they are just saying the general steps for the calling sequence. or the way in which activation record for callee is placed

granite wyvern
#

Are we talking jj?

white knot
#
1. The caller evaluates the actual parameters.
2. The caller stores a return address and the old value of top_sp into the callee’s
activation record. The caller then increments the top_sp to the respective
positions.
3. The callee-saves the register values and other status information.
4. The callee initializes its local data and begins execution.```
shrewd pine
granite wyvern
white knot
#

okkπŸ‘

chilly whale
#

that's sort of generalities. The specifics are going to be in the platform's ABI

granite wyvern
vale wasp
chilly whale
#

things like which registers get saved is specific to the ABI

shrewd pine
vale wasp
granite wyvern
shrewd pine
#

git is a good versioned file system only lacking a good vcs

crisp jay
chilly whale
pallid garden
#

i dont understand how github decides what to display as a code snippet and what to leave as a link

granite wyvern
chilly whale
#

I believe any URL for a range of lines with a branch/commit/tag gets turned into a code snippet unless it's too long

shrewd pine
#

probably also some heuristics to detect binary files

vale wasp
pallid garden
#

(ah yes, not python, sorry)

granite wyvern
pallid garden
chilly whale
#

no, definitely not

pallid garden
#

hmm

granite wyvern
#

Still feel like I'm missing context.

shrewd pine
#

i dont understand how github decides what to display as a code snippet and what to leave as a link
display where?

pallid garden
#

actually i shall move my non-python discussion to ot0

white knot
#

btw this stack is not related to the stack maintained by the cpu right?
i see that the storage organization and allocation is done by OS

#

static/heap/stack areas

chilly whale
#

this is the stack maintained by the CPU

#

the top_sp that you're reading about is the CPU's stack-pointer ("sp") register

#

the stack pointer to the (old) top of the stack

white knot
#

oh so the stack area in OS also has a stack which maps to this one maintained by the cpu? i mean when i execute my program it can't directly manage this CPU stack i thought

chilly whale
#

no, it can and does

#

the OS allocates some memory to use as the stack, and tells the CPU where the start of that stack is. The CPU's SP register points to the top of that stack. When a new function is called, the calling convention causes a new activation record (a new frame, we can say) to be pushed onto that stack, by writing into the memory that the stack pointer is pointing to, and then advancing the stack pointer to point to the (new) end of the stack

lament terrace
#

Don't you hate it when you coded stuff but yet you don't know what to do with them ...

#

dmenu and notify-send wrapper functions

#

Very nifty functions that idk what to do with that I made πŸ˜‚

white knot
#

suppose i have a compiled program where i define and call a function that am executing it. the process will be given memory.the machine code of the executing program will be having instructions to push or pop from the CPU stack

the stack area is maintained by OS just to make sure that all processes can access that CPU stack. by saving the state?

chilly whale
#

"all processes" - now you're getting into a different concept, virtual memory versus physical memory

#

each running process will have its stack in a different place, and when the OS switches a thread from running one process to another it tells the CPU where the current process's stack is. That's part of what a context switch is

solemn venture
chilly whale
white knot
#

yes i think i misunderstood it, when i heard about stack based systems. its clear now there is only one SP managed by the cpu and each process can have stack in memory

chilly whale
#

and at any given time, there's no guarantee that a process's stack is in memory at all. It might be paged out (or part of it might be), and so stored on disk instead of in RAM. Then you're getting into "page tables", and need to know about the "TLB"

white knot
#

yeah got it, thanks

viscid slate
#

Bro did anyone ever make a game or something else

swift sparrow
viscid slate
edgy krakenBOT
#
Go-to beginner resources

Here are the top free resources we recommend for people who are new to programming:

For a full, curated list of educational resources we recommend, please see our resources page!

swift sparrow
viscid slate
#

😩

viscid slate
#

I just want to make a game

swift sparrow
viscid slate
swift sparrow
narrow tiger
#

there are also some great pygame tutorials on youtube once you finish with the basics and cs50p πŸ™‚

viscid slate
swift sparrow
#

!learn

edgy krakenBOT
#
Go-to beginner resources

Here are the top free resources we recommend for people who are new to programming:

For a full, curated list of educational resources we recommend, please see our resources page!

swift sparrow
#

these ones

viscid slate
#

Oh vid lectures

viscid slate
shrewd pine
viscid slate
#

@swift sparrow

swift sparrow
viscid slate
swift sparrow
#

If you want to thank me, send me the first game you make πŸ™‚

velvet trout
viscid slate
swift sparrow
swift sparrow
#

Just be aware that making games is much harder than playing games

jade robin
#

LOL

swift sparrow
viscid slate
swift sparrow
#

Believe it or not, it will teach you how to write and run your code

viscid slate
#

Love u bro

chilly whale
# white knot yes i think i misunderstood it, when i heard about stack based systems. its clea...

also - I'm not sure if this will make it more or less confusing for you, but it might be a useful way to think about things: from the point of view of the CPU, "processes" don't exist. The CPU starts off running the kernel, and then sometimes the kernel jumps into code that it has loaded from somewhere else, and then that code jumps back into the kernel (either due to a timer interrupt or due to a software interrupt like a syscall) at which point the kernel might jump to different code somewhere else instead. Processes are an abstraction that doesn't really exist to the CPU

shrewd pine
#

or well, computational abstraction

chilly whale
#

yeah. The CPU more or less sees everything running on the computer as just one big continuous program that jumps around a lot, rather than as a bunch of separate processes

rapid rose
#

hi

#

does any1 know how i could make a macro that reads the screen?

kind bolt
#

Is there a certain keyboard size I should opt for if I plan on doing a little bit of programming

robust ledge
dry pike
#

make sure you have Home, End and Insert

kind bolt
dry pike
#

probably a tenkeyless is good. Comfortable size for most people, and you still have all keys that might be needed (numpad only useful for data entry which you don't really do much in programming)

deep zenith
#

Can open source be a career ?

kind bolt
fiery yarrow
chilly whale
white knot
pallid garden
#

find a keyboard that will motivate you to start typing

deep zenith
#

I recently changed my keyboard to a old one it feels new

chilly whale
#

the kernel will eventually jump back to that program to let it pick up where it left off, but in the meantime it might jump to some other program instead

fiery yarrow
chilly whale
#

it's mostly useful for games πŸ˜„

deep zenith
#

Ohh

deep zenith
#

When I heard that you can actually control and create threads in to the Computer System through C I was blown away

chilly whale
#

Python lets you create threads too

deep zenith
white knot
deep zenith
#

Can I create a plushy through these threads

granite wyvern
harsh anchor
#

just use jj

bronze dragon
full crane
#

Hi all

quartz fulcrum
#

hello

knotty escarp
#

heyy

torpid sparrow
#

if i containerize my python application, how do i keep it safe?

#

is containerizing it by itself already being safer?

inland karma
#

good morning

#

safe from what?

torpid sparrow
#

It's 1 AM here but sure good morning

#

Safe from vulnerabilities

#

things I import or do incorrectly in the code

inland karma
torpid sparrow
#

lol

inland karma
#

you can have your code scanned for them

torpid sparrow
#

if i containerize my code, with a latest docker hardened base image, I can use a scanner?

bronze dragon
torpid sparrow
#

right.. so containerization just makes it easy to run my code on different machines, it doesn't make anything safer

inland karma
inland karma
torpid sparrow
#

I'm sure I can scan before and after. I just felt like a "container" makes things safe like an egg carton protects the eggs

inland karma
torpid sparrow
#

jeez, I can't fathom dropping a house on eggs

#

ok moving them around and running the code from the containers is easier, "IT WORKS ON MY MACHINE" problem gets fixed

inland karma
#

so you can use dependabot on github, or any of the similar services for scanning code

torpid sparrow
#

im scared of third party scanners

#

sometimes they have viruses themselves

inland karma
#

what on earth are you talking about?

fiery yarrow
#

dependabot getting infected would scare the tail right off of shen methinks

torpid sparrow
#

like antiviruses

#

antivirus scanners are malicious sometimes if you get a bad one

inland karma
#

what?

#

please dont invent things

#

if you dont know something it is ok to say you dont know it

bronze dragon
#

code dependency scanners are conceptually pretty different from, like, Windows antiviruses

torpid sparrow
#

ok, i trust society and scanners

#

nevermind don't listen to me

undone grove
#

can i post my error

inland karma
#

yes you can

undone grove
#

Traceback (most recent call last):
File "/mnt/c/Users/11/python/14.py", line 19, in <module>
class SystemMonitor:
File "/mnt/c/Users/11/python/14.py", line 22, in SystemMonitor
self.cpu = 0
^^^^
NameError: name 'self' is not defined

torpid sparrow
#

That's an easy one

inland karma
undone grove
inland karma
#

share the code

torpid sparrow
#

No it's not a bad question just easy for people that know object oriented programming

fiery yarrow
torpid sparrow
#

Great question, self was definitely confusing the first time I used it, you need an instance

undone grove
#

import psutil
import threading
import time
import os
from datetime import datetime

Terminal colors

class Color:
RESET = "\033[0m"
CYAN = "\033[96m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
RED = "\033[91m"

def clear():
os.system("cls" if os.name == "nt" else "clear")

class SystemMonitor:
def init(self):
self.running = True
self.cpu = 0
self.ram = 0
self.disk = 0
self.net_sent = 0
self.net_recv = 0

edgy krakenBOT
#

Hey @undone grove!

Please edit your message to use a code block

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

This will result in the following:

print('Hello, world!')```
inland karma
#

your code is not indented

torpid sparrow
undone grove
#

that's all?

inland karma
#

you have to add indentation so they line up with the __init__ method

undone grove
#

okay you just fixed the whole thing for me thanks

inland karma
pallid garden
#

-# another reason why python is a great language for beginners: enforces good formatting practices

inland karma
#

you should use four spaces for every indent as well

fiery yarrow
undone grove
#

I don't even know how to change my tab setting (using notepad) so I always copy paste 4 spaces and use ctrl V

pallid garden
#

please dont use notepad for code

fiery yarrow
#

do you mean notepad or notepad++

undone grove
pallid garden
#

i would be lying if i say they are intuitive for beginners

undone grove
#

of course I will transition to that in the future

torpid sparrow
#

I use pycharm

#

pycharm is nice for python.

undone grove
#

at least notepad is just a white background that I can understand

inland karma
pallid garden
#

you should open a help thread if you are looking for help to guide you through the interface

inland karma
#

thonny is made for beginners

digital maple
#

VS Code my beloved

jade robin
#

i don't believe vscode ui won't be intuitive for a beginner, i think the menus scare people

fiery yarrow
#

does w11 notepad have syntax highlighting? i think it does?

pallid garden
#

i dont think so?

undone grove
inland karma
#

it even has markdown live rendered! πŸ˜„

fiery yarrow
#

i know there's something they significantly improved

jade robin
#

i switched out before i witnessed the glorius notepad updates lemon_pensive

sacred cypress
pallid garden
jade robin
#

that reminds me, i can recommend IDLE tho

inland karma
fiery yarrow
jade robin
#

IDLE is basically notepad but with basic python stuff

#

should be decent for learning

pallid garden
fiery yarrow
#

maybe i was thinking of tabbed window support? Β―_(ツ)_/Β―
-# also dark mode

torpid sparrow
#

if i tell ai, make my code safer, is that trustworthy?

#

I DONT UNDERSTAND THE SECURITY

inland karma
torpid sparrow
#

the ai is based on a network call that tells everyone on the internet my source code

#

so then it shows everyone my vulnerabilities

inland karma
#

i think you are missunderstanding something

#

what is your question and what is the problem you want to solve?

half pewter
#

Buongiorno

brisk gazelle
pallid garden
#

secure code is secure even when you show it to literally anybody

surreal knot
half pewter
#

if you vibecode without understanding the code it is not "trustworthy", AI is trained on normal security models just like everything else but implimentation is your job

patent python
royal verge
#

@young path i see you made new changes to the code , so error handling , thats awesome

blazing badge
#

any book recommendation for extremely hyper ultra super advanced python coders

inland karma
#

are you super advanced?

blazing badge
#

I think of myself as, yea

quartz fulcrum
#

take a test eivl

inland karma
#

what makes someone super advanced?

#

because if recommend something for an intermediate devloper, that would not fit i think

tame vapor
#

super().__advanced__()

inland karma
jade robin
inland karma
#

Fluent python is when you are on the brink of becoming intermediate

karmic sage
#

I have a question
idk if this is vague.
my question is how much similarity should be there between development and the production environment for application written in python ?

pallid garden
#

?

quartz fulcrum
#

i downloaded the epub version of python by mark lutz.
qnd it has more than 3500 pages if one is seeing on mobile

pallid garden
#

surely you want to make your dev environment as close as possible

fiery yarrow
#

prod ain't gonna need stuff like linters and testers and such.
most everything else is proably the same

karmic sage
tame vapor
#

thinkmon what does that mean

jade robin
#

hardware level abstraction? doesn't seem trivial, nor does it seem standard

inland karma
tame vapor
jade robin
#

idk micropython peeps probably have more knowledge of it

tame vapor
#

ngl i didnt understand a thing yall talked about

blazing badge
jade robin
inland karma
karmic sage
pallid garden
#

why did the LLM take so long to generate that sentence...?

tame vapor
tame vapor
pallid garden
#

i would think it's better to cache in a db, or some other caching service

karmic sage
blazing badge
#

I realized early on that standard polymorphism just encrypting the payload was a dead end against modern static analysis. So, I built the Metamorphic Core

pallid garden
#

you did say "the storage allocated is very little on ec2"

karmic sage
#

and logs are pain its on ec2 rn. need to move into db

jade robin
#

huh

blazing badge
karmic sage
pallid garden
blazing badge
inland karma
shrewd plinth
#

I program by flipping bits manually

jade robin
#

insert the xkcd

inland karma
shrewd plinth
#

With tweezers

pallid garden
#

.xkcd 378

verbal wedgeBOT
#

Real programmers set the universal constants at the start such that the universe evolves to contain the disk with the data they want.

tame vapor
jade robin
pallid garden
blazing badge
#

I engineered a program, its a self-evolving predator that rewrites its own AST logic and uses Reinforcement Learning to play EDR evasion like a game. By invoking raw syscalls through ctypes and pulling steganographic commands from the blockchain, it operates as a fragmented memory-only ghost that never touches the disk

tame vapor
blazing badge
#

Ai is not a real thing

void sphinx
#

hi

lone sand
#

Hello everyone