Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > OT: spacing of code in Google Groups

Reply
Thread Tools

OT: spacing of code in Google Groups

 
 
beliavsky@aol.com
Guest
Posts: n/a
 
      12-31-2004
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?

 
Reply With Quote
 
 
 
 
mensanator@aol.com
Guest
Posts: n/a
 
      12-31-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) 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:
## conjecture 1
#
# if ((i % 3)>0) and ((i % 5)>0):
# f = gmpy.fib(i)
# ip = gmpy.is_prime(i)
# fm = f % i
# if (fm==(i-1)) and (ip==0):
# print "fib %5d: %5d (mod %5d)" % (i,fm,i),
# print gmpy.is_prime(i)
# i += 2
#
#"""
#Conjecture #1: if i ends in 3 or 7 and fib(i) == i-1 (mod i)
# then i is prime
#
#run #1 print all fib(i) == i-1 (mod i) that are composite
#
#fib 5777: 5776 (mod 5777) 0 <-- counter example
#fib 10877: 10876 (mod 10877) 0 <-- counter example
#fib 17261: 17260 (mod 17261) 0
#fib 75077: 75076 (mod 75077) 0 <-- counter example
#fib 80189: 80188 (mod 80189) 0
#"""

Preview looked ok, so let's see what happens when I post it.

 
Reply With Quote
 
 
 
 
Grant Edwards
Guest
Posts: n/a
 
      12-31-2004
On 2004-12-31, (E-Mail Removed) <(E-Mail Removed)> wrote:
> (E-Mail Removed) 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
 
Reply With Quote
 
mensanator@aol.com
Guest
Posts: n/a
 
      12-31-2004

(E-Mail Removed) wrote:
> (E-Mail Removed) 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:
> ## conjecture 1
> #
> # if ((i % 3)>0) and ((i % 5)>0):
> # f = gmpy.fib(i)
> # ip = gmpy.is_prime(i)
> # fm = f % i
> # if (fm==(i-1)) and (ip==0):
> # print "fib %5d: %5d (mod %5d)" % (i,fm,i),
> # print gmpy.is_prime(i)
> # i += 2
> #
> #"""
> #Conjecture #1: if i ends in 3 or 7 and fib(i) == i-1 (mod i)
> # then i is prime
> #
> #run #1 print all fib(i) == i-1 (mod i) that are composite
> #
> #fib 5777: 5776 (mod 5777) 0 <-- counter example
> #fib 10877: 10876 (mod 10877) 0 <-- counter example
> #fib 17261: 17260 (mod 17261) 0
> #fib 75077: 75076 (mod 75077) 0 <-- counter example
> #fib 80189: 80188 (mod 80189) 0
> #"""
>
> Preview looked ok, so let's see what happens when I post it.


In looking at this, I noticed the tabs in the code were preserved,
but the double space between "fib" and "5777" in the comments was
not. But if you click on the "show original" link, the spaces come
back, so maybe you don't to any thing except "show original" when
you want to copy source code.

Testing 1
Testing 2
Testing 3

 
Reply With Quote
 
mensanator@aol.com
Guest
Posts: n/a
 
      12-31-2004

Grant Edwards wrote:
> On 2004-12-31, (E-Mail Removed) <(E-Mail Removed)> wrote:
> > (E-Mail Removed) 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...


It wrapped lines 16 and 19. But "show original" restores it.

>
> --
> Grant Edwards grante Yow! Now I

understand the
> at meaning of "THE

MOD SQUAD"!
> visi.com


 
Reply With Quote
 
Steve Holden
Guest
Posts: n/a
 
      12-31-2004
(E-Mail Removed) wrote:

> (E-Mail Removed) wrote:
>
>>(E-Mail Removed) 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).
>>

[...]
>

It would be helpful if submitted code were also copied to

http://rafb.net/paste/

although I don;t know how long they archive the pastings. That's a site
that gets used on the ##python IRC channel a lot, and it does make
sharing very easy.

Having said which, there's still a lot going for just using spaces
instead of tabs.

though-i-don't-know-what-ggogle-does-to-that-ly y'rs - steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
 
Reply With Quote
 
Adam DePrince
Guest
Posts: n/a
 
      12-31-2004
On Fri, 2004-12-31 at 13:03, (E-Mail Removed) 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?


Subscribe to the (E-Mail Removed) mailing list. Take a look at
http://python.org/community/lists.html The news group and this list are
mirrors of each other. Of course, the benefit this provides depends on
which mail client you use.


Adam DePrince


 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      01-01-2005
Grant Edwards wrote:
> I always rather liked line numbers (a-la 'can -n'). That also
> makes discussion of the code easier:


That, unfortunately, is somewhat harder to remove without
using a regular expression... leading hash marks # is
pretty simple to remove with almost any editor.

-Peter
 
Reply With Quote
 
M.E.Farmer
Guest
Posts: n/a
 
      01-01-2005
Grant Edwards wrote:
>Not sure what Google Groups does to it...

The usual... it mangles it.
I don't get it, Google uses Python too, they know it is whitespace
signifigant.
I made a complaint several weeks ago to Google support ,
asking them too quit stripping leading whitespace,
and the sent me a reply saying they appreciated my feedback.
Maybe they just need more feedback
M.E.Farmer

 
Reply With Quote
 
JanC
Guest
Posts: n/a
 
      01-01-2005
Adam DePrince schreef:

> On Fri, 2004-12-31 at 13:03, (E-Mail Removed) 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?

>
> Subscribe to the (E-Mail Removed) mailing list. Take a look at
> http://python.org/community/lists.html The news group and this list are
> mirrors of each other. Of course, the benefit this provides depends on
> which mail client you use.


I don't know if gmane keeps formating of messages intact when posting?
That could be an alternative too...

Or just use one of the free news servers, some of them even allow
connections on port 80.

--
JanC

"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does Google Groups contain Google Docs? me@privacy.net Computer Support 2 09-20-2009 08:08 AM
Re: Try Doing A Google Search For Greg Carr On Google Groups Kevin C Baer Computer Support 4 09-16-2008 10:09 PM
Google Groups background color hex code? john HTML 6 06-20-2006 03:10 PM
FAQ - references to Google/Google Groups Andrew Thompson Java 0 06-20-2005 12:26 PM
getting values from URL such as http://groups.google.co.uk/groups?q=parameters+url+asp.net&start=10&hl=en&lr=& anonymous ASP .Net 1 05-08-2005 03:58 PM



Advertisments