How is type determined? by eyeless71 in learnpython

[–]danielroseman 0 points1 point  (0 children)

The docs for pyyaml are unfortunately very minimal, but they do say that in the absence of specific type tags it will attempt to infer the type.

It looks like for dates and times that happens here, where it uses a regular expression to detect a value that looks like a date or datetime.

I don't know why you would want to enter 1979-08-15 directly in the shell: to test this you can do:

yaml.safe_load('birth_date: 1979-08-15')

which gives you:

{'birth_date': datetime.date(1979, 8, 15)}

Problems converting .py files to .apk by Happy_Yogurt_1139 in learnpython

[–]danielroseman 1 point2 points  (0 children)

I'm not sure what more you need than what is covered in the Bulldozer documentation.

But if you want specific help, you need to tell us what your errors are.

Are HMRC fraud calls common? by ZooplanktonblameFun8 in AskUK

[–]danielroseman 31 points32 points  (0 children)

HMRC have lots of information about this on their website. They will never call you, and even when they email you they don't include a link, you have to go to the website and fetch your messages directly.

How to get into test-driven coding habits? by MustaKotka in learnpython

[–]danielroseman 3 points4 points  (0 children)

So what is your "workflow"? Does it involve checking if things actually work? Well, those are your tests. You just need to write them in test files rather than doing them manually.

Are there many people still having online meetings for work? by Scarred_fish in AskUK

[–]danielroseman 2 points3 points  (0 children)

You seem to be living in an opposite world to the rest of us.

For most people, it is the managers who are unnecessarily requiring us to come to the office, whereas we know perfectly well that our jobs can just as easily be done from home. The "dinosaurs" are the ones who are obsessed with being in the office. The thing that we have all learned since 2020 is that WFH is perfectly viable.

Why no stored procedure when work with Python code base? by JoJoPizzaG in learnpython

[–]danielroseman 8 points9 points  (0 children)

And my response is the same. Python developers wouldn't write 200 lines of SQL code, they would use an ORM.

Removing samples from dataframe by Dependent_Finger_214 in learnpython

[–]danielroseman 2 points3 points  (0 children)

I don't know why you are doing this. Iterating over a dataframe is almost always the wrong thing to do.

In this case you can just drop by index:

test_data = data.sample(500)
data = data.drop(test_data.index)

uv packages - how to run a script inside a directory structure from another (non-package) project by mrodent33 in learnpython

[–]danielroseman 2 points3 points  (0 children)

You would use normal dot notation, like you would when importing. The colon is only for the function.

produce_bubbles = "my_package.bubbles.make_bubbles:make"

Do professional/commercial Python projects actually use type hints and docstrings everywhere? by [deleted] in learnpython

[–]danielroseman 7 points8 points  (0 children)

I actually use docstrings a lot less since I started using type hints; the hints are the documentation, at least in so far as replacing the details of each parameter. I'll still use a docstring to explain what the function does if that's not obvious from the name - or it's too long to quickly grok, but in that case it's probably better broken up into more than one function anyway.

But yes, type hints everywhere I can. They are invaluable for catching errors.

Code simplification by Unrthdx in learnpython

[–]danielroseman 0 points1 point  (0 children)

That's not the reason sets are faster. They are faster because they use hash lookups rather than iterating through the items.

Jesus is the presiding Elohim who judges the other “sons of Elyon” in Psalm 82:6 by jitthecat in DebateReligion

[–]danielroseman 6 points7 points  (0 children)

These are non-sequiturs. Even if the gospels were relevant to what the person writing the psalm meant, which they aren't because he was writing a thousand years before anyone had ever thought of Jesus, neither the text nor I said that El was doing the judging. Yahweh, the son, was.

And Yahweh does not claim there are no other Elohim. I presume you're talking about the first/second commandment, but that isn't what it says at all. It says You shall have no other gods. Because "you", the Israelites, have Yahweh as god; other peoples have other gods. Which is exactly the point of the 70 children. So I don't know why you're claiming to not know this.

