Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #71860

Re: All-numeric script names and import

References <CAPTjJmoadqpS0O-15We7xi7SzFCVxTFe1TU8hConcGZzxTRdcA@mail.gmail.com> <llidct$hi8$1@ger.gmane.org>
Date 2014-05-22 00:43 +1000
Subject Re: All-numeric script names and import
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.10195.1400683422.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, May 22, 2014 at 12:32 AM, Dave Angel <davea@davea.name> wrote:
> I don't think there's any question of dumbhood,  but the answer
>  should be found in the formal grammar document.

Yeah, I figured it'd be an issue of the grammar. It expects 1 to mean
an integer, not a name - which in most contexts is correct (you can't
go "1 = 2" because 1 isn't a name). In some contexts you can force a
different interpretation, so for instance you can look at attributes
of an integer literal as (1).real even though 1.real is an error; but
I couldn't find a way to fiddle this one. And the only way I could
find to pass a string was to use __import__(). So is that the only
way?

Same thing would happen, I guess, if you have dots in the file name. A
file called "foo.bar.py" probably can't be imported.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: All-numeric script names and import Chris Angelico <rosuav@gmail.com> - 2014-05-22 00:43 +1000

csiph-web