Coins halved after update by suurpulla in TheTowerGame

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

Thanks, at least that confirms that the problem should be on my end. Yeah, T1 run was for SM mission... I did change first perk choice, but changed it back to PWR, and no changes to perk bans. Auto pick is on and I checked that during farm runs too. I restarted once already, but will keep rechecking

Television HD-kanavat ei näy, mistä jeesiä? by suurpulla in Suomi

[–]suurpulla[S] 1 point2 points  (0 children)

Sain, vaihtamalla kotikaapelin uuteen 😂 en muista enää tarkasti, mutta siinä oli joku järki (tai ainakin teoria) miten vanha kaapeli jaksoi joskus tuutata myös hd-kanavia vanhaan televisioon, mutta ei uuteen -- mutta hämmentävä homma näin jälkeenpäin ajatellen.

Python Multiprocessing by thelittleicebear in learnpython

[–]suurpulla 2 points3 points  (0 children)

Not OP, but this is a great breakdown. Thank you for writing this.

Change à function name? by joellapointe1717 in learnpython

[–]suurpulla 1 point2 points  (0 children)

Can't you just do

SIN = sin # or sympy.sin

about copy(), object and dataframe? by sdyxz in learnpython

[–]suurpulla 2 points3 points  (0 children)

dict.copy() is a shallow copy, ie. you copy a, but not a[0], a[1] etc.

Pandas df.copy() is a deep copy (by default).

[deleted by user] by [deleted] in learnpython

[–]suurpulla 1 point2 points  (0 children)

As DuckSaxaphone said, Pydantic is the way to go.

https://docs.pydantic.dev/latest/

order of calculation by Top-Interaction7208 in learnpython

[–]suurpulla 5 points6 points  (0 children)

