Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-10-02 Thread Ethan Furman via Python-list

This thread is derailing.

Please consider it closed.

--
~Ethan~
Moderator
--
https://mail.python.org/mailman/listinfo/python-list


Re: ListAdmin: Is list/archive working correctly?

2024-08-31 Thread Ethan Furman via Python-list

On 8/30/24 15:28, dn via Python-list wrote:

> The OP was @Gilmeh Serda (from an invalid email address). That appears in the 
email thread
>
> @Stefan Ram has had two contributions quoted, but no such original-message 
has appeared in the thread.

I can't speak about the archives, but I can say that Stefan's posts are discarded automatically since they are opposed 
to their words showing up on the list.


--
~Ethan~
Moderator
--
https://mail.python.org/mailman/listinfo/python-list


Re: bring back nntp library to python3

2024-08-14 Thread Ethan Furman via Python-list

On 8/14/24 15:56, Alan Gauld via Python-list wrote:

> Lots of people care but the ability to influence these
> decisions seems to have been removed far from the
> general python user community. Python has moved from
> the BDFL/Bazaar to the Committee/Cathedral. Probably
> an inevitable consequence of its current "popularity".

The move came because of the vitriol directed at the BDFL (and others) with every major (and sometimes minor) change to 
Python.


Every action has consequences, and in this case the consequence was that we are 
now run by committee.

--
~Ethan~

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


Re: bring back nntp library to python3

2024-08-14 Thread Ethan Furman via Python-list

On 8/14/24 15:32, Left Right via Python-list wrote:

> I think the right word for this is "delusional". But people get
> offended when other people use the right words. Instead they want a
> grotesque round-about way of saying the same thing...
>
> So, the grotesque round-about way of saying this, if you are still
> reading that is... Even if pip, setuptools and friends worked well
> (which they don't) there are big problems that these tools cannot
> solve:
>
> * Network partition
> * Version mismatch
> * Competition between different installer tools
> * Increased requirement for vetting and validation
> * Shortening shelf life of existing projects
>
> But hey, this is just letting off steam.

No need to hit  if you're just venting.


> Nobody cares.

Yeah, people do.

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


Re: troglodytes

2024-08-14 Thread Ethan Furman via Python-list

On 8/14/24 15:19, Left Right via Python-list wrote:
>On 8/14/24 13:26, geodandw via Python-list wrote:

>> Why do you have to belittle other people?

> Who says I have to? I like to! I like to see people driven by all
> sorts of low and reprehensible motives being punished for it. I don't
> know if I need to explain this motivation further. I think it's a very
> natural feeling. Human nature if you will. The primordial sense of
> justice, that was later developed into a bunch of different theories
> of how justice might work.

It is not necessary to belittle in order to enjoy justice.

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


Re: bring back nntp library to python3

2024-08-14 Thread Ethan Furman via Python-list

On 8/14/24 13:14, Keith Thompson via Python-list wrote:

> The rationale for removing nntplib and other modules from the default
> installation is explained in PEP 0594 .
>
> """
> The nntplib tests have been the cause of additional work in the recent
> past. Python only contains the client side of NNTP, so the tests connect
> to external news servers. The servers are sometimes unavailable, too
> slow, or do not work correctly over IPv6. The situation causes flaky
> test runs on buildbots.
> """

Sounds like we need somebody to write an NNTP server for the stdlib!  :-)

--
~Ethan~

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


Re: Couldn't install numpy on Python 2.7

2024-06-13 Thread Ethan Furman via Python-list

Hey, everyone!

I believe the original question has been answered, and tempers seem to be flaring in sub-threads, so let's call this 
thread done and move on to other interesting topics.


Thank you for your support!

--
~Ethan~
Moderator
--
https://mail.python.org/mailman/listinfo/python-list


Re: Already Subscribed and Confirmed, But ....

2024-04-03 Thread Ethan Furman via Python-list

On 4/3/24 07:15, WordWeaver Evangelist via Python-list wrote:

> Hello. I already subscribed to this list several days ago. In fact, I did it 
two times, and
> I received the email with the confirmation link in it, which I clicked on and 
was confirmed.
>
> Despite this fact, each time that I try to post a message to the list. I get 
a response from
> the python bot stating that I need to register before I can post to the list. 
As I said, I
> already did that, and I was  confirmed. I still have the email here.

Well, this post made it through fine.

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


Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Ethan Furman via Python-list

On 3/6/24 08:28, Jacob Kruger via Python-list wrote:

