pip 20.3 release (heads-up for potential disruption)

2020-11-30 Thread Sumana Harihareswara
On behalf of the Python Packaging Authority, I am pleased to announce that we have just released pip 20.3, a new version of pip. You can install it by running `python -m pip install --upgrade pip`. This is an important and disruptive release -- we explained why in a blog post last year https:/

Re: Reading binary data with the CSV module

2020-11-30 Thread MRAB
On 2020-11-30 03:59, Jason Friedman wrote: csv.DictReader appears to be happy with a list of strings representing the lines. Try this: contents = source_file.content() for row in csv.DictReader(contents.decode('utf-8').splitlines()): print(row) Works great, thank you! Question ... wil

Best-practice for formatted string literals and localization?

2020-11-30 Thread Hartmut Goebel
Hi, formatted string literals are great, but can't be used together with localization: _(f"These are {count} stones") will crash babel ("NameError: name 'count' is not defined". And even it it would succeed, the *evaluated* string would be passed to "_(…)", resulting in a not-translated

Re: Best-practice for formatted string literals and localization?

2020-11-30 Thread Chris Angelico
On Tue, Dec 1, 2020 at 5:31 AM Hartmut Goebel wrote: > > Hi, > > formatted string literals are great, but can't be used together with > localization: > > _(f"These are {count} stones") > > will crash babel ("NameError: name 'count' is not defined". And even it > it would succeed, the *evaluate

Re: A problem with opening a file -- again

2020-11-30 Thread Chris Angelico
On Tue, Dec 1, 2020 at 5:36 AM Dennis Lee Bieber wrote: > Off-hand, since you aren't explicitly using "del lf" it means that > __del__() is being called during the process shutdown. Thing is, there is > no guarantee during shutdown of when things are deleted. There is a faint > possibility

Converting images to PDF. Final file has blank pages before and after.

2020-11-30 Thread Michael Baca
Hello, new to the group, rather new to programming. I'm writing a program that takes images and converts them into PDF's. It works after quite a few days of trying, however the final file has a blank page inserted before and after each page containing the images. This uses FPDF to do the conv

Re: Converting images to PDF. Final file has blank pages before and after.

2020-11-30 Thread MRAB
On 2020-12-01 01:20, Michael Baca wrote: Hello, new to the group, rather new to programming. I'm writing a program that takes images and converts them into PDF's. It works after quite a few days of trying, however the final file has a blank page inserted before and after each page containing t

Re: Converting images to PDF. Final file has blank pages before and after.

2020-11-30 Thread Kushal Kumaran
On Mon, Nov 30 2020 at 05:20:30 PM, Michael Baca wrote: > Hello, new to the group, rather new to programming. > > I'm writing a program that takes images and converts them into PDF's. It > works after quite a few days of trying, however the final file has a blank > page inserted before and afte

Concatenating a Hash to a String

2020-11-30 Thread Ivan "Rambius" Ivanov
Hello, I want to store the hashes of strings in a database and I have problems generating the sql statements. I generate the hashes using hashlib and then convert it to base64 and I put the base64 representation in the sql. Here is the code: #!/usr/bin/env python3.8 import base64 import hashlib

Re: Concatenating a Hash to a String

2020-11-30 Thread Chris Angelico
On Tue, Dec 1, 2020 at 4:34 PM Ivan "Rambius" Ivanov wrote: > > Hello, > > I want to store the hashes of strings in a database and I have > problems generating the sql statements. I generate the hashes using > hashlib and then convert it to base64 and I put the base64 > representation in the sql.

Re: Concatenating a Hash to a String

2020-11-30 Thread Ivan "Rambius" Ivanov
On Tue, Dec 1, 2020 at 12:39 AM Chris Angelico wrote: > Don't do this! DO NOT do this! Even if it might happen to work with a > base 64 encoded value, this is a terrible terrible bug just waiting to > happen. Instead, use *parameterized queries* and keep your SQL safe. OK. What are parameterized

Re: Concatenating a Hash to a String

2020-11-30 Thread Chris Angelico
On Tue, Dec 1, 2020 at 4:53 PM Ivan "Rambius" Ivanov wrote: > > On Tue, Dec 1, 2020 at 12:39 AM Chris Angelico wrote: > > Don't do this! DO NOT do this! Even if it might happen to work with a > > base 64 encoded value, this is a terrible terrible bug just waiting to > > happen. Instead, use *para