« first day (4494 days earlier)      last day (437 days later) » 

12:33 AM
what to say when most of commits in the projects start with, fixed, minor fix, and commit message ends with 5 words and no descriptions in pr as well? drawbacks of working in startups?
 
12:46 AM
i rant too much
 
 
6 hours later…
7:04 AM
@Aran-Fey did you try raise err from None?
 
 
1 hour later…
8:29 AM
@KarlKnechtel Makes no difference
 
@Aran-Fey Pyparsing does this when packrat parsing (memoizing the parse results or exception for a particular expression at a particular location) is enabled, giving a huge performance boost.
Back in 200x when I added packratting, I had to clear the traceback before saving the exception in the cache, since not doing so was creating a memory leak in PyPy. I also opted for a FIFO cache instead of an LRU cache; the FIFO cache acted as a sort of TTL for the cached contents, and I didn't pay the penalty of moving accessed items to the front of the cache.
Here's the code (lines 964-967) where I stuff a ParseException into the cache.
Better link to that code fragment
 
9:23 AM
I wish I could have kept working on my own personal projects with that kind of dedication.
(FWIW I have considered forking pyparsing, a few times)
 
Pyparsing's exception tracebacks can also get pretty long-winded, since it recurses through the built up parser structure. So inner exceptions get raised as raise exc.with_traceback(None) unless a verbose arg is set to True.
 
 
2 hours later…
11:25 AM
Oooh, .with_traceback(None) is useful. Don't need to create a new exception every time after all
 
 
2 hours later…
1:20 PM
is there any way to bypass the GUI of a program to directly send commands to the program without going through the GUI, if this is not natively supported by the program?
i.e., is this a possibility with any program that has a GUI?
for example, take Word. i don't think it has native support for non-GUI behaviour, but could I in principle perform the task of opening Word, creating a new document, then writing "hello" and saving it, exactly as if this was done on the GUI, without using the GUI?
 
When you say "without using the GUI" do you mean "without manually clicking the GUI" or "without starting the GUI at all"? The two are very different requirements.
 
without starting the GUI at all is what I'm looking for
or if it starts, not actually using the GUI at all
 
I doubt this is possible to do in general
 
1:37 PM
hm I see
so if some program doesn't have native support for Python, there's no way at all to interact with it?
directly I mean, not through a macro
 
well, you can always automate interaction with the GUI, but that's specifically not what you were asking
 
hmm I see, thanks for that comment
 
I just came across the "programming FAQ" page, never seen it before docs.python.org/3/faq/programming.html. To be specific I found the "augmented assignment on a tuple item might lead to an error plus successful result" weirdness linked from the data model docs.python.org/3/faq/…
 
 
1 hour later…
3:04 PM
@AndrasDeak--СлаваУкраїні pretty sure we have a canonical for this, and pretty sure it links said faq
 
 
1 hour later…
4:24 PM
strlist = ['22.4', '22.42', '22.50', '24.9']
we have 22.4 < 22.9 < 22.42 < 22.50
my key function is given by
tuple(map(int, x.split('.')))
anyone has a nicer key function?
 
4:40 PM
22.9 is not less than 22.42. For this to work, you'll need to make sure that all the values are presented with the same number of decimal places. If you added '24.123' to the end, for instance, it would give you a key of (24, 123) which is > (24, 9), even though 24.123 < 24.9.
(Did you mean the last list item to be '22.9'?)
 
I think the idea is exactly that these are version numbers rather than floats
22 major 4 minor -> 22 major 9 minor -> 22 major 42 minor -> 22 major 50 minor
and yeah, looks like a typo in the first line
if these were floats then we'd just need key=float
@shintuku unless there's a standard-library version parser tucked away somewhere I can't think of anything better
well, maybe a listcomp instead of tuple-map-int but that's the same thing
 
Personally, I'm reserving map() for just when I'm in the repl, and saving on keystrokes. In code, I use the list comprehension - they read more clearly to me.
 
same
unless I specifically only need to assign the iterator, because somehow foo = (bar(baz) for baz in quux) looks even weirder to me
 
5:00 PM
whoops, strlist as typed above is the list that hasn't been sorted yet
it is as Andras says
i'll check out the list comprehension way
thanks for the comments!
if I understood you guys correctly, my key function would be:
lambda x: tuple([int(i) for i in x.split('.')])
 
that's a generator expression consumed by a tuple, but yeah, similar
no, list comp + tuple is pointless
lambda x: [int(val) for val in x.split('.')]
 
oh! i didn't know the key function could return a list
thanks!
it does look nicer to read
 
duck typing means that whatever quacks can be used as a key
 
 
2 hours later…
7:33 PM
do I have to make a class list to be able to access all items for a class, or is there a native natural way? e.g. do I have to always do this:
classlist = []
class MyClass:
    	def __init__(self):
    		self.append(classlist)
 
7:48 PM
That can't run, surely? I can't test right now but that would be very odd to me
50 quatloos that that doesn't run
The biggest question is what you're trying to do here? What is the problem?
 
whoops, I meant to write
classlist.append(self)
hehe, sorry
 
If you want the class to track all instances that exist,maybe you want a class variable. I'm really nervous now that you can use self.append() in a class constructor
 
any difference between using a class variable vs. a global variable here? I guess being able to name all such class lists the same
 
Innumerable differences. You either have a class that tracks its instances or literally any abitrary collection tracking them? I guess I enumerated them as 2... but the implementations could be so different
 
what if you named your global variable as your class? (trying to understand the difference here)
 
7:57 PM
Well then you'd have a name collision?
 
MyClass_list = []

class MyClass:
	def __init__(self):
		MyClass_list.append(self)
 
@roganjosh Why should this make you nervous?
 
@KarlKnechtel if such things are possible then I have a large hole in my understanding
 
@shintuku "all items for a class" (i.e., all instances of the class) is not ordinarily a useful concept in the first place. No, there is no internal tracking for that. It would waste huge amounts of memory for something almost never needed or used.
 
thanks for the correct term
noted, thanks for the answer!
 
8:00 PM
@roganjosh Quite possible. __init__ doesn't cause the object to exist; that happened in the builtin code of object.__new__.
 
I know you can attach properties to things you might not expect, but being able to append to any arbitrary object would shock me. But j can't rule it out atm
 
self isn't even remotely an "arbitrary" object here
 
I'm not following
 
in fact, the only thing that enables __init__ methods to work at all is the ability to assign attributes to self.
__init__ is just a function that was called, after the object was created, with self pre-assigned to be a new instance of the class.
 
OK, and it inherits append from thin air?
 
8:02 PM
Within that function, self is obviously in scope (it's a local), so we can do things with it (such as assigning attributes); in the examples, classlist is also in scope (it's a global), so we can look it up and modify the value (we aren't rebinding the name, so we don't need the global keyword).
Oh, you're still asking about self.append(classlist). No, that clearly doesn't work, and was acknowledged as a typo already.
 
That's... entirely what my comment was based on. Chronological ordering kinda matters
 
This attempts to work by looking up the append attribute and then calling it. You can look up whatever you like, but in general you won't find it, and thus can't do anything with the not-found result. You get AttributeError instead.
@roganjosh In my view of the chat, your comment saying that you're nervous comes immediately after the one acknowledging the mistake. This might not be consistent across all clients, and of course there is lag between thinking about a comment, typing it, and propagating it
anyway, not important I guess. sorry for the confusion
 
No worries :) You just added to my fear of spooky python dark corners :P
 
(It's not so much that there are dark corners, more like the illumination model is not what other languages train you to expect)
 
class A takes 3 __init__ arguments
class B(A) takes 3 too
class C(A) takes 2
is the best way to deal with this to set the third argument of class A to None (or anything else) by default?
 
8:11 PM
Depends. Why is the different number of arguments a problem for you?
 
B(A) takes a name, an initial line position and a final line position, to get text between these two positions
C(A) takes a name and a position, which takes text only at that line
 
But why do you need all 3 constructors to have the same parameters?
 
all methods which use B(A)'s two positions will work if you repeat the position twice, making it natural to put these methods in A
@Aran-Fey I'm making a program to help me memorize text; RecallObject is the first class, Page(RecallObject) is the second class, PageItem(RecallObject) is the third class
the parameters here give a name to the object and their location in the text
 
I guess before we go too deep into details, I should mention some alternative way of making the constructors exchangeable. One way is functools.partial, i.e. b_constructor_with_2_parameters = functools.partial(B, third_parameter='default value'))
In other words, if all you need is a callable thing that takes 2 arguments and returns a A/B/C object, you don't necessarily have to change anything about the constructors
 
let me read up a second on how functools.partial works
hm, but wouldn't this give my partial objects the same methods that are in B(A)?
yet B(A) has some methods that C(A) doesn't have
 
8:24 PM
partial objects don't have any methods. The only thing you can do with them is call them
 
hm, i'll read up some more. thanks for the comment btw
 
@KarlKnechtel "illumination model". That's a term I never saw before. Do you mean by that the intuitiveness or how a model is understood?
 
@Aran-Fey If I understood the workings of functools.partial correctly, if initializing an A instance takes 3 parameters and initializing a C(A) instance takes 2 parameters, wouldn't using functools.partial also give a third parameter to C(A)?
 
No, it takes parameters away
>>> needs_3_args = lambda a, b, c: (a, b, c)
>>> needs_2_args = functools.partial(needs_3_args, c='default')
>>> needs_2_args('a', 'b')
('a', 'b', 'default')
 
hm right, thank you for the explanation
 
8:38 PM
Don't bind lambdas to names though :P
 
 
2 hours later…
10:43 PM
@NordineLotfi nothing like that. I was just extending the metaphor of "dark corners". they only seem dark because one doesn't understand the metaphorical light shining in that direction.
@shintuku the important part is: what will the logic look like, that creates the instances? For example, do you need to parse some data file to create arguments for the constructors?
because if you are just going to make hard-coded calls to the constructors, then just do that; the argument counts won't matter.
that said, there's a canonical for basic use of functools.partial: stackoverflow.com/questions/277922/python-argument-binders
... speaking of which! duplicate stackoverflow.com/questions/75348794, to the link I just gave. I'm out of votes
 

« first day (4494 days earlier)      last day (437 days later) »