I'm still tyring to figure out what "Pythonic" means, and I have a
feeling the answer to my question may fall into that category. Are block
comments somehow unpythonic? 18 2167
John Salerno wrote: I'm still tyring to figure out what "Pythonic" means, and I have a feeling the answer to my question may fall into that category. Are block comments somehow unpythonic?
only in the sense that python don't have them.
but they're pretty pointless, if you have a modern editor.
(and if you don't, you can quickly comment out regions by putting them
inside a triple-quoted string.)
</F>
Fredrik Lundh <fr*****@python ware.com> wrote: you can quickly comment out regions by putting them inside a triple-quoted string.)
Except that triple-quotes don't nest.
I do agree, however, with the idea that any decent editor should be
able to comment out a block of code faster than I can type this
sentence.
It's clear that if you have a modern editor, block comments are
unnecessary because it is trivial to add a # to the start of each line
of a block, but that doesn't really answer your question. It explains
why you might not always need block comments but doesn't explain why
you shouldn't use them (especially in a primitive editor).
The danger with block comments is that there is no way to tell that the
code you're looking at has been commented out unless you can see the
start or end of the comment block. If you have a modern editor, it
probably changes the color of all commented out code to eliminate
confusion. But if you have a primitive editor it does not. Also, even
people who use modern editors sometimes browse source code using a
plain text viewer (less/more).
Eliminating block comments eliminates uncertainty. :)
....and I forgot to mention that the output of grep and diff is far more
understandable in the absence of block comments!
Warby wrote: The danger with block comments is that there is no way to tell that the code you're looking at has been commented out unless you can see the start or end of the comment block. If you have a modern editor, it probably changes the color of all commented out code to eliminate confusion. But if you have a primitive editor it does not.
That makes sense. If you have a modern editor, you don't need blocks. If
you don't have one, blocks don't help. :)
Roy Smith wrote: you can quickly comment out regions by putting them inside a triple-quoted string.)
Except that triple-quotes don't nest.
''' """...excep t when they do""" '''
</F>
Warby <Ma************ @gmail.com> wrote: Eliminating block comments eliminates uncertainty. :)
An even better way to eliminate uncertainty is to eliminate the code.
Commenting out is fine for a quick test during development. Once the
code is committed, the dead code should be eliminated completely.
On Wednesday 08 March 2006 12:42 pm, Warby wrote: The danger with block comments is that there is no way to tell that the code you're looking at has been commented out unless you can see the start or end of the comment block. If you have a modern editor, it probably changes the color of all commented out code to eliminate confusion. But if you have a primitive editor it does not. Also, even people who use modern editors sometimes browse source code using a plain text viewer (less/more).
No doubt some Emacs zealot will say something snarky at this point, ;-)
but it's also true that Vi (or gvim anyway) will occasionally get
confused by very long block comments or triple-quoted strings,
causing the syntax-color to get out of synch.
I recently started running into this problem when I started using
doctest tests. There's probably a smarter way to do this, but I
was putting several of them in a module docstring, and it gets to
be a 100+ lines or so of doctest plus explanations.
I'm thinking this might be a use-case for the new support for
doctests in a separate file. Or maybe I just need to see if I
can move the tests into individual object docstrings.
--
Terry Hancock ( hancock at anansispacework s.com )
Anansi Spaceworks http://www.anansispaceworks.com
I have found that some editors colourize text based on parsing a
section of text around what is visible. Long, multi-line comments or
strings might not then get colored correctly.
Personally, I do use block comments in other languages but maybe they
should not exist in finished code for reasons already given by others,
readabiity!
Cheers, Paddy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tim Parkin |
last post by:
Terry Ready said:
> YUCK< YUCK< YUCK.
> <snip>
> The pollenation site is one of the worst I have seen. The mockup page
> has teeny type that IE will not enlarge.
> <snip>
> I care that the site remain physically readable and that it remain a
> vehicle for information rather than childish egos.
> <snip>
> Using IE6, I need a magnifying glass
|
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro capabilities, unfortunately. I'd like to know if it may
be possible to add a powerful macro system to Python, while
keeping its amazing syntax, and if it could be possible to
add Pythonistic syntax to Lisp or Scheme, while keeping all
of the...
|
by: Adam Barr |
last post by:
For a book I am working on, I have written a brief (9 page) summary
of Python. The intent of this is that an experienced programmer who
did
not know Python would be able to get enough information to read and
understand Python programs. It is not meant to be a 100% complete
summary of the language, but everything in there should be correct.
If anyone is interested, please feel free to read it and send me
comments. Note that the material...
|
by: Guido van Rossum |
last post by:
After many rounds of discussion on python-dev, I'm inviting public
comments for PEP 343. Rather than posting the entire PEP text here,
I'm inviting everyone to read it on line
(http://www.python.org/peps/pep-0343.html) and then post comments on a
Wiki page I've created for this purpose
(http://wiki.python.org/moin/WithStatement).
I think this is a good one; I hope people agree. Its acceptance will
obsolete about 4 other PEPs! (A sign...
|
by: Zhang Weiwu |
last post by:
Hello. This is problem puzzled me a long time. I wish to organize some
block elements and let them flow one after each other like text.
Think about a album, I wish the album have 12 thumbnails, each one has a
comment line under the picture. And I wish when the screen size is big,
this thumbnails arrange 3 rows, 4 columns; if the browser window is
smaller, arranges 4 rows, 3 columns; if it's even smaller, 6 rows with 2
columns. If there...
| |
by: lorinh |
last post by:
Hi Folks,
I'm trying to strip C/C++ style comments (/* ... */ or // ) from
source code using Python regexps.
If I don't have to worry about comments embedded in strings, it seems
pretty straightforward (this is what I'm using now):
cpp_pat = re.compile(r"""
/\* .*? \*/ | # C comments
|
by: Robert |
last post by:
After failing on a yield/iterator-continuation problem in Python (see
below) I tried the Ruby (1.8.2) language first time on that construct:
The example tries to convert a block callback interface
(Net::FTP.retrbinary) into a read()-like iterator function in order to
virtualize the existing FTP class as kind of file system. 4 bytes max
per read in this first simple test below. But it fails on the second
continuation with ThreadError after...
|
by: MartinRinehart |
last post by:
Tomorrow is block comment day. I want them to nest. I think the reason
that they don't routinely nest is that it's a lot of trouble to code.
Two questions:
1) Given a start and end location (line position and char index) in an
array of lines of text, how do you Pythonly extract the whole block
comment? (Goal: not to have Bruno accusing me - correctly - of writing
C in Python.)
2) My tokenizer has a bunch of module-level constants...
|
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
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |