« first day (3859 days earlier)      last day (1072 days later) » 
02:00 - 20:0020:00 - 00:00

2:31 AM
I believe you're supposed to be able to run code in the console using PyCharm between breakpoints but it always appears in green text and it doesn't really do anything. Anyone encountered this?
This is while Debugging the program
 
 
1 hour later…
3:48 AM
hey guys
any charts expert in the house?
this plot is a 2D Histogram Contour in plotly
does 'count' here mean that total_bill 12.5 and tip 2.5 happened 34 times ?
 
from the docs plotly.com/python/2d-histogram-contour I would believe that is the case "...x and y coordinates into bins, and applying an aggregation function such as count..."
 
thats crazy, because when I count total_bill 12.5 and tip 2.5 in the pandas df that has the data, I dont get 34!
one sec ill show you how I count total_bill 12.5 and tip 2.5 in df.
 
any panda user knows how to avoid truncating of columns at saving?   pd.set_option("display.max_rows", None, "display.max_columns", None)      has not helped, whole dataframe gets correctly saved, yes, though long rows of single columns get still truncated.
 
in fact, there are no rows where `total_bill` is 12.5.
`df.loc[df['total_bill'] == 12.5]` returns empty df
 
I looked up the docs to check what you said, other than that I have no idea :/
 
4:01 AM
I think whats happening is that x and y are getting grouped in buckets/bin.
but the hover box is so misleading, it should indicate the bucket/bin range (e.g.: 10-12.5).
 
it did mention it does some binning
 
@python_user true, but the default hover box (see pic above, box in gray), is misleading.
thanks! @python_user
 
tbh you figured it, I still have no idea what is happening ;)
if its anything check the docs before you ask something, usually it has the answer you need, although sometimes it is not straight forward
 
I will still have my thanks though :p
 
4:50 AM
Does anyone have links, how to write a master script with a python, so that it runs all steps, inputs, etc in one run for the pythn scripts?
 
5:15 AM
hi there,
 
5:30 AM
Does anyone know exactly what chuck size is? Is it how much data is written to the system at a time?
 
 
2 hours later…
7:28 AM
Chunk size? "Chunk" tends to be used to lumps of data of almost any convenient size. We'd need a bit more context tp determine what the case is for a specific chunk (!) of code ...
 
@SinkingTitanic that's what histograms are. Bin counts.
So imagine a 2d grud of bar plots, then draw a contour over this data. It's indeed misleading if you look at values. It's meant to convey the overall "spatial" distribution.
 
7:52 AM
looking django help
model, ``` class BlogCategory(models.Model):
    category_name = models.CharField(max_length=150)
    def __str__(self):
        return str(self.category_name)


class BlogPost(models.Model):
    title = models.CharField(max_length=255)
    category_name = models.ForeignKey(BlogCategory, on_delete=models.CASCADE)
    def __str__(self):
        return str(self.title)```
 
Cbg. This is in flask helper and I get too many files open. Shouldn't the file close automatically when the function returns?
relevant snippet is:
if current_app.use_x_sendfile and filename:
        if file is not None:
            file.close()
        headers["X-Sendfile"] = filename
        fsize = os.path.getsize(filename)
        headers["Content-Length"] = fsize
        data = None
    else:
        if file is None:
            file = open(filename, "rb")
            mtime = os.path.getmtime(filename)
            fsize = os.path.getsize(filename)
            headers["Content-Length"] = fsize
there the file = open(filename, "rb") gives the os error too many files open
 
view,
def Index(request, *args, **kwargs):
    blogCategory = models.BlogCategory.objects.all()
    blogPost = models.BlogPost.objects.all()
    context = {
        "demoJson": DemoJson(),
        "blogCategory": blogCategory,
        "blogPost": blogPost
    }
    return render(request, 'index.html',{"context": context} )
 
haha well unfortunate timing, two people posting a large code chunk
 
and template,
 <div class="blog__wrapper">
        {% for category in blogCategory %}
        <div class="card">
            <div class="card__wrapper">
                <h3>
                    {{category.category_name}}

                </h3>
                <div class="card__body">
                    <ul>
                        {% for post in blogPost %}
                        <li>
                            {{post.title}}
                        </li>

                        {% endfor %}
                    </ul>
 
