Python - replace long if/elif chain with dict mappings

Python - Avoiding long if/elif chain with dictionary mappings

########################
# Long if/elif chain

def keydown(key):
global paddle1_vel, paddle2_vel
if key == simplegui.KEY_MAP[“up”]:
paddle2_vel -= 2
elif key == simplegui.KEY_MAP[“down”]:
paddle2_vel += 2
elif key == simplegui.KEY_MAP[“w”]:
paddle1_vel -= 2
elif key == simplegui.KEY_MAP[“s”]:
paddle1_vel += 2

########################
# Avoiding long if/elif chain with dictionary mapping values to actions

def paddle1_faster():
global paddle1_vel
paddle1_vel += 2

def paddle1_slower():
global paddle1_vel
paddle1_vel -= 2

Apache Pig Philosophy

Apache Pig Philosophy
https://pig.apache.org/philosophy.html1

What does it mean to be a pig?
The Apache Pig Project has some founding principles that help pig developers decide how the system should grow over time. This page presents those principles.

Pigs Eat Anything

Pig can operate on data whether it has metadata or not. It can operate on data that is relational, nested, or unstructured. And it can easily be extended to operate on data beyond files, including key/value stores, databases, etc.

Tropos --- gource

Tropos
http://www.troposproject.org/
Tropos is a software development methodology, where concepts of the agent paradigm are used along the whole software development process. Notions of agent, goal, task and (social) dependency are used to model and analyze early and late software requirements, architectural and detailed design, and (possibly) to implement the final system. In this web site, you can find details of ongoing research, developed tools, industrial projects and Tropos related events. Tropos is derived from the Greek τροποσ, which means “way of doing things”; also τροπή, which means “turn” or “change”.

Pivotal Tracker

Pivotal Tracker

Pivotal Tracker is an easy to use, agile project management tool that brings focused collaboration to software development teams. Built by Pivotal Labs, it embodies proven agile methods, based on experience from hundreds of successful large scale projects.

Build better software, faster.
Collaborative, lightweight agile project management tool, brought to you by the experts in agile software development.
https://www.pivotaltracker.com/


Source: commit a6ce5b0 in My-Notes.

Scholarpedia

Scholarpedia
Scholarpedia is a peer-reviewed open-access encyclopedia written and maintained by scholarly experts from around the world. Scholarpedia is inspired by Wikipedia and aims to complement it by providing in-depth scholarly treatments of academic topics.
http://www.scholarpedia.org


Source: commit 8015493 in My-Notes.

Python Removing from List

Python Remove from List
Never Remove anything from a List that you are iterating on instead mark it and remove later

# define event handler for mouse click, draw
def click(pos):
remove = []
for ball in ball_list:
if distance(ball, pos) < ball_radius:
remove.append(ball)

if remove == []:
ball_list.append(pos)
else:
for ball in remove:
ball_list.pop(ball_list.index(ball))


Source: commit 36dedb5 in My-Notes.