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


Groups > comp.lang.python > #77061 > unrolled thread

IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?

Started byTwirlip2 <ahrodg@googlemail.com>
First post2014-08-26 11:01 -0700
Last post2014-08-27 02:04 -0700
Articles 20 on this page of 35 — 10 participants

Back to article view | Back to comp.lang.python


Contents

  IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 11:01 -0700
    Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Terry Reedy <tjreedy@udel.edu> - 2014-08-26 14:46 -0400
      Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 12:20 -0700
        Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 12:44 -0700
          Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 12:58 -0700
            Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-26 21:15 +0100
          Re: IDLE has suddenly become FAWLTY - so should I be hitting it with   a big stick, or what? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-08-27 10:03 +1200
            Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 15:55 -0700
              Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-27 08:25 -0700
            Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-27 10:01 +1000
              Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 17:06 -0700
              Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Chris Angelico <rosuav@gmail.com> - 2014-08-27 10:18 +1000
          Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-27 00:20 +0100
            Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 16:29 -0700
              Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Terry Reedy <tjreedy@udel.edu> - 2014-08-26 20:51 -0400
                Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 18:11 -0700
                  Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Terry Reedy <tjreedy@udel.edu> - 2014-08-27 00:03 -0400
                    Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-27 02:12 -0700
      Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 12:26 -0700
        Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-08-26 14:46 -0500
    Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Grant Edwards <invalid@invalid.invalid> - 2014-08-26 18:59 +0000
    Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Chris Angelico <rosuav@gmail.com> - 2014-08-27 09:07 +1000
      Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 16:25 -0700
        Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? Chris Angelico <rosuav@gmail.com> - 2014-08-27 09:42 +1000
        Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-27 10:04 +1000
          Re: Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 17:08 -0700
            Re: Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Chris Angelico <rosuav@gmail.com> - 2014-08-27 10:21 +1000
              Re: Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 17:58 -0700
                Re: Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Twirlip2 <ahrodg@googlemail.com> - 2014-08-26 18:06 -0700
                Re: Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Chris Angelico <rosuav@gmail.com> - 2014-08-27 12:36 +1000
                  Re: Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Rustom Mody <rustompmody@gmail.com> - 2014-08-26 20:13 -0700
                    Re: Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Chris Angelico <rosuav@gmail.com> - 2014-08-27 14:55 +1000
                      Re: Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Twirlip2 <ahrodg@googlemail.com> - 2014-08-27 01:50 -0700
                Re: Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2014-08-27 10:12 +0200
                  Re: Python conquors the BBC [was Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?] Twirlip2 <ahrodg@googlemail.com> - 2014-08-27 02:04 -0700

Page 1 of 2  [1] 2  Next page →


#77061 — IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-26 11:01 -0700
SubjectIDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?
Message-ID<4eec9365-4103-4474-a47f-ea665b265b1e@googlegroups.com>
I've been using IDLE with Python 3.4.0 on Windows XP (SP3), since March this year, and since May I've been running IDLE almost continuously, using it scores of times every day, mostly to run the same script (for running a media player on BBC WMA streams, to bypass the dreaded iPlayer).

No problems, until today.

For a few days, I'd been frequently running a second instance of IDLE, to test a new version of the same script.  Today, having closed this instance, I tried to open one again, but I briefly saw an error message about not being able to create a thread, or something like that. I'd seen similar messages before, but all that had ever been needed was to terminate a few other processes, and try again.  Not this time, however.

I closed the first IDLE instance as well - and since then, I haven't been able to get any instance of IDLE to run at all!

I have tried the following, all without success:

1. Closed other processes, and retried (as just mentioned).

2. Logged off, logged into an admin account, and tried running IDLE there.  Still nothing happened, and still nothing showed in Task Manager | Processes.

3. Installed 3.4.1 (over 3.4.0). It made no difference to the problem. (I also had to do a hard reboot of the system, after it had completely ground to a halt when I tried to reboot in the normal way.)

4. Disabled the router (for safety), then (temporarily) disabled the antivirus program.  No joy.

5. Rebooted, instructed Windows Firewall to make an exception for pythonw.exe.  Still no joy.

6. Downloaded Process Monitor, from <http://technet.microsoft.com/en-us/sysinternals/bb896645>, installed it, ran it, and filtered to show all events having process name 'pythonw.exe', and any result other than 'SUCCESS'. There were hundreds of such events, including many stating 'buffer overflow'. (I'll go into an admin account, run Process Monitor again, and give details of the results, if it will help.)

7. Deleted .idlerc - this had no effect on the problem, so I restored it.

8. Created shortcut with target <I:\Python34\Lib\idlelib\idle.bat -n>, and double-clicked it, with no effect.

9. Ran the same command in a Windows command shell window.  Still no result.

I think that's everything I've tried, so far.  I'm pretty exhausted now, so I thought I'd ask for help.  Any ideas?

[toc] | [next] | [standalone]


#77064

FromTerry Reedy <tjreedy@udel.edu>
Date2014-08-26 14:46 -0400
Message-ID<mailman.13475.1409078833.18130.python-list@python.org>
In reply to#77061
On 8/26/2014 2:01 PM, Twirlip2 wrote:
> I've been using IDLE with Python 3.4.0 on Windows XP (SP3),
...

Does all non-Python stuff seem to be working?

> For a few days, I'd been frequently running a second instance of
> IDLE, to test a new version of the same script.  Today, having closed
> this instance, I tried to open one again, but I briefly saw an error
> message about not being able to create a thread, or something like
> that.

In Command Prompt, 'python -m idlelib' should run Idle and display 
(without disappearing) any available error messages.

Idle imports tkinter which imports threading. If that fails, Idle never 
visibly starts.  If the imports succeed, and Idle starts, but cannot 
connect to a subprocess, it displays a message in Shell. (I have 
occasionally seen this, but close Idle and retry always works.)  Your 
description suggests the former.

Does 'python' itself start. If so, and you get interactive prompt, does 
'import threading' work?  Ditto 'import tkinter'?  If so, does 
'tkinter.Tk()' bring up an empty tk window?

Back at interactive prompt, what happens with 'python -m test'?  There 
are a couple of modules that may sometimes fail, but the rest should not.

> 3. Installed 3.4.1 (over 3.4.0). It made no difference to the
> problem. (I also had to do a hard reboot of the system, after it had
> completely ground to a halt when I tried to reboot in the normal
> way.)

Upgrading on top of broken Python may not work. If the tests above fail, 
re-install after un-installing.  Un-installing will leave /python34 but 
only with things you added (or separately installed). You may need to 
're-install' 3.4.0 to un-install.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#77067

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-26 12:20 -0700
Message-ID<5a9b5715-382b-4a6b-be90-c535ad14740a@googlegroups.com>
In reply to#77064
On Tuesday, 26 August 2014 19:46:55 UTC+1, Terry Reedy  wrote:
> On 8/26/2014 2:01 PM, Twirlip2 wrote:
> 
> > I've been using IDLE with Python 3.4.0 on Windows XP (SP3),
> 
> ...
> 
> 
> 
> Does all non-Python stuff seem to be working?

Yes.
 
> > For a few days, I'd been frequently running a second instance of
> 
> > IDLE, to test a new version of the same script.  Today, having closed
> 
> > this instance, I tried to open one again, but I briefly saw an error
> 
> > message about not being able to create a thread, or something like
> 
> > that.
> 
> 
> 
> In Command Prompt, 'python -m idlelib' should run Idle and display 
> 
> (without disappearing) any available error messages.

See below - it's starting to become much clearer what has happened (but it's not all clear yet) - thanks muchly for this suggestion!
 
> Idle imports tkinter which imports threading. If that fails, Idle never 
> 
> visibly starts.  If the imports succeed, and Idle starts, but cannot 
> 
> connect to a subprocess, it displays a message in Shell. (I have 
> 
> occasionally seen this, but close Idle and retry always works.)  Your 
> 
> description suggests the former.
> 
> 
> 
> Does 'python' itself start. If so, and you get interactive prompt, does 
> 
> 'import threading' work?  Ditto 'import tkinter'?  If so, does 
> 
> 'tkinter.Tk()' bring up an empty tk window?

All those 4 things worked normally.

