« first day (3526 days earlier)      last day (1421 days later) » 
00:00 - 16:0016:00 - 00:00

4:00 PM
working directory: import X. Stash: import Y. Merge result: import Z, some-yamming-how
 
it's probably due to quantum
 
You have ghosts in your computer. Reboot and take the rest of the week off.
 
git is the ghost - what do you think the 'g' stands for?
 
Ghost In Thecomputer
 
Do you suppose this question was posted as a joke? stackoverflow.com/questions/62328391/…
 
4:03 PM
@LinkBerest "grbl", the sound one makes when trying to remember git commands?
@AnnZen I doubt it. There are many script kiddies using trying to use Python.
 
I, too, think that question is sincere.
Satirically bad questions are usually much worse than this
 
If it was real maybe the op wouldn't say 10000, only 10.
 
Scalability is a real concern for aspiring spammers. If their solution can only send 10 emails a minute, then they're not going to make much of a profit.
 
@MisterMiyagi mine is more like *#&(!*&!!! but yep :)
 
And popping up the question And please can anybody help me how to get emails from csv ? makes it funny.
 
4:08 PM
I find that most funny posts were not intended to be funny by the author
 
@AnnZen I do that, though I have no intention of helping this spammer
for grades notifications to students (csv of different messages which I generate into full emails with Python)
 
Ending a question with "and also, how do I do this barely-related thing?" is quite common among new users
 
It's delvable now
 
which I stole from myself (used to do something similar with a business just substitute grades for performance reviews)
 
I tried using subprocess() it didn't work, I tried threading so that I can then join() it and then start() it yet again, it is slow. I tried tf.initialize_all_varaibles() to initialize all variables inside and outside of session did not work.
@MisterMiyagi Which line are you talking about specifically? so that I can fix it.
 
4:19 PM
threading doesn't create a separate process for each thread, so I wouldn't expect it to solve problems related to intermingling sessions
 
When I used subprocess for being it more cleaner however I need to return the processed video path and subprocess isn't helping with that. Now that I think of it I can use db for that as I am using it anyhoo.
 
@AshwinPhadke The first line. Function definitions must begin with def.
 
@Kevin oh okay.
 
... But that is just one symptom of the larger issue, which is the lack of an MCVE
 
user13564783
how do you check if arguments were given when running the script?
 
4:21 PM
sys.argv
 
@Kevin Ah that.
Let me try subprocess again
 
user13564783
rbrb
 
Hi, I'm making a graph of an audio waveform and I need to plot the duration of the sound on the x-axis by even increments. The problem is I also need the increments to make sense in context with how long the sound is. For example, I wouldn't want one of the plot lines to be 02:54:165 if I could help it. I'm not even sure where to ask this, if it's more a mathematics question. Any help would be appreciated
 
also a lack of knowledge with using subprocesses (not the module just in general) with data flows - subprocessing out the training with redirected output then killing the process and/or spawning a new one will work (I've done this before). If you have a file (or DB) to save results for later loading this also works.
The second one is probably easier (definitely easier if you've never worked with threading or subprocessing in any language before)
 
@LinkBerest I have worked on subprocess only in python or to execute cpp programs through python.
@LinkBerest I'll try both
 
4:28 PM
cool, its not something everyone works with so I tend to check :)
 
Yeah
A quick thought should I use subprocess.Popen(), subprocess.call() or .check_output() ?
 
@JoshuaBultman use an FFT (fast fouier transformation) to convert the frequency domain to a time one
 
@LinkBerest Thanks I'll check that out!
 
I typically try .call first (unless its Windows where that always gives me problems and I end up using .Popen)
^ I do not have a reason call gives me problems on Win; it just seems to
 
If you're using 3.5 or higher, run() is usually your first choice over anything else
 
4:34 PM
oh, yeah; I forget about that (cause well....stupid legacy). I repeat from yesterday: upgrade dagnabit!
 
I'm being hypocritical here because I still use check_output despite it being "Older high-level API"
 
@LinkBerest windows only supports Popen() AFAIK
@Kevin 3.8 , I'll try this too.
 
probably, I honestly don't remember why, just remember it was a thing
 
I'm on Windows and IIRC, call() has worked for me. Perhaps with some hiccups trying to get shell commands to work, but I wouldn't expect Popen to fare any better there
 
ghosts
the answer is always ghosts
 
4:36 PM
Hmm... A ghost in the shell. Edit: Aaaaaand I've been sued by Kodansha Ltd.
 
subprocess.call() gives buffsize must be an integer is it because I write subprocess.call("python", "script.py")
 
Honestly I've used subprocesses on a Windows - non-server - setup like twice so not something I'm an expert on (Linux being the OS of choice for most servers)
 
@AshwinPhadke Shouldn't it be subprocess.call(["python", "script.py"])?
 
@AnnZen damn I hurry.
 
I'm confused by you folks saying the subprocess convenience functions don't work properly on Windows. They're just wrapping Popen behind the scenes. How do these fail?
 
4:48 PM
is a Breakpoint possible in Python? Just like in VBA in EXcel so that i can run the script step for step and find where the damn error is
 
so subprocess.call() works but loads the libraries and quits. strange?
@ExoticBirdsMerchant you can debug all programming languages.
 
hihihi @AshwinPhadke i only knew this handy method. Surely Python has everything. I mean the stdout or stdin is ok. But is there the real thing? Breakpoints like in VBA or something similar?
 
if you have an IDE which supports breakpoints then yes (PyCharm does, VS does) .... technically you can always add a input prompt ( press any key to continue ) for a hacky breakpoint when using straight command-line
 
Ohhh so it is an IDE thing .. i see
and yes i remember this from VBA the input is always possible
 
@ExoticBirdsMerchant I don't know how breakpoints work in VB, but if you use VS code or the likes of it you can insert breakpoints wherever you want and then jump into it or keep going ahead so that will solve your issue I suppose.
 
4:51 PM
Thank you guys. I need to find a permanent IDE. Atom i didnt like for sure and Wing 101 is quite limited. Mayme λcmd
 
@MisterMiyagi I only used it twice and .call gave me issues (I didn't look deeper than "oh, popen worked") I know, I failed as an engineer by just accepting an answer without looking deeper but I hope you can find it in your hearts to forgive me :P ;)
 
@AshwinPhadke visual studio i must buy i think the expiration period is gone but i definitely need to check it out
 
@ExoticBirdsMerchant hehe great.
 
Could someone point me in the direction of what I'm missing here please? I'm trying to grab the function name and the first "block" of text of the docstring. I want to cover the case where the the opening line might go over to the next (so not cutting off the last couple of words). I've been trying to use this but can't get anything but a single string
def my_decorator(f):
    @wraps(f)
    def wrapper(*args, **kwargs):
        print(f.__name__)
        print(split_on_empty_lines(f.__doc__))
        return f(*args, **kwargs)
    return wrapper

@my_decorator
def example():
    """First line
    I want this too

    Not this, though
    """

example()
 
4:55 PM
@linkberest thanks for the tip :-)
 
I don't know regex but I've been playing around with the pattern in the way I assume it works, or putting extra blank lines between the bit I want and the bit I don't; nothing works. Nor does calling repr() on the docstring. I'm missing something basic; I thought they would be analogous string splits
@ExoticBirdsMerchant VSCode is not Visual Studio, it's something separate
 
Ohh so VS Community is the thing @roganjosh (got Win)
hihihi first ill switch it to English hah
 
Ohhhh Thanks man
 
both are linked in the link I gave - read the "about"s on each and pick the one you want (both work fine, VSCode is certainly smaller if that is a concern)
 
4:59 PM
yup both look like a good deal. Size is an issue. I m going with Code
 
I wonder how that is reading that in (as far as regex is concerned if it is coming in as a single string from __doc__ with newlines intact r'[\r\n]+' should work - meaning adding a limiter like {1,2} to the end should be a problem nor should adding a look-back to see if there's a string or not - ie. the example)
 
@AshwinPhadke you are right there are breakpoints. The whole VS environment is very good. I ll try it it looks very promising
 
@LinkBerest Should be a problem, or shouldn't?
 
if you're sure __doc__ is leaving the newlines intact it shouldn't be a problem - the example regex should work (though the {2,} would need changed for single line docs). I don't have python available to test right now and don't usually use that method so not sure how it returns the doc/cannot test.
oops, yeah - shouldn't. I see my typo now :P :)
 
print(repr(f.__doc__)) --> 'First line\n I want this too\n \n Not this, though\n ' so they are in there, and it displays them if you just use print(f.__doc__)
 
5:14 PM
huh...weird. I probably won't be on my home machine today but I'll look back and try some stuff tomorrow if I get a chance
 
@roganjosh I get ['First line\n I want this too', ' Not this, though'] as the output isn't that what's intended?
 
I get ['First line\n I want this too\n \n Not this, though']. Indeed, what you're getting is what I want... hmmm
Ok, obligatory "is this a Spyder thing?" check
 
Do you have 4 spaces on the blank line? Cause that's not present in your above docstring. And makes it break
 
No, it isn't Spyder doing anything dodgy to __doc__. I genuinely don't get the split that I'd expect, but you are. Now I'm even more confused
 
MAJOR UPDATE : SUBPROCESS FINALLY WORKS. Although not an actual solution but one that can be kept for now until a good solution comes up
 
5:19 PM
lol, well at least my ability to parse a regex on the fly is still intact :). I know an older version of Spyder didn't display doc strings when dealing with properties (literally wouldn't print them in @property methods) but I thought they fixed that - yeah, they fixed that.
 
@Peilonrayz It is? It's the space between the two newlines in I want this too\n \n isn't it? Or am I misunderstanding you
 
Thank you so much guys. Lots of love to y'all.
 
@roganjosh Looks like it got stripped then.
You can use (?:\r?\n\s*){2,}
 
I know rich text uses Sphynx but Plain Text is just suppose to be without formatting (in Spyder 3, Spyder 2.8 and below used to do something there)
 
@Peilonrayz Perfect, thanks! Sorry, I'm not sure what you mean by "it got stripped, then", could you elaborate a little please? Is it something specific with .__doc__ you think, or something else?
@LinkBerest I ran it outside of Spyder and still get the same result
 
5:24 PM
aw, very well then :)
 
Peilonrayz modification has made it work for me, though
 
@roganjosh The four spaces are not present in the above snippet. Copy and paste it and you'll get the dostring as 'First line\n I want this too\n\n Not this, though\n '. Notice the missing spaces between the \n\n, presumably as they've been stripped by SE.
 
5:38 PM
How do I return a variable through subprocess.run(), is it stdout arguement or check or capture_output? I am confused.
 
3
A: CompletedProcess from subprocess.run() doesn't return a string

Gianfrancoif you need to have STDOUT lines in an array to better manipulate them you simply miss to split output by the "Universal newline" separators nmap_out = subprocess.run(args = ['nmap', '-T4', '-A', '192.168.1.128'], universal_newlines = True, ...

 
Yes I get this
`CompletedProcess(args=['python', 'flask_process.py'], returncode=0, stdout=b'', stderr=b"2020-06-11 23:13:47.943497: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] `
 
@AshwinPhadke What are you trying to do, exactly? I see Flask in there
I once spent an awful lot of time going down the route of subprocesses to try make the front-end responsive and passing off CPU-work... the front-end user still has to sit and wait because you can't detach the work from the parent process in Flask. Maybe that's not what you're trying to do, but this feels awfully familiar to me
 
@roganjosh I have three params id, location and timestamp that the flask_process file uses, now it is in a subprocess so I need to return those three params after subprocess executes so that I can use it in the main script
@roganjosh geez , I am planning to show maybe a spinner to the user at frontend, as progress bar isn't an option with subprocess
 
5:53 PM
I wouldn't even bother with a subprocess, since it looks like you are going down the rabbit hole I did
Although, thinking about it again some 2.5 years down the line, maybe the subprocesses could leverage more cores if they're not bound to the same core as the parent (I don't know how that is handled, though). Other than that, I don't think much changes from just importing the library into your Flask app and using it directly
 
@roganjosh Yes eventually thinking it to make a single script so as to avoid overhead. Although as you mentioned subprocess has made the processing faster. As it is a just a side project I guess it will work for now but some better methods need to be be in place for tensorflow to terminate it's session so that people can avoid direct system calls to close something that the package can easily do on itself.
 
@AshwinPhadke I run simulations that take 1-2 minutes to complete. When a user submits a problem, I take a snapshot of the relevant db tables, dump it as a JSON with a UUID, write that UUID to a central database, and then just refresh the page. That simulation is now in a queue. An entirely separate program will pick up the pending simulations, solve them and write the results back. So users can just stack up jobs and keep checking back
In other words, decoupling the front-end from the solver. subprocess won't do that, even if it can launch processes on other cores - your front-end will still hang until that process returns
 
I've never seen this particular issue with tensorflow (I have used it with multiprocesses before but not in a flask environment & haven't used it in a while so it can be a problem). I do know that it doesn't reset certain things on purpose (i.e. so you can still use the last graph) when .close is called (or context with used) - which is why tf.reset_default_graph() is a thing.
but without a MVCE, I'm still just guessing at the actual issue
....I've also run into problems like this with Spyder but I don't want to call out Spyder once again :P ;)
 
6:21 PM
Is it necessary to add a disclaimer to our question that it's intended to be a self-answered one?
 
I just realized I've had an open issue on one of my github projects since January last year. Does github not display any kind of notification for that stuff...?
 
@AnnZen No. Provided that your question is phrased as an actual question, then it doesn't matter that you are going to answer it. It becomes trickier when people try to make canonicals because they could be closed as dupes before you can even answer. But canonicals take a lot of work and research
 
@Aran-Fey there are no reminders, as far as I know. You get one notification, once you accept that one that's it.
 
Hmm, it's possible that I forgot about it, but I don't recall ever seeing one
 
I admit to regularly missing github notifications and forgetting about open issues.
My solution are long stretches of demotivation on rainy days. Those give +3 on wading through old repos to look for procrastination opportunities.
 
6:41 PM
your suppose to be able to save notifications in github but it still marks then read (and I always forget to search with is:saved)
 
Find 1+2+3... +n=? with least code.
 
sum(range(1, n+1))?
 
without range
 
sum(xrange(1, n+1)) *hides*
 
lol
my answer is (1+n)*(n/2)
 
6:53 PM
I can never remember whether it's +1 or not...
strangely enough, I only ever find the German wikipedia article on that one. Isn't that something other people tell their little ones on stormy nights, huddled around a bonfire?
 
"ooo, OO, Papa! Tell the one about the quadratic pyramidal number again!"
 
lol
How come some questions are shaded pink?
 
You're following the tag they are tagged with?
 
But all the questions are tagged with the one i search.
 
isn't the sum of the first n positive integers (n*(n+1))/2 or (n**2 + n)/2
 
7:03 PM
That's the same thing.
 
nevermind, I glanced at the screen and didn't group right
 
@AnnZen then you need to be more clear. Do you have a screenshot?
 
@AnnZen Look on the right-hand-side of your screen for the "Watched Tags" box. Presumably you don't have in there but you have one of the other tags
ok... you'll note that you have in that list, and the highlighted question also has that tag, right?
 
I think i understand now, thanks.
 
7:11 PM
wait...wait...wait: did Tim Post quit? <- removed from list an hour ago (still staff on Profile)
(I presume quit over "let go" because I would think that was crazy to do so but....recent history means interpret the likelihood of that guess as you will)
 
Hello
 
@ChrisP Pay attention. I explained that nobody could see your code because you failed to edit it and then just deleted. For the last time, you need to see the formatting guide <-- that's a hyperlink and you need to read it. Next unformatted block and I'll start kicking you because this has gone on too long
 
the effbot docs (or the ones that someone had posted and starred/pinned) have information on that (its one I know I pointed you directly to): look up the CheckButton Widget or just search for that (there are like 10+ SO questions about it)
 
7:31 PM
Can someone remind me what the module that allows us to store an array of indexes so we can easily access them in multiple lists called?
 
@ChrisP Please do. I'm tired of suggesting it. In the meantime, I'm moving those last disembodied comments. You will note that there is a link to the sandbox in the guide I sent you, so you can practice in there before posting here. But you really must know that I'm bored of this now so I'm not joking about the kicking.
 
@ChrisP I missed roganjosh's warning to you, that's why you were kicked regardless. You are way deep in "can't even be bothered to try" territory, and you will be handled accordingly
 
@AnnZen huh? a "numpy" array of indexes (in which case I'd say numpy) or do you mean something else by that?
 
index = [1,3,4] print(index(['a','b','c','d','e'])) Output: ['b','d','e']
 
operator.itemgetter?
 
7:38 PM
That's it!
 
That'll give you tuples probably
 
you also wouldn't be able to pass index directly (you'd need to slice it: operator.itemgetter(*index)(second_list))
 
Thanks. It was only a rough example
 
fyi: with a numpy array you can directly use multiple indexes so that's why I asked earlier :)
 
 
1 hour later…
8:50 PM
def let_count(sample_string):

    L_sample_string = sample_string.lower()
    r_sample_string = L_sample_string.replace(' ','')
Why can i just....(?)
def let_count(sample_string):

    sample_string.lower()
    sample_string.replace(' ','')
 
because strings are immutable.
 
The 2nd on seems from intuition so much more logical
OHHHHHHHH
 
but you can do sample_string.lower().replace(' ','').
 
@MisterMiyagi that bashed my brains
Thanks slowly but decisively i will put all together i read the documentation about 10 months ago but then did zero scripting and i didnt hone any skill
 
That statement still does not modify sample_string, it just returns a lowercased version with no spaces in it.
 
user13682510
8:57 PM
cbg
 
user13682510
Potato
 
@PaulMcG so lower() can be considered a modification? sind all big letters are gone.
cabage
 
@PaulMcG Good point. r_sample_string = sample_string.lower().replace(' ','') it should be
 
In Python, you cannot combine the concepts of "string" and "modification".
 
that is the best because the copy is tanken into the new variable
it is immutable i heard the terminology before but now i am understanding it while scripting what is meant
 
8:59 PM
In sample_string.lower().replace(' ', ''), you are actually making two copies. The first is a copy of sample_string converted to lowercase, and then that copy is copied again, this time removing the spaces.
 
If it was a list it would be no problem ... in fact i was handling dictionaries before that is why i tripped
@paulMcG a copy and then a modified copy again. It is quite abstract to think it
 
@PaulMcG copies?
 
user13682510
@roganjosh Noted.
 
I'm trying to distinguish from an in-place modification. What would you call them?
 
maybe instances...
shallow copies ... yup the 2nd one is being used a lot
 
9:02 PM
Not sure what I'd use, but I think "copy" is a bear-trap?
 
No, a "shallow copy" is something like a_list = [1,2,3, [4,5]]; b_list = a_list[:]
The embedded [4,5] list is shared by both a_list and b_list.
 
user13682510
@AnnZen using lamda?
 
@paulMcg a_list = b_list actually since [start:end]
No start and no end specified in the brackets
 
Yes, and if you do a_list[0] += 1 then you modify only the 0'th element of a_list. But if you do a_list[-1].append(1000), you will modify the embedded list in both - because they are the same list!
 
But if [4,5] which it is an embedded list is included in b_list it can be viewed as a shallow copy
OHHHHH hehehe
 
9:06 PM
@username Why would you say "noted" if you weren't Ann yourself?
 
@ExoticBirdsMerchant think of it piecewise. a = sample_string.lower(); a.repleace() does the same as ample_string.lower().replace(' ', '').
 
@MisterMiyagi yes because both methods are at the same tie applied
I think i need a deeper understanding of muttability. Although simple it can lead to funny mistakes
 
They aren't (even if they are on the same source line). They are done one after the other.
 
Thats why 2 copies
 
@ExoticBirdsMerchant A very important concept to grasp when working with Python and its data structures.
Or "two new str instance constructions using the previous str with some transform"
 
9:10 PM
Yes and to develop a feel what does that mean while writing a script
 
note: using 'dot notation to build streams' is something that is not unique to strings but is used with many objects (basically think of it as "pass object to this method then that result to the next method then that result to the next method .... ")
 
Exotic.upper().count('x') these are 2 new str instances invoked one after another
@LinkBerest probably in mutables too
Hmmm like a package on a band. That is a nice analogy. I like it
 
Its more a functional programming concept then a specific thing in Python (I also use it in C# & Java a lot)
 
VBA has helped me a lot as i struggled to understand objects back then. Now in Python these things repeat themselves
 
note that method chaining is inherently the same as operator chains, e.g. a + b + c will evaluate a + b first, then add the result to c.
 
9:18 PM
Yes from left to right like in algebra. Exactly the same with method chaining
 
9:35 PM
Once one earns enough rep to vote-close, would flagging and vote-closing be any different?
 
flagging only puts the question into a queue where other people can close-vote it, so if you have closing privileges, flagging is just offloading the job to someone else
 
@AnnZen You should no longer be able to flag as off-topic. Everything else is the same.
 
If you have close-vote privileges, any attempt to raise a "recommend closure" flag is automatically converted into a vote to close.
So, no, flagging to close and voting to close are not different once you have close-vote privileges at 3k rep.
Other types of flags still exist, like "not an answer", "very low quality", "spam", "rude or abusive", etc., and these are never converted into votes.
 
i see
 
10:23 PM
@username Same here.
 
10:43 PM
I know this isn't the C room, but I got tricked into looking at the CPython source code coughKevincough and don't understand something. In C, *var is a pointer, right? If so, what does **var do? Are either of them different if they appear in the body of a function vs in the arguments? I'm looking at this in particular...
 
**var is a pointer to a pointer. It is often used as a pointer to an array (since arrays are pointer'ish).
 
Imagine designing a language where pointers and arrays look identical
self-documenting code? Never heard of it
 
@MisterMiyagi okay, I think I understand. Sort of...
 
@MattDMo I recommend not to learn C by inspecting the CPython source code.
 
@Aran-Fey In Go Slices (~Python lists) are copy-by-reference when passed around.
Ken Thompson himself made the Go Slice
 
10:51 PM
@MattDMo char is a character, char* is a string, char** is an array of strings
 
@MisterMiyagi not trying to do anything that complex, I just want to be able to follow a C program's logic. I'm not even close to trying C++
@Aran-Fey is *char a thing? What about *char*? :)
 
syntax error, I'd guess
 
I find proper C++ usually simpler, since it has allows for actual abstractions. Instead of some **char, you may have a vector<string>, for example.
 
That's an italic char. Very special use case
 
@Aran-Fey They do not. Arrays simply decay to pointers when passed to functions.
 
10:53 PM
Very special
 
While I'm at it, any good recommendations on resources for learning C? I started on K&R once, but didn't get that far...
 
@MattDMo The asterisk indicating that it's a pointer can go several different places. char* name and char *name are both valid, and denote a declaration of a pointer-to-char named name. *name would be using the asterisk as a dereference operator, dereferencing the pointer to get the value that it points at (a char).
 
@MattDMo I really like K&R. I also recommend digging into some Unix system and just having fun with a project
 
@CodyGray So arrays sometimes look like pointers? I'm not sure if that makes things better
 
@CodyGray thanks, I just found it
 
10:57 PM
K&R is great, but the problem with it is that you'll be learning a very early version of C, which is not what programmers generally use today.
 
True. It's missing decades of lessons learned.
 
@Aran-Fey Arrays decay into pointers, which means you can treat arrays as pointers. It doesn't mean that they are.
You can treat an array as a pointer to its first element. It is quite natural, if you think about it.
What an array adds is size information, which is lacking in a pointer. (Unless you have a pointer to an array of specific size, which is possible.)
 
Why would you ever want to treat an array as a pointer, though?
 
Isn't there also the difference that an array contains the first element, wheras a pointer would point to the first element?
@Aran-Fey if you pass them around by reference, they necessarily become pointers.
 
The name of the array is the address of the first element of the array. Therefore, the name of an array is a pointer to its first element.
 
11:01 PM
So it's not that you can treat them as pointers, but rather you have to
 
I'm assuming C17/C18 is the standard I should be going for, not C11? Going by the "newer is better" logic...
 
@MattDMo No, C11 is what everyone is using now, and there are almost no changes from C11 to C18 anyway, so you won't be doing yourself a disservice by using C11 materials.
 
@CodyGray but there is no indirection when working with the array, is there? whereas operating on a pointer actually has to look where it points to.
 
@CodyGray okay, thanks
 
@MisterMiyagi That's technically true, but almost irrelevant.
What people forget about C is that it was designed to be a portable assembler. That means that variable names are just convenient, human-readable labels for memory addresses. Just as in assembly, you create a label to correspond to a memory address and then use this label instead of hard-coding the memory address, the C language does the exact same thing.
 
11:03 PM
@Aran-Fey Part of treating an array as a pointer is the strong distinction C has with passing by value vs. reference. Passing an array as a pointer solves passing a potentially large data structure by reference.
 
The C compiler really has no choice but to pass an array as a pointer because the name of the array variable is just a label that is replaced at compile-time with a memory address.
 
yep
It doesn't inherit from object or anything like that
 
A pointer can be incremented, but an array, even if it decays to a pointer to its first element, cannot be incremented.
Since the memory address of the array doesn't change.
What is this "object" of which you speak?
C defines "object" as "a region of data storage in the execution environment, the contents of which can represent values" (C11 §3.15) So arrays are indeed objects!
 
I meant object in the Python sense. That's interesting
 
I'm not following this name vs address logic. If you have a name pointing to an array and you pass it to a function, the function also has a name that it can use to refer to the array. I don't see why passing it to a function has to have any effect on the array
 
11:08 PM
Interesting to see the word object being used in that way that long ago
 
You can't pass names. You can only pass addresses. Names are what we humans use to refer to what the computer refers to using addresses.
@charley It's used in the same sense as "object" has been used for centuries before computers or programming languages were invented.
"A thing"
"that you can maybe do some stuff with because, you know, it's a thing that is."
 
We've been talking about storage in the execution environment for centuries? I think that's a bit romantic.
 
Sure, but names are just fancy labels for addresses, as you said. So the compiler can pass the address behind the name to the function, and the function can hide the address behind a new name
 
@Aran-Fey Why would a function hide an address behind a new name?
 
@Aran-Fey I found this blog post: Are pointers and arrays equivalent in C? helpful to get the distinction. Has some visualisation and assembly to show what is going on.
 
11:11 PM
That's all it's doing is passing the address behind the name to the function. If it's a pointer, then it passes the address of the object that it refers to (which is passing a pointer by value).
 
@CodyGray Uh, that's what function parameters do, no? If I have a function with a parameter y and I pass my variable x into the function, the value of my variable will be visible under the name y inside the function
 
If it's an array, then it's the memory address of the first element in the array, which is basically a pointer.
@Aran-Fey Okay, sure. But that doesn't change the semantics. You've just given it a new name. I fail to see how this solves the problem of arrays naturally decaying to pointers.
 
Well, considering that I have no clue what the problem even is, it would be quite surprising if I could solve it :P
 
haha
The problem is, you have an array, which is just the address of the memory location containing the first element. Subsequent elements come in immediately following locations in memory. You are now going to pass that array (which is just a memory address) to something else, like a function. How do you do it, except by passing that memory address?
 
Of course you have to pass the memory address. But why can you treat that memory address as an array before you pass it, and after passing it you have to treat it as a pointer?
 
11:21 PM
You can pass it and then treat it like an array. You can pass an array then index into it.
 
Metadata. Inside the scope at which the array is declared, the compiler has knowledge that it is an array. Outside of that scope (e.g., in another function blindly receiving an argument), it has no idea that it was an array. It could just as well have been a pointer.
This is very powerful. Consider that I have a function that, say, converts a string into a number. Normally, I would want to pass it the beginning of the string (array of characters).
But what if I wanted to skip some whitespace at the beginning? Or convert the second number in a string containing a tab-delimited list of numbers? Well, now I can do that easily without making a bunch of copies of the string (array), because I can just pass it a pointer to (memory address of) whatever element in the array I want.
If the string-parsing function actually required an array, I would be much more limited, because that sub-array is not itself an array.
 
So let me just double-check: Is it possible for a function to define a parameter as an array or not? Like is void foo(char[] text) valid or does it have to be void foo(char* text)
 
Yes, both are valid, but they mean exactly the same thing.
 
It's just syntactic sugar for the pointer.
 
What's wrong with that?
 
11:25 PM
If you want to pass an array to a function, you need to introduce a layer of indirection: you pass a pointer to the array. For example: char (*text)[128]
Because it's now an array, it has a size associated with it (as arrays do, unlike pointers). That size (length of the array) in this case is 128.
 
pythonspot had an article that very briefly mentioned inner classes are something too generally avoid using, why is this the case
 
@Skyler they have practically no advantage over top-level classes but suffer from weird quirks of class scopes.
 
@Skyler I'm not sure; for opinions like that, you generally need to ask the original author. There's nothing particularly special about inner classes. There's nothing you can do with them that you cannot do with top-level classes. The only advantage is scoping. Which you can either consider an advantage (increased encapsulation, logical grouping, readability, etc.), or disadvantage (confusing).
 
@CodyGray Okay, I understand that sometimes it can be beneficial to work with a pointer rather than an array. But it seems like often you don't have a choice in the matter. Is there a reason why C can't pass that metadata to functions?
Is it because the size of the array is only known at compile-time?
 
@Aran-Fey I showed you a way, actually, by introducing a layer of indirection.
But normally, C will not do this, because passing metadata adds overhead, and in C, you only pay for what you need.
If something is known at compile-time, it is trivially known at run-time. All you have to do is compile it in. :-)
Going the opposite way is, of course, harder.
 
11:30 PM
@Aran-Fey The point is that arrays are compile-time constructs. Their metadata does not "exist" at runtime. But function arguments are runtime constructs, and the compiler cannot know up-front what arrays are passed to a function.
 
is it still considered inner classes if you use a collection of classes (like making a list of "inner" classes in a constructor)
 
This is one reason why 0-based indexing works so well in C, in which all the array elements are contiguous in memory. From the pointer to the array, you can find any element array[i] as *(pointer + i*sizeof(array_element)). So when i is 0, you are the the first, or 0'th, element.
 
@Skyler yes, but that's an even worse idea usually.
 
I do understand the argument that you could want to type your parameter like:

fn(foo []arr)

It's not unreasonable that fn then definitely takes an array.
 
@Skyler Do you have an actual use-case that makes you consider nested classes?
 
11:31 PM
Hindsight is 20/20
 
i was just reading a bit about inner classes in general to get an idea of them
 
Ok, I think I'm starting to get it. Although now I'm confused why I'm learning C when it's already past 1AM
 
Goodnight
 
Is there a better time to learn C?
 
3AM?
 
11:33 PM
Because C == 3? That's the only answer that makes sense, isn't it.
 
@MisterMiyagi no >:I
 
5AM, then
 
but i guess lets think of a toy model with a supply chain where factory objects pass goods objects between them, each factory has machines that can interact in certain ways with certain goods
 
