Re: Putting Unicode characters in JSON

2018-03-23 Thread Steven D'Aprano
On Sat, 24 Mar 2018 11:21:09 +1100, Chris Angelico wrote: >>> If I changed my database tables to all be UTF-8 would this work >>> cleanly without any decoding? >> >> Not reliably or safely. It will appear to work so long as you have only >> pure ASCII strings from the database, and then crash when

Re: Since when builtin dict preserve key order?

2018-03-23 Thread Chris Angelico
On Sat, Mar 24, 2018 at 3:34 PM, Arkadiusz Bulski wrote: > I already asked on PYPY and they confirmed that any version of pypy, > including 2.7, has dict preserving insertion order. I am familiar with > ordered **kw which was introduced in 3.6 but I also heard that builtin dict > preserves order s

Since when builtin dict preserve key order?

2018-03-23 Thread Arkadiusz Bulski
I already asked on PYPY and they confirmed that any version of pypy, including 2.7, has dict preserving insertion order. I am familiar with ordered **kw which was introduced in 3.6 but I also heard that builtin dict preserves order since 3.5. Is that true? -- ~ Arkadiusz Bulski -- https://mail.p

Re: Putting Unicode characters in JSON

2018-03-23 Thread Chris Angelico
On Sat, Mar 24, 2018 at 11:11 AM, Steven D'Aprano wrote: > On Fri, 23 Mar 2018 07:46:16 -0700, Tobiah wrote: > >> If I changed my database tables to all be UTF-8 would this work cleanly >> without any decoding? > > Not reliably or safely. It will appear to work so long as you have only > pure ASCI

Re: Putting Unicode characters in JSON

2018-03-23 Thread Steven D'Aprano
On Fri, 23 Mar 2018 07:46:16 -0700, Tobiah wrote: > If I changed my database tables to all be UTF-8 would this work cleanly > without any decoding? Not reliably or safely. It will appear to work so long as you have only pure ASCII strings from the database, and then crash when you don't: py> te

ANN: Wing Python IDEs version 6.0.11 released

2018-03-23 Thread Wingware
Hi, We've just released Wing 6.0.11 , which implements auto-save and restore for remote files, adds a Russian translation of the UI (thanks to Alexandr Dragukin), improves remote development error reporting and recovery after network breaks, correctly term

Re: Best practice for managing secrets (passwords, private keys) used by Python scripts running as daemons

2018-03-23 Thread Dan Stromberg
I'd put them in a file with access to the daemon.. Putting credentials in an environment variable is insecure on Linux, because ps auxwwe lists environment variables. On Fri, Mar 23, 2018 at 9:37 AM, Malcolm Greene wrote: > Looking for your suggestions on best practice techniques for managing >

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Steven D'Aprano
On Fri, 23 Mar 2018 10:39:05 -0600, Malcolm Greene wrote: >> Perhaps it doesn't need to be said, but just to be sure: don't use eval >> if you don't trust the people writing the configuration file. They can >> do nearly unlimited damage to your environment.  They are writing code >> that you are

Re: PyQt4 QWebView cant load google maps markers

2018-03-23 Thread Xristos Xristoou
tell some solution ?yes you are correct for some seconds show me the mark but only for some seconds.can i update my pyqt4 to show me the mark ? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Ned Batchelder
On 3/23/18 12:39 PM, Malcolm Greene wrote: Perhaps it doesn't need to be said, but just to be sure: don't use eval if you don't trust the people writing the configuration file. They can do nearly unlimited damage to your environment.  They are writing code that you are running. Of course! Sc

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Malcolm Greene
> Perhaps it doesn't need to be said, but just to be sure: don't use eval if > you don't trust the people writing the configuration file. They can do nearly > unlimited damage to your environment.  They are writing code that you are > running. Of course! Script and config file are running in a

Best practice for managing secrets (passwords, private keys) used by Python scripts running as daemons

2018-03-23 Thread Malcolm Greene
Looking for your suggestions on best practice techniques for managing secrets used by Python daemon scripts. Use case is Windows scripts running as NT Services, but interested in Linux options as well. Here's what we're considering 1. Storing secrets in environment vars 2. Storing secrets in confi

Re: Putting Unicode characters in JSON

2018-03-23 Thread Chris Angelico
On Sat, Mar 24, 2018 at 1:46 AM, Tobiah wrote: > On 03/22/2018 12:46 PM, Tobiah wrote: >> >> I have some mailing information in a Mysql database that has >> characters from various other countries. The table says that >> it's using latin-1 encoding. I want to send this data out >> as JSON. >> >>

Re: Putting Unicode characters in JSON

2018-03-23 Thread Grant Edwards
On 2018-03-23, Richard Damon wrote: > One comment on this whole argument, the original poster asked how to get > data from a database that WAS using Latin-1 encoding into JSON (which > wants UTF-8 encoding) and was asking if something needed to be done > beyond using .decode('Latin-1'), and in

Re: Putting Unicode characters in JSON

2018-03-23 Thread Grant Edwards
On 2018-03-23, Chris Angelico wrote: > On Fri, Mar 23, 2018 at 10:47 AM, Steven D'Aprano > wrote: >> On Fri, 23 Mar 2018 07:09:50 +1100, Chris Angelico wrote: >> I was reading though, that JSON files must be encoded with UTF-8. So should I be doing string.decode('latin-1').encode('utf-8

Re: Putting Unicode characters in JSON

2018-03-23 Thread Tobiah
On 03/22/2018 12:46 PM, Tobiah wrote: I have some mailing information in a Mysql database that has characters from various other countries.  The table says that it's using latin-1 encoding.  I want to send this data out as JSON. So I'm just taking each datum and doing 'name'.decode('latin-1') an

Re: PyQt4 QWebView cant load google maps markers

2018-03-23 Thread Anssi Saari
Xristos Xristoou writes: > I want to create a simple python app using pyqt,QWebView and google maps with > markers. > > The problem is that,the markers does not load inside the QWebView, as > you can see they load just fine in the browser. Well, since you got a javascript error, maybe Qt4 doesn

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Ned Batchelder
On 3/23/18 4:30 AM, Malcolm Greene wrote: Looking for advice on how to expand f-string literal strings whose values I'm reading from a configuration file vs hard coding into my script as statements. I'm using f-strings as a very simple template language. I'm currently using the following techniqu

Re: Entering a very large number

2018-03-23 Thread Thomas Jollans
On 2018-03-23 14:01, ast wrote: > Le 23/03/2018 à 13:43, Rustom Mody a écrit : >> On Friday, March 23, 2018 at 5:46:56 PM UTC+5:30, ast wrote: >>> Hi >>> >>> I found this way to put a large number in >>> a variable. >> >> What stops you from entering the number on one single (v long) line? > > >

Re: Putting Unicode characters in JSON

2018-03-23 Thread Richard Damon
On 3/23/18 6:35 AM, Chris Angelico wrote: On Fri, Mar 23, 2018 at 9:29 PM, Steven D'Aprano wrote: On Fri, 23 Mar 2018 18:35:20 +1100, Chris Angelico wrote: That doesn't seem to be a strictly-correct Latin-1 decoder, then. There are a number of unassigned byte values in ISO-8859-1. That's inc

Re: Entering a very large number

2018-03-23 Thread Richard Damon
On 3/23/18 9:35 AM, ast wrote: Le 23/03/2018 à 14:16, Antoon Pardon a écrit : On 23-03-18 14:01, ast wrote: Le 23/03/2018 à 13:43, Rustom Mody a écrit : On Friday, March 23, 2018 at 5:46:56 PM UTC+5:30, ast wrote: What meaningful information from number can you easily retrieve from represe

Re: Entering a very large number

2018-03-23 Thread Antoon Pardon
On 23-03-18 14:35, ast wrote: > Le 23/03/2018 à 14:16, Antoon Pardon a écrit : >> On 23-03-18 14:01, ast wrote: >>> Le 23/03/2018 à 13:43, Rustom Mody a écrit : On Friday, March 23, 2018 at 5:46:56 PM UTC+5:30, ast wrote: > > >> What meaningful information from number can you easily retrieve f

Re: Entering a very large number

2018-03-23 Thread ast
Le 23/03/2018 à 14:16, Antoon Pardon a écrit : On 23-03-18 14:01, ast wrote: Le 23/03/2018 à 13:43, Rustom Mody a écrit : On Friday, March 23, 2018 at 5:46:56 PM UTC+5:30, ast wrote: What meaningful information from number can you easily retrieve from representing the number in some kind of

Re: Entering a very large number