> Back at interactive prompt, what happens with 'python -m test'?  There 
> 
> are a couple of modules that may sometimes fail, but the rest should not.

I'll try this later - just out of interest - but your first suggestion has already borne fruit.

> > 3. Installed 3.4.1 (over 3.4.0). It made no difference to the
> 
> > problem. (I also had to do a hard reboot of the system, after it had
> 
> > completely ground to a halt when I tried to reboot in the normal
> 
> > way.)
> 
> 
> 
> Upgrading on top of broken Python may not work. If the tests above fail, 
> 
> re-install after un-installing.  Un-installing will leave /python34 but 
> 
> only with things you added (or separately installed). You may need to 
> 
> 're-install' 3.4.0 to un-install.

Mercifully, it looks like Python is not broken, but I have done something Silly!

The result of "python -m idlelib" in a Windows command window is a short stack of error messages, culminating in the revelation that Python is trying to execute (or at any rate syntax-check) one of the many source code I files I had just spent the entire morning and much of the afternoon editing.

Of course, they are bound to be festooned with errors; the reason I was trying to start the second IDLE instance, in the first place, was to start trying to debug all the work I had just done, but I was never able to get to it!

What I don't yet understand is why Python is trying to execute anything at all.

But I'm sure there's a simple explanation, and there'll certainly be at least a workaround, even if I have to temporarily move all my recently-edited source code files to another location!

Thanks again.

[toc] | [prev] | [next] | [standalone]


#77070

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-26 12:44 -0700
Message-ID<b92274f5-6ed8-451a-b01a-0874a1048b54@googlegroups.com>
In reply to#77067
On Tuesday, 26 August 2014 20:20:22 UTC+1, Twirlip2  wrote:
> Mercifully, it looks like Python is not broken, but I have done something Silly!
> 
> [...]
> 
> What I don't yet understand is why Python is trying to execute anything at all.
> 
> 
> 
> But I'm sure there's a simple explanation, and there'll certainly be at least a workaround, even if I have to temporarily move all my recently-edited source code files to another location!

The truth is that Python WAS broken, but it was (unsurprisingly) me wot broke it!

I had, in effect, already hit it with a "big stick", by naming one of my newly-created modules 'code.py' - thus evidently creating a name conflict with the standard module I:\Python34\Lib\code.py.

There is probably some lesson I should learn from this.

Meanwhile, let me try renaming my module, and see what happens ...

[toc] | [prev] | [next] | [standalone]


#77072

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-26 12:58 -0700
Message-ID<d76a4821-e2e5-4115-acdc-847334df61b1@googlegroups.com>
In reply to#77070
On Tuesday, 26 August 2014 20:44:35 UTC+1, Twirlip2  wrote:

> Meanwhile, let me try renaming my module, and see what happens ...

Whoopee, IDLE is back!

I need to sit down for a while, and just relax.  Oh look, there's a nice comfy chair!  Surely nothing unexpected can happen now.

[toc] | [prev] | [next] | [standalone]


#77073

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-08-26 21:15 +0100
Message-ID<mailman.13478.1409084146.18130.python-list@python.org>
In reply to#77072
On 26/08/2014 20:58, Twirlip2 wrote:
> On Tuesday, 26 August 2014 20:44:35 UTC+1, Twirlip2  wrote:
>
>> Meanwhile, let me try renaming my module, and see what happens ...
>
> Whoopee, IDLE is back!
>
> I need to sit down for a while, and just relax.  Oh look, there's a nice comfy chair!  Surely nothing unexpected can happen now.
>

Just when you thought it was safe, nobody expects the Batley Townswomen 
Guild's reenactment of the Battle of Pearl Harbour 
https://www.youtube.com/watch?v=kcSMaNlcDPs

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#77076 — Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2014-08-27 10:03 +1200
SubjectRe: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?
Message-ID<c64eh8F4jkuU1@mid.individual.net>
In reply to#77070
Twirlip2 wrote:
> There is probably some lesson I should learn from this.

The lesson is probably that you shouldn't put the code
you're developing somewhere that's on the default import
path.

Although shadowing builtin module names is never a good
idea, either!

-- 
Greg

