473,574 Members | 17,716 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 3139
"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
10919
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...
1
7395
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...
40
4604
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...
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....
11
6235
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...
0
7820
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...
0
7738
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...
0
8258
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...
1
7835
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...
0
6486
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...
1
5635
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...
0
3759
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...
1
2255
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
1
1360
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.