python -- callable iterator size? -


I'm looking at some text file for a certain string with the method.

Again. Illustrator (pattern, text) I like to know that when it does not give anything, which means that it can not get anything in the passed text .

I know that callable iterators, next and __ iter __

I would like to know whether I received the shape Or it can detect that it does not match my pattern.

itemprop = "text">

edit 3: @Hynesaker's answer is much better than this is.

Edit 2: If you have an infinite internet, or a lot of gigabytes (2010 gigabytes of RAM / disk space still in one Consumes large amounts), then it will not work RAM / disk space

You have already seen a good answer, but here is an expensive hack that you can use if you can eat a cake and get it too :) The trick is that We have to clone the cake, and when you eat, we put it back in the same box. Remember, when you get iterated on the itater, it usually gets empty, or at least lost the returned value earlier.

  & gt; & Gt; & Gt; Def getIterLength (iterator): floating = list (iterator) result = lane (temporary) iterator = eater (temporary) returns results >> gt; & Gt; & Gt; & Gt; & Gt; F = xrange (20)> gt; & Gt; & Gt; F xrange (20) & gt; & Gt; & Gt; & Gt; & Gt; & Gt; X = getIterLength (f)> and gt; & Gt; & Gt; X20> gt; & Gt; & Gt; F xrange (20) & gt; & Gt; & Gt; Edit:   Here's a safer version, but using it requires some discipline. It does not seem quite pithy. If you have posted the entire relevant code sample which you are trying to apply then you will get the best solution.  
  & gt; & Gt; & Gt; Def getIterLenAndIter (iterator): floating = list (itater) return lane (temporary), etter (temporary) & gt; & Gt; & Gt; F = iter ([1,2,3,7,8,9]) gt; & Gt; & Gt; F & lt; 0x02782890 Lipicator object & gt; & Gt; & Gt; & Gt; L, F = getIterLenAndIter (F)> and gt; & Gt; & Gt; & Gt; & Gt; & Gt; L6 & gt; & Gt; & Gt; F & lt; 0x02782610 Listener Object & gt; & Gt; & Gt; & Gt;  

Comments

Post a Comment

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -