This is why python is the best scripting language. Simplicity is key

This is why python is the best scripting language. Simplicity is key.

Attached: Screenshot from 2018-09-28 18-05-50.png (1303x655, 84K)

Other urls found in this thread:

file.com/file.mp4')
github.com/Jow
paste.pound-python.org/show/zJQCyKiTQHUqUKci3yvl/
twitter.com/NSFWRedditVideo

What is __name__ = '__main__'

I'm learning

>if __name__ == '__main__':

urls = [
"",
]

for url in urls:
get_imgs(url)
This is why python is the worst language

python is pretty dope, i have to say
>operator overloading
>seamless JSON integration
>huge library of packages
>pretty good syntax
>lambdas
>powerful and expressive collection queries
what else can you ask for? Other than fucking static typing

Dear God Python is painful to read as a C++ enthusiast. I struggle to read without curly braces.

Yep, just fucking call main() by default if its define. Now that Guido Van Rossum left the Python org maybe a PEP for that could get approved.

this is basically saying that if this module is called directly from the interpreter, run all code underneath this as the "main" function. If you do not include that, it would execute the entire file.

BeautifulSoup is so fucking slow even with lxml as parser, author fucked up too much

scrapy.selector is at least 10 times faster and xpath is better anyway it uses lxml properly

Thank you.

I appreciate my university having us explore java and python at the same time so we dont have trouble reading these different syntaxes and typing schema

>Python
That's a funny way of spelling Lua

Attached: 1528631547870.png (573x892, 213K)

It's not so simple. There is a lot of packages that can be user either as a library or as a software.

The 'if' at line 12 is not needed

from random_pip_package import sub_par_solution as my_entire_program

use the fucking api you dunderhead, it gives you the file name and the extension. you disgust me, I hope the Jow Forums admins see this and ban you for not using the api.

So elegant and simple

It's the Platonic ideal of pythonic code

Proper multithreading instead of having to use processes, pickle not being shit, and type annotations being mandatory would be my top missing features.

there is absolutely nothing wrong with this

wtf Jow Forums doesn't have an API

Yes it does

ARRAYS START AT 0, NIGGER

>lambdas

Aren't lambadas in Python a fucking joke and didn't Guido tried to kill them but failed?

>if i import enough packages itll do all the heavy lifting for me
I've seen this before.

so much fucking whitespace everywhere jesus

>urlretrieve("http:"+img["href"], "imgs/"+img["href"].split("/")[-1])
I died a lot inside.

__python__ == __literally__ "__shit__"

So what you're telling me is that you could just remove the if statement and it would function exactly the same.

>start writing some small stuff in python, give library X a try, it doesn't work, let's have a look at library Y, it barely does anything. Fuck it.
>write that shit in Java. Take library A. It just werks, and does all you'll ever need.
Python ecosystem fucking sucks with a few exceptions.

> len(imgs)
Python always does this shit and it triggers me. imgs.length makes more sense and I cannot even fathom why anyone would do this.
It's like Guido wanted a purely procedural language and then tacked on OOP as an after thought.
Oh wait, that's exactly what happened.

imgs is not an object.

Currently learning python as a beginner. What's a good language to learn in tandem?

I was thinking C or maybe Java.

>that nesting
op is clinically retarded

You can change

if len(imgs) > 0:

to
if imgs:

Probably learning C just so you understand how languages like Python/Ruby/PHP are made, and you can one day make your own module/extension for it.

Some languages are written in C++, but most are written in C.

are the __double underscores__ really necessary for a language syntax

If that were true, then it would think get_imgs(1) is undefined, no?

Python is an abomination. Even with just straight up syntax conversion TypeScript is better.

Attached: ts.png (1211x719, 45K)

Sorry, let me download that third party framework. Give me few minutes to add it to my visual studio properties. Hmm wait, I can't find the dll, where do I put the dll in? Its missing the x64 bit dll. What the fuck?

vs

pip install random_pip_package

from random_pip_package import sub_par_solution

kek. Shit's horrible. Atleast python makes the dealing with third party frameworks lighyears easier. Too bad other programming language doesn't have that. If other does have it, let me know. I'd rather work with third party frameworks that I can use vs third party frameworks that I can't. Even if the indentations are bit forced.

Is that Lua-chan or Lua-kun?

Weak bait

Ditto

Yes, but the if statement ensure that main can only be run from inside the script and not via an import.

Nothing matters but corporate support.

Lua has a pip equivalent called LuaRocks

you should just use Ruby then

Simplicity is meaningless if performance is attrocious.
Python is good for nothing but dumb few-line scripts.
Real programming is for languages like C++.

Real niggers use FORTRAN.

Hey Python pals,
var = a_bit_more_expensive_fn() if test else fn()

Is a_bit_more_expensive_fn() ever computed first before the test? I've seen ternary bytecode so I'm relatively sure it doesn't, but I want to make sure.

As someone who used to use python for everything.


Golang is.

C is elegant, but ancient, so it takes an extreme amount of discipline to use it well. C will teach you a lot about how your computer actually works, and that's invaluable, but it's probably not a good practical choice anymore for most things.

Java is clunky, but modern, so you can get away with a lot of dumb shit. If you just want to make stuff it's not a bad choice, but beware because Java's domain of usefulness can be pretty limited. If you try to make anything remotely sophisticated you will run into endless stumbling blocks because of how retarded parts of its design are. For example, it's >>> operator is broken as fuck, and it's not a bug. The standard specifically requires that operator to break on half the primitives.

Braces make everything so much better.

Dude. Maven.

>java
>modern
Java has a sample of modern features bolted onto a clearly decaying language without any sort of integration.

I don't know but you can easily make sure the test is evaluated first with something like
var = None
if test:
var = more_expensive_fn()
else :
var = fn()

FORTAN's kind of useless for application programming though, isn't it? I know you're memeing, but I'm pretty sure its domain is primarily academic.

I'm late to the party but why the hell are you using urlretrieve AND requests? To download something with requests, just use .content, which is the bytes of the request

resp = requests.get('file.com/file.mp4')
with open('my_local_video.mp4', 'wb') as fname:
fname.write(resp.content)

What editor is this?

Compared to C it's modern, but it's definitely lacking in a lot of ways. I will never get over how terrible its generics are.

What is that video is 1TiB large, nigger-san?

bracket

semicolons

Visual Studio Code

JavaScript is the best programming language ever invented.

Attached: 1527923253569.jpg (540x489, 20K)

You're using Python. Performance doesn't matter.

You can add stream=True to the requests.get() so the data isn't downloaded until you're ready to access the bytes

ES6+ is comfy

A different way of doing the problem. Not saying this is better or worse than OP, but I always like it when someone refactors my code. Let's you think about a different way of going about it

Attached: 2018-09-28-212439_1680x1050_scrot.png (1680x1050, 153K)

JS have its charm as long as its stay at web browser. When that shit crawl its way to my server I want to go back time and kill 2 fucker whos design its.

You type like a schizophrenic

>try catch
NIGGER

REEE

Yes it is.

It looks like shit, but that's a matter of personal opinion.

The primary Python implementation is practically abandoned.

No offense man but this much nested indentation is a sign of shitty code. You can come up with better logic I just know it

Attached: 1.png (206x101, 1K)

>it's a syntax conversion of op's post
>complaining about brackets, but not white space

kys, pycuck

>requests
Use asyncio, you're blocking the process for every single request. Imagine processing 10k requests like this.

len(foo) is actually just an alias for foo.__len__()

So that is an object and it's actually behaving the way that user describes, at least behind the scenes. But I don't know why Python prefers to 'prefix' some methods and not others, probably compatibility reasons (although that didn't stop Python 3, lel).

Writing image downloaders is a pretty fun project. I'm writing a Pixiv one atm.

Attached: Screenshot_2018-09-29_00-46-04.png (778x900, 98K)

>cURL

It's very good for women because it does simple things in a simple way.

I'm using requests.

kek

I used to love python but as I've gotten more and more into programming I've come to hate it. Ugly syntax, snake_case_everything, one line lambdas only, no static typing, __double_underscores_out_the_ass__, annoying exception handling, shitty REPL, annoying $PATH issues, pip install no wait pip3 install okay now python script.py wait shit it's python3 script.py, FORCED INDENTATION OF CODE

At least list comprehensions and function decorators are fun

>using lamba functions in 2018
Come on bro. Kick that legacy shit to the curb where it belongs. Even Master Guido says lamba functions are cancer. List comprehensions are much more pythonic :)

def get_url_list(filename: str) -> List[str]:
with open(filename) as file:
urls = [line.replace('https', 'http').strip() for line in file if line.startswith('http')]
return urls

I like lambdas they make me feel 1337

DAE Church > Turing

fair enough lol

>lambdas are cancer
>typing hinting is not
Pythonistas.

As a side note I fucking love how Python reads like english. Other languages are mad for sure

Attached: liberal_arts_CS.png (631x708, 474K)

It DOES have an API; it just doesn't advertise that fact anywhere on the webpage itself:
github.com/Jow Forums/4chan-API
It's read-only though, so any solution you make that posts wll necessarily have to imitate a browser.

The repo even has the full source code of the native extension, so that you can build your own if you want.

well type hinting makes code easier to read and understand. lambdas do not.

Except that's hardly a benefit. What you should be doing is using the right model to express what you're doing, not retrofitting another model to poorly express what you're doing. I'm not saying other languages are better about this than Python is. I'm saying English is hardly the gold standard of what a programming language should be.

You are absolutely, without question, competely right

Anyways here's a python script another user came up with that lets you use Jow Forums from a terminal, captchas and all

paste.pound-python.org/show/zJQCyKiTQHUqUKci3yvl/

Nice cryptic identifiers you fucking asshole.

>easily readable code is hardly a benefit
It is if you're human.

cute and better code than OP's

>the right model
List comprehensions are literally the right model for filter+map in python. Lambdas as definitions or in place of filter/map are heavily discouraged in the professional world too which I found out the hard way through interviews.

This is mostly an issue with python's lambdas, you can still use them as kind of conditionals in other places, like other functions

>having to piece together a URL using operators and methods

L M A O

Js masterrace checking in

Attached: 1537238206458.jpg (512x564, 41K)

>Bare except
Guido knows all of your sins, user.