Is there a generator version of `string.split()` in Python?

It is highly probable that re.finditer uses fairly minimal memory overhead. def split_iter(string): return (x.group(0) for x in re.finditer(r”[A-Za-z’]+”, string)) Demo: >>> list( split_iter(“A programmer’s RegEx test.”) ) [‘A’, “programmer’s”, ‘RegEx’, ‘test’] edit: I have just confirmed that this takes constant memory in python 3.2.1, assuming my testing methodology was correct. I created a string … Read more

Can iterators be reset in Python?

I see many answers suggesting itertools.tee, but that’s ignoring one crucial warning in the docs for it: This itertool may require significant auxiliary storage (depending on how much temporary data needs to be stored). In general, if one iterator uses most or all of the data before another iterator starts, it is faster to use … Read more

Any tools to generate an XSD schema from an XML instance document? [closed]

the Microsoft XSD inference tool is a good, free solution. Many XML editing tools, such as XmlSpy (mentioned by @Garth Gilmour) or OxygenXML Editor also have that feature. They’re rather expensive, though. BizTalk Server also has an XSD inferring tool as well. edit: I just discovered the .net XmlSchemaInference class, so if you’re using .net … Read more

Coroutine vs Continuation vs Generator

I’ll start with generators, seeing as they’re the simplest case. As @zvolkov mentioned, they’re functions/objects that can be repeatedly called without returning, but when called will return (yield) a value and then suspend their execution. When they’re called again, they will start up from where they last suspended execution and do their thing again. A … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)