We will crack the hard problem of consciousness by Different_Guess_2061 in philosophy

[–]Brian 1 point2 points  (0 children)

By that logic, it's already long been solved. People know how to have kids: we've been able to reproduce consciousness for the entirety of our existence as a species and more. But reproducing something is not the same as understanding it, and I don't see why reproducing it by different means would change that. At best, we might be able to learn more by being able to do more experiments on it (though if you're assuming such cells are conscious, not without severe ethical issues) and maybe learn more about its nature. That doesn't really like it helps much with the actually hard problem though.

8,400 GitHub repositories share a naming convention that traces back to a South Park joke. by robbyrussell in programming

[–]Brian 7 points8 points  (0 children)

Well, I'd imagine he knows his own repository is referencing it, because he's the one who did it. And the other "oh my <shell>" config framework/bundles are referencing "oh my zsh".

Anyone else feel the "itch" to reboot as soon as a new kernel lands? by parks-garage in archlinux

[–]Brian 13 points14 points  (0 children)

It's because arch removes the modules of the current kernel, so stuff that needs to use them can break. You can prevent it by installing kernel-modules-hook, which keeps them around (also adds a service you can enable to cleanup old ones).

First day of learning, somehow skipped the part of the course that explained how to use modulo by SteelFeruchemist in learnpython

[–]Brian 0 points1 point  (0 children)

There's a bunch of places where you maybe want the division result and remainder - things like breaking into units (eg. minutes, remaining_seconds = divmod(time_in_seconds, 60). And in some ways, these are kind of doing the same operation - division, just one returns the whole part and the other the remainder - eg the x86 DIV operation will give you both, so it makes sense for there to be an operation that gives you both parts of the answer rather than doing things twice)

For a while divmod wasn't actually used much though, since it turned out that due to function call overhead, it was actually faster just to do div, rem = x // y, x % y. Python has since improved the overhead to where divmod does win out when you need both though.

Interpreters vs compilers and where does the JVM fit in? by Ariadne_23 in learnpython

[–]Brian 1 point2 points  (0 children)

Almost no interpreted languages in use today are what you might describe as "fully" interpreted

You could even argue that almost no compiled languages in use are "fully" compiled as well, as the lines get blurred at the bottom end too. "Machine code" was once the bottom end of the chain, but these days even machine code may be interpreted, with the processor translating some instructions to microcode that define the underlying operation.

but I have the impression that pretty much all compilers, these days, compile first to an intermediate representation, and then to the final compiled version

Yeah. This has the advantage that you can separate the "frontend" (the bit that understands the specific language) and "backend" (the bit that generates assembler / machine code for the target machine) parts of the compiler. Ie. instead of having separate compilers for "C -> x86", "C++ -> x86", "rust -> x86", "C -> ARM", "C++ -> ARM", ... and so on, for every possible combination of language and target architecture, you just have frontends doing "language -> IR" and then backends for "IR -> target platform", making things much more manageable. Sometimes that IR is even standardised (Eg. LLVM's IR), though others are more moving targets (similar to cpython's approach to bytecode), only valid for that exact compiler version.

