Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 14th, 2012, 06:47 AM
psykosonik84 psykosonik84 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 9 psykosonik84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 3 sec
Reputation Power: 0
Infinite loop with WHILE

Hi,

I am posting a snippet of my code:
XsdModelList = self.Api.XsdModelList
while(len(XsdModelList)>0):
print XsdModelList.pop().getFileName()
print len(XsdModelList)


self.Api.XsdModelList is a list; when I run my code I am getting stuck in an infinite loop. can someone help what i am doing wrong?

Thanx

Reply With Quote
  #2  
Old August 14th, 2012, 07:43 AM
Quackajack Quackajack is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 35 Quackajack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 55 m 6 sec
Reputation Power: 1
Could you not use a for loop instead

Code:
for item in XsdModelList:
    print item.getFileName()

Reply With Quote
  #3  
Old August 14th, 2012, 09:08 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,350 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 7 h 37 m 52 sec
Reputation Power: 383
It's possible that the XsdModelList object has an unusual definition of its __len__ method.
Code:
class dumbList(list):
    def __len__(self): return 18
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #4  
Old August 15th, 2012, 06:28 PM
psykosonik84 psykosonik84 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 9 psykosonik84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 3 sec
Reputation Power: 0
Hmm, I used some print statements to see whats happening, the len() function counts down like it should and then stops at 0, but strangely the loop does not exit

Reply With Quote
  #5  
Old August 15th, 2012, 06:30 PM
psykosonik84 psykosonik84 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 9 psykosonik84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 3 sec
Reputation Power: 0
Quote:
Originally Posted by Quackajack
Could you not use a for loop instead

Code:
for item in XsdModelList:
    print item.getFileName()


Yup, thats the way I am using it right now, its just unusual that the loop didn't work the way I thought it should.

Reply With Quote
  #6  
Old September 3rd, 2012, 05:51 PM
Max00355 Max00355 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 3 Max00355 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 49 sec
Reputation Power: 0
You don't use a while loop for something like this


Code:
a = [1,2,3]
for x in a:
  print x

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Infinite loop with WHILE

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap