Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Tim Golden

On 08/03/2017 22:10, Chris Angelico wrote:

On Thu, Mar 9, 2017 at 8:25 AM, Chris Green  wrote:

Chris Angelico  wrote:

On Thu, Mar 9, 2017 at 6:27 AM, Chris Green  wrote:

dbcol['firstname'] = col('First Name', True, False)
dbcol['lastname'] = col('Last Name', True, False)


http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/


Yes, I'm well aware of these issues, but it's my personal address book
so I can avoid many/most of them.


So you assume that you'll never meet someone from another culture?
Okay. I'm pretty sure that counts as bigoted, but sure :)


Chris: I think that remark was uncalled for. You'd made a perfectly 
valid point about names not always working how we think. At that point, 
I think it's up to each person to decide their own approach based on 
their own knowledge of their own circumstances.


TJG
--
https://mail.python.org/mailman/listinfo/python-list


Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Chris Angelico
On Thu, Mar 9, 2017 at 7:45 PM, Tim Golden  wrote:
>> So you assume that you'll never meet someone from another culture?
>> Okay. I'm pretty sure that counts as bigoted, but sure :)
>
>
> Chris: I think that remark was uncalled for. You'd made a perfectly valid
> point about names not always working how we think. At that point, I think
> it's up to each person to decide their own approach based on their own
> knowledge of their own circumstances.

Yep. He's free to assume that not one of his friends will be from any
culture other than his own. It just happens to be a bigoted viewpoint.

I wonder, would people treat it differently if the address book took a
traditional binary view of gender, and required that everyone be
precisely "male" or "female"? Would that be called bigoted, or is it
perfectly reasonable to demand that all of your friends fit this?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Web Frameworks

2017-03-09 Thread Patrick McFarling
I would like to know what are the pros and cons of the web frameworks made in 
python.
The one I tend to lean towards is Flask.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Antoon Pardon
Op 09-03-17 om 10:01 schreef Chris Angelico:
> On Thu, Mar 9, 2017 at 7:45 PM, Tim Golden  wrote:
>>> So you assume that you'll never meet someone from another culture?
>>> Okay. I'm pretty sure that counts as bigoted, but sure :)
>>
>> Chris: I think that remark was uncalled for. You'd made a perfectly valid
>> point about names not always working how we think. At that point, I think
>> it's up to each person to decide their own approach based on their own
>> knowledge of their own circumstances.
> Yep. He's free to assume that not one of his friends will be from any
> culture other than his own. It just happens to be a bigoted viewpoint.

He didn't make that assumption.

-- 
Antoon Pardon

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Web Frameworks

2017-03-09 Thread David Froger
There is a free ebook on the subject on O'Reilly:
http://www.oreilly.com/web-platform/free/python-web-frameworks.csp

Hope it helps,
David


Quoting Patrick McFarling (2017-03-09 10:24:16)
> I would like to know what are the pros and cons of the web frameworks made in 
> python.
> The one I tend to lean towards is Flask.
> -- 
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Chris Angelico
On Thu, Mar 9, 2017 at 8:58 PM, Antoon Pardon
 wrote:
> Op 09-03-17 om 10:01 schreef Chris Angelico:
>> On Thu, Mar 9, 2017 at 7:45 PM, Tim Golden  wrote:
 So you assume that you'll never meet someone from another culture?
 Okay. I'm pretty sure that counts as bigoted, but sure :)
>>>
>>> Chris: I think that remark was uncalled for. You'd made a perfectly valid
>>> point about names not always working how we think. At that point, I think
>>> it's up to each person to decide their own approach based on their own
>>> knowledge of their own circumstances.
>> Yep. He's free to assume that not one of his friends will be from any
>> culture other than his own. It just happens to be a bigoted viewpoint.
>
> He didn't make that assumption.

He did.

On Thu, Mar 9, 2017 at 8:25 AM, Chris Green  wrote:
> Yes, I'm well aware of these issues, but it's my personal address book
> so I can avoid many/most of them.

The justification "it's *my* personal address book" is saying "none of
*my* friends have weird names, so I'm fine". So, yeah, he did. This is
a design flaw on par with assuming that a byte is identical to a
character; you can pretend it so long as you don't get any "funny
characters". And then you can blame the non-ASCII characters for
breaking your program, or force someone's name to fit into your
predefined scheme.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Antoon Pardon
Op 09-03-17 om 12:32 schreef Chris Angelico:

