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
[AF] Local install to hosting?

Hi /r/Flask , I have a decently sized app that is installed locally on my machine, what is the easiest way to publish it to the web?

Should I just put it on github and clone it from their to my web server?

Just seeing if there is anything I am missing.

Thank you.

/r/flask
https://redd.it/8nmuam
Is there any way to make Django send only 1 email of each error?

Whenever Django has an error, it send me mail because I have ADMINS in settings. But it send me like about 16 duplicates of each error and they all look exactly the same, it's so unnecassary.

How can I make it send just one?

/r/djangolearning
https://redd.it/8opi5f
Help using GEOSGeometry.simplify with DRF

I have a few ideas, but wanted to reach out to see if someone has implemented this before and has suggestions on how to allow my DRF endpoints to implement simplify to reduce the transport size of some of my geometries. It appears to already support precision and removing dupes, but no way to reduce the size.

My best idea currently is to extend the GeometryField to\_representation to call .simplify after the current logic is executed. Would this work, and if so, where would be the best place in my application to update the model serializer mappings to use my new CustomGeometryField?

I was hoping to use it with the default ListView and Detail views so the URL would look something like this "/Railroads/?*tolerance=0.1**&**preserve\_topology=True" rather than creating a whole new endpoint just to implement this feature.*

Appreciate any help anyone could provide, as I am still fairly new to django!

/r/djangolearning
https://redd.it/8oo5n8
What's everyone working on this week?

Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.


/r/Python
https://redd.it/8or3n3
Multiprocessing vs. Multithreading in Python: What you need to know.
https://timber.io/blog/multiprocessing-vs-multithreading-in-python-what-you-need-to-know/

/r/Python
https://redd.it/8or2w5
Python Chat with mitsuhiko and davidism about Flask on June 16

[Python Chat] is a video podcast by [Trey Hunner][] where viewers get to ask questions to be addressed live during the show. Armin and I will be chatting with Trey about Flask and Pallets on June 16th at [1pm PDT][].

[Click here to sign in and ask questions before it starts!][cast]

[Python Chat]: https://www.pythonchat.com/
[Trey Hunner]: https://twitter.com/treyhunner
[1pm PDT]: https://www.wolframalpha.com/input/?i=1pm+PDT+in+local+time
[cast]: https://www.crowdcast.io/e/flask2
[previous]: https://www.crowdcast.io/e/flask

/r/flask
https://redd.it/8ouc3i
[Best Practices Question] Can you help me decide if my approach to threading seems reasonable.

So I am building a server application that will have a maximum of 2000 tcp socket listener threads and I want to make sure I am approaching this with the best possible techniques.

These threads will be spawned when the tcp server detects a new connection, the thread will listen for 60 seconds and timeout repeatedly until data has been streamed to the connection or the connection has timed\-out 5 times. If data has been received, it caches the data into the thread until a full protocol command has been detected and it queues the command to be read by the main thread. If the command queue is being read by the main thread, the listener thread will get halted before adding anything to the queue until it is unlocked again. The main thread only reads the queue every 0.6 of a second.

All of the advice I have found on TCP in python teaches to spawn a new thread for the listeners, is this still recommended for a maximum of 2000 connections? Should I try to use multithreading.Pool instead or something different all together?

I thought it would help to time the connection out 5 times, every 60 seconds for 5 minutes, as opposed to setting a hard 5 minute timeout to the TCPClient. Is this a reasonable assumption or unnecessary if the only code I have in the thread is the listener?

The only object access being shared by threads is the protocol command queue which is happening every 0.6 of a second and a client can send hundreds of commands in that span of time. The command queue is hosted in the main thread and every client listener has the ability to Enqueue\(\) a command and the main thread is the only one allowed to Dequeue\(\). Is it necessary for me to program my own locking system for the queue object, or is locking necessary with queue.Queue.Enqueue? If two Enqueue\(\) methods are called at the exact same time from different threads will this cause any issue like overwriting a queued entry or will it just affect the possible order the queued entries come out?

Any help would be great, I imagine what I have currently would be fine for maybe even 100 people. But i feel like this approach is just not the best for 2000 people all trying to send commands to the queue.

/r/Python
https://redd.it/8otbl2
I finished my first python project.

I finally finished my first project in python and created a repository on [GitHub](https://github.com/HungryWalrus/Chem). Any feedback would be nice.

/r/Python
https://redd.it/8osfwi
[AF] No support for ALTER of constraints in sqlite dialect, flask-migrate.

Hi, so i have been trying to create a model called events which has a one to many relationship with the posts model, so an event can have many different posts.

Here is the part of the post model that is relevant:

event_id = db.Column(db.Integer, db.ForeignKey('event.id'))

And here is the event model:

class Event(db.Model):
id = db.Column(db.Integer, primary_key=True)
event_name = db.Column(db.String(150), index=True, unique=True)
posts = db.relationship('Post', backref='event', lazy='dynamic')

The part of the upgrade function, in the automatically generated alembic file, that is causing this problem is this:

op.create_foreign_key(None, 'post', 'event', ['event_id'], ['id'])

The error given states:

NotImplementedError: No support for ALTER of constraints in SQLite dialect.

Before making the edits the post model did have a column named event, which I've deleted now, does it have something to do with that?

[Here](https://www.github.com/ModoUnreal/nuncio) is the repo for further reference.

What is the problem here and how do I fix it?

/r/flask
https://redd.it/8ozw5e
Help with git checkout causing problem

It is the first time that I have deployed a wepapp. I needed to to run/execute `git checkout -- .` to clear all the changes I had made on the server before doing `git pull origin master`.

Accidentally, I ran `git checkout --` (notice the absence of `.`) and I received something like
`M a_file (.py file)`

`M b_file (.css)`

`M c_file (.css)`

I realised my mistake and corrected by running `git checkout -- .` followed by `git pull origin master`.

I restarted my app and saw that the app looked weird, and some of the styles were missing. Also, `.py` file mentioned above is not getting updated despite me doing `git pull origin master` multiple times.

Please provide hints/suggestions to get my app working properly.

/r/djangolearning
https://redd.it/8ozsfl
Saleor vs Oscar vs Home-made

Hello !

I've built my online shop without a dedicated e\-commerce library, just plugging into Stripe manually to deal with sales.

I'm beginning to feel the limits of this approach, especially with regards to integrating my site with third\-party services : stripe, google analytics, paypal, zapier, ...

For example, I'd like to activate 3D secure on my site, and add paypal support. It would probably be very easy to do with Saleor and Oscar, but I have to do it manually as of now. The downside to implementing these frameworks is that I've already got a working sales funnel, and I'm afraid of the amount of work required to fit the frameworks to my existing setup.

As a solo dev, do you think I should keep going with the manual approach, or do you think Saleor and Oscar would be good ways to upgrade my site ? What is your experience with them ?

/r/django
https://redd.it/8p1h97
[D] Dedicated to all those researchers in fear of being scooped :)

/r/MachineLearning
https://redd.it/8p169l
[JupyterLab] How to Run R Code AND Python Code in Same Notebook?

I am trying to run some python code, then carry those created objects through some R code, then back to python within the same notebook. I know it was possible in Jupyer Notebook as I have seen many tutorials on how to do it.
Jupyter notebook used to have things like rpy2 but that does not seem to work anymore. Does anyone know how to accomplish this in JupyterLab in anaconda?

Thanks in Advance!

/r/IPython
https://redd.it/8p4m0m