« first day (4732 days earlier)      last day (65 days later) » 

6:45 AM
in broad strokes, how would you make a program that takes a pyparsing parser and a string (or a regular expression and a string), and if the parser can't parse the string, tells you how far away the input string is from a valid string?
i'm trying to think about how you would make a CLI that suggests to you valid arguments if your argument was invalid
 
7:18 AM
That's definitely easier with pyparsing than regex. You basically have to loop over the expressions that make up the parser and generate the input string based on what kind of expressions you find. You find a Word(alphas)? input_string += ' ' + ''.join(random.sample(alphas)) + ' '. Etc
 
7:49 AM
depends on your metric for "distance". but yeah, with pyparsing you construct the matcher and it's an object with an explicitly exposed internal graph structure, so it's naturally going to be easier to do that kind of post-hoc analysis
@Aran-Fey I kinda struggle to imagine how a system that has less trouble with circular imports, would even work...
since I've been mentally working on the language design thing again recently, I'm open to ideas
also, float is weird and it's honestly worth keeping separate in that sort of way
python's attempt at pragmatism ends up requiring quite a bit more complexity, like __index__
and now the python discourse forum has been talking about designing a complex literal type, pretty much just to avoid weird issues with floating-point zero
 
@KarlKnechtel There are lots of options, really. From banning module-level code like in Java, to having special hoisting declarations like Javascript
 
ah
Java doesn't just ban top-level code to get that effect - it has to - well, I guess that would be necessitated by banning top-level code too
in Python, the def and class statements are top-level code, so you wouldn't really be able to have anything without changing that part, too.
and then, Java can figure out the symbol names in a module statically.
in the design I'm working on, the top-level code implicitly is the body of a function that gets called when the module is imported (and there's some hook to alter what is passed to it; and that argument is the equivalent of sys.argv for the main module)
rather than automatically creating a module object, that function needs to return or export (long story) something that is the actual import result
but I haven't really thought about how the import cache will work at all. clearly it needs modification from python's approach
 
8:04 AM
My personal favorite solution/improvement would be to automatically delay imports for as long as possible. So if I write from .foo import bar, nothing actually happens yet. Only when I access bar (or the end of the module is reached) is it actually imported
Or, if a complete overhaul of the import system is on the table, remove relative imports, remove __all__, and instead introduce an export keyword (like export def foo():) and a namespace/package keyword
Oh, and remove __init__.py I guess
(The idea being that you can access everything from your own package without having to import it at all)
Yes I said it, I want automatic and implicit import *
 
how do you want it to find/import subpackages?
The __init__.py is for more than just declaring exported names.
also it sounds like you still want things namespaced, you just want them recursively imported
but I can't begin to imagine why one would remove relative imports especially if those other things are on the table
like half the reason for saying something is in a namespace is so I can get other things from the same namespace without writing its name all the time... right?
 
8:23 AM
I see two options there, either the file structure has to mimic the package structure (so finding the subpackage foo is as simple as importing the subfolder foo), or each project would include some metadata about all the packages and where to find them. The metadata could be automatically generated by poetry or whatever you use to package/upload your code
I guess relative imports could still be useful for importing stuff from a subpackage
So you don't have to write subpackage. all the time
 
8:46 AM
You can already make do without init.py today.
but the eager imports are needed to ensure evaluation order. Laziness is where Haskell and Monads live. You might not want to go there with a base language like Python.
 
Only relative imports would be lazy, I think that shouldn't be a problem
 
 
1 hour later…
10:12 AM
@Aran-Fey hm, I'm not following. why are we constructing the input string?
 
You don't have to construct it from scratch, you can also match the parser against the input string and modify the input string where necessary
 
 
4 hours later…
2:30 PM
In pyqt5 i have a QMainWindow with a lot of QFrames.
What can i do to remove the scroll bar and have something like carousel or any other alternatives?
The question is not about the code, but about what can i do instead?
 
 
5 hours later…
7:03 PM
 
7:17 PM
I'm... not sure how to answer that. Someone posted them, a long time ago
 
On SOCVR you can post requests in ending in but is explicitly prohibited there. Why is/were they allowed here?
And most of them are from 2015 and 2014.
 
@user16217248 There's some info at the end of our cv-pls policy page: sopython.com/wiki/cv-pls
 
I guess nobody cared enough to say anything about it. Personally, I'm not sure why they're not allowed or frowned upon in the first place
 
IIRC, delv-pls requests were pretty rare. And there was usually some discussion as to why a post needed manual deletion. We never want people to robo-vote to del-vote or close-vote, we expect people to make an informed decision after closely examining the post, and ideally, after discussing it with other room members.
 
 
2 hours later…
9:16 PM
I'd appreciate if someone could take a look at this code and tell me if there's a way to avoid all those asserts and the final # type: ignore
 
9:32 PM
I just noticed there's a bug, self._stdin_writer_task is never initialized or used in any way. All this boilerplate and the IDE still doesn't understand a lick of what's going on :/
Maybe I'll become a functional programmer
 
@Aran-Fey I can't offer great comment, but why does ProcessReader.__init__() allow process to be Optional, that seems to cause half the asserts? And if you do instantiate a ProcessReader with no process, I don't see that any subsequent method allows you to ever set one? unless you kludge it.
(This is someone else's code, not yours? Is their intent clear? What level of quality do you think it is? If not good, maybe just don't use it.)
 
Honestly, I don't remember why I made the process optional. But if you don't pass a process into the constructor, you're supposed to override _setup and initialize the process there
Now that I think about it the code is definitely not great, but it doesn't really matter. The core of my problem is that the type system doesn't understand mutable objects at all
 
Ah, this is some abstract base class then?
 
It's a hybrid. You either pass something into the constructor, or treat it as abstract and subclass it
 
...in that case I would regard all the asserts inside _setup() as being equivalent to raise NotImplementedError, would be better to raise that instead inside _setup(). (or else what's the proper way for a class to signal partial abstract-base-class behavior on some members inside some methods?)
 
9:47 PM
The issue is essentially that the object starts in a sort of non-initialized state where self._process can be None, but later enters a state where the process definitely is not None any more. I know that _stop_process and _setup and _read_stderr can only be called when self._process and self._stderr_reader_task are not None, but the IDE/type checker doesn't. And I don't know how I can convince it of this fact
 
Honestly that sounds confused. I'd refactor into a hierarchy of abstract base class BaseProcessReader where __init__() allows process to be Optional, and ProcessReader where __init__() requires a process. Also that should be cleaner for type-checking. (type-checking isn't full static analysis... but anyway it's nasty to expect a missing process to be kludged in a non-existent subclass which hasn't been written). That's the limit of my humble comment...
...Even before type-checking was a thing, I'd try to avoid writing a base-class which is partially abstract and partially concrete. (I read the pandas codebase and it has lots of hierarchy and ABCs)
 
10:11 PM
@Aran-Fey: I think it's a borderline abuse of the Optional type-hint. How should I use the Optional type hint?. Optional means "nullable", it's different to an optional arg which supplies a (non-None) default.
 
You mean I should write Union[..., None] instead?
No, wait, what? I don't have any optional arguments with a non-None default value
I tried my hand at splitting it into 2 or even 3 classes, but it just turned into a bigger mess...
 
 
1 hour later…
11:21 PM
@Aran-Fey No, you really should have a hierarchy of abstract base class BaseProcessReader where __init__() allows process to be Optional (nullable), and ProcessReader where __init__() doesn't. Show us your attempt to split it into 2 or 3 classes?
...we'll get to see which methods you think shouldn't be implemented in the base class. (e.g. what does the abstract base class's read() do if it can't expect to be passed a self._process and .stdout? Just raise NotImplementedError? or what?)
 

« first day (4732 days earlier)      last day (65 days later) »