Re: Again: Please hear my plea: print without softspace

From: rzed (rzantow_at_ntelos.net)
Date: 03/02/04


Date: Tue, 02 Mar 2004 04:50:10 GMT

Josiah Carlson <jcarlson@nospam.uci.edu> wrote in
news:c209n0$cit$1@news.service.uci.edu:

>> I've wondered, though, whether there couldn't be a different
>> character instead of a ',' to alter the behavior of print.
>> Maybe a trailing '+' to indicate that what follows is to
>> concatenate directly.
>>
>> And yet I've been able to work around that little annoyance;
>> it's not that there is no way to format output the way you
>> want.
>
>
> It seems that you are saying:
>
> print "hello ", "world" + #-> "hello world"
>
> That looks like "magic syntax", and should rightfully return a
> syntax error, because + already has a meaning for most all data
> types in Python. Changing the behavior of print when a syntax
> error is present, is the wrong thing to do.
>
> The right thing to do (if it were to happen at all) is to make
> fileobject.softspace "sticky" under some condition, perhaps
> after a call to fileobject.SetSoftSpace(False) (which doesn't
> currently exist).
>

I'm not sure I agree with this entirely. The comma following a
print statement is a sort of magic syntax as it is; it changes the
behavior of the unadorned print statement in a way that has very
little to do with any syntactical meaning a comma would normally
have. The idle thought I mentioned above would just use a different
symbol to alter the behavior of print in a slightly different
fashion. What I actually had in mind, adapting your example, was
something a little different:
print "hello" +
print "nwheels" #-> "hellonwheels"

If a '+' is problematic, it could be some other character. If I use
a print statement in a Python program, from my viewpoint, a
trailing comma signals suppression of newline and adding a space.
In this scenario, a trailing <insert acceptable character here>
would suppress the newline but not add a space. There's not much
difference there.

Having said all that, I'll add that I don't see this as a big
issue, and I don't find it a burden to use an alternative syntax to
achieve the same effect. I don't know how to tell if it's a right
or wrong thing to do. If it were a feature of the language, I'd
probably use it. I've never really understood what it is about the
print statement that bothers some people; it's always seemed
reasonably useful and reasonably intuitive to me. Maybe every
language is destined to have irregular verbs.
 

-- 
rzed


Relevant Pages

  • text editor component (seeking design advice)
    ... TEXT FOLDING ... i do not know how to store the character data. ... i'll have to parse even the folded text - for syntax highlighting ...
    (alt.comp.lang.borland-delphi)
  • Re: The fallacy of strengthened liars paradox.
    ... have the same syntax. ... However, in English, the same expression, character ... no real difference. ... What does it mean to me to have contradictory ...
    (sci.logic)
  • Re: Triggers, truncate field, how to
    ... The lenfunction is the correct function to find the length of a character ... But I am wondering why you would want to truncate the column to only ... know where to find the wright syntax code for it. ... trigger to do logically. ...
    (microsoft.public.sqlserver.server)
  • Re: Skill caps
    ... be expected to alter their character builds if the skill cap were removed. ... I do think it would change some character builds. ... Oh I fully expect some builds to change if the skill cap was removed. ... Some paladins get to use various magical devices with low to no chance ...
    (rec.games.frp.dnd)
  • Nochmal utf8
    ... zu wenig Zeichen besitzt. ... `utf` LONGTEXT CHARACTER SET utf8 NOT NULL, ... Was ist an zweiter Syntax falsch? ...
    (de.comp.datenbanken.mysql)