/pyg/ - Python general

/pyg/ Python general

Let's have one of these.

Help and discussions about the Python language, libraries, etc.

>Language tutorial
docs.python.org/3/tutorial/

>Web development frameworks
flask.pocoo.org/
djangoproject.com/

>SQL
sqlalchemy.org/

>Plotting
matplotlib.org/

>Machine Learning / Scientific calculations
numpy.org/
pandas.pydata.org/
tensorflow.org/
scikit-learn.org/

>Astronomy
astropy.org/

>Python Package Index (PyPi)
pypi.python.org/pypi

>Pycon 2016 talks
youtube.com/channel/UCwTD5zJbsQGJN75MwbykYNw

>EuroPython 2016 talks
youtube.com/playlist?list=PL8uoeex94UhE3FDvjacSlHFffoNEoPzzm

What are you working on, Sup Forums?

Other urls found in this thread:

docs.python.org/3/tutorial/index.html
diveintopython3.net/
twitter.com/SFWRedditVideos

Can someone explain what yield does?

It's like return

It returns a generator rather than a list.

...

yield turns a function into a generator. What this means is that now, whenever you iterate over the generator, it will return a value, which is 'yielded' from the generator.

This gives some nice properties, like you do not need to return all values at once (saves memory) or allows to abstract data retrieval (e.g. you write a generator which returns rows from SQL Table).

e.g. a generator which returns odd numbers:

def yield_odd():
current_number = 1

while True:
current_number += 2
yield current_number


# this will go on forever
for i in yield_odd():
print(i)

Is it a good idea to write android apps with kivy?

I never tried it, but if you can, try writing it as a web app, rather than native. Easier portability and maintenance.

Thanks, seems useful. I'll try it out.

currently going from python -> clojure for hobby programming, but still using python for work.

flask json api / deep learning / NLP / scripting general

Overall 9/10 language, only thing that needs fixing is the concurrency model. Maybe python 3 fixed that but I haven't tried it so idk.

Don't believe his lies. Generating rows from SQL databases makes no performance increase.

Is there an NLP framework like spaCy that doesn't require so much training data? I'm unfamiliar with how NLP works but the spaCy similarity() function to analyze the sentiment of two strings works really well and handles, I assume, tokenization etc. behind the scenes which other frameworks don't seem to do. I don't mind losing accuracy at the expense of freeing up disk space.

1) Fetching data in batches of e.g. 1000 rows per batch is better than fetching everything in one go
2) Abstracting the code to connect to db, query it and retrieve the results, makes the code easier to read

Can i hack NSA with this?

That has nothing to do with generators. The SQL connector will push as many rows into the socket as fast as he can. You pulling them out one by one with a generator or iterator or enumerator makes no difference.

It would only make a difference if you were accessing the database itself, not through a connector.

A better example of generators is statistics, mathematical sequences (taylor, fibonacci) and shit.

It will push as many as were generated by the SQL Statement. What I'm talking about is using LIMIT / OFFSET / TOP (whatever you're on) to retrieve a subset of rows and then in each subsequent iteration, change the offset in the SQL query to retrieve next batch.

favorite out of the ordinary use for it?

I'm using Python to compare laser scanning data. It's not going to be fun once I have to process very dense point clouds...

I should probably learn C

What's your view on list comprehensions?

>mfw a gentooman tells me to learn an embedded systems language instead

Seems easy enough to me.

nth for flask

I want to start learning python, what book should i buy?

If you want to all out, the mouse book is pretty comprehensive.

Thanks, i'll look at some reviews and probaly buy it

Don't need to buy anything. You can start with the official documentation, which is pretty good

docs.python.org/3/tutorial/index.html

or

diveintopython3.net/

I'll check it out. Thank you