« first day (3337 days earlier)      last day (1835 days later) » 

16:16
Are these (question and current answer) really equivalent in django? If so, I really need to re-evaluate my ability to extrapolate from Flask
So if I'm understanding right, for opcode3 instructions, I'll advance my pointer by 2 rather than 4 for the +/* opcodes? [I feel slow here, but I'm working inbetween students. Guess I'll be modifying how I parse the opcodes and advance the pointer.
They can't even be vaguely similar, surely. The upvote to the answer must be a sock? It got it almost instantly but it was enough to throw me off
@roganjosh both Q and A look mostly gibberish'ish to me :/
but a simple comparison of content suggests they're not equivalent, at least not fully
@toonarmycaptain yes
@MisterMiyagi thanks. It was the answer upvote that made me take a step back and wonder if something radically different to my mental model was happening
16:26
my Django'foo is rather rusty, to be honest. But the Q and A itself looks rather fishy. For example, that the Q already imports the shortcut needed for the A.
It imports a lot of stuff that's not relevant to the Q. I don't know about generic.CreateView but I'm not sure why you'd have a route pointing to a class in the first place. Even when I did use django in a rudimentary way years ago, I never did that so everything looks wonky
Ah there we go, that's much better.
I redesigned and cleaned up my intcode interpreter.
I tell a lie, from django.shortcuts import render is the only unused import sorry
user11867329
16:45
k why isn't this working:

#PyScript
f= open("test.xml","w+")
f.write("This is line %d\r\n" %)
f.close()

ran from same folder as test.xml
Define "not working"
user11867329
Runs, doesn't write "this is line" in test.xml
because you did not set a shebang? because text.xml is not writeable? because python is not installed? because you run it on a commodore64? who knows...
because it has a syntax error?
"This is line %d\r\n" % is a syntax error. Percent style formatting requires a value to the right of the percent
user11867329
Thanks
user11867329
16:47
Let me retry
How did that not raise an error?
In any case, percent style formatting is very old. Consider using a more modern approach, such as f strings, or failing that, str.format
if the asker can't be trusted then no amount of help will, well, help
@Kevin %-formatting still has advantages over str.format
user11867329
@Kevin Yeah I'm just trying to, as simply as possible, open file and do minor actions
user11867329
16:48
it prints out %d though?
In my opinion, percent style formatting is the least simple of all the approaches.
still handy when you need to format something into a regex pattern
user11867329
Editing a guy's script using a tutorial but doing fancy stuff unnecessarily
f'this is line {x}' is way easier than "this is line %d" % x
user11867329
Great advice
16:49
@OakDev the code you have shown doesn't. It literally cannot be executed at all.
user11867329
{x}

x = REGEX?
Nah, no regex here
user11867329
function?
There is nothing fancy about what you posted, it's just broken
user11867329
16:49
No, the guy did fancy stuff
curly bracket in this context means "evaluate my contents and put the result here"
user11867329
x?
Morning cabbage
@Kevin I usually use % for first-class templates and f'' for embedded ones. Not quite the same use-case.
@OakDev Yeah, for single variable names like that, basically all it does is convert the value to string
16:51
@Kevin I do look forward to using fStrings when I eventually move out of the past.
@MisterMiyagi in what case? Asking for a friend
user11867329
gotcha so the {} is for argument x?
user11867329
or the syntax of f'abcedhfdksh'{x} is just like that?
@OakDev please stop right now and read this tutorial page top to bottom before going on talking here. I'm asking you this in official room owner capacity.
f'The value of x is {x}'
user11867329
16:53
@KieranMoynihan Still don't get it.
>>> f"I had {2*2**7} coconuts, and I lost one, so now I have {(2*2**7)-1}"
'I had 256 coconuts, and I lost one, so now I have 255'
@roganjosh % accepts any mappings, especially lazy ones. str.format requires the keys to be known up-front.
user11867329
@Kevin Amazing, gotcha.
This example illustrates that the curly brackets do not necessarily go at the end of the string. You put them exactly where you want the value to go.
user11867329
16:54
Is it only for calculus or ?
You can put any expression at all inside the brackets.
plus, str.format templates now have the problem of looking like f'' templates but being seriously outmatched.
List comps, function calls, whatever
user11867329
Since you said earlier 'not for RegEx'?
@MisterMiyagi So the example I had in my head was logging where the string formatting was lazy based on the error level of reporting, but I thought that was a property of the logging module, not %s itself
16:55
(but do keep in mind that "expression" and "statement" are different things)
@OakDev I meant that {x} is, itself, not regex. Feel free to use methods of the re module inside the brackets.
user11867329
Yeah, I assume you mean any sort of expression/calculus/math-ish, but not commands and other stuff.
@roganjosh formatting itself being lazy is a feature of first-class templates. You can get it with all templates but f''.
user11867329
Thanks a lot
user11867329
Mr. Kev
@OakDev The correct terminology here is "expressions" but not "statements"
16:56
For a formal definition of "expression", consult docs.python.org/3/reference/expressions.html
user11867329
@Code-Apprentice Yes, I also read the same thing as you
@MisterMiyagi aha, I've got it sorry. Yes, it is the way that logging works but it's %s that makes it possible.
Includes, but is not limited to, variables, literals, function calls, attributes, slices, mathematical operators, inequality operators, list comps, dict comps, set comps, lambdas
And the infinite combinations thereof
@MisterMiyagi True, percent formatting has its uses. Which is why I'm trying to wind down on telling people to never use it ever. The stance I'm aiming for now is "understand how each approach works and make an informed decision". With the subtext being "your informed decision will only very rarely be to use percent formatting"
It rustles my jimmies that so many tutorials make it seem as though percent formatting is the only option, or uncritically present it as the best option
17:11
I generally go for .format() because I don't know the point at which answers can reliably just move to f strings (where there is the option of multiple approaches)
Actually it's not my code. I used a code given here in a comment stackoverflow.com/questions/31517194/…banou 5 mins ago
"I'm writing a notebook for students"
:(
@MisterMiyagi Bout that upfrontness, str.format_map() accepts lazy mappings as well.
I have like 20 minutes - back on the AoC wagon
17:30
@roganjosh I'm sure OP will be an excellent instructor for their students ;)
@KieranMoynihan I'm chuckling but it belies the crushing sadness inside :P
Pretty soon Banou's students are going to be coming on SO asking for help because Banou doesn't know what they're doing
Only if they're smart, and then they'll probably have a rough ride if they do
Ah well. I'm pretty sure half my college instructors didn't know how to program. I turned out OK, for certain definitions of OK.
I'm not sure I'd fit any definition of "OK" :P but I'm unimpeded by a particular instructor in the world of programming. My car-windscreen-ice problem was mentally made much more complicated for me because I was specifically told by a lecturer that radiative heat loss can be ignored below 400 deg. C.
That sticks in mind, but at least it was correct in-context (engineering). God knows what sticks in other people's minds if you just lift SO posts, dump them in a booklet for students and can't even explain how it works
17:45
Nothing at all, I'd imagine.
Hopefully :)
I read that as "can be ignored below -400 degrees C", which is arguably true. When you're 130 degrees below absolute zero, you're not likely to see a lot of radiative heat.
The opposing argument being "that statement is not even wrong, it's incoherent, because -400 C does not correspond to any real physical state"
any equilibrium physical state, for what it's worth
I thought it was not possible to even go lower. as in, particles cannot not move more than not moving
For Chemical Engineering problems, radiative heat transfer is mostly negligible below 400C. That's a rule-of-thumb and you could make any number of arguments against it. But for a Heat Balance, you'll get close enough by ignoring it
17:51
@FélixGagnon-Grenier They can't, but that's an equilibrium notion of temperature. There's negative temperature but you can't measure it with a thermometer, or use it to make a cold beer even colder.
Let's see. en.wikipedia.org/wiki/Negative_temperature basically says that temperature doesn't necessarily correspond 1:1 to particle motion, and it's possible to get a lower temperature by adding more energy. Oops, beaten.
I love being wrong
"A system with a truly negative temperature on the Kelvin scale is hotter than any system with a positive temperature." Ok, so, maybe you can't ignore radiative heat at -130K? Especially since "if a negative-temperature system and a positive-temperature system come in contact, heat will flow from the negative- to the positive-temperature system"
Damnit
I was about to quote that same line, Kevin...
@Kevin This may have been mentioned, but some instances (eg code in jinja templates) may only support a subset of pull Python syntax, although that particular exception may have changed.
17:53
@Kevin I guess, yeah. One might argue that a laser beam is radiation from a negative-temperature body. Not sure if that argument is correct, but one can always argue.
I'm guessing this sort of state doesn't happen very often in nature.
@Kevin It's "ignored" in the sense of a yam-off blast furnace on it. Engineers cut corners
@Kevin it usually doesn't, because things reach equilibrium or something close fairly quickly (and you need a special kind of non-equilibrium for negative temperature)
Did you know that bananas get colder when you mash them.
Typically, you need to have more particles in excited quantum states than particles in the ground state. That doesn't tend to happen spontaneously.
17:56
"A system with a truly negative temperature on the Kelvin scale is hotter than any system with a positive temperature." where does this come from?
@roganjosh not sure what "hotter" tries to mean there
So what you're telling me is if I mash my bananas hard enough they'll get super hot?
@AndrasDeak nor I, but it's an interesting claim :)
@roganjosh That was based on the following sentence, I believe.
> "If a negative-temperature system and a positive-temperature system come in contact, heat will flow from the negative- to the positive-temperature system."
Here's my highly uninformed understanding. Temperature (at least in the range humans are familiar with) is a measure of entropy, aka randomness. Hot things are very random, because particles are bouncing all over the place. Cold things are not very random; for example, an ice crystal follows a very regular pattern.
17:59
I'm no expert, but that sounds like a kind of definition of "hotter"
@Kevin it was difficult enough that it took until 2013 for [a negative temperature gas to be created](sci-hub.tw/10.1126/science.1227831) (warning: ethical piracy on the link). Most negative-temperature systems have only a few discrete quantum levels (unlike atoms that bounce around, which have close to continuous spectrum)
But if you want to reach the maximum possible amount of kinetic energy in a unit of space, you have to cram that energy in very tightly, which is most easily done in a very ordered fashion. For example, accelerate a ton of photons moving in precisely the same direction. That's very energy dense, and it's also what a laser is.
@Kevin funny you should say that: ice has pretty large entropy even at T=0 because the molecules are oriented randomly
@KieranMoynihan I was asking for the source article. I'm curious about the context, otherwise it breaks thermodynamics
@roganjosh you've broken thermodynamics once you have negative temperature. Negative temperature is in the range of statistical physics that extends beyond thermo.
18:03
But it does average out to the point that the rules still hold on any system of more than 1 particle?
So if "temperature" is entropy, and "hotness" is energy, then you can have a hot system that is also low temperature.
This is a common thing. Like, the second law of thermodynamics? It's a hoax :P
Oh crap. You damn Physicists. Don't do this to me :P
@roganjosh I've no idea what you're asking. Or what "average out" means
18:04
Temperature measurements
temperature measurements assume thermalization, i.e. equilibrium between the system and the large measuring device
14 mins ago, by Andras Deak
@FélixGagnon-Grenier They can't, but that's an equilibrium notion of temperature. There's negative temperature but you can't measure it with a thermometer, or use it to make a cold beer even colder.
Outside of physics, every measurement of temperature would be an aggregate property, no?
As in, there's lots of particles and you get the average state reported back
The truth is statistical physics. If you take large systems which aren't too weird (they have a lot of quantum states), you will see that thermodynamics emerges as a very high probability prediction. It's not law, just "the chances of it being violated is practically 0".
@roganjosh there's no "particle temperature", only "system temperature".
> If the entropy of a thermodynamic system is not a monotonically increasing function of its internal energy, it possesses a negative temperature whenever (∂S/∂U) is negative. Negative temperatures are hotter than positive temperatures.
that "hotter" desperately needs a [clarification needed] or whatever tag
18:08
@AndrasDeak Ok, so are 2 particles a "system"?
> One of the standard formulations of the second law of thermodynamics must be altered to the following: It is impossible to construct an engine that will operate in a closed cycle and provide no effect other than (1) the extraction of heat from a positive-temperature reservoir with the performance of an equivalent amount of work or (2) the rejection of heat into a negative-temperature reservoir with the corresponding work being done on the engine.
@roganjosh of course
even 1 particle is a system
but it's hard to think of "averaging out" of any kind with 1 or 2 particles...
I think we're coming from different angles on this, but now I'm curious. At absolute zero, a single particle system would be stationary, so how can it have a lower temp from that point?
OK, having read the wiki page "hotter" probably means "if made in contact with [other object] heat will flow onto the [other object]"
If a system with temperature -100K meets a system with temperature 200K, I'm inclined to say that you can't find the resulting system's temperature just by adding the numbers together and dividing by two
18:11
@roganjosh okay, few particles will be a problem. But only because you can't differentiate with respect to energy...
@Kevin indeed
Hmm, I'm not sure "At absolute zero, a single particle system would be stationary" is always true. Doesn't liquid nitrogen still flow at 0K?
We've not achieved absolute 0
@Kevin yeah, that's a bit sketchy, but I can't answer without going into details of bosons and fermions....
I suspect bosonic gases can probably reach their single-particle ground state (more or less meaning Bose--Einstein condensation) which is as close to "stationary atoms" as possible in a quantum setting
@AndrasDeak yep, temperatures is just a description of the distribution of particle energies
this is actually an area where im quite competant in
@Kevin simple counterexample: both a -100K and a 100K version of the same system has finite energy, so putting them together can't have 0 energy (which would be the ground state)
18:14
how do you "make your own cloud" using python? what does this mean?
@Kevin How could anything "flow" at 0K? In order to flow it must have some kinetic energy, no?
@Kevin you cant have -100K, there exists a notion of negative temperature but its not going to operate how you think, energy flows from negative to positive
negative "temperature"
@KieranMoynihan does your water get hotter when you let it out the tap? There's too much confusion here.
aka just a weird distribution of the energy of the state of the system
Well yeah, but that's just maths. I was talking about a physical representation of this negative Kelvin state
18:15
Movement is not temperature. Atomic-scale movement is temperature, sort of, in a classical, thermodynamical setting. And then there's statistical physics...
@Skyler please read back the discussion so far
@KieranMoynihan case in point: a lot of gases turn into superfluids at low temperature, which will more than happily flow.
@AndrasDeak Low temperature != 0K ?
Whenever we talk physics I'm always prepared to abandon any argument that depends on my intuition about how the world works. My intuition is designed to operate correctly only in environments where my species could flourish, and supercold environments are not one of them.
@KieranMoynihan probably, but they'll also probably flow at any finite temperature
the typical definition of T=0 is "the ground state", so yeah, mechanical things should stop moving
But the most common negative-temperature systems are lasers, where the states that relate to negative temperature are excited electronic states of atoms. And not atoms running around like billiard balls.
so the whole "is it moving" aspect is moot
I think I was thinking of Superfluid Helium-4, which flows at ~1K, and even creeps up the walls of its enclosure. Skimming the article I don't see anything specifically describing how it might behave at exactly 0K
So, truly in the quantum domain?
18:23
you can't be more truly in the quantum domain than "creep up the wall of the container"
I'm prepared to abandon my intuition of "atoms behave in a way that makes sense"
Depends on your notion of sense, but yeah, super-* phenomena are freaky.
Leave behind your mental model of "particles are basically just really tiny spheres", you won't need them here
What does it even mean to say something can't be "moving" at 0K
What is "moving" even
For instance, the reason He-4 can creep up the wall is that it can spread very thin without evaporating that thin film, because it can dissipate heat throughout the liquid very fast. If I recall correctly heat is transferred in superfluid He like sound. If you imagine how fast sound propagates in water that's insane.
18:25
Relative to what is something defined to move?
@KieranMoynihan presumably there's a single-particle Hamiltonian, part of which is kinetic energy...
Ah yes, second sound
> The speed of second sound is close to zero near the lambda point, increasing to approximately 20 m/s around 1.8 K
with a bit of a hyperbole you shoot it with a flame thrower and 5 seconds later someone 100 m away can measure the heat across the medium
@KieranMoynihan I'm going to take a guess and say "relative to the boundaries of the system".
I'm not sure behaviour at 0K can be discussed with much certainty. Surely any movement would be involving some kinetic energy, and hence temperature >0K. At what point do electrons stop moving (to use a classical verb) etc?
At some point in this discussion I've heard the suggestion that time either essentially stops or does very, very weird things, even for the quantum realm.
@Kevin So a particle inside a system is said to have no kinetic energy if it is stationary relative to the boundaries of the system, even if the system is hurtling through time and space at extraordinary speed?
Side note: at T=0 K most electrons have huge momentum...
18:30
Essentially you have to draw a box around the particles you want to measure, if you want to draw any meaningful conclusions. The box itself can be stationary or moving in a straight line or whatever, and this may change your measurements, but they change in a predictable and logical fashion
Like, 1/5 speed of light fast.
yes
18 mins ago, by Andras Deak
@Kevin yeah, that's a bit sketchy, but I can't answer without going into details of bosons and fermions....
electrons are fermions...
@KieranMoynihan Yes, that's my understanding. A particle moving past earth at 0.333*c can have very high kinetic energy if you anchor the coordinates of your system on Earth, and can have low kinetic energy if you anchor the coordinates on the particle.
What accelerates them?
18:32
@roganjosh nothing. Or Pauli's exclusion principle. Take your pick :P
@Kevin So what you're telling me is that the temperature of a particle is dependent on who's looking at it? This is some next level twin paradox going on.
I need a wee and a trip to the shop; I've been glued to this convo for too long :P
@KieranMoynihan I'm either saying that, or I'm saying "energy can't be considered a property of a particle by itself, it can only be a property of the combination of the particle and the frame of reference". Or maybe both of those mean the same thing.
I don't believe that kind of relativity makes total sense...
Would not that mean that from the perspective of someone flying by earth at close to the speed of light, Earth would have enough KE to either burst into flames, or explode spontaneously?
@roganjosh the gist is that if you put a large number of of electrons in a bucket (a metal), they can't all occupy the single-particle ground state ("stationary electron") because of Pauli's exclusion principle. Instead they start filling up states with larger and larger energy (-> larger and larger momentum). The highest-energy electron are at the Fermi level
And if you estimate the speed of electrons in metals at the Fermi surface you get the Fermi velocity which is easily around 10^5 m/s in metals, at T=0 K.
of course the catch is that once you put electrons in a metal they are no longer electrons, but I digress
@Kevin that is truth
the temperature one not so much
if you start moving with v speed then a previously stationary object will suddenly pick up kinetic energy
18:37
Well temperature broadly speaking is a measure of the speed of movement of particles...so in a gas the temperature is proportional to the (average) velocity/momentum of the particles that make up the gas.

Long story short temperature ~ kinetic energy...so temp of a particular particle as measured by different observers might differ.
that's why particle physicists always append "in the center of mass frame of reference" after "13 TeV collision energy"
Of course, my physics is largely from university which is 15 years ago now, so..
@KieranMoynihan Yes, but only if the Earth were moving through a stationary medium that would produce friction against its movement. The interplanetary vacuum doesn't produce very much friction, and it's not stationary relative to the person flying by earth close to the speed of light.
If the person brought his own stationary medium with him from home, it would be akin to bombarding Earth with tons and tons of near-light-speed gas, which probably would have a spectacular result indeed
@Kevin But the earth itself would have extraordinary KE from the perspective of the person flying by, simply due to the earth being the one moving in his frame of ref
Yeah, but I don't think very high kinetic energy is sufficient to make a body spontaneously explode. Certainly lots of high-KE systems do explode, but this particular system is uncommonly well-ordered -- all the contituent particles are moving in mostly the same direction.
i.e. in the direction that the person flying by came from
18:43
@AndrasDeak I think I follow that, and also in relation to my earlier queries, but I'd never want to actually have to work in this space :) Thanks
@Kevin Fair enough
@KieranMoynihan The earth moves through space very, very fast, yes (eg using the sun as a reference point). But talking about individual particles in terms of temperature rather than energy/momentum becomes a little meaningless.
Incidentally I've really only thought about this in terms of... I don't know what you'd call it... "mundane relativity". I haven't taken into account, like, time dilation and relativistic mass and stuff.
In all our examples we were talking about near-c speeds but maybe it would be prudent to think about very-fast-but-not-near-c speeds first
@KieranMoynihan I see temperatures as a vibration rather than a movement. So, yes, we're hurtling through space, but particles vibrate locally
Mundane relativity == Galilean invariance, perhaps
18:50
So "stationary" refers to "not vibrating" rather than any relative position in space
Of couse, Andras would destroy that (and with good reason if you know what you're talking about there) but it's my layman's understanding and the one I stick to
If we pin our reference frame on a vibrating particle, then the usual rules don't apply to that reference frame, because it's not an inertial reference frame
i.e. it's not at rest or moving in a straight line (ignoring the chicken and egg question of "moving in a straight line relative to what?")
@roganjosh much better rule of thumb with the ape's intuition
which is to say, the intuition that every human has
@AndrasDeak I actually don't know if that's an insult, compliment or other :P
@roganjosh Enjoy your Rogan Josh, ape... ;)
19:03
It's a compliment. You're in the top tier of understanding of temperature, since the average person forgot about the mechanics of temperature immediately after seventh grade science class
If you see temperature as anything more sophisticated than "don't put your hand on the hot stove", you're winning
yey, I'm winning :)
I also think "don't go outside during winter without a coat"... Am I a winner?
Only if you didn't wear it inside for a prolonged period, because then you won't feel the benefit
</grandmaHat>
You forgot to open <grandmaHat>
What's in grandmaHat?
Me. I don't need to open it at all.
That's not quite true. I can't imagine grandmothers living like me. Even the locals are commenting that I don't own a coat and this is the north of the UK :P
ah, self-dupe, that's why the phrasing was familiar
good catch
I've answered this question before so i remember that guy
:D
my mistake
@AndrasDeak it's ok :P
19:48
I've a question for you guys. pastebin.com/v4W2aXcw
Those "null" and "false" values look suspicious to me. Try replacing them with None and False, no quote marks.
ok
Ops, it's works ! thanks
i tried with False before and null
@Kevin did you receive a notification if i mentioned you in a question which you are not in
No, I didn't get a notification. Typically the person you're pinging has to have been active on that post.
Good thing, too, or else the notification would go to every user with the name "Kevin", and there are a lot of them.
Approximately 3,616 if stackoverflow.com/… is trustworthy
(I'm the only real one though, don't believe their lies)
@Kevin hahahaha
@AndrasDeak thanks for the ref..
recbg
Huh, despite having had a credit card for about 15 years, apparently I've only got a credit history going back 4 years? Bananas.
What is the new equivalent to "too broad"? I'm voting with the old categories in mind but there's no "there's no hope in hell you'll get this into shape" category
20:06
idk why i usually read too broad as too bored
hahah
@roganjosh needs more focus
That's misleading for people who have a specific problem but can't be arsed actually solving it
Or, actually, even starting to try solve it (which is where my bugbear lies)
how do you guys convert local browser request headers to Python dictionary ? are there a way instead of manual formatting ?
I think the last time I needed to do that, I just clicked "raw headers", copied the text, and iterated over each line and split it into key-value pairs manually
There might be a helper function in one of Python's http related modules
i usually do the same . i think there's might be an online header formating.
20:17
docs.python.org/3/library/… looks like it might do something
@αԋɱҽԃαмєяιcαη right click -> copy
@Aran-Fey then right click and paste yea !
@Aran-Fey that's not the question BTW
>>> import http.client
>>> import io
>>> s = """cache-control: max-age=604800
... content-type: text/css
... content-encoding: gzip
... last-modified: Mon, 25 Nov 2019 23:47:20 GMT
... accept-ranges: bytes
... date: Mon, 02 Dec 2019 14:32:01 GMT
... via: 1.1 varnish
... age: 372495
... x-served-by: cache-lga21921-LGA
... x-cache: HIT
... x-cache-hits: 1
... x-timer: S1575297122.531510,VS0,VE1
... vary: Accept-Encoding,Accept-Encoding
... content-length: 13325
... X-Firefox-Spdy: h2"""
>>>
>>> x = http.client.parse_headers(io.BytesIO(s.encode()))
Note that it rejects the string if it includes the response code, for example HTTP/2.0 200 OK
h = <Ctrl+V>
h = {d['name']: d['value'] for d in h.popitem()[1]['headers']}
20:37
Alrighty. I believe I've got the new intcodes/instructions. Now to implement the parameter modes. :D
I kind of only half-implemented mine, in the hopes that the one catastrophic failure scenario I was setting myself up for would not occur. Good news, it didn't.
What scenario was that?
f-strings are in 3.6, right?
I record the mode for all parameters but completely ignore the mode value for any parameter that specifies where the result is written. For instance, it treat the opcodes 11002 and 11102 identically. Granted, the question says that targets will never be immediate mode, but I suspect that won't always be the case.
So you could say I'm setting myself up for catastrophic failure in a future intcode question.
20:42
The mode corresponding to the output for mul is the first digit, not the third (in the instruction)
Oops, in that case I treat 01102 and 11102 identically.
If it's part of the parameters of the intcode that that will always be the case, what's the issue?
@Kevin how can you make sense of an immediate-mode target?
(Kieran's valid point aside)
For example, instead of assigning the result to memory[target], a different mode might assign it to memory[memory[target]]
Hmm, right. But that would mean that you assume it's never positional mode, wouldn't it?
20:50
I'm pretty sure there are real-world instruction sets that allow this kind of double-indexed parameter but I can't figure out what it's called.
Ok, let's speculate that in the future there will be a third mode, called "referential", to which we give the numeric code "2". Read-only parameters can be immediate, or positional, or referential; writable parameters can only be positional or referential.
11002, X, Y, Z   ->   memory[X] = memory[Y] * Z
11102, X, Y, Z   ->   memory[X] = memory[Y] * memory[Z]
11202, X, Y, Z   ->   memory[X] = memory[Y] * memory[memory[Z]]
21102, X, Y, Z   ->   memory[memory[X]] = memory[Y] * memory[Z]
01102, X, Y, Z   ->   X = memory[Y] * memory[Z] #... But you can't assign to a number, so this is illegal
You've got your modes backwards again :)
Here's a couple examples. Basically my worry is that, since my code is currently hardcoded to assume all targets are in positional mode, it will be a pain in the butt to allow referential mode too.
I could change mine fairly easily, but I'd have to switch from a simple if else to something like...
for i in range(mode):
    x = memory[x]
Well, you know what I mean.
user11867329
What does (line, end='') do?
21:02
Crackpot design proposal: allow immediate mode for writable parameters. 5 = 2 + 2 means that every time the literal "5" appears in your source code, it is instead interpreted to mean "4"
user11867329
Is "line" a standard object or is it just the name used
it's the variable name in (presumably) the print() statement
what's a "standard object"?
user11867329
@Aran-Fey I'm not familiar with the programming term "object" and I was wondering if there was a set list of "objects" that could be interacted with
user11867329
21:06
or if it was ... i guess like a value?
user11867329
that you can name
If by "standard object" you mean a variable that's already accessible in an empty program with no imports required before hand, you can see them all with print(dir(__builtins__))
objects and values are the same thing
user11867329
@Aran-Fey Duly noted.
user11867329
dully?
user11867329
21:06
duly.
Most of them are functions or types, but there's a couple regular objects in there. __name__ is a string, for example.
__name__ is a global though, not a builtin. So dir(__builtins__) doesn't show you all the names
user11867329
@Kevin So according to doc, I could use either prebuilt functions or my own function (provided it's logical) as long as it's declared as an object previously?
Sounds right to me. "functions I made" and "functions I did not make" rather neatly cover all possible kinds of functions.
@OakDev "use"? Use for what?
Also not sure what "declared as an object" means
user11867329
21:10
For something mmmMorty
user11867329
@Aran-Fey You said it's practically like a value (an object), right?
user11867329
You have to declare values, no?
user11867329
Like "That value = This thing"
No, you declare variables. Variables are not values. Variables hold values.
@Aran-Fey Hmm, I can see __name__ in my own dir(__builtins__)... Maybe it's a version thing.
21:11
Ah, well, the builtins module has its own __name__ after all
user11867329
oOooooooOooO, so how can a value be a function?
I think that's backwards. A function is a value
user11867329
In my head a value is a static ... well... value (digit/string/etc...)
Python does not, strictly speaking, have a concept of "declaration". Sometimes an assignment looks like a declaration, for example x = int(2.5), but not every variable name has to appear in an assignment statement before being used. Consider the program from math import *; print(sin(0)). The function sin is not "declared" anywhere in your program, but it executes happily anyway
user11867329
Gotcha, that's why I was wondering if their was prebuilt objects
21:15
there were *
And, for once, I'm with you. In confusion over "value"
It may also interest you to know that names may appear inside functions even if the name hasn't been bound to a value yet, as long as the name is bound to a value before you call the function.
for example
def f():
    print(x)

x = 23
f()
This is permitted.
user11867329
>> It is too late to edit this message
user11867329
@Kevin I understood that.
* So long as the function is within the scope of the variable
@KieranMoynihan let's just throw global into the mix
21:20
Let's say "so long as the variable's scope is visible to the function's scope"
Eh, I think my edit fit the bill.
Yeah, I think we converged on the same idea.
I think I misread the transcript
I'm perhaps being more vague than necessary just in case I'm forgetting a situation where Y can see Z, but Z's scope does not encompass Y's scope. Some kind of crazy cousin scope scenario.
Ah yes, cousin scope.
user11867329
21:23
^
Roll tide, brother.
Mega garlic. I'll be elsewhere until this blows over.
first time i see user with 66k rep and his profile title is Test Automation Engineer and a RPA Developer and he don't know about network tab for dev.. stackoverflow.com/questions/59201104/…
I'll stop pouring gasoline on things now, as I need to go home anyway
meanwhile I can't participate because I still have no clue what a scope is
user11867329
21:25
Maybe Kevin is Kevin O'Leary?
Hmm, I've re-read the posts twice and I don't think they asked anything about scope
Consult docs.python.org/3/reference/… for a formal description of scopes.
well, not so much a formal description as incomprehensible word salad IMO
I'm only now realizing why it's called "scope"...
@roganjosh Yeah, I don't think he did. I went off on a tangent because I had a traumatic flashback to a certain language where you couldn't use a variable name in any context unless you declared it first higher up in the source file
21:27
@OakDev no, he isn't. And people are trying to address your understanding
I have never specifically denied being Kevin O'Leary >_>
user11867329
@roganjosh I acknowledge that. Also: "I have never specifically denied being Kevin O'Leary >_>"
ok, "word salad" was a bit harsh, but reading that page did nothing for my understanding of scopes. In fact it made it worse
I think I stopped addressing Oak's understanding and started filibustering about ten minutes ago
@Aran-Fey I would charitably call that section's wording "dense", and my uncharitable assessment cannot be reproduced in polite company
Most of my frustration is with the final paragraph describing the special quirks of a class-level scope
21:56
I hope we (and I mean you) have learned a valuable lesson about not enabling known problem users.
user11867329
^ oof
@OakDev I'm asking you as a room owner to please go away. We don't need noise here.
how much rep do I need to unlock the upload images privilege in chat? 50?
I think so, but not sure

« first day (3337 days earlier)      last day (1835 days later) »