« first day (3075 days earlier)      last day (1872 days later) » 
00:00 - 19:0019:00 - 00:00

12:21 AM
any ideas on how to use python selenium and save a screenshot into memory?
got it
 
 
2 hours later…
1:59 AM
class Login(APIView):

    def post(self, request):

        # parse code from query string

        code = request.data.get("code")


        if code is not None:

            r = requests.post(

                # a token exchange endpoint

                OAUTH + "/as/token.oauth2",

                {

                    "code": code,

                    "client_id": "documents",

                    "client_secret": SECRET,

                    "grant_type": "authorization_code",

                    "redirect_uri": REDIR
I'm using an OAUTH flow to sign in users in my backend
The first time users sign in the frontend, the backend creates a corresponding user object
However, the second login I get a 403 error
Any ideas why?
Could it be because the user is already logged in?
And if so is there a way to override Django to ignore sign ins even if already signed in?
 
 
6 hours later…
8:49 AM
@Aran-Fey Is that really a course?
 
no clue tbh
If it's not something the OP can drop out of, I feel sorry for them
 
might just be some really crap code challenge site
you're probably on to something with that "classmethod really means method" question
 
9:10 AM
Hi!
 
hello
 
Hello Everyone I need a help from one of you
date_cols = ['CLOSE', 'D_MONTH', 'OPEN']
gbl = globals()
for i in date_cols:
gbl[i] = pd.to_timedelta(min(data_frame_1[i]), unit='s') + pd.datetime(1960, 1, 1)

the output looks like this:
>OPEN
Out[520]: Timestamp('1993-02-12 00:00:00')
>CLOSE
Out[522]: Timestamp('2009-04-30 00:00:00')
>D_MONTH
Out[523]: Timestamp('2018-01-01 00:00:00')

type(OPEN)
Out[518]: pandas._libs.tslib.Timestamp

The output is a time stamp but I want a output as a dataframe like below:
Attr Min_Date
CLOSE 2009-04-30 00:00:00
 
9:50 AM
cbg
How to run a APScheduler job on the first day of every month?
 
@FrankAK I've never seen this module but from the description and name cron might be appropriate
 
10:10 AM
Oh, Really. APS is very popular.
 
Hi Deak My query has been moved to Python Ouroboros - The Rotating Knives will some one from the group look into it
 
I looked into it
it is indeed there
 
ok thanks
 
I was thinking that when we have a job do not run frequently, it's difficult to make sure it's alive after one month. so I decide to make it run every day, but I will add some logic to check some status (i.e is_already_on_this_month), if true pass, else do something.
 
 
2 hours later…
12:35 PM
How do I print a square in Python? I'm not allowed to use loops, functions, operators, identifiers, whitespace, or Python.
 
been to the front page again?
 
Don't need to today, I woke up pre-rustled
 
print("[]")  # pretty close to a square
 
I see python
 
I think I'm supposed to telekinetically direct cosmic rays onto my hard drive until the output spontaneously forms
Is there a module for that?
 
12:41 PM
Theoretically, any module can perform such a task, given enough cosmic rays and time
also: $ python -c "print_square()" || echo ∎
Don't need python for this version to run :p
 
I think I can get partial credit if I can claim that print("[]") is a syntactically valid program in a language other than Python. "Listen, if you pass this to python.exe, I can't guarantee that it will raise a SyntaxError. Not my department."
 
true
accidental polyglot
 
None come to mind, though. Why don't more languages use print?
 
perl?
 
Language devs want their project to feel all CS-y so they have to pick weird names like puts or console.log or std::cout >>
 
12:47 PM
$ perl -e 'print("[]")'
[]$
(that dollar sign is just the $PS1 with a missing trailing newline)
 
+[--->++<]>+++++.++.
 
Oh, good. I know perl likes its prints unparenthesized and I wasn't sure if it was legal to throw a superfluous pair in.
More specifically I didn't know if you could have print followed by ( with no whitespace in between
 
I would be surprised if any language forbade that
 
You never know if a language has a tokenizer that was written in ten minutes
(glances at KevinScript >_>)
((But actually KS doesn't require whitespace in any context))
 
1:21 PM
urgh, python is exiting on my event-driven script, where it should just wait instead
not sure how to tell it to wait, without blocking everything
 
shouldn't there be something that .run()s, creating the event loop?
 
well, the event look I'm making quits, but there's still internals running
although python doesn't seem to care about them
or rather, that event loop is ran as a task
which listens to websocket messages
 
Isn't "the event loop quits" the problem? Is that a normal thing?
 
and I guess python doesn't wait for tasks to quit?
 
Unless you're using threading and/or multiprocessing, it shouldn't be possible for Python to reach the end of your script while other parts of your script are still running
 
1:25 PM
right
 
Is async that different from threading in this regard? I know nothing about async.
 
Took me a while to converge to sensicality there
My (childishly incomplete) understanding of async is that it has as much power as yield.
 
@AndrasDeak "Async" is "cooperative multi-tasking", where tasklets ("microthreads") perform work then yield execution to the event loop (or trampoline) which can then schedule the next tasklet.
 
yield can't singlehandedly make your program threaded, so neither can async
 
@amcgregor that doesn't answer my question...does it?
 
1:28 PM
Where normal threads get "N opcodes" of quanta (time, based on the GIL), microthreads get as much as they take.
 
(confidence: 70% unless someone says otherwise in which case 0%)
 
or you're saying "no, async should finish before the interpreter may quit"?
 
I think that internals (that happened to be called by async) are threaded in my program anyway
 
@AndrasDeak It somewhat does; as long as the event loop (or trampoline) is alive, your application is alive. If a tasklet is active, your program is active running that tasklet until such time as it yields back to the trampoline.
 
for example, the websockets package
 
1:30 PM
E.g. in coroutines/microthreads/tasklets, there is no concept of a "daemon thread". Or any background execution of any kind, really.
 
Even if I'm correct, it may not be a useful observation that yield isn't as powerful as threading. If the problem is "my program completes before my task/tasklet/thread/coroutine/generator finishes", that could just as easily occur with coroutines as it can with threads. So maybe I'm just clouding the waters.
 
@amcgregor OK
 
c:\Users\Kevin\Desktop>type test.py
def f():
    print("Coroutine started.")
    yield
    print("Coroutine finisehd.")
g = f()
next(g)
print("Program finished.")

c:\Users\Kevin\Desktop>test.py
Coroutine started.
Program finished.
Tadaa, a thread-free program that doesn't finish executing all its code
 
Python 2.5 introduced sending values to the generator. That made generators a full-on alternative coding paradigm for the proper implementation of coroutines, where coroutines (embraced fully) can replace virtually all other code flow. To say "yield" is weaker than "threading" depends entirely on your problem. For heavy I/O, coroutines will result in substantially lower average load.
Regardless of use of async native support or generators + trampoline.
 
@Kevin how dare it
also, what do we do about it?
 
1:34 PM
For example, my HTTP/1.1 server uses a thread pool to execute the WSGI applications in, once a request has been received. All communication, however, happens in the main thread async-ly, both streaming in of the request (buffered temporary file if it exceeds a certain size) and streaming back of the response. One can happily blend the two paradigms.
@Kevin Lacking a trampoline scheduler, that's not a proper coroutine example… that's just a generator you never iterate completely. ;P
 
To qualify my terms, when I say "yield isn't as powerful as threading" I mean that threading can do everything that yield can do, and more. Whether it requires additional memory and/or processing power is an orthogonal issue
 
def a(): print(yield b())

def b(): yield 27

trampoline.schedule(a()) → should result in 27
It's also not entirely true that threading can do anything coroutines can do. Sure, you could fork a thread at every decision point, but that is hideously inefficient. Whereas with coroutines splitting out code flow into structured tasklets isn't just a good idea, it's the slaw. Finely shredded cabbage.
 
Academics don't care about inefficiency, our turing machines have an infinite supply of tape and actually running the code is left as an exercise to the reader :^)
 
Monday back from spring break cabbage
 
(Not pictured: the academics that care enough about efficiency to spend their careers getting the Traveling Salesman problem down from O(2^N) to O(1.9^N))
 
1:46 PM
Speaking of academics, Stackless Python has a great summary of "continuations", the lower-level unit of work for coroutines. ("Continuation-style programming" being the name for this paradigm.)
 
@Kevin People keep talking about the Travelling Salesman problem like Jeff Bezos didn't solve it about 20 years ago...
 
@toonarmycaptain Is it "well understood" in the same way as alkali metal reactions with water? (My high school physics teacher lied to us all. At that time we had no clue what was actually going on, despite it being "well understood in the literature"—which it was not. ;)
 
\o cbg
 
I like the concept that Bezos secretly possesses a sub-polynomial algorithm for finding solutions to NP hard problems, and he's been using it exclusively for literal bin packing and literal package delivery routing and nothing else
 
I wish he'd license that to Uber. They never direct people correctly so as to end up on the correct side of the road for pickup.
 
1:51 PM
I'm sure there are other practical applications. Maybe you could run all of folding@home on a graphing calculator.
 
¬_¬ Hasn't everyone with spare calculators been doing that since 1995?
Fourier transforms aren't the worst thing in the world, computationally. ;P
 
There's a rather neat scifi story out there on the Internet about a megacorp that finds a magic NP-solving oracle and uses it to economically conquer the galaxy
 
poor CS academics are getting desperate
"OK that's it, I'm going to write fanfic where we solve NP" ;)
 
I approve of stories where the protagonist starts off having already lost (e.g. stories involving a struggle to return/restore/normalize) or that explore the consequences of very specific, subtle-at-the-face-of-it changes, and how their impact can be extreme, like that. Solve problem X, you now have problems A, B, and C.
(Literary example, Jaunting, or pervasive teleportation and its effect on building security design.)
 
"subtle", you say? :P
 
2:03 PM
To a child say, "Pretend everyone can teleport." The answer will usually be: "K!" I may have meant simple rather than subtle.
 
@amcgregor I suggest that since the rise of internet commerce, and Amazon in particular, the number of travelling salesmen and their problems have decreased.
 
you underestimate the power of abstraction
 
# In test result:
AssertionError: assert 'Arthur_King_of_the_Britons' is 'Arthur_King_of_the_Britons'
#In console:
assert 'Arthur_King_of_the_Britons' is 'Arthur_King_of_the_Britons'
'Arthur_King_of_the_Britons' is 'Arthur_King_of_the_Britons'
True
 
Centralized logistics for fun, profit, and efficiency. Can't speak to the difficulties of a travelling salesman, but for sure, there are certainly less of them. I haven't met one in my adult life, though I do have memories of people stopping by my parents house for tea to try to sell them various things. ;P
 
My search for said story is stymied by the fact that its host website is now being cybersquatted
 
2:07 PM
@toonarmycaptain ask him the average velocity of a swallow
on a more serious note, that's why you don't test string equality with is
 
@AndrasDeak Laden or unladen?
 
I suspect I'm not understanding something about how classes, properties and getters/setters are working, since it seems to me that since the tests work without implementing @property (and using is) they should work fine with @property, but do not unless using ==.
 
This probably has nothing to do with setters and getters. is is for testing object identity. You're testing for a string value.
 
I vaguely recall that Python does some wacky stuff with binding that makes a.some_method is a.some_method sometimes evaluate to False
 
@amcgregor I don't know... [falls into pit]
 
2:10 PM
@toonarmycaptain Without @property, access of the method attribute (foo.bar) returns a callable function object. With @property, on __get__ (ref: descriptor protocol) the function is immediately called and return value presented as the value of the attribute; it is no longer a callable function object, it's the result.
 
Wait, did I miss more code? I thought it was just the one message about that assertion
 
c:\Users\Kevin\Desktop>type test.py
class Dog:
    def bark(self):
        pass

fido = Dog()
print(fido.bark is fido.bark)
c:\Users\Kevin\Desktop>test.py
False
Hmm, I think I misread the problem. Oh well, please enjoy the above irrelevant fact
My kingdom for an MCVE
 
@amcgregor I should have been clearer, I meant without implementing @property at all (so no defined function, just self.name = name), but I figured some sort of trickery was going on with the decorator.
 
@AndrasDeak yah, the AssertionError was from a test failure. It just seemed...unexpected that identical strings would fail in a test assertion, but not in the console, if identical strings is what they're evaluating to.
 
2:27 PM
Values returned from properties may or may not retain the same identity across multiple accesses. This is not a special quality of properties; you'd get the same result if you replaced them with get_thing() methods. Example:
c:\Users\Kevin\Desktop>type test.py
class Dog:
    def __init__(self):
        self._breed = "mutt"
    @property
    def breed(self):
        return self._breed
    @property
    def age(self):
        return float(1)

fido = Dog()
print(fido.breed is fido.breed)
print(fido.age is fido.age)

c:\Users\Kevin\Desktop>test.py
True
False
 
Ah, that's just bog-standard "string literals that are equal aren't always referentially identical"
 
if you have two literals then they are literally different objects, so identity tests will only give you True due to implementation details as long as you aren't working with singletons
 
I only trust is to work intuitively when I use it on None or on instances of object. Everything else is a disaster zone.
 
In general, only use is for testing with None, or a sentinel of your own creation (using sentinel = object(). 1000 - 1000 is 0 might work sometimes, others not. @toonarmtcaptian Why are you using is when you mean ==?
 
2:34 PM
@Kevin also True and False
 
Gah! Kevin'd again!
 
I mean, you typically wouldn't use is there but those bools are guaranteed to be singletons
 
I hate code that reads if my_test_var is True:
 
(I know, I know, doubletons)
 
Gah! Kevin'd by @AndrasDeak
 
2:35 PM
@AndrasDeak You are technically correct, the best kind of correct.
PaulMcG doing an excellent job of independent verification in this convo to confirm that we aren't lone crackpots
 
We are a group of coordinated crackpots. How is that reassuring?
6
 
@AndrasDeak Oh ok. I had this idea from somewhere that python stores all unique strings/numbers as objects on creation, so any reference to 314.15 or "three one four point one five" will actually point to the same memory location as the original. Not sure where I got that now.
 
that only happens to integers from -5(?) to 255(?) on cpython, and "certain" strings (and empty tuples and ...)
and, can't emphasize this enough, it's an implementation detail
so just ignore it and use == when you mean ==, which is almost always
 
Fair enough. :) It just struck me as...odd (given my assumption) that my first test passed, but the others didn't, given the AssertionError 'string' is 'string' in the traceback.
 
similar pitfall: taking id too seriously
>>> id([1, 2, 3])
139977766528712
>>> id([4, 5, 6])
139977766528712
 
2:43 PM
@AndrasDeak Common failure of understanding for new players; the first list is immediately freed, the second list allocated in its place. ;P
 
there are too many wild goose chases on SO main trying to explain weird id reuse behaviour
 
(Somewhat related to using mutable containers as default argument values. ;)
 
Ah ha, I found the story that I was digging around for. Sweet Surrender, a tale of an NP-solving Go-playing angel, originally hosted on the now-dead site kuro5hin.
Hopefully this overly-descriptive description will help me find the above message the next time I search for it a year from now
 
:D Added to my reading list.
@Kevin One of the things I use Pinboard for. Preserving "interesting links" in tagged, searchable ways.
 
I think he had the link in an easy-to-find place, but the host died
then again now he could replace the link with the pastebin
 
2:46 PM
T_T That's always sad.
 
Ok see that makes sense.
I must have remembered what Cpython does with smaller ints, and since is in tests is usually being used for None it's never bitten me before.
 
I didn't have a link so much as a trail of breadcrumbs. With the amazing combined powers of my horribly imperfect memory, Google, the Internet Archive, and a random third-party mirror of the exact page I happened to be looking for, I was able to snatch the story from the jaws of entropy.
 
Right said Fred, climbin' up his ladder…
 
The Internet archive is a wonderful place.
Not least of which for accessing content which might be banned by an employer's filter, but is archived. ;)
Unlike pastebin, which is blocked for me.
 
@toonarmycaptain Heh, I have a 140,000 line /etc/hosts file blocking most sites/domains commonly utilized by malware, ads, and call-home subsystems, which includes pastebin as a C&C vector. I go a few steps beyond the corporate filter. ;^P
 
3:00 PM
The mirror I copied from is keycorner.org/pub/text/SweetSurrender.html, which I assume is no more resistant to bitrot as the original site
One thing that troubles me in this story is an uneven application of mathematical rigor. It goes to great pains to explain how NP hard problems become multiplicatively more expensive to solve if you increase N by one, and how you would need a computer bigger than the universe to solve problems with modest values of N.
Later, it mentions that it is also multiplicatively expensive to convert a real-world decision problem into a formal NP-hard problem. But this time it basically says "no problem, we'll just throw more hardware at it"
Perhaps the implication is that formalizing real-world decision problems is really dang expensive, but only polynomially so, which makes increasing N by one tractable if you happen to have a revenue stream that gets bigger every time you increase N.
 
@amcgregor So when we use pastebin in here, you can't/don't look at it?
 
@toonarmycaptain Generally, aye. Alternatively, if I'm particularly desperate to see the content, I'll push the link over to my iPad, not on the corporate network.
And view it via curl, not a browser.
(I do occasionally get looks from coworkers for legitimately using ELinks or Lynx as a browser. ;)
 
3:20 PM
When I am king of the Internet, all useful information will be on text-only pages. Images will be allowed but only on anime fansites
It was once said, "the last time the Internet was truly usable was when there were 7 pages and the only one of interest to the general populace was the Smithsonian's collection of pictures of rare gems"
 
There's a reason forging e-mail from other people is so easy. It was a feature, not a bug, when everyone on the internet was a PHD who knew each-other personally.
Today, this gives me the joyful legacy of being able to start a presentation by sending everyone at the company an e-mail from Bill Gates.
 
One of my favorite solutions to the Fermi Paradox is "societies inevitably form a universal dependence on a system that was never designed to indefinitely withstand the load of an entire world's worth of users"
 
Diversity and optimization to the point of singleton solutions and potato famines.
 
If the Internet vanished tomorrow, we'd probably survive... But I'm not so sure the same will be true 200 years from now when all our cortical implants get firmware updates via SSL
Oops, an email worm bricked everybody's voluntary motor control...
 
Especially when it's all just leased software
 
3:32 PM
Alternatively, to give a positive post-singularity potential to counter the biological fear-harvesting of change: after I upload, I'm going to read every book (or other written collection of words) ever written. I'll fork a copy of myself for every book ever written, reading every book ever written in the time it takes to read the longest one, then merge those copies back in.
 
I've thought about the fork-on-all-books scenario, but I don't know if I can trust my instantiations to get through the boring ones
The problem of clones being useless layabouts has been explored in both Futurama and Calvin & Hobbes.
If two cultural tentpoles can identify this as a problem then there must be some truth to it
The Quantum Thief trilogy solves the problem by supposing that self-forks can be encouraged to perform particular actions by tweaking their personalities with dictates like "you find reading to be impossibly fascinating regardless of subject matter"
 
I read a somewhat weird article last night about some Facebook outage last week, and the resultant spike in p***hub usage, said site having spikes in searches for content featuring facebook, instagram, whatsapp...
I haven't really digested what that means for society, but suffice to say people were so bored without social media, that they turned to p*rn, and searched *for* social media themed content...
 
Rule 34, though, discounts most "kinks" as casual jokes. For example, I have chair-on-couch porn. That is, two inanimate objects miming an intimate act. It's stupid. Mildly amusing, but overwhelmingly stupid.
 
Possibly there are two separate phenomena there: people who are intentionally searching for facebook-related content on adult-oriented sites with the intention of finding adult-oriented content, and people who are desperately trying to get into facebook by typing "facebook" into every search bar that they have ever used.
Many Facebook users have vary limited technical ability. There was a tremendous wave of complaints the last time the top google hit for "facebook login" changed to a page that did not in fact have a facebook login. A significant portion of users simply couldn't log in without that stopgap.
 
3:42 PM
People Googling domain names encourages me to cheese-greater my face.
 
Sometimes I google domain names as a quick-n-dirty way of determining how trustworthy the page is
 
Here's the link: [Pornhub Had a Huge Spike in Users When Facebook Went Down](https://twentytwowords.com/pornhub-huge-spike-users-facebook-went/)
NB Should be safe for work...but I had to resort to some hijinks to find it without typing search terms I don't think my employer would be happy with...
 
If the site's summary text on Google is "buy cheap real estate now! CLICK HERE" then I know not to bother
... But I only need to do that once so that's not really the phenomena you're describing
 
@toonarmycaptain Alice's Law #137: When attempting to learn how to mask layers in the GNU Image Manipulation Program (GIMP) avoid searching unconsciously for “gimp mask”.
 
@amcgregor Heh. That's defendable. "p***hub facebook instagram" not so much.
 
3:46 PM
True story. XP
It's one of those "someone's in the shower, don't flush the toilet, don't flush the… damnit I flushed the toilet" types of situations. I knew it was an error as my finger descended towards the enter key, but I couldn't stop myself in time.
 
GIMP simply needs to become more popular than all other meanings of the word. If Python can do it...
But perhaps becoming more popular than herpetology is easier than becoming more popular than a longstanding form of adult entertainment
 
4:01 PM
recbg
 
cbg @AnttiHaapala
 
4:20 PM
Hmm, is there any abstract base class in collections.abc that includes list and tuple, and does not include string and bytes?
Neither sequence nor collection satisfy those requirements... What else is good...
>>> from inspect import getmembers, isclass
>>> import collections.abc
>>> print([member for _,member in getmembers(collections.abc, isclass) if isinstance((), member) and not isinstance("", member)])
[]
Dang
 
On 3.6.8 I get:

[<class 'collections.abc.Collection'>, <class 'collections.abc.Container'>, <class 'collections.abc.Hashable'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Reversible'>, <class 'collections.abc.Sequence'>, <class 'collections.abc.Sized'>]
 
Curious. I would expect string to belong to sized and hashable at least.
 
On 2.7.16: (notably iterating members of `collections`, not `collections.abc`)

[<class '_abcoll.Container'>, <class '_abcoll.Hashable'>, <class '_abcoll.Iterable'>, <class '_abcoll.Sequence'>, <class '_abcoll.Sized'>]
@Kevin It is.
On 2.7.16 swapping `()` for `""`:

[<class '_abcoll.Container'>, <class '_abcoll.Hashable'>, <class '_abcoll.Iterable'>, <class '_abcoll.Sequence'>, <class '_abcoll.Sized'>]

On 3.6.8:

[<class 'collections.abc.Collection'>, <class 'collections.abc.Container'>, <class 'collections.abc.Hashable'>, <class 'collections.abc.Iterable'>, <class 'collections.abc.Reversible'>, <class 'collections.abc.Sequence'>, <class 'collections.abc.Sized'>]
 
there is an ugly trick for 2.7...
strings do not have __iter__ :F
 
Bin
How to stop a currently running loop with a button
 
4:34 PM
Something is not right here. If you swap () for "" in my code, then you have if isinstance("", member) and not isinstance("", member), which should unconditionally evaluate to False
 
This is not the case?

>>> str.__iter__
<slot wrapper '__iter__' of 'str' objects>
I'm inline evaluating the following in a REPL:

[i for _,i in getmembers(collections.abc, isclass) if isinstance("", i)]
 
@Bin Most Python programs can be terminated by pressing ctrl-C. This is the easiest approach, because it automatically works without you having to change your program.
 
@Bin That gets into thread synchronization; the thing to look for are mutexes and semaphores. (Ways of signalling across threads.) If you have an "event loop" the thread is processing, on each iteration of the loop check for the signal and bail.
 
The harder approach is to run your loop in one thread, and run a GUI in another thread, and hook up the GUI's button to an inter-thread communication object (for example an Event) which the loop occasionally polls
^Oh good, independent verification.
 
(The "stop" action of the button then becomes "set that flag".)
 
4:38 PM
@Bin send the SIGINT signal
 
Bin
I have a pause button when i click the button it should stop the currently executing loop
 
kill -INT <pid>. There are other ways to do that, but IIRC SIGINT is the KeyboardInterrupt exception in Python
 
@WayneWerner "How to stop a currently running loop with a button" — I did not read this as whole program which process-wide signals or KeyboardInterrupts represent.
 
stop or pause?
 
Bin
pause
 
4:39 PM
Ah, well that's a different thing. Pause != Stop
 
If you already have the loop and the GUI running in parallel successfully, then you've done 99% of the work already
 
Bin
How to pause the loop
 
(I am hoping beyond hope that they are running succesfully and you're not about to say "My GUI window appears, but it becomes unresponsive once I enter the loop")
 
You just need to do something like this
 
Bin
I have play button pause forward and backward button
 
4:42 PM
for thing in whatever:
    do_stuff(thing)
    pause_if_needed()
 
Bin
play button works successfully
def plotDraw(self,x ,y):

self.MplWidget.canvas.axes.clear()
self.MplWidget.canvas.axes.plot(x, y)
self.MplWidget.canvas.axes.legend(('cosinus', 'sinus'), loc='upper right')
self.MplWidget.canvas.axes.legend(('cosinus', 'sinus'), loc='upper right')
self.MplWidget.canvas.axes.set_title('Signal')
self.MplWidget.canvas.draw()

def plotData(self,iters,x,y,current_iter,val,gvalue):
while(current_iter<=m):
print(current_iter)
loop=QEventLoop()
self.t = QTimer()
self.plotDraw(x[current_iter:current_iter + iters], y[current_iter:current_iter + iters])
 
@Bin Any loop can be "exited" using break. Not all iterable objects (being for looped over) are resumable (those returned by iter() usually can be). And resuming is just a form of intermittent iteration, a la fetching next values via explicit next(iter) calls. Break being effectively equivalent to raise StopIteration from normal iterators, but not generators any more. (Generators just return to declare they're done generating values, these days.)
 
so what you're really asking then is how to seek, which is something different :P
also, you should check the room rules about pasting loads of text. They're at the top of the sidebar --->
 
Bin
@Wayne Werner how to pause this code running from runnning
 
I think the requirements changed while I was away codesmithing, but for the record here is a minimal prototype that provides a pause/unpause button for a loop in its own thread
 
4:47 PM
rewrite it, wrap it in your own class that allows you to move forward and backward
 
Alas I know nothing about Qt so I can't give much advice about porting it from tkinter
 
Am I missing something about specifying a Path type object which using typehints?
 
@toonarmycaptain "Missing something" doesn't describe the mismatch between your expectation and what is happening to you; what's the actual problem?
 
Bin
I have called these buttons inside a class
class MatplotlibWidget(QMainWindow):

    def __init__(self):
        ---
        self.playbutton.clicked.connect(self.drawGraph)
        self.pausebutton.clicked.connect(self.pauseGraph)
        self.forwardbutton.clicked.connect(self.forwardGraph)
        self.backwardbutton.clicked.connect(self.backwardGraph)
 
@Kevin You reap what you sow, who lives by the sword dies by the sword, as ye Kevin so shall ye be Kevin'd
8
 
4:51 PM
et tu, Kevin... [dies]
 
That was Friday
In PyCharm, that is "beware the .ideas of March"
 
lol, I was just typing... using def func(mypath: Path) doesn't seem to work, and googling brings up some talk of adding some sort of PathLike to the typing apparatus. mypy states " Argument 1 to "Path" has incompatible type "Optional[Path]"; expected "Union[str, _PathLike[str]]"
But when I change the hint to that, it says error: Name '_PathLike' is not defined and error: Argument 1 to "Path" has incompatible type "Optional[Any]"; expected "Union[str, _PathLike[str]]"
 
@toonarmycaptain MCVE, please.
 
I figured someone in here might have tried to enforce passing of a Path object before, although the sparseness of SO and google results to python typehint pathlib.Path object might belie a flaw in that assumption.
 
4:55 PM
@Bin We've all shared our thoughts about ways to design this at a high level. It looks like you're trying to get more concrete advice about conforming your existing Qt objects to that design. But it seems none of us are particularly well-versed with that library. You might be better off asking a question on the main site, since there is a wider audience there.
Be sure to provide an MCVE if you go that route
 
@amcgregor I can't go there, lol
 
@toonarmycaptain You can't Cloudfront? O_o Okies. I tried uploading it here, but the upload modal is literally unresponsive to input.
 
My modal isn't unresponsive, so I will try... Oops, "failed to upload image"
 
4:58 PM
"Sorry,
s.webcore.io
is not available because it is categorized as unknown."
I'll make a MCVE in a sec whem my hands are less full.
 
oops
 
@toonarmycaptain Here's the link after redirection: d1jfzjx68gj8xs.cloudfront.net/items/2I0t0z3x0m2P2v0G2e0o/…
(Entirely might not work, too, given I'm using CDN protections, here.)
 
How about that, @toonarmycaptain?
 
Huzzah.
 
That's an interesting image host. It somehow disabled my "save image as..." ability.
 
4:59 PM
@WayneWerner I don't see that either.
 
@Kevin It's a link directly to the image file. :|
 
The Windows explorer prompt appears but the actual saving fails
 
@amcgregor This worked.
 
@toonarmycaptain that's imgur. Lol that the other thing worked
 
@toonarmycaptain Vs. s.webcore.io/e08bab9ddc39 (without the file in the URL) gives a wrapped version, which I generally dislike. ;)
 
5:00 PM
I was about to upload to a github repo lol
 
@WayneWerner Yea. I assume that the school district frowns upon a lot of content on imgur.
 
It worked on my third attempt. Weird.
 
snicker
 
If your network protections deny s.webcore.io (which only issues redirects to cloudfront) but allows imgur… that filter might need to reconsider life choices. ;^P (s.webcore.io powered by CloudApp)
 
Can't imagine why
 
5:02 PM
How can I make a program to solve this problem: math.stackexchange.com/questions/2569003/…
 
This is what happens when you upload text as an image
 
This is what happens when you have text input which can't handle ANSI sequences. Or SVG terminal capture that can't handle ligatures and promptline extended symbols. XP
 
@JaakkoSeppälä Third-party library Numpy has some support for linear algebra solving‌​.
 
Related to that last: anyone have a WOFF of Hasklig handy?
@Kevin Screenshots of text are usually my last resort. ;)
 
@Kevin I see. That problem seems to be hard to be implemented.
 
5:10 PM
Certainly it is hard for me since I don't know enough linear algebra to understand Jyrki Lahtonen's answer
Maybe the problem is easy to implement for someone who is well-versed in both Numpy and linear algebra. But then again, maybe not.
 
5:22 PM
Ok turns out I just shouldn't be coding at work on Monday after spring break :|
Optional[Path] = None works.
 
I think = None implies Optional, you should be able to do (path_arg: Path = None)
 
Hmm I have been playing recent puzzle game Baba Is You and I'm experiencing something similar to The Tetris Effect. All the text in the game has a two frame animation that alternates between slightly different squiggled letters. I keep getting the sensation that something is squiggling in my peripheral vision.
 
@JaakkoSeppälä yeah, that's hard
 
Take it as high praise for Baba that there are only two games that focus my attention enough to make me hallucinate, and the other one is the most popular game of all time
 
@Kevin Finnish streak
 
5:32 PM
Explain further
 
Jaakko and his answerer Jyrki are probably Finns, so is your game (made by Hempuli Oy)
 
They're everywhere!
 
Torilla tavataan
 
I like how the aesthetics of the respective hallucinations are so diametrically opposed. Neat interlocking squares falling in orderly sequence, vs the formless writhing void. Order, meet chaos.
 
I wish data science people would properly tag their questions with pandas so I could ignore the tag and not have to read see their awful code...
 
5:45 PM
np devs, please rename "array" to something that doesn't make me think "perhaps this question asker is asking about lists"
We could also ask every half-informed tutorial writer to choose a different incorrect name for "list" but you may as well try to drink the ocean
 
@Aran-Fey or at least put "PYTHON PANDAS" in the title like normal people do
@Kevin but it is an array :P
 
Not any more. Now data organized contiguously in memory is called... Grumbo.
I look forward to numpy.grumbo in the next major release
 
@Kevin Is "sequenced mutable compacted set allowing repeated members" better? >:D
 
SMCSARM is sure to be a hit among fans of impenetrable acronyms
 
Hehehe. Glad you caught the edit. :3
 
5:56 PM
:smacks arm: this baby can type so many SMCSARMs
 
That would read as "shm-charm" in Hungarian. Almost pronouncable.
 
Yup. Dangerously close to being pronounceable, and thus something someone will eventually try. XD
 
well people pronounce postgresql
 
Post-gres-queue-ell?
 
no idea
 
5:59 PM
I have a hard time believing anyone would pronounce it post-gre-sequel.
 
I have a hard time believing people pronounce SQL as sequel ;)
 
I thought it's "post-gre-es-queue-ell"
 
@AndrasDeak All the time. Seemingly only to get under my skin. ;^P
 
Wikipedia says the devs pronounce it Post-gres-queue-ell
 
@Aran-Fey Depends on the laziness of the writer at the time. I rarely write its name correctly, that is, PostgreSQL, I usually lower-case the SQL part, which makes it more word-like and less jarring.
 
6:02 PM
... Assuming that's what /ˈpoʊstɡrɛs ˌkjuː ˈɛl/. translates into, I can't read IPA fluently
 
@Kevin looks like that to me ^
 
@Kevin kju, "quque", given most North Americans abbreviate it "que"/"cue" rather than pronouncing the full thing, close enough. ;P
 
Wiktionary says queue is /kjuː/, so that's a match
 
Se so. Except for American pronunciation. Like "roof" becoming "ruf" or "roove".
By Romulus, it took me weeks to get used to the pronunciation of "roof" when I was travelling doing IT security and point-to-point network link work. So many ruvs. XP
 
The most prominent dialect wackiness around here is water being pronounced "wooder" or "wahter" depending on the speaker's mood
and time of day and phase of moon etc
 
6:08 PM
Heh. Wahter. One of my friends has the affectation of calling "milk", "melk". It's adorable, if confusing.
 
I only recognize half of these in my own speech patterns. Must be because I only spend half my week in Philadelphia. They call me... Daywalker.
Lexicon checklist
Yo - yes.
youse - no.
Anymore - never heard of this usage before.
Hoagie - yes, although "sub" is also understood.
Jimmies - yes, although "sprinkles" is also understood.
jawn - occasionally.
 
I didn't know Ben Franklin lived in Philadelphia
 
Yo, early to bed and early to rise makes youse healthy wealthy and wise anymore
 
@Kevin Québec French quick reference: :duck sound: — "yeah"
Oui is a proper yes. "Wegh" (said like a duck) is the less formal "yeah".
 
We could all stand to be a little more duck like
 
6:23 PM
What's "less formal no"? I want to use it now.
Meow?
 
I challenge anyone to go to Newcastle upon Tyne, UK and understand them speaking.
 
with context:
    eval(_)  # dang, it's not helping
 
C:\Users\Kevin\Desktop>type test.py
from contextlib import contextmanager

_locals = {}
@contextmanager
def context(**kwargs):
    _locals.update(kwargs)
    yield
    for k in kwargs.keys():
        if k in _locals:
            del _locals[k]

def eval(s):
    return __builtins__.eval(s, None, _locals)

with context(a=23):
    with context(b=42):
        print(eval("a+b"))
C:\Users\Kevin\Desktop>test.py
65
idk
Hard mode: modify the implementation so this code runs:
with context(a=23):
    with context(a=99):
        print(eval("a"))
    print(eval("a"))
Some kind of crazy dict-of-stacks may be in order
 
6:40 PM
just make a copy of _locals
 
I like it.
 
@contextmanager
def context(**kwargs):
    locals_copy = _locals.copy()
    _locals.update(kwargs)
    yield
    _locals.clear()
    _locals.update(locals_copy)
 
wim
_abs same as abs y tho
 
I was just writing up an implementation that contains the line global _locals which I feel must be some kind of sin
@wim Perhaps they want to ensure that abs and operator.abs are not referentially identical. I don't know why this is desirable, but [shrug]
 
wim
seems undesirable to me. just another pointless frame in the call stack.
operator.truth looks just as useless (same as bool)
 
6:47 PM
I sense a bit of kitchen sink design going on
 
countOf?‌​! Is that camel-case I see?!
 
wim
yes also indexOf
and it exports all the public names twice as both name and __name__. weird module.
I don't know why countOf and indexOf are even in there, since there is no corresponding operator.
 
I'd lean towards there being a difference in intent. bool() → typecast to a boolean, I don't really care how, I just need a bool instance back. truth → would this value be considered equivalent to True?
That truth uses a boolean return value to indicate truthiness is ancillary.
 
Since Python is all about implicit typing, not making the return type obvious in the function name is pretty on-brand for them
 
@Kevin Not sure what you're trying to imply with this. Also, Python isn't about implicit typing, it's atheist to your types. It's a honey badger that don't give a f*, unless you explicitly ask it to at runtime (typeguard and friends) or compile time (RPython).
def mul(a, b): return a * b — this is useful for integers, floats, mixed integer + float, but also strings. Why restrict your code unnecessarily?
Annotations like "int" etc. are overly restrictive, you can't possibly come up with an aggregate type covering all possible cases of objects including __mul__, but that's the crux: if it's got a __mul__ method, it's perfectly valid. New ABC opportunity: Multiplicative. ;P
 
6:54 PM
@amcgregor "Why restrict your code unnecessarily?" I think "I don't feel like writing tests for things outside of what this was designed for" is a decent excuse that many could invoke.
 
wim
python dev will not add another way to do the same thing because of "difference in intent". pointless complication.
 
I will rephrase. Python wants you to think of your data in terms of what it can do, rather than what it is. Providing truth as an alternative to bool is in line with this goal, because you don't have to consider how yes-no/true-false/on-off data is typically represented.
But you have to reach some serious type atheism Nirvana to forget what bools are, so it's reasonable to think that truth is a bit silly.
 
"What are you doing?" "I'm casting this value to a boolean to see if it's truthy and if so…" "That's how, not what." >;)
 
00:00 - 19:0019:00 - 00:00

« first day (3075 days earlier)      last day (1872 days later) »