Movatterモバイル変換


[0]ホーム

URL:


do...until wisdom needed...

Ixokainews at myNOSPAM.org
Mon Apr 16 01:18:23 EDT 2001


The standard Python Idiom (tm of someone, I'm sure :)) for a do-whileconstruct is:while 1:    statements    if condition:        breakIts in-elegant, and even ugly, IMHO. I think there's a reason that there isno do-while construct, otherwise I can't fathom why they wouldn't have putit in yet.. this is something that comes up frequently.--Stephen(replace 'NOSPAM' with 'myseraph' to respond in email)"Ken Peek" <Peek at LVCM.comNOSPAM> wrote in messagenews:tdku4kqlqjquf2 at corp.supernews.com...> Sometimes, when writing code, I find it would be nice if there were a> "do...until" construct in Python.  This would be preferable to using a"while"> construct if you wanted to make sure the loop will execute at least once.You> CAN do this with a "while" construct, but it requires fiddling with theloop> condition before the "while" construct, which is "messy".  An example:>> condition = TRUE   # make sure loop runs at least once> while (condition):>     # do some stuff>     # do some more stuff>     condition = whatever_stops_the _loop>> Here is my question--  If Python WERE to have a "do...until" construct,what> would be the best way to implement the syntactical rules?>> For example:>> do:>     # some stuff>     # some more stuff>     until (condition == TRUE)   # ("until" must be last statement or thereis an> error)>> OR:>> do:>     # some stuff>     # some more stuff> until (condition == TRUE)>> OR: ???>>>-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----http://www.newsfeeds.com - The #1 Newsgroup Service in the World!-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp