« first day (3256 days earlier)      last day (1692 days later) » 

5:31 AM
How I can implement a program so that calling by names will result in the output?
Like five(times(three())) should return 15
three(divided_by(two())) should return 1
It is sure that there will be two number and one operator
 
5:52 AM
Hi Need help,
How to delete the column values if cell value less than zero using pandas.
Any idea?
 
 
3 hours later…
8:33 AM
df[df['column'] >= 0] where df is the dataframe and the column is the desired column @MohanRaoD
 
@Quark there's no good way to implement that, but here's one
 
does anyone actually ever use the data structures and algos topics used in interviews?
 
 
2 hours later…
10:21 AM
^ closed
Sunday cbg :)
 
Thanks :) cbg
Oh, Andras just left and he's the Meta Oracle :/ What's the opinion on my assertion here about reproducing error messages on SO that are ultimately the library's fault?
 
11:01 AM
I don't see much point in posting/answering questions that are clearly a bug in a library, but I (usually) wouldn't go as far as down- or close- voting them. This one in particular seems to be asking a question related to the bug - "What causes this to happen?". It's a useful question because it lets people come up with a workaround.
Though it's also rather difficult to answer for people who're not involved in development of that lib
 
What he said ^
I think it's fine
 
The thought struck my mind that these typo questions might have long-term value if distilled as a "common typos" topic or search facility.
 
11:15 AM
Ok, I'll agree with that. Thanks guys. It was at -2 when I opened it like 2-3 minutes after it being posted, so I thought that was a bit harsh in terms of reviewing
 
 
1 hour later…
12:27 PM
cabbage
stackoverflow.com/questions/57934851/… the OP has not provided the requested information about the OS used to allow for a useful answer
 
Please update your question with a question. — quamrana 3 mins ago
heh
@ReblochonMasque IMO the OP's OS doesn't matter - this is SO, the OP is only one of (hopefully) thousands of people who'll be helped by the answers. Pick an OS and code away, or post a cross-platform solution for bonus points
 
yes, that's one way to look at it @Aran-Fey, thank you.
 
 
2 hours later…
user10984358
2:45 PM
heya, is doing a from module import Class inside a def of a function bad standards ?
 
imports usually go at the top of the module, yeah
there are valid reasons to do imports in functions, though
 
user10984358
I was asking about a circular import situation yesterday
 
user10984358
and doing an import like what I said seems to have avoided the problem
 
user10984358
but I read that its usually bad design and what not, so I wanted to know if its a bad design or something that is just unavoidable
 
My unpopular opinion is that circular imports are not indicative of bad design per se. Sometimes it makes perfect sense for two things from different modules to use one another
 
user10984358
2:55 PM
I need to justify my boss of this, so I was thinking any of you here would give me a strong reason
 
user10984358
its just the code is like 400 lines and this is the largest I have typed so I dont want to spend more time redesigning especially when due is tomorrow
 
Fill in the blanks: "A references B because X. B references A because Y. A and B are in different modules because Z."
 
user10984358
I told that out loud and I seem to have gotten a good response, thanks !
 
@TheNamesAlc Circular imports can be problematic, and injection techniques can help to offset those problems.
 
3:14 PM
Instead of importing another module, make the module (or imports from the module) parameters of the functions, so there need be no direct reference to the other module. This isn't always appropriate, but it can help (and often makes software easier to test as well).
 
take note that most times putting an import at the end of a file is enough to break an import cycle
that's still not ideal but better than dragging module layout into functions
 
3:52 PM
cabbage
 
 
1 hour later…
5:22 PM
Can we create object literal for own defined class?
 
only by forking cpython
 
technically, you can implement a custom import hook that modifies the source code
there is a library for immutable types which does that - swapping e.g. dict literals for immutable dict literals
that is quite complicated to get right, though
 
Ok
 
changing the type of existing literals is way easier than adding completely new literals though
 
indeed. what kind of literal do you have in mind anyways, @Quark?
 
 
3 hours later…
8:25 PM
Hmm, I wonder if there's a way to copy a function without having to rely on CPython implementation details
 
copy.copy seems to work
 
>>> copy.copy(f) is f
True
:/
 
ah, damn
hm, you can copy the foo.__code__.co_code
what parts do you need?
 
I actually want to modify the __closure__
...is __closure__ a CPython thing?
 
IIRC all those parts are specified
PyPy at least has them and they look the same
no guarantees whether you can modify them the same - but I guess yes
 
8:34 PM
I'm surprised the closure is mutable tbh
class Foo:
    def __init__(self):
        super().__init__()

Foo.__init__.__closure__[0].cell_contents = int
Foo()  # TypeError: super(type, obj): obj must be an instance or subtype of type
 
sneaky
cell_contents is read-only on PyPy3.6.1
 
9:22 PM
- stackoverflow.com/questions/57919813/… (duplicate, shadowing module name)
 

« first day (3256 days earlier)      last day (1692 days later) »