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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:33:14+00:00 2026-05-25T20:33:14+00:00

from PySide.QtCore import * class Eggs(QObject): evt_spam = Signal() print Loaded a = Eggs()

  • 0
from PySide.QtCore import *

class Eggs(QObject):
    evt_spam = Signal()
    print "Loaded"

a = Eggs()
b = Eggs()
print a.evt_spam
print b.evt_spam
print a.evt_spam is b.evt_spam

outputs:

Loaded
<PySide.QtCore.Signal object at 0xa2ff1a0>
<PySide.QtCore.Signal object at 0xa2ff1b0>
False

“Loaded” only printing once (as expected; it is a class variable), but why are 2 instances of the signal being created (if it is also a class variable)?

  • 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-25T20:33:14+00:00Added an answer on May 25, 2026 at 8:33 pm

    It’s not being printed when you create a class instance, but rather when the class scope is executed. This code will print “Loaded”, even though I never made an instance of “Test”.

    class Test:
        print "Loaded"
    

    If you want to run code when the class is initialized, take a look at __init__(). This code will print “Loaded” when an instance is made, instead of when the class itself is defined.

    class Test:
        def __init__(self):
            print "Loaded"
    

    QT’s QObject metaclass appears to be rewriting the class attributes to prevent duplicate signals when you initialize a new instance of the class. Perhaps you can assign the attribute like this:

    class Test(QObject):
        def __init__(self, signal):
            self.evt_spam = signal
    
    sig = Signal()
    a = Test(sig)
    b = Test(sig)
    

    Or this:

    class Test(QObject):
        def signal(self, signal):
            self.evt_spam = evt_spam
            return self
    
    evt_spam = Signal()
    a = Test().signal(evt_spam)
    b = Test().signal(evt_spam)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from django.db import models class Post(models.Model): title = models.CharField(max_length=100) content = models.CharField(max_length=1000) created =
This is a followup question from this one. Connecting Pyside with matplotlib My PythonFu
From JSP file accessed another JSP file which acts like java class, this used
I'm trying to get a pyside button to copy text from a qlineEdit field
from Tkinter import * master = Tk() listbox = Listbox(master) listbox.pack() listbox.insert(END, a list
From such a job, I'm doing: @OnApplicationStart public class Bootstrap extends Job { Foo
I'm trying to remove a Qt widget from a layout in a PySide application.
From a web developer point of view, what changes are expected in the development
From a desktop application developer point of view, is there any difference between developing
From what I've read, VS 2008 SP1 and Team Foundation Server SP1 packages are

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.