Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > query regarding python script

Reply
Thread Tools

query regarding python script

 
 
Shubhra Gupta
Guest
Posts: n/a
 
      05-20-2004


> Hi,
>
> I have the following statement in one my python script :-
>
> assert not opt_initialize or os.path.exists(initdir), "initialize implies init directory"
>
> Could u tell please what it is intended to do?
>
> Regards,
> Shubhra Gupta


 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      05-20-2004
Shubhra Gupta wrote:

>>I have the following statement in one my python script :-
>>
>>assert not opt_initialize or os.path.exists(initdir), "initialize implies init directory"
>>
>>Could u tell please what it is intended to do?


Nobody but the author could say what it was *intended* to
do.

What it is actually doing, however, is terminating the program
if the opt_initialize flag is False or, in the case where it's
True, if there is a directory or file (!) with the path in 'initdir'.
If it does terminate the script, it will also show the string that
follows.

The lines shown will also not execute at all if the script is
run with the -O or -OO options.

Looks like it was not entirely well thought out...

-Peter
 
Reply With Quote
 
 
 
 
Russell Blau
Guest
Posts: n/a
 
      05-20-2004
"Shubhra Gupta" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> I have the following statement in one my python script :-
>
> assert not opt_initialize or os.path.exists(initdir), "initialize implies

init directory"
>
> Could u tell please what it is intended to do?
>
> Regards,
> Shubhra Gupta


See http://www.python.org/doc/current/ref/assert.html


--
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.



 
Reply With Quote
 
Diez B. Roggisch
Guest
Posts: n/a
 
      05-20-2004
Shubhra Gupta wrote:

>
>
>> Hi,
>>
>> I have the following statement in one my python script :-
>>
>> assert not opt_initialize or os.path.exists(initdir), "initialize implies
>> init directory"


As the or-operator is non-strict, the right side of it gets only evaluated
if the left is False. So the comment pretty much says it: If opt_initialize
is True, the not negates it and then the os.path.exists(initdir) is
executed - but orly then.
--
Regards,

Diez B. Roggisch
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fw: Query regarding Python sybase module srinivasan srinivas Python 0 03-25-2009 07:14 AM
Query regarding Python sybase module srinivasan srinivas Python 1 03-24-2009 06:44 AM
Query regarding support for IPv6 in python Pramod TK Python 3 04-27-2006 06:13 AM
executing a python script from another python script. sarmin kho Python 1 06-04-2004 01:12 PM
query regarding embeding python in C Vardhman Jain Python 1 04-08-2004 03:33 AM



Advertisments