Print statements unique to each thread

85go

New member
#1
I'm wondering if I can print some stuff that is unique to each thread, so like a number in each print statement to tell which thread it is coming form. Here is my thread implementation:
Code:
import requests
import time
import threading
import json
from classes.logger import Logger
from classes.cart import Cart
from classes.captcha import Captcha
from classes.queue import Queue
from classes.tools import Tools



if __name__ == '__main__':
    session = requests.Session()
    lock = threading.Lock()
    tools = Tools()
    config = tools.load('config/config.json')
    log = Logger().log
    q = Queue()
    cart = Cart(session, lock)

    api_key = config['key']['2captcha']
    captcha = Captcha(api_key)
    queue = Queue()

    # Small, Medium, Large, one size
    t1 = threading.Thread(target=cart.add_to_cart, args=(['carabiner','palace','silver'],'one size'))
    t2 = threading.Thread(target=cart.add_to_cart, args=(['t-shirt','palace','bong'],'small'))
    t1.start()
    t2.start()
    t1.join()
    t2.join()

    cart.check_cart()

add_to_cart method:
Code:
class Cart:

    def add_to_cart(self,keywords,size):
        print("blah blah blah")

Would it be possible to print something like:
Code:
"1 - blah blah blah"
"2 - blah blah blah"