on-internet

IndexError: list index out of range when looping through a list in Python

I am learning Python and trying to print every item in a list using a for loop with range(). However, my program stops with an IndexError. Here is my code: numbers = [10, 20, 30, 40] for i in range(len(numbers) + 1): print(numbers[i]) When I run it, the first four values are printed, then I get this error: Traceback (most recent call last): File "main.py", line 4, in <module> print(numbers[i]) IndexError: list index out of range What I expected: the program prints all four numbers (10, 20, 30, 40) and then finishes without errors. What I tried: I changed the list values and restarted the progr

Join the discussion →

Where should the cookie-setting logic live, in the controller or the service layer, when it depends on configuration?

I used to set a cookie directly in the controller, deriving its value from the incoming request. I've changed it so the value now comes from a configuration property instead. In our architecture, configuration is supposed to be loaded in the service layer. Does that mean the cookie-setting logic should move into the service layer, with the controller only attaching the result to the response? Or can the controller keep setting the cookie and just call the service to get the configured value?

Join the discussion →

How to set a default value for FastAPI's Header?

I have a simple localised GET endpoint: @router.get("/codes", description="Get a list of codes data matching a query and locale") def get_codes_data( query: str = Query(default="", description="Search query"), accept_language: str = Header(default="de") ) -> CodesResponse: I would expect `Accept-Language` to be equal to `de` if I did not set a value. However, when a value is not provided, the value of `accept_language` is as follows: en-GB,en-US;q=0.9,en;q=0.8 When a value is provided, everything works as expected. I found a few issues on fastAPI's GitHub Issues that makes me think this is eit

Join the discussion →

select Faces/Vertices inside polyline area

When using the tool: select Faces/Vertices inside polyline area (what I often use) it selects thru the object. I really would like the option to 'Hold a button' to ONLY select the 'visible area' of the mesh. Can this be implemented? Greetings, Sten

Join the discussion →

TCP Sequence Number Generation: Minimum Permissible Rate with ToD Clock and 64-Second MSL

While opening a TCP connection, the initial sequence number is to be derived using a time-of-day (ToD) clock that keeps running even when the host is down. The low-order 32 bits of the counter of the ToD clock are to be used for the initial sequence numbers. The clock counter increments once per millisecond. The maximum packet lifetime is given to be 64 seconds. Which one of the choices given below is closest to the minimum permissible rate at which sequence numbers used for packets of a connection can increase? A. 0.015/s B. 0.064/s C. 0.135/s D. 0.327/s This is a question from GATE 2009 CSE

Join the discussion →

How to reduce my token consumption of my ai agent developed using n8n workflow?

I am building a workflow with a long process. I separate each stage to switch the ai agent system message. but it still consuming around 20k token for each call. I am currently using gemini-3.1 flash lite LLM with free. How can i reduce my token usage? In addition also, I use all stage system message are static but they are missing the prompt cache.. How can I get the prompt cache? I can't also able to reduce the reasoning the option not available on this Gemini LLM.

Join the discussion →

Tk window geometry functions are returning the wrong values on Linux (KDE Plasma)

An application I contribute to, which uses Tk for its UI, has subpanes which follow the main window around. While attempting to add proper Linux support I found that the subpanes jump downwards and slightly to the right whenever the program moves them (due to following the main window, resizing widgets, etc.) After some experimentation I determined that every function for getting window geometry seems to return the top-left corner inside the window border, while setting the geometry places it according to the outside of the window border. (The Tk docs by comparison say that both should be usin

Join the discussion →

Tk toplevel window returns wrong position on Linux (KDE Plasma)

An application I contribute to, which uses Tk for its UI, has subpanes which follow the main window around. This worked perfectly fine on Windows, but on my Linux system (which runs a KDE Plasma Wayland session), the subpanes jump downwards and slightly to the right whenever the program moves them (due to following the main window, resizing widgets, etc.) After some experimentation I determined that every function for getting window geometry seems to return the top-left corner inside the window border, while setting the geometry places it according to the outside of the window border. (The Tk

Join the discussion →

Scientists Used Seabirds To Track Hidden Ships

Scientists equipped seabirds with audio recorders and GPS trackers to detect fishing vessels that were not broadcasting their locations through the Automatic Identification System (AIS), according to a new study published in Science Advances. They found that unseen vessels accounted for about 32% of vessel-related audio detections in the North Atlantic and 12% in the Mediterranean. "The one petrel in the study interacted with vessels in the South Pacific, but its geolocation device was damaged, so it was not possible to calculate how many ships it encountered had their trackers off," adds 404

Join the discussion →
Older stories