This question already has answers here: How to iterate over a list in chunks (39 answers) Closed 8 months ago. I know that a list can be joined to make one long string as in: Obviously this would output: However, what I am trying to do is simply join the first and second strings in the list, then join the
Generating PDFs from SVG input
I am trying to generate a PDF from a SVG input file with Python in a Django application. I have already found 2 working solutions: cairo+rsvg and imagemagick but they both have one problem: They have some strange dependencies that I do not want to install on a server, for example DBUS and GTK. So I am asking for another
Pipe raw OpenCV images to FFmpeg
Here’s a fairly straightforward example of reading off a web cam using OpenCV’s python bindings: Now I want to pipe the output to ffmpeg as in: $ python capture.py | ffmpeg -f image2pipe -pix_fmt bgr8 -i – -s 640×480 foo.avi Sadly, I can’t get the ffmpeg magic incantation quite right and it fails with libavutil 50.15. 1 / 50.15. 1
Print Javascript Exceptions In A QWebView To The Console
I’m using PyQt4 and a QWebView widget to view a webpage, but it appears as though there is a problem with my Javascript. Other browsers seem to run ok, so I would like to know if any exceptions are occurring by printing them to the console. The code I’m using is below. What do I need to add to do
[] and {} vs list() and dict(), which is better? [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 months ago. The community reviewed whether to reopen this question 6 months ago and left it closed: Original close reason(s) were not resolved Improve this question
extracting public key from certificate and encrypting data
This is for a homework assignment! I get the server’s certificate using get_peer_certificate() and the calling dump_certificate to dump the certificate in a variable. The format is PEM and looks right to me. How do I extract the server’s public key from this file (‘server.pubkey’) and encrypt plaintext using RSA algorithm and any python library. At the time of writing
List sorting/modify problem
Initially, I wasn’t sure whether this was the appropriate place for this question, but after reading through the FAQ I feel fairly confident the topic is acceptable…. Furthermore I wasn’t sure if this would be classified as a particular type of problem (eg. a knapsack problem), thus, the title is rather vague. I’m sorry for that. Anyways. As both practice
How to find a best fit distribution function for a list of data?
I am aware of many probabilistic functions builted-in Python, with the random module. I’d like to know if, given a list of floats, it would be possible to find the distribution equation that best fits the list? I don’t know if numpy does it, but this function could be compared (not equal, but similar) with the Excel’s “Trend” function. How
Fast way to remove a few items from a list/queue
This is a follow up to a similar question which asked the best way to write and it seems the consensus was on something like However, I think if you are only removing a few items, most of the items are being copied into the same object, and perhaps that is slow. In an answer to another related question, someone
What’s an example use case for a Python classmethod?
I’ve read What are Class methods in Python for? but the examples in that post are complex. I am looking for a clear, simple, bare-bones example of a particular use case for classmethods in Python. Can you name a small, specific example use case where a Python classmethod would be the right tool for the job? Answer Helper methods for