/pyg/ - Python General

Remember, be friendly ;)

Other urls found in this thread:

udacity.com/course/intro-to-computer-science--cs101
github.com/cztomczak/cefpython
groups.google.com/forum/#!msg/comp.lang.python/LIXWQS2emaQ/IQvhEhPtd7kJ
pastebin.com/LqBwd0ag
python.org/dev/peps/pep-0008/
docs.python-guide.org/en/latest/writing/gotchas/
docs.quantifiedcode.com/python-code-patterns/
twitter.com/SFWRedditImages

while autism=True:
print("kys")

...

3rd for python 3 is obsolete. long live ~2.7

if you advocate python 3 please end your life.

I'm new to programming, as in I've never done it before. I want to learn as a hobby. Any good books/resources one could use to learn python?

what's a good site with programming challenged? from beginner to expert. hackerrank is fucking shit, iirc topcoder had some but i cant find.

i reccomend thinkpython(basic intro to programming), automate boring stuff with python(bare python basics and then a referrence of cool applications with python), introduction to computation and programming(goes more in depth with computer science)

>Slower than Java
>Syntax can reaching Perl levels of retarded magic

At least deployment is fast as my fucking.

I believe that 3.x is better than 2.7.
Do you have any valid arguments to support otherwise? If you can do so without greentexting or using "muh" then all the better.

>Any good books/resources one could use to learn python?

Programming: Principles and Practice Using C++ (2nd Edition)

>notepad++

Reminder that Ruby is better than Python in every way.

Python 3 is much better. I am glad that it's Python 3 at work.

>reminder that soft shit is better than liquid shit in every way

www.udacity.com have a great intro to Python course.

This course: udacity.com/course/intro-to-computer-science--cs101

I want a phantomjs alternative in Python and I found cefpython but I can't find minimal examples.
github.com/cztomczak/cefpython

Any suggestions?

Okay, if that's your conviction so then you may prefer to post in /ruby/.

>constants and private variables dont exist because "we're all consenting adults" and "I might want to change it later, just follow the underscore conventions"

Is there a more pozzed language?

What exactly is wrong with these conventions?

>muh speed
if you want speed go with c/c++

python is about not fucking with 20 pointers and defining a function just to print an "array of characters" on the screen

same goes for the low level shit, python has no place in there.

I work as a programmer in a local lab, ppl can't fucking wait for me to finish my code just to show few graphs of something that they will throw away in couple weeks.

They want fast results, and if the program runs in 30 seconds instead of 3, I will take 3 sips out of my coffee instead of 1 and no one will care.

Yet Javascript is faster than Python, has better syntax (since ES6) and semantics than Python, and is even faster to dev on.

I like Ruby, but Python is better for some scientific fields because of the libraries. But the difference is not really that big..

Also Django and Rails are not that different and get closer with every version, so it all boils down to personal taste. It's the same for Ansible/SaltStack vs. Puppet/Chef, you can accomplish anything with Python as well as Ruby.

So let's bury the hatchet..

speed is not of any concern when talking python, if you haven't understand that.

better syntax is something that one prefers but others don't, ie. your right is not my right. I like javascript for web stuff, and the syntax is okish, yet when it comes to choose between two, I would choose python, it syntax favors me more.

this is not an issue, mostly coz its fully automated

also Cython

It gets as ugly as C once you want speed

They lead to shit code.

How so, exactly?

>python is about not fucking with 20 pointers and defining a function just to print an "array of characters" on the screen

Translation:
Python script kiddies can't be bothered to learn real languages so they vehemently defend a piece of shit and force the meme on everyone else. (I kind of like that pointers confuse the shit out of most "programmers." Keeps them away from the important stuff.)

As much as I dislike JavaScript, this poster is correct.

Sorry, but Python syntax is shit.

Human beings are notoriously bad at 'just following conventions.' That's why real languages have syntax for explicitly controlling things.

Can you suggest a good replacement for scikit-learn and pandas?

>imperative brogramming
>ever
holy shit, you are no better than a "script kiddie"

pointers are nice and all, strings in c are not exactly friendly.

>and force the meme on everyone else.
Nobody forces 'the meme' though. Very rarely do I see aggression or overzealous promotion by Python users on Sup Forums.

I spend 4 years at uni learning C/C++ with my cs meme degree, after that I got a job that I kept for 2 years with C++ , meanwhile I fucked around with Python and Django and other web/python shit.

Now I have way better paid, yet junior job with Python. And I do know C++ better than Python when it comes to lang specific shit.

Also as much as I like Python, if the program needs a lot of abstraction and classes, I really really prefer C++ over Python, I can do it Python too, but C++ provides so much more when it comes to OOP.

Also pointers, at times I miss them. And sometimes I don't. A lot of times they can be avoided, yet some autistbro put them there "to speed things up" costing the company 2 weeks salary to debug the shitty code he wrote.

Perhaps the freedom provided by Python encourages more sensible behaviour from those humans. It seems to have worked well for the past two decades; I don't know of many houses exploding because somebody modified an underscored variable.

>so new to programming that you don't understand that languages are tools and some are better at certain tasks than others
Nobody will stop you if you want to write data science stuff in C on your own, but imagine actually working and insisting on this
>take 5x longer to write something that will be run 1-3 times just to make it 2-10x as fast
>nobody can debug your code because it had tons of pointer manipulation
>nobody else wants to use your code because it takes a big application to do something that takes 10 lines in Python

Almost all professional programmers know how to use pointers and what they are. If your fellow college freshmen don't know and you think that makes you superior, don't worry, they'll know them within a year. Just because they are easy to make mistakes with doesn't make using them better, even if done correctly

A library does not make a good language. If you have to work in Python for access to some piece of software with no equivalent in another language, that sucks for you but it doesn't mean Python is any good as a language.

>muh imperative programming is bad meme

Like I said, script kiddies are too afraid to swim in the deep end of the pool. They don't want to know anything about how the machine actually works, then wonder why their interpreted declarative code takes hours to complete.

>pointers are nice and all, strings in c are not exactly friendly.

This is something so many people don't seem to get. Running Python is slow. Writing Python is fast. CPU time is a lot cheaper than developer time. For many applications, the trade-off is well worth it.

imperative programming is for brainlets, and imperative support for higher order functions and lambda expressions are terrible.
Face it, functional programming is more elegant in very way.


>durr my code is compiled and therfore better
end yourself

>I don't know of many houses exploding because somebody modified an underscored variable.

That's because nobody is using Python in any situation where it might cause something to explode.

>>so new to programming that you don't understand that languages are tools and some are better at certain tasks than others

Oh I understand that. I just can't find the thing that Python is good at.

>>take 5x longer to write something that will be run 1-3 times just to make it 2-10x as fast

It doesn't take 5x longer. The claimed productivity gains are imaginary.

>>nobody can debug your code because it had tons of pointer manipulation

Implying the world wouldn't be a better place if everyone who can't into pointers found another career.

>Almost all professional programmers know how to use pointers and what they are.

Make up your mind.

An ecosytem is a very important part of a language. I may well adore the grammar and syntax of SeSotho, but it's of little use to me if nobody in my country speaks it.

/thread
Python is not about running speed.
And if you dont understand this, but you understand pointers, you are autist to the max.

Also employed ppl use Python, unemployed C.

I know how pointers work, for example, but it will take me a long time to debug a large application using them because there are many potential points of failure. It's just not worth it to waste developers' time doing that

ugh. why does everyone on this website have to have a smug sense of superiority? There are great uses for python and great uses for compiled languages. You're so much better than us. Now go away, please.

My problem with this Python meme is that other languages are just as productive if not more so, yet don't have the problems. C#, VB.NET, Swift...hell even JavaScript is better.

>muh elegance

No, it's simply people not wanting to learn how the machine actually works.

You think everyone is just a hobbyist with no formal education? everyone with a cs degree is required to learn computer architecture and some form of assembly. Jeez. fuck man. Some people can know how the machine works and reject the archaic architecture b building something more E L E G A N T on top of it. Fuck you faglord

int addToArray(const char * toadd, char * strarray[], int strcount)
{
const int toaddlen = strlen(toadd);

// Add new string to end.
// Remember to add one for the \0 terminator.
strarray[strcount] = malloc(sizeof(char) * (toaddlen + 1));
strncpy(strarray[strcount], toadd, toaddlen + 1);

// Search for a duplicate.
// Note that we are cutting the new array short by one.
for(int i = 0; i < strcount; ++i)
{
if (strncmp(strarray[i], toaddlen + 1) == 0)
{
// Found duplicate.
// Remove it and compact.
// Note use of new array size here.
free(strarray[i]);
for(int k = i + 1; k < strcount + 1; ++k)
strarray[i] = strarray[k];

strarray[strcount] = null;
return strcount;
}
}

// No duplicate found.
return (strcount + 1);
}

Guess how many lines of codes would it be in Python.
Also guess which will be more readable without even context or any comments.
And which one will be easier to debug, again on the fly.

And don't tell me a C programmer can read faster than Python, if you follow PEP8, you should be able to tell what this does, AND HOW it does it by line 1 or so.

>Python is not about running speed.

Meme response to the fact that Python is excruciatingly slow and the language syntax/paradigm defies common sense attempts at optimization.

And there's no excuse for this. Most languages are not C fast. But they're not complete shit either. It's like whoever is working on Python under the hood has no fucking clue how to write an interpreter or JIT.

Because tears are delicious.

>That's because nobody is using Python in any situation where it might cause something to explode.
Please don't feign ignorance as to my point, it simply comes off as avoidant. I don't think you have any real justification for your assertion that Python's lack of private variables causes "shit code".

Could you answer some questions please?
1. Do you have any experience as a paid developer?
2. Why are you posting in a Python general if you dislike Python?

>someone is wrong about something that is the theme of the thread he is posting in
>people who enjoy that theme patiently try to correct him and explain why
>claims he is extracting tears
Why don't you try reimplementing a hash map while we get actual work done

>muh elegance!

It's not particularly elegant.

>muh complexity!

This is a function so every piece of code that needs to do this needs: one line.

What you fail to realize is that under the hood Python has something just as complex, but you can't see it or understand it or optimize it.

>tears are delicious
please stop responding to this underage b& who learned how to write fizzbuzz in C and thinks he's a 1337 hax0r

Ah, right. So you're just a smug college student.

>Meme response
What does this even mean?
>the language syntax/paradigm defies common sense attempts at optimization
How so? Do you have any specific criticisms?

Acually Cython is 400 times faster than Python, and can be integrated very easy and fast ontop of existing python code.

At this point, you will notice a program that, written in C will have 0.04 runtime and written in Cython 0.09.

Not to mention, the best optimizations comes with better algorithms, not language prone built ins.

Also, better CPU costs a fraction of my salary. But yeah, you can't understand that since C programmers are so much more, and their salaries are like 1/10 of an actual data scientist. Or even better, if you are an actual C wizard you cannot be employed and you are stuck on your thinkpad x60 and performance is crucial to you.

>Please don't feign ignorance as to my point, it simply comes off as avoidant. I don't think you have any real justification for your assertion that Python's lack of private variables causes "shit code".

Are you the same guy who bitched about debugging pointers? Because debugging code where one line somewhere fucked a variable it was never supposed to touch is essentially the same problem as debugging pointers. But pointers have performance benefits while Python's complete lack of encapsulation and data hiding has no benefits.

>1. Do you have any experience as a paid developer?
Decades.

