473,383 Members | 1,795 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,383 software developers and data experts.

Weird scope error

Hi

I am trying to use the TidyHTMLTreeBuilder module which is part of
elementtidy, but I am getting what appears to be some sort of scope
error and it is scrambling my n00b brain.

The module file (TidyHTMLTreeBuilder.py) tried to import ElementTree by
doing the following:

from elementtree import ElementTree

This bombed, so after a bit of poking around I replaced it with :

from xml.etree import ElementTree

This appears to have worked. However, when I try and parse a file using
the function :
TidyHTMLTreeBuilder.parse('weather_ct.html')

I receive the following error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/usr/lib/python2.5/site-packages/elementtidy/TidyHTMLTreeBuilder.py",
line 107, in parse
return ElementTree.parse(source, TreeBuilder())
NameError: global name 'ElementTree' is not defined
The code producing the error is as follows:

def parse(source):
return ElementTree.parse(source, TreeBuilder())

Surely, if the from... import has worked, ElementTree is in the global
scope and should therefore be accessible to the function parse?

Can anybody help?

THanks
Apr 5 '08 #1
0 954

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

Similar topics

2
by: alice | last post by:
Hi, When I compiles the following program with g++, it gives the following output: # g++ -o list list.C list.C: In function `int main()': list.C:116: jump to case label list.C:110: crosses...
2
by: Nils Emil P. Larsen | last post by:
Hello I have read about a C shared library which I want to use in my C program. (It's a library to encode/decode packets from/to a serial bus running with the SNAP-protocol). Unfortunatly...
11
by: Afzal Mazhar | last post by:
What is wrong with this? class Example1 { public static long myClassVar; public static void Main() { { long myClassVar = 5;
13
by: Joe Attardi | last post by:
Over the weekend I attended a session on JavaScript at the No Fluff Just Stuff conference and learned an interesting quirk that I wanted to ask a question about.. Take this code: x = 5; ...
2
by: keepyourstupidspam | last post by:
Hi, I have a strange build problem. I am building an exe, this exe links to a number of static libraries maybe 20 in all and all are built from my code. I am using the gmake build system...
12
by: sparks | last post by:
My boss and I both have access 97 and access 2003 installed on our systems. Lately he has been having a lot of problems. Databases that won't close. The database looks like it closes but access...
2
by: Matt Nordhoff | last post by:
Sebastjan Trepca wrote: Python doesn't like when you read a variable that exists in an outer scope, then try to assign to it in this scope. (When you do "a = b", "b" is processed first. In...
8
by: Tom P. | last post by:
I have a webpage that takes user data and sends it to a stored procedure that inserts a row in a table then returns the ID of that row for display. The stored procedure does an insert then it...
9
by: mrstevegross | last post by:
I ran into a weird behavior with lexical scope in Python. I'm hoping someone on this forum can explain it to me. Here's the situation: I have an Outer class. In the Outer class, I define a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.