4

Suppose I have the .proto file:

message Bar { }

message Foo {
  repeated Bar bars = 1;
}

How can you delete all of the elements in the field bar?

michaelrbock
  • 1,160
  • 1
  • 11
  • 20

2 Answers2

4

Use a combination of del and [:]:

del foo.bars[:]
michaelrbock
  • 1,160
  • 1
  • 11
  • 20
2

You can use foo.ClearField('bars') or del foo.bars[:].

cs95
  • 379,657
  • 97
  • 704
  • 746