[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/pyg/ - Python General

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 242
Thread images: 33

Remember, be friendly ;)
>>
while autism=True:
print("kys")
>>
File: MathChecksOut.png (6KB, 446x187px) Image search: [Google]
MathChecksOut.png
6KB, 446x187px
>>
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.

>>57543214
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)
>>
File: 1454432733699.jpg (95KB, 570x432px) Image search: [Google]
1454432733699.jpg
95KB, 570x432px
>Slower than Java
>Syntax can reaching Perl levels of retarded magic

At least deployment is fast as my fucking.
>>
>>57543197
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.
>>
>>57543214
>Any good books/resources one could use to learn python?

Programming: Principles and Practice Using C++ (2nd Edition)
>>
>>57543195
>notepad++
>>
Reminder that Ruby is better than Python in every way.
>>
>>57543197
Python 3 is much better. I am glad that it's Python 3 at work.
>>
>>57544232
>reminder that soft shit is better than liquid shit in every way
>>
>>57543214
www.udacity.com have a great intro to Python course.

This course: https://www.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.
https://github.com/cztomczak/cefpython

Any suggestions?
>>
>>57544232
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?
>>
>>57544391
What exactly is wrong with these conventions?
>>
>>57542077
>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.
>>
>>57544591
Yet Javascript is faster than Python, has better syntax (since ES6) and semantics than Python, and is even faster to dev on.
>>
>>57544232

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..
>>
>>57544655
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
>>
>>57544591
also Cython
>>
>>57544815
It gets as ugly as C once you want speed
>>
>>57544518
They lead to shit code.
>>
>>57544939
How so, exactly?
>>
>>57544591
>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.)

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

>>57544800
Sorry, but Python syntax is shit.
>>
>>57544967
Human beings are notoriously bad at 'just following conventions.' That's why real languages have syntax for explicitly controlling things.
>>
>>57544981
Can you suggest a good replacement for scikit-learn and pandas?
>>
>>57544981
>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.
>>
>>57544981
>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 /g/.
>>
>>57544981
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.
>>
>>57545000
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.
>>
>>57544981
>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
>>
>>57545015
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.

>>57545033
>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.
>>
>>57545105
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.
>>
>>57545132
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
>>
>>57545101
>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.

>>57545105
>>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.
>>
>>57545132
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.
>>
>>57545178
/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.
>>
>>57545196
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
>>
>>57545196
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.
>>
>>57545178
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.

>>57545182
>muh elegance

No, it's simply people not wanting to learn how the machine actually works.
>>
>>57545244
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.
>>
>>57545232
>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.

>>57545239
Because tears are delicious.
>>
>>57545196
>>57545196
>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?
>>
>>57545293
>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
>>
>>57545267
>muh elegance!

It's not particularly elegant.

>>57545281
>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.
>>
>>57545293
>>57545314
>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
>>
>>57545322
Ah, right. So you're just a smug college student.
>>
>>57545293
>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?
>>
>>57545293
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.
>>
>>57545314
>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.
>>
>>57545328
>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.
>>
>>57545406
I generally feel this way as well, but this person is pretty blatantly (You)-fishing.
>>
>>57545363
>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.
>>
>>57545373
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.
>>
>>57545424
>>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

https://groups.google.com/forum/#!msg/comp.lang.python/LIXWQS2emaQ/IQvhEhPtd7kJ
>>
>>57545411

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.
>>
>>57543195
I like it
>>
>>57545493
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.
>>
>>57545426
Noticed you ignored the point.

>>57545488
>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.
>>
>>57545564
>but your manner of engagement is unnecessarily bellicose
This is not reddit.

>you haven't really offered up any substantial critiques.
Yes I have.
>>
>>57545596
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.
>>
>>57543286
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
>>
>>57545322
>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.
>>
>>57545790
wtf I love Python now?!?!
>>
>>57545322
>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/
>>
File: pasty.webm (775KB, 729x531px) Image search: [Google]
pasty.webm
775KB, 729x531px
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++
>>
File: fig.png (44KB, 400x300px) Image search: [Google]
fig.png
44KB, 400x300px
>>57545916
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
>>
>>57545979
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.
>>
>>57543197
How do you like no coroutines?
async def coro():
contents = await read_file('foo')
await write_file('bar', contents)
>>
>>57545424
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.
>>
>>57543195
what is the point of this
>>
>>57544169
Python3 for async
Pythob2.7 for libs
>>
>>57544169
libraries

>>57546558
don't forget non-shit utf-8 support
>>
>>57543286
I recommend codeeval, personally.
>>
>>57543286
>>57544293
>>57544178
thanks anons, here, have some dubs
>>
File: sinx.jpg (10KB, 377x152px) Image search: [Google]
sinx.jpg
10KB, 377x152px
>>57546547
>>
>>57546558
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?
>>
>>57548301
dude wth
>>57543214
>>
File: hereyougo.gif (88KB, 10000x10000px) Image search: [Google]
hereyougo.gif
88KB, 10000x10000px
>>57548301
Just make something, here is some stuff python can do
http://pastebin.com/LqBwd0ag
>>
>>57547088

oh shit
>>
>>57548944
>gif
Fuck you.
>>
Python > Everything else
>>
How's that async coming along?
>>
>>57546187
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
>>
>>57542077
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?
>>
>>57546187
What's a good resource for coroutines?
>>
>>57546558
>Pythob2.7 for libs
>>57547012
>libraries
Any examples of major libraries that haven't yet been ported?
>>
>>57542077
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
>>
>>57551241
depends on the projects, give examples of your ideas
>>
>>57551241
>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:
https://www.python.org/dev/peps/pep-0008/
http://docs.python-guide.org/en/latest/writing/gotchas/
http://docs.quantifiedcode.com/python-code-patterns/
>>
>>57542077
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
>>
>>57543171
no need for =True :^)
>>
>>57543171
>while autism=True
== You dunce
>>
>>57551506
>>57551446
>>
File: 2016-11-17-095620_648x184.png (23KB, 648x184px) Image search: [Google]
2016-11-17-095620_648x184.png
23KB, 648x184px
>>57543171
fgt
>>
>>57543171
autism = True
while autism:
print("kys")


FTFY
>>
Hello friends :)

MatLab here. How do I become /SciPy/?
>>
>>57551506
If you *must* test if a value is truthy, you can just do
while value: do_something()


Otherwise, if you want to test if a value is True, but nothing else, do
while value is True: do_something()
, never
value == True
>>
i am learning python, is doing this list a good idea, i know the basics well enought. or i will end up doing things badly, but working?

https://github.com/karan/Projects/blob/master/README.md
>>
how do I do this in python?

so you input a wordlist.txt (one word per line) then you input a word and it compares the word to the ones in the text file then if they match it prints the matching word FROM THE TEXT FILE

can anyone help?
>>
>>57553385
this chapter covers it, just learning it today
https://automatetheboringstuff.com/chapter8/
>>
>>57553447
thank you my man
>>
File: whatdoor.jpg (75KB, 433x580px) Image search: [Google]
whatdoor.jpg
75KB, 433x580px
>>57553289
Literally just google python for matlab users and there are tons of guides.

I recommend installing Anaconda since it already includes most of the libs you will need. That way you don't have to go messing around with pip every two seconds or worrying about getting things installed in Winblows

Best way to start is to rewrite something you already have in MatLab. Some things will seem clunkier since you lose a lot of the vector operator syntax. Another thing you lose is that plotting functions aren't built in. You'll have to pick a library. Matplotlib does it's best to emulate MatLab's functionality, but others like bokeh let you generate js plots for web use.

If you plan on working with a lot of tabular data, pandas has become the standard library for a lot of data scientists.

What you gain is that what you do is now open source and more reproduce-able. I also greatly prefer working with strings for things like filenames in python. Directory operations and cell arrays always felt clunky to me.

Certain things can be slow, but like with MatLab, you can always write C extensions.

