[Python-ideas] Re: Add a replace method to tuples

2022-03-15 Thread wfdc via Python-ideas
> think about 75% of the time "why are they doing this silly approach?" and 25% > "this is easy enough as is." None of them made me think "I wish I had a > method/function."___ Python-ideas mailing list -- pyth

[Python-ideas] New Tool Proposal

2022-05-10 Thread anthony.flury via Python-ideas
A proposal for a new tool to be implemented  - It is often the case that developer write Code in Python and then convert to a C extension module for performance regions. A C extension module has a lot of boiler plate code - for instance the Structures required for each class, the functions

[Python-ideas] Python array multiplication for negative values should throw an error

2022-05-31 Thread fjwillemsen--- via Python-ideas
Hopefully this is not a duplicate of an existing thread or in the wrong section, first time posting here. In Python, array multiplication is quite useful to repeat an existing array, e.g. [1,2,3] * 2 becomes [1,2,3,4,5,6]. Multiplication by 0 yields an empty array: [1,2,3] * 0 becomes

[Python-ideas] Re: Python array multiplication for negative values should throw an error

2022-05-31 Thread fjwillemsen--- via Python-ideas
Thanks for your response. While legacy production code is always an issue with potentially breaking changes, this line of thought would mean that future versions of Python could never introduce breaking changes. This should not be the case and is not the case now: for new Python versions

[Python-ideas] Re: Python array multiplication for negative values should throw an error

2022-05-31 Thread fjwillemsen--- via Python-ideas
programmers' part and Python's lack of strict typing. However, raising an error on negative multiplication would immediately make it clear what is wrong, instead of hiding it. _______ Python-ideas mailing list -- python-ideas@python.org To unsubscri

[Python-ideas] Custom unpickler and pickler for the shelve module

2022-11-17 Thread furkanonder via Python-ideas
Unpickler) as sh: squared = lambda x: x ** 2 sh['test_key'] = squared I could easily solve this problem I had while using the Shelve module. I believe that shelve module will be a more useful module by adding support for custom unpickler and pickler. Kindest regards, Furkan Onder_

[Python-ideas] Re: Proposal: -X importcache to supplement -X importtime for loaded modules

2023-02-14 Thread anthony.flury via Python-ideas
cisions, but it seems if this really is only a couple of lines, and all the test cases pass this (or something very similar) should be a considered for 3.12. Thank you Noah, -- Original Message -- From: "Noah Kim" To: python-ideas@python.org Sent: Saturday, 11 Feb, 23 At 00:

[Python-ideas] Native support of YAML in Python STDLIB

2023-03-13 Thread scott.fields--- via Python-ideas
Though this has been discussed before, the last detailed discussion appears to have been roughly 9 years ago. YAML is a technical standard widely used in various projects and at least two major ones (Ansible and containers). Though PyYAML has become ubiquitous as the primary Python solution to

[Python-ideas] Warn when iterating over an already exhausted generator

2023-06-12 Thread BoppreH via Python-ideas
This is my first post to this list, apologies in advance if this is the wrong place or it's a known topic that my search failed to find. As a Python user since 2.6, I make stupid mistakes with exhausted generators more often than I'd like to admit: numbers = (i for i in range(5)) as

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-12 Thread BoppreH via Python-ideas
empty list. BoppreH On Mon, Jun 12, 2023, at 10:11 PM, Barry wrote: > > > > On 12 Jun 2023, at 16:55, BoppreH via Python-ideas > > wrote: > > > > Then the empty list creates hard-to-track bugs. I'm familiar with the > > iterator protocol and why the

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread BoppreH via Python-ideas
via Python-ideas wrote: > > Also the OP's request was for generators, not for any iterator. > > IMO it would be a bad idea to make generators behave differently > from other iterators in this regard. And it's far too late to > redefine the iterator protocol in general, becaus

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread BoppreH via Python-ideas
would already be helpful, like Go's race condition detector. -- BoppreH___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at http

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread BoppreH via Python-ideas
> In close to 10 years of experience with python I have never encountered > anything like this. Here's a small selection of the StackOverflow questions from people who encountered this exact issue: https://stackoverflow.com/questions/25336726/why-cant-i-iterate-twice-over-the-same-i

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread BoppreH via Python-ideas
Sorry, I'm new to the list and was not aware the burden of proof was so high. Can you point me to one or two successful posts in Python-ideas where I can learn how to show there's a real need for a feature? On Tue, Jun 13, 2023, at 11:25 PM, Chris Angelico wrote: > On Wed, 14 Jun

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread BoppreH via Python-ideas
I'd love to stay and improve the points you mentioned, but to be honest I started regretting this thread when the first reply was a counter-example that didn't work. And then Chris' messages started rolling in. If anybody wants to take the idea forward, be my guest. ___

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-24 Thread anthony.flury via Python-ideas
ll then no parser is clever enough to diagnose all possible side effects of calling bar() twice, or even detect that bar can be cached, so it will always be called twice. In Python then a better way might be result = temp := bar() if temp else default This way only bar() and default are evaluated a