> On Thu, Mar 9, 2017 at 8:25 AM, Chris Green  wrote:
>> Yes, I'm well aware of these issues, but it's my personal address book
>> so I can avoid many/most of them.
> The justification "it's *my* personal address book" is saying "none of
> *my* friends have weird names, so I'm fine". So, yeah, he did.

No he didn't, you are reading conclusions into his words that aren't
there. An other possibility is that it is his personal address book,
so he is at liberty to handle those weird names as he sees fit. He
doesn't own anyone an explanation of how he organises his own personal
address book.

Just because you can only think of one conclusion to draw from his words,
doesn't mean that is the only possible conclusion.

-- 
Antoon Pardon.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Chris Angelico
On Thu, Mar 9, 2017 at 11:06 PM, Antoon Pardon
 wrote:
> Op 09-03-17 om 12:32 schreef Chris Angelico:
>
>> On Thu, Mar 9, 2017 at 8:25 AM, Chris Green  wrote:
>>> Yes, I'm well aware of these issues, but it's my personal address book
>>> so I can avoid many/most of them.
>> The justification "it's *my* personal address book" is saying "none of
>> *my* friends have weird names, so I'm fine". So, yeah, he did.
>
> No he didn't, you are reading conclusions into his words that aren't
> there. An other possibility is that it is his personal address book,
> so he is at liberty to handle those weird names as he sees fit. He
> doesn't own anyone an explanation of how he organises his own personal
> address book.
>

You're still assuming that there are such things as "weird names". As
of Python 3, we've finally moved beyond the notion that there are
"weird characters" that don't fit into our nice tidy system where one
character is the same as one byte. We need to give people's names the
same courtesy. They are not "weird" names. They are 100% legitimate
names that should be welcomed into any system that accepts names.

