473,388 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

import parser does not import parser.py in same dir on win

Hi!

I have a possibly dumb question about imports. I've written two python
modules:

parser.py
------------------------------------
class Parser(object):
"my parser"
------------------------------------

app.py
------------------------------------
from parser import Parser
print "import successful"
------------------------------------

Running app.py on linux, gives:
------------------------------------
import succesful
------------------------------------

However, runnning it on windows gives:
------------------------------------
Traceback (most recent call last):
File "test.py", line 1, in ?
from parser import Parser
ImportError: cannot import name Parser
------------------------------------

It turns out that on Windows, the builtin parser module is imported
instead. Why? Why is there a difference? What other names are "taken"?

In both cases the script dir is first on sys.path, and I'm using the
plain old terminal/cmd window.

Thanks for your time.

Cheers!
/Joel Hedlund
Nov 11 '06 #1
2 3197
Joel Hedlund wrote:
It turns out that on Windows, the builtin parser module is imported
instead. Why?
the table of built-in modules are checked before searching the path.
Why is there a difference? What other names are "taken"?
depends on how the interpreter is built; there's a sys variable that
contains a list of all built-ins:

http://effbot.org/pyref/sys.builtin_module_names

</F>

Nov 11 '06 #2
the table of built-in modules are checked before searching the path.

I figured as much. But why is the behavior different on linux/win? Is
this documented somewhere?

/Joel
Nov 11 '06 #3

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

Similar topics

2
by: Dennis | last post by:
The setup: Windows XP Pro Python 2.3 GTK+ 2.2.1.2 and pyGTK 1.99.17 for Python 2.3 from http://www.pcpm.ucl.ac.be/~gustin/win32_ports/ I've downloaded and installed per the instructions the...
0
by: flamencoman | last post by:
Hi, Has any one used the XML::Parser module with the Subs style? The Perl documentation states: "Each time an element starts, a sub by that name in the package specified by the Pkg option...
0
by: Bernd Oninger | last post by:
What is the difference between parser.setContentHandler and parser.setErrorHandler for a XMLParser ?
2
by: bearclaws | last post by:
I created a small "app" using an XML file and an XSLT file. It works great on a PC but when I try to view it on a Mac (IE or Safari) it blows up and does not display the XML properly. I'm...
4
by: Peter Row | last post by:
Hi, I have 2 XML files and 1 XSLT file. The second XML file has the following declarative 1st line: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> ....the 1st one (the one to be...
4
by: Regnab | last post by:
I'm automating the import of all text files into Access from a source folder. I was getting the "Field 'F1' doesn't exist in destination table" error, so I checked it out on the net and it said to...
0
by: Joel Hedlund | last post by:
Hi! I have a possibly dumb question about imports. I've written two python modules: parser.py ------------------------------------ class Parser(object): "my parser"...
5
by: szepesg | last post by:
Hi! If I want to parse this html file (e.g. copy it into an other file using HTML Parser) I only get an empty file. What am I doing wrong? Thank you for your answer in advance. Gábor
2
by: neoonwheels | last post by:
Hi, I have a Oracle 9 dump file with me with user "plus10". I would like to import everything present in this file into my database. I do not have any idea about the tablespace this was exported...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.