On 7 May 2018 at 14:33, Nathaniel Smith wrote:
> On Sun, May 6, 2018 at 8:47 PM, Nick Coghlan wrote:
> > On 7 May 2018 at 13:33, Nathaniel Smith wrote:
> >>
> >> Spit-balling: how about __filepath__ as a
> >> lazily-created-on-first-access
On 2018-05-06 19:13, Nick Coghlan wrote:
Specifically, the ones I'd have in mind would be:
- dirname (aka os.path.dirname)
- joinpath (aka os.path.join)
- abspath (aka os.path.abspath)
Yes, I end up importing those in most scripts currently. Just "join" has worked
fine, although I could
On Sun, May 6, 2018 at 8:47 PM, Nick Coghlan wrote:
> On 7 May 2018 at 13:33, Nathaniel Smith wrote:
>>
>> Spit-balling: how about __filepath__ as a
>> lazily-created-on-first-access pathlib.Path(__file__)?
>>
>> Promoting os.path stuff to builtins just as
> On May 6, 2018, at 6:00 AM, Steven D'Aprano wrote:
>
> On Thu, May 03, 2018 at 04:32:09PM +1000, Steven D'Aprano wrote:
>
>> Maybe I'm slow today, but I'm having trouble seeing how to write this as
>> a lambda.
>
> Yes, I was definitely having a "cannot brain, I have
On 7 May 2018 at 13:33, Nathaniel Smith wrote:
> Spit-balling: how about __filepath__ as a
> lazily-created-on-first-access pathlib.Path(__file__)?
>
> Promoting os.path stuff to builtins just as pathlib is emerging as
> TOOWTDI makes me a bit uncomfortable.
>
pathlib *isn't*
[Tim]
>> I have a long history of arguing that magically created lexically
>> nested anonymous functions try too hard to behave exactly like
>> explicitly typed lexically nested functions, but that's the trendy
>> thing to do so I always lose ;-)
[Nick Coghlan ]
> You have the
Spit-balling: how about __filepath__ as a
lazily-created-on-first-access pathlib.Path(__file__)?
Promoting os.path stuff to builtins just as pathlib is emerging as
TOOWTDI makes me a bit uncomfortable.
On Sun, May 6, 2018 at 8:29 PM, Nick Coghlan wrote:
> On 7 May 2018 at
On 7 May 2018 at 12:35, Chris Angelico wrote:
> On Mon, May 7, 2018 at 12:13 PM, Nick Coghlan wrote:
> > So I have a different suggestion: perhaps it might make sense to propose
> > promoting a key handful of path manipulation operations to the status of
>
[Tim]
>> There's a difference, though: if `y` "leaks", BFD. Who cares? ;-)
>> If `y` remains inaccessible, there's no way around that.
[Chris]
> That's Steve D'Aprano's view - why not just let them ALL leak? I don't
> like it though.
I didn't suggest that. I'm not suggesting changing _any_
On 7 May 2018 at 12:51, Nick Coghlan wrote:
> If any other form of comprehension level name binding does eventually get
> accepted, then inline scope declarations could similarly be used to hoist
> values out into the surrounding scope:
>
> rem = None
> while
On Mon, May 7, 2018 at 12:34 PM, Tim Peters wrote:
>> That's a fair point. But there is another equally valid use-case for
>> assignment expressions inside list comps:
>>
>> values = [y + 2 for x in iter if (y := f(x)) > 0]
>>
>> In this case, it's just as obvious that the
On 7 May 2018 at 11:32, Tim Peters wrote:
> I have a long history of arguing that magically created lexically
> nested anonymous functions try too hard to behave exactly like
> explicitly typed lexically nested functions, but that's the trendy
> thing to do so I always lose
[Tim]
>> In a different thread I noted that I sometimes want to write code like
>> this:
>> ...
>>while any(n % (thisp := p) == 0 for p in small_primes):
>>n //= thisp
>> ...
[Ryan Gonzalez ]
> Couldn't you just do:
>
> def first(it):
>return next(it, None)
>
>
On Sun, May 6, 2018 at 7:37 PM, Matt Arcidy wrote:
>> Personally, I'd still like to go back to := creating a statement-local
>> name, one that won't leak out of ANY statement. But the tide was
>> against that one, so I gave up on it.
>
> yes.
>
> I have some probably tangential
> Personally, I'd still like to go back to := creating a statement-local
> name, one that won't leak out of ANY statement. But the tide was
> against that one, so I gave up on it.
yes.
I have some probably tangential to bad arguments but I'm going to make
them anyways, because I think := makes
On Mon, May 7, 2018 at 12:13 PM, Nick Coghlan wrote:
> So I have a different suggestion: perhaps it might make sense to propose
> promoting a key handful of path manipulation operations to the status of
> being builtins?
>
> Specifically, the ones I'd have in mind would be:
>
[Chris Angelico ]
> ...
> You're correct. The genexp is approximately equivalent to:
>
> def genexp():
> for p in small_primes:
> thisp = p
> yield n % thisp == 0
> while any(genexp()):
> n //= thisp
>
> With generator expressions, since they won't
On May 6, 2018 8:41:26 PM Tim Peters wrote:
In a different thread I noted that I sometimes want to write code like this:
while any(n % p == 0 for p in small_primes):
# divide p out - but what's p?
But generator expressions hide the value of `p` that
On Mon, May 7, 2018 at 11:32 AM, Tim Peters wrote:
> In a different thread I noted that I sometimes want to write code like this:
>
> while any(n % p == 0 for p in small_primes):
> # divide p out - but what's p?
>
> But generator expressions hide the value of `p`
In a different thread I noted that I sometimes want to write code like this:
while any(n % p == 0 for p in small_primes):
# divide p out - but what's p?
But generator expressions hide the value of `p` that succeeded, so I
can't. `any()` and `all()` can't address this themselves -
On Mon, May 7, 2018 at 1:05 AM, George Fischhof wrote:
>> On Sun, May 6, 2018, 1:54 AM Yuval Greenfield
>> wrote:
>>>
>>> Hi Ideas,
>>>
>>> I often need to reference a script's current directory. I end up writing:
>>>
>>> import os
>>> SRC_DIR =
2018-05-06 15:28 GMT+02:00 Cody Piersall :
> With PEP 562, the name __dir__ is off limits for this.
>
> Cody
>
> On Sun, May 6, 2018, 1:54 AM Yuval Greenfield
> wrote:
>
>> Hi Ideas,
>>
>> I often need to reference a script's current directory. I
With PEP 562, the name __dir__ is off limits for this.
Cody
On Sun, May 6, 2018, 1:54 AM Yuval Greenfield wrote:
> Hi Ideas,
>
> I often need to reference a script's current directory. I end up writing:
>
> import os
> SRC_DIR = os.path.dirname(__file__)
>
>
> But I
On Sun, May 06, 2018 at 06:53:11AM +, Yuval Greenfield wrote:
> Hi Ideas,
>
> I often need to reference a script's current directory. I end up writing:
>
> import os
> SRC_DIR = os.path.dirname(__file__)
>
>
> But I would prefer to have a new dunder for that. I propose: "__dir__". I
> was
Hi Ideas,
I often need to reference a script's current directory. I end up writing:
import os
SRC_DIR = os.path.dirname(__file__)
But I would prefer to have a new dunder for that. I propose: "__dir__". I
was wondering if others would find it convenient to include such a shortcut.
Here are
25 matches
Mail list logo