Thread: no spaces

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

    Join Date
    Mar 2003
    Posts
    81
    Rep Power
    12

    no spaces


    How do I force the print not to print spaces?
    $ 12343 $
    is printed from this line
    print "$",self.tok,"$"

    but what I want is
    $12343$
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Using a formatted string:

    print "$%s$"%self.tok


    See Python docs for more info - Python Library Reference Section 2.3.6.2

    Grim
    Last edited by Grim Archon; April 10th, 2004 at 03:47 PM.
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    You can also use the + operator to concatenate the variable in the middle, without the spaces i.e. print '$' + self.tok + '$'. This does however require self.tok to be a string. if it isnt then you will need to type cast the variable using the built-in str() function.

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


IMN logo majestic logo threadwatch logo seochat tools logo