[toc] | [prev] | [next] | [standalone]


#77078

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-26 15:55 -0700
Message-ID<696490b0-065f-4a6a-b6fd-3e760d168140@googlegroups.com>
In reply to#77076
On Tuesday, 26 August 2014 23:03:20 UTC+1, Gregory Ewing  wrote:

> Twirlip2 wrote:
> 
> > There is probably some lesson I should learn from this.
> 
> 
> 
> The lesson is probably that you shouldn't put the code
> 
> you're developing somewhere that's on the default import path.

Most of what I was doing today was splitting up one too-large module into more reasonable-sized and comprehensible pieces - there's still a long way to go! - and arranging for these now-separate modules to import only what they needed from each other.

I had already learned, from section 12.8.5 of Chun's 'Core Python Programming', 2nd ed., how to avoid an interminable cycle of mutual import attempts.

Thus, for example, in one module, I have:

# \Work\Comp\Python\Lib\user.py

"""More functions for interacting with the user in a console session."""

# The importation of these names:
#
#     BeebToken from beeb.py
#     CodeToken from prog.py
#
# has to be postponed for a short while, in order to avoid an interminable
# cycle of attempted importations.

[... some definitions ...]

from beeb import BeebToken
from prog import CodeToken

[etc.]

and then, for example, in one of those two modules (the one that was originally FAR too large, and is still an ugly mess), I have:

# \Work\Comp\Python\Lib\beeb.py

"""Listen to streaming audio."""

# Standard Python 3 library stuff:

from configparser   import ConfigParser
from datetime       import datetime
from functools      import partial
from html.parser    import HTMLParser
from math           import ceil
from os             import getenv, system
from sys            import argv
from urllib.request import urlopen

# My Python 3 library stuff, from <\Work\Comp\Python\Lib\>:

from console3 import get_val
from misc3    import null
from kernel   import Kernel, WebPage
from user     import UserToken, TokenStack

[...]