>>57553385
https://docs.python.org/3/tutorial/inputoutput.html
> what is == ?
>>
>>57550955
That's an OS issue, not something Python can solve anyway.
>>
>>57544901
Elaborate?
>>
>>57545916
>aaron
Shalom
>>
>>57553297
>If you *must*
?
Is there much of a reason not to?
>>
>>57555051
No reason, I worded that poorly.
>>
>>57553297
Why do numpy arrays not obey this? It's so frustrating testing values that could be a numpy array or any other type
>>
>>57555106
Is your question: Why are numpy arrays always truthy? (I really have no clue what you're asking)
>>
>>57553269
>python3
disgusting
>>
>>57555125
>>python 3
>disgusting
kys, your shitty python 2.7 belongs in the 2010's.
>>
Why should I learn this over C#? Python doesn't seem like a language often required in jobs
>>
>>57555145
We are in the 2010's
>>
>>57555189
s/2010/2000/
>>
>>57555197
S/kys
>>
File: the_burrowers.png (28KB, 725x240px) Image search: [Google]
the_burrowers.png
28KB, 725x240px
>>57555121
This behaviour annoys me. Why should an array be any different from a list?
>>
>>57555709
Is it even possible to create a zero-length (empty) numpy array? Lists are truthy if they contain at least one element. So I guess that wouldn't equate well to numpy, unless empty arrays are a thing..
>>
File: IMG_20161117_130505.jpg (641KB, 2592x1944px) Image search: [Google]
IMG_20161117_130505.jpg
641KB, 2592x1944px
>>57543214
Visual quickstart guide by Toby Donaldson
>>
>>57544334
Selenium
>>
File: 1454994214401.jpg (398KB, 551x600px) Image search: [Google]
1454994214401.jpg
398KB, 551x600px
>>57543171
>=
>no indentation
>>
File: 1399820415107.jpg (11KB, 200x200px) Image search: [Google]
1399820415107.jpg
11KB, 200x200px
>>57542077
>friendly
>/g/

KEK
>>
>>57556442
hilarious
>>
File: the_burrowers1.png (10KB, 307x181px) Image search: [Google]
the_burrowers1.png
10KB, 307x181px
>>57555955
>Is it even possible to create a zero-length (empty) numpy array?
Yes, and they a falsy, that's what makes the whole thing more perplexing.
>>
File: 2016-11-17-225743_1600x900_scrot.png (218KB, 1600x900px) Image search: [Google]
2016-11-17-225743_1600x900_scrot.png
218KB, 1600x900px
learning python. What do you /g/uys think? Loving flask
>>
>>57554789
Is aaron a jewish name? Cuz I am jamaican.
>>
File: 1479401081655.png (68KB, 420x420px) Image search: [Google]
1479401081655.png
68KB, 420x420px
>>57556830
love flask, it's really straightforward when you're just throwing something together. I'm lazy, so I usually use SQLAlchemy too

I'm thinking about doing django soon though because I just picked up the Test-driven dev (goat) book that uses it.

I struggle because I want to work on my C++ skills, but python keeps seducing me away.
>>
>>57556919
It is, but since Jews and Christians share the Old Testament, Aarons might be Christians as well.
>>
>>57557023
Yey, gas the kikes
>>
>>57556442
Everyone is capable of friendliness, or at least civility.
>>
>>57543195
>python
> how to do this?
> dude install xyz library
> library does 99% of work
> feelgood.jgp
> im a hackerz 1337

Python is for 12 years old autist
>>
>>57558185
> how to do this?
> dude install xyz library
> library does 99% of work
Even though you meant this as an attack, it's actually a huge selling point.
>>
>>57558434
exactly what I was thinking
>>
>>57543171
Plz leave carley
>>
>>57558185
yeah dude same I'd much rather spend 14 hours writing my own custom utility that I get to debug and test all by myself
>>
>>57547320
>math with trayvon
>>
>>57543388
If the program is getting bottlenecked, it's the programmer, not the language.
>>
>>57556442

Yes, what's with all that "friendly xyz thread"s lately? Afraid of criticism? Back to R_E_D_D_I_T, thb.
>>
>Intern at medical research company who does data informatics
>Current scripts to clean/reformat data from mass spectrometer machine is written in Perl and nobody understands it because the employee who wrote it left
>Rewrite in Python with pandas
>Pandas is literally magic
>Be office hero

Feels good, /pyg/
>>
>>57559852
Wow, this guy hates friendship. Everybody laugh at the edge lord without any friends! Haha! *does an eskimo kiss with Pinkie Pie*
>>
>>57558185
There's a difference between taking on needless dependencies for one tiny part of your programming because you're too lazy to do it yourself and using well tested libraries with good communities.

I agree that there's a lot of shitty Python out there that does that, though.
>>
>>57559852
>Afraid of criticism?
No. On the contrary, civility stimulates higher quality posting, with better thought out critiques and eloquent responses, whereas rudeness tends to mask a lack of valid argument.
>>
>>57545244
>how the machine actually works

This shit is why no one in the engineering field, or any other field for that matter, takes CS fags seriously.
>>
File: 1478924691105.jpg (99KB, 653x590px) Image search: [Google]
1478924691105.jpg
99KB, 653x590px
>>57542077
> using Django
> using Vue.js
> duplicate templates for both server and client side
>>
>>57560037

Bullshit.

Honesty and harsh criticism is the reson you get only the plain cold truth on /. Even if it might hurt at first, it make you stronger in teh end.

If you want a "please don't hurt my precious feelings" culture, reddit might be more to your liking, good sir.
>>
>>57560415
>good sir
I think you might feel more comfortable on reddit, faggot.
>>
>>57560765
:^)
>>
Does anyone know sklearn?

