473,915 Members | 3,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Baffled on Windows.

I have the following Python program:

import win32com.client
print 'Huh?' # Actually, it says something profain.
Running this program with 2.5.1 causes another Python script in
the same directory to be loaded and run (specifically the import
causes it), and a .pyc file is created from that list.

The 'other' program is called 'new.py'. Is that what's causing
my problem?

--
Neil Cerutti
Jun 7 '07 #1
4 1087
Neil Cerutti wrote:
I have the following Python program:

import win32com.client
print 'Huh?' # Actually, it says something profain.
Running this program with 2.5.1 causes another Python script in
the same directory to be loaded and run (specifically the import
causes it), and a .pyc file is created from that list.

The 'other' program is called 'new.py'. Is that what's causing
my problem?
A useful technique on these occasions is to use the -v
switch when starting python. If I do nothing more than
import win32com.client , watch what happens:

python -v -c "import win32com.client " 2python-startup.txt
grep "new" python-startup.txt
..
..
# c:\python24\lib \new.pyc matches c:\python24\lib \new.py
import new # precompiled from c:\python24\lib \new.pyc
# cleanup[2] new

So somewhere in there a module called "new" is being
imported from standard library and, yes, you are
shadowing that module by your own one of the same
name.

http://docs.python.org/lib/module-new.html

TJG
Jun 7 '07 #2
On Jun 7, 8:17 am, Neil Cerutti <horp...@yahoo. comwrote:
I have the following Python program:

Running this program with 2.5.1 causes another Python script in
the same directory to be loaded . . . 'new.py'
A good habit for naming your scripts: If you have a script and you
want to name it text.py, or list.py or new.py or old.py or some common
name that might be found in the thousand and one other modules and
programs in your various installations, just use my_text.py or
my_list.py or neil_new.py or something to reduce the chances that
you'll be shadowing without knowing it.

rick
Jun 7 '07 #3
BartlebyScriven er wrote:
On Jun 7, 8:17 am, Neil Cerutti <horp...@yahoo. comwrote:
.........
A good habit for naming your scripts: If you have a script and you
want to name it text.py, or list.py or new.py or old.py or some common
name that might be found in the thousand and one other modules and
programs in your various installations, just use my_text.py or
my_list.py or neil_new.py or something to reduce the chances that
you'll be shadowing without knowing it.

rick
using your advice we will start getting problems where my_new is shadowed so
then we start having to recur and we'll have names like

my_my_new.py my_my_list.py ...... my_my_my_new.py .....

I leave as an exercise the algorithm which chooses the appropriate version of
new/list to use :)
--
Robin Becker

Jun 7 '07 #4
On 2007-06-07, Robin Becker <ro***@reportla b.comwrote:
BartlebyScriven er wrote:
>On Jun 7, 8:17 am, Neil Cerutti <horp...@yahoo. comwrote:
........
>A good habit for naming your scripts: If you have a script and you
want to name it text.py, or list.py or new.py or old.py or some common
name that might be found in the thousand and one other modules and
programs in your various installations, just use my_text.py or
my_list.py or neil_new.py or something to reduce the chances that
you'll be shadowing without knowing it.

rick

using your advice we will start getting problems where my_new
is shadowed so then we start having to recur and we'll have
names like

my_my_new.py my_my_list.py ...... my_my_my_new.py .....

I leave as an exercise the algorithm which chooses the
appropriate version of new/list to use :)
Thanks all for the helpful replies.

I'll just memorize the names of all the Python modules in
existence to eliminate this source of errors once and for all.

Or possibly I'll just rename my scripts things whenever this
happens. ;)

--
Neil Cerutti
Jun 7 '07 #5

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

Similar topics

4
2902
by: Mark Thomas | last post by:
Hi I do not understand why the following does not compile under Visual C++ 7.1. It is just a simple "Hello, World" program. // Hello World Application. Why does this fail? #include <iostream> using namespace std;
13
2429
by: s_m_b | last post by:
I'm building a suite of online forms for insurance. These have been stripped down from messy MS Word templates, and two of the six, substantially identical, are misbehaving with the .js page that validates some of the content. The correct behaviour is that some fields must have content, some must have valid dates/times. On validation, the form is POSTed to a processing page that flows it into a blank template and emails that elsewhere. ...
2
1707
by: Bob Graham | last post by:
When my applications hit certain types of errors, it shows me a box that says if I enable JIT debugging in the machine.config file, the code will break into a debugger instead of showing me the dialog in question. My machine.config file *does* have jit debugging = true. Just how stupid am I? I can't begin to figure out how to get this to work. Do I have to install something I don't know about? Does it work only outside the...
10
1114
by: Damien | last post by:
I am a complete newbie to .net. I have just built a simple Stopwatch Application but when I F5 to get things going I get this message popping up. An unhandled exception of type 'System.ArithmeticException' occurred in system.drawing.dll Additional information: Overflow or underflow in the arithmetic operation. I am totally stumped. I sent this to my tutor who advised this works on his machine??
5
1153
by: =?Utf-8?B?Q2hhcmxlc0E=?= | last post by:
Hi folks, I will try my best to clarify what should be a simple thing to solve: I've got XP pro sp2 VS 2005 Team system and .Net 2.0 with ASP.net and C# I've got the compilation <debug="true"in web.config (and this doesn't work even if I have @page debug="true") when I run any individual page in the browser with 'View in Browser'
0
9883
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11359
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10928
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8102
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5944
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4779
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 we have to send another system
2
4346
muto222
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.