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

306
Views
Python: ¿hay una forma abreviada de [por ejemplo]: print(f'type(var) = {type(var)}')

¿Hay una abreviatura en Python para (por ejemplo) print(f'type(var) = {type(var)}') , sin tener que indicar el objeto en el texto y {.} ?

La respuesta corta puede ser "no", ¡pero tenía que preguntar!

Por ejemplo, en SAS se puede usar &= para generar una macro variable y su valor en el registro...

 %let macrovar = foobar; %put &=macrovar;

que devuelve en el registro: MACROVAR = foobar

Esta es mi primera pregunta, y me resultó difícil buscar una respuesta, así que disculpe si se ha preguntado y respondido.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

De hecho lo hay. A partir de python 3.8, simplemente puede escribir f'{type(var)=}' y obtendrá el resultado que desea:

 >>> x = {} >>> f'{x=}' 'x={}' >>> f'{type(x)=}' "type(x)=<class 'dict'>"

Otras lecturas:

  1. La página "Novedades de Python 3.8"
  2. La documentación para f-strings
  3. La discusión sobre BPO que condujo a la implementación de esta función.
over 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!