[IPython-User] questions about using macro ...
Ching-Chao Chang
cchang@geodigmcorp....
Tue Jun 8 11:42:36 CDT 2010
Hi,
I'm new to ipython and python and I'm currently trying to use ipython as
a replacement to windows shell.
But I got some questions about using macro.
I wrote a macro named "get_case" as follows ...
order_id = _margv[0]
!mkdir C:\Temp\${order_id}
a = !dir
a = a.grep(str(order_id))
for f in a.fields(4):
!copy ${f} C:\Temp\${order_id}
this macro works fine, but after I make some changes, it becomes really
weird
num_cases = len(_margv)
for I in range(num_cases):
order_id = _margv[0]
!mkdir C:\Temp\${order_id}
a = !dir
a = a.grep(str(order_id))
for f in a.fields(4):
!copy ${f} C:\Temp\${order_id}
I call the modified macro this way get_case(91111, 91112)
Then I get the following error messages
------------------------------------------------------------------------
---
AttributeError Traceback (most recent call
last)
C:\Python26\Scripts\<ipython console> in <module>()
C:\Python26\lib\site-packages\ipython-0.10-py2.6.egg\IPython\macro.pyc
in __call__(self, *args)
36 def __call__(self,*args):
37 Term.cout.flush()
---> 38 self._ip.user_ns['_margv'] = args
39 self._ip.runlines(self.value)
40
AttributeError: Macro instance has no attribute '_ip'
I totally have no idea why? Can anyone shed some light on this?
Besides, using macro which occupies more than one lines seem to screw up
the line number. After I use the macro,
what I got from rep $line_number is different from what I see from the
prompt. Am I using the macro in a wrong way,
or is there anything I can do to avoid this?
I really appreciate any help on these two questions.
Alvin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20100608/341563c7/attachment.html
More information about the IPython-User
mailing list