aspe:keyoxide.org:HOT6KMK2MDVWOHG5LNT3XFRK5U
I hereby claim:
- I am 1o55 on github.
- I am 1055 (https://keybase.io/1055) on keybase.
- I have a public key ASCDzIHJ4BtrejU2kntCjFFQkMLx_3yumVGI5prmJ9RSCgo
To claim this, I am signing this object:
by Bjørn Friese
Beautiful is better than ugly. Explicit is better than implicit.
I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on("chat:message", function(msg) { | |
//checks if the message is 1) an API message and 2) contains our call | |
if (msg.type == "api" && msg.content.indexOf("!wildshape") !== -1) { | |
//splits the contents of the message in to parts and stores them in an array | |
var args = msg.content.split(/\s+/); | |
//deletes the "!wildshape" from the array of message contents | |
args.shift(); | |
var mycharName = args[0]; | |
var mycharobj = findObjs({ | |
_type: "character", |