[seqfan] submitting a program, while preserving preformatted text

Donald Alan Morrison donmorrison at gmail.com
Sat Sep 4 20:52:37 CEST 2010


http://www.research.att.com/~njas/sequences/eishelp1.html

I submitted a python/sage program, which requires preservation of
indentation (because indents are implicit blocks, like curly braces in
C).

How do I preserve indentation, so it shows up correctly on the page?

http://www.research.att.com/~njas/sequences/A100959

Attached is a version with correct indentation and a fix to write the
file to the current user's home directory, it also only uses 'w' mode.
 (Assuming the seqfan list lets small attachments through, please see
attached.)

If you want to try out sage: http://sagemath.org/download.html

Cheers,
Don
-------------- next part --------------
%time
# python 2.6.X, sage 4.5.2, seq id:A100959
from os.path import expanduser
lo = 2
hi = 14 * 10^3
nonsemip = [1]
for a in xrange(lo,hi+1):
    lst = list(factor(a))
    if len(lst)==1:
        if lst[0][1]==2:
            continue
    elif len(lst)==2:
        if lst[0][1]==1 and lst[1][1]==1:
            continue
    nonsemip.append(a)
with open(expanduser("~/B100959.txt"), 'w') as fp:
    for i in xrange(10^4):
        print >> fp, "%d" % nonsemip[i]
fp.close()
del(fp)



More information about the SeqFan mailing list