(That said, though, I think it's not unreasonable to demand that names
be represented entirely in Unicode - falsehood #11 - as it's extremely
hard to deal with non-Unicode text. But you have to understand that
you'll be asking some number of people to represent themselves
differently for the convenience of your code.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Chris Green
Michael Torrie  wrote:
> On 03/08/2017 12:27 PM, Chris Green wrote:
> > I have a fairly simple application that populates a GUI window with
> > fields from a database table.  The fields are defined/configured by a
> > dictionary as follows:-
> 
> Instead of ordering the data in Python, why not rely on the GUI to do
> the sort?  Most GUI's even have table widgets that let you click on the
> headings to sort arbitrarily.
> 
How would it sort it?  The order I want is arbitrary, or at least not
alphabetical or anything, I just want the order to be the way I
listed it.

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Chris Green
Chris Angelico  wrote:
> On Thu, Mar 9, 2017 at 7:45 PM, Tim Golden  wrote:
> >> So you assume that you'll never meet someone from another culture?
> >> Okay. I'm pretty sure that counts as bigoted, but sure :)
> >
> >
> > Chris: I think that remark was uncalled for. You'd made a perfectly valid
> > point about names not always working how we think. At that point, I think
> > it's up to each person to decide their own approach based on their own
> > knowledge of their own circumstances.
> 
> Yep. He's free to assume that not one of his friends will be from any
> culture other than his own. It just happens to be a bigoted viewpoint.
> 
I think I probably have more friends from 'other cultures' than most
as I lived in the arab world for ten years and have spent a
considerable time in various other places too.

I personally am not upset when people elsewhere have a problem with my
name because it doesn't fit *their* norms so I don't expect them to
get all upset when the same happens the other way around.  It's
inevitable that things like this will happen, one just lives with it
or works around it.

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Chris Green
Chris Angelico  wrote:
> On Thu, Mar 9, 2017 at 8:25 AM, Chris Green  wrote:
> > Chris Angelico  wrote:
> >> On Thu, Mar 9, 2017 at 6:27 AM, Chris Green  wrote:
> >> > dbcol['firstname'] = col('First Name', True, False)
> >> > dbcol['lastname'] = col('Last Name', True, False)
> >>
> >> http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/
> >>
> > Yes, I'm well aware of these issues, but it's my personal address book
> > so I can avoid many/most of them.
> 
> So you assume that you'll never meet someone from another culture?
> Okay. I'm pretty sure that counts as bigoted, but sure :)
> 
> As a general rule, it's safest to just have a single "name" field and
> have done with it.
> 
Which doesn't work at all for me as I want to:-

Sort on family/last name
Separate first and family name so I can write addresses etc.

I've lived in quite a few different places where names are not
formatted like ours.  I'm aiming to add 'nameprefix' and 'namesuffix'
fields to handle different formats more completely, the layout I
showed here is just a prototype.

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Database security tool for Python apps with PostgreSQL backend.

2017-03-09 Thread borysova . mary
Database security tool for Python apps with PostgreSQL backend: 
https://www.cossacklabs.com/blog/presenting-acra.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Antoon Pardon
Op 09-03-17 om 13:16 schreef Chris Angelico:
> On Thu, Mar 9, 2017 at 11:06 PM, Antoon Pardon
>  wrote:
>> Op 09-03-17 om 12:32 schreef Chris Angelico:
>>
>>> On Thu, Mar 9, 2017 at 8:25 AM, Chris Green  wrote:
 Yes, I'm well aware of these issues, but it's my personal address book
 so I can avoid many/most of them.
>>> The justification "it's *my* personal address book" is saying "none of
>>> *my* friends have weird names, so I'm fine". So, yeah, he did.
>> No he didn't, you are reading conclusions into his words that aren't
>> there. An other possibility is that it is his personal address book,
>> so he is at liberty to handle those weird names as he sees fit. He
>> doesn't own anyone an explanation of how he organises his own personal
>> address book.
>>
> You're still assuming that there are such things as "weird names".

You are the one that started to use the word "weird". Please don't
draw conclusions about what I assume, just because I followed your
word choice.

> As
> of Python 3, we've finally moved beyond the notion that there are
> "weird characters" that don't fit into our nice tidy system where one
> character is the same as one byte. We need to give people's names the
> same courtesy. They are not "weird" names. They are 100% legitimate
> names that should be welcomed into any system that accepts names.
>
> (That said, though, I think it's not unreasonable to demand that names
> be represented entirely in Unicode - falsehood #11 - as it's extremely
> hard to deal with non-Unicode text. But you have to understand that
> you'll be asking some number of people to represent themselves
> differently for the convenience of your code.)

But you don't know whether he is using unicode or not. And if he is not,
it still is his own personal address book and he is allowed to transliterate
the names he enters any way he likes. If he has a French friend with the
name "Pièrre", he is allowed to enter it as "Pjair" in his personal address
book if he thinks that would help him to pronounce it more correctly.

So he is not asking a number of people to represent themselves differently
because this is not something for different people to use, it is his personal
address book.

-- 
Antoon Pardon.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "Best" websocket implementation for Python 2.x?

2017-03-09 Thread Daniel Bastos
Skip Montanaro  writes:

[...]

> These two packages would appear to have stalled. Looking around, I also
> found
>
> ws4py
> websockets - Python 3.3 or later
> autobahn.websocket
>
> There are probably others I haven't yet stumbled upon. (I'd continue poking
> around PyPI, but it seems the server is having problems.)

It seems you didn't Tornado yet.
http://www.tornadoweb.org/en/stable/

[...]
-- 
https://mail.python.org/mailman/listinfo/python-list


python/gui question

2017-03-09 Thread Xristos Xristoou
i want to create a very simple python plugin using QT designer but i an not 
sure how to connect my variable from gui to my python script.
my gui is simple have only one lineEdit and ok or cancel.
in the gui (widget):

 
   

 20
 90
 171
 31

   
  


def run(self):
self.dlg.show()
result = self.dlg.exec_()
if result:
distance = self.dlg.lineEdit.value()
if distance == 0:
#do something
else:
#do sothing else
pass

i test this code but dont work dont show me anything. any idea ?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Web Frameworks

2017-03-09 Thread Patrick McFarling
On Thursday, 9 March 2017 05:05:37 UTC-5, David Froger  wrote:
> There is a free ebook on the subject on O'Reilly:
> http://www.oreilly.com/web-platform/free/python-web-frameworks.csp
> 
> Hope it helps,
> David
> 
> 
> Quoting Patrick McFarling (2017-03-09 10:24:16)
> > I would like to know what are the pros and cons of the web frameworks made 
> > in python.
> > The one I tend to lean towards is Flask.
> > -- 
> > https://mail.python.org/mailman/listinfo/python-list

