Python - short syntax and list comprehension and iterations -
I'm a big fan of understanding Python's list and I think it's really easy to read from running regularly .
I am writing a constructor which has an alternative code that can be used to set however the syntax looks good, I think it is bad coding because you have , they are just sitting there and yes I know it is collected after the constructor is run, but I Still do not like it. If I have read someone's code, then I will be uncompressed. Is there a better way to do such a recursive list as clear as a list but do not make useless objects Edit: < P> To use loop Is it that you guys What are you saying? If not, a better way to write Instead of understanding the list, you can use direct generator expression: in __ dictra, Kwargs.viewkeys () Simply use The generator expression produces To understand the list for side effects: just not. You are actually wasting the cycles that make such inventory objects that are immediately abandoned, there is a list of misleading expectations in terms of . Viewkeys () & amp; Self. Etter: sateterer (self, atri, quarrel [atri]) ** kwargs square etters, and I understand it as a list I want to write, but it seems there is no list which does not actually do anything to consider:
class book (object): attrs = ('id', 'title ',' Authors', ...) def __init __ (self, * args, ** kwargs): [orator (self, atri, etter) If kwargs.get (attr)]
[none , None, no one ...]
class book (object): Attrs = ('id', 'title', 'writer', ...) def __init __ (self, * Args, ** kwargs): For attr in attrs: if kwargs.get (set): setattr (self, attr, kwargs.get (attr)
class book (object): attrs = ('id', 'title', 'authors', ...) def __init __ (self, * args, ** kwargs): self. In the Python 3, it also uses the update for k (एtr, quoraj [k]) and
kwargs.viewkeys () instead of
kwargs.keys () . A dictionary acts as a visual set;
& amp; Self.attrs creates intersection between the keys and your list of properties of the expression
(key, value) is one of two acceptable inputs for pair.
Updating
@property and / or other custom descriptor), then bypassing those who reach
self.decc_____ .
Comments
Post a Comment