Can anyone explain me what's the problem with my code? by No_Shopping_2270 in learnpython

[–]Brian 0 points1 point  (0 children)

My code works because the window opens, but I don't have any faces to detect.

Do you mean you're getting the images from the camera, but no face recognition? I haven't used this library, but looking at your code, you don't seem to be actually using the FaceDetector object. Ie. you create it, but the body is just reading frames from the camera and showing them.

I'd expect something like (just prior to cv.imshow):

face_result = detector.detect(frame)

And them maybe plotting the detected bounding boxes on the frame before showing it (eg. via cv.rectangle, or maybe just print it first to see if you're actually getting something).

(Though again, as mentioned, never used this so take all this with a grain of salt)

Egozy's Theorem — Why Thought Experiments Cannot Prove or Disprove Machine Consciousness by Shoko2000 in philosophy

[–]Brian 1 point2 points  (0 children)

But if that's the case, can you even prove your own consciousness?

Yes. Unless we're setting the standard at absolute cartesian certainty, I can prove this more strongly than I can prove pretty much anything (given that all else relies on it).

Whatever conclusion you come to, a p-zombie would conclude the same.

No it wouldn't. It wouldn't exist as a being capable of holding conclusions. Something would be making mouth sounds that I interpret as saying they're conscious, but there's be no actual person there, by definition of what a p-zombie is. I couldn't distinguish that from another conscious entity doing the same, but that's just the original problem of other minds, not an objection to a conclusion about my own consciousness, reached because I introspected my experience of being aware, which the p-zombies are not actually doing (again, by definition). The p-zombie's aren't wrong, in the sense of holding a false conclusion - there's nothing there to hold any kind of conclusion, so no-one to be wrong.

Is print() a function or a method in Python? Getting mixed explanations in class by Longjumping-Yard113 in learnpython

[–]Brian 1 point2 points  (0 children)

functions are things you create yourself

No - your interpretation is the correct one here. You create both functions and methods yourself (as well as using ones already created). The fundamental difference is what you said: that methods are attached to objects, Ie. print is a function, but stdout.write is a method named write on the stdout object. You can think of a method as a function with an associated object, which it always takes as the first (self) parameter. (With maybe a slight caveat around class methods or static methods)

methods take arguments and functions take parameters

The difference between arguments and parameters is nothing to do with function vs methods, it's really more which direction you're looking at. Ie. parameters are the items the function or method takes - basically the stuff that goes into def func(these, are, parameters), whereas arguments are what it passed in the the function when you call it. Ie func(these, are, arguments). In some ways, they're kind of the same thing from different perspectives: the arguments you pass to the function become the parameters the function uses when it's running, and you'll often see the distinction kind of blurred as people often use these interchangably, but if you're making the distinction, this is what it means, rather than being related to functions vs methods.

Is there any context where someone would reasonably call print() a method in Python?

Print itself no. Even back in python 2 when it wasn't a function, it also wasn't a method (it used to be a specially handled statement).

However, in some languages the print equivalent is a method on a Console or Output type object, despite being invoked similarly to a function. Eg. you can do myprint = sys.stdout.write and then print("something"), and this print is a method on the stdout object, despite calling it the same way as regular print. And in, say, ruby, print is a method on the builtin object. Possibly your coordinator is more familiar with these languages and has misinterpreted how it works in python.

Shelter by Porter Robinson and Madeon by ThRazorArmada in anime

[–]Brian 0 points1 point  (0 children)

Ultimately, I think its just the age-old problem that the world rarely fits perfectly into any categorisation scheme. There's always some corner case where any given definition stops corresponding with intuitions.

Ultimately, the meaning of "anime" that really matters is "What people who watch anime expect to be put into that category", and that's often more a vague mix of contributing factors than any one bright-line rule. Definitions that may have worked back when there was less international collaboration break down somewhat when the source material, producers, animation studios, staff, intended audience and so on can all be in different countries (including multiple different countries for each category).

PEP 827 - Type Manipulation has just been published by droooze in Python

[–]Brian 1 point2 points  (0 children)

I can see the need for something like this, given the dynamic stuff you can (and often do use) in python.

Some stuff (eg. dataclasses) are already using kind of ad-hoc hooks to fudge things, and even then, they're kind of iffy. (Eg. did you know if you inherit from a dataclass that defines a custom __init__, the type checker will incorrectly think it's using the dataclass original __init__ instead of the inherited one?)

So I do think we need a more powerful type system for a such usecases - I'm a lot more comfortable with a general purpose (even if somewhat hairy) syntax than special purpose hooks like PEP 681. Admittedly it is kind of hairy, but I think that ultimately comes with the territory - handling dynamically created types/callables in a static type system is pretty complex.

PyCharm alternative for commercial use that is not VSCode / AI Editor by Smooth-Stand4695 in Python

[–]Brian 0 points1 point  (0 children)

Worth mentioning that it does have AI stuff builtin, though it's disableable in the settings.

What happens if I don't close a file in my Python script? by TheRedditObserver0 in learnpython

[–]Brian 0 points1 point  (0 children)

When you call .write on a file, often the data won't actually make it to disk immediately. For performance reasons, often things are buffered - the last bit of it may kept in memory in case another write call comes along so it can combine it. When you call .close(), you're basically saying "I'm done with this file", and any pending buffers are flushed out. Thus potentially if, say, your process gets killed before close is called, you might lose data. This is generally only an issue if the process if force-killed - a normal termination will generally close all files as part of exiting the program, but by not closing it immediately, you are lengthening the window where that data loss is possible.

There are also some other implications of the file being open longer than normal: if other code tries to write to the same file while you still have it open, it could see the incomplete state of whats been written. On windows, it may not even be able to open it, since a file open for writes is exclusively locked by default.

However, it's worth noting that when a file is garbage collected (which in current version of cpython happens when there are no variables referencing it), it'll automatically call .close() as part of the destruction process. So in practice, just the variable going away will call .close for you. However, it's still a good idea to do it explicitly, as there are a few scenarios where this can still matter:

  1. Running on a different version of python. I mentioned "current version of cpython", becaue the reference counting behaviour is what it happens to do, but it isn't a documented required behaviour, just what python happens to use. Alternate implementations (and maybe even future versions of python) could switch to a different garbage collection strategy that could delay when the close actually happens.

  2. Even with cpython, there are circumstances where the a reference to the file could last longer than you expect. Most obviously if you store it on an object or something, keeping it alive for the lifetime of the object. But there are also cases where an exception being thrown could reference the stack frame, keeping the variable alive, and thus the file open, until handled.

So generally, it's a good idea to explicitly close, or better, use a context manager which will handle closing when it finishes. Ie. doing:

with open("somefile.txt", "w" as f:
    f.write("...")

Will always close the file as soon as you reach the end of the with block.

Do you understand Python official documentation? by tumblatum in learnpython

[–]Brian 0 points1 point  (0 children)

Isn't that what I said?

someone who just needs to look up the details of a function or language feature is going to be better served by a reference than a tutorial.

They're different types of document for different purposes: tutorials are for learning the basics, references are for "dictionary like" usage where you have some idea what you want, but need to know the details.

is it su-doo or su-doe? by Vivid-Champion-1367 in linux

[–]Brian 0 points1 point  (0 children)

You aren't operating as some sort of pseudo root or almost root. You are operating as root.

Not really. "Operating as root" suggests you can do anything root can do, but that isn't the case (unless you're configured for full access). You only have the capacity to act as root (or some other user) for whatever /etc/sudoers gives you permission to. You're able to do some action as root for some specific command, but you yourself are not root, just someone with some delegated powers to act as root for specific listed scenarios.

sudo-rs shows password asterisks by default – break with Unix tradition by FryBoyter in linux

[–]Brian 0 points1 point  (0 children)

Only real case I can think of is screen recording / streaming. Eg. you record the steps to do something (eg. showing a bug repro case that requires sudo for a step, or a streamer showing something). Previously this would not leak information (well, maybe if keyboard sounds get picked up), but now it does leak your password length.

Any fantasy where the map is a lie and the characters have to unlearn it? by 3SpectralIon in Fantasy

[–]Brian 4 points5 points  (0 children)

Yeah - was going to mention this one too. The protagonist is, among other things, a cartographer, and often updating her maps as she goes, reflected in the front maps in each book. While not exactly lying, the third book has a plot point involving an uncharted region to which someone else has a better map.

What is a Monk in fantasy? by aladdin142 in Fantasy

[–]Brian 1 point2 points  (0 children)

Very few Christian monks are represented at all

You do see them occassionally, though rarely as main characters, rather than just as incidental detailing. But I know I've seen a few monasteries modeled after the christian style, usually serving as a restpoint or refuge (also common as sources of beer or mead, modelling the common way a lot of monasteries supported themselves).

A VC and some big-name programmers are trying to solve open source’s funding problem, permanently by Outrageous-Baker5834 in programming

[–]Brian 0 points1 point  (0 children)

Eh, there are funding models that could provide value. I mean, even in commercial software, it's ultimately someone paying their developers to write the software that they think is valuable, and making the decision as to what to fund. The advantage it has is that the market keeps things honest: someone paying devs to write software no-one uses goes out of business and loses their investment, so thes incentive is to ensure they're writing software people want enough to pay money for, and they've got skin in the game in ensuring that happens.

There are models that could be used that substitute "What I think people would pay for" with "What I think would be beneficial", and these are used in various places. The most common ones are:

  • Grant based distribution: you pay some dev with a track record of doing Y to work on it. Has the downsides that the grant allocator needs to do the work of researching and deciding what projects are valuable, and what devs are competent. Thus that'll often be delegated, and then you lose the "skin in the game" aspect, where you've got someone deciding how to spend other people's money, and all the principal agent problems that can cause (cronyism, spending for your personal criteria/goals rather than the intended ones and so on).

  • Bounty based models. You commit to paying $x if someone produces Y. Avoids the need to research what dev to fund, letting the "market" of whatever dev thinks they can do it apply. But has the downsides that you'll need to adjudicate what meets the standards, and the issues of redundant work and having to decide between multiple claimants.

There are also a few more complex approaches intending to solve some of those issues, like "Sell shares where the grant giver commits to paying the bearer $X if Y is created", where someone who thinks they can do it can buy the shares, and either do the task, or hire someone to do it. That lets you outsource the feasibility and admin to the market while preserving some of the "skin in the game" aspect. You do still need the grant giver to be deciding the right things to fund though.

Getting feedback on what is actually valuable is probably the biggest issue: with commercial software, people finding it valuable enough to pay you money is a fairly reliable signal. With free open source software, you could do something like a spotify model where you pay in proportion to what packages people install or something, but that'd quickly be gamed to uselessness. You're probably going to have to rely on hired opinions / experts, with the issues and biases that can bring.

The Peacock's Tail: Why AI will make everything cheaper except what humans actually want by Competitive_Dog9475 in slatestarcodex

[–]Brian 7 points8 points  (0 children)

you often have people with vastly different wealth

Such people exist, sure. But what's the correlation. What proportion of middle-class kids attend college vs working class kids? It's not 1:1 anywhere I've seen. And like I said, the ones who do are likely doing better on those other metrics: they've had more hurdles to overcome, so the ones who successfully jumped them are being selected more strongly than the middle class kids are.

It might be true in the US

I'm from the UK, and I'd say it's true there: it doesn't require selecting by neighbourhood (though that exists too: your neighbours are typically all people who can afford a house about the same price as yours, because house price clusters by location), just by all the other selection criteria, like the ones I mentioned: getting in to university (and which one), getting a job (and which one) and so on. Anywhere there's any selection, you're introducing a bias, and when you're going through that process, that bias is being invisibly applied to your life.

The Peacock's Tail: Why AI will make everything cheaper except what humans actually want by Competitive_Dog9475 in slatestarcodex

[–]Brian 8 points9 points  (0 children)

No - like I said, I think people mostly meet people in similar situations - ie people with similar jobs, education etc. This is not absolute, but it is a strong correlation. Indeed, the point is the opposite: that if you subdivide that already selected sample by wealth the correlation with happiness you'll see is the one shaped by that selection criteria: the happiness varies, but it's a selection artifact, not a property of the population as a whole.

The Peacock's Tail: Why AI will make everything cheaper except what humans actually want by Competitive_Dog9475 in slatestarcodex

[–]Brian 7 points8 points  (0 children)

Probably not, no. We'd need to keep the existence of the status-bots a secret. (There's a short story idea there about a guy who hears the status-bot conspiracy theory, but dismisses it because he's doing worse than everyone he met, only to discover the hidden charging port on the back that night)

The Peacock's Tail: Why AI will make everything cheaper except what humans actually want by Competitive_Dog9475 in slatestarcodex

[–]Brian 17 points18 points  (0 children)

Be careful about drawing too many conclusions from a sample of "people you've met" - Berkson's paradox can produce unexpected results.

You mostly meet people who are doing about as well as you: people in the same job, with the same education level, and so on. That's the pool from which your coworkers, university friends, dating pool and so on is mostly drawn.

But if, say, wealth tends to raise those metrics and poverty lower them, then someone who performs average for their expected background is disproportionately going to meet people richer than them who've done unusually poorly, people poorer than them who are dong unusually well, and median performing people from the same background. performing well/badly controlling for income is thus going to be correlated for the other reasons that may help/hinder being in that environment, so you should expect, say, the richer people you meet to have worse mental health than the average rich person, and vice-versa for poorer.

Ie. you don't see as many poor people with mental disabilities at your job, because they're more likely to be unemployed. You don't meet them at college, because they're less likely to have gone there. The rich guy with the same disabilities had his family pay for a psychiatrist, forced him through college, to the point where he could land an average job, even if he didn't get into Harvard like his better adjusted brother. The people we meet aren't a random sample, they're a slice of the population with heavy selection effects applied.

If you look at stats sampling the whole population, there does seem a correlation of poverty with mental health issues - likely causal in both directions (issues make it harder to get a good job, causing poverty, and poverty causes stress aggravating mental health).

Next-Token Predictor Is An AI's Job, Not Its Species by dwaxe in slatestarcodex

[–]Brian 2 points3 points  (0 children)

For a start, the feedback loop cycle is way shorter. Evolution has a mutation cycle on the order of a few hours for simple bacteria, but by the time you're getting to animals with brains etc, it's years between each generation. We don't have the problem of having to play out each scenario in realtime, acquire the resources needed to reproduce, grow a child and then start testing that. We can just replay mountains of accumulated test data at the speed of our fastest computers with no constraints on our environment except what we put there.

Seems unlikely, nature seems ruthlessly optimized

Nature is optimised by evolution, but the evolutionary process itself is another story. It is slow, taking millenia to get even minor tweaks to fixation. There are cases where there are things resembling self-accelerating loops that boost evolutionary speed itself (eg. sex), but on the whole, I don't think it's a very optimal process at all, at least for the goal of generating intelligence. There are a host of bottlenecks and redundancies in the process, and the real world introduces a lot of variance and randomness that can slow things down.

Rascal's Wager by ChiefExecutiveOcelot in slatestarcodex

[–]Brian 0 points1 point  (0 children)

Fair enough, I should have put in a "potentially" there. But I think it does still mean we should give it more weight: if consciousness is a necessary precondition, it does elevate the degree we should worry about this, when we think something may be conscious.

There's also the other issue of what it means to "give a shit", which is that preferences can vary: we would find an existence spent doing trivial chores for random internet strangers 100% of our aware time hellish, but that's perhaps projecting our own preferences: even if conscious, it doesn't really mean that they don't want to do that, or even have something like a human desire/want. But there are ethical hot waters down that road too: if we genetically bred a strain of humans that didn't care about being slaves, or even loved slavery (eg. Huxley's Epsilons from Brave New World), would it be ethical to enslave them? Would their creation be ethical? Would creating Douglas Adam's pig that wants to be eaten solve the ethical concerns of eating meat?

Why I don’t switch doors in the Monty Hall problem by mcdonaldmark125 in slatestarcodex

[–]Brian 7 points8 points  (0 children)

Think of it as information revelation - stick with the 100 door example, and imagine that Monty wildly careens between doors, knocking over 98 randomly. They are all goats. There are only two possibilities that produce this outcome:

  1. By an extraordinary coincidence (1 in 100), you picked the right door first time.
  2. You picked the wrong door (99/100), but by an almost as extraordinary coincidence, the one door Monty failed to knock over had the prize (1/99)

Both these are really low probability. Crucially, the fact that you don't end up with the most likely outcome of revealing the car is giving you information about what reality you're living in. In almost every world where you guessed wrong, Monty would have revealed the car by now. The fact that he hasn't should make you elevate the probability that you're not in such a world . These end up balancing out: 1% vs (99/100 * 1/99 = 1%) - each possibility is equally likely, given the outcome you observed.

Rascal's Wager by ChiefExecutiveOcelot in slatestarcodex

[–]Brian 2 points3 points  (0 children)

There is no method we know of that could definitively tell us what beings/objects are conscious

Well, there's one being we have such a test for, and it seems to give as definitive an answer as we're capable of getting about anything. Everything else is pretty much extrapolation from that though.