Thanks for the book!
-- 
https://mail.python.org/mailman/listinfo/python-list


keyrings.cryptfile released on github

2017-03-09 Thread Hans-Peter Jansen
Hi,

since the PyCrypto ML is dead, I'm looking for advise/feedback from some
cryptography aware people.

I've released a keyring companion package today:

https://github.com/frispete/keyrings.cryptfile

Its primary purpose is a decent encrypted file backend for python keyrings.
As such, it uses manually parameterized argon2 hashes as KDF, and AES in OCB 
mode as stream cipher (well, it just encrypts the password for a given 
service/user name). Granted, the advantages of OCB are not /that/ crucial 
here :wink:, but apart from technical factors, the exclusion of military uses 
by its license is rather *attractive* from my POV(!). But I'm open for 
discussions of course.

Still interested? Here we go:

To get you started, I expect you to have a python3 environment and git 
available. You might want to provide the packages argon2-cffi, keyring, 
pycryptodome and their dependencies (most notably SecretStorage and 
cryptography, or use a local venv, but that will depend on a compiler and some
development packages.

Example session, create an encrypted keyring:

$ git clone https://github.com/frispete/keyrings.cryptfile
$ cd keyrings.cryptfile
$ pyvenv env
$ . env/bin/activate
(env) $ pip install -e .
[...] # should succeed, some development packages might be missing otherwise
(env) $ python3
Python 3.4.5 (default, Jul 03 2016, 12:57:15) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from keyrings.cryptfile.cryptfile import CryptFileKeyring
>>> kr = CryptFileKeyring()
>>> kr.set_password("service", "user", "secret")
Please set a password for your new keyring: 
Please confirm the password: 
>>> ^d

Second session, retrieve the stored secret from the keyring:

(env) $ python3
Python 3.4.5 (default, Jul 03 2016, 12:57:15) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from keyrings.cryptfile.cryptfile import CryptFileKeyring
>>> kr = CryptFileKeyring()
>>> kr.get_password("service", "user")
Please enter password for encrypted keyring: 
'secret'
>>> ^d

Note, that the KDF might delay the {set,get}_password() operations for a 
few seconds (~1 sec. on a capable system).

The resulting file is located here (by default) and might look similar to:
(env) $ cat ~/.local/share/python_keyring/cryptfile_pass.cfg
[keyring_2Dsetting]
password_20reference = 
eyJub25jZSI6ICJQdVdWVUIwUHNYbEFqYUUxZ2l2RlxuIiwgIm1hYyI6ICIvVTFIVDBWTnRheTFl

TjA5TVlHb0dRPT1cbiIsICJzYWx0IjogIklMdDNBU1hMUENrbWZ2NzFudmtBSUE9PVxuIiwgImRh
dGEiOiAidW1EQkNvQ2dRUTk5WEVaNkZ4NWt3NXRkSUZDOHFIUE5ZOHhWXG4ifQ==
scheme = PyCryptodome [Argon2] AES OCB
version = 1.0

[service]
user = 
eyJub25jZSI6ICI5SUU3UGp2eDU2SXNQdHlLUGRtaFxuIiwgIm1hYyI6ICJKcFR1NXMxaDd0UGlW

OW9XL3d5cFdBPT1cbiIsICJzYWx0IjogIlpBeEhJdXlqYnRuTkgzb3BMNTFvdkE9PVxuIiwgImRh
dGEiOiAiT2I3Z1JJbXR5aVJLXG4ifQ==


The values can be decoded like this:

(env) $ python3
>>> import base64
>>> base64.decodebytes(b"""
... eyJub25jZSI6ICI5SUU3UGp2eDU2SXNQdHlLUGRtaFxuIiwgIm1hYyI6ICJKcFR1NXMxaDd0UGlW
... OW9XL3d5cFdBPT1cbiIsICJzYWx0IjogIlpBeEhJdXlqYnRuTkgzb3BMNTFvdkE9PVxuIiwgImRh
... dGEiOiAiT2I3Z1JJbXR5aVJLXG4ifQ==""")
b'{"nonce": "9IE7Pjvx56IsPtyKPdmh\\n", "mac": "JpTu5s1h7tPiV9oW/wypWA==\\n", 
   "salt": "ZAxHIuyjbtnNH3opL51ovA==\\n", "data": "Ob7gRImtyiRK\\n"}'

