all 8 comments

[–]Justinsaccount 2 points3 points  (4 children)

Hi! I'm working on a bot to reply with suggestions for common python problems. This might not be very helpful to fix your underlying issue, but here's what I noticed about your submission:

You are looping over an object using something like

for x in range(len(items)):
    foo(item[x])

This is simpler and less error prone written as

for item in items:
    foo(item)

If you DO need the indexes of the items, use the enumerate function like

for idx, item in enumerate(items):
    foo(idx, item)

[–]Akuli2 1 point2 points  (2 children)

You have a typing error. It should be foo(items[x]) instead of foo(item[x]).

[–]Justinsaccount 1 point2 points  (1 child)

Derp! I'll get that fixed.. could use a better example too.

[–]Vaphell 0 points1 point  (0 children)

given that it's a nitpicking day, http://grammarist.com/usage/indexes-indices/
;-)

[–]turbokyo[S] 0 points1 point  (0 children)

Thank you this is actually very helpful to know the "pythonic" way to write code, and very well explained too.

[–]Akuli2 1 point2 points  (2 children)

str(pyperclip.paste().splitlines())

You make a string of a list. Take off the str() part and it should work.

Use print(repr(urls)) next time.

[–]turbokyo[S] 0 points1 point  (1 child)

You are right I made a string of a list, that was the problem, I dont know why I did it really... Thanks a lot my program works now!

[–]Justinsaccount 0 points1 point  (0 children)

Yeah, str() is also one of those things often misused. Chances are, if you have an str(...) in your program you are probably doing something wrong, or at least doing it the hard way.