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

  • Home
  • SEARCH
  • 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 8029513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:27:41+00:00 2026-06-05T00:27:41+00:00

def mention_notifier(self): print self.stat_old if __name__ == __main__: import sys self.stat_old = Set([]) l

  • 0
def mention_notifier(self):
    print self.stat_old


if __name__ == "__main__":
    import sys
    self.stat_old = Set([])
    l = task.LoopingCall(mention_notifier).start(timeout)

This is the basic skeleton of my code. I want stat_old to be a global variable that doesn’t get re intialized every time I call mention_notifier. Thus, I did something like this. But got this error of ‘self’ not defined. Any clues how to go about this?

  • 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-05T00:27:44+00:00Added an answer on June 5, 2026 at 12:27 am

    I don’t use Twisted, but from looking at the docs, something like this might work:

    def mention_notifier(self):
        print self.stat_old
    
    class Namespace(object): 
        pass
    
    if __name__ == "__main__":
        import sys
        self=Namespace()
        self.stat_old = Set([])
        l = task.LoopingCall(mention_notifier,self).start(timeout)
    

    Of course, here the variable name self should probably be changed to something else — by convention self is typically used inside of classes to reference the instance of the class in a method call …

    It looks like LoopingCall can be given arguments to be passed along to the function (in this case, the Namespace object self is passed). Then inside the function, “self” is modified (as long as you don’t do something like self=... inside the function, you’re golden — self.attribute=... is completely fine)

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

Sidebar

Related Questions

okay code: #!/usr/bin/python import wx import sys class XPinst(wx.App): def __init__(self, redirect=False, filename=None): wx.App.__init__(self,
This is my class: class Account(models.Model): name = models.CharField(max_length=255) def __unicode__(self): return '{0}'.format(self.name) class
def ask(): global name, loca print What's your name? name = raw_input('> ') print
def initUI(self): self.columnconfigure(5, weight=1) self.rowconfigure(3, weight=1) self.search_label = Label(self, text='Keyword:') self.search_label.grid(row=0, column=0, padx=5) self.keywords
I've seen this code in a rails tutorial I'm doing def access_denied redirect_to login_path,
This is my form: from django import forms class UploadFileForm(forms.Form): titl = forms.CharField(max_length=50) ffile
Let's say we have a particularly simple function like import scipy as sp def
i work on grails project def result = customer //(this value is according to
Let's say I have B.py import A def F(): pass def G(): pass if
def a_method p in distress end alias :hero :a_method def a_method hero p Saved

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.