I have a problem with the multilayer perceptron.

I have a big database of 150k rows. Training the model seems to work fine. But when I feed an equally large list of unclassified vectors into it, it gobbles up all RAM until it crashes

If I feed it at once, to a smaller network I have no problems, it still uses a shitton of ram but it's enough for the system to handle. But I want to have a deeper network.
So I tried splitting the unclassified set into several smaller parts.

It runs, I can reappend it and everything, but the output is bullshit. I expected it to be the same as with feeding it at once, but it isn't - it just returns the same class for all vectors. It feels like I'm missing a trivial point here, but I can't see it. The splitting and reappending all works correct, but the predict step seemingly doesn't
>>
>>57553459
Anaconda is fucking awesome.

I use conda environments exclusively at work, we dont mess around with anything else anymore.
>>
>>57560405
Why? Why would you do that? Just have the home page call a bundled script and do the routing client-side.
>>
>>57556830
What editor is that? It looks really comfy.
>>
>>57555149
Depends on the kind of work you want to do. You'd be surprised at how much Python can do and how often it's used.
>>
>>57542077
>be friendly
if I install python3 does it support python 2?
>>
>>57565004
You can install as many versions as you want side by side.
>>
File: 1469506439955.png (141KB, 372x388px) Image search: [Google]
1469506439955.png
141KB, 372x388px
>>57559827
http://benchmarksgame.alioth.debian.org/u64q/python.html

Hell something simple like Gregory's series to calculate the value of pi is a perfect example. Java calculating to a series of 1b takes less than 10 seconds unoptimized. Python once you hit 1m it begins to get exponentially slow, even with optimizations, generators, you name it. If you can write a Gregory's Series where Python matches or beats Java at 1b calculations I'll consider leaking source code on the back end of pypi.compgeom.org

Current deployment is broken due to the original devs having a pajeet fuck up the elastic search server with no back ups.
>>
File: 1455891954807.png (274KB, 478x528px) Image search: [Google]
1455891954807.png
274KB, 478x528px
s="1Uv naba! Ubj ner lbh?\nUhu? Fbeel V pbhyqa'g urne lbh. Jul ner lbh fb dhvrg?\n...bxnl, naljnlf jung'f lbhe anzr?\nV thrff jr pna or sevraqf.\nQb lbh yvxr navzr?\nTerng! Yrg'f trg yhapu. Nf sevraqf bs pbhefr :C.Htu... znlor jr fubhyqa'g or sevraqf.Cyrnfr shpx zr Punq!3"
r=lambda _:_.encode(''.join(s[i]for i in (16,127,114,0,263)))
i=lambda _:raw_input(r(_))
i(s[1:23])
i(s[23:77])
_=i(s[77:112])
if any(bool(ord(a)-b)for a,b in zip(_.lower()+'\x04',(99,104,97,100,len(_)))):
_='n' in i(s[112:158])
if _:print r(s[158:206])
else:print r(s[206:243])
else:print r(s[243:263])
print'~FIN~'
>>
>>57562670
It's vim
>>
>>57560415
>Honesty and harsh criticism
Are not in any way opposed to friendliness, that's a false dichotomy. Criticism wrapped in insults is actually dishonest because it makes an appeal to emotion before anything else. Unlike a computer, humans care how a message are presented. It's not about being nice for the sake of a hugbox — I think genuine, reasoned debate is far more likely to arise when posters restrain their more agressive tendencies.
>>
drunk = True
asleep = False
distracted = False
will_to_live = 100
will_to_die = 0
age = 20
while will_to_die < will_to_live:
if drunk or asleep or distracted:
will_to_live += 1
else:
will_to_die += 1
if random.randint(0,1) == 1:
drunk = True
else:
drunk = False
if random.randint(0,1) == 1:
asleep = True
else:
asleep = False
if random.randint(0,1) == 1:
distracted = True
else:
distracted = False
age += 1
if age >= 60:
death_of_natural_causes()
else:
suicide()
>>
>>57545424
>Kind of ironic comment considering the freedom you have with C/C++ and the limitations imposed by Python's syntax and paradigm.
Guess how I know you don't have a college degree or understand what a Turing Machine is.
>>
>>57566295
You don't need any == there, and you could rephrase using ternary operators.
>>
>>57546075
This is /g/, the let's-make-an-ambitious-encrypted-chat-program-and-use-C board.
>>
>>57566350
Yeah, I'm still a little slow at it.
I learned the bulk of what I know now a few days ago.
>>
>>57545493
>find a hug box

the irony!
>>
2.7 > 3 desu
>>
>>57566295
This program almost certainly doesn't terminate.
>>
>>57566295
drunk = True
asleep = False
distracted = False
will_to_live = 100
will_to_die = 0
age = 20
while will_to_die < will_to_live:
if drunk or asleep or distracted:
will_to_live += 1
else:
will_to_die += 1
drunk = random.choice([True, False])
asleep = random.choice([True, False])
distracted = random.choice([True, False])
age += 1
if age >= 60:
death_of_natural_causes()
else:
suicide()
>>
>>57566720
will_to_live = 101
age = 21
r = lambda:random.getrandbits(1)
while will_to_live:
will_to_live += 1 if r() or r() or r() else -1
age += 1
if age >= 60:
death_of_natural_causes()
else:
suicide()
>>
>>57566860
will_to_live = 101
age = 21
while will_to_live:
will_to_live += 1 if random.getrandbits(2) else -1
age += 1
death_of_natural_causes() if age >= 60 else suicide()
>>
File: 162.jpg (73KB, 600x338px) Image search: [Google]
162.jpg
73KB, 600x338px
>>57566720
>>57566860
>>57566894
Still isn't gonna terminate. Anon will just will himself into immortality.
>>
>>57566976

You ain't got enough entropy in there, man.
You need something that has bigger deflection, otherwise you just get a more or less asymptotic behaviour..


>>57566198

If you can't see through insults and can't tell emotions from solid reasoning you need to git gud with your meta skills.

Basically you're comitting a "fallacy fallacy" which means you reject a conclusion only because an argument for it is fallacious.


Oftentimes shitposting has produced some real good insights, if people get triggered they often bring up very valid points to save face.


Don't bother, you woudn't understand..
>>
File: CAP.png (15KB, 278x151px) Image search: [Google]
CAP.png
15KB, 278x151px
How to make Emojis white again

re.sub(u'[\U0001f3fc-\U0001f3ff]', "\U0001f3fb", input("Enter some emojis: "))
>>
>>57547088
MADMAN
>>
File: 1444450900525.png (304KB, 722x768px) Image search: [Google]
1444450900525.png
304KB, 722x768px
>>57567142
>You need something that has bigger deflection, otherwise you just get a more or less asymptotic behaviour..
>>
>>57556742
that's freaking annoying omg
>>
>>57567199

