Python tutorial moment

264 points · 55 comments · view on lemmy.world

55 Comments

Buffalox@lemmy.world · 63 pts · 2y (27 replies)

How is this funny? 8 Upvotes at current writing???

bjoern_tantau@swg-empire.de · 102 pts · 2y (20 replies)

It's kind of funny because it looks like it is nonsense dreamt up by a non-programmer. But it actually works.

mac@infosec.pub · 102 pts · 2y (9 replies)

I thought it was poking fun at the tutorial saying instead of learning to code, import a library from someone who knows how to code.

lowleveldata@programming.dev · 27 pts · 2y (5 replies)

That's what libraries are for. I'm no security expert and the sensible thing to do is using a library instead of taking a class.

bort@sopuli.xyz · 11 pts · 2y (4 replies)

I’m no security expert and the sensible thing to do is using a library instead of taking a class.

Counterpoint: "not knowing your libraries" + "blind trust in the maintainer" will give you stuff like this: https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in

(the thread itself is worth a read. But also very impressive is the list of big players who fell for exactly this mentality)

unique_hemp@discuss.tchncs.de · 4 pts · 2y

Love the part where he claims that if your users are authenticated, it's not untrusted input. I mean, surely you trust all of your users to run any code on your server, right?

gears@sh.itjust.works · 2 pts · 2y (1 reply)

Jesus that was one hell of a thread

anguo@lemmy.ca · 3 pts · 2y

I dont want to see the words "low quality tooling" ever again.

Gabu@lemmy.ml · 1 pts · 2y

Impressive and unsurprising. As soon as you start getting complex libraries with multiple dependencies it becomes nearly impossible to review everything. At one time I had an interest in contributing to some AI libraries, but they're a mess as soon as you go looking for points of improvement.

bjoern_tantau@swg-empire.de · 17 pts · 2y

Works as well.

billwashere@lemmy.world · 6 pts · 2y

Which is funny because when I first started my CS degree in the late 80s (get off my lawn) we used to make fun of the beginning Java classes because it seems 90% of coding was to import the right library.

WolfLink@lemmy.ml · 1 pts · 2y

That is a large part of coding

mondoman712@lemmy.ml · 58 pts · 2y (7 replies)

It's basically import antigravity

ChaoticNeutralCzech@lemmy.one · 17 pts · 2y

Time travel is a prerequisite but don't worry, you can just

from __future__ import antigravity
mac@infosec.pub · 9 pts · 2y

"I also sampled everything in the medicine cabinet"

This made me smile.

grue@lemmy.world · 8 pts · 2y (3 replies)

It's literally this comic, five years and a research team later.

dandroid@sh.itjust.works · 4 pts · 2y

It's funny how solvable that problem is now. I remember seeing that comic, I think over a decade ago now, and thinking about how true it was. It really shows you have far we've come in CS.

tofubl@discuss.tchncs.de · 2 pts · 2y (1 reply)

More like all the research teams.

Bene7rddso@feddit.de · 1 pts · 2y

And 10 years

RobertoOberto@sh.itjust.works · 1 pts · 2y

From the hovertext: "I wrote 20 short programs in Python yesterday. It was wonderful. Perl, I'm leaving you."

After years of a dozen other languages, I finally tried Perl the other day.

Never again, if I can help it.

otter@lemmy.ca · 13 pts · 2y
from Lemmy import Upvote
from Fediverse import Posts
from ActivityPub import Submit

target_post = 'https://lemmy.ca/post/18691085'
num_votes = 8

post = Posts.open(target_post)

package = Upvote(post, num_votes)

package.Submit(target_post)

or something

billwashere@lemmy.world · 1 pts · 2y

Good because I was confused. I’ve written similar code

akhial@lemmy.world · 19 pts · 2y (2 replies)

It's funny because

from apps import facebook-killer as fb

fb.start()

// 3 million seed investment 

zaphod@sopuli.xyz · 6 pts · 2y (1 reply)

SyntaxError

pewpew@feddit.it · 1 pts · 2y

: Inconstistent indentation

CanadaPlus@lemmy.sdf.org · 13 pts · 2y (1 reply)

Because this example isn't really programming, it's just calling an existing library. Which is the big joke about Python.

Buffalox@lemmy.world · 1 pts · 2y

OK that way I get why it could be considered funny.

lupec@lemm.ee · 3 pts · 2y

