Learing Python, Newbie question

Johannes Gamperl info at devshare.de
Thu Oct 25 06:58:37 EDT 2001


In article <Xns9145768DC9835michaelrcpcouk at 194.238.50.13>, 
michael at rcp.co.uk says...
> Johannes Gamperl <info at devshare.de> wrote in 
> news:MPG.1642065dc9ef9d80989687 at news.t-online.de:
> 
> > Do you know if there is a 
> > coditional operator in python ( ?: )
> > 
> > e.g.
> > 
> > if os.path.exists("gbook.txt"):
> >   db_first = 0;
> > else:
> >   db_first = 1;
> > 
> > 
> > db_first = ( os.path.exists("gbook.txt") ) ? 0:1;
> 
> Ho ho!
> 
> I'm glad that beginners also miss the conditional operator.
> 
> I'm afraid there's been a bit of an argument about possible syntax, and 
> most of the old hands seem firmly convinced that the conditional operator 
> serves no useful purpose.
> 
> No, it doesn't exist!
> 
> 
> Mind you, in the example you give, there's no point at all in having a 
> conditional operator, since what you *really* wanted to write is:
> 
>     	db_first = not os.path.exists("gbook.txt")

hello Michael,

the e.g. doesn't make sin :) .. but i want to describe for what i'm 
looking for. i came from perl and i find the conditional operator very 
usefull ..

oki ... my journey to python goes on ;)

Hannes



More information about the Python-list mailing list