Skip to content

Commit

Permalink
tweaked readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed May 8, 2013
1 parent ea965db commit cdbb413
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 0 additions & 5 deletions macropy/macros2/linq_test.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
for line in open("macros2/linq_test_dataset.sql").read().split(";"): for line in open("macros2/linq_test_dataset.sql").read().split(";"):
engine.execute(line.strip()) engine.execute(line.strip())




db = generate_schema(engine) db = generate_schema(engine)




def compare_queries(query1, query2): def compare_queries(query1, query2):
res1 = engine.execute(query1).fetchall() res1 = engine.execute(query1).fetchall()
res2 = engine.execute(query2).fetchall() res2 = engine.execute(query2).fetchall()
Expand All @@ -27,7 +23,6 @@ def compare_queries(query1, query2):
print res2 print res2
raise e raise e



class Tests(unittest.TestCase): class Tests(unittest.TestCase):
""" """
Most examples taken from Most examples taken from
Expand Down
5 changes: 4 additions & 1 deletion readme.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -338,9 +338,10 @@ print Point(1, 2) == Point(1, 2)


[Case classes](http://www.codecommit.com/blog/scala/case-classes-are-cool) are classes with extra goodies: [Case classes](http://www.codecommit.com/blog/scala/case-classes-are-cool) are classes with extra goodies:


- A nice `__str__` method is autogenerated - Nice `__str__` and `__repr__` methods autogenerated
- An autogenerated constructor - An autogenerated constructor
- Structural equality by default - Structural equality by default
- A Copy-constructor, for creating modified copies of instances


The reasoning being that although you may sometimes want complex, custom-built classes with custom features and fancy inheritance, very (very!) often you want a simple class with a constructor, pretty `__str__` and `__repr__` methods, and structural equality which doesn't inherit from anything. Case classes provide you just that, with an extremely concise declaration: The reasoning being that although you may sometimes want complex, custom-built classes with custom features and fancy inheritance, very (very!) often you want a simple class with a constructor, pretty `__str__` and `__repr__` methods, and structural equality which doesn't inherit from anything. Case classes provide you just that, with an extremely concise declaration:


Expand Down Expand Up @@ -434,6 +435,8 @@ This is an implementation of a singly linked [cons list](http://en.wikipedia.org


As the classes `Nil` are `Cons` are nested within `List`, both of them get transformed into top-level classes which inherit from it. This nesting can go arbitrarily deep. As the classes `Nil` are `Cons` are nested within `List`, both of them get transformed into top-level classes which inherit from it. This nesting can go arbitrarily deep.


Overall, case classes are similar to Python's [`namedtuple`](http://docs.python.org/2/library/collections.html#collections.namedtuple), but on steroids (methods, inheritence, etc.), and provides the programmer with a much better experience.

Pattern Matching Pattern Matching
---------------- ----------------
Pattern matching is taken from many functional languages, including Haskell, Pattern matching is taken from many functional languages, including Haskell,
Expand Down

0 comments on commit cdbb413

Please sign in to comment.