On 07/17/2017 05:01 PM, Ethan Furman wrote:
I haven't timed it (I'm hoping somebody will volunteer to be the bench mark
guru), I'll offer my NamedTuple
implementation from my aenum [1] library. It uses the same metaclass
techniques as Enum, and offers doc string and
default value support
Guido has decreed that namedtuple shall be reimplemented with speed in mind.
I haven't timed it (I'm hoping somebody will volunteer to be the bench mark guru), I'll offer my NamedTuple
implementation from my aenum [1] library. It uses the same metaclass techniques as Enum, and offers doc
On 06/26/2017 01:20 PM, Mikhail V wrote:
I dont't like "while True:" simply because it does not make enough
visual distinction with the "while condition:" statement.
My "while True:" loops look something like:
while "":
--
~Ethan~
___
On 06/19/2017 07:26 PM, Steven D'Aprano wrote:
Or maybe we decide that it's actually a feature, not a problem, for an
AttributeError inside self.attr.__get__ to look like self.attr is
missing.
It's a feature. It's why Enum classes can have members named 'value' and
'name'.
--
~Ethan~
On 06/19/2017 06:31 PM, Chris Angelico wrote:
On Tue, Jun 20, 2017 at 10:18 AM, Steven D'Aprano wrote:
Having said that, there's another problem: adding this feature (whatever
it actually is) to __getattr__ will break every existing class that uses
__getattr__. The problem
On 06/16/2017 01:37 PM, Alexandre Brault wrote:
So a if used directly, and a if used as a
context manager. I don't have a copy of 3.6 nor the future 3.7 handy,
so maybe it changed there?
The code in master has the context manager return `self.name`. This
behaviour has (based on looking at
On 06/14/2017 01:54 PM, Barry Scott wrote:
super().__dir__ looks at the class above me that is typically object() and so
is not useful
as it does not list the member function from my class or __mro__ or other stuff
I may not be aware of
that is important to return.
__dir__ should return
On 06/08/2017 12:22 PM, Brett Cannon wrote:
Already exists, been discussed, and rejected:
https://bugs.python.org/issue29447 .
Ah, right, because the returned object is not a file path. Makes sense.
--
~Ethan~
___
Python-ideas mailing list
On 06/08/2017 06:42 AM, Antoine Pietri wrote:
Hello everyone!
A very common pattern when dealing with temporary files is code like this:
with tempfile.TemporaryDirectory() as tmpdir:
tmp_path = tmpdir.name
os.chmod(tmp_path)
os.foobar(tmp_path)
On 06/01/2017 07:17 AM, joannah nanjekye wrote:
Today I was writing an example snippet for the book and needed to write a
function that returns two values something
like this:
def return_multiplevalues(num1, num2):
return num1, num2
I noticed that this actually returns a tuple of the
On 05/17/2017 02:06 PM, Ethan Furman wrote:
You might want to check out the NamedTuple class from my aenum [1]
library
[1] https://pypi.python.org/pypi/aenum
--
~Ethan~
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org
0, y=0)
>>> Point(1)
Point(x=1, y=0)
>>> Point(y=2)
Point(x=0, y=2)
It is also possible to create ``NamedTuples`` that only have named attributes
for certain fields; any fields without names can still be accessed by index::
>>> class Person(N
On 05/17/2017 06:20 AM, Stephan Houben wrote:
class MyClass:
foo = attr.ib()
MyClass = attr.s(MyClass)
Given that one of Python's great strengths is its readability, I would
not use the attr library in teaching because it is not. Having a dot in
the middle of words is confusing,
On 05/01/2017 07:04 AM, Juancarlo Añez wrote:
On Mon, May 1, 2017 at 9:38 AM, Nick Coghlan wrote:
just support two
keyword arguments to hex(): "delimiter" (as you suggest) and
"chunk_size" (defaulting to 1, so you get per-byte chunking by
default)
I'd expect "chunk_size" to mean the number
On 04/21/2017 09:04 AM, Stephan Hoyer wrote:
On Thu, Apr 20, 2017 at 10:58 AM, Ethan Furman wrote:
I'm curious, what did you find ugly with:
class TestEnum(CallableEnum):
@enum
def hello(text):
"a pleasant greeting"
print('hel
[redirecting back to the list]
On 04/19/2017 11:15 PM, Stephan Hoyer wrote:
Ethan and Steven,
Thanks for your feedback on this one. I agree that it probably doesn't make
sense for the standard library.
I'm still not really happy with any of the standard approaches for choosing a
function
On 04/16/2017 01:24 AM, Steven D'Aprano wrote:
On Fri, Apr 14, 2017 at 06:06:29PM -0700, Stephan Hoyer wrote:
One way that I've found myself using enums recently is for dispatching (as
keys in a dictionary) between different interchangeable functions or
classes.
[...]
Given that wanting
On 03/27/2017 08:04 AM, Steven D'Aprano wrote:
On Mon, Mar 27, 2017 at 02:50:38PM +0200, Ram Rachum wrote:
What do you think about adding methods pathlib.Path.write_json and
pathlib.Path.read_json , similar to write_text, write_bytes, read_text,
read_bytes?
That's not pathlib's
On 03/08/2017 08:01 AM, Francesco Franchina wrote:
Before expressing my thought and proposal, I want to make sure we all agree on
a simple and clear fact:
the __str__ magic method is used to give a literal and human-readable
representation to the object (unlike __repr__).
If __str__ has not
On 03/05/2017 11:13 AM, Ed Kellett wrote:
I'm not trying to get anyone to implement list.get, I'm trying to get it
centrally
> documented and allowed into list's overly-mappingproxied namespace.
--> dir(list)
# non dunder methods
'append', 'clear', 'copy', 'count', 'extend', 'index',
On 03/03/2017 10:48 AM, Sven R. Kunze wrote:
On 03.03.2017 18:06, Ethan Furman wrote:
On 03/02/2017 12:36 PM, Sven R. Kunze wrote:
It then would make sense to remove .get() on dicts. ;-)
and to remove parameter "default" of max().
and to remove parameter "default" of ge
On 03/03/2017 01:14 AM, Brice PARENT wrote:
Sorry for the very long message, I hope it will get your interest. And I also
hope my English was clear enough.
Long messages that explain the idea are welcome!
I think it looks interesting.
--
~Ethan~
On 03/03/2017 08:21 AM, Matthias Bussonnier wrote:
##
# forloop.break(), to break out of nested loops (or explicitly out of
current
#loop) - a little like pep-3136's first proposal
has_dog_named_rex = False
for owner in owners:
for dog in
On 03/02/2017 12:36 PM, Sven R. Kunze wrote:
On 01.03.2017 06:34, Ethan Furman wrote:
On the bright side, if enough use-cases of this type come up (pesky try/except
for a simple situation), we may be able
to get Guido to reconsider PEP 463. I certainly think PEP 463 makes a lot more
sense
On 03/03/2017 08:09 AM, Ed Kellett wrote:
P.S. all the talk of PEP 463 seems misplaced. That it solves (FSVO solve) this
problem doesn't mean it should supersede
this discussion.
The advantage of PEP 463 is that issues like this would be less pressing, and
it's much more general purpose.
On 03/03/2017 06:29 AM, Victor Stinner wrote:
An alternative for generated signature of multiple optional arguments
is "bytearray([source[, encoding[, errors]]])", but I'm not a big fan
of nested [...],
But that's not the same thing.
bytearry([source,] [encoding,] [errors])
says that each
-1.
It is already possible to specify what
inst in cls
means by using a metaclass. For example:
class Color(enum.Enum):
RED = 1
GREEN = 2
BLUE = 3
some_var = Color.GREEN
some_var in Color # True
some_var in enum.Enum # False
Containment != isinstance()
--
On 03/01/2017 11:41 PM, Stephan Houben wrote:
I have a slight variant of the decorator proposal.
Rather than specify a count, let the decorator implement the typeshed dunder
convention:
@positional_only
def replace(self, __old, __new, count=-1):
(I imagine this decorator would also
On 03/01/2017 11:53 AM, Guido van Rossum wrote:
FWIW in typeshed we've started using double leading underscore as a convention
for positional-only parameters, e.g. here:
https://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L936
I would much rather have a single '/' to denote
On 03/01/2017 01:37 AM, Wolfgang Maier wrote:
Now here's the proposal: allow an except (or except break) clause to follow
for/while loops that will be executed if the
loop was terminated by a break statement.
I find the proposal interesting. More importantly, the proposal is well
written
On 02/28/2017 05:18 PM, Michel Desmoulin wrote:
I love this proposal but Guido rejected it. Fighting for it right now
would probably be detrimental to the current proposed feature which
could potentially be more easily accepted.
PEP 463 has a better chance of being accepted than this one
https://www.python.org/dev/peps/pep-0457/
https://mail.python.org/pipermail/python-dev/2014-January/131865.html
--
~Ethan~
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct:
On 02/10/2017 10:48 AM, Nick Timkovich wrote:
If everything was contained right in the same file, this is sanctioning
another way to do it (when there should only be one obvious way).
No worries, this way is not obvious.
If you have multiple modules/packages, horrors can evolve where a
On 01/27/2017 01:07 PM, Brent Brinkley wrote:
I’m relatively new to the world of python
Welcome!
but in my short time here I’ve
fallen in love with how readable this language is. One issue that I’ve
seen in a lot of languages struggle with is nested function calls.
Parenthesis when
On 01/23/2017 01:18 PM, João Matos wrote:
Why should I repeat global if I can use the line separation character \
(like I mentioned on my 1st email) or parentheses as I suggested?
Because prefixing each line with global is more readable than either \ or ( )?
At least to me. ;)
--
~Ethan~
On 01/23/2017 05:33 AM, Soni L. wrote:
It's literally sugar for repeating the name and moving the dot to the right.
I think it's clearer than most other compound operators in that it doesn't
affect precedence rules.
`x += y`, for any code `y`, is equivalent to `x = x + (y)`, not `x = x + y`.
On 01/22/2017 03:30 PM, Soni L. wrote:
On 22/01/17 08:54 PM, Serhiy Storchaka wrote:
On 23.01.17 00:45, Soni L. wrote:
I've been thinking of an Immutable Builder pattern and an operator to go
with it. Since the builder would be immutable, this wouldn't work:
long_name = mkbuilder()
On 01/15/2017 08:40 AM, Chris Rose wrote:
I want to address one gap in the PEP regarding reclaiming abandoned names.
This should be on the DistUtils sig where the PEP is being discussed.
--
~Ethan~
___
Python-ideas mailing list
On 01/12/2017 03:21 PM, Random832 wrote:
Just out of curiosity... in your estimation, what is a "wart", and why
is the term "wart" used for it? I mean, this is an accepted term that
the Python community uses to refer to things [...]
I do not see any difference between calling something a
On 01/10/2017 08:36 AM, Thane Brimhall wrote:
Does anyone have thoughts on this topic? I assume the silence is because
this suggestion is too trivial to matter.
Sometimes it's just a matter of timing. :)
I use cProfile a lot, and would like to suggest three backwards-compatible
On 01/09/2017 09:18 PM, Simon Lovell wrote:
[snip]
This is not the place for this conversation. Please take it to Python List.
--
~Ethan~
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
On 12/30/2016 06:47 PM, j...@math.brown.edu wrote:
__eq__ only has to be called when a hash bucket is non-empty. In that case,
it may be O(n) in pathological cases, but it could also be O(1) every time.
On the other hand, __hash__ has to be called on every lookup, is O(n) on
the first call,
On 12/30/2016 06:12 PM, j...@math.brown.edu wrote:
... your point stands that Python had to call __eq__ in these cases.
But with instances of large, immutable, ordered collections, an
application could either:
1. accept that it might create a duplicate, equivalent instance of
an existing
On 12/30/2016 03:36 PM, j...@math.brown.edu wrote:
In the use cases I described, the objects' members are ordered. So in the
unlikely event that two objects hash to the same value but are unequal, the
__eq__ call should be cheap, because they probably differ in length or on their
first
On 12/30/2016 07:10 AM, Chris Angelico wrote:
Actually, that makes a lot of sense. And since "property" isn't magic
syntax, you could take it sooner:
from somewhere import property
and toy with it that way.
What module would be appropriate, though?
Well, DynamicClassAttribute is kept in
On 12/12/2016 03:45 PM, Steven D'Aprano wrote:
Proposal: enhance vars() to return a proxy to the object namespace,
regardless of whether said namespace is __dict__ itself, or a number of
__slots__, or both.
+1
--
~Ethan~
___
Python-ideas mailing
On 11/30/2016 02:32 AM, Jelte Fennema wrote:
It would be nice to have a supported way to add defaults to namedtuple,
so the slightly hacky solution here does not have to be used:
http://stackoverflow.com/a/18348004/2570866
Actually, the solution right below it is better [1]:
--> from
On 11/28/2016 05:46 PM, Random832 wrote:
On Mon, Nov 28, 2016, at 15:05, Ethan Furman wrote:
Because it is unfriendly. Helpful error messages are a great tool to
both beginner and seasoned programmers.
There won't be a helpful error message unless the distributor writes
one.
The purpose
On 11/28/2016 01:26 PM, Paul Moore wrote:
On 28 November 2016 at 21:11, Ethan Furman <et...@stoneleaf.us> wrote:
One "successful" use-case that would be impacted is the fallback import
idiom:
try:
# this would do two full searches before getting the error
import
On 11/28/2016 01:01 PM, Guido van Rossum wrote:
On Mon, Nov 28, 2016 at 12:51 PM, Ethan Furman wrote:
On 11/28/2016 05:28 AM, Tomas Orsava wrote:
Rendered PEP: https://fedora-python.github.io/pep-drafts/pep-A.html
<https://fedora-python.github.io/pep-drafts/pep-A.html>
Over
On 11/28/2016 05:28 AM, Tomas Orsava wrote:
Rendered PEP: https://fedora-python.github.io/pep-drafts/pep-A.html
Overall +1, but using Guido's #2 option instead for handling *.missing.py files
(searching all possible locations for the module before falling back to the
stdlib xxx.missing.py
On 11/18/2016 12:42 PM, Ram Rachum wrote:
Sure, here are a couple of use cases:
1. I'm making a program that lets people lease machines. They can issue
a command to lease 7 machines. When they do, my program leases them one
by one and adds them all to an exit stack, so in case there aren't 7
On 11/18/2016 11:34 AM, Chris Angelico wrote:
Hmm. I'm seeing them. Where are you reading -ideas? Is there possibly
a glitch between mailing list and newsgroup?
Yeah, I'm using the mailing list.
On 11/18/2016 11:39 AM, Mikhail V wrote:
I am really sorry :( Didn't intended it
Something
On 11/16/2016 03:51 AM, Roland Hedberg wrote:
My question to you is if it would be possible to get an OAuth2/OIDC
implementation like mine
to be part of the Python standard distribution.
I realise that I will have to rewrite parts of pyoidc because presently it uses
modules
(for instance
On 11/06/2016 08:11 PM, Nick Coghlan wrote:
On 7 November 2016 at 12:25, Ethan Furman <et...@stoneleaf.us> wrote:
On 11/06/2016 12:44 AM, Ram Rachum wrote:
I see that Python does allow you to not call `__exit__` if you don't want
to [...]
Um, how? I was unaware of this (mis-)f
On 11/06/2016 12:44 AM, Ram Rachum wrote:
I see that Python does allow you to not call `__exit__` if you don't want
to [...]
Um, how? I was unaware of this (mis-)feature.
--
~Ethan~
___
Python-ideas mailing list
Python-ideas@python.org
On 11/06/2016 12:18 AM, Ram Rachum wrote:
Well, you think it's weird that I want a `finally` clause to not be called
in some circumstances.
Yes I (we) do.
Do you think it's equally weird to want an `__exit__` method that is not
called in some circumstances?
Yes I (we) do.
--
~Ethan~
On 11/02/2016 12:32 PM, Nikolaus Rath wrote:
On Nov 02 2016, Zero Piraeus
wrote:
On Wed, 2016-11-02 at 08:46 -0700, Guido van Rossum wrote:
[...] we need to agree on what even the right definition of ?. is. It's
been frighteningly difficult to
On 10/21/2016 10:17 PM, Ryan Birmingham wrote:
I want to start small and ask about smart/curly quote marks (” vs ").
Although most languages do not support these characters as quotation
marks, I believe that cPython should, if possible. I'm willing to write
the patch, of course, but I wanted
On 10/21/2016 03:48 PM, Amit Green wrote:
NOTE: This is my first post to this mailing list, I'm not really sure
how to post a message, so I'm attempting a reply-all.
Seems to have worked! :)
I like Nathaniel's idea for __iterclose__.
I suggest the following changes to deal with a
On 10/21/2016 12:13 PM, Mark Lawrence via Python-ideas wrote:
This list is irrelevant. The PSF has to be consistent across all of its lists.
This list is not irrelevant, and yes *volunteers who moderate* should be
consistent.
Who the hell is Marietta, I don't recall a single post from
On 10/11/2016 07:00 AM, Steven D'Aprano wrote:
On Tue, Oct 11, 2016 at 02:41:34PM +0200, Sven R. Kunze wrote:
on django-developers, an intriguing idea appeared:
https://groups.google.com/d/msg/django-developers/4bntzg1HwwY/HHHjbDnLBQAJ
"""
It seems to me that the default `method.__bool__` is
On 10/05/2016 12:20 PM, Sven R. Kunze wrote:
On 05.10.2016 18:06, Nick Coghlan wrote:
Guido's idea of a shadow thread to let synchronous threads run
coroutines without needing to actually run a foreground event
loop should provide a manageable way of getting the two runtime
models
On 09/19/2016 06:45 PM, Chris Angelico wrote:
Yes we are (at least in that instance). With more real-world tests,
they're allowed to use all the standard library - this was the "in
some cases" bit. (We don't teach float multiplication, because it's
very complication, but we do teach some stuff
On 09/19/2016 04:38 PM, אלעזר wrote:
I was talking specifically about advanced courses, in which an assignment
is "implement a side-channel attack using data" and you can use whatever
library you like.
Am I misunderstanding, or did you just say you want this new functionality in
order to
On 09/19/2016 09:25 AM, אלעזר wrote:
Many proposals to add something to stdlib are rejected here with the suggestion
to add such library to pypi first. As noted by someone, pypi is not as
reachable as stdlib, and one should install that package first, which many
people don't know how.
On 09/17/2016 03:14 PM, Chris Angelico wrote:
On Sun, Sep 18, 2016 at 8:06 AM, Ethan Furman wrote:
Just like Python will use the defined __ne__ if
it's present, or fall back to negating the result of __eq__ if __ne__ is
not present, I see __divmod__ working the same way:
- is __mod__ present
On 09/15/2016 10:03 AM, Steven D'Aprano wrote:
On Wed, Sep 14, 2016 at 09:51:32PM +1000, Chris Angelico wrote:
Perhaps the advice needs to be along the lines of: Decide what the
purpose of the enum is, and follow a naming convention accordingly.
Uppercase if you're basically making constants;
On 09/13/2016 09:29 AM, Chris Angelico wrote:
On Wed, Sep 14, 2016 at 2:16 AM, Pim Schellart wrote:
A well-written PEP that looked very interesting.
https://github.com/Rosuav/Decorators/blob/master/evil.py
@monkeypatch
class A:
x = 5
def foo(self):
pass
def
On 09/12/2016 08:37 AM, Guido van Rossum wrote:
For the record, I still really don't like PEP 463. We should strive to
catch fewer exceptions, not make it easier to catch them.
I certainly agree with the first part, slightly reworded: we should strive to
generate fewer exceptions that we
On 09/12/2016 12:05 AM, Michel Desmoulin wrote:
There is also an alternative to this operator, and it's allowing a
shortcut to do:
try:
val = do_thing()
except ThingError:
val = "default"
In the form of:
val = do_thing() except ThingError: "default"
I was debated, and rejected,
On 08/29/2016 02:16 PM, Eric V. Smith wrote:
I've been looking at this, and I agree it's the best thing to do, for
now (and possibly forever).
I'm just not convinced I can get it done before alpha 1.
Isn't the f-string feature already in place?
Update the PEP, then it's a bugfix. ;)
--
On 08/19/2016 08:57 PM, C Anthony Risinger wrote:
[...]
The appeal of f-strings is the rapid inlining of whatever plus string data. "Whatever" is
typically more complex than a simple attribute access or variable reference, though not much more
complex eg. `object.method(key, "default")`. If
301 - 373 of 373 matches
Mail list logo