Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Programming Fundamentals for Data Science [xpost from datascience]

I am entering my final semester in a Data Science Master's program and just completed a three month data science internship at a large corporation. While the experience was very fulfilling, it also highlighted my lack of programming (and math!) background or experience.


I have a Bachelor's in business before I joined the program and only did simple SQL work - self taught - in my last job. I've obviously done schoolwork in Python and R, but it became apparent when the training wheels came off and I was faced with a blank screen that there was much I didn't know.


What concepts, methods, best practices are fundamental to learn to become proficient in Python/R, or better yet, give me the ability to pick up any language I may need in the future.

Thanks!

/r/Python
https://redd.it/6xn3wy
Is there an extension like Flask-Admin, but for the user to use?

So If I have a web application with users, and they have a lot of data in databases is there an extension out there to make displaying all this data to them easier than building out tables in html and passing the data through?



/r/flask
https://redd.it/6x2txp
Hunter 2.0 - can now trace other processes

Just made a release (https://pypi.python.org/pypi/hunter#changelog) with a process tracing feature. It works in two ways:

* GDB injection. Like all the other projects, it's prone to the same kinds of problems, deadlocks, segfaults and whatnot. But for development I guess it's ok ...
* Bootstrapping via [manhole](https://pypi.python.org/pypi/manhole). A convenience `hunter.remote.install()` is provided.

Give it a try, eg `pip install -U 'hunter[remote]'` and `hunter-trace -p PID --gdb`.

Also, it has filters, eg: `hunter-trace -p PID stdlib=False`.

Windows ain't supported. If you have ideas for Windows support let me know.

PS. Yes, I don't know how to reddit.

/r/Python
https://redd.it/6xpcxx
[AF] Beginner Question: "object is not callable" from inside a route

Having this problem that I can't figure out what is wrong with it.

[Link to pastebin of code](https://pastebin.com/xykEQ3qG)

I must be not understanding some fundamental aspect of all of python to not being able to understand it.

edit:
here is the error code: *TypeError: 'Test' object is not callable*

/r/flask
https://redd.it/6wr1i9
syntax error when following the official tutorial!

I've gotten [this](https://docs.djangoproject.com/en/1.11/intro/tutorial02/#playing-with-the-api) far into the official tutorail for Django, but I keep getting an error when getting to the filter function.

Here's the command I tried to run, and its consequent output:

>>> Question.objects.filter(id=1)
File "<console>", line 1
Question.objects.filter(id=1)
^
SyntaxError: invalid syntax


What have I done wrong? I've been sure to import the models and that doens't return any errors.

Here's my models.py: https://gist.github.com/wOstensen/d55c63135df9da9c99a61e80a7a7aeee

EDIT: Running on Windows 10 with Python 3.6.0 in Cygwin.

/r/djangolearning
https://redd.it/6xlw4j
Best Practices: OOP in Python.

I sure this question is nothing new but I want to hear your answers anyways. I am actually new to object-oriented programming (even though I know the theoretical concepts; OOP has a lot of resemblance in pure math, particularly in set theory).

What are some best practices in creating OOP systems in Python? And what are some bad practices to avoid?

Throughout my programming experience, I spent most of my time organizing my programs into functions/definitions, not necessarily relying much on classes. But I think OOP, as a paradigm, is pretty good for implementing mathematical structures.

/r/Python
https://redd.it/6xs6od
How to count choices in aggregation?

suppose we have a model of a document:

class Document(TitleDescriptionModel, TimeStampedModel):
...
source = models.ForeignKey(Source, related_name='docs', blank=True, null=True)

class Meta:
ordering = ('year', 'month', 'title' )

and its source:

class Source(models.Model):
PHOTO = 'photo'
NEWSPAPER = 'newspaper'
MAGAZINE = 'magazine'
BOOK = 'book'
OTHER = 'other'
...
kind = models.CharField(max_length=32, choices=TYPE_CHOICES, default=PHOTO)

class Meta:
ordering = ('title', 'id', )

how to get how many photos, newspapers and magazines are in db?

the only solution i know is to use standard Counter:

qs = Document.objects.values_list('source__kind', flat=True)
counter = Counter(qs)

Counter({'other': 123,
'newspaper': 234,
'magazine': 345,
'book': 456,
'photo': 567,
None: 111})

i tried to do the same with `aggregate` but in vain. how could it be done?

/r/django
https://redd.it/6xrodm
nbconvert 5.3.0 Release — adds tag-based element filtering
https://groups.google.com/forum/#!topic/jupyter/W2M_nLbboj4

/r/IPython
https://redd.it/6xtak5
Do not reload all Flask apps

Hi There,

I'm using flask blueprints just as written here:
http://flask.pocoo.org/docs/0.12/patterns/appdispatch/

Specifically, I'm running the following piece of code:

from werkzeug.wsgi import DispatcherMiddleware
from frontend_app import application as frontend
from backend_app import application as backend

application = DispatcherMiddleware(frontend, {
'/backend': backend
})

Flask has an awesome feature of reloading application as it detects change in code. However, in my case it is not desirable for both apps: backend app is too heavy to be reloaded every few minutes. When I reload fronend, backend gets reloaded as well and it takes too long. Is there any way to reload only app that was changed?

I realize it might be difficult, because as far as I understand at this point

application = DispatcherMiddleware(frontend, {
'/backend': backend
})

applications are merged into a single one and they are not separate anymore.

Anyway, maybe there is a different way to achieve what I want?

Thanks.



/r/flask
https://redd.it/6xsh81
I made a Pinterest clone for practice

Hey guys,

I made this week this [Pinterest](https://pinclone-django.herokuapp.com/) clone to practice my skill with Django, you can tell me everything wrong with it and I wll try to improve it, also I'll try to create a new app this week, maybe a hacker news clone to keep practicing

[github repo](https://github.com/iKenshu/pinclone)

/r/django
https://redd.it/6xu9em
[AF] How to separate individual form from others in for loop and then do ajax post?

I'm having trouble with submitting a certain form if they are all identical(for loop). Only the first one is submitted. I want to be able to enter the credentials into a form 2-10 and have that one submit instead of the first. Here is the code: https://gist.github.com/anonymous/f5a34a14c79d5de59d28b37c85daacdf

screenshots: http://imgur.com/a/Ndequ

In the first image, the program works fine because the two fields are filled out for the first form.

In the second image it doesn't work because the second field of the first form is not filled out.

The third image shows that only the first form is being submitted.



/r/flask
https://redd.it/6xvhr1
Seeking Django Tutor

Hi, I'm seeking a Django tutor, where might I be able to find one?

/r/django
https://redd.it/6xvenm