[By the way, I've read recently - in section 12.5.3 of Chun's book - that all this "from ... import..." stuff that I've been doing is bad style.  That's one of the less urgent things I'll get around to fixing eventually.  At least today I've had a painful lesson in the importance of keeping namespaces clean and tidy!  So I will fix it.  But there are worse things wrong with my code, needing more urgent attention - although the bit I was editing today does work, and the error with the r'\' string was, surprisingly, the only [new] bug in it, apart from an understandable failure to import a few necessary names.]

This works fine - now that the horrible name clash has been resolved! - but it still leaves me open to a recurrence of the same problem, if I get careless.

How do I go about putting my own unstable modules in a safer location, while still being able to import what I want from them?

There's something in Chun's book, which I hadn't read (section 12.7.4), about "relative imports": is that what I should be looking at?

> Although shadowing builtin module names is never a good
> 
> idea, either!

It doesn't seem immediately obvious how to get a definitive list of which names to avoid using (and therefore, inadvertently 'shadowing', as I did today).

For example, <https://docs.python.org/3/tutorial/modules.html#standard-modules> doesn't list the filename 'code.py', which is the one I clashed with today.

Of course, if all else fails, I will be sure to manually search the Python installation directory for possible clashes, but there must be a more logically secure way, one more integral to the language itself.

[toc] | [prev] | [next] | [standalone]


#77138

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-27 08:25 -0700
Message-ID<9c3a125a-7137-495f-b26c-4098360ba21d@googlegroups.com>
In reply to#77078
On Tuesday, 26 August 2014 23:55:51 UTC+1, Twirlip2  wrote:

> It doesn't seem immediately obvious how to get a definitive list
> of which names to avoid using (and therefore, inadvertently
> 'shadowing', as I did today).
> 
> For example, 
> <https://docs.python.org/3/tutorial/modules.html#standard-modules>
> doesn't list the filename 'code.py', which is the one I clashed
> with today.
> 
> Of course, if all else fails, I will be sure to manually search
> the Python installation directory for possible clashes, but there
> must be a more logically secure way, one more integral to the
> language itself.

Does the interaction below (copied from an IDLE session) show a safe
and reliable way to do it?

>>> from importlib.util import find_spec
>>> find_spec('code')
ModuleSpec(name='code', loader=<_frozen_importlib.SourceFileLoader object at 0x01139330>, origin='I:\\Python34\\lib\\code.py')
>>> find_spec('ftang')
>>> 

This seems to show that I can safely use the name 'ftang.py'
for a module in the search path, if I want; but might it be
dangerous in some way, or might it fail to find some module
name that I might still cause a clash with?

[toc] | [prev] | [next] | [standalone]


#77084

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-08-27 10:01 +1000
Message-ID<53fd1fd3$0$30001$c3e8da3$5496439d@news.astraweb.com>
In reply to#77076
Gregory Ewing wrote:

> Although shadowing builtin module names is never a good
> idea, either!

/s/builtin/standard library/

Quick! Name all the standard library modules, stat!

In Python 3.3, there are something like 410 modules in the standard library.
There's a reasonable chance that you've shadowed at least one but never
noticed. Yet.

I think it is a serious design flaw that the standard library and user code
co-exist in a single namespace.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#77086

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-26 17:06 -0700
Message-ID<14ef582f-0a8d-4134-aa2c-2ef18ddee1c0@googlegroups.com>
In reply to#77084
On Wednesday, 27 August 2014 01:01:22 UTC+1, Steven D'Aprano  wrote:

> Gregory Ewing wrote:
> 
> > Although shadowing builtin module names is never a good
> > idea, either!
> 
> /s/builtin/standard library/
> 
> Quick! Name all the standard library modules, stat!
> 
> In Python 3.3, there are something like 410 modules in the standard library.
> There's a reasonable chance that you've shadowed at least one but never> 
> noticed. Yet.
> 
> I think it is a serious design flaw that the standard library and user code
> co-exist in a single namespace.

Shades of Windows *.DLLs!

[toc] | [prev] | [next] | [standalone]


#77088

FromChris Angelico <rosuav@gmail.com>
Date2014-08-27 10:18 +1000
Message-ID<mailman.13482.1409098740.18130.python-list@python.org>
In reply to#77084
On Wed, Aug 27, 2014 at 10:01 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Gregory Ewing wrote:
>
>> Although shadowing builtin module names is never a good
>> idea, either!
>
> /s/builtin/standard library/
>
> Quick! Name all the standard library modules, stat!
>
> In Python 3.3, there are something like 410 modules in the standard library.
> There's a reasonable chance that you've shadowed at least one but never
> noticed. Yet.

Not sure about that figure; any that are namespaced away in packages
don't count (or rather, they count as just one, for the package
itself). But yes, there are a lot.

> I think it is a serious design flaw that the standard library and user code
> co-exist in a single namespace.

There are two concerns here. One is that if you create a "random.py",
you can't yourself import the normal random module; and the other is
the possibility that some unrelated application like Idle can be
affected. I think the latter is far more serious than the former,
which is basically equivalent to using "id" as a variable name and
then finding you've shadowed a builtin (it affects only your current
module, so it's pretty safe). But if I can create stuff that breaks
Idle, that's a problem. And I think the solution to that is simply:
never put your files onto the module search path, always just use the
current directory. It might also be worth having some tools like Idle
remove "" from sys.path, in case someone invokes it from a project
directory, but that's an arguable point. (That's probably more useful
for something like 2to3, where it's expected that you'll run it from a
project directory. And maybe that already happens.)

