August 28th, 2006, 02:52 PM
Why no dollar sign variables?
how come variables in python, you dont put $ in front of them, I miss that from php
August 28th, 2006, 05:38 PM
why should they have them? it's just an extra character to type.
August 28th, 2006, 05:57 PM
August 28th, 2006, 06:06 PM
The main argument against them is simply that they increase the amount of noise, they may make it easy to see a variable for simple cases but when you have a lot of them in a small space you may find it becomes harder, and rather ugly.
Think of what would happen if you forget to add $ to a variable? When you're doing it a lot there is a tendency to just miss it. Of course this is the same argument used against using ; to end statements.
On the flip side it can be said that DSLs (Domain Specific Languages) are easier to express without such symbols cluttering up the mix.
Python already has enough line noise as it is even if Python users don't see it, so we don't want to add anymore .
Scuzzo, please try to refrain from one liners if you can .
August 28th, 2006, 06:11 PM
Really? I find they just get in the way ( & yes - I do use PHP ).
Perl goes two better and has a scalar array marker @ ( e.g. @arr = ( x, y, z ); ), and a hash marker % ( e.g. %arr = (0, x, 1, y, 2, z) ). Nice idea, but it doesn't help readability at all - it's usually pretty obvious what is a variable and what is a language token.
August 29th, 2006, 06:54 AM
Because in every language you create variables in different ways.. In Python it's simply just "myvar = 10", PHP "$myvar = 10;", C++ "int myvar = 10;". And I agree with netytan.
September 10th, 2006, 07:40 PM
I like Python better the way it is. Were working in BASIC in my software design class and I really dislike using n$ or whatever for string variables. It gets really messy and confusing when weve got like 10 different variables we need to use and some are integers and some are strings and whatever. It gets crazy, python makes me much happier.
September 15th, 2006, 09:01 PM
We could try an alternative and not use variables at all; or at least depreciate them . I think there's no worse way of violating the DRY principle than writing things like this:
Originally Posted by AntiGravity
Yet in imperative programming I come across this type of thing every day to some degree. Just one thing I dislike sorry .
aString = "Some string."
aString = aString.something1()
aString = aString.something2()
aString = aString.something3()
aString = aString.something4()
It may be a confusing idea that you can write programs without doing this kind of thing but I do it every day and I'm very pleased with the results.
It is possible to do this in Python but it's really not worth the headache right now. Python 3k should make this a little easier though so we'll have to see.