NameError with case classes

43 views
Skip to first unread message

msha...@twitter.com

unread,
Mar 3, 2014, 3:08:23 AM3/3/14
to mac...@googlegroups.com
I am unable to get case classes to work correctly on my machine. I am running this on Windows with Python 2.7.6 32-bit (have tried 2 different python installations):

In [14]: from macropy.case_classes import macros, case
In [15]: @case
   ....: class Point(x,y):
   ....:     pass
   ....:
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-15-82da36e76a20> in <module>()
      1 @case
----> 2 class Point(x,y):
      3     pass
      4
NameError: name 'x' is not defined


I tried to run the example as well:

----> 1 import examples.using_macros.target
C:\macropy-master\docs\examples\using_macros\target.py in <module>()
      2
      3 @case
----> 4 class Point(x, y): pass
      5
      6 p = Point(1, 2)

NameError: name 'x' is not defined


For fun I also tried show_expanded:

In [13]: with show_expanded:
   ....:     @case
   ....:     class Point(x,y):
   ....:         pass
   ....:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-13-32d9ae40feb8> in <module>()
----> 1 with show_expanded:
      2     @case
      3     class Point(x,y):
      4         pass
      5
AttributeError: __exit__


Any help would be appreciated.

Thanks,
Matt

Haoyi Li

unread,
Mar 3, 2014, 3:27:39 AM3/3/14
to msha...@twitter.com, mac...@googlegroups.com
You need to do an 

import macropy.console

if you want to use macros in the console, or 

import macropy.activate

if you want to use macros in the files you are importing. Note that you cannot use macros in the same file you activate them, so you may need a simple "run.py" file which activates macros and imports the "real" application


--
You received this message because you are subscribed to the Google Groups "macropy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macropy+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages