Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
How to pass a function result to a tuple?

I am working on a Python/Django/Wagtail project, and at some point I have a class like this:

class SuperClass(BaseClass):

    body = StreamField([
        ('overview_speakers', OverviewSpeakers()),
    ])

    def some_function():
        return 'Hola'

OverviewSpeakers is a class that is expecting an argument and I want to try to pass in the results of some_function()

I tried both:

body = StreamField([
    ('overview_speakers', OverviewSpeakers(self.some_function())),
])

and

body = StreamField([
    ('overview_speakers', OverviewSpeakers(SuperClass.some_function())),
])

But respectively it yells that self or SuperClass are not defined.

What can I do to pass in the results of the function?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Check this out:

class SuperClass(BaseClass):

    def some_function():
        return 'Hola'

    body = StreamField([
        ('overview_speakers', OverviewSpeakers(some_function())),
    ])
about 4 years ago · Santiago Trujillo Report

0

You cannot refer to a class that is being defined, but you can add attibutes to it after it is defined. So this should work:

class SuperClass(BaseClass):
    def some_function():
        return 'Hola'

SuperClass.body = StreamField([
    ('overview_speakers', OverviewSpeakers(SuperClass.some_function())),
])
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!