The items should be self explanatory. In theory, it should be considerable 
hard to get back to the plain values of data without knowing the password.

Any cryptography experts attending?

What do you think? The class hierarchy is inherited from keyrings.alt, and 
not exactly easy to follow, but the interesting parts are all in cryptfile,
which is quite brief.

I would be glad to hear something from you about my handling of cryptography. 
Is it ready for the public in that form or should I better locked away? :wink:

TIA,
Pete

-- 
https://mail.python.org/mailman/listinfo/python-list


Gtk.Label text positioning

2017-03-09 Thread Chris Green
Is there any way to postion different lines of text in a Gtk.Label in
different ways?  

E.g. is it possible to centre one line of text and left justify the
remainder?

Or does one simply have two Gtk.Label instances, one with centred text
and one with left justified text. 

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's the neatest way of getting dictionary entries in a specified order?

2017-03-09 Thread Erik

On 09/03/17 13:09, Chris Green wrote:

Michael Torrie  wrote:

On 03/08/2017 12:27 PM, Chris Green wrote:

I have a fairly simple application that populates a GUI window with
fields from a database table.  The fields are defined/configured by a
dictionary as follows:-


Instead of ordering the data in Python, why not rely on the GUI to do
the sort?  Most GUI's even have table widgets that let you click on the
headings to sort arbitrarily.


How would it sort it?  The order I want is arbitrary, or at least not
alphabetical or anything, I just want the order to be the way I
listed it.


To be fair to Michael, you did not state your required order in the 
message that he replied to. You just kept saying "the order I want".


If you're going to make people guess, don't chastise them for guessing 
wrong :D


E.

--
https://mail.python.org/mailman/listinfo/python-list


Re: keyrings.cryptfile released on github

2017-03-09 Thread Paul Rubin
Hans-Peter Jansen  writes:
> I've released a keyring companion package today:
>   https://github.com/frispete/keyrings.cryptfile

Interesting, I'll take a look at it.  I wrote something like it many
years ago but never did much with it.  Thanks for posting!
-- 
https://mail.python.org/mailman/listinfo/python-list


Unsubscribe to Python email list

2017-03-09 Thread Pablo Lozano
Good day,

I would like to unsubscribe this e-mail to the Python e-mail list.

Kind regards
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unsubscribe to Python email list

2017-03-09 Thread MRAB

On 2017-03-10 02:38, Pablo Lozano wrote:

Good day,

I would like to unsubscribe this e-mail to the Python e-mail list.

Kind regards


You'll have to do it yourself. Read this:

https://mail.python.org/mailman/listinfo/python-list

The relevant bit is in the section titled "Python-list Subscribers".

--
https://mail.python.org/mailman/listinfo/python-list


Re: keyrings.cryptfile released on github

2017-03-09 Thread ng0
Hans-Peter Jansen transcribed 3.8K bytes:
> Hi,
> 
> since the PyCrypto ML is dead, I'm looking for advise/feedback from some
> cryptography aware people.
> 
> I've released a keyring companion package today:
> 
>   https://github.com/frispete/keyrings.cryptfile
> 
> Its primary purpose is a decent encrypted file backend for python keyrings.
> As such, it uses manually parameterized argon2 hashes as KDF, and AES in OCB 
> mode as stream cipher (well, it just encrypts the password for a given 
> service/user name). Granted, the advantages of OCB are not /that/ crucial 
> here :wink:, but apart from technical factors, the exclusion of military uses 

I was looking for some proprietary EULA or something else locked down license
and instead just saw the Expat license.  I assume that you are aware
that no anti-mil clause exists in co-existence with free software
licenses 
and your sentence was just written in an
odd way?

> by its license is rather *attractive* from my POV(!). But I'm open for 
> discussions of course.
[...] 
> What do you think? The class hierarchy is inherited from keyrings.alt, and 
> not exactly easy to follow, but the interesting parts are all in cryptfile,
> which is quite brief.
> 
> I would be glad to hear something from you about my handling of cryptography. 
> Is it ready for the public in that form or should I better locked away? :wink:
> 
> TIA,
> Pete
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list