0

I have a function like this:

def region_3d(context):
    for area in context.screen.areas:
        if area.type == 'VIEW_3D':
            space = area.spaces.active
            r3d = space.region_3d
            plane_no = r3d.view_rotation @ Vector((0, 0, -1))
            region = area.regions[-1]
            break
    else:
        assert False, "Requires a $D view"
    return region, r3d, area

sometimes I just need region and r3d, not the area, but when I do:

region, r3d = region_3d(context)

I get an error:

ValueError: too many values to unpack (expected 2)

I'd like to either:

  • tell from inside the function how many values are expected on the left side of the assignment, and act accordingly or
  • be able to assign to a undef-ish variable that is just a dump (kinda like a /dev/null of variables).

Like in perl you'd do:

sub foobar { return qw/a b c/ }

my ($foo, $bar, undef) = foobar();

print $foo, $bar

and be fine. And you could use Want to determine what's on the left side.

Can you do that in python?

simone
  • 4,283
  • 4
  • 20
  • 35

0 Answers0