Permalink
Browse files

Removed examples

  • Loading branch information...
1 parent 3da6ccd commit 7bf1cc06f875daf226918eee9d97ca7f78198c90 @orangeduck committed May 17, 2012
Showing with 0 additions and 126 deletions.
  1. +0 −14 Examples/example_module.py
  2. +0 −36 Examples/pets.py
  3. +0 −69 Examples/pets_better.py
  4. +0 −7 examples/toys.py
View
@@ -1,14 +0,0 @@
-from pymark.util import flags, enum
-
-merchandise, reward, bonus = flags(3)
-body_armor, helmets, gloves, boots = enum(4)
-
-def modifiers(*args): return args;
-def cost(x): return x
-
-example_module = {
- "explorer_jacket" : ( "Explorer Jacket", "greatcoat_new", merchandise|reward, body_armor, cost(214), {"weight" : 5, "protection" : 11}, modifiers("old", "ragged", "torn") ),
- "chaps" : ( "Chaps", "chaps", merchandise|bonus, boots, cost(23), {"weight" : 1, "protection" : 2}, modifiers("wrapped", "posh", "battered") ),
- "sailor_shirt" : ( "Sailor Shirt", "sailor_shirt", merchandise, body_armor, cost(112), {"weight" : 3, "protection" : 4}, modifiers("wet") ),
- "pegleg" : ( "Peg Leg", "peg_leg_m", None, boots, cost(321), {"weight" : 7, "protection" : 4}, modifiers("wonky", "new") ),
-}
View
@@ -1,36 +0,0 @@
-
-pets = [
-
- {"name": "John",
- "animal": "Dog",
- "legs": 4,
- "age": 10,
- "toys": ["squeezy","bone"],
- "traits": ["Cute","Funny","Friendly"],
- "color": "Brown"},
-
- {"name": "Benni",
- "animal": "Cat",
- "legs": 4,
- "age": 8,
- "toys": ["mouse_ball","string"],
- "traits": ["Cute","Vain"],
- "color": "Ginger"},
-
- {"name": "Leeroy",
- "animal": "Elephant",
- "legs": 4.5,
- "age": 102,
- "toys": ["peanuts"],
- "traits": ["Friendly"],
- "color": "Grey"},
-
- {"name": "Tophat",
- "animal": "Sparrow",
- "legs": 2,
- "age": 1,
- "toys": None,
- "traits": ["Vain","Speedy"],
- "color": "Brown"},
-
-]
View
@@ -1,69 +0,0 @@
-from PyMark.Util import *
-
-""" The "animal" field isn't really looking for a String - it's looking for a type. So we can use this Enum instead. Much better. """
-
-Dog, Cat, Elephant, Sparrow = Enum(4)
-
-""" Lots of the personality traits are shared, perhaps we can use Flags instead! Makes a lot more sense than a list of Strings. """
-
-Cute, Funny, Friendly, Vain, Speedy = Flags(5)
-
-""" It'd be nicer to represent color as a tuple rather than a string, we can do it with this quick function definition.
- This adds more expressive power, and we can even ensure that the outputs are floats. """
-
-def Color(r,g,b):
- return (float(r),float(g),float(b))
-
-""" We can define some constants to help us with the colors. That way we can reuse them. """
-
-BROWN = Color(156,137,61)
-GINGER = Color(247,172,32)
-GREY = Color(128,128,128)
-
-"""
- If you're worried about detecting these flags, enums or constants afterwards don't be. All constants are compiled to a special "constants" module, so it should be no problem!
-
- Finally lets consider the "toys" field. If in fact we consider a toy as another object and if we have toys module defined, then we can use the reference function to express this link!
-
- Overall I think this is much nicer. We've reduced the instances of Strings to just the parts which actually are strings, and dramatically increased the expressiveness of the data!
- Also without all those strings I think it is much easier to read.
- I'm not saying that all of these things are the "correct" way to structure the data.
- I believe you should structure your data to best suite the task in hand, not by some set of global rules.
- Having extra constructs just allows for that a little more easily :)
-"""
-
-pets = [
-
- {"name": "John",
- "animal": Dog,
- "legs": 4,
- "age": 10,
- "toys": [Ref("toys.squeezy"), Ref("toys.bone")],
- "traits": Cute|Funny|Friendly
- "color": BROWN},
-
- {"name": "Benni",
- "animal": Cat,
- "legs": 4,
- "age": 8,
- "toys": [Ref("toys.mouse_ball"), Ref("toys.string")],
- "traits": Cute|Vain
- "color": GINGER},
-
- {"name": "Leeroy",
- "animal": Elephant,
- "legs": 4.5,
- "age": 102,
- "toys": [Ref("toys.peanuts")],
- "traits": Friendly
- "color": GREY},
-
- {"name": "Tophat",
- "animal": Sparrow,
- "legs": 2,
- "age": 1,
- "toys": None,
- "traits": Vain|Speedy,
- "color": BROWN},
-
-]
View
@@ -1,7 +0,0 @@
-toys = [
- "squeezy" : (),
- "mouse_ball" : (),
- "peanuts" : (),
- "bone" : (),
- "string" : (),
-]

0 comments on commit 7bf1cc0

Please sign in to comment.