« first day (4380 days earlier)      last day (558 days later) » 

1:11 AM
@TheRealMasochist Read the error message - sympy.abc.x is not a package, it's a thing inside a package, Python can only import packages, and from packages import things inside it. See similar thread as an example.
 
 
4 hours later…
5:30 AM
@metatoaster Thank you. It is very useful.
@ParitoshSingh np.vstack([xs,ys]).T is another option.
xs = np.linspace(0,10,11)
ys = 2*xs

ps = np.vstack([xs,ys]).T
print(ps)

qs = [list(q) for q in zip(xs,ys)]
print(np.array(qs))

rs = list(map(list,zip(xs,ys)))
print(np.array(rs))
 
 
3 hours later…
8:30 AM
If I have two (or more) components in a Class that automatically receives events dispatched from the Class, how should I handle errors that can happen in the components, if the class is dependent on that they work? Should I remove the event handling here altogether and just call the components methods from the Class or is there anything I can do to catch to observer exceptions?
 
I think if the class is dependent on them, then you just write a ginormous test suite to make sure it actually works
 
Log the error and proceed. You don't have any more to base a decision on. That's if running the program is your priority.
Alternatively, if things really should not fail then halt on error. Force the admin/developer/… to keep the software in shape.
 
Oh okay, in this case I have a Report class that dispatched different kind of events. One of the components that receives these event is a "ReportHTML" class that is responsible for writing the HTML file. But you know, writing to a file can generate exceptions, which is why I'm questioning the use of events between these classes. Hmm..
 
"writing to a file can generate exceptions" Frankly that is nothing I would consider worth handling inside the application. If your environment is that unreliable, then nothing can be done reliably.
 
Depends on context, I'd say. You wouldn't want to find out that your server hasn't been writing logs for the last 3 years because it ran out of disk space and your program never reported that as a problem
 
8:43 AM
:55368119 That's completely true. Would you still use events between these classes?

class Report:
     html: ReportHTML

     def log(self, entry: Entry):
          dispatch(self.EntryAddedEvent(entry))

or


class Report:
     html: ReportHTML

     def log(self, entry: Entry):
          self.html.add_entry(entry)
No, exactly, I do want to know when there's a problem writing to the file.
A crash is fine, of course. But I mean, many sources on the internet is against raising events from the observers.
 
Are you writing an app or a library?
 
I'm writing a framework/library.
 
@Warcaith I'm not a fan of generic Events when there is actually a specific structure.
It seems you want to pass on reports specifically to report backends.
 
:55368179 Yeah, I do have a implementation that looks kind of like this:

class ReportHTML:
     def __init__(self, reference: weakref.ReferenceType[Report])
          pass
Instead of using events, it keeps a reference to the report.
 
BTW, I seem to have missed why you are using weakrefs all of a sudden.
 
8:53 AM
@MisterMiyagi I'd want to have a weak reference to the Report (as it contains a lot of data), but I've perhaps misunderstood weak references in Python?
I'm coming from the C++ world :p
 
@Warcaith Note that neither direct replies (:55368179) nor mentions work when the message contains block formatted content.
Write a normal message with the reply/mention, then write another message with the block formatted content.
@Warcaith That's my suspicion, yes.
 
There are too many unknowns here for me to say anything useful. Given that it's a library, there should definitely be a way to customize what happens in case of an exception, but I can't tell you how to best do that
 
It looks like ReportHTML would be unusable without the working reference, so the report must keep the reference alive.
This looks like the wrong place to have a weakref.
 
@MisterMiyagi Yes, but "ReportHTML" will only live if "Report" is alive, as it is an component/instance attribute to the "Report".
 
@Warcaith Then the weakref doesn't gain you anything either.
 
8:57 AM
@MisterMiyagi So, there's no difference between passing the actual report than a weakref.ref(report)?
 
Note that the Python GC is pretty good at handling cycles since 3.4'ish, aka forever.
 
Lies
 
Statistics!
 
Granted, it probably doesn't matter much here. But have you ever used BeautifulSoup without calling decompose()?
 
You probably wouldn't like it if BS would randomly spill parts of the soup either, would you?
 
9:03 AM
No, but it sounds like there's no chance of that happening here
 
Why take the gamble? Using a weakref only means a) adding overhead and b) adding the chance of a bug. It doesn't actually solve anything here.
 
@MisterMiyagi I thought that passing without a weakref would copy the whole report object, but that doesn't seem to be the case in Python.
 
@Warcaith If you want a C analogue, then Python is call-by-pointer-copy.
 
@MisterMiyagi So the things I pass is just a copy of the pointer? That means if I override the object that I've passed in, the original object will still be unchanged, right?
 
@Warcaith It means the original pointer will remain unchanged. Changing the state of an object is visible through every pointer to it.
 
9:12 AM
But what happens if the Report instance gets deleted, but ReportHTML still lives (wouldn't happen in my case, but still interesting)? Wouldn't the copy of the pointer point to an invalid/empty object, just like a weakref would?
 
@MisterMiyagi The upside is that you don't have to manually decompose() the Report
 
@Warcaith If ReportHTML has a proper reference to Report, then Report cannot be deleted while ReportHTML still needs it.
@Aran-Fey Well, it doesn't look like they have to do that either. They can just drop the Report and then both the Report and ReportHTML are globally unreachable and will be cleaned up.
 
@MisterMiyagi Oh, I see, that's the difference between weakref and a ordinary object.
 
@MisterMiyagi Will eventually be cleaned up. Which might be later than desired since "it contains a lot of data"
 
@Aran-Fey Practically speaking, in the worst case it will be cleaned up when there is memory pressure. So it's guaranteed to be gone by the time the memory is needed.
 
9:16 AM
@Aran-Fey I'm trying to get a grasp about what you two are talking about. Would a weakref be better for the garbage collector?
 
@Warcaith Are you aware that there is a difference between reference counting and cyclic garbage collection?
 
@MisterMiyagi I don't think that's how that works. How would python know whether there's "memory pressure"? Does it have a background thread running that constantly polls the amount of free RAM?
 
@Aran-Fey Simply put, when allocating new memory fails.
 
That sounds a little late
Plus, even before you reach that point, it can already cause swapping
 
Since allocating can be retried after cleaning up, that's pretty much the perfect time for "late".
@Aran-Fey That's why the GC also runs regularly...
 
9:20 AM
CPython can retry the allocation, sure. But will the other processes on the PC also do that?
 
Doesn't matter. CPython never release memory back to the OS.
 
That... makes things even worse
 
Okay, now "can this be an issue in a pathological program?" – well, definitely yes.
"Are we talking about a pathological program?" – well, definitely no.
 
Alright, memory management is one thing, but I just want to get this straight: Can/should "event callbacks"/"observers" really be a dependency that the actual object that dispatches the events has? Events tend to be used with the "fire-and-forget" methodology, which basically means that the dispatcher should ignore the errors (which is not something I can do here).
I'm leaning towards making the call explicit to the ReportHTML right now, instead of having the object rely on the events (as I do have more control over the flow then).
However, I do have two more components that also writes other types of contents to their files, which is why I wanted to use events in the first place. It gets quite messy fast when you have several components that need to act on the same thing.
 
@MisterMiyagi Look, I can tell you from experience that cleaning up reference cycles can make the difference between a RAM usage of 900MB and 50MB. It probably make much that big of a difference here, but I reject the idea that you can just leave everything to the GC
(I only had 4GB RAM at the time)
 
9:32 AM
@Aran-Fey Weakref should therefore be more memory effiicient, if done right?
 
@Aran-Fey I'm all for fixing such issues once they actually occur.
 
@Warcaith Yes
 
Most people don't get how memory management works, prematurely giving them tiny fixes for things that aren't problems can well result in huge problems.
FWIW, if we want to avoid the cycle – then I would question why ReportHTML needs a stateful reference to Report at all.
Presumably, it only needs the Report for writing the HTML; that's a call, not state.
 
@MisterMiyagi ReportHTML is a context manager that starts to write the file as soon as it's created, which is why I needed the reference to the report from the start.
I need the report object when I'm running the exit method in the context manager also.
I had a OpenEvent and CloseEvent before that handled all of this, but as I'm now thinking of not using events, I need to pass the actual Report when ReportHTML is created.
@MisterMiyagi How would the ReportHTML know what content to write without the Report?
 
9:51 AM
Sorry, but I need to take a step back here first...
What exactly is in a Report to begin with so that it is needed so often?
When do the open/close events occur wrt the Report being created?
 
The **Report** acts as the interface for storing the output coming from our test framework, which is, for example, information about "which log entries has been created" and "which test cases has been created".

class Report(contextlib.ExitStack, EventDispatcher):
    html: ReportHTML

    def __init__(self):
        ...
        self.html = enter_context(ReportHTML(dispatcher=self))
        self.dispatch(event=self.OpenEvent(self))

    def __exit__(self, exc_type, exc_val, exc_tb):
        ...
Here's a small example (excluding all other logic)
One issue right now is of course that the OpenEvent will only ever be able to be received by an internal observer. If you attach something after init, you'll lose that event.
This is an example when I'm using events instead of calling the "self.html" object directly.
class ReportHTML:
    def __init__(self, dispatcher: EventDispatcher):
        dispatcher.attach(event=OpenEvent, callback=self.on_open)
        dispatcher.attach(event=CloseEvent, callback=self.on_close)
        dispatcher.attach(event=EntryAddedEvent, callback=self.on_entry_added)
You can easily see my problem now. Like, what should happen if the ReportHTML have an exception inside "self.on_entry_added"? The report needs to handle that in some way or another.
 
10:09 AM
@Warcaith If the Report is just the interface doing the dispatch... then why does ReportHTML need a reference to it? It doesn't look as if Report contains any data that ReportHTML needs.
 
It actually has a ton of data that should be represented in the ReportHTML, just didn't bother to expose everything here.
 
@Warcaith How does dispatch change the situation? Whether you call self.on_open directly or via dispatch, you still need to decide what you want to happen in case of uncontained failure.
 
@MisterMiyagi Yes, of course, I still need to decide that. However, I've read and learned from different sources that the event callback shouldn't throw errors, which is basically why I started to give you all these questions.
I mean, how do I know which exception to catch when the callbacks are all dynamic?
I know which exceptions to catch from my internal observers of course, but not from external observers.
 
If you just want to suppress them, then catch Exception.
That should cover all user-defined exceptions and all builtin non-fatal exceptions.
Since callbacks shouldn't throw exceptions, any exceptions that are thrown will be unexpected to begin with.
 
@MisterMiyagi The problem here is that I have no way to know then which callback went wrong. How should the user know that the ReportHTML couldn't be written, when ReportHTML is just an observer of the Report?
 
10:19 AM
hey all, im really confused about pyodbc executemany command, when did you guys use it? since if there was some error in one of the thousand rows, you cannot find it either, so why even some developer recommends it? is it for absolute data?
 
I'm trying my best to come up with a good design, which is why I have all these questions.
 
@Warcaith Either your dispatcher logs the source of the error (since it is the one calling it) or you use inspection.
Personally, I would let the application crash. The traceback also reveals where the error occurs.
 
when i was faced with performace issue caused by cursor.execute command, SO recommend me to use executemany, but when i faced a difficulty in trying to catch which row causing the error, SO recommend me to use regular cursor.execute
 
As your design says callbacks shouldn't throw errors, when they do then your application is in an inconsistent state and limping on may well make things worse.
 
@MisterMiyagi Yeah, it's in a completely inconsistent state and should perhaps, as you said, just crash.
 
10:55 AM
Does this structure seem odd?
Trying to remove the "OpenEvent" and "CloseEvent", because they are just unnecessary
class Report(contextlib.ExitStack, EventDispatcher):
    html: ReportHTML

    # One of many different data that exists in the Report
    verdict: Verdict

    def __init__(self):
        ...
        self.html = enter_context(ReportHTML(reference=self))

    def __exit__(self, exc_type, exc_val, exc_tb):
        super().__exit__(self, exc_type, exc_val, exc_tb)


    def log(self, entry: Entry):
        ...
        self.dispatch(event=EntryAddedEvent(entry))


class ReportHTML:
    reference: Report
 
I doubt you really want to inherit from ExitStack
 
Are you sure? It's really great to have that, especially in Report when I use many context managers.
 
It should probably use an exitstack, but not be an exitstack
 
Oh, I see. That's perhaps better yeah! :)
What do you think about passing the Report to the ReportHTML, including registering one callback like that?
 
Other than that it looks fine
 
10:59 AM
Sadly no weakref... ;)
 
11:45 AM
Hello I'm trying to create an empty index but my dates are populated out of order and I'm not sure why
NPS_Table = pd.DataFrame(index={"March'15","May'16","April'17","April'18","May'19","April'20","August'21","August'22"})
 
Use [] braces instead of {} ones.
Right now your dates are in a set, which does not preserve order.
 
12:18 PM
Ah
thank you! @MisterMiyagi
 
In django I can write tests where the DB is "refreshed" on each test.
Is there a way to do that in SQLAlchemy as well? (I m trying out FastAPI)
 
1:04 PM
how to solve the 8 piece puzzle problem
 
1:35 PM
Can't say I'm familiar with the 8 piece puzzle problem
 
The first piece is figuring out what the 8 piece puzzle problem is
 
I have chosen to interpret the question as, "how to solve en.wikipedia.org/wiki/15_puzzle, but with a 3x3 grid"
 
2:22 PM
@MisterMiyagi Turns out that’s completely wrong these days. For 3.9: github.com/python/cpython/issues/81438
 
Making a solver was a fun little challenge. pastebin.com/R7CTbRPA
 
How do you even solve that? Brute force?
 
Yep :-)
I'm trying it on the 4x4 board now and it's been churning for ten minutes
I'm sure A-star and its cohorts could find an optimalish path pretty quickly, but I haven't tried
 
Hmm. Doesn't strike me as a problem that would work with A*
 
All problems are graph traversal problems if you are suitably determined.
 
2:39 PM
I mean sure, but I don't see what heuristic you could use that would make it different from a breadth-first-search
 
In any case cs.princeton.edu/courses/archive/spr10/cos226/assignments/… says "try doing A* to it" so it must either be solvable, or unsolvable in an interesting way
 
I can vaguely imagine one such heuristic, but I think it would require you to already know the solution
 
We don't know the path to the solution, but we at least know what the solution looks like: the numbers sequentially ordered, with the blank cell in the bottom right corner.
In a pinch, you could convert the current state and goal state to strings, and do Levenshtein distance on them :-p
 
 
1 hour later…
3:42 PM
If anyone feels like digging into CPython, there is a bounty'd question with a rather non-obvious RecursionError vs Stackoverflow issue.
 
3:58 PM
@MisterMiyagi I don't think that's been true since 3.4, maybe earlier. But the docs aren't crystal clear about that, and I don't feel like crawling through the CPython soirce code. docs.python.org/3/c-api/memory.html#raw-memory-interface
 
stackoverflow.com/q/74058291 unclear (not a question)
 
That's borderline spam, even.
 
This answer by abarnert looks relevant, but it's from 2013. stackoverflow.com/a/15508271
And I guess it also depends on how the C compiler implements malloc/free.
BTW, image uploading is currently borked. meta.stackexchange.com/q/382854/334566
 
4:26 PM
Hi guys,

I have a series of functions (for doing database actions) in a module which I import. These functions can use what ever database is given on the env file.

The problem I have is that in the script I'm working on I need to access more than one db and I don't want to replicate those functions for a copy of the function for each DB. I'm also hoping not to have to enter the perameter each time I call it. Is there any way of importing the fucntions once, with one permater set and then again with a different perameter set? Or is there a better way of doing this?
 
@PM2Ring Many thanks. This answer and the other links were interesting reads and resources!
 
No worries!
 
@JamesMcIntyre This is what classes are for. Put the functions in a class.
 
Hey @Prof.Green
 
Well, arguably you'll still have to pass the db as an argument every time. It'll just look like db.func() instead of func(db)
 
4:37 PM
@Prof.Green RE: [your question](https://stackoverflow.com/questions/74058572/algorithm-to-find-programming-code-to-solve-data-structures-questions)

This generic of a problem is **unsolvable** with 100% correctness. I'll give a proof.

First, let me formalize your query a little bit. You want an algorithm M, such that: given a sample input datum X and output datum Y — M outputs the best algorithm R which produces Y from X.

Next, I'll transform this into a [decision problem][]. I want an algorithm M', such that: given a sample input datum X, output datum Y, and algorithm P — M' answers "yes
 
hi @ulidtko thanks
 
OMG no markdown. The main link: en.wikipedia.org/wiki/Rice's_theorem
 
Sounds very interesting. go for it
 
@Prof.Green please read through. And check "Rice's Theorem". Some magic you just cannot do, not even with computers.
 
@ulidtko I'm going through it now
 
4:42 PM
@Aran-Fey how does putting the fuctions in a class help in this case sorry?
 
@ulidtko Multiline messsges don't support Markdown. That's so code doesn't get interpreted as Markdown.
 
On the other hand, if you only want an algorithm and not the best algorithm, it's relatively easy
 
indeed easier... still undecidable though :)
 
@ulidtko Indeed, you are right about finding a way to prove that an algorithm is the best. So we will change the discussion to finding an algorithm
 
@JamesMcIntyre That's kind of a tough question. It... doesn't really help. But then again, you're pretty much asking for something impossible. At the end of the day, the function needs to know which database it should operate on. The only choice you can make is how you want to provide that input. Your options are essentially: func(db1), db1.func(), and func1()
Currently you're using option 1. Classes would be option 2.
 
4:48 PM
I suspect James is using func1() and the function accesses the DB via a global.
 
Ok, at the moment, I'm working towards implamenting the permater in the functions and then I'm planning to import those functons and then set one object equal to the fucntion with one perameter and anouther equal to the other perameter.

Will that work and does it make sense?
 
@PM2Ring Ah, you're probably right
 
Maybe I misunderstand the problem... I'll rephrase. Suppose you have two sequences of real numbers named X and Y. Both sequences have length N. You want to find some function f such that f(X[i]) == Y[i]) for all i from 0 to N-1. I assert that such a function always exists, and the function is a polynomial with degree no greater than N.
 
More accurately, he's using func(), and now that he has more than 1 db, he'd need a func1() and a func2()
 
@Prof.Green still impossible. Alan Turing has derived this in 1936; read about Entscheidungsproblem. Having said that, check pypi.org/project/howdoi — maybe it inspires you or someone else to try more. But the math says: no matter what you try, the outcome will always be flawed, in some way or another.
 
4:51 PM
@JamesMcIntyre That's a bit too vague for me. I'm not sure what it means to "set one object equal to the function"
 
@JamesMcIntyre It's possible, but it could get messy & chaotic, having multiple groups of functions that do the same thing, but with different DBs.
 
In Prof Green's problem, if the sample input datum X and output datum Y can be represented as sequences of real numbers, then algorithm M must exist. It will almost certainly produce useless values for any input that isn't in X, but caveat emptor.
 
What can't be represented as a sequence of real numbers?
 
@Kevin true. Like a poorly-generalizing AI — practical utility will be doubtful at best
@Aran-Fey are real numbers even real :D
 
Yesn't
 
4:54 PM
@ulidtko We'll talk more about it...

I'll give here a code that solves certain problems and we'll move on from there..
 
@James What Aran is suggesting is that you have a class that defines all your functions as methods. Then you can create an instance of that class, passing it the DB name. Then you can call a method of that instance & it will use the correct DB.
 
I tired to format the above as code but might have failed
 
@Aran-Fey Hmm. Maybe I better shave that down to "sequences of rational numbers"
 
@JamesMcIntyre There's a formatting guide linked in the room description.
 
@Kevin I would like to remind you of the existence of computers. Sequences of 0s and 1s are still good enough
 
4:57 PM
Oh and when I say sequences I mean "finite sequences"
 
def response(sql: str, headers: bool = True, pdb: bool = False):
    """
    This function allows you to run a basic SQL select query.

    Inputs:
    * sql - The query string
    * headers - Boolean to include headers or not. Defaults to True.
    """

    if pdb:
        data_base = config.PDB_DB
        user = config.PDB_USER
        password = config.PDB_PWD
    else:
        data_base = config.READING_DB
        user = config.DB_USER
        password = config.DB_PWD

    database = DatabaseConnection.connect_by_tns(username=user,
 
the cardinality of "finite sequences of rational numbers" is ℵ0 (I think), which is a far cry from the ℵ1 you could get from reals
 
@Kevin ℵ0 yes. Enumerable
"countable" ?.. whatever
 
One of those, definitely
 
The above is what I'm trying and then I'm hoping to do somthing like...
import responce

presponce = responce(pdb = True)
Will that work?
 
5:01 PM
Yeah
 
You're looking for functools.partial, not a call.
 
@MisterMiyagi is this directed at me? if so I don't understand
 
Aha, clearly we have different ideas about what that code is supposed to be doing
 
But... changing the architecture to use classes would be cleaner, as Aran mentioned.
 
5:02 PM
@Aran-Fey thanks, gonna give this a go
 
I will also once again strongly recommend classes
 
history classes, CS classes, CS history classes? jk
 
functools.partial is what I was thinking of earlier when I mentioned chaos & messy. ;)
 
@PM2Ring ok so did a implament a parsial correctly above then?
 
@JamesMcIntyre Nope. ;)
 
5:05 PM
You can tell you've used functools.partial correctly, when your code includes the words functools.partial, and it runs without crashing or producing incorrect output :-P
 
@PM2Ring sigh... can you tell me what it should look like? I'm terrible with documenation, I normally look at answers on stack overflow rather than docs (possbily because I'm dyslexic)
 
class Database:
    def __init__(self, data_base, user, password):
        self._db = DatabaseConnection.connect_by_tns(
            username=user,
            password=password,
            db=data_base,
        )

    def response(self, sql: str, headers: bool = True):
        return self._db.select(sql, headers)

db1 = Database(config.PDB_DB, config.PDB_USER, config.PDB_PWD)
db2 = Database(config.READING_DB, config.DB_USER, config.DB_PWD)
Something like that
 
ah, the good ol' single-method class :>
"Stop writing OOP" ? what was the title of that talk
 
Stop writing classes
 
@James Forget about partial. Follow Aran's advice. It will be neater, and easier to read, and to modify.
 
5:08 PM
Single-method classes are fine, sometimes. Even zero-method classes can be ok. But in any case, this class will almost certainly have more than 1 method
 
@ulidtko Well, the real class will have several methods. Aran has just shown the basic pattern.
 
import functools
q = functools.partial(response, "select * from widgets where quantity > 100", True)

print("PDB results:")
print(q(True))

print("READING results:")
print(q(False))
 
I'd like to keep it so that it still auto fills most of the details though, with the above, each time you create an instance you have to specify the database, the user and the password
 
Then just don't create instances very often?
 
this is a shared repo so I feel like we'd end up just creating a function for each database anyway with with those values filled in
(for creating the class instances)
 
5:12 PM
I think that would basically be fine.
I had a similar problem this morning. I have a function call, frobnicate("green"), and I considered writing a function def frobnicate_green(): return frobnicate("green")
 
not working though I'm afraid
 
I have a hundred frobnicate("green") functions all over my project and I'm paranoid that I mistyped one as frobnicate("gren"). None of my code analysis tools will notice a mistyped string literal. But if I replaced those hundred calls with frobnicate_green, then my tools will definitely notice if I type frobnicate_gren
 
PResponce = response(pdb = True)

ERROR: Closed process due to: response() missing 1 required positional argument: 'sql'
 
Have you tried the code I posted yet? The one that starts with import functools
 
@Kevin This?
 
5:20 PM
Yeah :-)
 
so would that be in my case...?
somone at the door will craft code in moment
 
I hope the person at the door does a good job crafting the code :-P
I'm imagining it's Aran at the door. "I decided this would be faster. Where's your computer?"
3
 
@Kevin Have you tried typing.Literal?
Also makes for nice bridges, in case you are interested.
 
I haven't, although I considered an enum, which is in the same ballpark
 
Unfortunately, I'm busy manhandling my own computer at the moment...
 
5:25 PM
An additional difficulty is that half the frobnicate calls take place inside template files, which get pretty spotty coverage from my code analysis tools. The fancier the code, the spottier it gets.
I solved the problem by simply concluding that I am perfect, and would never type "gren" accidentally in any conceivable future.
 
Doesn't the function throw an error if it gets "gren" as input?
 
It does. So I'll eventually find all gren-related problems. But some code paths go for weeks without getting called.
 
It's not easy being gren.
 
Wisdom
 
5:44 PM
Sounds like it's actually too easy to be gren :P
 
Becoming gren is easy. Surviving and thriving while gren is hard.
 
Help. stackoverflow.com/questions/14681005 There are tons of these lurking around. They're all bad, in different ways. It's this specific assignment that keeps getting asked about, because instructors keep assigning it.
This one happens to have survived 9 years and gotten 12k views.
https://stackoverflow.com/search?q=%5Bpython%5D+is%3Aquestion+score+calculator
https://stackoverflow.com/search?q=%5Bpython%5D+is%3Aquestion+grade+calculator
 
They say that there are a lot of screenplays about screenplay authors... I guess it makes sense that there are a lot of assignments about grading assignments.
 
6:00 PM
I guess it would be funny to think of a teacher going to SO to ask questions on their grading system, but then would hate if the student did the same for their homework...
 
:55370582

import functools
presponce = functools.partial(response, pdb, True)
Would my version of the code be that then @Kevin?
 
I think it should be partial(response, pdb=True)
 
6:18 PM
@ulidtko if you are still into answering that wretched question, it has two reopen votes already ... If you are up to it I'll cast the third, but I suspect it will be closed again
re: Prof. Green
 
@Aran-Fey I'll make a not of this to try next time, thanks. I've just tried the following which didn't work but I think it might be somthing wrong somwhere else
def PResponce(sql):
    response(sql, pdb = True)
Should the above work if response is working correctly?
 
You forgot the return?
 
@Aran-Fey ahh yes, of course!
 
@JamesMcIntyre No, the second argument shouldn't be pdb. Besides the first argument to partial, the order of arguments to partial should be the same as the order of the original function. pdb is the third argument to response, so it shouldn't be the second argument to partial.
 
@Aran-Fey it worked!!! :D
Thanks so much everyone
 
6:25 PM
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa. Questions this bad can get 67k views. stackoverflow.com/questions/21030116
 
@Kevin so it was what aran said before then if I were to use partial? i.e. partial(response, pdb=True)
 
I was hoping that the code I wrote would work perfectly with no changes required. Maybe I misunderstood the question.
 
@KarlKnechtel Obviously, given it's 8 years old. If it was maybe 1 year old, it might surprise me, but even then, bad question (even ones with only 1 upvote) will be seen by a lot of people, say 10-20k given how the site work.
 
Anyway, it's working now with the def. thanks so much everyone! have a good night (or day depending on where in the world you all) all
 
6:38 PM
@tripleee yea, one of those votes (was) mine... Really doubtful the title is searchable enough for my answer to become generally useful. Let it be, I think I got the point across
 
looks like one of the reopen votes was retracted (-:
 
6:54 PM
I just spent 45 minutes trying to get my coworkers to copy 2 files to a specific location. I think next time I'm on-premise, I'm going to set up an ssh connection.
 
7:05 PM
Relatable
 
The image upload bug must be tricky. There have been no updates since:
We've reproduced this and are investigating the problem. Thanks for reporting it! We'll be back with updates soon. — Catija ♦ 6 hours ago
 
If we define an alias of numpy as np, we cannot use this alias for the subsequent import declarations, is it by design?
import numpy as np
# from np import random as rnd
# import np.random as rnd
 
Yeah. You can't use variables in an import statement
 
OK. Thanks.
 
 
1 hour later…
8:41 PM
Folk, what are the minimum and maximum values returned by np.random.randn()?
I am confused because the returned values are not in [0,1).
 
@TheRealMasochist It's a standard normal distribution, centred on zero, with standard deviation = 1. See numpy.org/doc/stable/reference/random/generated/…
 
@PM2Ring OK. Thank you. Does it mean the range is (-\infty,+\infty) ?
 
And you should be using the new random functions on new code. numpy.org/doc/stable/reference/random/…
@TheRealMasochist Yes.
 
OK. Thanks.
 
But most values will be within a few standard devs of zero.
 
8:56 PM
OK.
 
9:07 PM
They've finally fixed the image upload. I had my suspicions when I noticed that it failed around midnight, New York time, but I immediately thought "Surely it's not DNS!".
 

« first day (4380 days earlier)      last day (558 days later) »