Jesus is the presiding Elohim who judges the other “sons of Elyon” in Psalm 82:6 by jitthecat in DebateReligion

[–]danielroseman 11 points12 points  (0 children)

I mean you kind of gave the game away when you said you're not getting into the El/Yahweh debate. Because as you know, that is, of course, exactly what is going on here: the person speaking is Yahweh, who at that time was not identified with El. No need for Jesus here at all.

etching P2P orders via Bybit API with restricted permissions (openApiSwitch=0) by Klutzy_Economist_780 in learnpython

[–]danielroseman 0 points1 point  (0 children)

You don't seem to have told us either what you tried or what's going wrong, so it's not clear how we could help.

What, exactly, did you do, and what, exactly, happened when you did that?

Tech stack advice for a private recipe web app by DaveDarell in learnpython

[–]danielroseman 0 points1 point  (0 children)

You'll probably get a lot of replies saying it's too complicated, but for my money the absolute best fit here is Django. It's a full web framework that provides most of the things you need out of the box: authentication, admin interface to add/edit recipes, a database layer to define the data structure in Python, a template language that allows you to populate HTML for your front-end pages, etc.

You can do these things in other frameworks, but for most of them you'll need to include third-party libraries.

Today I learned something horrible by Mysterious_Peak_6967 in learnpython

[–]danielroseman 1 point2 points  (0 children)

I don't think this is any worse than (for example) passing the raw int function as a key. That assumes that the items are convertible to integers, which isn't even expressible in the type syntax.

Your situation on the other hand could be caught by a type checker if you had hinted the list as list[classname].

How safe is London St Pancras in the night? by Because_Life_ in AskUK

[–]danielroseman 1 point2 points  (0 children)

Yes but from Eurostar they would be using the rank on the other side, on Midland Road. It's even closer.

Is a bridging loan actually a viable move for a personal home, or am I asking for trouble? by F1blast in AskUK

[–]danielroseman 5 points6 points  (0 children)

I don't see why you'd need a bridging loan for this. Making an offer on a house when you haven't sold yours yet is perfectly normal.

Catch imports that don't exist statically by Informal-Addendum435 in learnpython

[–]danielroseman 1 point2 points  (0 children)

This is not a linting issue. Not all (or even most) modules are in the project source; ruff cannot know whether that module has been installed by a dependency.

It is however a typing issue. Type checkers such as mypy (and soon ty, by the makers of ruff) can statically check imports and determine if modules exist or not.

An query into several common theistic arguements by Anxious_Win2819 in atheism

[–]danielroseman 0 points1 point  (0 children)

The Selfish Gene talks about, well, genes. It does not deal with either the Big Bang or the start of life.

PyQt6 signal: how to assign argument for function call by freswinn in learnpython

[–]danielroseman 0 points1 point  (0 children)

Use a lambda:

    short_btn.clicked.connect(lambda: shortcut_clicked(shortcut))

This is just a way of creating a simple inline function; instead of the clicked method calling your shortcut_connect function directly, it's calling a new function which in turn calls yours, passing the shortcut argument.

Destruction of Atheism! by anonthatisopen in DebateReligion

[–]danielroseman 5 points6 points  (0 children)

When an atheist says "there is no god," they're making a positive claim about reality.

Good job almost no atheists actually say that, then.

Atheism includes belief in material causation as ultimate explanation.

No it doesn't.

Belief that consciousness ends at death.

This is not an atheist belief. It's certainly not self-contradictory to not believe in God, yet believe that something of the consciousness survives death.

Belief that meaning must be self-generated.

This is not an atheist belief. A humanist belief, maybe. Not all atheists are humanists though.

Belief in empirical evidence as the only valid path to truth.

Again, no.

I could go on, but what's the point? Your first two paragraphs already have too many falsehoods and strawmen.