[IronPython] Using blocks separators instead of indentation

Thane Plummer thane at tkpcorp.com
Mon Aug 13 23:45:44 CEST 2007


Ori, In my previous post I forgot to join the line with a semi-colon.

The following is a legal -- albeit "unpythonic" -- single line that meets
your requirement:

>>> mycommand = "i = 1\nif i >= 1:\n\tprint 'Test passed'\nelse:\n\tprint
'test failed'"; exec(mycommand)
Test passed
>>>

May the Python gods have mercy!

--Thane

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Ori
Sent: Monday, August 13, 2007 5:23 PM
To: users at lists.ironpython.com
Subject: Re: [IronPython] Using blocks separators instead of indentation


Thanks but I did not ask if it is ugly or not. I just need it.
Is there a way to do it?


Curt Hagenlocher wrote:
> 
> On 8/13/07, Ori <oorrii at gmail.com> wrote:
>>
>>
>> OK I got the point. I have to use several statements in a single line.
>>
>> For exmpale, something like:
>> i = 1; if (i >=1): i = 0
>>
>> is there a way to do it? Is there a replacement to the newline char?
> 
> 
> This is legal Python:
> 
> a = 1; b = 2
> if a != b: print 'different'
> 
> I don't know *why* someone would want to write code like this unless
> they've
> been programming for such a short time that they've never had to go back
> and
> change something that they wrote over a year ago.  I find this style
> unreadable.
> 
> --
> Curt Hagenlocher
> curt at hagenlocher.org
> 
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> 
> 

-- 
View this message in context:
http://www.nabble.com/Using-blocks-separators-instead-of-indentation-tf42594
31.html#a12134397
Sent from the IronPython mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.15/949 - Release Date: 8/12/2007
11:03 AM
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.15/949 - Release Date: 8/12/2007
11:03 AM
 




More information about the Ironpython-users mailing list