@Hakaishin only one of them posting three pages of code
 
7:58 AM
I am unable to make the template for loop to make a category and belongs to category blog post will there
I got output: prnt.sc/12r6w5f
 
@AndrasDeak hmmm, well you can just not click on the see full text if it bothers you, but we
 
> If your code is longer than about 12 lines, use an external paste tool such as dpaste.com.
 
because the relevant part doesn't make sense without the context
 
here, nesting for loop not giving the result of there category
 
Nikhil's blocks are also borderline, but at least they fit in half the screen if I expand it
@Hakaishin I can move those too if you want
 
8:02 AM
Right I forgot. Would be nice to get a prompt like if the message is too long, code is too long. I'm kinda surprised it doesn't give you that prompt, because how can it differentiate between code and text
 
It probably could but nobody bothered.
 
which makes me wonder, is there some js which counts button presses and that's why it doesn't catch long copy pastes messages, because intuitively I would just check the message size periodically, but that doesn't seem to be how it's implemented
 
here is of my code: dpaste.com/7Z4HKJZMJ
I will be very appreciative if I get a solution of mine, I have read so many StackOverflow but not get the exact solution.
 
@Hakaishin not sure what you mean
 
@Hakaishin I'm wondering about the leading if file is not None – is there some scope that keeps a/some file alive longer than the function?
Other than that, "too many open files" should actually say "too many open file handles" – which includes things like pipes, sockets, and such.
So if you are doing a lot of network'y things, that too can push you on the brink of that error.
 
8:18 AM
@AndrasDeak when you type a long msg you get too long msg prompt and can't send it. When you copy paste a long code block you don't get that prompt. Which means it doesn't just check the size of the msg but also how it got entered.
@MisterMiyagi maybe, but that would be weird for the send_file function. Maybe for streamed files or something like that. But I just send a simple image. I'm installing a second raspberry to make an mvce. because on my pc I can't reproduce
 
Simple solution: Increase your file limit via ulimit/systemd/....
 
@Hakaishin no, that's because of newlines. Add a newline to a manual message and you won't get the prompt.
post a line of minified JS and you'll probably get the prompt
 
@MisterMiyagi Simple and not solving the problem but just delaying it
I only show 2 images, but after 200 hundred calls I get the error. So it doesn't close them and I suspect it's a bug in the werkzeug server and I would like to fix it
 
8:39 AM
@Hakaishin Sadly, the only thing I can offer with what you've shown.
 
got solution, txt
 
cbg folks
 
cbg
 
8:59 AM
hmm I can't reproduce on a second raspi, so strange
 
9:21 AM
cbg guys, there is no way a print "something" will work on Py 3.x right? if so how am I getting 3.2.0 when I use print platform.python_version() here 101computing.net/pixel-art-in-python
 
@python_user 3.2??
None of this sounds right, why do you still have the tab open? :P
 
3.2.0 was the output for print platform.python_version(), and that was for a question on main, I found out it is an old version on the IDE, but I wanted to check the version and hence this confusion
 
Python 3.0: "The print statement has been replaced with a print() function"
 
that confirms it, but idk how that statement worked and gave that result though :/
 
What does print 1, 2 print?
 
9:27 AM
run this instead. print platform.python_version, "blahblah", "test"
and you'll probably spot something fishy going on
(note that i didn't use brackets. that's deliberate)
 
print 1, 2 - > 1 2
 
@python_user huh
that's python 2 print
 
@ParitoshSingh <function <native JS>> blahblah test
 
@python_user That's not CPython.
<function <native JS>>
 
9:28 AM
JSython
 
ohh, so different rules there I see
 
@python_user well there shouldn't be
print 1, 2 should be a syntax error on all python >= 3
 
@python_user Just some alternate implementation not adhering to the spec.
Since they're claiming 3.2, I guess they started out with 2.X and made some superfluous changes only.
 
calling it 3.2 is a bit of a stretch
 
note that they do seem to have a separate "genuinely python 3" version, that might be paywalled. trinket.io/features/python3
 
9:31 AM
See if they have concurrent.futures. It was added in 3.2.
 
thanks for the insight guys, I stumble upon trinket io and this is the first time I bothered checking the version, sys.version didnt work, should have suspected from that
 