2018-03-23 Thread ast
Le 23/03/2018 à 13:55, Wolfgang Maier a écrit : On 03/23/2018 01:30 PM, Wolfgang Maier wrote: On 03/23/2018 01:16 PM, ast wrote: n = int(     ''.join(""" 37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 74324986199524741059474233309513058

Re: Entering a very large number

2018-03-23 Thread Antoon Pardon
On 23-03-18 14:01, ast wrote: > Le 23/03/2018 à 13:43, Rustom Mody a écrit : >> On Friday, March 23, 2018 at 5:46:56 PM UTC+5:30, ast wrote: >>> Hi >>> >>> I found this way to put a large number in >>> a variable. >> >> What stops you from entering the number on one single (v long) line? > > > It i

Re: Entering a very large number

2018-03-23 Thread Johannes Bauer
On 23.03.2018 14:01, ast wrote: > It is not beautiful and not very readable. It is better to > have a fixed number of digits per line (eg 50) Oh yes, because clearly a 400-digit number becomes VERY beautiful and readable once you add line breaks to it. Cheers, Joe -- >> Wo hattest Du das Beben

Re: Entering a very large number

2018-03-23 Thread ast
Le 23/03/2018 à 13:30, Wolfgang Maier a écrit : On 03/23/2018 01:16 PM, ast wrote: A very simple improvement would be to use a single triple-quoted string. Assuming you are copy/pasting the number from somewhere that will save a lot of your time. no, it seems that sone \n are inserted insid

Re: Entering a very large number

2018-03-23 Thread ast
Le 23/03/2018 à 13:43, Rustom Mody a écrit : On Friday, March 23, 2018 at 5:46:56 PM UTC+5:30, ast wrote: Hi I found this way to put a large number in a variable. What stops you from entering the number on one single (v long) line? It is not beautiful and not very readable. It is better to

Re: Entering a very large number

2018-03-23 Thread Wolfgang Maier
On 03/23/2018 01:30 PM, Wolfgang Maier wrote: On 03/23/2018 01:16 PM, ast wrote: Hi I found this way to put a large number in a variable. C = int( "28871482380507712126714295971303939919776094592797" "22700926516024197432303799152733116328983144639225" "9419778031109293496555784189494417409338

Re: Entering a very large number

2018-03-23 Thread Rustom Mody
On Friday, March 23, 2018 at 5:46:56 PM UTC+5:30, ast wrote: > Hi > > I found this way to put a large number in > a variable. What stops you from entering the number on one single (v long) line? In case there is a religious commitment to PEP 8 dicta, the recommended meditation is this line (als

Re: Entering a very large number

2018-03-23 Thread Wolfgang Maier
On 03/23/2018 01:16 PM, ast wrote: Hi I found this way to put a large number in a variable. C = int( "28871482380507712126714295971303939919776094592797" "22700926516024197432303799152733116328983144639225" "94197780311092934965557841894944174093380561511397" "421542416933972905423711002751

Entering a very large number

2018-03-23 Thread ast
Hi I found this way to put a large number in a variable. C = int( "28871482380507712126714295971303939919776094592797" "22700926516024197432303799152733116328983144639225" "94197780311092934965557841894944174093380561511397" "4215424169339729054237110027510420801349667317" "55152859226962916

Re: Putting Unicode characters in JSON

2018-03-23 Thread Chris Angelico
On Fri, Mar 23, 2018 at 9:29 PM, Steven D'Aprano wrote: > On Fri, 23 Mar 2018 18:35:20 +1100, Chris Angelico wrote: > >> That doesn't seem to be a strictly-correct Latin-1 decoder, then. There >> are a number of unassigned byte values in ISO-8859-1. > > That's incorrect, but I don't blame you for

Re: Putting Unicode characters in JSON

2018-03-23 Thread Steven D'Aprano
On Fri, 23 Mar 2018 18:35:20 +1100, Chris Angelico wrote: > That doesn't seem to be a strictly-correct Latin-1 decoder, then. There > are a number of unassigned byte values in ISO-8859-1. That's incorrect, but I don't blame you for getting it wrong. Who thought that it was a good idea to disting

Re: Putting Unicode characters in JSON

2018-03-23 Thread Paul Moore
On 23 March 2018 at 00:27, Thomas Jollans wrote: > On 22/03/18 20:46, Tobiah wrote: >> I was reading though, that JSON files must be encoded with UTF-8. So >> should I be doing string.decode('latin-1').encode('utf-8')? Or does >> the json module do that for me when I give it a unicode object? >

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Chris Angelico
On Fri, Mar 23, 2018 at 7:37 PM, Malcolm Greene wrote: > My original post reformatted for text mode: > > Looking for advice on how to expand f-string literal strings whose values I'm > reading from a configuration file vs hard coding into > my script as statements. I'm using f-strings as a very s

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Malcolm Greene
My original post reformatted for text mode: Looking for advice on how to expand f-string literal strings whose values I'm reading from a configuration file vs hard coding into my script as statements. I'm using f-strings as a very simple template language. I'm currently using the following tech

Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Malcolm Greene
Looking for advice on how to expand f-string literal strings whose values I'm reading from a configuration file vs hard coding into my script as statements. I'm using f-strings as a very simple template language. I'm currently using the following technique to expand these f-strings. Is there a bett

Re: Putting Unicode characters in JSON

2018-03-23 Thread Chris Angelico
On Fri, Mar 23, 2018 at 4:35 PM, Steven D'Aprano wrote: > On Fri, 23 Mar 2018 12:05:34 +1100, Chris Angelico wrote: > >> Latin-1 is not "arbitrary bytes". It is a very specific encoding that >> cannot decode every possible byte value. > > Yes it can. > > py> blob = bytes(range(256)) > py> len(blob