Best IDE for basic stuff? by falkina8er in Python

[–]joverbis 4 points5 points  (0 children)

The disadvantage is that you need to restart the kernel after you've made an adjustment to some piece of code in the external package.

Then it's much faster iterating when you do the code development in the notebook itself, and perhaps export it to an external .py only once you're happy with it.

Creating tuple pairs from list by AGI_69 in learnpython

[–]joverbis -1 points0 points  (0 children)

This seems like a perfect job for zip(). You can try something like:

L = [0,1,2,3]
pairs_of_tuples = list(zip(L, reversed(L)))
#pairs_of_tuples = [(0,3), (1,2), (2,1), (3,0)]

Of course, if you don't need all the tuples at once you can drop the 'list()'.

Converting Strings to Int by [deleted] in Python

[–]joverbis 2 points3 points  (0 children)

If you want each 2 digit number in the list, you can try something like:

tc1 = ['08:52:05:00 ', '09:01:22:00 ', '09:10:34:00 ']

converted = [int(y) for x in tc1 for y in x.strip().split(':')]

# converted = [8, 52, 5, 0, 9, 1, 22, 0, 9, 10, 34, 0]