Hi Samuel,
Classes already have a `obj.mro()` public method that wraps their private
dunder `__mro__`.
Non-classes (instances) don't have a `__mro__`.
> Additionally, the class named `object` should have a method named
> `__mro__` and any class which inherits from `object` may override
> `__mro
On Mon, Mar 06, 2023 at 10:33:26AM +0100, Marc-Andre Lemburg wrote:
> def join_words(list_of_words)
> return ' '.join([x.strip() for x in list_of_words])
That's not Rob's suggestion either.
Rob's suggestion is an operator which concats two substrings with
exactly one space between them, wit
On Sun, Mar 05, 2023 at 10:49:12PM -0500, David Mertz, Ph.D. wrote:
> Is it really that much longer to write `f"{s1} {s2}"` when you want that?
That's not the same as Rob's proposal.
--
Steve
___
Python-ideas mailing list -- python-ideas@python.org
T
Hello and welcome!
Trying to squeeze many lines of code into one line is a bad idea. It
makes it hard to read, and will be impossible for Python where
statements and expressions are different and must be on separate lines.
Extra lines are cheap. Python does not encourage people trying to cram
On Sun, Jan 08, 2023 at 05:30:30PM +0900, Stephen J. Turnbull wrote:
> Steven D'Aprano writes:
>
> > On Sat, Jan 07, 2023 at 10:48:48AM -0800, Peter Ludemann wrote:
> > > You can get almost the same result using pattern matching. For example,
> your
&
On Sat, Jan 07, 2023 at 10:48:48AM -0800, Peter Ludemann wrote:
> You can get almost the same result using pattern matching. For example, your
> "foo:bar;baz".partition(":", ";")
> can be done by a well-known matching idiom:
> re.match(r'([^:]*):([^;]*);(.*)', 'foo:bar;baz').groups()
"Well-known"
+1 on the idea of having `partition` and `rpartition` take multiple
separators.
Keep it nice and simple: provided with multiple separators, `partition`
will split the string on the first separator found in the source string.
In other words, `source.partition(a, b, c, d)` will split on a /or/ b
On Sat, Dec 24, 2022 at 11:34:19AM -0500, Shironeko wrote:
>
> Is the => syntax needed? as far as I can think of, the only time where
> late evaluation is needed is when the expression references the other
> arguments.
You are missing the most common case, the motivating case, for
late-bound d
On Fri, Dec 23, 2022 at 06:02:39PM +0900, Stephen J. Turnbull wrote:
> Many would argue that (POSIX) locales aren't a good fit for
> anything. :-)
:-)
> I agree that it's kind of hard to see anything more complex than a
> fixed table for the entire Unicode repertoire belonging in str,
> though.
On Tue, Dec 20, 2022 at 11:55:49PM -0800, Jeremiah Paige wrote:
> @property
> def data(self):
> return f"{self}"
By my testing, on Python 3.10, this is slightly faster still:
@property
def data(self):
return "".join((self,))
That's about 14% faster than the f-stri
On Wed, Dec 21, 2022 at 01:18:46AM -0500, David Mertz, Ph.D. wrote:
> I'm on my tablet, so cannot test at the moment. But is `str.upper()` REALLY
> wrong about the Turkish dotless I (and dotted capital I) currently?!
It has to be. Turkic languages like Turkish, Azerbaijani and Tatar
distinguish
On Wed, Dec 21, 2022 at 09:42:51AM +1100, Cameron Simpson wrote:
> With str subtypes, the case that comes to my mind is mixing str
> subtypes.
[...]
> So, yes, for many methods I might reasonably expect a new html(str). But
> I can contrive situations where I'd want a plain str
The key word the
On Mon, Dec 19, 2022 at 05:53:38PM -0800, Ethan Furman wrote:
> Personally, every other time I've wanted to subclass a built-in data type,
> I've wanted the built-in methods to return my subclass, not the original
> class.
Enums are special. But outside of enums, I cannot think of any useful
s
On Mon, Dec 19, 2022 at 03:48:01PM -0800, Christopher Barker wrote:
> On Mon, Dec 19, 2022 at 3:39 AM Steven D'Aprano wrote
>
> > In any case, I was making a larger point that this same issue applies to
> > other builtins like float, int and more.
>
>
> Act
On Mon, Dec 19, 2022 at 01:02:02AM -0600, Shantanu Jain wrote:
> collections.UserString can take away a lot of this boilerplate pain from
> user defined str subclasses.
At what performance cost?
Also:
>>> s = collections.UserString('spam and eggs')
>>> isinstance(s, str)
False
which pretty muc
On Sun, Dec 18, 2022 at 10:23:18PM -0500, David Mertz, Ph.D. wrote:
> I'd agree to "limited", but not "hostile." Look at the suggestions I
> mentioned: validate, canoncialize, security check. All of those are
> perfectly fine in `.__new__()`.
No, they aren't perfectly fine, because as soon as y
On Sun, Dec 18, 2022 at 07:38:06PM -0500, David Mertz, Ph.D. wrote:
> However, if you want to allow these types to possibly *do* something with
> the strings inside (validate them, canonicalize them, do a security check,
> etc), I think I like the other way:
>
> #2
>
> class html(str): pass
> cl
On Tue, Dec 06, 2022 at 07:58:09PM -0500, David Mertz, Ph.D. wrote:
> You have an error in the code you posted. You never use R2 after one
> call to SystemRandom.
Ah so I do, thanks for picking that up!
James, see how *easy* it is for experts to notice bugs, at least some of
them, in a short p
Thanks for posting your code, but at 178 lines (most of which are either
commented out or irrelevent to your question) its a hard slog to work out what
you're doing.
And as for the seemingly endless sequence of "Random number ... Value entered",
what did information did you think we would get f
On Sun, Dec 04, 2022 at 01:34:13PM -0800, Bruce Leban wrote:
> I agree with most criticism of this proposal, although I'll note that
> the one place where I'd like something like this is at top level. I
> often write something like this at top level:
>
> __part1 = (some calculation)
> __part2
On Fri, Dec 02, 2022 at 03:48:36AM -0700, Anony Mous wrote:
> These objections -- such as they are -- are all applicable to every
> instance of "I wrote a function" or even "I named a variable" in any
> particular namespace: not just within imports, either. Anywhere. Global
> context. Sub functions
On Thu, Dec 01, 2022 at 03:19:38PM -0700, Anony Mous wrote:
> I'd love to hear a justification -- any justification -- against what I'm
> talking about, because to date, I've never run into one. Many have tried,
> too. :)
What is the `str` interface? Perhaps not the best example, because
strings
On Wed, Nov 30, 2022 at 01:27:32PM -0700, Anony Mous wrote:
> the string class, which has some annoying tight couplings to "string" and
> 'string')
What does that mean?
It sounds like you are complaining that the syntax for creating strings
creates strings. Or possibly the other way around: tha
Wes, what purpose do you think these data dumps have?
--
Steve
___
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/
Messag
On Tue, Nov 15, 2022 at 05:10:06AM -0500, Wes Turner wrote:
> There should be better software random in python.
Better is what way? What do you think the current MT PRNG lacks?
--
Steve
___
Python-ideas mailing list -- python-ideas@python.org
To unsu
On Sat, Nov 05, 2022 at 01:37:30AM -0500, James Johnson wrote:
> I wrote the attached python (3) code to improve on existing prng functions.
> I used the time module for one method, which resulted in
> disproportionate odd values, but agreeable means.
First the good news: your random number genera
On Tue, Nov 15, 2022 at 12:19:48AM -0600, James Johnson wrote:
> The random function in Python is not really adequate for a magic eight ball
> program,
That is an astonishing claim for you to assert without evidence.
Python's PRNG is the Mersenne Twister, which is one of the most heavily
studie
On Tue, Nov 08, 2022 at 09:55:04PM +, Barry wrote:
> But anyone that is suitably motivated can implement this.
This is true for every function in a Turing Complete language. Perhaps
we should start using iota or jot? :-)
https://en.wikipedia.org/wiki/Iota_and_Jot
A "suitably motivated" per
On Mon, Nov 07, 2022 at 07:31:36PM -, Charles Machalow wrote:
> I propose adding a mechanism to both pathlib.Path and os.path to check
> if a given path is a junction or not. Currently is_symlink/islink
> return False for junctions.
+1 on a function is_junction.
I am neutral on the questio
I haven't read the PEP yet, so this should not be read as either support
of or opposition to the design, just commenting on one aspect.
On Sat, Sep 10, 2022 at 01:42:38PM -0700, Christopher Barker wrote:
> > The current design is that sentinels with the same name from the same
> > module will al
On Fri, Sep 02, 2022 at 12:53:47AM -, Steve Jorgensen wrote:
> I didn't say that I was talking about a file. In fact, today, I'm
> talking about an object that manages a subprocess. If a caller tries
> to call a method of the manager to interact with the subprocess when
> the subprocess has
On Fri, Sep 02, 2022 at 06:49:37AM +0800, Matthias Görgens wrote:
> >
> > If the target of the call isn't in an appropriate state, isn't that a
> > bug in the constructor that it allows you to construct objects that are
> > in an invalid state?
> >
> > You should fix the object so that it is never
On Thu, Sep 01, 2022 at 03:11:29PM -0700, Bruce Leban wrote:
> * a stream-like object that has been closed and you attempt to read from or
> write data to it.
That would be a ValueError:
>>> f.write('a')
Traceback (most recent call last):
File "", line 1, in
ValueError: I/O operation on close
On Thu, Sep 01, 2022 at 09:40:05PM -, Steve Jorgensen wrote:
> I frequently find that I want to raise an exception when the target of
> a call is not in an appropriate state to perform the requested
> operation. Rather than choosing between `Exception` or defining a
> custom exception, it w
On Tue, Aug 30, 2022 at 03:28:06PM -0400, Wes Turner wrote:
> - Copying __qual/name__ would definitely be a performance regression
Doubtful that it would be meaningful. It's just a lookup and assignment.
>From the perspective of the partial object, it's just
self.__name__ = func.__name__
(
On Mon, Aug 29, 2022 at 09:31:25PM -0700, Charles Machalow wrote:
> Hey folks,
>
> I propose adding __name__ to functools.partial.
https://github.com/python/cpython/issues/91002
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe se
On Sun, Jun 19, 2022 at 01:34:35AM +0100, Rob Cliffe via Python-ideas wrote:
> To me, the natural implementation of slicing on a non-reusable iterator
> (such as a generator) would be that you are not allowed to go backwards
> or even stand still:
> mygen[42]
> mygen[42]
> ValueError: El
On Tue, Jun 21, 2022 at 12:13:08AM +1000, Chris Angelico wrote:
> Nice analogy. It doesn't hold up.
>
> Consider this function:
>
> def f(stuff, max=>len(stuff)):
> stuff.append(1)
> print(max)
>
> f([1,2,3])
>
> How would you use lazy evaluation to *guarantee* the behaviour here?
By
On Tue, Jun 21, 2022 at 03:15:32AM +0100, Rob Cliffe wrote:
> Why do people keep obscuring the discussion of a PEP which addresses
> Problem A by throwing in discussion of the (unrelated) Problem B?
> (Chris, and I, have stated, ad nauseam, that these *are* unrelated
> problems.
Chris says:
"E
On Sun, Jun 19, 2022 at 02:21:16AM +0100, Rob Cliffe via Python-ideas wrote:
> Sorry, but I think all this talk about lazy evaluation is a big red herring:
> (1) Python is not Haskell or Dask.
Python is not Haskell, but we stole list comprehensions and pattern
matching from it. Python steals
On Sun, Jun 19, 2022 at 11:03:45PM -0700, Jeremiah Paige wrote:
> What if next grew a new argument? Changing the signature of a builtin is a
> big change, but surely not bigger than new syntax? If we could ask for the
> number of items returned the original example might look like
>
> >>> first,
On Sun, Jun 19, 2022 at 11:47:22AM -0700, Lucas Wiman wrote:
> Since "today" depends on the time zone, it should be an optional argument
> to date.today(). The interface should be the same as datetime.now(tz=None),
> with date.today() returning the date in the system time zone.
Sure, that sounds p
Okay, I'm convinced.
If we need this feature (and I'm not convinced about that part), then it
makes sense to keep the star and write it as `spam, eggs, *... = items`.
--
Steve
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe sen
On Sun, Jun 19, 2022 at 12:21:50AM -0700, Lucas Wiman wrote:
> Using either * or / could lead to some odd inconsistencies where a missing
> space is very consequential, eg:
> x, / = foo # fine
> x, /= foo # syntax error?
> x / = foo # syntax error
> x /= foo # fine, but totally different from
On Fri, Jun 17, 2022 at 11:32:09AM -, Steve Jorgensen wrote:
> That leads me to want to change the proposal to say that we give the
> same meaning to "_" in ordinary destructuring that it has in
> structural pattern matching, and then, I believe that a final "*_" in
> the expression on the
On Fri, Jun 17, 2022 at 06:32:36AM +0100, Rob Cliffe wrote:
> The bar for adding a new hard keyword to Python is very high.
Likewise for new syntax.
> The suggestion is to add a new keyword to a PEP which absolutely doesn't
> need it,
*shrug*
The match...case statement didn't "need" keyword
On Thu, Jun 16, 2022 at 08:31:19AM +1000, Chris Angelico wrote:
> On Thu, 16 Jun 2022 at 08:25, Steven D'Aprano wrote:
> > Under the Specification section, the PEP explicitly refers to
> > behaviour which "may fail, may succeed", and different behaviour which
&g
On Fri, Jun 17, 2022 at 02:36:48AM -, Steve Jorgensen wrote:
> Is there anything that I can do, as a random Python user to help move
> this to the next stage?
If you think the PEP is as complete and persuasive as possible right
now, you can offer moral support and encouragement. Or you can
On Fri, Jun 17, 2022 at 02:50:50AM -, Steve Jorgensen wrote:
> What are people's impressions of this idea. Is it valuable enough to
> pursue writing a PEP?
I don't think it is useful enough to dedicate syntax to it. If you are
proposing this idea, it is your job to provide evidence that it
On Thu, Jun 16, 2022 at 12:02:04AM +1000, Chris Angelico wrote:
> On Wed, 15 Jun 2022 at 22:38, Steven D'Aprano wrote:
> > There's no consensus that this feature is worth the added complexity, or
> > even what the semantics are. The PEP punts on the semantics, saying t
On Wed, Jun 15, 2022 at 01:58:28PM +0100, Rob Cliffe via Python-ideas wrote:
> Please. This has been many times by several people already. No-one is
> going to change their mind on this by now. There's no point in
> rehashing it and adding noise to the thread.
Rob, there's no rule that only "
On Tue, Jun 14, 2022 at 11:59:44AM +0100, Rob Cliffe via Python-ideas wrote:
> I used to prefer `:=` but coming back to this topic after a long
> interval I am happy with `=>` and perhaps I even like it more, Chris.😁
> The PEP status is "Draft". What are the chances of something happening
> any
On Mon, Jun 13, 2022 at 07:41:12AM -0400, Todd wrote:
> This has been proposed many times. You can check the mailing list history.
> Such proposals have been even less popular then PEP 671, since it requires
> a new keyword, which is generally avoided at nearly all costs,
Now that Python is using
On Wed, Jun 15, 2022 at 10:44:28AM -, Mathew Elman wrote:
> Could this be the behaviour of passing in an Ellipsis? e.g.
>
> def foo(defaults_to_one=1):
> return defaults_to_one
>
> assert foo(...) == foo()
It isn't clear to me whether your question is a request for clarification
(does t
On Fri, Jun 10, 2022 at 09:59:36PM -0500, James Johnson wrote:
> I guess I was jumping to conclusions. Thank you for taking the time to look
> at my email.
>
> I apologize if I wasted your time.
No stress -- opening issues up for discussion is not a waste of time.
This would be a good time to me
On Wed, Jun 08, 2022 at 06:51:54AM -0500, James Johnson wrote:
> When an amateur develops code incorrectly, s/he sometimes ends up with a
> code object that doesn’t run because of intermediate compiler optimizations.
If that happens, that's a bug in the compiler. Optimizations should
never chang
On Tue, Jun 07, 2022 at 02:28:51PM -, martineznicolas41...@gmail.com wrote:
> Do you know if there has been discussions around why is the default
> argument is positional only in the dict methods get and pop?
Its probably just left over from earlier versions of Python when builtin
functions
Why don't you use the version from the itertools recipes?
```
from itertools import tee, filterfalse
def partition(pred, iterable):
"Use a predicate to partition entries into false entries and true entries"
# partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9
t1, t2 = tee(ite
On Mon, Jun 06, 2022 at 06:17:32PM +0200, Benedict Verhegghe wrote:
> There still is something wrong. I get the second list twice:
>
> odd, even = partition(lambda i: i % 2, range(20))
> print(list(odd))
> [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
> print(list(even))
> [0, 2, 4, 6, 8, 10, 12, 14, 16, 1
On Sun, Jun 05, 2022 at 09:11:41PM -, Steve Jorgensen wrote:
> m = {'a': 123, 'b': 456, 'c': 789}
> m.except(('a', 'c')) # {'b': 456}
> m.only(('b', 'c')) # {'b': 456, 'c': 789}
> m.values_at(('a', 'b')) # [123, 456]
Maybe I'm a bit slow because I haven't had my morning coffee yet, but I
On Sun, Jun 05, 2022 at 07:03:32AM +1000, Chris Angelico wrote:
> How is redundancy fundamentally good,
I don't know, you will have to ask somebody who is arguing that
"redundancy is fundamentally good", which is not me. Redundancy can be
either good or bad.
https://www.informationweek.com/gov
On Sat, Jun 04, 2022 at 11:16:18PM +1000, Chris Angelico wrote:
> > Redundancy is good:
> >
> > # Obviously, clearly wrong:
> > spam, eggs, cheese = islice(myvalues, 5)
>
> Yes but which part is wrong?
You're a professional programmer, so I am confident that you know the
answer to that
On Sat, Jun 04, 2022 at 10:04:39AM -, Steve Jorgensen wrote:
> OK. That's not terrible. It is a redundancy though, having to re-state
> the count of variables that are to be de-structured into on the left.
Redundancy is good:
# Obviously, clearly wrong:
spam, eggs, cheese = islice
On Sat, Jun 04, 2022 at 07:31:58AM -, Steve Jorgensen wrote:
> A contrived use case:
>
> with open('document.txt', 'r') as io:
> (line1, line2, *) = io
>
with open('document.txt', 'r') as io:
line1 = io.readline()
line2 = io.readline()
It would be lovely if
On Fri, Jun 03, 2022 at 06:43:59PM -, Nadav Misgav wrote:
> should I try to implement this? seems there is some acceptance
If you want to experiment with an implementation just for your own
pleasure, then go ahead. Or if you think that the implementation is
trivial and simple, and a working
On Mon, May 30, 2022 at 02:31:35PM -, fjwillemsen--- via Python-ideas wrote:
> 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].
It certainly does not do that.
>>> [1, 2, 3]*2
[1, 2, 3, 1, 2, 3]
Also, that's a lis
On Tue, May 24, 2022 at 04:31:13AM -, mguin...@gmail.com wrote:
> seek() and tell() works with opaque values, called cookies.
> This is close to low level details, but it is not pythonic.
Even after reading the issue you linked to, I am not sure I understand
either the issue, or your suggest
On Thu, May 26, 2022 at 08:28:24PM +1000, Steven D'Aprano wrote:
> Narrow builds were UCS-2; wide builds were UTC-32.
To be more precise, narrow builds were sort of a hybrid between an
incomplete version of UTF-16 and a superset of UCS-2.
Like UTF-16, if your code point was above U+
On Wed, May 25, 2022 at 06:16:50PM +0900, Stephen J. Turnbull wrote:
> mguin...@gmail.com writes:
>
> > There should be a safer abstraction to these two basic functions.
>
> There is: TextIOBase.read, then treat it as an array of code units
> (NOT CHARACTERS!!)
No need to shout :-)
Reading the
There are at least three existing ways to already do this.
(foo["bar"]
["baz"]
["eggs"]
["spam"]) = 1
foo["bar"][
"baz"][
"eggs"][
"spam"] = 1
foo["bar"]\
["baz"]\
["eggs"]\
["spam"] = 1
I think the first
On Wed, May 18, 2022 at 10:23:16PM +0300, Serhiy Storchaka wrote:
> try:
> expression block
> expect Exception if condition else ():
> expression block
Aside from the typo "expect" when it should be `except`, that is a
terrible thing to do to the people reading your code :-(
--
Steve
On Sun, May 15, 2022 at 03:34:15PM +0100, MRAB wrote:
> On 2022-05-15 03:10, Aaron Fink wrote:
> >Hello.
> >
> >I've been thinking it would be nice to be able to use await to suspend
> >execution until a condition is met (as represented by a function or
> >lambda which returns a boolean.
[...]
>
On Sun, May 15, 2022 at 07:32:56PM -0300, Rafael Nunes wrote:
> Hi. Thanks for asking.
> In .BAT files we could write some Windows Shell commands before python code
> and python interpreter would ignore them.
Hi Rafael,
You have answered Eric's question with *what* you would do (write
Windows S
Users of the statistics module, how often do you use it with
heterogeneous data (mixed numeric types)?
Currently most of the functions try hard to honour homogeneous data,
e.g. if your data is Decimal or Fraction, you will (usually) get Decimal
or Fraction results:
>>> statistics.variance([Dec
On Sun, May 08, 2022 at 04:00:47PM +0100, Rob Cliffe wrote:
> Yes, I know unrestricted use of the walrus can lead to obfuscated code
> (and some of Steven's examples below might be cited as instances 😁).
They're intended as the simplest, least obfuscatory examples of using
the walrus operator
On Sun, May 08, 2022 at 03:59:07PM +0100, MRAB wrote:
> > # Currently a syntax error.
> > results = (1, 2, (a, b) := (3, 4), 5)
> >
> Doesn't ':=' have a lower precedence than ',', so you're effectively
> asking it to bind:
>
> (1, 2, (a, b))
>
> to:
>
> ((3, 4), 5)
Possibly.
I don't have an opinion one way or the other, but there is a discussion
on Discourse about the walrus operator:
https://discuss.python.org/t/walrus-fails-with/15606/1
Just a quick straw poll, how would people feel about relaxing the
restriction on the walrus operator so that iterable unpacking
On Sun, May 08, 2022 at 11:02:22AM +1000, Chris Angelico wrote:
> On Sun, 8 May 2022 at 10:23, Steven D'Aprano wrote:
> > Outside of that narrow example of auto-assignment of attributes, can
> > anyone think of a use-case for this?
> >
>
> Honestly, I don'
On Sat, May 07, 2022 at 04:01:34AM -, python-id...@lucas.rs wrote:
> If you had to get the user where user['id'] == 2 from this list of
> users, for example, how would you do it?
>
> users = [
> {'id': 1,'name': 'john'},
> {'id': 2, 'name': 'anna'},
> {'id': 3, 'name': 'bruce'},
On Sat, May 07, 2022 at 11:38:19AM -0700, Ethan Furman wrote:
> > I'd define it very simply. For positional args, these should be
> > exactly equivalent:
> >
> > def func(self, x, x.y):
> > ...
> >
> > def func(*args):
> > self, x, x.y = args
> > ...
>
> Simple or not, I don't thin
On Mon, May 02, 2022 at 08:23:31PM -0700, Christopher Barker wrote:
> On Mon, May 2, 2022 at 11:18 AM Steven D'Aprano
>
> > why one couldn't just use the redirect_stdout context manager.
> >
> > (Plus not-yet-existing, but hopefully soon, redirect_stdin.)
>
&
On Sun, May 01, 2022 at 10:40:49PM -0700, Christopher Barker wrote:
> Yes, any class could use this feature (though it's more limited than what
> dataclasses do) -- what I was getting is is that it would not be
> (particularly) useful for all classes -- only classes where there are a lot
> of __i
On Mon, May 02, 2022 at 07:44:14PM +0100, Paul Moore wrote:
> I have classes with 20+ parameters (packaging metadata). You can argue
> that a dataclass would be better, or some other form of refactoring,
> and you may actually be right. But it is a legitimate design for that
> use case.
Indeed.
On Mon, May 02, 2022 at 07:55:16PM -, sam.z.e...@gmail.com wrote:
> Using the prospective redirect_stdin context manager, the following code
>
> ```
> with open("/dev/tty", 'r+') as file:
> with contextlib.redirect_stdin(file), contextlib.redirect_stdout(file):
> name = input('Nam
On Mon, May 02, 2022 at 05:42:12PM -, sam.z.e...@gmail.com wrote:
> input(prompt=None, /, infile=None, outfile=None)
> What do people think about this?
I think I want to see some examples of how and why you would use it, and
why one couldn't just use the redirect_stdout context manager.
(P
On Mon, May 02, 2022 at 05:29:56PM -, sam.z.e...@gmail.com wrote:
> > There's already contextlib.redirect_stdout() and
> > contextlib.redirect_stderr(). Adding contextlib.redirect_stdin() would
> > be logical, but I think a more flexible
> >
> > contextlib.redirect_stdio(stdin=None, stdou
On Mon, May 02, 2022 at 10:34:56AM -0600, Pablo Alcain wrote:
> For what it's worth,
> the choice of the `@` was because of two different reasons: first, because
> we were inspired by Ruby's syntax (later on learned that CoffeeScript and
> Crystal had already taken the approach we are proposing) a
On Mon, May 02, 2022 at 05:57:45PM +0900, Stephen J. Turnbull wrote:
> def __init__(s, s.x, s.y): pass
I think that if this proposal threatens to encourage people to write
that horro, that would be enough of a reason to reject it.
--
Steve
___
Python
On Sun, May 01, 2022 at 06:22:08PM -0700, Devin Jeanpierre wrote:
> Is it unreasonable to instead suggest generalizing the assignment target
> for parameters? For example, if parameter assignment happened left to
> right, and allowed more than just variables, then one could do:
>
> def __init__(s
On Mon, May 02, 2022 at 09:58:35AM +0200, Marc-Andre Lemburg wrote:
> Just a word of warning: numeric bases are not necessarily the same
> as numeric encodings. The latter usually come with other formatting
> criteria in addition to representing numeric values, e.g. base64 is
> an encoding and not
On Sat, Apr 30, 2022 at 11:54:47PM -0700, Christopher Barker wrote:
> On Sat, Apr 30, 2022 at 6:40 PM Steven D'Aprano wrote:
>
> > On Sat, Apr 23, 2022 at 12:11:07PM -0700, Christopher Barker wrote:
> > > Absolutely. However, this is not an "all Classes" q
On Sat, Apr 23, 2022 at 12:11:07PM -0700, Christopher Barker wrote:
> On Sat, Apr 23, 2022 at 10:53 AM Pablo Alcain wrote:
>
> > Overall, I think that not all Classes can be thought of as Dataclasses
> > and, even though dataclasses solutions have their merits, they probably
> > cannot be extende
On Thu, Apr 28, 2022 at 01:18:09AM -, zmvic...@gmail.com wrote:
> *Background*
> It is frequently desirable to delete a dictionary entry if the key
> exists.
Frequently?
I don't think I've ever needed to do that. Can you give an example of
real code that does this?
> It is necessary to ch
On Mon, Apr 25, 2022 at 03:38:21PM -, aanonyme.perso...@hotmail.fr wrote:
> Typically, when subclassing a NamedTuple type, you often don't want
> the <, >, <=, >=, + or * operators to work, so in that case you would
> want for the related methods to return NotImplemented.
When I have subcla
On Sun, Apr 17, 2022 at 07:39:29PM +1200, Greg Ewing wrote:
> On 16/04/22 10:26 pm, Steven D'Aprano wrote:
> >C++ and Eiffel are even stricter (more restrictive) than Python. They
> >don't just exclude class hierarchies which are inconsistent, they
> >exclude class
On Sat, Apr 23, 2022 at 10:18:05PM +0900, Stephen J. Turnbull wrote:
> malmiteria writes:
> > If O1 and O2 are refactored into N1(GP) and N2(GP)
> > the MRO as it was before refactoring was essentially N1, GP, N2, GP,
> > as what was O1 before refactoring is equivalent to N1, GP after
> > ref
On Fri, Apr 22, 2022 at 08:46:38PM +1100, Matsuoka Takuo wrote:
> On Fri, 22 Apr 2022 at 15:47, Christopher Barker wrote:
> >
> > Sure -- but there's nothing special or difficult here -- refactoring
> > can create breaking changes. I believe it was part of Hettinger's
> > thesis in "Super Consid
On Wed, Apr 20, 2022 at 03:43:44PM -, malmiteria wrote:
> to give you exemples of problems :
> 1) let's start with a django problem :
> ```
> class MyView(ModelView, PermissionMixin): pass
> ```
> doesn't apply any of the PermissionMixin logic to the view.
> It doesn't raise a single error ei
On Sat, Apr 16, 2022 at 12:23:10PM -0400, David Mertz, Ph.D. wrote:
> R doesn't have inheritance, it's not OOP,
R is OOP and always has been. All values, arrays, functions etc in R are
objects. Even expressions are objects. And it has inheritance.
https://cran.r-project.org/doc/manuals/r-releas
On Sat, Apr 16, 2022 at 05:27:57PM +1200, Greg Ewing wrote:
> On 15/04/22 10:37 pm, Steven D'Aprano wrote:
> >If you look at languages that implement MI, and pick the implementations
> >which allow it with the fewest restrictions, then that is "full MI".
>
&g
1 - 100 of 1212 matches
Mail list logo