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
Applied Machine Learning in Python - Machine Learning is today a buzzword and you do not really know what it is until you do it. The University of Michigan has put together a great program that takes you from the basics of Python to the latest Machine Learning techniques.
http://www.courserapro.com/learn/python-machine-learning

/r/Python
https://redd.it/87mkt7
Looking for in-person training classes in the DC, MD, VA area

I just started working on some projects at work that will require me to learn python. I’ve got a bit of programming background but nothing formal or in-depth. Boss man told me to try to find a 3-5 day boot camp type class for Python that I can attend locally.

I’ve done some quick google searches but didn’t find anything happening in DC area other than purely online stuff. I’d prefer a class in April/May, if possible. Not having to travel would be best, but I could do short distance travel to the class if necessary.

Anyone have a good source to look for training classes? Python.org had some classes listed but still mainly online, or in Europe.

Thanks for the help!

/r/Python
https://redd.it/87n2xy
Is there a fast way to look up classes and methods?

One of thing things I find very frustrating about learning and using python is trying to find classes and their methods. Does anyone know of a better way to find classes and methods in the python standard library besides the search engine at [docs.python.org](https://docs.python.org/3)?

I'm looking for something like Ruby's [ruby-doc](https://ruby-doc.org/core-2.5.0/) where you can type and it instantly filters the list of classes or methods. [http://docs.gl](http://docs.gl/) is also similar to this.

/r/Python
https://redd.it/87oyj8
Where to begin with Python?

Hi everyone! I'm a CS student and so far all I have learned is C++ in most of my courses. During this upcoming summer I'd like to sit down and learn as much Python as I can, or that's my goal anyway. Do any of you recommend any Book, YouTube channel, Course, Website, or any good resource that you'd think is great for someone that knows some programming yet haven't touched Python. I know I can "Google" a lot of theses things, but maybe someone in here has a good tip, insight, advice, for me.

/r/Python
https://redd.it/87po0z
My attempt at histogram_equalization (Digital Image Processing)

Does this seem correct? Is there anything I can do to improve speeds?

def histogram_equalization(image):

try:
assert len(image.shape) == 2
except ValueError as e: #what exception
image = imread(image)
assert len(image.shape) == 2
source, indicies, counts =np.unique(image, return_inverse= True, return_counts = True)
s_cdf = np.cumsum(counts).astype(np.float64)
s_cdf /= s_cdf[-1]
new_values = np.around(s_cdf * source).astype('uint8')
new_image = new_values[indicies].reshape(image.shape)

return new_image




/r/Python
https://redd.it/87o21t
Building RESTful APIs and using Websockets (3 hour video course)

Hey everyone,

I don't post here too often but I'm the author behind the [Build a SAAS App with Flask course](https://buildasaasappwithflask.com/).

I just wanted to let you know that I recently added a big free update to that course which covers building a RESTful API and even hooking up websockets too. If you're wondering what tech stack is used, it includes Flask, Docker, Postgres, Flask-Classful, Flask-JWT-Extended, Marshmallow and Pusher.

**It's a free update for anyone who bought the main course at https://buildasaasappwithflask.com/**.

If your scroll down to about the middle of the page there's a 5 minute demo video showing what we'll build. Think of this as a companion to the main course.

Thanks so much for the support over the years, and this is only 1 of a few large free updates that I will be adding to the course over time.

If you have any questions, please don't hesitate to ask.

/r/flask
https://redd.it/87sacz
Jupyter keeps breaking.

I am brand new to python and I am trying to use the jupyter notebook as I work through an Edx course on Python. The notebooks work, maybe four or five times before they no longer work. I've tried refreshing the book, but I'll be half-way through coding assignment and consistently, the notebooks will just stop working.

Any thoughts on why? It would be a tremendous time saver if I could do the coursework without having to start a new notebook every five minutes.

Thanks!

/r/IPython
https://redd.it/87t1h4
Django best practices questions

So i have been building apps since 2012, and now im starting on a larger project with Python, and django + DRF.

I have used various langauges, but never done anything serious with python before. So im uncertain of some choises and hope i dont make the wrong ones in the start of the project.

Would love to get some advice from you guys!

1) Should i have a models ”app” and keep all models there, or should each app have their own models?

2) When working with DRF is it best to use ApiView, function views or more generic class based views. Note i probably will have to have custom logic in what data is returned, this app will be a crm like app, with lots of real time stuff.

3) How much should i separate my code into apps? Is there a good rule of thumb to remember when i should create a new app?

4) I found this https://github.com/gothinkster/django-realworld-example-app is it s good example how things should be setup?



Thank you for reading!

/r/django
https://redd.it/87p2m6
Flask-Security with Flask-Admin, how to use two different login forms?

I am building a flask boilerplate site and I am using flask admin so I can create users (its an "internal" site with no registrations).

So I have a login form where the admin can login and create user, but I also want to have a regular login where users can log into the site.

They're pretty much the same login just a different form and look? Is that possible or should I have them route to the same form and then have non admin redirect to the home page and the admin can redirect to the admin backend?

Right now I am using a context processor to hook into flask-admin:

# define a context processor for merging flask-admin's template context into the
# flask-security views.
@security.context_processor
def security_context_processor():
return dict(
admin_base_template=admin.base_template,
admin_view=admin.index_view,
h=admin_helpers,
get_url=url_for
)

So that the url_for('security.login') will direct you to /mysite/admin/login?
Is there a way to break it so that, url_for('security.admin.login') directs to /mysite/admin/login
and url_for('security.login') directs to /mysite/login?

Something along those lines.

/r/flask
https://redd.it/87v277
Using Flask with GraphQL

Hey guys,

I'm trying to create a small application using GraphQL and Flask. I'm currently running into issues getting it all working together. I might be doing something very silly as I'm quite new to GraphQL but I keep getting the following error:

{
"errors": [
{
"message": "mutate() got an unexpected keyword argument 'name'",
"locations": [
{
"line": 2,
"column": 3
}
]
}
],
"data": {
"createUser": null
}
}

The code that I have in my schema.py is:

import graphene
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyConnectionField, SQLAlchemyObjectType
from models import User as UserModel
from sqlalchemy import and_
from app import db

class Users(SQLAlchemyObjectType):
class Meta:
model = UserModel
interfaces = (relay.Node, )


# Used to Create New User
class createUser(graphene.Mutation):
class Arguments:
name = graphene.String()
age = graphene.Int()

user = graphene.Field(Users)

@classmethod
def mutate(cls, _, args, context, info):
user = UserModel(name=args.get('name'), age=args.get('age'))
db.session.add(user)
db.session.commit()
ok = True
return createUser(user=user)

class Query(graphene.ObjectType):
node = relay.Node.Field()
user = SQLAlchemyConnectionField(Users)

class MyMutations(graphene.ObjectType):
create_user = createUser.Field()


schema = graphene.Schema(query=Query, mutation=MyMutations, types=[Users])

I was trying to follow: https://github.com/Getmrahul/Flask-Graphene-SQLAlchemy but I was trying to use flask-sqlalchemy also. Any help would be greatly appreciated as I'm rather stumped. Thank you!

/r/flask
https://redd.it/87t9m5
Trouble understanding syntax with filtering Django models

I see this:
file_obj = Results.objects.using('tool').filter(id=fooid)
I know it is filtering a collection of Results by fooid. I'm not sure yet what 'tool' is referring to. What does the using keyword do here?

/r/djangolearning
https://redd.it/87uvg2
Static files dont work on pythonanywhere, even though i set them up correctly and use collectstatic

Hello... so, its been so annoying please help..

I created new django site on pythonanywhere.com but admin site loads without style.

I put these settings in settings.py file:

STATIC_URL = '/static/'

STATIC_ROOT ='static'

I used python manage.py collectstatic command and it created new admin folder (with css, js etc.) int my static folder.

BUT ADMIN SITE IS STILL WITHOUT STYLES. WHAT IS THIS

please help

p.s. im using virutalenv created with virtualwrapper

p.s.s. its working if i put /static/ folder into Static Files on pythonanywhere.com web panel. But tutorials said thats its a bad way to do this. HELP

/r/djangolearning
https://redd.it/87zfl4