@ParitoshSingh Nice, 3.6.6. That's practically not outdated yet.
 
@AndrasDeak ImportError
 
@python_user How about sys.version_info? It was changed in 3.1 so it should be old.
 
@AndrasDeak Didn't work. "no such attribute"
 
9:33 AM
no sys at all. no concurrent. they provide a list of packages. it's small
 
So it works just like you'd expect python 2 plus JS to work
 
sys does work, it doesnt have all attributes
 
what's weird is, the imports dont always downright error out
yeah, like with sys
 
that turtle module is sure as heck pre 2.6, as the question I answered was based on that
 
 
3 hours later…
12:13 PM
Current status: working on a problem that's so problematic, I can't even describe what the problem is
 
i feel you
 
It involves... integers. I'm sure about that.
 
@Kevin Seems problematic.
 
Fellas, any tips about integer related problems?
 
Yeah: Don't.
 
12:15 PM
Wisdom
 
Probably not helpful, eh?
 
Switching to a language that doesn't support arbitrarily sized ints makes the search space much narrower :P
 
Good idea, I'll pick out a flavor of asm that only has one byte registers.
 
use floats
then blame any further issues on precision issues
 
@MisterMiyagi It's a helpful memento mori that the only perfect program is the one that you never actually implement
 
12:19 PM
morning cabbages, folks!
 
blame caches :)
 
I remember reading an article proposing a one byte floating point format... I should try to dig that up
 
I need some holidays, but the weather is terrible, so I don't want to take some
 
@Kevin quarter precision
 
I think I was thinking of en.wikipedia.org/wiki/Minifloat. The smallest fraction it can represent is 1/8.
This article related to my problem is mentioning "NP hard" an awful lot
 
12:45 PM
Do you just take the eighth of eighths to get smaller floats?
 
You would need some kind of MegaMiniFloat to do such a thing
 
How does Python IDLE handle syntax highlighting?
I thought it used pygments.
 
1:01 PM
IDLE runs on tkinter, right? tkinter text boxes can contain multiple colors of text. No external library required.
 
Hmmmm but the identification of it?
Maybe re.
 
Seems like idlelib.colorizer.py contains some regexen, so that's a decent guess
 
1:14 PM
@Kevin Cool
 
regex is a quite typical approach for lexical analysis. In other words, it's a good way to group and categorize character sequences in the source code as identifiers, numbers, string literals, operators...
 
Hi there,
In Django, Is there any way to remove dublicate value in template for loop?
so how do I make hindi, saruk?
I am getting output: hindi,hindi, saruk
 
@CoolCloud I'd be surprised if stdlib relied on third-party libraries
 
@AndrasDeak Hmmmm, re dint occur to me at all
Perpahs because I have not used it before
 
1:41 PM
@NIKHILCHANDRAROY Try to remove the duplicates before you pass it to the template.
 
how do I do?
I tried in view but it's still same
artist_name = models.AlbumMusic.objects.filter(artist_alphabet=alphabet_type)
    artist_name_single = []
    for ar in artist_name:
        if ar not in artist_name_single:
            artist_name_single.append(ar)
 
Are you sure you're displaying artist_name_single and not artist_name?
 
1:59 PM
any solution?
 
Nope, as far as I know your program should work perfectly
 
but, I have tried several times not working
I guess,     artist_name = models.AlbumMusic.objects.filter(artist_alphabet=alphabet_type)
this can be issue,
but not understanding
 
Life's mysteries are endless
 
2:18 PM
I have following small flask app: pastebin.com/Avmdqk6U Now calling set_foo_bar about 1-2times a second works fine for 1000-2000 times then after crashing once crashes continuously with following message:
[2021-05-10 15:21:03,358] ERROR in app: Exception on /set_foo_bar/1/2 [GET]
Traceback (most recent call last):
  File "/home/usr/project/lib/python3.9/site-packages/redis/connection.py", line 559, in connect
  File "/home/usr/project/lib/python3.9/site-packages/redis/connection.py", line 584, in _connect
  File "/usr/lib/python3.9/socket.py", line 953, in getaddrinfo
OSError: [Errno 16] Device or resource busy
I wouldn't mind that getaddrinfo is busy every once in a while, but it stays busy after being busy once. Am I running out of ports/sockets? This sounds impossible but who knows
 
