473,708 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Case Sensitive, Multiline Comments

Hi I have two questions. Could someone explain to me why Python is
case sensitive? I find that annoying. Also, why aren't there
multiline comments? Would adding them cause a problem of some sort?

Thanks,
Elliot

Jul 19 '05 #1
32 3157
"Elliot Temple" <cu****@gmail.c om> writes:
Hi I have two questions. Could someone explain to me why Python is
case sensitive? I find that annoying.
Because it comes from a language background of case sensitive
languages (C, shell, etc.). But read what the BDFL has to say about
it: <URL:
http://mail.python.org/pipermail/pyt...ly/054788.html >

Personally, I think anyone who has two variables whose names differ
only in case should be shot. No, let me extend that - anyone who has
two variables whose names would be pronounced the same should be
shot. I've had to debug such code, and it ain't fun.

Variables whose name differs from the class they are instance of only
in case is the only allowable exception. And should be used with care.

On the same note, anyone who spells a variable name with different
cases because the languge is case-insensitive should be shot. I want
to be able to use various source analysis tools without having to
worry about dealing with two different ascii strings being names for a
single variable.

Add those two together, and you'll see that *I don't care*. I consider
taking advantage of a language being case-sensitive or
case-insensitive to be a bad idea, so it doesn't matter what the
language does.
Also, why aren't there
multiline comments? Would adding them cause a problem of some sort?


Because no one every really asked for them. After all, there are two
formats for multi-line strings, which the interpreter will build and
then discard. There are tools that recognize multi-line strings after
function/method definitions and treat them as function documentation.

Adding multiline comments probably wouldn't be a problem - you'd just
have to come up with an introductory character sequence that can't
occur in the language (not that that stopped C). But you'd have to get
someone to write the code, then someone with commit privs to decide it
was useful enough to commit. That seems to be a lot of work for very
little gain.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 19 '05 #2
Mike Meyer wrote:
"Elliot Temple" <cu****@gmail.c om> writes:
Also, why aren't there
multiline comments? Would adding them cause a problem of some sort?


Because no one every really asked for them. After all, there are two
formats for multi-line strings, which the interpreter will build and
then discard. There are tools that recognize multi-line strings after
function/method definitions and treat them as function documentation.

Adding multiline comments probably wouldn't be a problem - you'd just
have to come up with an introductory character sequence that can't
occur in the language (not that that stopped C). But you'd have to get
someone to write the code, then someone with commit privs to decide it
was useful enough to commit. That seems to be a lot of work for very
little gain.


Don't we already have multi-line comments in the form of string literals?

--
Paul McNett
http://paulmcnett.com

Jul 19 '05 #3
Mike Meyer wrote:
Personally, I think anyone who has two variables whose names differ
only in case should be shot. No, let me extend that - anyone who has
two variables whose names would be pronounced the same should be
shot. I've had to debug such code, and it ain't fun.


Here's a pair of targets for you:

From "Software Engineering with Modula-2 and Ada", by Wiener &
Sincovec, page 84:

WITH w^ DO
...
Col := column;
Row := row;

It turns out that 'Row' & 'Col' are module-global variables holding the
current cursor position, and 'row' & 'column' are elements of the record
to which 'w' points.

Here's another corollary for Meyer's Law: Anyone who has two variables
the name of one of which is, or could reasonably be understood to be, an
abbreviation of the name of the other should be shot.

Cheers,
John
Jul 19 '05 #4
Thanks for the link on case sensitivity. I'm curious about the person
who found case sensitivity useful though: what is it useful for?

The way I find multi-line comments useful is to quickly comment out a
block of code while debugging. A good development environment can
(mostly) solve that one though.

Jul 19 '05 #5
"Elliot Temple" <cu****@gmail.c om> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Hi I have two questions.
....

Also, why aren't there
multiline comments? Would adding them cause a problem of some sort?
As a matter of fact, yes. First, consider that as soon as you have
multi-line comments, someone is going to request nested multi-line
comments. (In other words, the compiler should check that the
embedded comment is still correct.) That rapidly leads to madness.

Second, multi-line comments aren't really necessary; as someone
in the thread commented, a decent editor or IDE will allow adding
or removing comments from a block of code easily. Python's
philosophy is to only add features when there is a use case that
will improve the language significantly, and commenting out a block
of code for testing isn't it. (It's also not the world's best practice,
but that's another subject.)

John Roth


Thanks,
Elliot


Jul 19 '05 #6
Elliot Temple wrote:
Thanks for the link on case sensitivity. I'm curious about the person
who found case sensitivity useful though: what is it useful for?


I wasn't that person, but I do find case sensitivity very useful.

Mainly it's useful in that it allows me not to spend any time at all
worrying that I just might have a collision in my naming of various
entities that are conceptually in different spaces but which -- due to
the nature of the language I'm using -- happen to co-exist in the same
namespace.

For example, although this contrived example suggests poor imagination
in picking names, I think it demonstrates the point.

INVENTORYCODE = 5 # in effect one item in a constant "enum"

class InventoryCode:
'''Might represent something to do with inventory codes... duh'''
def myfunc():
inventoryCode = someOtherFuncti on()
In other words, I have a CONSTANT, a Class, and an instance, and if the
set of code involved were large enough, these three things might be
defined far enough apart that the potential collision wouldn't be as
obvious as it is here.

More to the point, there might not be any relationship between these
things in my mind as I'm programming, and having to deal with an error
message from a compiler or, worse, a run time error resulting from this
collision would really annoy me.

Case sensitivity might not be something we should be deliberately
exercising on a daily basis, but there's no good reason (in my opinion)
for not having it available to allow one freedom in naming (assuming one
is sane and uses consistent convention for the case of things like
constants, classes, and instances) without the worry of pesky collisions.

-Peter
Jul 19 '05 #7
On 26 May 2005 17:33:33 -0700, "Elliot Temple" <cu****@gmail.c om>
declaimed the following in comp.lang.pytho n:
Thanks for the link on case sensitivity. I'm curious about the person
who found case sensitivity useful though: what is it useful for?
Making a language run faster on slow machines since the syntax
parsing doesn't have to do the equivalent of upper or lower casing
anything that is not a string literal before checking for keywords or
identifiers.

Consider the time spent by languages like Ada and Fortran when
they have to do case normalization every time you compile.

-- =============== =============== =============== =============== == <
wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
=============== =============== =============== =============== == <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.ne tcom.com/> <

Jul 19 '05 #8
Dennis Lee Bieber wrote:
On 26 May 2005 17:33:33 -0700, "Elliot Temple" <cu****@gmail.c om>
declaimed the following in comp.lang.pytho n:
Thanks for the link on case sensitivity. I'm curious about the person
who found case sensitivity useful though: what is it useful for?

Making a language run faster on slow machines since the syntax
parsing doesn't have to do the equivalent of upper or lower casing
anything that is not a string literal before checking for keywords or
identifiers.

Consider the time spent by languages like Ada and Fortran when
they have to do case normalization every time you compile.

That isn't a good argument for case sensitivity. You really aren't going to
be able to measure a slowdown in compilation speed just because the
compiler has to lowercase all the identifiers before using them.

What I consider good arguments for case sensitivity are:

Consistency. I've used non-case sensitive languages where the same variable
was spelled sometimes with capitals and sometimes without. Forcing you to
choose one case and stick to it is, IMHO a good thing. Worse, I've used
Visual Basic where the editor will gratuitously change the case of a
variable you just typed in because there is another occurrence of the same
name somewhere else in a different case.

Conventions such as capitalising class names, or camelCasing can be useful.
Again this only applies if they are used consistently.

Interoperabilit y. Like it or not, there are other case sensitive systems
out there. I once had the misfortune to use a Microsoft Access database
(where lookups on indexed fields are case insensitive) to store records
indexed by a case sensitive medical coding system. Codes in that system do
exist which differ from other completely unrelated conditions only by the
case of the code. The only way to handle this in a case insensitive system
is to somehow escape each case sensitive code.

That particular example wouldn't necessarily apply to a case insensitive
programming language, but plenty of others would: e.g. using a remote
procedure call system to call a (case sensitive) function on another
system.

In all such cases, the case insensitive system is the 'poor relation', it
is the one where you have to introduce workrounds in order to communicate
with the case sensitive system. Going in the other direction (calling a
case insensitive function from a case sensitive system) you simply have to
invent a convention (e.g. lowercase everything) and stick by it.

There are arguments that, especially for beginners, case sensitivity
introduces an extra level of complexity, but the cost of losing this
complexity would be to make Python a poor relation amongst programming
languages.
Jul 19 '05 #9
i found case sensitivity very useful

1. variables can be stored in a dict (think about __dict__, globals())
and dict type should be case sensitive

2. It's necessary when i write short scripts and i use one letter
names. (eg. when i playing with linear algebra i always use a,b,c for
vectors and A,B,C for matrices). I dont want to think about "more than
one letter" names when i run that script only once. And usually this is
the case with python (at least when i use it in interpreted mode).

3. i write sometimes:
class Foo:
...
foo = Foo()

and i think it's readable and makes sense.

4. actually i never wanted to use 'foo', 'Foo' and 'FOO' for the same
variable and i can't imagine a situation when it's useful. it makes the
code less readable so i think the language should force the programmer
not to use different names for the same variable.

nsz

Jul 19 '05 #10

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

Similar topics

4
10935
by: Uwe Ziegenhagen | last post by:
Hello, my fellows and me implement a c++ tool that is able to divide blank/tab separated files into <number>, <text>, <c-singlelinecomment> and <multilinecomment>. So far it's not working bad, we have just one problem if I call the a.exe that gcc compiles with the following textfile (./a.exe < test.txt) he does not match the multiline comments correctly. *test.txt contains:
1
7399
by: Laser Lu | last post by:
Hi, all, I'm now writing a program to compress JavaScript code. One puzzle is how to write a regular expression to find out and remove all the redundent blank spaces. However, those blank spaces that are in the comments should be kept intact. I've tried to write some Regexs, and I list them here for your information: regex = new Regex(@"/\**?\*/"); // pattern used to match a multiline comment block regex = new Regex(@"//*\n"); //...
40
4622
by: Edward Elliott | last post by:
At the risk of flogging a dead horse, I'm wondering why Python doesn't have any multiline comments. One can abuse triple-quotes for that purpose, but that's obviously not what it's for and doesn't nest properly. ML has a very elegant system for nested comments with (* and *). Using an editor to throw #s in front of every line has limitations. Your editor has to support it and you have to know how to use that feature. Not exactly...
0
363
by: Ethan Furman | last post by:
Maric Michaud wrote: Actually, the OP said: -- So you're saying to ensure that stage_map's keys are initially -- lower-case to begin with? Well, I can't do this either since the -- *case of the keys is actually valuable* ***later on***. It's only for -- the purposes of this specific comparison operation that the case -- should be ignored. In other words, the key (as a key) is case-insensitive, and the key (as
11
6248
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as the app is concerned). The problem is, If someone makes a typo, they may get an unexpected error due accidentally calling the original attribute instead of the wrapped version. Does anyone have a simple solution for this?
0
8788
marktang
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...
0
8697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9290
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
9159
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
9001
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
7925
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...
0
5939
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
4454
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
4713
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.