mhonarc-dev

fancyquote on python interpreter recordings

2005-06-22 16:40:07
I really like the text/plain fancyquote option (IMO, it's more
aestetic and easier to read - and it's certainly more semantic). 
However, it has the nasty habbit of butchering Python interpreter code
(see example below).

Has anyone worked on a solution for this?  I realize it borders on the
AI, but ideally it should detect realize when >>> is a triple quote
and when it is a Python prompt.  I think a good algorithm might be to
assume any >>> are a Python prompt unless they are bordered by a >> or
a >.  Perhaps this should only be turned on if the word /python/i
appears somewhere in the email, or if a _ ( ) [ ] = - + / * or :
appears on the line (much more common in Python than in quotations). 
Ideas?

I'm also confused about how to implement it?  Again, ideas, anyone?

--ECC

EXAMPLE (begin quote):
Strange.  Here's what I found:

value = [r for r in xrange(1000000)] +[{1:2,3:4,5:6},{"simon":"wittber"}]
import time, marshal
t1=time.time();s=marshal.dumps(value);t2=time.time()
t2-t1
0.22474002838134766
len(s)
5000061
t1=time.time();new_value=marshal.loads(s);t2=time.time()
t2-t1
0.3606879711151123
new_value == value
True


I can't reproduce your large times for marshal.dumps.  Could you
post your test code?
IS RENDERED AS:
</pre></blockquote><pre style="margin: 0em;">

Strange.  Here's what I found:

</pre><blockquote style="border-left: #5555EE solid 0.2em; margin:
0em; padding-left: 0.85em"><block
quote style="border-left: #5555EE solid 0.2em; margin: 0em;
padding-left: 0.85em"><blockquote style=
"border-left: #5555EE solid 0.2em; margin: 0em; padding-left:
0.85em"><pre style="margin: 0em;">valu
e = [r for r in xrange(1000000)]
+[{1:2,3:4,5:6},{&quot;simon&quot;:&quot;wittber&quot;}]
import time, marshal
t1=time.time();s=marshal.dumps(value);t2=time.time()
t2-t1
</pre></blockquote></blockquote></blockquote><pre style="margin:
0em;">0.22474002838134766
</pre><blockquote style="border-left: #5555EE solid 0.2em; margin:
0em; padding-left: 0.85em"><block
quote style="border-left: #5555EE solid 0.2em; margin: 0em;
padding-left: 0.85em"><blockquote style=
"border-left: #5555EE solid 0.2em; margin: 0em; padding-left:
0.85em"><pre style="margin: 0em;">len(
s)
</pre></blockquote></blockquote></blockquote><pre style="margin: 0em;">5000061
</pre><blockquote style="border-left: #5555EE solid 0.2em; margin:
0em; padding-left: 0.85em"><block
quote style="border-left: #5555EE solid 0.2em; margin: 0em;
padding-left: 0.85em"><blockquote style=
"border-left: #5555EE solid 0.2em; margin: 0em; padding-left:
0.85em"><pre style="margin: 0em;">t1=t
ime.time();new_value=marshal.loads(s);t2=time.time()
t2-t1
</pre></blockquote></blockquote></blockquote><pre style="margin:
0em;">0.3606879711151123
</pre><blockquote style="border-left: #5555EE solid 0.2em; margin:
0em; padding-left: 0.85em"><block
quote style="border-left: #5555EE solid 0.2em; margin: 0em;
padding-left: 0.85em"><blockquote style=
"border-left: #5555EE solid 0.2em; margin: 0em; padding-left:
0.85em"><pre style="margin: 0em;">new_
value == value
</pre></blockquote></blockquote></blockquote><pre style="margin: 0em;">True
</pre><blockquote style="border-left: #5555EE solid 0.2em; margin:
0em; padding-left: 0.85em"><block
quote style="border-left: #5555EE solid 0.2em; margin: 0em;
padding-left: 0.85em"><blockquote style=
"border-left: #5555EE solid 0.2em; margin: 0em; padding-left:
0.85em"><pre style="margin: 0em;">

</pre></blockquote></blockquote></blockquote><pre style="margin: 0em;">

I can't reproduce your large times for marshal.dumps.  Could you
post your test code?
END

---------------------------------------------------------------------
To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the
message text UNSUBSCRIBE MHONARC-DEV

<Prev in Thread] Current Thread [Next in Thread>
  • fancyquote on python interpreter recordings, East Coast Coder <=