473,473 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

IDLE vs Command Line

I like to work with xemacs, so I've been coding modules with xemacs and
running them using the dos prompt (using windows port of xemacs). Some
scripts that work fine with IDLE don't work at the dos prompt. For example:

import random

for i in range(10):
x = random.random()
print x

This simple script doesn't work if I use the command prompt, with this
syntax: python random.py

I am just wondering why that is.
Jul 18 '05 #1
4 2172
Jesse B. wrote:
I like to work with xemacs, so I've been coding modules with xemacs and
running them using the dos prompt (using windows port of xemacs). Some
scripts that work fine with IDLE don't work at the dos prompt. For example:

import random

for i in range(10):
x = random.random()
print x

This simple script doesn't work if I use the command prompt, with this
syntax: python random.py

I am just wondering why that is.


Because you have given the script the same name as the module you're
importing, so the script tries to import itself?
--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.********@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)

xxx
xxx
xxx
xxx
xxx
xxx
xxx
xxx
xxx

Jul 18 '05 #2

Jesse B. wrote:
I like to work with xemacs, so I've been coding modules with xemacs and
running them using the dos prompt (using windows port of xemacs). Some
scripts that work fine with IDLE don't work at the dos prompt. For example:
import random

for i in range(10):
x = random.random()
print x

This simple script doesn't work if I use the command prompt, with this
syntax: python random.py

I am just wondering why that is.


Because you have given the script the same name as the module you're
importing, so the script tries to import itself?


That makes sense.
Jul 18 '05 #3

"Jesse B." <jb*******@adelphia.net> wrote in message
news:8P********************@adelphia.com...
I like to work with xemacs, so I've been coding modules with xemacs and
running them using the dos prompt (using windows port of xemacs). Some
scripts that work fine with IDLE don't work at the dos prompt. For example:
import random

for i in range(10):
x = random.random()
print x

This simple script doesn't work if I use the command prompt, with this
syntax: python random.py

I am just wondering why that is.

It is running the copy of random.py from the python lib not your random.py

Tom

P.S. it is not trying to import itself!
Jul 18 '05 #4
Thanks for the feedback. It's happened before, but I was prob using the same
mistake.

"Tom B." <sb******@commspeed.net> wrote in message
news:10**************@news.commspeed.net...

"Jesse B." <jb*******@adelphia.net> wrote in message
news:8P********************@adelphia.com...
I like to work with xemacs, so I've been coding modules with xemacs and
running them using the dos prompt (using windows port of xemacs). Some
scripts that work fine with IDLE don't work at the dos prompt. For example:

import random

for i in range(10):
x = random.random()
print x

This simple script doesn't work if I use the command prompt, with this
syntax: python random.py

I am just wondering why that is.

It is running the copy of random.py from the python lib not your

random.py
Tom

P.S. it is not trying to import itself!

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Paul M | last post by:
Pythoneers, IDLE doesn't use the ps2 prompt ("..." in the command line interpreter) because it supports multiline editing. This issue has been discussed before, for example see Guido's...
16
by: Kerry Neilson | last post by:
For the past couple of months, Idle won't start when I invoke it. I am at a complete loss for why this is. When this happens, they python command line still starts, and python works fine...
6
by: Kevin Walzer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm looking for other peoples' viewpoints about their experiences with IDLE as an editor--what are its good points? What are its limitations? Any...
15
by: Ashot | last post by:
This is sort of both Python and Vim related (which is why I've posted to both newsgroups). Python related: ---------------------- I have been frustrated for quite some time with a lack of a...
13
by: John Salerno | last post by:
If I want to write my code in a separate text editor (I like UltraEdit) but then press a single button to have that code run in the IDLE environment, is that possible? I know that you can configure...
3
by: Rob | last post by:
I have Python 2.4.3 installed on Windows XP on both a real computer and a virtual machine under VMware. Just recently, IDLE stopped working. I would select IDLE from the start menu or right click...
3
by: writser | last post by:
hey all, For my study I'm writing a simple threaded webcrawler and I am trying to do this in python. But somehow, using threads causes IDLE to crash on Windows XP (with the latest python...
2
by: Jim Hendricks | last post by:
New to Python, and just had something strange happen. I've been running my new code in IDLE running in windows. My IDLE version shows as 1.2.1, Python version displaying in IDLE is 2.5.1. I...
2
by: Russ P. | last post by:
Is it possible to pass command-line arguments when running a program in IDLE? The "Run" menu does not seem to provide that option. Thanks.
6
by: Andreas Tawn | last post by:
I'm trying to integrate the timeout function from here http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473878 into a long running automation script and the following code causes IDLE after...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.