473,943 Members | 14,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to comment lot of lines in python

Like in C we comment like
/*
Bunch of lines of code
*/

Should we use docstring """ """

Or there is something else too ??

Every help is appreciated.

Thanks

Mar 30 '06
19 2232
Eric Deveaud <ed******@paste ur.fr> wrote:
some moderns editors allow you to comment/uncomment a selected Bunch
of lines of code


Out of curiousity, is there a modern editor which *doesn't* allow you
to comment/uncomment a selected bunch of lines of code?

--
\S -- si***@chiark.gr eenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
Apr 3 '06 #11
Sion Arrowsmith wrote:
Eric Deveaud <ed******@paste ur.fr> wrote:
some moderns editors allow you to comment/uncomment a selected Bunch
of lines of code


Out of curiousity, is there a modern editor which *doesn't* allow you
to comment/uncomment a selected bunch of lines of code?

TextPad is my editor of choice but it doesn't have this feature.

Kent
Apr 3 '06 #12
Kent Johnson <ke**@kentsjohn son.com> wrote in news:44310867$1 _1
@newspeer2.tds. net:
Sion Arrowsmith wrote:
Eric Deveaud <ed******@paste ur.fr> wrote:
some moderns editors allow you to comment/uncomment a selected Bunch
of lines of code


Out of curiousity, is there a modern editor which *doesn't* allow you
to comment/uncomment a selected bunch of lines of code?

TextPad is my editor of choice but it doesn't have this feature.


I use TextPad all the time, and while it is true that the feature is not
built in, it's misleading to say it doesn't have it. It is implemented by
means of a macro definition. I assign a key to a 'comment' macro (basically
replacing regex ^ with '# ' for the selected text) to do this. And of
course I have a reciprocal 'uncomment' macro as well.

--
rzed
Apr 3 '06 #13

Kent Johnson wrote:
Sion Arrowsmith wrote:
Eric Deveaud <ed******@paste ur.fr> wrote:
some moderns editors allow you to comment/uncomment a selected Bunch
of lines of code


Out of curiousity, is there a modern editor which *doesn't* allow you
to comment/uncomment a selected bunch of lines of code?

TextPad is my editor of choice but it doesn't have this feature.

Kent


I also use TextPad - 4.7.3. I have never thought to comment a block of
code, but this thread prompted me to see if it is possible. As far as I
can see, you can do it like this -

Menu > Configure > Block Select Mode - Ctrl+Q,B

Select a block, one column wide, using mouse or keyboard.

Menu > Edit > Fill Block (brings up dialog box)
Fill character: #
Format: Left align
Fill mode: Replace
OK

Done.

To uncomment, as above but set Fill character to a space.

It feels a bit fiddly, but I reckon if you use it a few times it will
become quite smooth.

Frank Millman

Apr 3 '06 #14
Rick Zantow wrote:
Kent Johnson <ke**@kentsjohn son.com> wrote in news:44310867$1 _1
@newspeer2.tds. net:
Sion Arrowsmith wrote:
Out of curiousity, is there a modern editor which *doesn't* allow you
to comment/uncomment a selected bunch of lines of code?

TextPad is my editor of choice but it doesn't have this feature.


I use TextPad all the time, and while it is true that the feature is not
built in, it's misleading to say it doesn't have it. It is implemented by
means of a macro definition. I assign a key to a 'comment' macro (basically
replacing regex ^ with '# ' for the selected text) to do this. And of
course I have a reciprocal 'uncomment' macro as well.


Thank you! I don't suppose you have any tricks to make it work with
UTF-8 data outside the cp1252 character set, do you?

Kent
Apr 3 '06 #15
Kent Johnson <ke**@kentsjohn son.com> wrote in
news:44******** **@newspeer2.td s.net:
Rick Zantow wrote:
Kent Johnson <ke**@kentsjohn son.com> wrote in news:44310867$1 _1
@newspeer2.tds. net:
Sion Arrowsmith wrote:
Out of curiousity, is there a modern editor which *doesn't* allow
you to comment/uncomment a selected bunch of lines of code?

TextPad is my editor of choice but it doesn't have this feature.


I use TextPad all the time, and while it is true that the feature is
not built in, it's misleading to say it doesn't have it. It is
implemented by means of a macro definition. I assign a key to a
'comment' macro (basically replacing regex ^ with '# ' for the
selected text) to do this. And of course I have a reciprocal
'uncomment' macro as well.


Thank you! I don't suppose you have any tricks to make it work with
UTF-8 data outside the cp1252 character set, do you?


Sadly, I don't. TP claims Unicode support, but I'm not sure what they
mean; it does seem to be restricted to cp1252.