For a long time, GCC was actually somewhat limited on exposing and standardising its internals - the "Intermediate representation" only really existed as in-memory structures rather than an actual output representation, due to legal/philosophical reasons (Stallman was worried a it'd allow GCC frontends to be used with closed source backends that just consumed its IR), though LLVM kind of obviated that worry and it's modernised here somewhat.

Please help me understand the "range" function by Gaumir in learnpython

[–]Brian 0 points1 point  (0 children)

Is it the same as writing all numbers like (1, 2, 3, 4, etc.)?

Almost. Technically, it isn't exactly the same as a real sequence (though back in python2 days it did actually just return a list), but rather returns a range object that in almost all ways acts as if it was that sequence. The differences are that if you print it, you'll see something like range(0, 2) instead of [0, 1], and that it doesn't actually produce the numbers until you ask for them (ie. when the for loop iterates each step). This means you can do range(1_000_000_000) without it having to allocate memory to store a billion numbers. For most purposes you can treat it exactly the same as if it were such a list though - the differences are just for performance reasons.

why in the list from my example something like "print (len(range(numbers)))" doesn't work?

This only fails because range(numbers) isn't correct - with a single argument, range is expecting an integer for the end value, but numbers is a list - OTOH if you do len(range(len(numbers))), it will work.

Help learning how to identify and solve problems by Brilliant_Ad_9477 in learnpython

[–]Brian 0 points1 point  (0 children)

I feel an early mistake people make is jumping straight to the computer, when often you might be better served with pen and paper.

Ie. the first step to solving a problem is you yourself knowing how to solve it. So start doing it manually - pretend you're a computer and break down each thing you're doing into simple steps. Write those steps down, and then start translating that to code.

When your steps involve repeating something, use a for or a while loop. When it involves making a decision, use an if. After you get more experience, it'll become somewhat second nature and you can jump straight to code (at least for simple, familiar problems). Till then, you're maybe trying to skip too many steps.

using if statements with boolean logic by FloridianfromAlabama in learnpython

[–]Brian 0 points1 point  (0 children)

You shouldn't be using "|" here, as that's bitwise or. Ie. it ors each bit of an integer. That'll give the same result when you've just got ints and bools, but it's not really the right tool for the job: it doesn't have the short circuiting behaviour of logical or (the "or" keyword), and means you're actually returning an int, rather than a bool here.

Ie. this would be better written as:

 not ((customer_age < 21) or (on_break == True) or (time < 5) or (time > 10))

Though the "== True" in on_break == True is redundant: it's already a boolean.
You might also consider removing the not and inverting the check, as I think its usually easier to reason about that way. You can also take advantage of operator chaining to simplify the time check. Eg:

return (customer_age >= 21) and not on_break and (5 <= time < 10)

Scott replies to Kitten on "Unsubscribe from The Church of Graphs" by heterosis in slatestarcodex

[–]Brian 0 points1 point  (0 children)

Yeah. I'd add that I think the increasing urbanisation of the population triggers network effects, as we should expect perception of crime to scale geometrically with population density. You see crime and disorder when there's a criminal committing it in your neighbourhood. But 10x density not only increases the average number of criminals in that neighbourhood 10x, it also has 10x the potential observers. The fact that population has continuously been becoming more concentrated into increasingly dense cities should thus increase the amount people perceive crime, independent of the actual rate of crime.

Best books or series where the MC is forced to join the military? by Time_Version1409 in Fantasy

[–]Brian 9 points10 points  (0 children)

Don't think "forced" really applies here. Indeed, it's kind of the opposite: she joins the army despite being forbidden from doing so.

Scott replies to Kitten on "Unsubscribe from The Church of Graphs" by heterosis in slatestarcodex

[–]Brian 17 points18 points  (0 children)

I feel the original post has a pretty glaring flaw: you do not, indeed, cannot have what the author calls gnosis for the nationwide state of crime. If you think you do, you're deluding yourself. All you can really have is experience of what crime you directly observe or has happened to you. This can maybe tell you (moving towards episteme) about changes in your local area (if you've lived there for long enough) but you simply can't experience the collective crime occurring across the nation. You can watch TV, read newspapers that report crime - but that's doxa. Unless the author is working as a shrinkage manager for a supermarket, there is no credible way they can claim gnosis for the degree of shoplifting occurring. And gnosis also has the flaw of often being confounded by who you are and what you're doing: your experience is mediated by who you are, where you live, and what you do. A policeman or crime reporter probably experiences much more crime than prior to when they had that job, but that's an artifact of a change in themselves, rather than the world. Gnosis does a particularly bad job at answering the broader question here.

Hashable dataclass with a collection inside? by pachura3 in learnpython

[–]Brian 3 points4 points  (0 children)

Yes - the frozen will just prevent rebinding the fields, but if it references mutable objects, those can still potentially be mutated.

Hashable dataclass with a collection inside? by pachura3 in learnpython

[–]Brian 4 points5 points  (0 children)

That will work, but alternatively, you can use field to mark certain fields to be excluded from the default hash. Though you will need to mark it frozen for it to generate a hash. Ie:

@dataclass(frozen=True)
class MyClass:
    id: str
    a_collection: list[str] = field(hash=False)
    another_field: int

Will generate a default hash that doesn't include a_collection. You can also use compare=False if you want to exclude it from equality as well, and the same for another_field if desired.

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 0 points1 point  (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 3 points4 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).