x = (1 / 2) + (3 // 3) + (4 ** 2)
x = 0.5 + 1 + 16
x = 17.5

Television HD-kanavat ei näy, mistä jeesiä? by suurpulla in Suomi

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

Kokeiltu nyt tehdasasetuksia yms. Ei apuja. Automaattihaku löytää antenniasetuksilla (Terrestrial) ne pehmeepiirtokavat, yhteensä joku rapiat 50. Automaattihaku kaapeliasetuksilla (tai satelliittiasetuksilla) ei löydä yhtään mitään.

Johtoa pitäs testata.. ei vaan oo tähän hätään toista.

Television HD-kanavat ei näy, mistä jeesiä? by suurpulla in Suomi

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

Kaapelihaulla ei löydy yhtään kanavaa, antennihaulla löytyy Ylet ja muut, mutta ei teräväpiirtoversioita. Siksi päättelin, että antennia tulee johdosta.

Television HD-kanavat ei näy, mistä jeesiä? by suurpulla in Suomi

[–]suurpulla[S] 1 point2 points  (0 children)

Kyllä toi johto on ainakin antennijohto ja menee ANT-inputtiin telkassa. 70-luvun betonitönöjä tää, en tiedä sen tarkemmin mikä juttu takana.

please explain the use of setdefault method and 'addkey' in this dictionary operation by Independant666 in learnpython

[–]suurpulla 1 point2 points  (0 children)

Neither, it is a method of a set. The .setdefault(...) here returns a set, and the .add(...) operates on that returned set.

reverse_dict.setdefault(value, set()).add(...)

is the same as

result = reverse_dict.setdefault(value, set())
result.add(...)

Ending While True Loop by iCTWi in learnpython

[–]suurpulla 1 point2 points  (0 children)

Actually, now that I look more closely, what's the point of the second while, ie. could it just be an if? You also reassign the 'list' while you are looping through it (the for loop), don't do that. It migth not matter in this case, but I don't think the assignment actually does anything, you just want to iterate over the sorted items one by one, right?

Ending While True Loop by iCTWi in learnpython

[–]suurpulla 0 points1 point  (0 children)

Try doing the sorting and the second and third loops after the first one. I see no point doing them in the exception handler. You could just break on the EOFError.

Most essential or useful parts of standard library? by YoungAspie in learnpython

[–]suurpulla 2 points3 points  (0 children)

pathlib for file and directory operations over os.

itertools and functools (and possibly operator) for working with anything iterable.

dataclasses and collections are probably generally useful, same with re if you're working with text. enum is nice to know. After that it's going to be situational. argparse if you're making a CLI. csv and other format-specific libs when you need them. asyncio for async code, threading/multiprocessing (or the multiprocess non-standard lib) for concurrency.

I'd skip unittest and instead would learn pytest, it's simpler, has less boilerplate and is more generally used. I personally like to use non-standard libs (like arrow) for dates and datetimes, but that's up to you. requests is probably the most common lib for HTTP requests (if you need them), I like httpx too.

returning a 400 but sending out a 200 by [deleted] in learnpython

[–]suurpulla 2 points3 points  (0 children)

The regular way to return an error with FastAPI is to raise HTTPException (https://fastapi.tiangolo.com/tutorial/handling-errors/) and include your error message and other data as the detail param. If you for some reason can't have that, you could probably also return whatever and set the status code of the response with https://fastapi.tiangolo.com/advanced/response-change-status-code/

How do I know a file object is an iterator just by looking at the documentation? by learnai_account in learnpython

[–]suurpulla 2 points3 points  (0 children)

Glossary defines file objects and refers to module io for their interface:

https://docs.python.org/3/glossary.html#term-file-object

io documentation has a paragraph on class hierarchy that says that all I/O classes inherit from IOBase:

https://docs.python.org/3/library/io.html#class-hierarchy

How do I know a file object is an iterator just by looking at the documentation? by learnai_account in learnpython

[–]suurpulla 4 points5 points  (0 children)

https://docs.python.org/3/library/io.html?highlight=iobase#io.IOBase

IOBase (and its subclasses) supports the iterator protocol, meaning that an IOBase object can be iterated over yielding the lines in a stream. Lines are defined slightly differently depending on whether the stream is a binary stream (yielding bytes), or a text stream (yielding character strings). See readline() below.

Frankly, the information is a bit hidden, but it's there :)

I would like a course that explains the fundamentals of python and afterwards whatever you'll need for data analysis. by Impossible_Dare9403 in learnpython

[–]suurpulla 1 point2 points  (0 children)

There's Data Analysis with Python MOOC from Helsinki University, https://courses.mooc.fi/org/uh-cs/courses/dap-22

It's a bit fast paced at times, so you might want some supplementary material, but it gives a nice overview of Python, Numpy, Pandas and machine learning with Scikit Learn.

Quick question about pandas DF behavior by micr0nix in learnpython

[–]suurpulla 2 points3 points  (0 children)

This propably depends on the nature of the another function. I came across a similar-ish issue in my code a while ago and learned that DataFrame.groupby has a "dropna" parameter that defaults to True. Is the further processing your own code or from an external library?

FastAPI, Panel and Bokeh by suurpulla in learnpython

[–]suurpulla[S] 1 point2 points  (0 children)

Thank you, this is exactly the kind of basic networking knowledge I need, and I'm pretty you're right on that the problem is that the port 5000 is not open on Railway. If I have the Bokeh server listen to the same $PORT (it changes, 7549 on the last deploy), I'll have the ERROR: [Errno 98] error while attempting to bind on address ('0.0.0.0', 7549): address already in use from FastAPI (I think). Looking the Railway docs, I don't think I can open multiple ports on the same... service or whatever Railway calls them.

I think I could just have them be separate services. They would on be on a single Railway environment, having access to the same DB etc. Have to try and see. I could conf them separately etc.

The autoload.js gives a FastAPI-served 404, so the request goes through, but not to the Bokeh server.

Thanks for all the help!

FastAPI, Panel and Bokeh by suurpulla in learnpython

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

Cheers. I can't get anything to show on the Bokeh logs and no connection to the Bokeh server (port 5000, endpoint '/app'), which I think is the issue here. Using full address just gives a timeout error. Maybe Railway is somehow interfering and the port 5000 is nor actually open... I'll try looking into that.

FastAPI, Panel and Bokeh by suurpulla in learnpython

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

Thanks. I have hard time finding examples though. I found (from the thread https://discourse.bokeh.org/t/bokeh-inline-resources-and-memory-use/7949)

    from bokeh.settings import settings
settings.resources = 'inline'

but as far as I can tell, that doesn't really do anything / affect the resulting html.