473,218 Members | 1,696 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,218 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 1411
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.