gives me a list of objects. Some of the objects have different attribute values. A chat object can.either have .title or .first_name. My return looks like this
                  
                  
                  
                  
                  
                  return [dlg for dlg in dialogs]
                  
                  
                  What would be the ternary operator to return dlg.title if the title is not None but dlg.first_name if it is None?
                  
                  
                  
                  
                  
                  return [dlg.first_name for dlg in dialogs if dlg.first_name else.... ]
                  
                  
                  
                  
                  
                  How would i construct this?
                  
                  
                
Maybe I can just iter thru dialogs and have an empty list, append to the list in a normal for loop and the return the list? 🤔
Think about it some more before you give up
Mmm Maybe create a class that inherits from the dialogs And changes iteration
let me guess... you make a userbot?
Обсуждают сегодня