--
rzed
Apr 4 '06 #16
Rick Zantow wrote:
Thank you! I don't suppose you have any tricks to make it work with
UTF-8 data outside the cp1252 character set, do you?


Sadly, I don't. TP claims Unicode support, but I'm not sure what they
mean; it does seem to be restricted to cp1252.


TP will correctly read and write UTF-8 files if they use only the
characters available in cp1252. So there is a little Unicode support but
it breaks down pretty quickly with, e.g. Chinese or even Polish.

Kent
Apr 4 '06 #17
> You should use a decent editor that could automatically
comment/uncomment code upon your request.


The Zeus for Windows IDE has just such a feature:

http://www.zeusedit.com/python.html

To do this in Zeus you basically mark the lines of text
that need commenting then use the Macros, Add Comment
Block menu to comment the lines selected.

Then to remove the comments you use the Macros, Remove
Comment Block menu.

Jussi Jumppanen
Author: Zeus for Windows

Apr 4 '06 #18
What's wrong with using three sets of double-quotes? I do it with kwrite
and it works like a charm.

Apr 5 '06 #19
In <00************ **********@reec e.net.au>, Michael Sperlle wrote:
What's wrong with using three sets of double-quotes?
One can't comment out code that contains multiline strings. Especially
nested comment out does not work.
I do it with kwrite and it works like a charm.


Why not Ctrl+D (comment) and Ctrl+Shift+D (uncomment)?

Ciao,
Marc 'BlackJack' Rintsch
Apr 5 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
3551
by: Riko Wichmann | last post by:
Dear all, is there a way in Python to comment out blocks of code without putting a # in front of each line? Somethings like C's /* block of code here is commented out */ Thanks,
16
2317
by: qwweeeit | last post by:
In analysing a very big application (pysol) made of almost 100 sources, I had the need to remove comments. Removing the comments which take all the line is straightforward... Instead for the embedded comments I used the tokenize module. To my surprise the analysed output is different from the input (the last tuple element should exactly replicate the input line) The error comes out in correspondance of a triple string.
9
3062
by: Tim Anderson | last post by:
Does anyone else think VB should support the // prefix for comments? I keep using it by accident, because so many other languages use it (unlike the single quote, which is I believe unique to VB). If you think VB would be improved by this change, please vote on my suggestion here: http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackId=FDBK15038 Thanks!
16
1881
by: Christopher | last post by:
Hello all, I've got a question of comment logic. I'm trying to determine if a given line of C/C++/C#/Java is a comment or not. Can you please comment on my logic. I need to define some terms first: starts with = has only white space on the line untill it reaches ... first preceeding valid /* = looking back, the first /* from the current point in the file where the line does not have a // before the /*
3
2419
by: Martin P. Hellwig | last post by:
Hi all, I've been toying with python for about two years now. Not every day, just when I encounter something in my job (sysadmin) repetitively dull. The amazing thing is that like any other language (natural or not) learning it more gives you power to express your thoughts better and create something from nothing, for me this is something I can only compare to freedom. However since I'm learning more of python I've struggled with
29
2397
by: dbhbarton | last post by:
Had a thought that's grown on me. No idea if it's original or not- too inexperienced in programming- but I guess there's no harm floating it out there. Python wins big on readability, and there's no doubt that context- dependent text formatting in IDEs (keywords, strings, comments etc) is a massive help too, therefore benefitting development and maintenance. This idea is in a similar vein, especially for when scripts grow large.
3
1021
by: Ludwig Miniatur | last post by:
Hi, I ran into a funny thing when I played with the python parser, to build a python call graph for learning... When I have a (special) python program, that runs without any error it gives an error, when I try to parse it parser.suite. The error is, when my program has a comment on the last line after an indented block. Note that there no newline behind "# comment". With a newline everything is fine. For example:
39
2915
by: polas | last post by:
Afternoon all. I was just wondering about this point - I have (generally) used // for commenting a single line in C, but from looking at code other people have written it seems many use /* */ (which I only use if my comment will be over multiple lines) - does one way have any advantages over the other, or is the style exactly that, a question of style? Cheers, Nick
3
10866
by: Richard | last post by:
Again, new to DB2. Trying to do something I can do in Sybase ASE. In any Sybase SQL script I can use /* */ to comment out a block of code. In the DB2 9.0 SQL Reference Manual V1 it says: Comments: SQL comments are either bracketed (introduced by /* and end with */) or simple (introduced by two consecutive hyphens and end with
0
11532
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11123
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10662
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9864
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8219
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6087
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6308
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.