[Python-ideas] Re: Descriptor __get__ and __set__ argument discrepancy

2023-10-18 Thread dn via Python-ideas
On 19/10/2023 18.29, Dom Grigonis wrote: def __get__(self, instance, owner): def __set__(self, instance, value): Is there a reason why `__set__` does not have owner in it’s arguments while `__get__` does? Is this a Python Idea? You may have only given us a couple of lines, when the scope

[Python-ideas] Re: Descriptor __get__ and __set__ argument discrepancy

2023-10-19 Thread dn via Python-ideas
, but it is significantly easier to understand than what we had to do 'before'. Another surprise, and I've assumed you're asking in the context of [Custom] Descriptors, is in how many places/functions Python makes use of a descriptor/descriptor protocol. Yet few of us seem

[Python-ideas] Re: Descriptor __get__ and __set__ argument discrepancy

2023-10-19 Thread dn via Python-ideas
On 19/10/2023 20.43, Dom Grigonis wrote: On 19 Oct 2023, at 10:27, dn via Python-ideas wrote: On 19/10/2023 19.50, Dom Grigonis wrote: Thank you, Good information, thank you. Was not aware of __set_name__. IIRC that was one of the updates/improvements. Thanks to whomsoever...! The

[Python-ideas] Re: Extract variable name from itself

2023-11-08 Thread anthony.flury via Python-ideas
o the user_name variable will only have the name 'person_name', but not user_name, as the field objects need to know their names on the model (and their names on the views/forms). -- Original Message -- From: "Rene Nejsum" To: python-ideas@python.org Sent: Saturday,

[Python-ideas] PEP 533 Redux?

2020-12-31 Thread Paul Bryan via Python-ideas
dress this issue? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives

[Python-ideas] Re: PEP 533 Redux?

2020-12-31 Thread Paul Bryan via Python-ideas
> From: Paul Bryan via Python-ideas > Sent: Thursday, December 31, 2020 12:06 PM > To: python-ideas@python.org > Subject: [EXTERNAL] [Python-ideas] PEP 533 Redux?  > I've now encountered an issue I believe that PEP 533 was intended to > address: > > When

[Python-ideas] Re: Standard tool for iterating over recursive data structures?

2021-01-01 Thread Samuel Freilich via Python-ideas
g to me, though it's only O(n*d) where d is the nesting depth, not O(n^2)): https://github.com/python/cpython/blob/3bf05327c2b25d42b92795d9d280288c22a0963d/Objects/object.c#L1974 copy.deepcopy keeps track with a dict: https://github.com/python/cpython/blob/3bf05327c2b25d42b92795d9d280288c22a0963

[Python-ideas] Re: Python with braces formal proposal?

2021-01-05 Thread Ronald Oussoren via Python-ideas
gt;> >>> There're tons of projects which introduce alternative braces >>> (i.e. C-like) syntax for Python. Most of them are however not >>> properly documented, and definitely not spec'ed for what they do. >>> >>> I wonder, does anyone here

[Python-ideas] Re: Python with braces formal proposal?