>2. Why are you posting in a Python general if you dislike Python?
Your tears.

>please stop responding to this underage b&
I firmly believe that responding in an upfront way is a more effective way of dealing with (or, if you're lucky, educating) such people than outright ignoring them or being rude and combative. Obviously this assumes they aren't blatantly shitposting or (You)-fishing.

I generally feel this way as well, but this person is pretty blatantly (You)-fishing.

>Acually Cython is 400 times faster than Python, and can be integrated very easy and fast ontop of existing python code.

That would go a long way towards fixing a major issue with Python. Not all of them, but one big one.

>Not to mention, the best optimizations comes with better algorithms, not language prone built ins.

Kind of ironic comment considering the freedom you have with C/C++ and the limitations imposed by Python's syntax and paradigm.

>Also, better CPU costs a fraction of my salary.

This meme is why so much is shit today. If programmers in 2016 cared as much about performance as programmers from 1996 or, hell, 1986 then pretty much every thing would be instantaneous.

>Or even better, if you are an actual C wizard you cannot be employed and you are stuck on your thinkpad x60 and performance is crucial to you.

Sure thing buddy.

But, fellow faggotman, I have 6 years of professional and paid experience with C/C++ and I choose Python, my dick is around 8 inches and I have wife and kids.

I don't have time for dick waving, neither at the university or in anime forums like this. So extracting tears out of me is waste of your time.

>>Not to mention, the best optimizations comes with better algorithms, not language prone built ins.

>Kind of ironic comment considering the freedom you have with C/C++ and the limitations imposed by Python's syntax and paradigm.

think twice

> Why python does not have data encapsulation

groups.google.com/forum/#!msg/comp.lang.python/LIXWQS2emaQ/IQvhEhPtd7kJ

You people are worse than SJWs.

I made a comment that led to a conversation and you don't like the conversation so it's "who are you? what do you earn? why are you here? get out! (You)-fishing!"

Find a hug box. If you're interested in critiques of Python, respond. If not, don't. But don't cry about it.

I like it

I get that you're trying to open up a conversation, but your manner of engagement is unnecessarily bellicose and, more importantly, you haven't really offered up any substantial critiques.

Noticed you ignored the point.

>wall of philosophy text

There were programmers. They noticed that when any line of code could do anything to any part of RAM things tended to crash. So they built walls.

Now walls are no longer cool because we're agile n sheeeit and we don't want to think about architecture, we just want to pound the keyboard.

>but your manner of engagement is unnecessarily bellicose
This is not reddit.

>you haven't really offered up any substantial critiques.
Yes I have.

Having a language specific feature helping you to write safe code is as retarded as C fags claim Python is.

If you want to build good software where public and private and protected and so on features are there, just do it without explicitly specify it.

It is possible, it won't come right on top of your head, since its not tough in school, but its doable and better than the classic OOP C++ force on the user.

codingame is one of the best ones out there, has great challenges and you can go head to head with other programmers. Also hosts contests with a bunch of great prizes

>What you fail to realize is that under the hood Python has something just as complex, but you can't see it or understand it or optimize it.
But since it's used by everyone and Python isn't exactly a one-man programming project, you can be damn sure that whatever Python is doing under the hood has been more thoroughly checked for bugs and optimized than something some random code monkey shits out in C.

Alright C/C++ faggots, write a web scraping bot from scratch that searches a page, first by text, then by URL and then by images found on the page ( you can use OpenCV since its there for python too ( yep a C++ wrapped with python)).

Also, do it so it can be used on any machine, android, gnu/linux, ios, etc.

How much time do you need ? Like couple days or so ? A week maybe ?

You know what ? I use C++ on a daily basis, mainly for OpenCV shit and CV shit in general (I work for a government owned security stuff) and this one time we needed to develop the said thing, with GUI, fool and idiot proof for the other, non tech literate employees, while the others fucked around and wrote all kinds of shit I did it in a day using Python, it was as fast as real time searching, it could be faster or more light weight in pure C/C++ but at this point, where it works on any device without major mods, and its so fast to be developed and put in use, it is considered the better option.

wtf I love Python now?!?!

>muh muh shitposting
it is elegant. Pattern matching is a Godsend. no excessive if-statements.

You have done nothing other than say "no it isn't" and for that, this will be my last reply/

C and python are both great, just for different things. If i wanna make a program like pic related, I am most definitely going to use python, But if I want to create a 3d game engine, Ill use c/c++

yep
its stupid to write this with C if you value efficiency and rationality.

I mean, all this time you will spend to speed up what ? At this point all it matters is the speed of the internet connection you have, yet you need couple of days building and then a week debugging this shit, while in python it can happen in a day from scratch.

I dont want to metion python and 3d graphics in one sentence, even tho (pic related) is coded in python

Exactly, someone argued that it would be smarter to do it in C. I forgot their dumb reason but I was pretty dumbfounded that someone could really try and argue about that.

How do you like no coroutines?
async def coro():
contents = await read_file('foo')
await write_file('bar', contents)

If programmers in 2016 cared as much about performance as programmers from 1996, nothing would have gotten done, and our CPUs would still be maxing at half a GHz.

>python is good for sci & math

Just fucking use Julia.

what is the point of this

Python3 for async
Pythob2.7 for libs

libraries

don't forget non-shit utf-8 support

I recommend codeeval, personally.

thanks anons, here, have some dubs

...

I don't know of any useful libraries that haven't been ported to Python 3, not counting that legacy pile of crap that your project is using that's been deprecated half a decade ago and still uses camel case and getter and setter methods.

I'm probably stupid or somethings though, but I'm learning the language of python, but I don't know how to program. Can anyone here just throw me in a direction?

dude wth

Just make something, here is some stuff python can do
pastebin.com/LqBwd0ag

oh shit

>gif
Fuck you.

Python > Everything else

How's that async coming along?

to be fair, true hard disk async io is not a reality cross-platform. even python libraries like aiofiles (which is great, dont get me wrong) use a threadpool executor

So I've made a facebook chat client in python, I've added affine cipher to messages so it's encrypted. As of right now you have to input your email and password everytime you launch the script which is fine but I want to improve it, I'm thinking of making it so you set your credentials as vaules inside the script but I'm thinking of making it so the creds are encrypted with ROT then affine and you just enter your decryption keys at launch, obviously you shouldn't share your encrypted credentials but this would add a bit of security - what do you lads think?

What's a good resource for coroutines?

>Pythob2.7 for libs
>libraries
Any examples of major libraries that haven't yet been ported?

ok, yesterday, there was a thread about python, i got dissed on so i will ask here again.

I do web development, exactly front-end. My dail work consists of sass, js and html.

But i have some small home ideas and side project thoughts. I have never learnt any programing language per se, at school, we had that uglyass Pascal lessons, that's all.

So my question: is python legit to start with ? What is the best learning platform/source you have encountered ?

Want to learn something as a hobby.
Thanks

depends on the projects, give examples of your ideas

>But i have some small home ideas and side project thoughts.
>I have never learnt any programing language per se
>Want to learn something as a hobby.
Python is ideal for all of these. I have a similiar background to you: the only 'language' I had experience with was R, and I wanted something for hobbyist projects.
Python is simple, quick to learn amd easy to read, and it should be powerful enough for your needs.

As for resources, I just digested the official documentation and browsed Stack Overflow, but I'm sure someone will give advice for a more structured programme for learning. However, once you've got the basics down, you have to make use of these:
python.org/dev/peps/pep-0008/
docs.python-guide.org/en/latest/writing/gotchas/
docs.quantifiedcode.com/python-code-patterns/

daily reminder that programing languages are just tools, so there is no reason to argue over whether c or python is the better

>t. employed c programmer

no need for =True :^)