The os.path.commonprefix function basically returns the common initial
characters (if any) shared by a sequence of strings, e.g.
os.path.commonprefix(("Python is great!", "Python is not bad",
"Python helps")) # returns "Python "
This is purely a str
The os.path.commonprefix function basically returns the common initial
characters (if any) shared by a sequence of strings, e.g.
os.path.commonprefix(("Python is great!", "Python is not bad",
"Python helps")) # returns "Python "
The following was w
On 13/06/2024 02:20, Rob Cliffe wrote:
The os.path.commonprefix function basically returns the common initial
characters (if any) shared by a sequence of strings, e.g.
os.path.commonprefix(("Python is great!", "Python is not bad",
"Python helps")) # returns
This is a low-level API that coroutines should never
> touch. (At least my experience working with coroutines says so...)
First of all, thanks for your work in this PEP! I think it really completes the
async Python to a state where most synchronous code can be changed easily to be
asynchronou
/questions/185936/delete-folder-contents-in-python
But it'd be simpler if there were an optional parameter added to shutil.rmtree,
called removeroot. It would default to true so as to not break any backward
compatibility. If it's set to false, then it leaves the root directory in
ing like
> shutil.remove_dir_files().
The typical Python term for the concept would be "clear", giving
shutil.clear_dir(). Like the ".clear()" method on containers, it would
delete the contents, but leave the container itself alone. rmtree()
could then be a thin wrapper around clear_dir() that
On 29/08/2016 02:44, Ken Kundert wrote:
Changing Python so that it understands SI scale factors on real numbers as first
class citizens innately requires a change to the base language; it cannot be
done solely through libraries. The question before you is, should we do it?
No, no, no, if
On 29/08/2016 13:35, Stephan Houben wrote:
Note that the Sage computer algebra system uses Python with some
syntactic changes implemented by a "pre-parser".
The current proposal could be implemented in a similar way and then
integrated in, say, Ipython.
If it would prove to be wild
CamelCase
used in ‘DictReader’. But maybe that’s just an attempt at foolish consistency
:).
best,
—titus
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3
oking for read or
readline instead? Codifying that in some standard way could be nice.
best,
—titus
> On Sep 5, 2021, at 5:30 PM, Oscar Benjamin wrote:
>
> On Mon, 6 Sept 2021 at 01:13, Greg Ewing wrote:
>>
>> On 6/09/21 3:07 am, C. Titus Brown via Python-ideas wrote:
>>
)
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message
Hi all,
python-ideas moderator here. It’d be great if y’all could take a few days to
cool off the frozen set discussion, which is veering off the rails a little bit
into emotional language.
I’ll keep an eye on it and put emergency moderation into effect if I must, but
it’d be nicer if I
gt;> B), then you can say C > A and C > B, but then you can't say A > B or A < B
>>> which breaks sorting.
>>>
>>> If you want to know if a B inherits from Base, then I think `Base in
>>> B.mro()` will cover that just as succinctly. And if you need
`<:` kind of notation would look more clear, I agree.
My proposition came after thinking the wording used in Python.
issubclass() - is subclass?
By definition, subclass reminds me set theory.
https://en.wikipedia.org/wiki/Subclass_(set_theory) which also has a relativity
with Subtyping
On Thu, Mar 12, 2020 at 2:32 PM Marco Sulla via Python-ideas
wrote:
>
> On Thu, 12 Mar 2020 at 21:22, Chris Angelico wrote:
> > They actually ARE already discarded
>
> 0O
> You're right. So *how* can juliantaylor said he measured a speedup of
> 2x for large ndar
ng it. Good catch from the end. I found another similar at
> https://gstindianews.info. But you get the idea - a simple wrapper around
> a list is going to be way better than a wrapper around StringIO. i
>
> jayesh
> _______
> Python
:
The code of conduct that governs this list (and all Python spaces) is here,
https://www.python.org/psf/conduct/.
If you want to discuss the python code of conduct and its applicability to this
thread (or anything else), python-ideas is not the place to do so. You may do
so privately with the
Hi all,
as a moderator of python-ideas, I’ve asked postmaster to place python-ideas
into emergency moderation. (I do not have the tools to do so myself.) I’m
willing to review messages individually as needed.
best,
—titus
> On Jun 29, 2020, at 9:24 AM, Abdur-Rahmaan Janhangeer
>
Python uses an index of -1 to index the last element in a list. Since -1 occurs
before 0 we might think of the elements of the linear list are being bent into
a circle making the last element occur before the 0th element. Consider a list
with n elements: it would be perfectly reasonable to
As discussed earlier on the post on 'Circular Indexing', considering
interpreting indices that lie outside the range 0 to n-1 modulo n for list
indexing. Thus element n corresponds to element 0, n+1 to element 1 and so on.
This has two consequences:
1.) Makes the Python con
extremely common in ML. Using
circular indexing gets rid of this extra FOR loop. If we have to iterate 2
times you can iterate using range(-n,n) but in most cases you need to iterate
over 10 or more epochs in ML.
Most scientific applications of Python involve an outer FOR loop which
: [email protected]; [email protected]
Subject: Re: [Python-ideas] Getting rid of FOR loops and simplifying cicular
conviolutions with Circular Indexing
days_of_the_week[14 % 7]
There ya go!
On Wed, Nov 25, 2020 at 12:51 PM Mathew M. Noel via Python-ideas
mailto:[email protected]
: Mathew M. Noel
Cc: python-ideas; [email protected]
Subject: Re: [Python-ideas] Getting rid of FOR loops and simplifying cicular
conviolutions with Circular Indexing
You've started three separate threads to propose something that has exactly
zero chance of happening, and would be of
The PEP should
> appear online soon.
>
> --
> Ivan
>
> ***
>
> PEP: 562
> Title: Module __getattr__
> Author: Ivan Levkivskyi
> Status: Draft
> Type: Standards Track
> Content-Type: text/x-rst
&g
s ain't a
walk in a park, and there's the boilerplate and the crazy issues with
interpreter shutdown.
--
Thanks,
-- Ionel Cristian Mărieș, http://blog.ionelmc.ro
_______
Python-ideas mailing list
[email protected]
https://mail.python.org/mai
PositiveInteger(metaclass=MyMeta):
@classmethod
def __instancehook__(cls, instance):
return isinstance(instance, int) and instance > 0
Of course, the real implemention is more detailed...
What do you think about that ?___
Python-id
y. Maybe I can make this compatible with it anyway._______
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
After I generate an UML diagram from collections.abc, I found very strange that
MappingView inherit from Sized instead of Collection (new in python 3.6).
Yes, MappingView only define __len__ and not __iter__ and __contains__, but all
of its subclasses define them (KeysView, ValuesView and
;/usr/lib/python3.6/_collections_abc.py", line 764, in __iter__
yield self._mapping[key]
TypeError: list indices must be integers or slices, not str
It's because __init__ in MappingView treat the passed argument -- wich is
stored in self._mapping -- as the whole mapping, not jus
a way to hide the paranetesis either. I
could make those changes whth a graphic tool though. Same thing with the empty
box.
Whereas it's possible with plantuml. But may be I have to use a pure python
tool. What's your opinions about that?
Another thing: for exemple, in the case o
Mixin
Methods.
_______
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
c.png]___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
In python 2.7, ABCs's caches and registries are sets. But in python 3.6 they
are WeakSet.
In consequence, the output of _dump_registry() is almost useless:
>>> from collections import abc
>>> abc.Iterator._dump_registry()
Class: collections.abc.Iterator
Inv
In the table of the documentation page, the abstract methods are listed fisrt.
In the source code, the abstract methods are implemented fisrt.
In UML, the convention is to place the abstract methods first.
_______
Python-ideas mailing list
Python-ideas@python.
unter: 8
_abc_cache: {}
_abc_negative_cache: set()
_abc_negative_cache_version: 8
_abc_registry: set()
It's going into the cache and not into the registry.
Strange behaviour...
>I guess a PR to fix the registry output would make sense (first file a bug on
>bugs.python.org for it).
Ok, I wi
's empty:
every iterator passed to Iterator.register() defines __iter__ and __next__, so
they satisfy Iterator.__subclasshook__ and are added to the cache beforehand.
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
ragmatic Programmer,
Andrew Hunt & David Thomas.
Here are the files! I used plantuml.
base.puml
Description: Binary data
full.puml
Description: Binary data
other_collections.puml
Description: Binary data
___
Python-ideas mailing list
Python-ideas
also interesting by the way...___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
nsome going forward or we will simply have to
>> drop the image at the first instance of needing to update it because no one
>> can or be willing to put in the effort (and I'm thinking in 5 years, not
>> soon while we can count on you to help).
>>
>> On Sat, Dec
ections-abc-uml/blob/master/plantuml/other_collections.svg
https://gitlab.com/yahya-abou-imran/collections-abc-uml/blob/master/plantuml/full.svg___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
hat
it's a lot more work (and pain) than a plain text file.
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
rite to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
.
The full text of the GPL is distributed in
/usr/share/common-licenses/GPL-3 on Debian systems.
___
Python-ideas mailing list
Python-ideas@py
And on the sourceforge page:
https://sourceforge.net/projects/plantuml/
License
GNU General Public License version 2.0 (GPLv2)
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct
don't manage to all agree with each other, I will just let the issue open
until somebody comes with an undisputed solution._______
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Condu
attr, value in self.__dict__.items()
if not attr.startswith('_')}
_______
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
amespace you want to expose to your clients without compromosing the real one.
Of course, the real one could always be accessible via __dict__ (if present).
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
apply of course.___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
gt;> s = set([10, 20, 1])
>>> s
{1, 10, 20}
You're seeing an accidental byproduct of the implementation.
Eric
_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
ht
a performance issue with keyword arguments vs.
positional. People are touchy when it comes to dicts!
Eric
_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.
permitted, and then
a future version of Python changes it to be an exception? Or the other
way around? Because I could do that. Maybe it would reduce the
arguments. Pun intended, and I am not apologizing for it.
A third option would be that it's a syntax error for you to define such
a fun
On 6/18/2022 5:34 PM, Paul Moore wrote:
After all, it has the
advantage of working on older versions of Python (and given that one
of your use cases is Textual, I can't imagine anyone would be happy if
that required Python 2.12+...)
Guido's "no 2.8" shirt apparently did
ork with the expression AST *before* evaluation). My
> concern is that we're unlikely to be able to justify *two* forms of
> "deferred expression" construct in Python, and your proposal, by
> requiring transparent evaluation on reference, would preclude any
> processing (suc
e". I'd rather look into
> ways of solving that problem instead - ways of taking a function
> signature, making specific changes to it (usually adding and/or
> removing args, but maybe other changes), and then making that your
> declared signature. At the moment, it's only po
the
effort.
That would be the beauty of 638: if it's important to one piece of code,
it could be just enabled there. Of course the implementing macro would
need to be either part of your application or become a dependency.
But I'm under no delusions that this PEP will ever get accept
> On Dec 17, 2022, at 10:08 AM, [email protected] wrote:
>
> Bruce Leban wrote:
>>> Try googling "python-ideas string prefixes". Doing mimimal diligence is a
>>> reasonable expectation before writing up an idea.
>
> Thanks for the query "stri
everyone!
>
> I'm the maintainer of a small django library called django-components. I've
> run into a problem that I have a language-level solution (tagged strings) to,
> that I think would benefit the wider python community.
>
> *Problem*
> A component in my libra
t;) and
then proceeds to cast the pointer and directly inspect its
members.
As such, I don't think UserString can ever truly be a str,
I had figured subclasses of str wouldn’t be full players in the C
code — but join() us pretty fundamental:-(
tutorial on the distinction between bytes and strings
> and why it is important, when I saw the root cause. People coming from
> C, Perl, Python 2 and similar languages tend to misinterpret "\x90" for
> b"\x90" often. My idea is that Python could deprecate string literals
>
ld attribute.
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python
But without knowing the use case, it's hard to say.
Eric
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
http
On Sep 23, 2023, at 5:37 PM, Dom Grigonis wrote:It seems that my guess was correct. There was a commit, when only the first part was working:https://github.com/python/cpython/pull/13123/commits/67977672360659f203664d23cfc52b5e07e4381aSince I wrote that commit: no one is saying it’s impossible
nt line.
Eric
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-i
st is basically dead.
And when you do post over there, please provide an example. It's not
clear what would happen in the generated code if abstract=True.
Eric
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an emai
htening.
-CHB
_______
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
> None is keyword, and just like any other keyword, it can't be re-bound.
>> it's only a keyword because Python doesn't otherwise have a way of creating
>> non-rebindable names. It's purpose is to represent the singular object of
>> NoneType, and in t
espace — you can mess with pretty much anything else in Python.
-CHB
Sent from my iPhone
On Aug 17, 2018, at 12:46 PM, Chris Barker wrote:
On Thu, Aug 16, 2018 at 12:37 PM, Chris Angelico wrote:
>
> I've no idea what interpreter you're using, but it doesn't work for
look at
traitsui for ideas.
http://docs.enthought.com/traitsui/
-CHB
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
to provide exactly one high-quality
> implementation for each platform, with as few layers as
> practicable between the Python API and the platform's native
> GUI facilities.
So kinda like wxWidgets but in Python — which would be nice. wxPython
definitely suffers from its C++ underpi
ood choice!
We’re have enough trouble with really slow adoption of the new ways of
doing packaging, not even providing the tools seems to really defeat the
purpose.
-CHB
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mail
CHB
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
t;
> from . import test_main
>
> to get the test/test_main module from the test/__init__ module.
>
> (Disclaimer: I have not actually run the above code to check that it
> works, beyond testing that its not a SyntaxError.)
>
> What *precisely* is the problem you are tryi
Perhaps I got confused by the early part of this discussion.
My point was that there is no “map-like” object at the Python level.
(That is no Map abc).
Py2’s map produced a sequence. Py3’s map produced an iterable.
So any API that was expecting a sequence could accept the result of a
py2 map
sure why one would do that, but it should be possible.
- CHB
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
> Alex Shafer via Python-ideas wrote:
>> 1) I'm in favor of adding a stringify method to all collections
>
> Are you volunteering to update all the collection
> classes in the world written in Python? :-)
To be fair, we could add an implementation to the sequence ABC, a
>
> Rather than using map in this way, I would recommend a list comprehension:
Exactly! I really don’t get why folks want to use map() so much when
the comprehension syntax is often cleaner and easier. It was added for
a reason :-)
-CHB
___
, a method like future.set_result_threadsafe,
which would hide the details of the loop.call_soon/call_soon_threadsafe
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.pyth
te":
>
> class MySpecialException(Exception):
> pass
>
>
> I think that in 22 years of using Python, I have never written an
> exception that took more than these two lines of code.
>
> Heck, I even have my memory jogged of string exceptions reading this.
&
I have a use case where I'm writing a small filter in Python which
should be able to take output from the find command to filter and
optionally pass it to other commands (like xargs), but also can be
passed specific filenames for the input and/or output. Find can output
it's filenam
s not None:
data["count"] = count
Could be written as
data = {
"count" = count is not None ?? count, # set the "count" key in the
dictionary conditionally, if count is not None, else don't set the key
at all
"other_param" = ... ?? ...,
...
}
oesn’t seem like a good idea to be handling months and
femptoseconds with the same “encoding”
-CHB
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
from 0 to 255, as opposed to being
> the number itself, but that's getting rather existential :)
No, I’m making the distinction that an eight bit byte is, well, eight
bits, that CAN represent a number from 0 to 255, or it can represent
any other data type — like one eighth of the bits in a
ood solution. I know I spent years thinking “there
should be an easy way to do this” before I found setdefault().
-CHB
>
> :-)
>
> [snip]
> ___
> Python-ideas mailing list
> [email protected]
> https://mail.python.org/mailman/list
that gets tacked on automatically in you app, so again, you use
relative paths everywhere.
The concept of non-python-code resources being accessible within a
package is really a separate issue than generic data files, etc. that
you may want to access and serve different way.
In short, if you have a
? I know it's not exactly properties on a class,
> but I thought there were other cases, even if I couldn't name one.
> Dont mind me, then.
It wouldn’t be THAT hard to wrote lazy-import code for pathlib.
But there has been a lot of discussion lately about Python startup time
Just a small idea that could possibly be useful for python decorators.
An idea I had is that it could be possible for a decorator function to
declare a parameter which, when the function is called as a decorator,
the runtime can fill in various information in the parameters for the
decorator to
ed inside the body of a class to decorate a class member:
class MyClass(object):
@decorator
def method(self):
pass
Using the explicit is better than implicit:
class MyClass(object):
@decorator(MyClass, ...)
def method(self):
pass
>> However -- if this is really such a good idea -- wouldn't someone have make
>> a C lib that does it? Or has someone? Anyone looked?
>
> No, there's nothing magical about C. You can do it in pure Python.
Sure, but there are a number of FP subtleties around the
.
-CHB
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
sion that transforms the list first.
That would get the keys right. Though still not call append for you.
So maybe a solution is an accumulator special case of defaultdict — it
uses a list be default and appends by default.
Almost like counter...
-CHB
_______
Pyt
l is.
Which makes me think — a new classmethod on the builtin dict is a
pretty heavy lift compared to a new type of dict in the collections
module.
-CHB
_______
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-
ilt a
histogram for continuous data as well.
Though that might be a bit klunky.
But if someone thinks that’s a good idea, a PR for an example would be
accepted:
https://github.com/PythonCHB/grouper
-CHB
--
Steve
___
Python-ideas mailing list
Python-
> my vote would go to `A otherwise B` since it's unambiguous, the case you care
> about the state of comes first, and it doesn't trip your brain up looking
> for 'if'. :)
And I’d hope “otherwise” is a rare variable name :-)
- CHB
>
> _____
de, and run a garbage collector once in a while
instead.
After all, cPython’s (mostly) deterministic garbage collection is not
guaranteed by the language standard.
-CHB
_______
Python-ideas mailing list
[email protected]
https://mail.python.org/mailma
A note here:
Earlier in the conversation about standardizing type hinting, I (among
others) was interested in applying it to C-level static typing (e.g.
Cython).
Guido made it very clear that that was NOT a goal of type hints —
rather, they were to be used for dynamic, python style types — so a
t; something which could much more easily be done by adding an rreplace
> function - which is the real point of the comment.
> Paul
> ___
> Python-ideas mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/
lp the authors of suck a package(s),
but if the bulk of users didn’t need them, then no point in adding
them to the language.
-CHB
_______
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of
; ---
This is also a convention — and primarily applies to mutable defaults,
which you hardly ever want to assign directly.
So a good example of None being used as a sentinel, but nog really
anything special about None.
-CHB
> /
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
1601 - 1698 of 1698 matches
Mail list logo