Python 3 range Vs Python 2 range

Python 3 uses iterators for a lot of things where python 2 used lists.The docs give a detailed explanation including the change to range. The advantage is that Python 3 doesn’t need to allocate the memory if you’re using a large range iterator or mapping. For example for i in range(1000000000): print(i) requires a lot … Read more

Copy a selected range to another worksheet

Here is good examples on How to avoid using Select in Excel VBA Link stackoverflow Here is simples of copy/paste – values = values – PasteSpecial method Option Explicit ‘// values between cell’s Sub PasteValues() Dim Rng1 As Range Dim Rng2 As Range Set Rng1 = Range(“A1”) Set Rng2 = Range(“A2”) Rng2.Value = Rng1.Value ‘or … Read more

range over character in python

This is a great use for a custom generator: Python 2: def char_range(c1, c2): “””Generates the characters from `c1` to `c2`, inclusive.””” for c in xrange(ord(c1), ord(c2)+1): yield chr(c) then: for c in char_range(‘a’, ‘z’): print c Python 3: def char_range(c1, c2): “””Generates the characters from `c1` to `c2`, inclusive.””” for c in range(ord(c1), ord(c2)+1): … Read more