My best guess is it's a play at the usual "all you do in python is import libraries without knowing how they work lololol" dig but yeah, I don't find it particularly funny either

anzo@programming.dev · 32 pts · 2y

This is exactly why we love Python (and other languages with rich package ecosystem, even when only on their niche usage cases). You can build upon other people's knowledge and effort to do cool things efficiently and effectively!

qx128@lemmy.world · 25 pts · 2y (8 replies)

Hahaha now code-golf it. One line FTW!

remove(Image.open(‘cl.jpeg’)).save(‘output.png’)

Tangent5280@lemmy.world · 26 pts · 2y (3 replies)

If I find this in production I'm whipping your ballsack till you change it back.

Jumuta@sh.itjust.works · 13 pts · 2y

import("rembg").remove(import("PIL").Image.open(‘cl.jpeg’)).save(‘output.png’)

_edge@discuss.tchncs.de · 9 pts · 2y

Can i hire you?

hackris@lemmy.ml · 3 pts · 2y

So I'm not going to change it

madcaesar@lemmy.world · 4 pts · 2y (3 replies)

Code golf! I just learned something new 😂

sexual_tomato@lemmy.dbzer0.com · 6 pts · 2y

https://codegolf.stackexchange.com/

Enjoy a new rabbit hole to dive down

meekah@lemmy.world · 2 pts · 2y (1 reply)

You never heard of code Golf before? It's usually programming challenges where the goal is to use the smallest number of source code characters possible.

Soulg@sh.itjust.works · 2 pts · 2y

I haven't either but I like it.

johannesvanderwhales@lemmy.world · 21 pts · 2y (2 replies)

Remove seems like a terrible name for that method.

SkyeStarfall@lemmy.blahaj.zone · 16 pts · 2y (1 reply)

While yes, the true issue here is that, for some reason, the code only imports the remove method from the package, instead of importing the package and doing rembg.remove().

trashgirlfriend@lemmy.world · 3 pts · 2y

if you only wanted to import remove you could maybe import as rembg_remove

unless there's some weird taboo against doing that I don't know about, I'm an awful programmer tbh

toddestan@lemm.ee · 20 pts · 2y (3 replies)

That reminds me back when some time ago, I was tired of dealing with sketchy, and often broken, websites and programs for downloading videos from Youtube. I figured these sorts of programs must be doing something along the lines of downloading the Youtube page, parsing through the massive pile of HTML and Javascript to find the stream, and then saving that to a video file. That seemed like something I could do myself with Python, so I set out to see if I could figure out how to do it.

A few minutes and a couple of web searches later, I discovered that someone else had figured that all out already and I just needed to do "pip install pytube".

MazonnaCara89@lemmy.ml · 18 pts · 2y (2 replies)

Have you ever heard about yt-dl?

aBundleOfFerrets@sh.itjust.works · 13 pts · 2y

yt-dlp

toddestan@lemm.ee · 9 pts · 2y

I did switch over to yt-dlp some time later as development seems to have slowed on Pytube and yt-dlp seems to be where all the activity is.

Thcdenton@lemmy.world · 18 pts · 2y (1 reply)

Goddamn i love python

aluminium@lemmy.world · 4 pts · 2y

*the libraries that are made for python

backhdlp@iusearchlinux.fyi · 17 pts · 2y

There's a python library for everything

j4k3@lemmy.world · 8 pts · 2y

No work in micropython on uno? pls help. Need thesis in Rust do tomorgh. Removed French bloat rm -fr catz tut. Why

shootwhatsmyname@lemm.ee · 5 pts · 2y

Waiting for the “in one line” tutorial

SanndyTheManndy@lemmy.world · 3 pts · 2y (1 reply)

Python is an illusion

essell@lemmy.world · 3 pts · 2y

All the best things in life are intangible.

HStone32@lemmy.world · 2 pts · 2y

Having a similar moment right now. I'm trying to figure out how to compute the transformation matrix for reflecting a bitmap of any given dimension across the y axis, but all the tutorials that come up in my search just tell me to import some python library. Its like nobody wants to learn how to do anything anymore.

AceFuzzLord@lemm.ee · 0 pts · 2y (1 reply)

I know this is a joke, but I totally wanna run the code and see what happens or what errors I get just for fun.

captain_aggravated@sh.itjust.works · 2 pts · 2y

According to PyPI, the library is genuine.