Hi Chelsea,
> On Nov 15, 2023, at 10:51 AM, 'Chelsea Patella' via pymarc Discussion <
pym...@googlegroups.com> wrote:
>
> record['245'].subfields[-1] = re.sub('\.$', '', record['245'].subfields[-1])
Sadly the subfields are now NamedTuples, which are immutable. So this will give you a "AttributeError: can't set attribute” error:
record['245'].subfields[-1].value = re.sub('\.$', '', record['245'].subfields[-1].value)
Maybe someone has a better solution here, but one (tedious) way of approaching this might be to create a variable for the last subfield, and then use it to construct a new subfield:
sf = record['245’].subfields[-1]
record['245'].subfields[-1] = Subfield(sf.code, re.sub('\.$', '', sf.value)
I think using the placeholder variable makes it a bit more readable than this (which looks abysmal):
record['245'].subfields[-1] = Subfield(
record['245'].subfields[-1].code,
re.sub('\.$', '', records['245'].subfields[-1].value
)
//Ed