For what it's worth, I like "Modern C" by Jens Gustedt. I haven't checked to see if that's what the canonical SO Q&A recommends, and it's not perfect, but it's a good general introduction, and as the title suggests, much more "modern" than K&R.
 
wouldnt assigning a bunch of machine inner classes that handle goods object make sense?
 
11:36 PM
Using "inner" instances makes sense.
There is no need for the classes themselves to be "inner".
 
Jens's book explains all of this stuff about arrays and pointers quite nicely, almost certainly better than yours truly.
 
oh ok, since the quick primer i read didnt really draw that distinction i wasnt too sure if inner instances vs inner classes were different things pythonspot.com/inner-classes
 
@Skyler Consider that nested classes only have a functional difference when they depend on scope local information. Since each class has only one scope, it's information is de-facto global – meaning it cannot introduce information unique to its scope.
# compare this to function local class definitions
def factory(base):
    class Bar(base):
        _base = base
         def __repr__(self): f"A {self._base} comes into a Bar"
    return Bar
 
basically when data isolation at a scope level is preferable nested classes can make sense
 
every time factory is evaluated, it creates a new Bar variant.
 
11:40 PM
hmm
 
in contrast, a class scope is evaluated only once. You can create only one variant in a class scope – which is exactly the same restriction as on global scope.
 
oh ok, so if you make an inner instance it can accept information that isnt global to the class thats using it, but if you make an inner class it can only take in info that was passed through the class, so its already "global" to the class
also, in that link i sent technically thats more what you are describing as an inner instance then a true inner class right
since its just making instances of the other objects in the Human object
 
Hi, I'm new and really stumped. Any spaCy folks out there?
 
@Skyler the linked tutorial is very weird. The text and code describe different things. Not to mention that the code is basically broken.
 
@Skyler I don't think the author of that code had any clue what they were doing. They're talking about composition, but calling it "inner classes" for reasons that will forever be a mystery
Also that if __name__ ... inside the class body is painful
 
11:48 PM
Yeah, the first example would not run correctly.
 
@Aran-Fey I think the tabbing is messed up. None of the classes are accessible from self.
 
I would be SUPER grateful for a pair of eyes on this stackoverflow.com/questions/62266678/…
Thanks.
 
@Peilonrayz Oh wow, I didn't even notice that self.! Crazy how many people who write python tutorials can't even get the indentation right!
 
@N.Craig Note that def and lambda both produce objects of the same type. If you have a def foo(x): ..., there is no need to wrap it in a lambda x: foo(x). Just use foo directly.
Aside from that, I don't what is the question. It seem there are multiple sub-question (.is_stop, filtering stopwords, ...) and the desired output is not clear to me.
 
wim
We need a witty name for the lambda x: foo(x) anti-pattern. I see it all the time on main.
 
11:58 PM
Matryoshka pattern: If you look inside the outer function, you see the exact same thing again
6
 
00:00 - 16:0016:00 - 00:00

« first day (3526 days earlier)      last day (1421 days later) »