473,287 Members | 1,399 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,287 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 1416
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.