OT: spacing of code in Google Groups

Grant Edwards grante at visi.com
Fri Dec 31 16:35:02 EST 2004


On 2004-12-31, mensanator at aol.com <mensanator at aol.com> wrote:
> beliavsky at aol.com wrote:
>> When I copy code from a source file into a Google Groups
>> message, the indentation is messed up, making my Python code
>> illegal and all my code ugly. Are there tricks to avoid this?
>
> Try putting a # at the start of every line. Everyone should
> understand what you mean (and you can always tell them to remove
> the #'s once they copy the listing).
>
> #import gmpy
> #i = 7
> #while i<100000:

I always rather liked line numbers (a-la 'can -n').  That also
makes discussion of the code easier:

     1	import gmpy
     2	i = 7
     3	while i<100000:
     4	# conjecture 1
     5	
     6	     if ((i % 3)>0) and ((i % 5)>0):
     7	             f = gmpy.fib(i)
     8	             ip = gmpy.is_prime(i)
     9	             fm = f % i
    10	             if (fm==(i-1)) and (ip==0):
    11	                     print "fib %5d: %5d (mod %5d)" % (i,fm,i),
    12	                     print gmpy.is_prime(i)
    13	     i += 2
    14	
    15	"""
    16	Conjecture #1: if i ends in 3 or 7 and fib(i) == i-1 (mod i)
    17	               then i is prime
    18	
    19	run #1 print all fib(i) == i-1 (mod i) that are composite
    20	
    21	fib  5777:  5776 (mod  5777) 0 <-- counter example
    22	fib 10877: 10876 (mod 10877) 0 <-- counter example
    23	fib 17261: 17260 (mod 17261) 0
    24	fib 75077: 75076 (mod 75077) 0 <-- counter example
    25	fib 80189: 80188 (mod 80189) 0
    26	"""

Not sure what Google Groups does to it...
    
-- 
Grant Edwards                   grante             Yow!  Now I understand the
                                  at               meaning of "THE MOD SQUAD"!
                               visi.com            



More information about the Python-list mailing list