Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8795921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:29:57+00:00 2026-06-13T23:29:57+00:00

Why is PyDev giving me this error: Class variable undefined when I try to

  • 0

Why is PyDev giving me this error: “Class variable undefined” when I try to implement a simple class for an inversion counting algorithm? Here’s my code:

from collections import deque

Class inversionCount:

    def __init__(self, n):
        self.n = n
    def inversionMergeSort(m, n):
        print m
        if len(m) <= 1:
            n = 0
            return (m, n)
        half = len(m)/2
        left = m[0:half]
        right = m[half:]
        left = mergeSort(left)
        right = mergeSort(right)
        return inversionSort(left, right)

    def inversionSort(left, right, n):
        leftQueue = deque(i for i in left)
        rightQueue = deque(j for j in right)
        orderedList = []
        while len(leftQueue) > 0 or len(rightQueue) > 0:
            if len(leftQueue) > 0 and len(rightQueue) > 0:
                if leftQueue[0] < rightQueue[0]:
                    orderedList.append(leftQueue[0])
                    leftQueue.popleft()
                else:
                    orderedList.append(rightQueue[0])
                    if len(leftQueue) > 1:
                        self.n += len(leftQueue)
                    rightQueue.popleft()
            elif len(leftQueue) > 0:
                orderedList.append(leftQueue[0])
                leftQueue.popleft()
            elif len(rightQueue) > 0:
                orderedList.append(rightQueue[0])
                rightQueue.popleft()
        return (orderedList, n)

yet PyDev is failing to recognize that inversionCount is indeed a class. Any thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:29:59+00:00Added an answer on June 13, 2026 at 11:29 pm

    class is lowercase:

    class inversionCount:
    

    The error is thrown because the variable Class is indeed not defined; python is case sensitive and Class is not the same thing as class; the former is seen as a variable name, while class is a keyword.

    If you were to run your code with the interpreter, it’ll throw a syntax error instead; PyDev’s interpretation is slightly different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why is Pydev giving me syntax errors for built-in python functions like str()? Undefined
Whenever I start pydev/eclipse and try to run .py file I have an error:
I'm using Eclipse / PyDev trying to find a way to debug code that
I cannot compile python in pydev in eclipse. I get the following error: unable
I setup PyDev with this path for the python interpreter /System/Library/Frameworks/Python.framework/Versions/2.5/Python since the one
In Eclipse/PyDev, when mouse over or click on a class or an object, there
I installed PyDev in Eclipse on my Mac. Whenever I am writing code, it
When trying to install PyDev on eclipse I get the following error message: An
I'm trying to integrate the pydev, pyqt, python and eclipse. Now the code can
I've installed and configured Pydev with Eclipse but when I try to use interactive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.