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

using the filter function within class return error

I'm trying to use the __builtin__ filter function within a class;
however, I receive the following error:

NameError: global name 'MajEthnic' is not defined

The line of code is: EthMaj = filter(self.MajEthnic,flist)

So, I'm trying to use the MajEthnic function to filter the list flist.
Any ideas?

Thanks!

Nov 2 '07 #1
1 1419
On Fri, 02 Nov 2007 09:42:17 -0700, david.katkowski wrote:
I'm trying to use the __builtin__ filter function within a class;
however, I receive the following error:

NameError: global name 'MajEthnic' is not defined

The line of code is: EthMaj = filter(self.MajEthnic,flist)

So, I'm trying to use the MajEthnic function to filter the list flist.
Any ideas?

Yes, many.

The first idea is: the exception that you get tells you what's wrong. You
should pay attention and define MajEthnic, just as it says.

My second idea is that you're probably giving us incorrect information. I
can't think of any possible way for the line of code you quote to give
the NameError you say it does. I can think of how it might give a
different NameError:

class Parrot(object):
flist = [1, 2, 3]
EthMaj = filter(self.MajEthnic, flist)

or possible an AttributeError:

class Parrot(object):
def method(self, flist):
EthMaj = filter(self.MajEthnic, flist)
but not the exception that you quote.

My third idea is that if you want better help, you should provide better
information. Please quote the entire traceback, not paraphrasing it,
unless it is excessively long, in which case you can trim some of the
extra stack trace (but tell us you've done so!). Please ensure you are
actually quoting the correct line of code that generates the exception.

My fourth idea is that your subject line is incorrect. The filter
function does not RETURN an error, it RAISES an error. Using correct
terminology is important.

Although technically, it is just barely possible that filter actually is
*returning* an exception, or at least a list containing an exception, if
flist looks something like this:

flist = [NameError("global name 'MajEthnic' is not defined"), 0, 1, 2]

Exceptions are objects like any other, and can be returned, although that
would be extremely unusual, and not something that "just happens" -- you
have to work at it!

--
Steven.
Nov 2 '07 #2

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

Similar topics

28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
7
by: fakeprogress | last post by:
For a homework assignment in my Data Structures/C++ class, I have to create the interface and implementation for a class called Book, create objects within the class, and process transactions that...
2
by: Tugrul HELVACI | last post by:
I'm using Delphi 2006 and I have a class defination like this: TPerson = class fPersonName : String; fPersonSurName : String; fPersonAge : Integer; published property PersonName : String...
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
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,...

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.