2:40 PM
@Hakaishin why do you have StrictRedis and percent formatting?
 
because I copy pasted it from a SO post :P And strictredis is just redis, it's just there for backwards compatibility also the string formatting doesn't cause any issues
or does it?
 
Exactly
@Hakaishin no
Just anachronistic
 
What's weird is there seems to be something missing between calling set_foo_bar and redis connection. I guess it happens in the red pub method, but I'm not getting any wiser by looking at it
 
How do webapps work? Do they spawn threads? Or processes?
 
I don't know. but I know the SO post said you need threaded=True when starting the server otherwise the stream won't work
ok yeah the connection call happens in publish. I just would like to know what resource or device is busy
 
2:46 PM
I don't know what I'm talking about but you could try specifying a connectionpool with a fixed port
 
Looking at the code it just uses the default one:
class Connection(object):
    "Manages TCP communication to and from a Redis server"

    def __init__(self, host='localhost', port=6379, db=0, password=None,
                 socket_timeout=None, socket_connect_timeout=None,
                 socket_keepalive=False, socket_keepalive_options=None,
                 socket_type=0, retry_on_timeout=False, encoding='utf-8',
                 encoding_errors='strict', decode_responses=False,
                 parser_class=DefaultParser, socket_read_size=65536,
 
> Behind the scenes, redis-py uses a connection pool to manage connections to a Redis server. By default, each Redis instance you create will in turn create its own connection pool. You can override this behavior and use an existing connection pool by passing an already created connection pool instance to the connection_pool argument of the Redis class. You may choose to do this in order to implement client side sharding or have fine-grain control of how connections are managed.
 
hmmm I guess it's worth a try
You meant like this?
pool = redis.ConnectionPool(host="localhost", port=6379)
red = redis.StrictRedis(connection_pool=pool)
I still think this is the same as the default args but let's try
I mean it feels so weird that it works for 1000-2000 times and then suddenly is busy forever
 
@Hakaishin yeah, that's more or less what the docs does pypi.org/project/redis/#connection-pools
 
3:12 PM
hmm still the same behaviour
 
OK, thanks
 
If I inherit from collections.abc.MutableMapping or collections.abc.MutableSet, should I call super().__init__() or nah?
 
Yah.
 
# chosen by fair coin toss
 
These classes sure don't get a lot of love. MutableSet doesn't even implement an update method.
 
3:23 PM
YouWontBelieveItsNotImmutable
To be fair I'm pretty sure I didn't even know sets had an update method.
 
TIL: MutableSet.discard "should return True if the element was present and False if it wasn't."
Ah, there's a reason for missing update: "Unlike set.__ior__; MutableSet.__ior__ accepts an arbitrary iterable and therefore MutableSet.update is redundant."
 
The toggle method wasn't a bad idea, wonder why that one didn't make the cut
So set.update came before abc.MutableSet, and then Guido decided update wasn't necessary? Weird move
 
3:39 PM
Honestly, it's weird quirks like these why I practically never use collections.abc these days.
 
Python's a mess. Python 4 when?
 
Once they figured out the typing mess.
 
So never
 
cbg, I'm so confused as to what's going on... 👀
 
3:45 PM
just make python 4 be 0.4 and start breaking things
 
@12944qwerty It makes sense in some context.
Now don't ask me which...
 
Maybe, but I think I need to read higher up to understand a bit more...
 
definitely not nullcontext
 
Read up the abstraction ladder.
 
4:00 PM
Is there a name for this concept: S is a recursively defined set. the tuple (1,1) is a member of S. If (a,b) is a member of S, then so are (a+b,b) and (a, a+b).
here is a little script that visualizes the members of the set close to the origin.
 
Isn't that just N^2?
 
As in, is it the set of all integer pairs? I don't think so. (2,2) isn't a member, for instance.
 
Ah, I see.
 
I suspect it has something to do with coprime-ness, but it doesn't quite match the graph at en.wikipedia.org/wiki/… AFAICT
 
@Kevin first half sounds like congruence
If a = S mod b then so is a + b
 
4:12 PM
Realized that if you multiply the first row of cofactor matrix with the first row of the main matrix, you will get the determinant of the main matrix
Any existing rules or properties that govern this?
 
Rnj
hey guys I was able to debug a py file in vscode. But suddenly it started giving me error No such file or directory: '/home/rnj/.local/share/virtualenvs/venv-Sn4ov4BM/lib/python3.8/dist-packages'. I then checked if I can run the python exp.py and it ran. So what might have gone wrong?
 
@CoolCloud what's the cofactor matrix?
Ah, I know
It must be the Laplace expansion en.wikipedia.org/wiki/Laplace_expansion
 
@Rnj Perhaps your virtual environment got cleaned up somehow before you were done using it
 
@AndrasDeak Interesting, let me play around and see for awhile
 
@Kevin what does it exactly mean by cleaned out? corrupted?
never happened earlier
 
4:20 PM
More like, deallocated. Shut down and erased.
 
but then how python exp.py is working?
 
That command doesn't use a virtual environment, unless you set one up beforehand
 
Yeah ... I thought so ... but then any workaround? I restarted vscode making it reload extensions and reconnect to pipenv ... still same error
 
Maybe you can switch to a different environment that's still alive. I'm not too familiar with VSCode's interface, but code.visualstudio.com/docs/python/environments looks useful. Try to "use the Python: Select Interpreter command from the Command Palette". That should show a list of environments you can pick.
 
Hello....Has StackOverflow changed default font or my firefox is broken again?
 
4:26 PM
Hmm, the main site's font looks... A little different to me? It's a small enough difference that it could be my imagination.
 
@AndrejKesely yes
160
Q: We are switching to system fonts on May 10, 2021

Aaron ShekeyTL;DR We’re shipping system fonts as our default font stack. We plan to do this on May 10th, 2021. What? We’re planning on specifying system fonts on Stack Overflow and the Stack Exchange Network. On macOS and iOS, you’ll see things set in San Francisco. On Windows, you’ll see Segoe. On Android y...

 
Now it uses Ubuntu font
 
Rnj
I felt its segoe and consolas
 
@AndrasDeak Ah ok, i see :) Hmm.... let's read the comments
 
@Kevin How come I just realized this right now
I would like to have roboto though
@AndrasDeak Well yea that sums it up
Did you know this already or did you look it up? If yes, how did you search it
I did all kinds of weird searches but couldn't find something :P
 
4:33 PM
@CoolCloud I knew the reason but I had to look up the English name. We just call it the expansion theorem. And there's the skew expansion theorem.
 
That's nice, just sad that someone already found it out decades ago :p
 
Decades, yeah, technically.
 
It is quite useful for me, because to find the inverse we use adjoint of a the matrix and the divide it by the determinant, instead of wasting time on more calculation I just have to multiply the cofactor with the main matrix now
Well I could also do the column of the adjoint with the row of the main, and vice versa too? I suppose
 
Okay it is going to take some getting used to, the new font :0
@AndrasDeak Laurel :PP
 
4:38 PM
@CoolCloud probably not
Check 2x2, 3x3
 
Ummm for 3x3 it works
Technically its the same thing, one is the transpose of the other, so your multiplying rows with columns. Instead of the default rows with rows
 
@CoolCloud ah, of course. I didn't notice the "adjoint". Then absolutely. But heads-up: this is a very niche meaning of adjoint. Outside matrix inverses adjoint means conjugate transpose.
More often this is called the adjugate, I think, to distinguish it. en.wikipedia.org/wiki/Adjugate_matrix
 
Oh okay, Ill use adjugate then, seems nice :p
 
5:13 PM
I was thinking, what would be the LC version of this
for i in range(2):
    for j in range(3):
        if (i+1)==2 and (j+1)==3:
            break
        print(i+1,j+1)
I came up with
lst = [[(i+1,j+1) for j in range(3)] for i in range(2) if not ((i+1)==2 and (j+1)==3)]
But not the same output 😬 My nested LC is broken I guess
 
list comprehensions don't have a native way to emulate break
 
they do break code in a rather intuitive way however
 
@Kevin Does not do the job? Of taking every other element?
 
In this case, yes, but only because you're breaking at the very last iteration
 
[
    (i+1, j+1)
    for i in range(2)
    for j in itertools.takewhile(lambda j: not (i+1 == 2 and j+1 == 3), range(3))
]
 
