OT: spacing of code in Google Groups

Discussion in 'Python' started by beliavsky@aol.com, Dec 31, 2004.

  1. Guest

    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?
     
    , Dec 31, 2004
    #1
    1. Advertising

  2. Guest

    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.
     
    , Dec 31, 2004
    #2
    1. Advertising

  3. On 2004-12-31, <> wrote:
    > 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
     
    Grant Edwards, Dec 31, 2004
    #3
  4. Guest

    wrote:
    > 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
     
    , Dec 31, 2004
    #4
  5. Guest

    Grant Edwards wrote:
    > On 2004-12-31, <> wrote:
    > > 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
     
    , Dec 31, 2004
    #5
  6. Steve Holden Guest

    Quoting code [was: OT: spacing of code in Google Groups]

    wrote:

    > wrote:
    >
    >> 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
     
    Steve Holden, Dec 31, 2004
    #6
  7. On Fri, 2004-12-31 at 13:03, 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 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
     
    Adam DePrince, Dec 31, 2004
    #7
  8. Peter Hansen Guest

    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
     
    Peter Hansen, Jan 1, 2005
    #8
  9. M.E.Farmer Guest

    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
     
    M.E.Farmer, Jan 1, 2005
    #9
  10. JanC Guest

    Adam DePrince schreef:

    > On Fri, 2004-12-31 at 13:03, 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 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
     
    JanC, Jan 1, 2005
    #10
  11. Dan Bishop Guest

    M.E.Farmer wrote:
    > 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.


    And for a long time, Google groups postings *were* whitespace
    significant. But the new interface broke it.

    > 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 :)


    I send them some earlier today. So far, I've only received their
    auto-reply.
     
    Dan Bishop, Jan 1, 2005
    #11
  12. Terry Reedy Guest

    "JanC" <> wrote in message
    news:Xns95D132B172343JanC@213.118.32.224...
    > I don't know if gmane keeps formating of messages intact when posting?
    > That could be an alternative too...


    Reading posts via gmane with Outlook Express preserves leading spaces just
    fine. However, OE deletes tabs regardless of what newsgroup does.
    The funny thing is that typing a tab gets converted to 4 spaces.

    Terry J. Reedy
     
    Terry Reedy, Jan 1, 2005
    #12
  13. JanC Guest

    Terry Reedy schreef:

    > "JanC" <> wrote in message
    > news:Xns95D132B172343JanC@213.118.32.224...
    >> I don't know if gmane keeps formating of messages intact when
    >> posting? That could be an alternative too...

    >
    > Reading posts via gmane with Outlook Express preserves leading spaces
    > just fine. However, OE deletes tabs regardless of what newsgroup
    > does.


    OE is useless anyway (at least as a newsreader).

    I was talking about the gmane web interface as an alternative to Google's.
    They have an NNTP server but also three http-based interfaces: RSS-feed,
    blog-style & framed (looks more or less like a newsreader).

    ....

    Tested it in gmane.test, posting through their web interface preserves
    whitespace.


    --
    JanC

    "Be strict when sending and tolerant when receiving."
    RFC 1958 - Architectural Principles of the Internet - section 3.9
     
    JanC, Jan 2, 2005
    #13
  14. Peter Hansen <> writes:

    > 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...


    You mean to say that your editor does not have rectangle operations ?
    :)
     
    Jacek Generowicz, Jan 5, 2005
    #14
  15. Peter Hansen Guest

    Jacek Generowicz wrote:
    > Peter Hansen <> writes:
    >>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...

    >
    > You mean to say that your editor does not have rectangle operations ?
    > :)


    I wouldn't know.** I try quite hard to limit the features
    that I have to learn and remember to a very, very small
    list. Why the heck would I ever have to do "rectangle
    operations" on a regular basis? ;-)

    -Peter

    ** I'm using Scite; it probably has it. It has quite a few
    features -- far more than I'll ever use. Remarkable how
    simple an editor could be and still be effective... for
    some people.
     
    Peter Hansen, Jan 5, 2005
    #15
  16. JanC Guest

    Peter Hansen schreef:

    >> You mean to say that your editor does not have rectangle operations ?
    >> :)

    >
    > I wouldn't know.** I try quite hard to limit the features
    > that I have to learn and remember to a very, very small
    > list. Why the heck would I ever have to do "rectangle
    > operations" on a regular basis? ;-)


    > ** I'm using Scite; it probably has it. It has quite a few
    > features -- far more than I'll ever use. Remarkable how
    > simple an editor could be and still be effective... for
    > some people.


    Rectangular selection only works with the mouse in SciTE/Scintilla:
    alt-click-drag.

    Most of SciTE's (editor-)features are also available in other Scintilla
    based editors.


    --
    JanC

    "Be strict when sending and tolerant when receiving."
    RFC 1958 - Architectural Principles of the Internet - section 3.9
     
    JanC, Jan 5, 2005
    #16
  17. Peter Hansen <> writes:

    > Why the heck would I ever have to do "rectangle operations" on a
    > regular basis? ;-)


    Well, given that all editors are cat equivalent[*], you don't _have_
    to use any of their features :)

    But just like Python (particularly in the hands of a skilled Python
    programmer) is more productive than a Turing Machine, any featureful
    editor (in the hands of an experienced user) is far more productive
    than "cat > file".


    [*] A bit like Turing equivalence: any program you can write in any
    other editor, you could also write with "cat > file"
     
    Jacek Generowicz, Jan 6, 2005
    #17
  18. On Wed, 05 Jan 2005 22:57:33 GMT, JanC <> wrote:
    > Rectangular selection only works with the mouse in SciTE/Scintilla:
    > alt-click-drag.


    Nope - hold down alt-shift, and select with the cursor keys.

    --
    Cheers,
    Simon B,
    ,
    http://www.brunningonline.net/simon/blog/
     
    Simon Brunning, Jan 6, 2005
    #18
  19. Peter Hansen Guest

    Jacek Generowicz wrote:
    > Peter Hansen <> writes:
    >>Why the heck would I ever have to do "rectangle operations" on a
    >>regular basis? ;-)

    >
    > Well, given that all editors are cat equivalent[*], you don't _have_
    > to use any of their features :)


    This "cat equivalent" thing is a red-herring. I can rarely type more
    than a line of code without making a typographical error. Sometimes
    I won't catch that error until a bit later. Using "cat" alone would
    provide me little opportunity to fix the error, so I would never
    be able to produce a working program longer than a few lines.

    You might call this simply "less productive" (though I'd argue
    it becomes a qualitative difference). But, okay, let's work from there...

    > But just like Python (particularly in the hands of a skilled Python
    > programmer) is more productive than a Turing Machine, any featureful
    > editor (in the hands of an experienced user) is far more productive
    > than "cat > file".


    I don't disagree. I do, however, claim that the set of features
    that are required to make *me* orders of magnitude more productive
    than "cat" (to use your quantitative comparison) is very, very small.

    And that I use less than 2% of the features most editors have.

    And that if a programmer with equal abilities managed to learn to
    use 98% of the features of such an editor, such that he could
    readily use whichever such feature was most effective at any given
    time, he would not be more than 10% more effective than I am.

    But the whole argument is fairly moot... I've needed a rectangle
    operation only once in the last ten years, and if I hadn't known at
    the time that my editor could do it (and spent about half an hour
    figuring out how it worked), I could have written a utility to
    do the job faster if I'd been using Python at the time...

    Cheers,
    -Peter
     
    Peter Hansen, Jan 6, 2005
    #19
  20. Steve Holden Guest

    Peter Hansen wrote:

    [...]
    >
    > But the whole argument is fairly moot... I've needed a rectangle
    > operation only once in the last ten years, and if I hadn't known at
    > the time that my editor could do it (and spent about half an hour
    > figuring out how it worked), I could have written a utility to
    > do the job faster if I'd been using Python at the time...


    Or even used cut(1) from the command line.

    regards
    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
     
    Steve Holden, Jan 6, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Petra Hübner
    Replies:
    0
    Views:
    460
    Petra Hübner
    Feb 16, 2004
  2. anonymous
    Replies:
    1
    Views:
    4,625
    Francisco Padron
    May 8, 2005
  3. Andrew Thompson

    FAQ - references to Google/Google Groups

    Andrew Thompson, Jun 20, 2005, in forum: Java
    Replies:
    0
    Views:
    655
    Andrew Thompson
    Jun 20, 2005
  4. john
    Replies:
    6
    Views:
    1,307
  5. Replies:
    3
    Views:
    369
    Peter Hansen
    Jun 10, 2005
Loading...

Share This Page