I have the following function:
def to_url(self):
return {
'ass_cls': self.model.__class__.__name__,
**{local.name: getattr(self.model.src, remote.name)
for local, remote in self.model.__class__.src.property.local_remote_pairs},
**{k: v
for k, v in self.model.__dict__.items()
if not k.startswith('_') and k != 'src'},
}
How do I convert this piece of code into Python 3.4-compatible?
I believe, the code currently uses PEP 448 - Additional Unpacking Generalizations right now, which is a Python 3.5 feature.
The new unpacking feature is what won't work in 3.4.
You'll have to use the older, more verbose method of merging dictionaries.
def to_url(self):
d = {'ass_cls': self.model.__class__.__name__}
d.update({local.name: getattr(self.model.src, remote.name)
for local, remote in self.model.__class__.src.property.local_remote_pairs})
d.update({k: v for k, v in self.model.__dict__.items()
if not k.startswith('_') and k != 'src'})
return d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With