2021-01-05 Thread Ronald Oussoren via Python-ideas
2nd level miss about this miss. I'm not the 1st >>> asking about braces in Python, hundreds of people embraced braces >>> (sorry for the pun) in Python for decades (references are in other >>> messages of this thread). Apparently, they forgot to ask for >>> &q

[Python-ideas] Re: Add a "closed for" loop (was "PEP 533 Redux?")

2021-01-06 Thread Paul Bryan via Python-ideas
re would be no backwards incompatibility. > > If we want to get really crazy we can also allow an "open for" loop > and kick off a very long deprecation process where eventually an > unadorned for loop would become "closed" by default. > > Thanks, > B

[Python-ideas] dataclass: __init__ kwargs and Optional[type]

2021-01-24 Thread Paul Bryan via Python-ideas
dataclass decorator parameter like "init_kwonly" (default=False to provide backward compatibility) that if True would implement this behavior. Thoughts? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-id

[Python-ideas] Re: dataclass: __init__ kwargs and Optional[type]

2021-01-24 Thread Paul Bryan via Python-ideas
The main benefits of this proposal: - the order of fields (those with defaults, those without) is irrelevant - don't need to pedantically add default = None for Optional values On Sun, 2021-01-24 at 19:46 +, Paul Bryan via Python-ideas wrote: > I've created a helper class in m

[Python-ideas] Re: dataclass: __init__ kwargs and Optional[type]

2021-01-25 Thread Paul Bryan via Python-ideas
Eric > On 1/24/2021 3:07 PM, Paul Bryan via Python-ideas wrote: > > The main benefits of this proposal: > > - the order of fields (those with defaults, those without) is > irrelevant > - don't need to pedantically add default = None for Optional values > &

[Python-ideas] Re: Conditional with statements

2021-02-12 Thread Rob Cliffe via Python-ideas
want to illustrate this with a bit of actual code from one of my programs.  It uses lines up to 102 characters including 12-space indentation.  Oh, and it breaks another Python shibboleth - not having multiple statements on one line.  Apologies, it looks horrible in an e-mail with the spacing

[Python-ideas] Re: Conditional with statements

2021-02-14 Thread Rob Cliffe via Python-ideas
re treated similarly*.  This is just an amorphous mass of code that I find much harder to grok. (YMMV but I find it hard to imagine.) Rules are all very well, but "A Foolish Consistency is the Hobgoblin of Little Minds" [PEP 8] Best wishes Rob PS Can anyone shed any light on why Alt-R d

[Python-ideas] Re: Conditional with statements

2021-02-15 Thread Rob Cliffe via Python-ideas
d.process_keystroke(ch) Of course, you'd need this kind of "switch" construct in the object class anyway. Unless you wanted to get really wordy, and have: def process_A(self..)     ... def process_B(self...)     ... you could be a bit saved in Python: getattr(selected_object, "

[Python-ideas] Re: Arrow functions polyfill

2021-02-15 Thread Rob Cliffe via Python-ideas
I'd like '->' much better than '=>'. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Me

[Python-ideas] Re: Alternate lambda syntax

2021-02-16 Thread Rob Cliffe via Python-ideas
_function = def x, y: x * y That seems sensible, if there is no syntactical ambiguity. Parentheses on the parameter list could be allowed as well. Yes please!  That is a feature of Python 2 that I miss in Python 3. Javascript has (too much) flexibility in this area, but I wouldn't

[Python-ideas] Re: Conditional with statements

2021-02-16 Thread Rob Cliffe via Python-ideas
27;re appropriate*; I've done it many times.) I'm not sure I'd call it "tricks" -- but anyway, I've found that big nested ifelses are rarely the cleanest solution -- but not never. - Chris B. -- Christopher Barker, PhD (Chris) Python Language Consulting   - Tea

[Python-ideas] Re: SimpleNamespace vs object

2021-02-22 Thread Rob Cliffe via Python-ideas
  None of the other names IMO convey the intended/suggested use nearly as well. Rob Cliffe _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/pyth

[Python-ideas] Re: Arrow functions polyfill