The only other way to separate them would be to do something like C's
include paths - you have the user include path (which starts with the
current directory) and the system include path (which doesn't), and
then you can #include "local_file.h" and #include <system_file.h> to
get the one you want. In Python, that could be done as "import random
from system", which would then look up sys.systempath instead of
sys.path - but do we really need that functionality?

ChrisA

[toc] | [prev] | [next] | [standalone]


#77080

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-08-27 00:20 +0100
Message-ID<mailman.13480.1409095270.18130.python-list@python.org>
In reply to#77070
On 26/08/2014 20:44, Twirlip2 wrote:
> On Tuesday, 26 August 2014 20:20:22 UTC+1, Twirlip2  wrote:
>> Mercifully, it looks like Python is not broken, but I have done something Silly!
>>
>> [...]
>>
>> What I don't yet understand is why Python is trying to execute anything at all.
>>
>>
>>
>> But I'm sure there's a simple explanation, and there'll certainly be at least a workaround, even if I have to temporarily move all my recently-edited source code files to another location!
>
> The truth is that Python WAS broken, but it was (unsurprisingly) me wot broke it!
>
> I had, in effect, already hit it with a "big stick", by naming one of my newly-created modules 'code.py' - thus evidently creating a name conflict with the standard module I:\Python34\Lib\code.py.
>
> There is probably some lesson I should learn from this.
>
> Meanwhile, let me try renaming my module, and see what happens ...
>

Another lesson is that google grops is crap, so would you please access 
this list via https://mail.python.org/mailman/listinfo/python-list or 
read and action this https://wiki.python.org/moin/GoogleGroupsPython to 
prevent us seeing the double line spacing and single line paragraphs 
above, thanks.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#77082

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-26 16:29 -0700
Message-ID<231abf85-568d-409b-ba4c-7a0855fc91e3@googlegroups.com>
In reply to#77080
On Wednesday, 27 August 2014 00:20:56 UTC+1, Mark Lawrence  wrote:
 
> Another lesson is that google grops is crap [...]

You read my mind! (See parenthetical note at end of my most recent post.)

I'm a recovered Usenet addict, of long standing.

My excuse is that it was a near-emergency - I'd been working hard for hours, indeed all day, without any visible success, and was in a near-panic, so I reached out and grabbed what help I could.

[toc] | [prev] | [next] | [standalone]


#77091

FromTerry Reedy <tjreedy@udel.edu>
Date2014-08-26 20:51 -0400
Message-ID<mailman.13484.1409100698.18130.python-list@python.org>
In reply to#77082
On 8/26/2014 7:29 PM, Twirlip2 wrote:
> On Wednesday, 27 August 2014 00:20:56 UTC+1, Mark Lawrence  wrote:
>
>> Another lesson is that google grops is crap [...]
>
> You read my mind! (See parenthetical note at end of my most recent post.)

You can access python-list (and a few thousand other tech lists as an 
nntp newsgroup via news.gmane.com. If you check headers, you will see 
that this is what I (and many others) do.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#77093

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-26 18:11 -0700
Message-ID<cc6774b1-9bce-4f8e-90db-df9bc8eac958@googlegroups.com>
In reply to#77091
On Wednesday, 27 August 2014 01:51:20 UTC+1, Terry Reedy  wrote:
> On 8/26/2014 7:29 PM, Twirlip2 wrote:
> > On Wednesday, 27 August 2014 00:20:56 UTC+1, Mark Lawrence  wrote:
> >> Another lesson is that google grops is crap [...]
> > You read my mind! (See parenthetical note at end of my most recent post.)
> You can access python-list (and a few thousand other tech lists as an 
> nntp newsgroup via news.gmane.com. If you check headers, you will see 
> that this is what I (and many others) do.

That sounds good, and I'd like to try it (tomorrow!), but:

"Server not found
Firefox can't find the server at news.gmane.com.
Check the address for typing errors [...]"

Sorry if I've just done something silly again.

Must ... sleep ...

[toc] | [prev] | [next] | [standalone]


#77097

FromTerry Reedy <tjreedy@udel.edu>
Date2014-08-27 00:03 -0400
Message-ID<mailman.13486.1409112210.18130.python-list@python.org>
In reply to#77093
On 8/26/2014 9:11 PM, Twirlip2 wrote:
> On Wednesday, 27 August 2014 01:51:20 UTC+1, Terry Reedy  wrote:
>> On 8/26/2014 7:29 PM, Twirlip2 wrote:
>>> On Wednesday, 27 August 2014 00:20:56 UTC+1, Mark Lawrence  wrote:
>>>> Another lesson is that google grops is crap [...]
>>> You read my mind! (See parenthetical note at end of my most recent post.)
>> You can access python-list (and a few thousand other tech lists as an
>> nntp newsgroup via news.gmane.com. If you check headers, you will see
>> that this is what I (and many others) do.
>
> That sounds good, and I'd like to try it (tomorrow!), but:
>
> "Server not found
> Firefox can't find the server at news.gmane.com.

sorry. .org
This is gmane.comp.python.general

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#77122

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-27 02:12 -0700
Message-ID<d8622b80-b1ba-48c4-a928-bc1409eccaf0@googlegroups.com>
In reply to#77097
On Wednesday, 27 August 2014 05:03:10 UTC+1, Terry Reedy  wrote:
> On 8/26/2014 9:11 PM, Twirlip2 wrote:
> 
> > Firefox can't find the server at news.gmane.com.
> 
> sorry. .org
> 
> This is gmane.comp.python.general

Found it now, thanks.  I'll take my time and learn how to use it.  I
hope it's OK if I carry on using Google Groups to post to this thread
(with manual reformatting). Then I'll get off Google Groups as quickly
as I can, that's for sure!

[toc] | [prev] | [next] | [standalone]


#77068

FromTwirlip2 <ahrodg@googlemail.com>
Date2014-08-26 12:26 -0700
Message-ID<4737dfe9-8a02-46d5-b69b-945199f48a5c@googlegroups.com>
In reply to#77064
On Tuesday, 26 August 2014 19:46:55 UTC+1, Terry Reedy  wrote:
> On 8/26/2014 2:01 PM, Twirlip2 wrote:
> 
> > [...]

Here are the aforementioned error messages (sorry, I didn't realise I could simply "select all" and "copy" text from a command window) - I hope the formatting doesn't get messed up. (I haven't used Google Groups in years.)

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

Traceback (most recent call last):
  File "I:\Python34\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "I:\Python34\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "I:\Python34\lib\idlelib\__main__.py", line 8, in <module>
    import idlelib.PyShell
  File "I:\Python34\lib\idlelib\PyShell.py", line 18, in <module>
    from code import InteractiveInterpreter
  File "E:\Work\Comp\Python\Lib\code.py", line 28
    path = getenv('PYTHONPATH') + r'\'
                                     ^
SyntaxError: EOL while scanning string literal

[toc] | [prev] | [next] | [standalone]


#77071

FromZachary Ware <zachary.ware+pylist@gmail.com>
Date2014-08-26 14:46 -0500
Message-ID<mailman.13477.1409082441.18130.python-list@python.org>
In reply to#77068
On Tue, Aug 26, 2014 at 2:26 PM, Twirlip2 <ahrodg@googlemail.com> wrote:
> On Tuesday, 26 August 2014 19:46:55 UTC+1, Terry Reedy  wrote:
>> On 8/26/2014 2:01 PM, Twirlip2 wrote:
>>
>> > [...]
>
> Here are the aforementioned error messages (sorry, I didn't realise I could simply "select all" and "copy" text from a command window) - I hope the formatting doesn't get messed up. (I haven't used Google Groups in years.)
>
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> Traceback (most recent call last):
>   File "I:\Python34\lib\runpy.py", line 170, in _run_module_as_main
>     "__main__", mod_spec)
>   File "I:\Python34\lib\runpy.py", line 85, in _run_code
>     exec(code, run_globals)
>   File "I:\Python34\lib\idlelib\__main__.py", line 8, in <module>
>     import idlelib.PyShell
>   File "I:\Python34\lib\idlelib\PyShell.py", line 18, in <module>
>     from code import InteractiveInterpreter
>   File "E:\Work\Comp\Python\Lib\code.py", line 28
>     path = getenv('PYTHONPATH') + r'\'
>                                      ^
> SyntaxError: EOL while scanning string literal

It looks like the problem is that you've named your module 'code.py',
which is the name of a standard library module used by IDLE.  So, when
IDLE tries to 'from code import InteractiveInterpreter', instead of
getting I:\Python34\lib\code.py, it's getting
E:\Work\Comp\Python\Lib\code.py, which isn't going to work :).

Incidentally, your SyntaxError is due to trying to use r'\' to get a
backslash literal.  Even with r'' strings, backslash will escape a
quote character (but the backslash remains in the string).  In this
case, it's simplest to just use '\\'.

Hope this helps,
-- 
Zach

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.python


csiph-web