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
What are some amazing blogs related to Python?

I have followed Miguel Grinberg's blog ( https://blog.miguelgrinberg.com/ ) and Sentdex blog ( https://pythonprogramming.net/ ). I was looking for blogs that focus on a particular module entirely like Web development or Image Processing or GUI or anything related to Python.

/r/Python
https://redd.it/8aigrf
Recruiting statisticians/data analysts participants for a research study on career success

I am a graduate student conducting a research study about the skill and knowledge sets of statisticians/data analysts and their perceived career success. Participation involves filling out a questionnaire, which is expected to take approximately 10-15 minutes to complete. Participants must be 18 years old or older. If you are interested in participating, [click here]( https://usmep.co1.qualtrics.com/SE/?SID=SV_cw0L49DrDO04RsF&Q_JFE=0) to take the survey. If you have any questions or concerns, I can be reached at Harold.noble@eagles.usm.edu. Thank you very much for your consideration

/r/pystats
https://redd.it/8ahzj1
Testing of Celery Tasks in Django

Hoping for just some general information here. I have a Celery Task that performs a few functions and then updates a model with new information from the functions.

I want to be able to test

\> that the task completes successfully

\> that the model updates successfully

And I want to be able to debug any errors inside the task. I have read alot of loose instructions but am not entirely sure which way to start.

I have used

@override\_settings\(

DEBUG=True,

CELERY\_TASK\_ALWAYS\_EAGER=True,

CELERY\_TASK\_EAGER\_PROPOGATES=True,

\)

to set appropriate settings for the test I want to run.

The test completes without failure, however, I KNOW that the task should be throwing exceptions and it does not.

How best to go about getting the exception info I need from the task in the django testing environment?

/r/django
https://redd.it/8aljqr
How to tackle Heroku 30 secs request timeout limit

I have a Django application pushed on Heroku which sometimes takes more than 30 secs time to process the data, hence I get the request timeout error. Is there any way to increase the timeout value to say around 2-5 min Or should I look for other web hosting alternatives.

/r/django
https://redd.it/8aij8x
[N] PyTorch as of April is installable via `pip install torch`

http://pytorch.org/ updated on April 3rd to allow `pip install torch`

/r/MachineLearning
https://redd.it/8aj2bj
Downloading files from MongoDB to the user

My project has MongoDB storing a users "file structure". Since the structure is a dict of dicts, eventually bottoming out at a string representation of the individual files, I'm trying to find a way to get django to zip all files in the structure and download them to the user when the user clicks a button. I'm not entirely sure how to go about this if anyone can post any resources or have advice on doing something simliar?

/r/django
https://redd.it/8an3zx
Best way to test Django app running on docker

I'm adding tests to a large Django application in order to facilitate upgrades to python 3 and more recent versions of Django. The app relies on postgres, elasticsearch, and redis. Docker-compose works well with for this, allowing me to start a clean install of the app with versions matched exactly to what is in production.

I feel like integration tests are important because the search function, redis features, etc are intertwined. The problem I'm running into with the integration tests is using selenium. I tried running a headless version of chrome within docker (selenium/standalone-chrome-debug) but the tests are very slow, and sometimes hang. It really does not seem feasible to use selenium within docker. How are others dealing with this problem? From what I can tell I have these options:

1. Stop using selenium and move exclusively to something like Django TestCase

2. Refactor the tests so that I start the services and expose the ports with docker, but then run the main Django tests through a regular virtualenv. I'm not a big fan of this because I would have to change environment variables that point to the services just to run tests.

3. Somehow use my local version of chrome on my MacBook to run selenium tests, even though everything is running on docker. Not sure if this is possible?

Am I missing something? I would love to hear how others are solving this issue. I love docker so far but this hurdle is becoming frustrating.

/r/django
https://redd.it/8aneug
[AF] Authenticating internal APIs

I built a website using flask_login for handling 'logged in' permissions. This extension works great for protecting my views using `@login_required`, but it does nothing to protect my APIs (as far as I'm aware). How do I protect my internal API's? Do I integrate token-based JWT authentication?

EDIT: I had my decorators in the wrong order, sorry. `@login_required` wasn't working for me so I figured that it doesn't work with APIs for some reason. I actually discovered my problem: I placed my `l@login_required` decorator before my route handler, not after. Noob mistake.

/r/flask
https://redd.it/8akawc
What would you ask Guido if you had the chance ?

What if you had the chance to interview the creator of python himself ? What would you ask him?

/r/Python
https://redd.it/8amnrd
Serializing a dictionary that is not a model in Django restframework

I have read a few answers and posts about serializing an dictionary . But I still can't get it to work. Here is the problem. I do some data processing in django app , and it returns this dictionary (It has information about a quiz):

{101: {'subject': 'General-Intelligence', 'topics': ['Coding Decoding', 'Dice & Boxes', 'Statement & Conclusion', 'Venn Diagram', 'Mirror and Water Image', 'Paper Cutting and Folding', 'Clock/Time', 'Matrix', 'Direction', 'Blood Relation', 'Series Test', 'Ranking', 'Mathematical Operations', 'Alphabet Test', 'Odd one out', 'Analogy'], 'num_questions': 25, 'creator': 'Rajesh K Swami'}}

I want to serialize this dictionary. So what I have done is created a class for this dictionary. ie.

class PsudoTests:

def __init__(self,body):
self.body = body

Also a serializer:

class PsudoTestSerializer(serializers.Serializer):
body = serializers.DictField()

Now in api view :

class TestListView(generics.ListAPIView):
def get_serializer_class(self):
serializer = PsudoTestSerializer
def get_queryset(self):
me = Studs(self.request.user)
tests = me.toTake_Tests(1) # this method brings in the above dictionary that i want to serialize
p_test = PsudoTests(tests) #this creates an instance of class created above

return p_test

Now when i go to the url there is a key error:

"Got KeyError when attempting to get a value for field body on serializer PsudoTestSerializer.\nThe serializer field might be named incorrectly and not match any attribute or key on the dict instance.\nOriginal exception text was: 'body'."


/r/django
https://redd.it/8apaxg
Why use threads in Python?

I just learned about the GIL and from the looks of it, it appears even if we use threads in python, our program will take the same time if we just use a single thread due to GIL. If that's the case, using threads for performance isn't really the ideal use case in python, so why use it?

/r/Python
https://redd.it/8ao7lt
Is Django for freelancing worth it?

I am interested in learning webdev for freelancing. I've tried php, asp mvc and django. I heard from most people that php is the way to go but i prefer python and django.

So how is the freelance landscape for django and python?


/r/django
https://redd.it/8aqdxo
“The Cathedral and the Bazaar”: Mathematica vs. python, IPython and Jupyter, and their application to scientific papers
https://www.theatlantic.com/science/archive/2018/04/the-scientific-paper-is-obsolete/556676/

/r/Python
https://redd.it/8aqmzk