2021-02-23 Thread Rob Cliffe via Python-ideas
nverters such as pyupgrade will be quick to replace lambdas (and people publishing libraries will have to wait until the EOL of the older versions of Python before being able to run it). And if, otherwise, there is no such consensus, the change will never happen. Same as u"xxx" ver

[Python-ideas] Re: Arrow functions polyfill

2021-03-11 Thread Rob Cliffe via Python-ideas
On 24/02/2021 14:04, Random832 wrote: On Tue, Feb 23, 2021, at 17:01, Rob Cliffe via Python-ideas wrote: As far as I know, there is no case of valid syntax using 'lambda' where replacing 'lambda' by 'def' results in valid syntax. Can anyone provide a counter-ex

[Python-ideas] Re: Implicit line continuation for method chaining

2021-03-12 Thread Rob Cliffe via Python-ideas
Hi, It's becoming more popular in Python to have interfaces which are built around method chaining as a way of applying operations to data. For example in pandas is moving more towards a default model where methods do not change the object in-place but instead return an altered version (or

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-03-15 Thread Rob Cliffe via Python-ideas
Python is the ability to query, introspect, and modify Python code.  It helps with debugging, with experimenting, with fixing.  Indeed, one of the few frustrating bits about Python is the inability to work with the C portions as easily as the Python portions (note: I am /not/ suggesting we do

[Python-ideas] Itertools generator injection

2021-03-19 Thread Alastair Stanley via Python-ideas
for a in f1(): for b in f2(): yield (a, b) ``` Would others find this useful? Are there any drawbacks I'm missing? Best, Alastair ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-id

[Python-ideas] Re: Improve the textual representation of IPv4-mapped IPv6 addresses

2021-03-25 Thread Ronald Oussoren via Python-ideas
> On 18 Mar 2021, at 11:07, Maxime Mouchet wrote: > > Hi, > > Python supports IPv4-mapped IPv6 addresses as defined by RFC 4038: > "the IPv6 address :::x.y.z.w represents the IPv4 address x.y.z.w.” > > The current behavior is as follows: > >

[Python-ideas] Re: On function signature mismatch, include candidate function in traceback

2021-04-20 Thread Rob Cliffe via Python-ideas
d be less helpful. Rob Cliffe There are situations (e.g. monkey patch) where this is not obvious. Would be great detail to include that in the traceback, I think. Best Pol _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe se

[Python-ideas] Re: Support more conversions in format string

2021-04-21 Thread Rob Cliffe via Python-ideas
x27;{x} is {x!lc} in lowercase' just by registering 'lc' as a conversion from my code. Chaining then per Serhiy's other suggestion would bring a fair amount of power. Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-idea

[Python-ideas] Re: Changing The Theme of Python Docs Site

2021-04-30 Thread Rob Cliffe via Python-ideas
wanted to use a stronger expression) is an SaaS? I'd never heard of it. OK, Google told we what it stood for, but I don't feel any the wiser. Rob Cliffe _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to pyt

[Python-ideas] Re: String comprehension

2021-04-30 Thread Rob Cliffe via Python-ideas
For those cases where you're merging literal parts and generated parts, it may be of value to use an f-string: >>> f"[{','.join('0123')}]" '[0,1,2,3]' The part in the braces is evaluated as Python code, and the

[Python-ideas] Re: Changing The Theme of Python Docs Site

2021-05-02 Thread Rob Cliffe via Python-ideas
On 02/05/2021 20:07, Abdur-Rahmaan Janhangeer wrote: Oh seems like you are a dinosaur needing some carbon dating. Thanks for the insult. Rob Cliffe ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python

[Python-ideas] Re: Namespaces!

2021-05-04 Thread Rob Cliffe via Python-ideas
ully understand the proposal and how it would be implemented, but IMO adding an overhead (not to mention more complicated semantics) to *every* chained attribute lookup is enough to kill the proposal, given that it seems to have relatively slight benefits. Best wishes Rob Cliffe __

[Python-ideas] Re: Add a mechanism so that multiple exceptions can be caught using `except E1, E2, E3:`

2021-05-10 Thread Rob Cliffe via Python-ideas
ror as err How long will it be before people, fooled by the similarity to other uses of `as`, try writing this: except ValueError as verr, KeyError as kerr, TypeError as terr and how soon after that before people propose it as an actual feature? but the editor won't show it up (s

[Python-ideas] Re: division of integers should result in fractions not floats

2021-05-14 Thread Rob Cliffe via Python-ideas
F(1,2) ? Rob Cliffe ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/46U4V4PPFBDL

[Python-ideas] Re: New Idea: A safe keyword to execute the following statement in a failsafe mode.

2021-05-23 Thread Ricky Teachey via Python-ideas
try: >element = some_list[index]/divisor >except ZeroDivisionError: >element = 0 # It will make element zero if divisor is zero, > but it will not except IndexError in case index is out of range for > some_list > *Can be rewritten as:* >e

[Python-ideas] Re: New Idea: A safe keyword to execute the following statement in a failsafe mode.

2021-05-23 Thread Irit Katriel via Python-ideas
On Sunday, May 23, 2021, 02:23:05 PM GMT+1, Shivam Saini wrote: >> Like the first example in which I am sending an log, which isn't important.  If the log is not important, then why are you sending it? ___ Python-ideas m

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-25 Thread Rob Cliffe via Python-ideas
high. But then on the other hand, who would ever want to change the value of pi? Surely you recall the Indiana Pi Bill? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Rob Cliffe via Python-ideas
fused as to what the proposal is as anybody else. Rob Cliffe On 26/05/2021 14:20, Steven D'Aprano wrote: On Wed, May 26, 2021 at 12:53:32PM -, Shreyan Avigyan wrote: I've already given one. Since Python is dynamically typed changing a critical variable can cause huge instability. Wa

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Ronald Oussoren via Python-ideas
the end of the > program. Well Python also kind of has that functionality. Python's default > values provide the same type of functionality but it's a *hack* and also > *problematic* because only mutable types that are mutated persists. Static > should behave much like Python

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-27 Thread Rob Cliffe via Python-ideas
On 26/05/2021 08:25, Shreyan Avigyan wrote: Reply to Chris: There are two things I want to say about constants :- 1) Global-Local Constants - The ALL_CAPS convention variables should become constant. Good luck enforcing that on every Python programmer.  Should it apply to variable names

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Ronald Oussoren via Python-ideas
ck by caching values in the VM. Ronald — Twitter / micro.blog: @ronaldoussoren Blog: https://blog.ronaldoussoren.net/ ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/m

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Ronald Oussoren via Python-ideas
> On 27 May 2021, at 11:42, Chris Angelico wrote: > > On Thu, May 27, 2021 at 7:20 PM Ronald Oussoren via Python-ideas > wrote: >> On 27 May 2021, at 09:56, Shreyan Avigyan wrote: >> >>> Static should behave much like Python's for loop variable

[Python-ideas] Re: Add static variable storage in functions

2021-05-28 Thread Ronald Oussoren via Python-ideas
o locals than globals and builtins, or at least > no worse. So it is a fair expectation that any time you can turn a > global lookup into a local lookup, you should have some performance > benefit. It is a performance hack regardless. There are other solutions possible, includi

[Python-ideas] Re: Add static variable storage in functions

2021-05-28 Thread Ronald Oussoren via Python-ideas
> On 27 May 2021, at 18:15, Steven D'Aprano wrote: > > On Thu, May 27, 2021 at 04:53:17PM +0200, Ronald Oussoren via Python-ideas > wrote: > >> Statics are still hidden global state > > How are they *global* state when they are specific to an individual >

[Python-ideas] Re: A __decoration_call__ method for Callable objects (WAS: Decorators on variables)

2021-05-28 Thread Rob Cliffe via Python-ideas
will be better received by more if the type hint is required?). Please, please, please, don't ever make type hints *required*!  Some of us are perfectly happy not using them (and not having to learn them)! Rob Cliffe _______ Python-ideas mailing list

[Python-ideas] Re: Cleaner tracebacks from Python code

2021-05-29 Thread Irit Katriel via Python-ideas
See this issue:  https://bugs.python.org/issue31299 On Saturday, May 29, 2021, 07:19:32 PM GMT+1, André Roberge wrote: With CPython, tracebacks obtained from code written in C can be extremely clean compared with functionally equivalent code written in Python.  Consider the

[Python-ideas] Re: A __decoration_call__ method for Callable objects (WAS: Decorators on variables)

2021-05-29 Thread Rob Cliffe via Python-ideas
; spam # No problem Rob Cliffe But this is introducing a new multiline syntax, and it makes no more sense to take away the second line and expect a naked decorator to be valid than it does remove the decorator and expect the naked identifier to be valid. ______

[Python-ideas] Re: Cleaner tracebacks from Python code

2021-05-29 Thread Irit Katriel via Python-ideas
ré Roberge wrote: What I am interested in is having a project-agnostic standardised Python way to specify what to show to an end-user when an exception is raised. _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email

[Python-ideas] Re: Pre PEP: Python Literals (was custom strings before)

2021-06-10 Thread Rob Cliffe via Python-ideas
I am concerned that we have too many string formatting methods:     % formatting     .format()     f-strings     string templates (are there others I've missed?). And now we have another proposed one. It's all getting a bit much.  And IMO a turnoff for people learning Python (which on

[Python-ideas] Re: Deprecate sum of lists

2021-06-16 Thread Rob Cliffe via Python-ideas
nti-pattern and how to correct it. So I propose moving (eventually) to the same system with lists as for strings. Or else removing the performance trip-hazard from the sum function with lists. Best regards, Oliver _______ Python-ideas mailing lis

[Python-ideas] Re: Deprecate sum of lists

2021-06-18 Thread Rob Cliffe via Python-ideas
On 18/06/2021 16:42, Mathew Elman wrote: I don't see how allowing [x, y for x in a] follows from allowing [*chunk for chunk in list_of_lists]. Nor do I. Rob Cliffe ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe se

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Rob Cliffe via Python-ideas
ent against [*chunk for ...], but it does show that there's no straightforward explanation of its meaning through equivalence (like the OP seemed to think), and I think this is what Serhiy was also getting at in his post. __ [1] Does the unary star operator have a name when used li

[Python-ideas] Re: Extension methods in Python

2021-06-20 Thread Rob Cliffe via Python-ideas
say I created a library that builds html from python code, with a nice builder interface: class Html: def __init__(self): self.__items = [] def add_p(self, text): self.__items.append(text) return self def add_h1(self, text): self.__i

[Python-ideas] Re: Extension methods in Python

2021-06-24 Thread Rob Cliffe via Python-ideas
On 24/06/2021 12:44, Richard Damon wrote: On 6/24/21 7:09 AM, Simão Afonso wrote: On 2021-06-24 20:59:31, Steven D'Aprano wrote: Seriously, there's a time to realise when arguments against a feature devolve down to utterly spurious claims that Python programmers are idiots w

[Python-ideas] Re: Implementing a 'but' statement in for-iterations

2021-06-28 Thread Rob Cliffe via Python-ideas
rd by reusing one that can't go there, like except? for i in range(0,10) except (2, 8): don't know if it is actually worth it, but at least it doesn't add a new keyword. ___ Python-ideas mailing list -- python-ideas@python.org To

[Python-ideas] Re: Pre PEP: Python Literals (was custom strings before)

2021-07-02 Thread Rob Cliffe via Python-ideas
On 02/07/2021 08:12, Thomas Güttler wrote: Hi Nick and all other Python ideas friends, yes, you are right. There is not much difference between PEP-501 or my proposal. One argument why I would like to prefer backticks: Some IDEs detect that you want to use a f-string automatically: You

[Python-ideas] Re: Python Documentation in Bengali (translation)

2021-07-13 Thread Julien Palard via Python-ideas
Hi, Le 7/11/21 à 6:19 PM, sharifmehed...@outlook.com a écrit : > I am preparing a team to start translating python documentation to Bengali. > > I'd appreciate some reference materials, comments and ideas about this. Looks like [1] Kushal Das is the current contact for Benga

[Python-ideas] Re: startswith() and endswith() methods returning the matched value

2021-08-09 Thread Samuel Freilich via Python-ideas
ion of that). For > instance: > > domain.findsuffix((".fr", ".com", ".org")) > > ChrisA > ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le.

[Python-ideas] Re: startswith() and endswith() methods returning the matched value

2021-08-09 Thread Samuel Freilich via Python-ideas
't understand why my comment > about "can be used eg for indexing" was being quoted for context > there. I was talking about how you could do something like this: > > protocol = ("ws:", "wss:")[url.startswith("https:")] > > If the return value changes, this breaks.

[Python-ideas] Re: C API for converting Python integers to/from bytes sequences

2021-08-11 Thread Ronald Oussoren via Python-ideas
> On 8 Aug 2021, at 18:53, Serhiy Storchaka wrote: > > 08.08.21 07:08, Stephen J. Turnbull пише: >> Serhiy Storchaka writes: >> >>> Python integers have arbitrary precision. For serialization and >>> interpolation with other programs and libraries we nee

[Python-ideas] Re: Request for help

2021-08-16 Thread Alan Gauld via Python-ideas
On 16/08/2021 16:54, Mebale Tsige Araya wrote: > Is there anybody who can help me, please? Can I run Python codes on > Browser, please? If so could you have any idea how to run my codes on > Browser? Your question could mean several different things. I'll give very brief answers

[Python-ideas] Re: New 'How to Write a Good Bug Report' Article for Docs

2021-08-16 Thread Rob Cliffe via Python-ideas
g/en-US/docs/Mozilla/QA/Bug_writing_guidelines> > > > Is there a reason why we can't just link to the Wayback Machine copy like > you did here? > > > > > ___ Python-ideas mailing li

[Python-ideas] We should have an explicit concept of emptiness for collections

2021-08-22 Thread Tim Hoffmann via Python-ideas
Hi all, The Programming Recommendations section in PEP-8 states "For sequences, (strings, lists, tuples), use the fact that empty sequences are false:" # Correct: if not seq: if seq: # Wrong: if len(seq): if not len(seq): In the talk "When Python Practices Go

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-23 Thread Tim Hoffmann via Python-ideas
u have to change a check `if values` to `if len(values) == 0`. That works for both but is against the PEP8 recommendation. This is a shortcoming of the language. _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-23 Thread Tim Hoffmann via Python-ideas
My conclusion (and thus proposal) differs from the video. On a technical level, everything can be solved with the current language capabilities. The main advantage is clearer semantics (explicit is better / readability counts): - Re bool: As experienced python users we are used to translate `if not

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-23 Thread Tim Hoffmann via Python-ideas
empty()" method. However, defining a method downstream breaks duck typing and maybe even more important authors have to mentally switch between the two empty-check variants `if users` and `if users.is_empty()` depending on the context. Ethan Furman wrote: > On 8/23/21 1:15 PM, Tim

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-23 Thread Tim Hoffmann via Python-ideas
Ethan Furman wrote: > On 8/23/21 2:31 PM, Tim Hoffmann via Python-ideas wrote: > > Ethan Furman wrote: > > > It seems to me that the appropriate fix is for numpy to have an > > > "is_empty()" function > > that knows how to deal with arrays and array-like

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-24 Thread Tim Hoffmann via Python-ideas
, even if it did exist. As written in another post here, `len(container) == 0` is on a lower abstraction level than `isempty(container)`. ___________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@py

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-24 Thread Tim Hoffmann via Python-ideas
hird party libs to adopt that convention as well. That would give a uniform syntax by convention. Reflecting the discussion in this thread, I now favor variant 3). Tim _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-24 Thread Tim Hoffmann via Python-ideas
Ethan Furman wrote: > On 8/24/21 3:03 PM, Tim Hoffmann via Python-ideas wrote: > > **How do you check if a container is empty?** > > IMHO the answer should not depend on the container. > I think this is the fly in the ointment -- just about everything, from len() > to bo

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-25 Thread Tim Hoffmann via Python-ideas
m with that). But "bool(c)" should mean "c is empty" is an arbitrary additional constraint. For some types (e.g. numpy, padas) that cannot be fulfilled in a logically consisent way. By requiring that additional constraint, the Python languages forces these containers to be

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-25 Thread Tim Hoffmann via Python-ideas
arrays and dataframes. _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-id

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-25 Thread Tim Hoffmann via Python-ideas
ant enough here to take further action. Anyway, thanks all for the discussion! Tim _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/li

[Python-ideas] synatx sugar for quickly run shell command and return stdout of shell command as string result

2021-08-26 Thread Evan Greenup via Python-ideas
o` Its is enhanced feature which combine both subprocess and os.system Because, subprocess can return output of file, but does not support pipe in command. While os.system can apply pipe in command but doesn't support return stdout result. This can be very convenient to make python available

[Python-ideas] Re: synatx sugar for quickly run shell command and return stdout of shell command as string result

2021-08-26 Thread Tim Hoffmann via Python-ideas
And also IPython: https://ipython.readthedocs.io/en/stable/interactive/shell.html e.g. ls_lines = !ls -l ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org

[Python-ideas] Complete recursive pickle dump

2021-08-27 Thread Evan Greenup via Python-ideas
lly a cool feature, because pickle is to keep python object, completeness is a great advantage of pickle than json and other data persist library. Sent with ProtonMail Secure Email. _______ Python-ideas mailing list -- python-ideas@python.org To unsubscri

[Python-ideas] Re: synatx sugar for quickly run shell command and return stdout of shell command as string result

2021-08-29 Thread Rob Cliffe via Python-ideas
On 26/08/2021 15:44, Christopher Barker wrote: Python itself is purposely not designed to provide quick and easy shell access. Is that really true?  What evidence do you have for that statement? Best wishes Rob Cliffe ___ Python-ideas mailing

[Python-ideas] Re: NAN handling in statistics functions

2021-08-30 Thread Ronald Oussoren via Python-ideas
m. Why do you prefer strings for the options rather than an Enum? The enum clearly documents what the valid options are for the option. Ronald — Twitter / micro.blog: @ronaldoussoren Blog: https://blog.ronaldoussoren.net/ ___ Python-ideas mailing lis

[Python-ideas] Re: NAN handling in statistics functions

2021-08-31 Thread Ronald Oussoren via Python-ideas
mirror C > enums in extension code), but part of that is because I have yet to see what > the point is in Python, over simple string flags. > > I suppose they provide a real advantage for static typing, but other than > that I just don't see it. Not just static typing, bu

[Python-ideas] open functions in dbm submodule need to support path-like object

2021-09-07 Thread Evan Greenup via Python-ideas
Currently, in Python 3.9, `dbm.open()`, `dbm.gnu.open()` and `dbm.ndbm.open()` doesn't support path-like object, class defined in `pathlib`. It would be nice to add support with it. Sent with ProtonMail Secure Email. ___ Python-ideas mailing

[Python-ideas] Re: Different exceptions for assert

2021-09-10 Thread Rob Cliffe via Python-ideas
assertions. Best wishes Rob Cliffe ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org

[Python-ideas] Re: itertools.compress default selectors

2021-09-13 Thread Rob Cliffe via Python-ideas
a selectors. So "compress(a)" would be equivalent to "compress(a, a)" For example: from itertools import compress [*compress([0, 1, 2, 3]))] [1, 2, 3] [*compress(["", "CFLAGS=-O3"])] ["CFLAGS=-O3"] opts = compress([None, "

[Python-ideas] Invalidate list iterators after size changes?

2021-10-09 Thread Tyler Hou via Python-ideas
Right now, the following code is valid in Python 3.9 (and infinitely loops): ``` lst = [1, 2, 3] for i in lst: lst.append(i) ``` IMO this is a source of bugs, and even though this behavior is technically documented (https://bugs.python.org/issue32767), I don't know if it should belo

[Python-ideas] socketserver StreamRequestHandler non-blocking read__

2021-10-10 Thread Evan Greenup via Python-ideas
input, then it will return None type. This would be a nice feature. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Me

<    1   2   3   4   5   6   7   8   9   10   >