> C:\temp\py_try>python
> Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec  4 2023, 19:24:49) [MSC v.1937 64 
bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> from scoping2 import *

And it becomes clear:  only do `from ... import *` when the module has been 
specifically designed to support that.

If you were to also do `import scoping2` and, after calling `do_it()`, `print(scoping2.dt_expiry)`, you would see that 
it had changed.


I know there are good explanations for how variables and names work in Python, but I couldn't find any at the moment. 
Sorry.


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


Re: Can u help me?

2024-03-05 Thread Ethan Furman via Python-list

On 3/5/24 16:49, MRAB via Python-list wrote:
> On 2024-03-06 00:24, Ethan Furman via Python-list wrote:
>> On 3/5/24 16:06, Chano Fucks via Python-list wrote:
>>
>>> [image: image.png]
>>
>> The image is of MS-Windows with the python installation window of "Repair 
Successful".  Hopefully somebody better at
>> explaining that problem can take it from here...
>>
> If the repair was successful, what's the problem?

I imagine the issue is trying get Python to run (as I recall, the python icon on the MS-Windows desktop is the 
installer, not Python itself).

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


Re: Can u help me?

2024-03-05 Thread Ethan Furman via Python-list

On 3/5/24 16:06, Chano Fucks via Python-list wrote:


[image: image.png]


The image is of MS-Windows with the python installation window of "Repair Successful".  Hopefully somebody better at 
explaining that problem can take it from here...


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


CoC Warning [was: What is Install-Paths-To in WHEEL file?]

2024-01-02 Thread Ethan Furman via Python-list

On 12/29/23 05:02, Left Right via Python-list wrote:


Wow. That place turned out to be the toxic pit I didn't expect.

It's a shame that a public discussion of public goods was entrusted to
a bunch of gatekeepers with no sense of responsibility for the thing
they keep the keys to.


Personal attacks are not welcome nor tolerated.  Please be constructive when 
engaging with the community.

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


[dead thread] Re: What is Install-Paths-To in WHEEL file?

2024-01-02 Thread Ethan Furman via Python-list

This thread is no longer being useful, and is now closed.

--
~Ethan~
Moderator
--
https://mail.python.org/mailman/listinfo/python-list


Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread Ethan Furman

On 3/3/23 03:32, Chris Angelico wrote:
> On Fri, 3 Mar 2023 at 20:44, Alan Gauld wrote:
>> On 02/03/2023 20:54, Ian Pilcher wrote:

>>> Seems like an FAQ, and I've found a few things on StackOverflow that
>>> discuss the technical differences in edge cases, but I haven't found
>>> anything that talks about which form is considered to be more Pythonic
>>> in those situations where there's no functional difference.
>>
>> I think avoiding dunder methods is generally considered more Pythonic.

Outside of writing dunder methods, I tend to agree.

>> But in this specific case using isinstance() is almost always
>> the better option.

True.  IIRC, the only time I haven't used `isinstance` is in `Enum`, where a particular object has to be exactly a tuple 
(not a namedtuple, for example) to work correctly.


> Using isinstance is very different from querying the type of an object
> though. They're used for different purposes. And obj.__class__ and
> type(obj) are different too, which is why the OP specifically narrowed
> this down to the situations where you know they're the same.

When writing classes and subclasses, I use `obj.__class__`, `isinstance` otherwise, and rarely `type(obj)` (and then 
mostly with `tuple`s, as they're special).


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


Re: Python 3.10 Fizzbuzz

2023-02-27 Thread Ethan Furman

On 2/27/23 12:20, rbowman wrote:

> "By using Black, you agree to cede control over minutiae of hand-
> formatting. In return, Black gives you speed, determinism, and freedom
> from pycodestyle nagging about formatting. You will save time and mental
> energy for more important matters."
>
> Somehow I don't think we would get along very well. I'm a little on the
> opinionated side myself.

I personally cannot stand Black.  It feels like every major choice it makes (and some minor ones) are exactly the 
opposite of the choice I make.


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


Hen Hanna & google groups

2023-02-27 Thread Ethan Furman

Greetings, all!

As has been stated, Hen Hanna is posting through Google Groups, over which the 
Python List moderators have zero control.

The only thing we can do, and which has now been done, is not allow those posts 
in to the Python List.

--
~Ethan~
Moderator
--
https://mail.python.org/mailman/listinfo/python-list


Re: Not receiving posts

2023-02-23 Thread Ethan Furman

On 2/23/23 12:29, Jim Byrnes wrote:

> I have been reading the python-list for some time now. At first via gemane 
and since it's demise via a subscription.
> Recently I noticed that I have not received any emails for quite sometime.
>
> I tried resubscribing but still have received no emails from the list. To my 
knowledge I have done nothing to warrant
> removal.
>
> Can you please check and see what I need to do to start receiving emails once 
more.

It doesn't look like that address is subscribed.  I tried inviting you, let's 
see if that works.

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


Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-29 Thread Ethan Furman

This thread has run its course and seems to now be generating more heat than 
light.

It is now closed (at least on the Python List side).

Thank you everyone for your participation and understanding.

--
~Ethan~
Moderator
--
https://mail.python.org/mailman/listinfo/python-list


Re: The Zen of D.E.K.

2023-01-13 Thread Ethan Furman

On 1/13/23 09:06, Stefan Ram wrote:

>"Beautiful is better than ugly." - The Zen of Python
>
>This says nothing. You have to sacrifice something that
>really has /value/!
>
>"[A]esthetics are more important than efficiency." - Donald E. Knuth

[okay, falling for the troll bait]

Those two things do not say the same thing; further, in Python at least, and depending on the situation, aesthetics may 
/not/ be more important than efficiency.


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


Re: To clarify how Python handles two equal objects

2023-01-10 Thread Ethan Furman

On 1/10/23 12:03, Jen Kris via Python-list wrote:

> I am writing a spot speedup in assembly language for a short but 
computation-intensive Python
> loop, and I discovered something about Python array handling that I would 
like to clarify.

> But on the next iteration we assign arr1 to something else:
>
> arr1 = [ 10, 11, 12 ]
> idc = id(arr1) – 140260325308160
> idd = id(mx1[2]) – 140260325306880
>
> Now arr1 is no longer equal to mx1[2]...

If you want to have `arr1` to still be `mx1[2]` (and consequently for `mx1[2]` to now be `[10, 11, 12]` you need to 
mutate `arr1` instead of reassigning it:


arr1[:] = [10, 11, 12]

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


Re: Possible re bug when using ".*"

2022-12-28 Thread Ethan Furman

On 12/28/22 11:07, MRAB wrote:

On 2022-12-28 18:42, Alexander Richert - NOAA Affiliate via Python-list wrote:

  In a couple recent versions of Python (including 3.8 and 3.10), the
following code:
import re
print(re.sub(".*", "replacement", "pattern"))
yields the output "replacementreplacement".

This behavior does not occur in 3.6.

Which behavior is the desired one? Perhaps relatedly, I noticed that even
in 3.6, the code
print(re.findall(".*","pattern"))
yields ['pattern',''] which is not what I was expecting.


It's not a bug, it's a change in behaviour to bring it more into line with 
other regex implementations in other languages.


The new behavior makes no sense to me, but better to be consistent with the other regex engines than not -- I still get 
thrown off by vim's regex.


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


Friendly Reminder

2022-12-20 Thread Ethan Furman

Greetings, all!

I know our stress levels can be higher than normal around the holidays, but let's please be patient with each other. 
Both conversations and debates will be smoother if we assume other posters are asking/debating in good faith (at least, 
until proven otherwise).


Happy Pythoning, and happy holidays!

--
~Ethan~
Moderator
--
https://mail.python.org/mailman/listinfo/python-list


Re: mailbox misbehavior with non-ASCII

2022-07-29 Thread Ethan Furman

On 7/29/22 16:24, Peter Pearson wrote:


> ... but if the apostrophe in "a'b" is replaced with a
> RIGHT SINGLE QUOTATION MARK, the returned h is of type
> "email.header.Header", and seems to contain inscrutable garbage.
>
> I'd think an exception would be the right answer.
>
> Is this worth a bug report?

I would say yes.

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


Async SIG post

2022-04-28 Thread Ethan Furman

Anybody interested in asynchronous programming may want to check out

async-...@python.org

as it has an interesting post about ASGI and PEPs 3156 and .

Sign up at

https://mail.python.org/mailman3/lists/async-sig.python.org/

and see the archive at

https://mail.python.org/archives/list/async-...@python.org/

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


Re: Style for docstring

2022-04-22 Thread Ethan Furman

On 4/22/22 12:36, Michael F. Stemper wrote:


   Tells caller whether or not a permutation is even.

   Determines if a permutation is even. (Alternative is that it's odd.)

   Returns True if permutation is even, False if it is odd.


Third option.

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


Re: Enums and nested classes

2022-04-21 Thread Ethan Furman

On 4/21/22 15:00, Greg Ewing wrote:

On 20/04/22 10:57 pm, Sam Ezeh wrote:

Has anyone here used or attempted to use a nested class inside an enum?

If so, how did you find it? (what did you expect to happen and did
your expectations align with resulting behaviour etc.)


That's a pretty open-ended question. Is there something about
its current behaviour that you think should be different?


Indeed -- the point of the question is to (hopefully) find out what folks have already tried, and whether they found the 
current behavior surprising.  We're looking for what happened in practice, not for what should happen in theory.  ;-)


And of course, no one using enums that way means we can change how that bit 
works fairly easily.

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


Re: Proposal: Syntax for attribute initialisation in __init__ methods

2022-04-15 Thread Ethan Furman

On 4/15/22 04:19, Sam Ezeh wrote:

Elsewhere, the idea of supporting new syntax to automatically initialise
attributes provided as arguments to __init__ methods was raised.


[...]

Good post!  You'll want to send this to python-ideas at some point (that's where most new python features are 
discussed).  This particular desire has come up in the past, so you'll need to do some more research (i.e. find the 
previous threads on python-ideas) so you can answer objections already raised, or find new data supporting/refuting 
previous arguments.


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


PSA: Linux vulnerability

2022-03-08 Thread Ethan Furman

https://arstechnica.com/information-technology/2022/03/linux-has-been-bitten-by-its-most-high-severity-vulnerability-in-years/

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


Re: Behavior of the for-else construct

2022-03-03 Thread Ethan Furman

On 3/3/22 5:32 PM, Rob Cliffe via Python-list wrote:

> There are three types of programmer: those that can count, and those that 
can't.

Actually, there are 10 types of programmer:  those that can count in binary, 
and those that can't.

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


Re: Aw: PYT - How can I subscribe to a topic in the mailing list?

2022-02-27 Thread Ethan Furman

On 2/21/22 3:19 AM, vanyp wrote:

> The option to filter by topic is offered in the mailing list subscription 
customization page, although
> no option list is given. Topics may have been a project that was never 
implemented.

Topics are not currently enabled.  I suspect for them to be useful, people would have to be diligent about setting them, 
which, quite frankly, I don't see happening -- some don't even set a useful subject line.


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


Re: Best way to check if there is internet?

2022-02-07 Thread Ethan Furman

On 2/7/22 4:27 PM, Greg Ewing wrote:
> On 8/02/22 8:51 am, Chris Angelico wrote:

>> Some day, we'll have people on Mars. They won't have TCP connections -
>> at least, not unless servers start supporting connection timeouts
>> measured in minutes or hours - but it wouldn't surprise me if some
>> sort of caching proxy system is deployed.
>
> Or the internet acquires a new protocol that's designed
> for very-long-latency connections.

RocketNet -- a massive store-and-forward protocol.  ;-)

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


Re: Waht do you think about my repeated_timer class

2022-02-04 Thread Ethan Furman

On 2/4/22 6:28 AM, Cecil Westerhof via Python-list wrote:

> It was already not a good name, but I am rewriting the class
> completely, so now the name is a complete bumper. (No more timer.) I
> am thinking about naming the class repeating_thread, but I cannot say
> that I find it a very good name. So if someone has a good idea for a
> name …
>
> The class starts a thread where every by the user defined interval a
> by the user define function is called.

How about `timed_repeat` or `repeat_timer`?

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


Re: New assignmens ...

2021-10-23 Thread Ethan Furman

On 10/23/21 6:42 AM, Jon Ribbens via Python-list wrote:
> On 2021-10-23, Chris Angelico wrote:

>> The onus is on you to show that it needs to be more flexible.
>
> Is it though?

Yes.

> It seems to me that the onus is on you to show that
> this special case is special enough to be given its own unique
> existence.

It already has existence, so no further proof is needed.

> It's a bit surprising that the PEP doesn't discuss this
> decision at all.

In conversations as long as that one was, I'm not surprised this and maybe a couple other options didn't make it back to 
the PEP.  Nevertheless, I recall the decision to start simple, and expand later if needed.


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


Re: Posts from gmane no longer allowed?

2021-09-26 Thread Ethan Furman

On 9/26/21 10:34 AM, Grant Edwards wrote:
> On 2021-09-26, Ethan Furman  wrote:

>> I am unaware of a change in the newsgroup <--> mailing list policy,
>> and other newsgroup posts were coming through last week (it's been a
>> light weekend).
>
> We're not talking about the usenet<-->list gateway.

> My first _guess_ would be that Mailman started refusing emailed posts
> from the gmane server to python-list, and that triggered the gmane server
> to stop accepting posts for python-list.

I readily admit I may not understand, or know, all the usenet jargon, but looking at the Mailman server for Python list 
I see it is still fully configured to talk with News.FU-Berlin.DE, newsgroup comp.lang.python.


I'll forward the problem to the maintainers -- hopefully they'll have some 
insight.

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


Re: Subject: Re: Posts from gmane no longer allowed?

2021-09-26 Thread Ethan Furman

On 9/26/21 9:21 AM, Grant Edwards wrote:
> On 2021-09-26, Chris Angelico  wrote:

>> I'm not sure whether the policy change happened on python-list, or at
>> gmane. From the look of the error message you got, it may have
>> actually been gmane's decision. Haven't heard anything from the list
>> admins here about it, either way, so I have no idea.
>
> I'm just guessing, but I can't imagine that gmane's owner would have
> done that unless python-list itself started to refuse posts (or the
> python-list admins requested that gmane stop sending posts).

I am unaware of a change in the newsgroup <--> mailing list policy, and other newsgroup posts were coming through last 
week (it's been a light weekend).


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


Re: XML Considered Harmful

2021-09-21 Thread Ethan Furman

On 9/21/21 11:12 AM, Michael F. Stemper wrote:

> It seems to me that XML is the right approach for this sort of
> thing, especially since the data is hierarchical in nature.

If you're looking for a format that you can read (as a human) and possibly 
hand-edit,
check out NestedText:

  https://nestedtext.org/en/stable/

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


RFC for PEP 663: Improving and Standardizing Enum str(), repr(), and format() behaviors

2021-07-21 Thread Ethan Furman

PEP: 663
Title: Improving and Standardizing Enum str(), repr(), and format() behaviors
Version: $Revision$
Last-Modified: $Date$
Author: Ethan Furman 
Discussions-To: python-...@python.org
Status: Draft
Type: Informational
Content-Type: text/x-rst
Created: 23-Feb-2013
Python-Version: 3.11
Post-History: 20-Jul-2021
Resolution:


Abstract


Now that we have a few years experience with Enum usage it is time to update
the ``repr()``, ``str()``, and ``format()`` of the various enumerations by their
intended purpose.


Motivation
==

The addition of ``StrEnum`` with its requirement to have its ``str()`` be its
``value`` is inconsistent with other provided Enum's ``str``.

Having the ``str()`` of ``IntEnum`` and ``IntFlag`` not be the value causes
bugs and extra work when replacing existing constants.

Having the ``str()`` and ``format()`` of an enum member be different can be
confusing.

The iteration of ``Flag`` members, which directly affects their ``repr()``, is
inelegant at best, and buggy at worst.


Rationale
=

Enums are becoming more common in the standard library; being able to recognize
enum members by their ``repr()``, and having that ``repr()`` be easy to parse, 
is
useful and can save time and effort in understanding and debugging code.

However, the enums with mixed-in data types (``IntEnum``, ``IntFlag``, and the 
new
``StrEnum``) need to be more backwards compatible with the constants they are
replacing -- specifically, ``str(replacement_enum_member) == 
str(original_constant)``
should be true (and the same for ``format()``).

IntEnum, IntFlag, and StrEnum should be as close to a drop-in replacement of
existing integer and string constants as is possible.  Towards that goal, the
str() output of each should be its inherent value; e.g. if ``Color`` is an
``IntEnum``::

>>> Color.RED

>>> str(Color.RED)
'1'
>>> format(Color.RED)
'1'

Note that format() already produces the correct output in 3.10, only str() needs
updating.

As much as possible, the ``str()`, ``repr()``, and ``format()`` of enum members
should be standardized across the stardard library.

The repr() of Flag currently includes aliases, which it should not; fixing that
will, of course, already change its ``repr()`` in certain cases.


Specification
=

There a three broad categories of enum usage:

- standard: Enum or Flag
  a new enum class is created, and the members are used as ``class.member_name``

- drop-in replacement: IntEnum, IntFlag, StrEnum
  a new enum class is created which also subclasses ``int`` or ``str`` and uses
  ``int.__str__`` or ``str.__str__``; the ``repr`` can be changed by using the
  ``global_enum`` decorator

- user-mixed enums and flags
  the user creates their own integer-, float-, str-, whatever-enums instead of
  using enum.IntEnum, etc.

Some sample enums::

# module: tools.py

class Hue(Enum):  # or IntEnum
LIGHT = -1
NORMAL = 0
DARK = +1

class Color(Flag):  # or IntFlag
RED = 1
GREEN = 2
BLUE = 4

class Grey(int, Enum):  # or (int, Flag)
   BLACK = 0
   WHITE = 1

Using the above enumerations, the following table shows the old and new
behavior, while the last shows the final result:


+-+--+-++---+---++---+
| type   | enum repr() | enum str() | enum format() | flag repr()   | flag str() 
| flag format() |

+-+--+-++---+---++---+
| standard| 3.10 | ||   |   | 
Color.RED|GREEN| Color.RED|GREEN   |
| 
+--+-++---+---++---+
| | new  | ||   |  | 
Color.RED|Color.GREEN  | Color.RED|Color.GREEN |

+-+--+-++---+---++---+
+-+--+-++---+---++---+
| user mixed  | 3.10 | || 1 || | 1 
 |
| 
+--+-++---+---++---+
| | new  | || G

Re: Verify independence and uniform distribution of discrete values in Python?

2021-07-09 Thread Ethan Furman

From Tim Peters:

> `secrets` is just a wrapper around `random.SystemRandom`, so the
> presence or absence of `secrets` doesn't matter.
>
> As to SystemRandom, all answers depend on the quality of the platform
> os.urandom(), which Python has no control over. See my answer here,
> and the comments on it:
>
> https://stackoverflow.com/questions/20936993/

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


Re: Neither pdb or print() displays the bug

2021-06-01 Thread Ethan Furman

On 6/1/21 1:42 PM, Rich Shepard wrote:

> When I run it this is the output:
> $ python activitytypes.py 2021-06-01 13:39:10,219 -DEBUG - Start of Program
> 2021-06-01 13:39:15,229 -DEBUG - End of Program

Well, you only had two logging statements in that code -- logging is like 
print: if you want to see it, you have to call it:

logging.info('start of xx procedure')
logging.info('spam = %s', spam) # note the comma and not actual 
%-interpolation

> Obviously I have much to learn about using python's logging capabilities.
> I'll keep looking.

I'm certainly not an expert, but this is how I do it:

from logging import INFO, getLogger, Formatter, handlers

logger = getLogger()
logger.setLevel(INFO)
_handler = handlers.TimedRotatingFileHandler(
virtualenv / 'var/log/openerp/continuous_sync_records.log',
when='midnight',
backupCount=30,
)
_formatter = Formatter('%(asctime)s %(funcName)-25s %(message)s')
_handler.setFormatter(_formatter)
logger.addHandler(_handler)
del _handler, _formatter

and then in my code:

logger.info('failure converting %r to %r', target_bmp_file, target_png_file)

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


Re: Neither pdb or print() displays the bug

2021-06-01 Thread Ethan Furman

On 6/1/21 1:18 PM, Rich Shepard wrote:

> I'd appreciate recommendations on the process to find where the bug lives
> since I can't seem to find it with print() or line-by-line in pdb.

Sounds like a console issue.  Try using `logging` with a file... you could even 
use `print` with a file if you wanted to.

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


Re: Definition of "property"

2021-05-30 Thread Ethan Furman

On 5/30/21 9:57 AM, Irv Kalb wrote:

> I understand what a "property" is, how it is used and the benefits, but apparently my explanation hasn't made the 
light bulb go on for my editor.


My answer from Stackoverflow [1]:

> Properties are a special kind of attribute. Basically, when Python encounters 
the following code:
>
> spam = SomeObject()
> print(spam.eggs)
>
> it looks up eggs in spam, and then examines eggs to see if it has a __get__, 
__set__, or __delete__
> method — if it does, it's a property. If it is a property, instead of just 
returning the eggs object
> (as it would for any other attribute) it will call the __get__ method (since 
we were doing lookup)
> and return whatever that method returns.

Feel free to use that however you like.  :)

--
~Ethan~


[1] https://stackoverflow.com/a/7377013/208880
--
https://mail.python.org/mailman/listinfo/python-list


name for new Enum decorator

2021-05-27 Thread Ethan Furman

Greetings!

The Flag type in the enum module has had some improvements, but I find it necessary to move one of those improvements 
into a decorator instead, and I'm having a hard time thinking up a name.


What is the behavior?  Well, a name in a flag type can be either canonical (it represents one thing), or aliased (it 
represents two or more things).  To use Color as an example:


class Color(Flag):
RED = 1# 0001
GREEN = 2  # 0010
BLUE = 4   # 0100
PURPLE = RED | BLUE# 0101
WHITE = RED | GREEN | BLUE # 0111

The flags RED, GREEN, and BLUE are all canonical, while PURPLE and WHITE are aliases for certain flag combinations.  But 
what if we have something like:


class Color(Flag):
RED = 1# 0001
BLUE = 4   # 0100
WHITE = 7  # 0111

As you see, WHITE is an "alias" for a value that does not exist in the Flag (0010, or 2).  That seems like it's probably 
an error.  But what about this?


class FlagWithMasks(IntFlag):
DEFAULT = 0x0

FIRST_MASK = 0xF
FIRST_ROUND = 0x0
FIRST_CEIL = 0x1
FIRST_TRUNC = 0x2

SECOND_MASK = 0xF0
SECOND_RECALC = 0x00
SECOND_NO_RECALC = 0x10

THIRD_MASK = 0xF00
THIRD_DISCARD = 0x000
THIRD_KEEP = 0x100

Here we have three flags (FIRST_MASK, SECOND_MASK, THIRD_MASK) that are aliasing values that don't exist, but it seems 
intentional and not an error.


So, like the enum.unique decorator that can be used when duplicate names should be an error, I'm adding a new decorator 
to verify that a Flag has no missing aliased values that can be used when the programmer thinks it's appropriate... but 
I have no idea what to call it.


Any nominations?

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


Typing and Enum and Abstract

2021-05-20 Thread Ethan Furman

Here's a question on SO about typing, enum, and ABC:

  https://stackoverflow.com/q/67610562/208880

No answers so far.

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


Re: Proposal: Disconnect comp.lang.python from python-list

2021-05-06 Thread Ethan Furman

On 5/6/21 11:05 AM, Jon Ribbens via Python-list wrote:
> On 2021-05-06, Stestagg wrote:

>> Where's this discussion going?
>>
>> Which of the practically possible options are best for this list <->
>> newsgroup setup?
>
> And it appears even the suggestion that
> Mailman 3 cannot be used while a gateway is involved is untrue:
> https://mailman.readthedocs.io/en/latest/src/mailman/handlers/docs/nntp.html

Interesting.  I know the NNTP gateway wasn't there a couple years ago, and I do not see a date as to when that became 
possible.


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


Re: Transistion from module to package and __init__.py

2021-05-05 Thread Ethan Furman

On 5/4/21 7:20 PM, Chris Nyland wrote:

> Here is
> where I my primary design question comes in. As organized now as described
> to import and use the package I need
>
> from database import database
>
> or I have to put in the init file
>
> from database import *
>
> Either of these still leaves a database.database namespace laying about and
> to me it just seems untidy. So for a while now I have taken to converting
> my module, in this example database.py, to the __init__.py of the package.

> So I was hoping to get
> feed back from a wider audience about if there are any issues with this
> type of design that I just haven't encounter yet or find out what other
> people do with this same problem.

This is the same method I use, and it works fine for smaller packages.  I do have one package, dbf, that I am in the 
process of converting to multiple files simply because there is so much (10k lines for me, YMMV).


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


Re: [OT] Annoying message duplication, was Re: Unsubscribe/can't login

2021-05-05 Thread Ethan Furman

On 5/5/21 7:39 AM, Peter Otten wrote:
> On 05/05/2021 16:10, Ethan Furman wrote:

>> I see your messages twice (occasionally with other posters as well).  I have 
no idea how to fix it.  :(
>
> OK, I'll try another option from Thunderbird's context menu: Followup to 
Newsgroup.
>
> Does that appear once or twice?
>
> In theory it should go to the newsgroup only which would mirror it to the 
list.

Only once.

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


Re: Unsubscribe/can't login

2021-05-05 Thread Ethan Furman

On 5/5/21 5:58 AM, Peter Otten wrote:
> On 05/05/2021 13:03, Jan van den Broek wrote:
>> On 2021-05-05, Peter Otten <__pete...@web.de> wrote:

>> Perhaps there's something wrong on my side, but I'm
>> seeing this message twice:
>>
>> Msg-ID: mailman.145.1620211376.3087.python-l...@python.org
>> Return-Path: __pete...@web.de
>>
>> and
>>
>> Msg-ID: mailman.146.1620211381.3087.python-l...@python.org
>> Return-Path: python-python-l...@m.gmane-mx.org
>
> Sorry for the inconvenience.
>
> Does that happen with all my messages? I'm reading the mailing list via
> news.gmaneio.

I see your messages twice (occasionally with other posters as well).  I have no 
idea how to fix it.  :(

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


Re: do ya still use python?

2021-04-19 Thread Ethan Furman

On 4/19/21 11:22 AM, Unbreakable Disease wrote:

[offensive drivel]

List, my apologies -- not sure how that one got through.

--
~Ethan~
Python List Moderator
--
https://mail.python.org/mailman/listinfo/python-list


Re: How does "__doc__ % globals()" work?

2021-04-12 Thread Ethan Furman

On 4/12/21 3:06 PM, Jaime wrote:
> Hi all. Line 102 of https://github.com/python/peps/blob/master/pep2html.py 
says:
>
> print(__doc__ % globals(), file=out)
>
> I realise that globals() is a standard-library
> built-in function that returns a dictionary representing the current
> global symbol table, and that the result of this expression is the
> value of the dictionary where the key is "__doc__"

This is not correct.

There are a couple ways to use %-interpolation:

some_name = 'Jaime'

# simple
`hello, %s` % (some_name, )  # hello, Jaime

# keyed
`hello, %(a_name)s` % {'a_name': 'Ethan'}  # hello, Ethan

What you are seeing is the keyed version.  So, if the module had, for example:

version = 1.3
author = 'GvR'
date = '2021-04-12'

and the doc string was

__doc__ = "version %(version)s was initially created by %(author)s"

then

__doc__ % globals()

would substitute the `author` and `version` keys into __doc__, and printing 
that would yield

version 1.3 was initially created by GvR

Note that extra keys are ignored.

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


Re: Horrible abuse of __init_subclass__, or elegant hack?

2021-03-31 Thread Ethan Furman

On 3/31/21 4:14 PM, Chris Angelico wrote:

I think this code makes some sort of argument in the debate about
whether Python has too much flexibility or if it's the best
metaprogramming toolset in the world. I'm not sure which side of the
debate it falls on, though.


Well, `__init_subclass__` is there to provide metaclass power without needing a 
full-blown metaclass.

I vote elegant hack.  :)

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


Re: Why assert is not a function?

2021-03-11 Thread Ethan Furman

On 3/11/21 1:45 PM, dn via Python-list wrote:


Is assert so much faster/cheaper than try...except...raise?


Infinitely faster when they are not there.  ;-)

Basically, you are looking at two different philosophies:

- Always double check, get good error message when something fails

vs

- check during testing and QA, turn off double-checks for production for best 
performance possible.

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


editor recommendations?

2021-02-26 Thread Ethan Furman

I'm looking for an editor to use for Python programming, as well as related 
incidentals such as markdown files, restructured text, etc.

I'm currently using vim, and the primary reason I've stuck with it for so long 
is because I can get truly black screens with it.  By which I mean that I have 
a colorful window title bar, a light-grey menu bar, and then a light-grey frame 
around the text-editing window (aka the only window), and a nice, 
black-background editing area.

When I have occasionally tried other editors, they either don't support a black 
background, or the black background is only for the text-editing portion which 
leaves large portions of screen real-estate with a bright background, which is 
hard on my eyes.

So, what's the state-of-the-art with regards to editors supporting dark color 
themes?

TIA.

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


Re: name for a mutually inclusive relationship

2021-02-25 Thread Ethan Furman

On 2/25/21 7:06 PM, Joe Pfeiffer wrote:

Ethan Furman writes:



Like I said, at this moment I don't have a good example, only an awareness that 
such a thing could exist and I don't know the name for it (if it has one).

So far I have seen that there are even fewer good use-cases than I might have 
guessed, and that no one seems to have a name for the general idea.


Do you have a specific problem you're trying to solve?


No, I just came across the concept in my browsing and was wondering if there was a name 
for it.  I think the most accurate name at this point is probably "pain in the 
butt".  ;-)

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


Re: name for a mutually inclusive relationship

2021-02-24 Thread Ethan Furman

On 2/24/21 1:54 PM, 2qdxy4rzwzuui...@potatochowder.com wrote:

Ethan Furman wrote:



I didn't say it was a good example.  ;-)  Hopefully it gets the idea across.


Ditto.  ;-)

IMO, the whole idea of "my program has two options, and the user has to
specify both or neither," isn't a question of whether or not the
argument parsing library supports it, but a question of whether or not
it's a good API.


Like I said, at this moment I don't have a good example, only an awareness that 
such a thing could exist and I don't know the name for it (if it has one).

So far I have seen that there are even fewer good use-cases than I might have 
guessed, and that no one seems to have a name for the general idea.

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


Re: name for a mutually inclusive relationship

2021-02-24 Thread Ethan Furman

On 2/24/21 1:23 PM, 2qdxy4rzwzuui...@potatochowder.com wrote:


entangled (none or all):

image size override:  height   width


IMO, that's *one* option (-s 640x480 or -s 640,480), not two.  In
argparse/optparse terms, a required argument with a custom type.

(OTOH, in a GUI, it'd be two separate mandatory text fields, both
controlled (i.e., enabled or disabled) by one checkbox.)


I didn't say it was a good example.  ;-)  Hopefully it gets the idea across.

--
~Ethan~

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


Re: name for a mutually inclusive relationship

2021-02-24 Thread Ethan Furman

On 2/24/21 12:40 PM, Alan Gauld via Python-list wrote:

On 24/02/2021 16:12, Ethan Furman wrote:

I'm looking for a name for a group of options that, when one is specified, all 
of them must be specified.

For contrast,

- radio buttons: a group of options where only one can be specified (mutually 
exclusive)
- check boxes:   a group of options that are independent of each other (any 
number of
   them may be specified)

- ???: a group of options where, if one is specified, all must be specified 
(mutually
 inclusive)


Given that radio buttons and check boxes are all effectively
using boolean states, doesn't this mean none of the group
or all of the group?

In which case it's a single boolean value - a check box that
controls all options.

I suspect I'm missing something...



radio buttons (none or one):

   t-shirt size:  Small  Medium  Large


check boxes (none or one or several or all):

   sandwich toppings:  lettuce  tomato  onion  cheese


entangled (none or all):

   image size override:  height   width

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


Re: name for a mutually inclusive relationship

2021-02-24 Thread Ethan Furman

On 2/24/21 8:28 AM, 2qdxy4rzwzuui...@potatochowder.com wrote:


Entangled?


Hey, I like that one!  ;-)

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


name for a mutually inclusive relationship

2021-02-24 Thread Ethan Furman

I'm looking for a name for a group of options that, when one is specified, all 
of them must be specified.

For contrast,

- radio buttons: a group of options where only one can be specified (mutually 
exclusive)
- check boxes:   a group of options that are independent of each other (any 
number of
 them may be specified)

- ???: a group of options where, if one is specified, all must be specified 
(mutually
   inclusive)

So far, I have come up with:

- the Three Musketeers
- clique
- club
- best friends
- tight knit
- group

Is there a name out there already to describe that concept?

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


Re: Python 2.7 and 3.9

2021-02-16 Thread Ethan Furman
Kevin, please reply to the list (preferably Reply-to-list, or 
Reply-all), that way others can chime in with help.


On 2/16/21 12:55 PM, Kevin M. Wilson wrote:

Windows 7 OS, and typically run in conjunction with testing SSD', as for 
stand alone scripts.
Those require: python BogusFile.py. I too was expecting users to type: 
python my_Script.py!


I'm afraid I have no experience with the above, hopefully somebody else 
on the list does.


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


Re: Python 2.7 and 3.9

2021-02-16 Thread Ethan Furman

On 2/16/21 12:09 PM, Kevin M. Wilson via Python-list wrote:


My employer has hundreds of scripts in 2.7, but I'm writing new scripts in 3.9! 
I'm running into 'invalid syntax' errors.I have to maintain the 'Legacy' stuff, 
and I need to mod the path et al., to execute 3.7 w/o doing damage to the 
'Legacy' stuff...IDEA' are Welcome!


My first idea/request: have a blank line, a line with only a '--' 
(without quotes), and then your signature at the bottom of your posts. 
White space aids readability and readability counts.  :)


How are those scripts being run?  Microsoft Windows or Unix/Linux/BSD?

Typically, the first line of a script will say which version of Python 
is needed.  For example, on a *nix type system:


#!/usr/bin/python2

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


Re: Mr. Flibble

2021-02-15 Thread Ethan Furman

On 2/15/21 2:02 PM, Grant Edwards wrote:

On 2021-02-15, Ben Bacarisse  wrote:


You said you used Usenet (and your reply here was via Usenet).
Usenet posts to comp.lang.python don't go to the mailing list (the
"here" that Ethan is talking about).  Mails to the list /are/ sent
here, but it's one-way traffic.


That's new -- it always used to be two-way. When did it change?


It is two-way still (or we wouldn't have seen his posts to begin with).

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


Mr. Flibble

2021-02-15 Thread Ethan Furman
Thank you to those who pointed out this individual to the moderators. 
As Mr. Flibble accurately noted, he is not on the mailing list -- so his 
posts won't be here either.


--
~Ethan~
Python List Moderator
--
https://mail.python.org/mailman/listinfo/python-list


Re: help

2021-01-26 Thread Ethan Furman

On 1/26/21 9:05 AM, Terry Reedy wrote:

On 1/26/2021 4:01 AM, Maziar Ghasemi wrote:



...


Please do not repost, especially the same day.


Maziar Ghasemi appears to be a new user, and had to sign up to the Python List mailing list.  Are you seeing his request 
twice because you use gmane?


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


Re: why sqrt is not a built-in function?

2021-01-14 Thread Ethan Furman

On 1/14/21 11:06 AM, Eli the Bearded wrote:


"There should be one-- and preferably only one --obvious way to do it."

Meanwhile, Alan Gauld pointed out:

   AG> because pow() is a builtin function and
   AG> root = pow(x,0.5)
   AG> is the same as
   AG> root = math.sqrt(x)

Plus the ** operation ("root = x ** 0.5"), that's now three ways.


Yes, but which of those is obvious?

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


Re: why sqrt is not a built-in function?

2021-01-14 Thread Ethan Furman

On 1/14/21 9:44 AM, Denys Contant wrote:


I don't understand why sqrt is not a built-in function.
Why do we have to first import the function from the math module?
I use it ALL THE TIME!


And thousands, tens of thousands, and maybe hundreds of thousands don't.


That felt good. Thank you.


Any time.  ;-)

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


Re: How do you find what exceptions a class can throw?

2020-12-20 Thread Ethan Furman

On 12/20/20 6:06 PM, Julio Di Egidio wrote:


You could have taken the chance to pay attention



Programming is a *discipline*, while you keep echoing cheap and vile marketing 
nonsense.



I am sure you do, rigour mortis eventually...


Mean-spirited and hostile messages are not welcome on this list.

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


Re: dict.get(key, default) evaluates default even if key exists

2020-12-16 Thread Ethan Furman

On 12/16/20 3:08 AM, Peter J. Holzer wrote:

On 2020-12-15 13:07:25 -0800, Ethan Furman wrote:

On 12/15/20 9:07 AM, Mark Polesky via Python-list wrote:


D = {'a':1}

def get_default():
  print('Nobody expects this')
  return 0

print(D.get('a', get_default()))


Python has short-circuiting logical operations, so one way to get the behavior 
you're looking for is:

 D.get('a') or get_default()


That will call get_default for any falsey value (0, "", an empty list ...),
not just for missing values.

Which may or may not be what the OP wants.


Good point, thanks for clarifying.

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


Re: dict.get(key, default) evaluates default even if key exists

2020-12-16 Thread Ethan Furman

On 12/16/20 1:44 AM, Chris Angelico wrote:

On Wed, Dec 16, 2020 at 8:43 PM Loris Bennett
 wrote:


Paul Bryan  writes:


On Wed, 2020-12-16 at 10:01 +0100, Loris Bennett wrote:


OK, I get the point about when the default value is generated and
that
potentially being surprising, but in the example originally given,
the
key 'a' exists and has a value of '1', so the default value is not
needed.


But the function is still called. The get method just doesn't use (or
return) the value it generates because the key exists. Nevertheless,
you're passing the return value of the get_default function as an
argument.


Thus, I am still unsurprised when dict.get returns the value of an
existing key.


As am I.


What am I missing?


You'll need to tell me at this point.


I was just slow and confused, but you helped me get there in the end.  I
now realise that issue is not about the result of the dict.get(), but
rather about the fact that the method which generates the default value
is called, whether or not it is needed.

I shall remember that next time I think it might be a good idea to
define a computationally massively expensive value as a rarely needed
default :-)



Yep! That's what defaultdict can do - or if you need more flexibility,
subclass dict and add a __missing__ method.


Or, if the computationally massively expensive call uses potentially
different arguments for each invocation:

some_var = d.get('a') or cme(arg1, arg2, ...)

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


Re: dict.get(key, default) evaluates default even if key exists

2020-12-15 Thread Ethan Furman

On 12/15/20 9:07 AM, Mark Polesky via Python-list wrote:

> D = {'a':1}
>
> def get_default():
>  print('Nobody expects this')
>  return 0
>
> print(D.get('a', get_default()))

Python has short-circuiting logical operations, so one way to get the behavior 
you're looking for is:

D.get('a') or get_default()

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


Fwd: Fwd: How to specify JSON parameters in CallBack?

2020-12-13 Thread Ethan Furman

From: Caleb Gattegno
Date: Fri, Dec 11, 2020 at 5:02 PM
Subject: How to specify JSON parameters in CallBack?


Please can you suggest where should I look for advice on converting a old style web app which vends whole pages of html 
with a cgi-bin/python script invoked bypython3 server.py, into one that only serves callbacks to this Javascript AJAX 
async RPC call:


$('#compute').click(function() {
     $('#poly').val('Waiting...');

     var seq = $('#seq').val();
     console.log(seq);
     $.post('/compute', seq, function(result) {
         $('#poly').val(result.poly);
     }, 'json');
});

I don’t want to touch the html/javascript, but I’d like to update the python cgi code module to respond to the RPC call 
in the post by returning a json data structure. Poly is a string of variable length.


Many thanks
gattegnPython
--
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a conflict of libraries here?

2020-11-09 Thread Ethan Furman

On 11/8/20 9:20 PM, Chris Angelico wrote:


Perhaps, but certainly the confusion is far less when the module is
always imported as itself, and then the class is "datetime.datetime"
which nicely parallels "datetime.date" and "datetime.time".


I find doubled names such as "datetime.datetime" both jarring and visual noise.

Thankfully, we can rename modules on import:

  import datetime as dt
  import time as t
  import PIL.Image as im

As for "from blablah import *" -- that should only be done with modules specifically designed for it; having said that, 
it looks like datetime.py was so designed.  So, if I had a module making extensive use of the datetime contents, and 
wasn't using the time module, I would have no problem with "from datetime import *".  On the other hand, if datetime was 
only a small portion of my module, I would "import datetime as dt".


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


Re: Post request and encoding

2020-11-02 Thread Ethan Furman

On 11/2/20 9:32 AM, Karsten Hilbert wrote:


because .encode() does not operate in-place.


Yeah, none of the string operations do, and it's embarrassing how many times 
that still bites me.  :-/

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


Re: Best way to determine user's screensize?

2020-10-31 Thread Ethan Furman

On 10/31/20 11:24 AM, Peter J. Holzer wrote:

On 2020-10-31 11:58:41 -0500, 2qdxy4rzwzuui...@potatochowder.com wrote:



I don't think we're disagreeing too much here, either.  IMO, the user
should be in control, whether by config file or command line or
whatever,


Config files and command lines are inputs to the application. The
programmer has to decide what options to accept, what they mean and how
to process them. As far as this discussion is concerned, they are
strictly part of the application.


I'm not sure which of the above two snippets I'm (dis)agreeing with, but if the user has specified in the config file 
that they want "full screen", how does the application tell the layout manager that?


(And yes, I have three screens, and each one has a full-size window running in it.  Also, four virtual desktops, one for 
each area of interest.  I hate overlapping windows.)


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


Re: Best way to determine user's screensize?

2020-10-31 Thread Ethan Furman

On 10/30/20 6:24 PM, Grant Edwards wrote:

On 2020-10-30, flaskee via Python-list wrote:



but allow the user to alter things, via preferences.


If you want to remember when a user resizes the application and
re-open with that same geometry, that's OK. Doin't it "via
preferences" is right out.


Why is using preferences "right out"?  Is that not the user saying where they 
want the app to be positioned?

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


Re: GUI: I am also looking for a nudge into the best (GUI) direction.

2020-10-29 Thread Ethan Furman

On 10/29/20 11:30 AM, Igor Korot wrote:


If you have any further questions you can contact me directly.


Please do not.  By keeping the discussion on the list many people can 
participate and learn.

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


Re: Question on ABC classes

2020-10-22 Thread Ethan Furman

On 10/22/20 9:25 AM, Julio Di Egidio wrote:


Now, I do read in the docs that that is as intended,
but I am not understanding the rationale of it: why
only if there are abstract methods defined in an ABC
class is instantiation disallowed?  IOW, why isn't
subclassing from ABC enough?


Let's say you subclass from ABC:

  class Abstract(ABC):
  pass

Then you subclass from that:

  class Concrete(Abstract):
  pass

Then subclass from that:

  class MoreConcrete(Concrete):
  pass

If you do a

  issubclass(, ABC)

you'll get

  True

The idea behind abstract classes is the prevention of creating non-functional instances, which means if any abstract 
methods, properties, etc., are present in an abstract class, then it's instances will not be fully functional; 
contrariwise, if there are no abstract anythings in the class, then it is functional and there's no reason not to allow 
it to be created.


Put another way:  if ABC is anywhere in a class' parentage, then it is "abstract" -- the only way to tell if 
instantiating it is okay is by the presence/absence of abstract pieces in the class.


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


Re: Puzzling difference between lists and tuples

2020-09-17 Thread Ethan Furman

On 9/17/20 10:43 AM, MRAB wrote:

On 2020-09-17 17:47, Ethan Furman wrote:



The only time the parentheses are required for tuple building is when
they would otherwise not be interpreted that way:


They're needed for the empty tuple, which doesn't have a comma.


Ah, right.  Thanks.

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


Re: Puzzling difference between lists and tuples

2020-09-17 Thread Ethan Furman

On 9/17/20 8:24 AM, William Pearson wrote:


I am puzzled by the reason for this difference between lists and tuples.

A list of with multiple strings can be reduced to a list with one string with 
the expected results:



for n in ['first']:
 print n


['first'] is a list.


for n in ('first'):
 print n


('first') is not a tuple.  The tuple operator is actually the comma:

>>> not_a_tuple = ('first')
>>> type(not_a_tuple)


>>> is_a_tuple = 'first',
>>> type(is_a_tuple)


I tend to use both as it makes it stand out a bit more:

>>> still_a_tuple = ('first', )
>>> type(still_a_tuple)


The only time the parentheses are required for tuple building is when 
they would otherwise not be interpreted that way:


some_func('first', 'second')   # some_func called with two str args

some_func(('first', 'second')) # some_func called with one tuple arg

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


[closed] Final statement from Steering Council on politically-charged commit messages

2020-08-19 Thread Ethan Furman

This thread is now closed.

Thank you for your cooperation.

--
~Ethan~
Python List Moderator
--
https://mail.python.org/mailman/listinfo/python-list


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

2020-08-19 Thread Ethan Furman

On 8/19/20 12:40 PM, Tim Daneliuk wrote:

On 8/19/20 2:00 PM, Karen Shaeffer wrote:



Considering all your posts on this thread, it is reasonable to infer you have 
some ideological motivations.


My motivation was to demonstrate that if people of your ilk are free to
peddle their worldview,


Unless you know Karen personally, you don't know what her world view is. 
 Poking holes in arguments or observing what is being said does not 
require an opposing world view.


As you yourself said:


The sole relevant
demand should be civility.


Let's make sure we stay that course.

--
~Ethan~
Python List Moderator
--
https://mail.python.org/mailman/listinfo/python-list


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

2020-08-19 Thread Ethan Furman

On 8/19/20 6:35 AM, Alexandre Brault wrote:

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


An excellent summary.  Thank you.

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


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

2020-08-19 Thread Ethan Furman

On 8/19/20 2:55 AM, J. Pic wrote:


[...] but still, I
don't understand how this sentence (changed by the patch):


When writing English, follow Strunk and White.


Does "uphold relics of white supremacy" (as per the commit message).

Thanks in advance for your simple explanation (I'm not a native
english speaker).


The purported issue is that Strunk and White itself is doing the upholding.

For example, on a slightly different topic, earlier versions of S&W were 
sexist: the examples of men used positive words, while the examples of 
women used negative and subservient words.


I have not read S&W myself, and my requests for WS examples have gone 
unanswered, so I do not know about the WS aspect.


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


Re: Are instances of user-defined classes mutable?

2020-08-06 Thread Ethan Furman

On 8/6/20 7:40 AM, Robin Becker wrote:

On 06/08/2020 05:17, ZHAOWANCHENG wrote:



So are instances of user-defined classes mutable or immutable?


user class instances are clearly mutable, and in my python 3.8 you can 
do horrid things like this

>
> [snip buggy/incorrect uses of __hash__]

You can do horrid things like that clear back in Python 2, but the fault 
lies with the programmer for misusing the __dunders__.


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


Re: Fwd: [BUG] missing ')' causes syntax error on next line

2020-07-22 Thread Ethan Furman

On 7/22/20 2:57 PM, Jeff Linahan wrote:


Subscribing to the mailing list as per the bot's request and resending.


*beep* *whir*

WE ARE NOT

*click* *whi*

A BOT.

*bzzzt*

WE ARE

*bzzzt* *click*

ADVANCED LIFE

*whi*

FORMS

*click*

*beep*

.

--
~eTHAN~
pYTHON lIST mODERATOR
NoT a BoT  (i ThInK...)
--
https://mail.python.org/mailman/listinfo/python-list


Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-04 Thread Ethan Furman

On 07/04/2020 10:32 AM, Random832 wrote:


I said obvious because even if it was not obvious from the commit message 
itself, it had *already been explained* in the thread on the other mailing list


That would require Michael to have been reading the other mailing list to know 
that.  Just because the information is out there, doesn't mean everybody has 
seen it.

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


Making and seeing mistakes [was: Formal Question to Steering Council]

2020-07-03 Thread Ethan Furman

On 07/03/2020 11:57 AM, Jon Ribbens via Python-list wrote:

On 2020-07-03, Michael Torrie  wrote:



All you needed to say was, "No, she did not conflate 'White' with race."
  To say "[I] did," is a very odd thing, and certainly inaccurate. I
definitely did not conflate White with race.  Why do you think that?


Because you conflated the name of the author and race in the post
I was responding to.


That is ridiculous.  It is possible to see someone else's mistake without 
making it oneself.

Michael's mistake was assuming that the author had, in fact, conflated the 
names.

Your mistake is to assume that since the author did not make that mistake that 
Michael must have made it.

I'm sure somebody will point out what my mistake was.

Can we now drop this subthread?

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


Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-03 Thread Ethan Furman

On 07/02/2020 07:42 PM, Jon Ribbens via Python-list wrote:


She didn't - you did.


Please keep the discourse civil.  Petty taunts are not helpful.

--
~Ethan~
Python List Moderator
--
https://mail.python.org/mailman/listinfo/python-list


Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-02 Thread Ethan Furman

On 07/02/2020 12:14 PM, Michael Torrie wrote:


The fact she would conflate an
author's name with some kind of race-related thing is a bit
embarrassing, frankly.


It seems she has studied literary and English history, at least as related to 
the 20th century, so I don't think any name conflation is going on.  I have 
asked for links that would support her view as expressed in the commit message, 
but haven't yet seen any.

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


Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-02 Thread Ethan Furman

On 07/02/2020 06:39 AM, Rhodri James wrote:


We've had the requested 24 hour cooling off, and I don't imagine anyone is 
surprised that the situation remains unchanged.  The commit message that caused 
the controversy is still in the PEP repository, and is still controversial.  
Whether you think it's the best thing since the last best thing or the biggest 
load of bollocks since the last biggest load of bollocks is irrelevant.  It's 
there, it espouses a political stance, and by implication the Steering Council 
support it.

Since explicit is better than implicit :-), I would like to formally ask the 
Steering Council to answer the following questions.


An issue asking basically the same thing has been created:

  https://github.com/python/steering-council/issues/31

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


Re: Can I have a class with property named "from"

2020-06-05 Thread Ethan Furman

On 06/05/2020 03:15 PM, MRAB wrote:

On 2020-06-05 22:50, Ethan Furman wrote:



There is no workaround that allows a keyword to be used except as a keyword, other than making it a 
string.  When faced with this kind of situation myself I use a synonym, like "since", or 
a translation, like "desde".


The usual workaround is to append an underscore: 'from_'.


True, but ick.  ;-)  It's like a dangling preposition.

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


Re: Can I have a class with property named "from"

2020-06-05 Thread Ethan Furman

On 06/05/2020 02:36 PM, zljubi...@gmail.com wrote:


class abc:

 def __init__(self):
 self._from = None

 @property
 def from(self):
 return self._from

 @from.setter
 def from(self, value):
 self._from = value


I get the error SyntaxError: invalid syntax because of the property named from.
Looks like in python from is a keyword that cannot be used as a property name.

I have to create a python object from a complex (nested) json object that has many keys 
with name "from" and value of date in string format.

As I would like to keep property names as they are in the json file... is there 
a workaround?


There is no workaround that allows a keyword to be used except as a keyword, other than making it a 
string.  When faced with this kind of situation myself I use a synonym, like "since", or 
a translation, like "desde".

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


Re: Enums are Singletons - but not always?

2020-05-23 Thread Ethan Furman

On 05/23/2020 11:57 AM, Richard Damon wrote:


I don't think Python anywhere defines that a enum will be a singleton,
and you should be checking for equality (==) not identity (is)


If you're not sure, please do a little research first.  We have enough bad 
information on the 'nets already.

According to Kushal's link:


The most interesting thing about Enum members is that they are singletons.


The only time using `==` is necessary is for mixed-Enums, such as IntEnum, and 
you need to compare what could be an IntEnum member in code that could be using 
actual `int`s.

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


Re: Strings: double versus single quotes

2020-05-19 Thread Ethan Furman

On 05/19/2020 11:40 AM, Joel Goldstick wrote:


I thought triple quotes are for docstrings?


It's the recommendation, but double and single quotes work just fine, too -- at 
least for docstrings that fit an one line.

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


Re: Sphinx plugin to make easier-to-navigate class documentation

2020-05-18 Thread Ethan Furman

On 05/18/2020 09:46 AM, Kale Kundert wrote:


I'm writing to share a Sphinx plugin I wrote, which I think makes the
documentation for large classes much easier to navigate and understand.  The
plugin is called `autoclasstoc` and you can find the documentation here:

https://autoclasstoc.readthedocs.io/en/latest/


This sounds pretty cool!  You should also post this on

  python-announce-l...@python.org

to reach a wider audience.

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


Re: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)

2020-03-19 Thread Ethan Furman

On 03/19/2020 02:09 AM, Terry Reedy wrote:

On 3/18/2020 10:28 PM, Santiago Basulto wrote:


For dictionaries it'd even be more useful:
 d = {
 'first_name': 'Frances',
 'last_name': 'Allen',
 'email': 'fal...@ibm.com'
 }
 fname, lname = d[['first_name', 'last_name']]


Insert ordered dicts make this sort of thing less useful.

 >>> d = {
     'first_name': 'Frances',
     'last_name': 'Allen',
     'email': 'fal...@ibm.com'
}
 >>> fname, lname, _ = d
 >>> fname, lname
('first_name', 'last_name')


I disagree -- the ordered dict would have to be small (maybe five entries) and 
one would have to know the insertion order.

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


Re: Reduce waiting queue at supermarket from Corona with Python-Webapp

2020-03-16 Thread Ethan Furman

On 03/16/2020 01:16 PM, Barry Scott wrote:


If you search google for a shop the right hand panel has a popular times
sections that tells you how busy the store typically is and the current busyness
estimate. Is that what you are after?


I suspect that's the general idea, only in real-time.

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


Re: Reduce waiting queue at supermarket from Corona with Python-Webapp

2020-03-16 Thread Ethan Furman

On 03/16/2020 01:52 PM, Orges Leka wrote:


Following your reasoning, then radar detection apps / wikipedia / facebook,
which crucially depend on user generated content should not work


Those are global apps, and one user's content can be useful in another user's 
country.

Who's shopping at the grocery store 100 miles away from me is useless.

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


Re: [Mostly OT] Feedback on Python homework using Canvas LMS

2020-03-16 Thread Ethan Furman

On 03/16/2020 11:31 AM, Irv Kalb wrote:


The problem is that in the feedback section for homework assignments, Canvas
 eliminates any leading space characters.  So, I might write:

if x == y:
 # do thing 1
else:
 # do thing 2

but when it gets posted and viewed by the student, it shows up as:

if x == y:
# do thing 1
else:
# do thing 2


Sounds like HTML display -- have you tried enclosing your snippets in  or 
 tags?

If that fails, are embedded spaces retained?  If so, maybe

.if x == y
.# do thing 1
.else:
.# do thing 2

That would make less work after copy pasting, at least.

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


Re: Help building python application from source

2020-03-07 Thread Ethan Furman
On 03/03/2020 01:50 PM, Marco Sulla via Python-list wrote:

> People of Python List, I strongly discourage you to support this user.
> He is quite suspicious for the following reasons:

Marco, this is not an appropriate response.  If you have concerns about list 
behavior then email the list owners.  If you have evidence of wrong-doing then 
email the list owners and do what you can to contact the appropriate 
authorities.

Asking the list to not help someone because you disagree with their beliefs 
will not be tolerated.  Consider this your warning.

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


wxjmfauth posts

2020-03-07 Thread Ethan Furman

All,

wxjmfauth is a known troll who posts on the usenet comp.lang.python.  Their 
posts are discarded from Python List.

If you choose to interact with them anyway, please:

- leave `wxjmfauth` in the attribution lines so those replies can be discarded
- keep your discourse civil

Thank you.

--
~Ethan~
Python List Moderator
--
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >