Jump to content

fizzlesticks

Member
  • Posts

    1,196
  • Joined

Everything posted by fizzlesticks

  1. Ha, quotes? 1 2 3 4 5 6 7 8 9 10 compiled with g++. Whos language is bloated now?
  2. I reject your languages and substitute best language. print((lambda s: f"{' '.join(s[:-2])} {s[-2:]}")(__import__('pytesseract').image_to_string(__import__('PIL').Image.open(__import__('io').BytesIO(__import__('requests').get('https://linustechtips.com/main/uploads/monthly_2017_08/1to10.png.e49e4e83ff2a738a8fc08eddde33e9dc.png').content)))))
  3. You can read more about the different options here https://docs.python.org/3.6/library/functions.html#open It sounds like you're looking for r+ or r+b.
  4. That fixes the problem because imap_unordered is probably running a lot slower than normal map, not sure I'd call that a real solution. I tried a bunch of stuff and just can't reproduce the problem you're having so I have no idea what a real solution would be. Edit: Also if you're doing what I suggested with returning true/false depending on whether the proxy works or not, using unordered won't work because the values in the return list won't match up with the correct elements in the proxy list.
  5. In the tqdm call try setting the parameter mininterval=0 If that doesn't help I'm not sure what's wrong.
  6. Try running it in a command line if you're not already. And increase the size of the 'r' list to make sure it's actually running long enough to see anything happen.
  7. total=len(r) is part of the tqdm call. The 'i' in the loop is the return value from one of the function calls, not a counter. You'll need to add 'i' to some list then get the length of that list. And remember that printing is horribly slow, so doing it like that is going to significantly slow down the program.
  8. Sure is. Using tqdm for the progress bar would be like this from multiprocessing import Pool from itertools import compress import tqdm def f(s): return s % 2 == 0 if __name__ == '__main__': r = list(range(100000)) print(r) with Pool(5) as p: ret = [] for i in tqdm.tqdm(p.map(f, r), total=len(r)): ret.append(i) print(ret) r = list(compress(r, ret)) print(r) If you don't want to use tqdm, just get rid of those and loop over the p.map directly then update your progress somehow by the length of ret.
  9. It keeps the items that have a true value in the second list. Essentially it looks something like def compress(values, flags): new_list = [] for i in range(len(values)): if flages[i]: new_list.append(values[i]) return new_list
  10. Compress takes 2 lists the first is the one you want to remove items from and the second is a list of flags. If the element in list 2 evaluates to true the corresponding element is kept in list 1, if it's false it is removed. It returns a generator like most functions in Py3 so you need to convert to a list to actually get the values. Pools use resources, after you're done with them they need to be closed by calling pool.close(). Using with is the best way to make sure it gets done.
  11. Pool.map returns a list of all the return values from the function. So for example, to remove all the odd numbers in a list you can do: from multiprocessing import Pool from itertools import compress def f(s): return s % 2 == 0 if __name__ == '__main__': r = [1,2,3,4,5,6] print(r) with Pool(5) as p: ret = p.map(f, r) print(ret) r = list(compress(r, ret)) print(r)
  12. When you use Multiprocessing.Pool each process get it's own copy of the data. You're altering that copy not the original in the main process. From your proxyCheck function you can return a bool saying whether or not that proxy worked then at the end use that list of bools to filter the proxy list.
  13. It looks like the code you're using as an example is written for Python 2 and you're using Python 3. In Py2 struct.unpack worked on strings and in Py3 it uses bytes. Unfortunately it's one of those annoyances for converting between versions.
  14. The email you're passing is a bytes object, not a string. In the line b += '\0' * (4 - len(b) % 4) you're trying to concatenate a string onto that bytes object, which you can't do, hence the error. The fix is to change the string to a bytes by using the 'b' prefix. b += b'\0' * (4 - len(b) % 4)
  15. The print function accepts numbers fine.
  16. You're trying to copy/paste a script into an interactive shell. You need to go to File > New File, then put the code in there, save it, then run it.
  17. The window inside VS is for debug output. You can write to it using OutputDebugString. However like the name says that's only for debug stuff, don't use it for normal input/output. For simple programs you can run your program without debugging using ctrl + f5 or the option in the menu which keeps the console window open after the program finishes. If you need the debugger you can set a breakpoint at the last line of the program.
  18. Please use code tags, fix your text colors (it's currently unreadable on night theme) and a link to the problem you're trying to solve would be helpful.
  19. You need to enable the multiline and global modes. I've never used PHP regex so can't really help with how to do that.
  20. ^([A-Za-z0-9]+)\s+([0-9]+)\s+[0-9]+\s+([0-9]+)\s+\/\1$ ^ //match start of line ([A-Za-z0-9]+) //first word \s+ //space between first and second word ([0-9]+) //second word \s+ //space between second and third word [0-9]+ //non-captured third word \s+ //space between third and forth word ([0-9]+) //forth word \s+ //space between forth and fifth word \/ // '/' character \1 //matches the first match in the string $ //end of line
  21. That would probably just delete all the unicode characters not convert them to ascii. But depending on what you're doing that may work fine.
  22. That would work but if there are unicode quotes there are probably unicode other things and you'll have to go through the entire thing to find them all.
×