#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2005
    Posts
    27
    Rep Power
    0

    Why no dollar sign variables?


    how come variables in python, you dont put $ in front of them, I miss that from php
  2. #2
  3. (retired)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2003
    Location
    The Laboratory
    Posts
    10,101
    Rep Power
    0
    why should they have them? it's just an extra character to type.

    --Simon
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2005
    Posts
    27
    Rep Power
    0
    easier to read the code
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Hey,

    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 .

    Take care,

    Mark.
    programming language development: www.netytan.com Hula

  8. #5
  9. (retired)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2003
    Location
    The Laboratory
    Posts
    10,101
    Rep Power
    0
    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.


    --Simon
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Location
    Finland
    Posts
    260
    Rep Power
    21
    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.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2006
    Location
    Knoxville, TN
    Posts
    16
    Rep Power
    0
    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.
    Peace
  14. #8
  15. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Originally Posted by AntiGravity
    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.
    Peace
    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:

    Code:
    aString = "Some string."
    aString = aString.something1()
    aString = aString.something2()
    aString = aString.something3()
    aString = aString.something4()
    ...
    Yet in imperative programming I come across this type of thing every day to some degree. Just one thing I dislike sorry .

    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.

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo