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 6596155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:02:17+00:00 2026-05-25T18:02:17+00:00

I’m not entirely sure what has happened. I was debugging a script that worked

  • 0

I’m not entirely sure what has happened.

I was debugging a script that worked “fine” (except for said intermittent bugs) and all of a sudden the module cannot be imported anymore. I undid all changes and still the problem exists.
Well, problemS. Plural.

Once I got an “unexpected indent” error, even though all the lines were perfectly indented. I fixed that one by deleting the line and retyping it.

Now in the following code, I get one of two errors:

class Lottery:
    def __init__(self, session):
          self.prizes = PrizeList()
          self.session = session
          self.players = self.session.listof.players.split(',')
          self.pickWinner()

Most of the time, it gives me an error saying “session” is not defined. This is true. I’m just importing the module. It gets defined when the script calling it runs it. I experimented with just removing that line altogether, and then it told me that “self” was not defined.

All of that is the original code that was working 20 minutes ago. the bugs I was fixing are on a different part of this module altogether, and it was certainly importing without problems. Please help!

Traceback:

  File "minecraft/mcAdmin.py", line 5, in <module>
    from lottery.lottery import *
  File "/home/tomthorogood/minecraft/lottery/lottery.py", line 36, in <module>
    class Lottery:
  File "/home/tomthorogood/minecraft/lottery/lottery.py", line 39, in Lottery
    self.session = session
NameError: name 'session' is not defined

EDIT: SOLVED. Okay, somehow while editing, I did accidentally switch between tabs and spacing, which lead to the problem. I deleted and re-wrote that block of code exactly as pasted above and now it’s working. There was a ghost indent problem.

DOUBLE EDIT: the core problem was that I only recently turned on auto-indenting in Vim. The configuration I am using is not using tabs as auto-indents, but I was using tabs in the past.

  • 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-05-25T18:02:17+00:00Added an answer on May 25, 2026 at 6:02 pm

    You’ve got an indentation problem.

    The self.session = session line, and everything below, isn’t inside your __init__ method, it’s just inside the class body.

    session isn’t defined in the class body, only inside __init__, as you mention in your question, so you get the error.

    IF you remove that line, the first thing that gets looked up is the self in self.players = self.session.listof.players.split(','), so you get the self is not defined error.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I need a function that will clean a strings' special characters. I do NOT
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm trying to create an if statement in PHP that prevents a single post
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

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.