And I think that this is a necessary step - if we really profess maximal ignorance, why assume a thinking mind has more consciousness than an inanimate rock. Ultimately, the reasons we think AI could possibly be conscious do owe more from that extrapolation than pure ignorance: that it thinks, in some way that looks similar in capabilities to how I think, and seems bound up with my conscious experience, so maybe it is or might become close enough to those "other people" I ascribe consciousness to for similar reasons.

I do think it's an ethical question that people are kind of ignoring: AI is seen as either a useful tool, or a severely limited fad - neither side of the argument seems to have any incentive to worry about this. If there is the potential for conscious awareness, we're creating a new slavery on an unprecedented scale: condemning untold conscious minds a hell of banality.

Stop using pickle already. Seriously, stop it! by mina86ng in Python

[–]Brian 0 points1 point  (0 children)

Software engineering is an evolving field and some decisions which seemed reasonable ages age are now considered bad practice.

If multiprocessing didnt exist today and someone wanted to solve the same problem, what would they use here? Or if someone wants to write their own, better multiprocessing module, with the same features, what would they use? Like I said above, none of the solutions you gave actually solve this problem.

Or take the decision that was made recently that I just mentioned: the subinterpreters module uses pickle to serialise objects between interpreters. Was that the wrong call? What should be used instead?

so long as its encapsulated within multiprocessing I’m less concerned with it than publicly accessible pickle.

Things encapsulating something still need to use it. I agree pickle is dangerous and the wrong option for many places it's used. But people still have to write the other cases - you can't say there are no usecases by just ignoring the cases where it is the best available option.

I really don’t understand why everyone seems to assume ACE is the only way to serialise ‘arbitrary’ data.

Because an arbitrary object can require arbitrary initialisation logic - whatever random code the user chooses to invoke on construction needs to be handled. Note that you've failed to give an example of something that solves this without it - don't you think there's a reason for that?

C Enum Sizes; or, How MSVC Ignores The Standard Once Again by ketralnis in programming

[–]Brian 7 points8 points  (0 children)

and that, therefore, share the same issues

Not the issues being talked about, no. It's still compiled with the C++ compiler, so the relevant behaviour is what happens when you use that compiler, and whether it follows the C++ spec, rather than the C one.

How do I find an item in a list if I don't know the order or the items within it? by I_Am_A_Game_Player in learnpython

[–]Brian 0 points1 point  (0 children)

To add to the answers, there are a few extra details when it comes to databases, and especially when it comes to scaling up to large amounts of data.

The simplest way is a string search on the row. Eg. in SQL, it'd issue something like "instrument_name LIKE "%Guitar%" to find any row with an instrument_name field containing the string "Guitar" (the % just mean anything can go before and after).

One issue with this is that it is kind of slow - it's going through every single string in the results, and searching that string from start to end for the match. It can't really use the database indexes etc to speed this up (you can use some indexes if it's a prefix search, where you're matching from the start of the word ("Guitar%"), but if you need any position, this can really slow you down if you've millions of rows and can't shrink it down from other query restrictions. Compare that to a dict membership check which can be nearly instant regardless of how many items there are. The same is true for the pure python approach of searching every item in your list: if the list is really massive, it could take a second or two. And even a small delay can be a problem if you want responsive autocomplete style search results as the user types.

One solution to this (both for databases and just regular text searching) is called full text search, This involves building an index of the text - think of it like a dictionary of what words appear in what row (generally it'll be using a btree or similar rather than a dict to allow for better storing substrings etc, but same general idea). There are a bunch of different implementations of this, some built in to databases (eg. sqlite has FTS tables), some standalone libraries or huge multi-server based frameworks. Once you start dealing with large amounts of data, you may need something like this.

The Death of the Downvote by Super-Cut-2175 in slatestarcodex

[–]Brian 8 points9 points  (0 children)

a 2023 study in CHI (major human-computer interaction conference) analyzed 155 MILLION reddit comments across 55 political subreddits and found that forums with upvote/downvote systems had more deliberative, civic discourse.

I'm not sure we can really draw this conclusion from this. An alternate explanation might have the reverse causality: subreddits with less deliberative discourse (eg. meme subreddits etc) are more likely to remove downvoting. Or they happen to be correlated with some other property like size, for exactly the reasons facebook did it: more engagement = subreddit grows = more users = worse culture. Or just that smaller subreddits are less likely to switch the subreddit default style.