5:18 PM
>>> [(i+1,j+1) for i in range(2) for j in range(3) if not ((i+1)==2 and (j+1)==3)]
[(1, 1), (1, 2), (1, 3), (2, 1), (2, 2)]
 
@Kevin Oh, my order was messed up!
 
Yeah, and it's also a bad idea to have (j+1)==3 in a conditional that's outside of the list comprehension that creates j
 
If you wanted to retain the nested list comp structure, move the conditional inside the second list comp
 
I thought we needed to put list inside a list, NVM :p
@Kevin This is simpler
 
5:21 PM
>>> [[(i+1,j+1) for j in range(3) if not ((i+1)==2 and (j+1)==3)] for i in range(2)]
[[(1, 1), (1, 2), (1, 3)], [(2, 1), (2, 2)]]
 
By the way, would anyone mind removing all that chatter about tuple unpacking from the tsarboard? (I caught the typo, but I'm leaving it in because it's funny)
 
@Aran-Fey yes, comrade
 
Thanks, comrade
 
huh, just got the joke
 
Oh, okay. Did not see that one
 
5:23 PM
Although comrades and tsars rarely overlap in time. Not for lomg.
 
@Aran-Fey Costed me a google search for tsarboard :P
 
yeah, were I less geographically / historically challenged I would have said something about the slight anachronism
 
@Aran-Fey itertools have alot of weird stuff, never heard of takewhile. Gotta go through its documentation
 
👍
 
6:27 PM
@Aran-Fey they're gone now, right?
 
yup
 
OK. It wasn't me.
 
Rnj
6:59 PM
I was doing:
df['log_volume'] = np.log(df.volume*df.close) if ((df.volume*df.close) != 0) else 0
But it gave error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Whats going wrong here?
 
Hmm. What does print((df.volume*df.close) != 0) display?
 
@Rnj google that error message first
Choose one from the two dozen posts on Stack Overflow, read the top three answers. If it's still unclear, come back and we'll explain further :)
 
Rnj
@Kevin rows of form:
index  True / False
@AndrasDeak it seem that this error is caused by many reasons ... I already went trough three posts
 
So whats new in python?
 
7:06 PM
@Rnj Well, that's not good. anything you put inside that if (...) clause should be either True or False or something with a non-ambiguous truth value, for example a scalar number.
 
Rnj
is it that such if-else assignment is not allowed in data frame context? I ended up doing:
df['log_volume'] = np.where((df.volume*df.close) != 0, np.log(df.volume*df.close), 0)
But it still gave me RuntimeWarning: divide by zero encountered in log
which is what I intended to avoid with this snippet
But it still occurred.
 
@Mikhail We're getting better Syntax Error messages, soon, that's exciting... Or did we just get that? We are or have been getting it.
 
@Rnj that's the right solution, more or less. The problem is that bool(ser) is meaningless for a pandas Series or a numpy array. So whenever bool would be called implicitly, this error will be raised
@Rnj you get that warning because the second argument of np.where gets executed before the call to np.where, so there are nans in the second argument. However the first argument's condition will ignore these values in the output of np.where.
the alternative to this is assigning the values in two rounds using boolean indices
nonzeros = df.volume*df.close != 0  # TODO: use np.isclose instead?
df.loc[nonzeros, 'log_volume'] = np.log(df.volume[nonzeros]*df.close[nonzeros])
df.loc[~nonzeros, 'log_volume'] = 0
something like that (untested)
 
np needs a with i_know_what_im_doing: block that can silence warnings ;-)
 
the warnings module has that I think :P
 
7:15 PM
My name is better though >_>
 
and I'm not sure numpy.testing should be used in the wild
Although this seems like a documented API to test numpy things, so it has to be stable.
I couldn't really find any warnings asking not to use numpy.testing in production, so it's all good.
 
suppress_warnings emits a DontUseMeInProductionWarning, but it gets suprressed
 
7:32 PM
I thought you were serious for a whole minute :|
 
My favorite yuks are the ones that are ridiculous yet plausible
If HTTP servers can emit "I'm a teapot", then why can't we have a warning that never ever gets displayed
 
I wouldn't put it past Python
 
02:00 - 20:0020:00 - 00:00

« first day (3859 days earlier)      last day (1072 days later) »