On Mon, May 7, 2018 at 9:17 AM, Steven D'Aprano wrote:
> I'm arguing that for some people, your preferred syntax *is* more
> distracting and hard to comprehend than the more self-descriptive
> version with named functions.
then use Path.joinpath() if you want.
> From that perspective, using /
On Tue, May 15, 2018 at 10:11 PM Rob Speer wrote:
> From what I can tell, if you wanted to exclude '__init__.py' from Nginx in
> particular, you would have to write an unconventional Nginx configuration,
> where you determine whether a path refers to a static file according to a
> regex that excl
> Are you saying that servers like Nginx or whatever your mini-server uses
don’t have a way to blanket ignore files? That would surprise me, and it
seems like a lurking security vulnerability regardless of
importlib.resources or __init__.py files. I would think that you’d want to
whitelist file e
On May 15, 2018, at 14:03, Rob Speer wrote:
> Consider a mini-Web-server written in Python (there are, of course, lots of
> these) that needs to serve static files. Users of the Web server will expect
> to be able to place these static files somewhere relative to the directory
> their code is
While importlib.resources looks very good, I'm certain that it can't
replace every use of __file__ for accessing files relative to your Python
code.
Consider a mini-Web-server written in Python (there are, of course, lots of
these) that needs to serve static files. Users of the Web server will
exp
Yuval Greenfield wrote:
I often need to reference a script's current directory. I end up writing:
import os
SRC_DIR = os.path.dirname(__file__)
The question I have is, why do you want to reference the script's
current directory?
If the answer is to access other files in that directory, the
On 2018-05-07 09:17, Steven D'Aprano wrote:
I'm arguing that for some people, your preferred syntax*is* more
distracting and hard to comprehend than the more self-descriptive
version with named functions. And its not just a matter of*learning*
the API, it is a matter of using it so often that it
On Sun, May 6, 2018 at 9:30 PM, Mike Miller
wrote:
> 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
On Mon, 7 May 2018 at 08:17 Serhiy Storchaka wrote:
> 07.05.18 17:42, Eric Snow пише:
> > I'm not necessarily saying we should add ModuleSpec.dirname(), but it
> > (or something like it) is what I'd advocate for *if* we were to add a
> > convenient shortcut to the directory a module is in. FWIW,
On Mon, May 07, 2018 at 11:42:00AM +, Nathaniel Smith wrote:
> On Mon, May 7, 2018, 03:45 Steven D'Aprano wrote:
[...]
> > So yes, its very distracting.
>
> Well, yes, you do have to know the API to use it, and if you happen to have
> learned the os.path API but not the pathlib API then of c
07.05.18 17:42, Eric Snow пише:
I'm not necessarily saying we should add ModuleSpec.dirname(), but it
(or something like it) is what I'd advocate for *if* we were to add a
convenient shortcut to the directory a module is in. FWIW, I'd
probably use it.
The question is *why* you need the absolut
On Mon, May 7, 2018 at 7:14 AM, Serhiy Storchaka wrote:
> * Additional burden on maintainers of import machinery. It is already too
> complex, and __file__ is set in multiple places. Don't forgot about
> third-party implementations.
>
> See also issue33277: "Deprecate __loader__, __package__, __fi
06.05.18 09:53, Yuval Greenfield пише:
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
On Mon, May 7, 2018 at 8:44 PM, Steven D'Aprano wrote:
> On Sun, May 06, 2018 at 09:33:03PM -0700, Nathaniel Smith wrote:
>
>> How is
>>
>> data_path = __filepath__.parent / "foo.txt"
>>
>> more distracting than
>>
>> data_path = joinpath(dirname(__file__), "foo.txt")
>
>
> Why are you dividing by
On 7 May 2018 at 21:42, Nathaniel Smith wrote:
> On Mon, May 7, 2018, 03:45 Steven D'Aprano wrote:
>
>> On Sun, May 06, 2018 at 09:33:03PM -0700, Nathaniel Smith wrote:
>>
>> > How is
>> >
>> > data_path = __filepath__.parent / "foo.txt"
>> >
>> > more distracting than
>> >
>> > data_path = join
On 7 May 2018 at 20:44, Steven D'Aprano wrote:
> First I have to work out what __filepath__ is, then I have to remember
> the differences between all the various flavours of pathlib.Path
> and suffer a moment or two of existential dread as I try to work out
> whether or not *this* specific flavou
On Mon, May 7, 2018, 03:45 Steven D'Aprano wrote:
> On Sun, May 06, 2018 at 09:33:03PM -0700, Nathaniel Smith wrote:
>
> > How is
> >
> > data_path = __filepath__.parent / "foo.txt"
> >
> > more distracting than
> >
> > data_path = joinpath(dirname(__file__), "foo.txt")
>
>
> Why are you dividing
On Sun, May 06, 2018 at 09:33:03PM -0700, Nathaniel Smith wrote:
> How is
>
> data_path = __filepath__.parent / "foo.txt"
>
> more distracting than
>
> data_path = joinpath(dirname(__file__), "foo.txt")
Why are you dividing by a string? That's weird.
[looks up the pathlib docs]
Oh, that's w
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 pathlib.Path(__file__)?
> >>
> >> Promoting os.path stu
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 imagi
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 pathlib is emerging as
>> TOOWTDI makes
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* TOOWTDI, since it t
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 12:35, Chris Angelico
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
> > being builtins?
> >
> > Specifically,
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:
>
> - dirname (aka os.p
On 7 May 2018 at 03:44, Chris Angelico wrote:
> 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:
> >>>
> >>> impor
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 = os.path.dirname(__file__)
> I would give +1 for __d
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 end up writing:
>>
>> import os
>> SRC_DIR = os.pa
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 would prefer to have a new d
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 so
31 matches
Mail list logo