Oh well, statistics 101: mean value and standard deviation (let's ignore Kurtosis and Skewness for now)..

You have two problems:

1. Your standard deviation is too small, you need to spred the values so you can actually get over a threshhold so "will_to_live" can get higher/lower values. Then it will termintae SOMETIMES.

2. To really make it terminate every time you need to have a more "chaotic" behaviour. The "law of large numbers" says that eventually your result will eventually reach convergence towards some value (i.e. the mean value). So either the convergence of will_to_live is towards a positive mean value (you won't stop your while loop) or it will (almost certain) go to zero sooner or later. You will break out sometimes* from this behaviour if you have a bigger variance, but eventually it will mostly go down like you adjusted it to do.

So what you want are parameters that act independently from each other but are influenced by each other, so your "system" has a chance to "break out" later. You need more complexity/entropy. You're relying on one "ramdom number" function which sucks.
>>
>>57567500
I think you misunderstood me, I wasn't running the code.
If you analyze it you'll find it's incredibly unlikely to ever terminate.
>>
>>57567640

That's just what I tried to say..
Anon needs a better control mechanism.
>>
>>57558185
k3k
soooo

you write everything from scratch every time you write a program?
>>
>>57567669
I don't understand what you mean. You said
>You're relying on one "ramdom number" function which sucks.
But that is not the issue?
What do you mean by control mechanism?
>>
>>57567142
>If you can't see through insults and can't tell emotions from solid reasoning you need to git gud with your meta skills.
I can, easily, but I'm aware that most on this site aren't as dispassionate a me.
>Oftentimes shitposting has produced some real good insights, if people get triggered they often bring up very valid points to save face.
This may be true, but I don't think this occurs often enough. I've observed that the majority of such posts are met with further (unproductive) shitposts. Therefore I believe that a shift toward more civil discussion will, overall, bring about higher quality engagement.
>>
>>57551228
python2 fags btfo
>>
>>57544169
Python2 is better for code golf.
>>
Anyone got experience with Cython? Am I better of learning C and writing performance critical functions in it?
>>
>>57547088
cool
>>
>>57542077
how to deal with retarded distros like arch which link python to python3?
>>
File: logo.png (11KB, 280x280px) Image search: [Google]
logo.png
11KB, 280x280px
Why don't you take the redpill ?
>2016
>still being cucked by the serpentine Jew
>>
File: tinkin_0.png (59KB, 500x402px) Image search: [Google]
tinkin_0.png
59KB, 500x402px
>>57542077
Python is slow, yet it is the industry standard for any data intensive application out there.
C* and Java are only useful because mobile processors are shit.
>>
File: 1452759449892.png (18KB, 581x97px) Image search: [Google]
1452759449892.png
18KB, 581x97px
>>57562458
I wrote a machine learning genotyping pipeline for mutations (bioinformatics here)

I'm a little confused on what you wrote but here's my take on it

When you train a model you can save it as a pickle object (look up model persistence)

Also you can specific the cache memory in many models when you train

When I predict classes on test data it takes only a few seconds. Maybe 30minutes for 100k+ data sets
>>
>>57567685
I'm a cobol programmer so I actually do that.

It's annoying to create everything from scratch.

But on the other hand, sometimes it's better to do something without using a library just to learn something new. Instead of creating systems full of black boxes.
>>
>>57573040

It's used because it provides a wrapper around the native fortran and C libraries m8. Python is slow when it's not directly calling C code.
>>
>>57572799
You should not use python 2.
>>
I really thought I had an understanding of Python's scoping rules, now I'm completely stumped.
def outer():
var1 = "HI /PYG/"
var2 = inner()
print(var1, var2)

def inner():
var2 = var1.lower()
return var2

if __name__ == "__main__":
outer()

Result is:
>NameError: global name 'var1' is not defined

Any idea why this doesn't work? I thought it would search the outer scopes for var1?
>>
>>57574617
Because var1 is defined inside the method outer().
Declare it outside the method.
>>
>>57574617
>>57575261
I realise I was wrong to think the calling function's scope would be searched. It goes straight from local to module. I think what confused me was that it worked when everything in outer() was just in the module, i.e. it stopped working when I wrapped it a function. I assumed the previous behaviour would continue, i.e. it would treat outer() function as if it were the enclosing namespace.

Come to think of it, why doesn't it work like that?
>>
>>57572799
That's why you should always explicitly call python2 or python3, even better with env.

>>57573416
Operating systems shouldn't break standards. Since lots of python3 stuff is incompatible to python3 and vice versa, python3 is called explicitly and everything that referrs to python is python x-2.7, so basically, when someone writes #!/usr/bin/env python, the OS should use python2.

Basically the whole shit is fucking retarded. They should give python3 a completly new name...
>>
>>57545655
>Having a language specific feature helping you to write safe code is as retarded as C fags claim Python is.
>this is what mommy coder camp graduates actually believe

Both the average IQ and the average education level of the generation of software engineers who added these features was higher than the IQ/education of millennial programmers today. But keep thinking you're right and they were wrong.

Also: don't ever review NASA's standards for code on spacecraft. Their restrictions to insure safe code would make your head explode.
>>
>>57545790
>How much time do you need ? Like couple days or so ? A week maybe ?

Command line? A day.

GUI? You didn't specify a cross platform framework. Pick one. Admittedly this might stretch it to 2 days.
>>
>>57545790
Why would a web scraper need OpenCV?
>>
>>57572824

> being cucked by the MicroJew
> Not using the glorious germanic C++

pleb-tier
>>
>>57545655
>If you want to build good software...just do it without explicitly specify it.
oh god, i can't stop screaming
>>
>>57542077
can python generate syntax to be run?
>>
I'm doing my final Python assignment right now. We need to make a calendar with 9 days per week and between 27 to 37 days. Inputs ask for the starting day and how many days are in the month of the user wants to display. I'm not asking for anyone to do it for me, just where to start. The instructor has cancelled half his classes this semester so i feel like this is something we haven't even had a lecture on.
>>
>>57577738
yes
>>
>>57578250
example?
>>
>>57577738
what do you mean?
>>
File: 1479524025.png (209KB, 1075x971px) Image search: [Google]
1479524025.png
209KB, 1075x971px
just learned about static web sites generators
https://www.smashingmagazine.com/2015/11/modern-static-website-generators-next-big-thing/


any recommendations, with best themes?
https://www.staticgen.com/
>>
Is it possible to get the cmd prompt python opens upon running a .py file to not immediately close upon encountering an unhandled error? Shit makes troubleshooting a pain.
>>
>>57578384
like lisp macros
>>
>>57578659
i don't think it can
>>
>>57546187
>coroutines
What kind of corouines are they? If they aren't Lua-esque stackful asymmetric coroutines then they are garbage.
>>
>>57578520
work in IDLE
>>
>>57578975
Most languages have not embraced total metaprogramming. Most language semantics (like python) are too unclean for multi-stage metaprogramming to work. There is MetaOcaml and MetaHaskell if you want something other than LISP. There is also the dead metaLua distribution and the Lua/LLVM-based Terralang.
>>
Never really cared much for pythons syntax but willing to give it a second shot.

Is there some library that will let me easily make micros for windows in python?
>>
File: 1443056647004.png (111KB, 277x276px) Image search: [Google]
1443056647004.png
111KB, 277x276px
>>57579232
>>
File: 1461996413887.webm (1MB, 1280x720px) Image search: [Google]
1461996413887.webm
1MB, 1280x720px
gimme some ideas of easy but helpful scripts to make
I already did a 4chan file downloader and a bulk rename script
>>
>>57578520
pin powershell on taskbar
>cd to that directory (tab to autocomplete)
>ls to show files
>py yourscript.py
>>
>>57580316
>I already did a 4chan file downloader
Can I have a link?
>>
File: 1437945424198.gif (357KB, 369x244px) Image search: [Google]
1437945424198.gif
357KB, 369x244px
Why does eveyone posting in this thread ask a question and just walk away, without responding to other questions or even when they get an answer?
>>
>>57580066
chek'd
>>
>>57578520
use --pdb option to enter the debugger.
>>
>>57582798
Probably two reasons:
1. /pyg/ is new and so it's population is largely ephemeral; it takes a little time for an established community to coalesce.
2. Many posters have relatively simple problems requiring little discussion and are not really able to answers for others. Although this will lessen as a general develops around a core of more experienced users, the nature of Python makes it an inevitable feature of /pyg/.
>>
>>57579232
You mean macros? Can you give an example of something you want to make?
>>
>>57558185
>too lazy to look up if there's a library for it
>keep writing it myself
>hours upon hours wasted
I am not very clever
>>
>>57579183

I really hate to be pedantic here, but look into Ruby. It's Python+Perl+Lisp+Smalltalk in one language.

I really don't get why people use Python when there is Ruby. I mean I use both, because there are a lot of Python Jobs out there, but I don't really get the reason. Maybe most guys learn Python at University and just keep on using it later on?
>>
>>57585825
Scientific computing
>>
Python 4 when
>>
>>57587949
Python 3.0 was released in 2008 and they've only just released Python 3.6, so probably in 2022 or thereabouts.
>>
So I am trying to learn some programming, and having done just a little bit of C, I am now trying out Python.

At the moment, I am trying to make a basic Caesar decipherer, which chooses the most likely key based on the occurrences of each letter in a ciphered document, which has been ciphered by my own code.

So, what I have done so far is this:
def countCharacters(astring):
"Returns a dictionary where each key represents a character in the english alphabet and the value representing its occurance within the string-argument"
charcountsUpper = {}
charcountsLower = {}
for char in astring:
if char.isalpha():
if char.islower():
if char in charcountsLower:
charcountsLower[char] = charcountsLower[char] +1
else:
charcountsLower[char] = 1
else:
if char in charcountsUpper:
charcountsUpper[char] = charcountsUpper[char] + 1
else:
charcountsUpper[char] = 1

upperSorted = sorted(charcountsUpper.items(), key=operator.itemgetter(1))
lowerSorted = sorted(charcountsLower.items(), key=operator.itemgetter(1))
upperSorted.reverse()
lowerSorted.reverse()


I now have two, sorted lists of tuples - one with lowercase letters and their value, and one with uppercase letters and their values.
What I want to do is merge the values of these two into just one list of tuples, but for the life of me I can't figure out how. I would appreciate any help!
>>
>>57589301
def countCharacters(astring):
charcounts = {}
for char in astring:
if char.isalpha():
charcounts[char] = charcounts.get(char, 0) + 1
return sorted(charcounts.items(), key=operator.itemgetter(1), reverse=True)
>>
>>57589542
Thanks, that was very clean! However, that doesn't quite seem to resolve the issue I am having, as that will just return a list of tuples, where there is differentiated between 'a' and 'A'. What I wanted to do was to sort of "merge" those, so, for instance, if we had two capital letter A's in a string, and 8 lowercase a's, the function should return [('a', 10)]
>>
>>57587544

OK, fair enough. There's quite a big ecosystem with SciPy and NumPy.


>>57589273

from collections import defaultdict

a = defaultdict(lambda: 0, {})
txt = "This is a text with upper AND lower case.."
for i in txt.lower():
a[i] += 1

a = sorted([(v,k) for k, v in a.items()], reverse=True)
print(a)


Returns:
[(8, ' '), (4, 't'), (4, 'e'), (3, 's'), (3, 'i'), (3, 'a'), (2, 'w'), (2, 'r'), (2, 'p'), (2, 'h'), (2, '.'), (1, 'x'), (1, 'u'), (1, 'o'), (1, 'n'), (1, 'l'), (1, 'd'), (1, 'c')]
>>
>>57589737
def countCharacters(astring):
charcounts = {}
for char in astring.lower():
if char.isalpha():
charcounts[char] = charcounts.get(char, 0) + 1
return sorted(charcounts.items(), key=operator.itemgetter(1), reverse=True)
>>
>>57589874
So simple. Thanks a lot anon! I didn't know of the .lower method. I'm still very new to programming,

Cheers!
Thread posts: 242
Thread images: 33


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.