Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
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?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Check this out:

class SuperClass(BaseClass):

    def some_function():
        return 'Hola'

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

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())),
])
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda