The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Case sensitivity ads/disads?
Discuss Case sensitivity ads/disads? in the Python Programming forum on Dev Shed. Case sensitivity ads/disads? Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

March 6th, 2004, 04:18 PM
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Case sensitivity ads/disads?
Why would you design a programming language with case sensitvity in it's general syntax? (such as x and X being two different varibles) How does it help? What are its advantages?
(I'm not trying to bash python, I am just curious why this is a reaccuring theme with many programming languages)
|

March 6th, 2004, 04:32 PM
|
|
Contributing User
|
|
Join Date: Oct 2003
Location: Canada
Posts: 185
Time spent in forums: 20 h 44 m 48 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by ultimai Why would you design a programming language with case sensitvity in it's general syntax? (such as x and X being two different varibles) How does it help? What are its advantages?
(I'm not trying to bash python, I am just curious why this is a reaccuring theme with many programming languages) |
I don't think it is intended to be a nuissance, it simply is there to conform to the
ASCII character codes. Where 'x' is represented by the decimal value 120 and 'X' by the decimal value 88. As there are times when you want to use one or the other, it allows not only options in your coding style, but conforms to standards necessary for all computers to better communicate.
keep in mind that python still recognises both characters too. a x is still an x regardless of its ascii representation.
ex:
Code:
ltr = raw_input("enter ltr:").lower()
enter ltr: G
ltr
g
I hope that answers your question. let me know.
__________________
"In theory, there is no difference between theory and practice.
But, in practice, there is."
|

March 6th, 2004, 06:50 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
|
Where i don't know the technical reason why - i've never really questioned it but - I actually find it pretty useful.
Mainly because it allows for multiple objects with the same name - each with a different case - but it also seems logical that they are different... then, maybe thats because of we're used to it that way!?
Case is also useful for passing info about the object around i.e. Python naming conventions say that class names should be writen as 'className' so its easy to see when we're talking about a class or a function.
[QUOTE]Its one of those things that you will never know the answer to ... and will proberly drive you insane if you try/QUOTE]
Hope this helps,
Mark.
__________________
programming language development: www.netytan.com – Hula
|

March 6th, 2004, 07:00 PM
|
|
Contributing User
|
|
Join Date: Feb 2004
Location: London, England
|
|
|
caroundw5h, I think the original poster meant why are keywords, variable names, function names etc case sensitive.
I have used both languages that are not case sensitive (e.g. VB) and languages that are case sensitive (e.g. virtually everything else), and I think the main answer is that case sensitive languages are easier to read.
Consider this: you are looking at a program and you find a call to a function called "doStuff", so you scan through the listing looking for other references to this function. In a case sensitive language you know exactly what you are looking for. However in a case insensitive language it could be written as DoStuff, Dostuff, dostuff, DOSTUFF, dOsTuFf etc. Your brain has to do a hell of a lot more work just to find one function. Multiply that by all the variable, class and function names in the source code and simply reading the listing become a major chore.
When we read we pay more attention to the overall shape of the word than to the individual letters - this is why UPPER CASE IS HARDER TO READ than lower case and RAndOmLy MixEd-CaSE WOrDs aRe evEN HaRdeR. If you do not know what the shape of a word is going to be in advance then you are forced to read words letter by letter, which will reduce your reading speed.
Regards,
Dave - The Developers' Coach
Last edited by DevCoach : March 6th, 2004 at 07:04 PM.
|

March 6th, 2004, 07:29 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 217
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I would say it is for, like DevCoach said, consistency.
|

March 7th, 2004, 12:11 AM
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I personally find it annoying beacuse when you use third party libaries and such, the style tends to be different with each library, or changes ocassionally which can break your code and make you have to run things like pylint and do search and replaces through it.
|

March 7th, 2004, 05:22 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
Gotta agree with Ulti, and even in the stadard library i'm still waiting got Python to enforce its naming and or conventions.
But i haven no problem with case sensativity as a hole and anything i write follows Pythons style guide as much as possiable.
http://www.python.org/doc/essays/styleguide.html
Mark.
|

March 7th, 2004, 08:58 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 217
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by ultimai I personally find it annoying beacuse when you use third party libaries and such, the style tends to be different with each library, or changes ocassionally which can break your code and make you have to run things like pylint and do search and replaces through it. |
I was thinking the same thing when I started to used the Queue module. It starts with a capital, which it unusual.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|