-2

I was wondering if there is a decent way to avoid repeating "IGNORED" when assigning it to multiple values in python, something like *"IGNORED" maybe:

raw_size, size, content_type, last_modified, error = "IGNORED", "IGNORED", "IGNORED", "IGNORED", {}

I got this link but it was not quite the answer I was looking for.

nino
  • 554
  • 2
  • 7
  • 20
  • 1
    Why is the link you provided not an answer you wanted? It seems to me that the article answers your question exactly. – j1-lee Mar 28 '21 at 18:27
  • `raw_size = size = content_type = last_modified = error = "IGNORED"` ? or `raw_size, size, content_type, last_modified = ('IGNORED',) * 4` ? – shahkalpesh Mar 28 '21 at 18:28
  • Because the last variable, i.e. ```error``` should be a different value, i.e. ```{}``` – nino Mar 28 '21 at 18:30
  • 2
    Then you can put that in another line. – j1-lee Mar 28 '21 at 18:31
  • 2
    This doesnt appear good to me but you could do `a, b, c, d = ('IGNORED',) * 3 + ({},)` – shahkalpesh Mar 28 '21 at 18:34
  • ```a, b, c, d = ('IGNORED',) * 3 + ({},)``` works fine, Thanks. And I would be thankful if you tell me why that doesnt appear good. – nino Mar 28 '21 at 18:40
  • 1
    It just looks uhm ugly to me (and to @shahkalpesh too, I guess). By 'ugliness', I mean that the code loses legibility. To human readers `a, b, c, d = something; e = another` seems more easy to comprehend than the more convoluted oneliner. – j1-lee Mar 28 '21 at 18:46

2 Answers2

2

If you insist,

raw_size, size, content_type, last_modified, error = ('IGNORED', ) * 4 + ({},)

might work.

j1-lee
  • 13,764
  • 3
  • 14
  • 26
1

What you're looking for is:

raw_size = size = content_type = last_modified = "IGNORED"
error = {}

If this isn't what you're looking for, please rewrite your question to have more clarity.

ObjectJosh
  • 601
  • 3
  • 14