Re: Final statement from Steering Council on politically-charged commit messages

2020-08-19 Thread Alexandre Brault

On 2020-08-18 7:34 p.m., rmli...@riseup.net wrote:

There are many reasons Elements is a terrible English style guide:
https://www.pure.ed.ac.uk/ws/files/8520953/PULLUM_2010_The_land_of_the_free_and_the_elements_of_style.pdf

I would kindly recommend that folks just educate themselves on what
white supremacy is & how it continues in both subtle & overt ways to
this day. Sadly, getting extremely upset after being exposed to the
accurate term white supremacy is a symptom of what's called 'white
fragility' by psychologists who study the social pathologies of racism &
its long-lasting, inter-generational impacts on society.

You need serious help with processing your anger if you look at
everything that's happening in the world & bubble in anger over a commit
message that is simply acknowledging a social ill. One of countless
many. I do hope you get the help you need.

I would also caution against relying on the idea of human rights when
defending against accusations of being political, since they too are
political. Life is political. We continue to this day trying to
redefine, as a society, what human rights are, & who is considered to
deserve them. That process is politics.

Some people think that being called white is racist. Other people think
that having their land & children stolen because of their race & being
forced to write in the language of their captors is racist. One group is
deflecting blame for the worst atrocities in history, the other is
acknowledging a real problem & seeking accountability in everyday life.


Resources:
   A People's History of the United States:
https://mvlindsey.files.wordpress.com/2015/08/peoples-history-zinn-1980.pdf
   The Invention of the White Race: Volume II:
http://ouleft.org/wp-content/uploads/Invention-White-Race-Vol2-Allen.pdf


I've not seen anyone objecting to the idea of removing the reference to 
Strunk and White in favour of the underlying message of "be 
understandable by others who may read your comments" (there were at most 
a few philosophical "what is understandable") . In fact, that is how the 
topic was initially presented.


What people *are* complaining about is the use of a commit message to 
stand on a soapbox and preach. The time to preach was when debating the 
change; commit messages, in many people's opinions, is not the time to 
espouse non-technical opinions


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


Re: Why generate POP_TOP after an "import from?"

2020-04-17 Thread Alexandre Brault

On 2020-04-17 2:22 p.m., Adam Preble wrote:

Given this in Python 3.6.8:

from dis import dis

def import_from_test():
from sys import path


dis(import_from_test)

   2   0 LOAD_CONST   1 (0)
   2 LOAD_CONST   2 (('path',))
   4 IMPORT_NAME  0 (sys)
   6 IMPORT_FROM  1 (path)
   8 STORE_FAST   0 (path)
  10 POP_TOP
  12 LOAD_CONST   0 (None)
  14 RETURN_VALUE

I don't understand why there's a POP_TOP there that I don't get for an 
import_name grammatical statement.

IMPORT_NAME needs to eat the top two entries of the stack for level and the 
from-list. BTW I don't know what level is for either since my science projects 
have always had it be zero, but that's another question.

IMPORT_NAME will the push the module on to the stack.

IMPORT_FROM will import path from the module on the stack, and push that result 
on the stack.

STORE_FAST will store path for use, finally "modifying the namespace."

At this point, my conceptual stack is empty. If I POP_TOP then I have nothing 
to pop and the world would end. Yet, it doesn't. What am I missing?


You can get an idea of what you're missing if you import multiple names 
from a module at once:


>>> def f():
...     from sys import path, argv
...
>>> dis.dis(f)
  2   0 LOAD_CONST   1 (0)
  2 LOAD_CONST   2 (('path', 'argv'))
  4 IMPORT_NAME  0 (sys)
  6 IMPORT_FROM  1 (path)
  8 STORE_FAST   0 (path)
 10 IMPORT_FROM  2 (argv)
 12 STORE_FAST   1 (argv)
 14 POP_TOP
 16 LOAD_CONST   0 (None)
 18 RETURN_VALUE

As shown here (and confirmed by the doc of the IMPORT_FROM opcode), 
IMPORT_FROM loads an attribute from the module on top of the stack, but 
doesn't pop the module. The POP_TOP instruction is what does.


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


Re: Spread a statement over various lines

2019-09-18 Thread Alexandre Brault

On 2019-09-18 4:01 p.m., Ralf M. wrote:
> Am 17.09.2019 um 20:59 schrieb Manfred Lotz:
>> I have a function like follows
>>
>> def regex_from_filepat(fpat):
>>  rfpat = fpat.replace('.', '\\.') \
>>    .replace('%', '.')  \
>>    .replace('*', '.*')
>>
>>  return '^' + rfpat + '$'
>>
>>
>> As I don't want to have the replace() functions in one line my
>> question is if it is ok to spread the statement over various lines as
>> shown above, or if there is a better way?
>>
>> Thanks.
>>
>
> Not related to your question, but:
> You seem to try to convert a Windows wildcard pattern to a regex
> pattern. However, wildcards sometimes behave a bit different than what
> you assume. I know for instance that *.* matches any filename, even if
> the filename doesn't contain a dot.
>
> Out of curiosity I played around a bit, details below.
> As you can see, there are other wildcard strangenesses, e.g.
> - ? does not match a dot
> -  between letters etc. matches exactly 4 characters, but
>    at the end or directly before a dot matches at most 4 characters
>
> I don't know the exact rules of Windows wildcards, so there may be
> even more cases of unexpected behavior.
> If anyone knows where to find the complete rules (or a python module
> that implements them), I would be interested.
>

fnmatch in the standard library has a translate function that transforms
a glob pattern to a regex

https://docs.python.org/3.7/library/fnmatch.html#fnmatch.translate

Alex

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


Re: How to load cookies from a json input in python-requests?

2019-08-12 Thread Alexandre Brault

On 2019-08-12 11:38 p.m., Peng Yu wrote:

```
import requests
s = requests.Session()
import json
s.cookies.set_cookie(requests.utils.cookiejar_from_dict(json.load(sys.stdin)))
```

I used the above command to load cookies from a json file. But I got
the following error. Does anybody know how to fix the error? Thanks.

```
Traceback (most recent call last):
   File "/xxx/xxx.py", line 15, in 
 
s.cookies.set_cookie(requests.utils.cookiejar_from_dict(json.load(sys.stdin)))
   File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/cookies.py",
line 345, in set_cookie
 if hasattr(cookie.value, 'startswith') and
cookie.value.startswith('"') and cookie.value.endswith('"'):
AttributeError: 'RequestsCookieJar' object has no attribute 'value'
```
set_cookie is used to add an individual cookie in an existing cookiejar. 
You might want to have a look at 
requests.utils.add_dict_to_cookiejar(s.cookies, json.load(...)) or 
passing the result of requests.utils.cookiejar_from_dict ti the cookies 
argument of requests.Session

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


Re: SyntaxError: positional argument follows keyword argument

2019-06-07 Thread Alexandre Brault
On 2019-06-07 2:43 p.m., Rich Shepard wrote:
> I understand positional and keyword arguments and the syntax for the
> ttk.Checkbutton as described on
> .
>
> $ python3 geochem.py
>   File "geochem.py", line 60
>     ttk.Checkbutton(text='Censored?', variable=input_var),
>     ^
> SyntaxError: positional argument follows keyword argument
>
> I've provided only keyword arguments to the call to the ttk.Checkbutton
> widget and am not seeing the positional argument that follows. Please
> show
> me what I miss seeing here:
>
> self.inputs['nondetect'] = LabelInput(
>     self, 'Censored?',
>     #input_var = tk.BooleanVar(),
>     input_var = tk.IntVar,
>     ttk.Checkbutton(text='Censored?', variable=input_var),
> )
>
> It does not matter if the variable holding the checkbutton's state is an
> IntVar or a BooleanVar, the same syntax error is generated. Commenting
> out
> all widgets prior to this one makes no difference so the error must be
> local. Yes?
>
> Please explain where the positional argument is located.
>
> Regards,
>
> Rich

The positional argument in question is not one you passed to the
ttk.Checkbutton call, but the ttk.Checkbutton itself that you're passing
to LabelInput as a positional argument after the input_var keyword argument

Alex

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


Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Alexandre Brault
On 2019-03-27 10:42 a.m., Paul Moore wrote:
> On Wed, 27 Mar 2019 at 12:27, Alexey Muranov  wrote:
>> On mer., mars 27, 2019 at 10:10 AM, Paul Moore 
>> wrote:
>>> On Wed, 27 Mar 2019 at 08:25, Alexey Muranov
>>>  wrote:
  Whey you need a simple function in Python, there is a choice
 between a
  normal function declaration and an assignment of a anonymous
 function
  (defined by a lambda-expression) to a variable:

  def f(x): return x*x

  or

  f = lambda x: x*x

  It would be however more convenient to be able to write instead just

  f(x) = x*x
>>> Why? Is saving a few characters really that helpful? So much so that
>>> it's worth adding a *third* method of defining functions, which would
>>> need documenting, adding to training materials, etc, etc?
>> Because i think i would prefer to write it this way.
> That's not likely to be sufficient reason for changing a language
> that's used by literally millions of people.
>
>> (Almost no new documentation or tutorials would be needed IMHO.)
> Documentation would be needed to explain how the new construct worked,
> for people who either wanted to use it or encountered it in other
> people's code. While it may be obvious to you how it works, it likely
> won't be to others, and there will probably be edge cases you haven't
> considered that others will find and ask about.

For what it's worth, if I encountered "f(x) = x * x" in code, my first
thought would be that Python somehow added a way to return an assignable
reference from a function, rather than this being an anonymous function
declaration.

So documentation of that syntax would 100% be required

Alex

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


Re: What is the difference between "ws.Messagebeep(1)" and "ws.Messagebeep(-1)" ?

2019-03-21 Thread Alexandre Brault
Assuming ws is winsound, MessageBeep(-1) produces a "simple beep".
MessageBeep(1) doesn't seem to actually exist so it might fall back to
that same "simple beep". The possible values are -1, MB_ICONASTERISK,
MB_ICONEXCLAMATION, MB_ICONHAND, MB_ICONQUESTION, and MB_OK, all of
which are defined in the winsound module.

Alex

On 2019-03-21 9:59 a.m., Steve wrote:
> Also: What is the code for other tones that I can call?
>
>  
>
>  
>
> Footnote:
>
> When someone asks "A penny for your thoughts" and you give your 2c worth,  
>
> I wonder what happens to that other penny?
>
> TTKMAWAN
>
>  
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 394

2018-10-19 Thread Alexandre Brault
On 2018-10-19 06:06 AM, Marko Rauhamaa wrote:
> Anders Wegge Keller :
>> * python2 will refer to some version of Python 2.x.
> Untrue for macOS.
>
>> * python3 will refer to some version of Python 3.x.
> Untrue for macOS, ArchLinux, RHEL and CentOS.
>
>> * for the time being, all distributions should ensure that python, if
>> installed, refers to the same target as python2, unless the user
>> deliberately overrides this or a virtual environment is active.
> Should, would, could.
>
Some platforms not being 394-compliant doesn't change what PEP-394 says.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.6 Logging time is not listed

2018-08-13 Thread Alexandre Brault
On 2018-08-13 12:37 PM, Keep Secret wrote:
> #!/usr/bin/env python3
> import logging
> logging.basicConfig(filename='example.log',level=logging.DEBUG)
> logging.basicConfig(format='%(asctime)s;%(levelname)s:%(message)s', 
> level=logging.DEBUG)
> logging.debug('Message1)
> logging.info('Message2')
> logging.warning('Message3')
>
> DEBUG:root:Message1
> INFO:root:Message2
> WARNING:root:Message3
> BUT if I remove 
> logging.basicConfig(filename='example.log',level=logging.DEBUG)
> I get 
> 2018-08-13 18:35:48,982;DEBUG:Message1
> 2018-08-13 18:35:48,982;INFO:Message2
> 2018-08-13 18:35:48,983;WARNING:Message3
>
> Can someone please tell me what I am doing wrong?
> Thanks

The logging module doesn't allow you to update its config. You're
supposed to configure all the options you want in a single call to
basicConfig (or one of the other config methods for a different way to
configure logging)


>>> import logging
>>>
logging.basicConfig(filename='example.log',level=logging.DEBUG,format='%(asctime)s;%(levelname)s:%(message)s')
>>> logging.info('Message2')
>>> logging.warning('Message3')

produces this

2018-08-13 12:52:03,330;INFO:Message2
2018-08-13 12:52:04,231;WARNING:Message3


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


Re: Guido van Rossum resigns as Python leader

2018-07-13 Thread Alexandre Brault
The important question we should ask ourselves: Do we have a replacement
Dutch person to figure out the one obvious way to do things that may not
be obvious at first?

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


Re: List replication operator

2018-05-25 Thread Alexandre Brault


On 2018-05-25 11:40 AM, bartc wrote:
> On 25/05/2018 16:27, Chris Angelico wrote:
>> You're way WAY too late to debate the matrix multiplication operator.
>
> /The/ matrix multiplication operator?
>
> In which language? And what was wrong with "*"?
>
In Python, the language we're discussing right now. What was wrong with
* is described in detail in PEP 465

> (I've implemented matrix multiply in a language (although for
> specialised matrix types), and I used the same "*" symbol as was used
> to multiply anything else.)
>
> Anyway this is not matrix multiplication, but replication, and using
> '@' seems more a consequence of there not being any better ones
> available as they are already used for other things.
>
You're right, it's not matrix multiplication. And Pathlib's use of / is
not division, nor do C++'s streams use bitshifting.
But overloading the matmul operator would allow this feature to work
without changing the syntax of the language, nor breaking existing code
(since no built-in types implement __matmul__).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Target WSGI script cannot be loaded as Python module.

2018-05-22 Thread Alexandre Brault
On 2018-05-22 02:29 PM, Νίκος wrote:
> Hello all,
>
> Iam tryign to run a bootle script iw rote as wsgi app and iam gettign the 
> follwing eroor.
>
> ===
> [Tue May 22 06:49:45.763808 2018] [:error] [pid 24298] [client 
> 46.103.59.37:14500] mod_wsgi (pid=24298): Target WSGI script 
> '/home/nikos/public_html/app.py' cannot be loaded as Python module.
> [Tue May 22 06:49:45.763842 2018] [:error] [pid 24298] [client 
> 46.103.59.37:14500] mod_wsgi (pid=24298): Exception occurred processing WSGI 
> script '/home/nikos/public_html/app.py'.
> [Tue May 22 06:49:45.763872 2018] [:error] [pid 24298] [client 
> 46.103.59.37:14500] Traceback (most recent call last):
> [Tue May 22 06:49:45.763911 2018] [:error] [pid 24298] [client 
> 46.103.59.37:14500]   File "/home/nikos/public_html/app.py", line 4, in 
> 
> [Tue May 22 06:49:45.763951 2018] [:error] [pid 24298] [client 
> 46.103.59.37:14500] import re, os, sys, socket, time, datetime, locale, 
> codecs, random, smtplib, subprocess, geoip2.database, bottle_pymysql
> [Tue May 22 06:49:45.763976 2018] [:error] [pid 24298] [client 
> 46.103.59.37:14500] ImportError: No module named geoip2.database
> ===
>
> He is the relative httpd-vhosts.conf
>
> 
> ServerName superhost.gr
>
> WSGIDaemonProcess public_html user=nikos group=nikos processes=1 threads=5
> WSGIScriptAlias / /home/nikos/public_html/app.py
>
> ProxyPass / http://superhost.gr:5000/
> ProxyPassReverse / http://superhost:5000/
>
>
> 
> WSGIProcessGroup public_html
> WSGIApplicationGroup %{GLOBAL}
> WSGIScriptReloading On
>
> Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
>
> AddHandler cgi-script .cgi .py
> AddHandler wsgi-script .wsgi .py
>
> AllowOverride None
> Require all granted
> 
> 
>
>
> Any ideas as to why iam getting the above error although i have python36 
> isntalled along with all modules? why can it find it?
How did you install geoip2? Was it by any chance in a virtual
environment? If it was, you need to tell mod_wsgi to use this virtual
environment; otherwise, it'll use the global environment that probably
doesn't have geoip2 installed

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


Re: what does := means simply?

2018-05-18 Thread Alexandre Brault
On 2018-05-18 02:48 PM, bartc wrote:
> On 18/05/2018 18:27, bartc wrote:
>
>> (BTW here's a port of that benchmark based on the Lua code:
>>
>>    https://pastebin.com/raw/ivDaKudX
>
> And here's the payoff: I was able to use this version to port it to
> Python. One which works better the the originals, as they wrote output
> to the screen (/binary/ output) which I found difficult to capture
> into an actual ppm file in order to test it worked.
>
> The translation was straightforward, EXCEPT that I wasted an hour
> trying to figure out to write /a single byte/ to a file. The following
> eventually worked, using a binary file as a text one had Unicode
> problems, but it's still hacky.
>
> Note this version doesn't use any imports at all.
Except your version doesn't read its parameter from the command line
args and doesn't output to standard output, which all of the others do.
That's why the other Python versions of that code imported sys: Because
that's how you read from commandline args and write bytes to standard
output in Python. You don't need to know *exactly* how sys works to have
an idea of what sys.argv and sys.stdout do
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why does list's .remove() does not return an object?

2018-05-17 Thread Alexandre Brault

On 2018-05-17 11:26 AM, Abdur-Rahmaan Janhangeer wrote:
> I don't understand what this would return? x? You already have x.  Is it
> meant to make a copy? x has been mutated, so I don't understand the benefit
> of making a copy of the 1-less x.  Can you elaborate on the problem you are
> trying to solve?
>
> --Ned.
>
>
> assignment to another var
>
You already have access to the list before removal, the list after
removal and the element to be removed.

Do need a copy of the list before removing x?
>>> old_list = list[:]
>>> list.remove(x)

Do you need the list after removing x?
>>> list.remove(x)  # list is the modified list

Do you need x?
>>> list.remove(x)  # x is x

What else would need to be assigned to another var?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is django-hotsauce?

2018-02-02 Thread Alexandre Brault
So it's a buzzword generator?

Alex


On 2018-02-02 04:17 AM, Etienne Robillard wrote:
> About Django-hotsauce:
>
> Scalable and high-performance WSGI microframework on top of Django and
> others: Django-hotsauce is the ultimate web development toolkit for
> rogue Python hackers and chronic weed users looking to build porn web
> sites in your mama basement! :)
>
> Typically used for advanced training of slackers, hackers, and
> unemployed people bored with life and looking to learn Schevo DBMS on
> PyPy. :)
>
> I think django-hotsauce is a great Python library for
> research/educational and experimental purpose.
>
> In specific, it is interesting to break Django ORM and use ZODB to
> develop your own models api...
>
> Anyways, have fun hacking django-hotsauce with PyPy.
>
> Hacking life is essential to happiness... :)
>
> Pragmatic hackers love to learn rogue ways to exploit Django api with
> JIT and PyPy. ;)
>
> cheers,
>
> Etienne
>
>
>
>

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


Re: why won't slicing lists raise IndexError?

2017-12-06 Thread Alexandre Brault
process() wasn't defined either, nor were n and seq and yet you're not 
complaining about them.


It seems it was clear to everyone but you that seq was a sequence 
defined elsewhere, n was an index defined elsewhere, and both process 
and do_without_item were functions defined elsewhere.


And even if you want to be so incredibly pedantic that do_without_item 
(and only do_without_item, because the rest of the code fragment seems 
to get your seal of approval) is not defined, your "functioning 
equivalent" is still not equivalent, because the original code would 
have raised a NameError that yours doesn't.



On 2017-12-06 7:05 PM, Rick Johnson wrote:

Python wrote:

[...]


THIS IS FALSE.  CALLING A FUNCTION

What *FUNCTION*?

You think you can just slap a function-y looking symbol
willy-nilly in the middle of a chunk of code and then have
it "magically" transform into a python function object?

 >>> do_without_item()

 Traceback (most recent call last):
   File "", line 1, in 
 do_without_item()
 NameError: name 'do_without_item' is not defined
 >>> foo()

 Traceback (most recent call last):
   File "", line 1, in 
 foo()
 NameError: name 'foo' is not defined
 >>> bar()

 Traceback (most recent call last):
   File "", line 1, in 
 bar()
 NameError: name 'bar' is not defined

if "do_without_item()" had been defined, then you could call
it a function. But until you do, it's just a NameError.


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


Re: Increasing the diversity of people who write Python

2017-11-27 Thread Alexandre Brault
A quick Google search turned up WinCompose. It defaults to Right-Alt for
its compose key, but that's configurable


On 2017-11-27 02:05 PM, Paul Moore wrote:
> On 27 November 2017 at 18:13, Skip Montanaro  wrote:
>>> If you have a Windows key, you can assign it to be
>>> the Compose key.
>> Would this be true on a machine running Windows? My work environment
>> has me developing on Linux, with a Windows desktop. It's not clear to
>> me that any sort of xmodmap shennanigans would work. Won't Windows
>> itself always gobble up that key?
> Programs can access the Windows key. IIRC, there is a utility that
> provides compose-key functionality on Windows. I can't recall the name
> right now and it's on my other PC, not this one, but I'll try to
> remember to post the name tomorrow...
>
> Paul

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