← Back to team overview

kicad-developers team mailing list archive

Re: more pythonic scripting API for pcbnew

 

In response to a message written on 07.01.2015, 19:29, from Adam Wolf:
Hi folks,

Good work!

I dunno, LordBlick, it looks pretty Pythonic to me!

Also, I do not think

  dict(map(lambda lname: lname, layers_tuple.index(lname), layers_tuple))

is clearer than using a dictionary called layer_dict :)
Some tip: count chars… :P
This dictionary is not necessary for this code since it is used only for the one function. Code below makes the same without dict:
def get_layer(s):
	"Get layer id from layer name\n If it is already an int just return it."
	if hasattr(pcbnew, s):
		return getattr(pcbnew, s)
	elif isinstance(s, int) \
		and(s in range(pcbnew.LAYER_ID_COUNT):
		return s
	return None

BTW. I love Tabs in python code, which syntax is based on Tab counting and I don't intend to change that… Setting tab length is not so advanced and hard activity.
--
Best Regards,
LordBlick


Follow ups

References