« first day (3861 days earlier)      last day (1070 days later) » 
00:00 - 20:0020:00 - 00:00

12:16 AM
@lorelayb for what it's worth, it's usually not worth including a font in e.g. a web application just so you can render an SVG--just convert the SVG element from a text tag to a path and save the path. Then you don't need the font and life is simple
 
Doesn't that inflate the size and potentially introduce artifacts?
 
@duhaime I see! in this case, I'd like to preserve the tag as text and not as a path because I'm trying to change the value of the text (the words in the text) and after that do the conversion from SVG to a PNG.
 
12:43 AM
Oh the contrary, the path should be smaller than the full font size. Think about it--the font has data for all sorts of glyphs that aren't in the path...
But don't take my word for it! Check and see if the byte size of the svg with the path is smaller than the full font file and the svg with the text element combined
Hmm, are you building an asset for an application? Or are you building an application that runs this kind of conversion?
@lorelayb can you show us the SVG? Is the text doing something complicated?
 
 
5 hours later…
5:20 AM
Oh! @duhaime maybe I’m not getting the idea. For example, if I have a text that says “hello”, and it is converted into a path, is there a way I can change the “hello” message to something else now that it is a path (for example, replace “hello” by “goodbye”)? I’m trying to preserve the text tags (instead of switching to paths) so I can basically change the “hello” message into something else since I don’t have a way of modifying a path the way I can modify texts (If I’m not missing something here).
the SVG File: easyupload.io/ydp6zy
 
6:00 AM
Some expert of pytorch?
I asked this question stackoverflow.com/questions/67466741/… but I still have no idea of how to solve
 
 
2 hours later…
7:41 AM
@CasellaJr discuss.pytorch.org is also quite responsive btw
 
8:21 AM
A high rep user just edited my solution into their answer :/ is this normal? not that they dont know how to figure that, but just felt kind of off to do that
 
8:31 AM
Hard to say. Could be plagiarism... or they could just have had the same idea as you
 
I find myself not able to pick a side on this. because we do often wish for answers to be more complete, updating information with things they miss out on.
 
yeah maybe they wanted an overall complete answer, its not like they couldnt have figured it out, the sneaky < 5 mins edit sure makes it a way to answer first then edit
 
I know what you mean. i dislike the rep gaming that goes on sometimes, especially on certain tags. I personally don't care too much about rep, so i manage to avoid worrying about these issues that much
 
btw I noticed Flask 2.0 with async view support, might try it out this eve
 
cbg
 
8:43 AM
cabbage
 
 
2 hours later…
10:49 AM
cbg
 
11:11 AM
@lorelayb is this for a website? Why are you converting to a png? Why does the text content need to be dynamic? Knowing the answers to these questions can help us help you
 
 
1 hour later…
12:19 PM
I'm trying to figure out the best way to translate a set of points. I have the following:
Does anyone have an idea for how to fill in a corresponding set of points on the two empty sides?
Here is my code
 
Well, you already have a working approach for plotting a dotted line between two corners. Can't you just run it two more times using the final corner as a parameter?
 
I could and have, just wondering if there is a trick to flip this or something
 
If you know the shape is a parallelogram, you could copy the existing lines and rotate them 180 degrees
 
It's guaranteed to be a parallelogram. I'll try that.
When I originally completed this I did not use the last point as an actual parameter and my initial case was oriented in a way that made it easier, as in all of the ordered pairs on one side shared a value, x or y respective to the side. But this layout posed greater problems for me. I guess moving in reverse off the last point might be best, as you initially mentioned. I have my morning commute to think about it.
 
12:38 PM
Something like this is what I had in mind.
 
Thanks. I’ll run it when I get to work.
 
I've been working with vector math and parallelograms all week, and I'm trying to think of a way to summarize what I've learned without boring you with a lecture... Maybe something like "you can do almost anything without ever inspecting a point's coordinates"
"inspecting" being a rather fuzzy category of actions, usually involving a conditional doing an inequality on a scalar, for example rdirection = -1 if rax > rbx else 1
 
@Dodge convex hull?
Might not help you, hmm
Not in itself I mean
 
The most rugged vector/geometry algorithms don't care about coordinates, because they work just as well no matter what coordinate system you use
 
@Kevin yup
Coordinate-free geometry ftw
In this case corner differences give translation vectors
 
12:56 PM
On a somewhat related topic, last night I came up with an approach in MS paint to draw a circle with a given center, and whose circumference passes through a given point. This is a trivial action in compass-and-straightedge problems, but it's nontrivial in Paint because it defines circles by their bounding box, not by their center and radius
 
1:13 PM
Here's the first 75% of the visual construction. The sub-objective here is to find C such that AC is horizontal and AC's magnitude is equal to AB's
 
I'm starting to get concerned about your ongoing obsession with MS paint :p
 
In other words, rotate AB so that it's flat. So very very easy if you have a compass, but Paint does not have a compass.
@JonClements It's fine, it's fine
 
I'll keep my paws crossed it stays that way :p
 
1:30 PM
If I have:

l = [1,2,3]
l[:max_records]

is there a value for max_records I can provide to get all items in l?
(aside from len(l))
 
I propose None
 
yup ^
 
stackoverflow.com/questions/14978575/… he is using "with file()" but I generally use "with open()". I notice he is using Python 2.7, is this a difference between python 3+ and 2.7?
 
Nice :)
 
@ChristopherBrown yes, file doesn't exist on 3
 
1:32 PM
Thank you!
 
Even when I used 2.7, I preferred open over file, and I believe this was the recommended practice
 
Probably, yes. I've never seen file being used anywhere (then again I started late).
 
I basically only used file in the REPL so I could view the help documentation for various file methods without first creating a file instance with open
Compare:
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help(file.readlines)
Help on method_descriptor:

readlines(...)
    readlines([size]) -> list of strings, each a line from the file.
#etc
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help(file.readlines)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'file' is not defined
 
got it, thanks. I was just making sure I wasn't missing something in my header that he had left out of his example. and header, that's the top part with all the "from tkinter import *" stuff right?
 
"Header" is not a formal concept in Python, but sure, you can think of the top bit of the program as the header.
 
1:36 PM
Learned two new things today, open and file and help()... need to keep that in my back pocket.
 
Users that do not include their import statements in their questions and answers must be slapped with a medium sized herring
 
happens often, which is why I asked lol.
 
bikeshedder there gets a double slap because he clearly didn't run his own code to verify it was syntactically correct, because with file("data.csv", "a" as fh: isn't
 
no he didn't... I noticed that in my first question because that was the line I copied, and I just thought it was my bad for not selecting it all. I trimmed it down to just the file() because that is what I was interested in.
but, he did help me figure out how to open the file as both read and append, so bronze star?
 
I try not to get too worked up about incomplete code as long as the reader still learns the important part
Take that "someone is wrong on the internet" impulse and push it down real deep
 
1:45 PM
especially because "answered Feb 20 '13 at 11:41". Over 8 years ago lol.
 
@ChristopherBrown if you want to sound fancy you can borrow LaTeX's "preamble" term (but that's well-defined there, because documents start at \begin{document})
 
oooo, then my code and the U.S. Constitution will have something in common lol
 
We the Coders hold many truths to be self-evident, which is why we don't bother writing documentation for them
7
 
Hi anyone here?
 
1:56 PM
@boyenec no
 
:)
I am stack an django problems
 
@boyenec please take a look at our rules before you ask sopython.com/chatroom
 
okay
 
Hmm, I'm not pleased that TkDocs only documents findclosest in the mirror of the NMT docs from 2013. You were the chossen one, TkDocs ;_;
You were supposed to encompass and surpass all of the abandoned half finished docs, not become them
 
2:02 PM
What aspect of tkinter makes it hard to document? Evil curse?
 
@Kevin umm... help(io.FileIO.readlines) ?
 
@AndrasDeak I'll chalk it up to a combination of 1) skilled users may migrate to Qt (et al) for a variety of reasons; 2) You have to learn an entire other language (tcl) if you want to properly understand fundamental behaviors of Tkinter
... In addition to all the normal reasons nobody documents things, such as "maybe if I wait long enough, somebody else will do it"
 
That appears to be working. Thanks @Kevin and @AndrasDeak
 
Looking good :-)
 
Save for the off by one error on the last row and range but that's easy
 
2:12 PM
I don't use TkDocs though
anzeljg? Seems nice
 
I believe I've sung the (relative) praises of the New Mexico Tech docs before. TkDocs also hosts a mirror of those pages, FWIW
It's exactly those documents that turn up when I search tkdocs for find_closest tkdocs.com/shipman/canvas-methods.html
 
Oh, so that is what NMT stands for. What is anzel though
 
As far as I can tell, just a regular fan of Tkinter that wanted to mirror the NMT docs on his github
 
Ah, the good people
 
I'm 65% sure there's supposed to be a canvas method that tells you which polygons/arcs/etc contain a given (x,y) point, but I don't see it here. Not sure if it's poorly documented, or if I imagined it
I'll get a second opinion from the wayback archive of Fredrik Lundh's tkinter docs...
 
2:21 PM
@Kevin What about find_enclosed()
 
@CoolCloud Not useful unless I happen to know how wide and tall every element in the canvas is ahead of time... But find_overlapping might work
 
yay, when you learn how to reduce code by 1 line lol. Old:
test = string.find("asdf")
if test >= 0:
string found!
new, if string.find("asdf") >= 0: etc, etc. woot! Sorry, wanted to share my small victory lol.
 
@ChristopherBrown Great!
 
@ChristopherBrown Have an additional victory: if "asdf" in string:
 
@boyenec please don't ask for help here with fresh questions on the main site
 
2:23 PM
@Kevin mind blown lol
 
@Kevin Hmmm I see
 
@ChristopherBrown please see our code formatting guide to chat
 
I am thankful that I almost never need to use str.find. I had enough of that for one lifetime during my C++ days.
 
You guys get annoyed when system lags like hell??
 
2:26 PM
searching through pdfs, for substrings to classify stuff. Probably a better way to do it, but I'll brute force my way through it for now.
 
@Kevin it's also quite easy if someone doesn't read the docs to think of doing if string.find('something') - which is likely to end up consuming a bit of debugging time :p
 
Asking, but also practicing formatting code for chat skills,
`if row[0].find(noa) >= 0:`
is the same as: (sorry if it's too vague)
`if noa in row[0]:`
 
likely depends on what row[0] is...
 
for row in readCSV: really trying to get this backtick to work...
 
Backticks don't work in multiline messages, if you were wondering about your previous attempt
This is mentioned in sentence 2 of our code formatting guide... Maybe I should make it bold instead of italics
 
2:34 PM
Ctrl + K for multilines
 
If I read down on that page you linked Andres, I would have seen the common issue "Indenting only the lines of your message that you intend to be code. This does not work. Every line must be indented; you can’t mix plaintext and code in a multi-line message." which is why my first attempt did not work.
oh look, a sandbox room for me to fail in lol
 
2:48 PM
"Hmm, I want to print the repr of the string here... Oh, I'll use that cool format specifier Jon told me about the other day. How did it go...?"
>>> s = "foobar"
>>> print(f"warning: can't frobnicate {s:r}")
ValueError: Unknown format code 'r' for object of type 'str'
>>> print(f"warning: can't frobnicate {s:sr}")
ValueError: Invalid format specifier
>>> print(f"warning: can't frobnicate {s:!r}")
ValueError: Invalid format specifier
>>> print(f"warning: can't frobnicate {s:r!}")
ValueError: Invalid format specifier
"... Maybe I'll just keep doing f"can't frobnicate {repr(s)}" :-/"
 
@ChristopherBrown it's almost as if the page was meant to be helpful....
 
I have now learned it's {s!r}, but I 100% guarantee I'll forget by next time
 
>>> print(f"warn: can't frobnicate {s!r}")
warn: can't frobnicate 'foobar'
I'm not quite sure I understand what is the information given by the ''
 
As in, how is it useful to put the string in apostrophes? It isn't really, but !r does other things too, for example escape special characters. Example:
>>> s = "foo\nbar"
>>> print(f"Warning: can't frobnicate {s}")
Warning: can't frobnicate foo
bar
>>> print(f"Warning: can't frobnicate {s!r}")
Warning: can't frobnicate 'foo\nbar'
 
frobnicate, what a fun word. I learn so much by just sitting here lol
 
3:01 PM
Wait until you hear about all their other made-up words, like lettuce and spline and bezier
 
@Kevin oh, nice, thx :)
 
3:26 PM
GUI with Python Calculator Application // Why are buttons not showing? It was all perfect, untill the eval in source code
I wonder if sympy has something that would parse '6*9+6+9'
 
As far as I can tell, that particular answer doesn't use eval
 
@Kevin I mean it doesnt have the function there, but in the link given above to Calculator PRO, it has eval.
 
I'm tempted to comment "I downvoted your answer because it doesn't contain the full code", and then when he edits the full code in, say "I downvoted your answer because it uses eval"
 
TBH, I would upvote it for the brilliant design :P
@Kevin evil :p
 
@CoolCloud might be able to utilise numexpr
 
3:34 PM
eh, that's a bit overkill
 
@JonClements It says 'for numpy' but I assume it would work with numbers too?
@AndrasDeak Is it?
 
yes, using a full-fledged JIT compiler is overkill
 
it works though lol
 
@AndrasDeak I've heard JIT before, it is used for PyPy right ?
 
@CoolCloud among other things, yes
 
3:35 PM
(plus it's got some functions available that you'd find on a calculator...)
 
Any other better way, to parse?
 
just type it into wolfram alpha? :p
 
@JonClements Hax
 
I'd be inclined to verify that the expression only contains numbers and arithmetic operators, then eval it
that's somewhat easier said then done if you want to support floats including complexes
 
I was about to say, since the string can only contain the values that the buttons can provide, eval is... Less dangerous here than average.
I would say you could plausibly go through the code and formally prove its safety.
 
3:38 PM
How bout I disable the entry and just allow to work with buttons? That would be kind of non user friendly
 
Oh, the code has an entry? Never mind, it's totally insecure.
 
Not a huge deal though. I toyed with the idea of writing a small safe eval parser when this last came up a week or two ago. It should be easy enough to allow arbitrary combinations of literals (if I don't include strings in the definition of literals).
My rough plan was first re.replacing valid floats (including complexes) with '' for the safety check, then check if the remaining characters are arithmetic operators or brackets or digits. Then off it goes into eval if OK.
 
I suppose ast.parseing the string... walking the nodes to validate they're all of acceptable types, then if they are, evaling the string might work... (probably simpler than walking the tree and calculating as you go...)
 
I endorse Andras' suggestion of verifying the expression, then eval-ing it. You could even generalize it by supplying a whitelist of exactly which ast nodes are permitted, and which aren't
 
here in the Eastern Bloc we don't mess with ASTs
 
3:44 PM
No idea what nodes are
So I guess, the overkill solution is the one I could use here
 
nodes in the AST, obviously
@CoolCloud yeah, gotta be careful not to do things too right
 
My next question was, what is AST, but I googled it :P
 
good luck to your users when they need a C compiler for '6*9 + 6 + 9'
 
Damn
Perhaps something lightweight
 
Like parsing the string yourself? Excellent idea!
 
3:48 PM
import ast
def less_dangerous_eval(s):
    """NOT GUARANTEED TO BE SAFE"""
    whitelist = {ast.Expression, ast.BinOp, ast.Constant, ast.Add, ast.Div, ast.Mult, ast.Sub, ast.Pow}
    tree = ast.parse(s, mode="eval")
    for node in ast.walk(tree):
        if type(node) not in whitelist:
            raise Exception(f"forbidden node type: {type(node)}")
    return eval(s)
print(less_dangerous_eval("1.2 + 3 / 4 * (2 ** 3)"))
 
I was suggested pyparsing has features to do this by Paul
 
I recently wrote a pretty similar parser. Was surprisingly easy, although writing all the classes for my custom AST was annoying
 
@python_user yes, you can generally parse strings with a parser
 
Annoyingly, less_dangerous_eval("'foo'+'bar'") is legal, and not 100% trivial to forbid with simple type checking
 
Why is that annoying?
 
3:51 PM
Because I intentionally want the user to have as little power as possible, even if it's harmless
 
I guess Ill look for other methods than parsing
 
*sigh*
 
Ill try to bring a code up here soon
 
The sentence following this one is not an admission of my legal liability in the event my code is unsafe. I'm pretty sure my code is safe, I just put the scary docstring there so you don't sue me in the 0.1% chance I'm wrong
 
@Kevin Oh
 
3:56 PM
You can't call functions or define functions or execute statements or access attributes... That closes the usual loopholes that come to mind
 
Can you create classes?
 
is there any actual case where eval has caused security issues and loss to someone?
 
@Aran-Fey Let's see... Nope. It doesn't even get to the whitelist checking loop, since mode="eval" rejects any statement other than an expression statement
 
Never mind the eval... the indentation and the typo of opeartion throughout the code has made me go "ugh"...
 
@python_user I am 99.999% certain that it has. But it is a good question... I wonder if there are any well-documented historical events.
 
4:00 PM
@Kevin I mean if the user has the input and the user types in something, its users fault right. Why are we accountable :p
 
maybe my google keywords are off "sql injection real life" yields promising results but "python eval exploits real life" does not
 
A question that I think is more relevant is, "has eval ever caused a security issue, when used in an application run on the user's local machine, with exactly the same permissions level as the user running it?"
 
does it include damage by having the user set a precedent "oh it was fine that one time, i don't understand why it's not fine here in this api im about to expose to the whole of internet"
 
obligatory...
 
oh btw, thanks for writing an epic pandas answer that just saved my bacon @piRSquared :P
 
4:10 PM
May 1 at 14:02, by Kevin
@CoolCloud here is a quick framework for four-function arithmetic evaluation. 99.999% guaranteed to not let you get hacked
 
@Kevin That was legendary :p
 
I consider the framework from May 1 even less dangerous than less_dangerous_eval, because, well, it doesn't use eval().
Let's say less_dangerous_eval is 99.99% safe, so you're getting a whole extra 9 here for just a few lines of code more
Bonus, it's ever so slightly easier to forbid strings and other undesirable constant types
If you're thinking "both approaches look 100% safe to me", there is a good chance you're correct. But I won't give a perfect score to anything that uses the letters e, v, a, and l in that order
Just typing its name draws attention from gods that like cruel irony
 
@Kevin meh... doesn't even use {node.op!r} :p
 
I welcome you to fork the code and make your own improvements (<font size=0.1px>and assume all liability in perpetuity</font>)
 
Any idea on how to get the border color like this? i.stack.imgur.com/yaq3E.png
 
4:22 PM
something other than paint and a lot of copy paste? :P
 
@ParitoshSingh yw (-:
 
You could code up a RoundedRectangleButton widget from scratch, using a Canvas to render whatever you wanted... But it would be annoying to re-implement all the nice features the Button widget already has, especially the ones you don't know about
 
@Kevin I did try highlightthickness=5,highlightbackground='white'. It gives me no border, and IDH any idea why
 
I also don't have any idea. The finer points of styling aren't my strong suit, as I'm usually content to leave my GUIs functional yet unbeautiful
 
4:29 PM
Users, be grateful when my widget layout is more complicated than "a single vertical column"
 
If the window isn't taller than your screen, then you are one of the lucky ones
Hmm, the Windows OS API has an interface for fully controlling the appearance of a button while retaining its nice features... I wonder if you can drill down to that from Tkinter.
It's at least one abstraction layer beyond Tcl, which makes it proportionally more difficult to get to
 
I can never remember if tkinter is actually part of the stdlib or not. I know tkinter doesn't work out-of-the-box on linux, but is that only because tcl/tk isn't installed or (additionally) because the actual tkinter module is missing?
 
its part of stdlib
 
4:38 PM
I think it's the former. When Python is installed, by default it will try to install tkinter, if its dependencies exist.
(Confidence: 85%)
 
but yes, also missing from preinstalled python versions, which is i guess linux doing linux things
 
Come to think of it, I don't think I ever installed tcl/tk on any of my computers. And yet, tkinter is available to me.
 
tkinter is by default also missing on MacOS when installed via brew. :/
 
Maybe the Windows installer has a little more handholding
 
but yeah, even though i dont use linux, there's definitely some distributions that are missing tkinter itself. I remember someone mentioned it
 
4:40 PM
On Windows, tcl/tk is bundled with the python installer
 
I never understood why things like venv are separate debian packages
 
This inconsistent installation process is reason #3 that tutorials are hard to come by
Windows might have a market share thirty times larger than Linux, but I'd wager a pretty quatloo on which demographic produces more and better documentation
 
@Kevin Windows folks?
 
Thoughts: That syntax theme is so awful, I can barely read the code :|
 
4:45 PM
@MisterMiyagi Maybe so! On an unrelated note, are you interested in buying a bridge? ;-)
 
@Kevin Depends. Can I interest you in some fine leather jackets?
 
First I want to tell you about an exciting sales opportunity for these herbal supplements that are flying off the shelves
 
@Aran-Fey I should've send the picture of UI, it was done fast, so ya
 
/-:
 
@Kevin All products powered by 100% genuine quantum!
 
4:48 PM
Warning: opening product may collapse waveform
 
This side up and down.
 
Strange, yet charming
 
A beauty, one might say.
 
All my favourite colors
 
On macOS the UI looks nice though.
 
4:52 PM
'Course it does. It's MacOS.
 
One reason to switch :p
 
@CoolCloud Looks much nicer than what I usually make.
 
I wouldn't take much credit, as the color codes are taken from other answer, but I wrote this quick, so kudos to me :P
 
Pointless code style challenge: rather than having separate loops for creating the button and gridding it, try to do it in one block. (nested loops allowed)
 
Interesting, no spoilers. Well I gtg for now. But ill try this soon
@Kevin Am I allowed to use a function?
 
5:02 PM
Yeah.
 
Nice, that's essentially one of the solutions I had in mind.
 
@Kevin What's the others?
Ugh screw it, this is better paste.pythondiscord.com/ehazuvuyex.bash ...I think
 
Something like
texts = [
    ['DEL', 'C', 'x²', 'v'],
    ['1', '2', '3', '+'],
    ['4', '5', '6', '-'],
    ['7', '8', '9', 'x'],
    ['.', '0', '=', '÷']
]

#not pictured: some code unrelated to the challenge

for j, row in enumerate(texts):
    for i, name in enumerate(row):
        btn = Button(text=name, etc etc)
        btn.grid(row=i, column=j)
 
Hah, enumerate.
 
5:07 PM
Bonus: works on "jaggy" sequences-of-sequences. Delete the hyphen from the third sublist, for example, and it won't muck up the placement of the rows below it
 
@Kevin arrays?
 
Hey, it could work on an array... If DEL and x^2 were shortened to one character each.
 
@Kevin I did not get you
 
I'll concoct an illustrative MCVE in a bit
 
Okay cool, I gotta go for now, I'll take a look soon :D
rbrb
 
5:15 PM
hello all
i am waiting for a nice time to ask a little help
 
Now is a nice time, it seems :-)
 
thanks
list = [a,b,[c,d]]
output = [[a,b,c],[a,b,d]]
i am working on combinations, implemented via 2d nested lists
i cannot devise an efficient way to accomplish this
list2 = [a,[b,c],[d,e]]
ouput2 = [[a,b,d],[a,b,e],[a,c,d],[a,c,e]]
(orderings trivial)
do offer some advise if you do have one
previously i tried itertools.product
 
I bet you could do something with itertools.product. Just takes a little bit of work to get it into the correct format first
 
but it does'nt do well with objects
 
Essentially it won't work unless every element of your list is also a list.
 
5:21 PM
obj type not supported
 
So, just put each object into a list, and you're 90% of the way there
 
Things should be easier when you wrap everything in a list.
 
hints are wanted
 
Poll: does a class attribute that doesn't start with _ imply that it should be accessible for something useful?
 
Rule of thumb: all of the elements of a list should have the same type unless you have a very very good reason to do otheerwise
 
5:22 PM
@roganjosh I am inclined to say "yes". If something isn't useful, it should be removed.
 
Myself, I think accessible attributes are allowed to be useless, for certain definitions of "useless"
 
@Kevin does that mean, i should not have nested list ?
 
I just got some strange feedback on one of my libraries that a list of custom objects wasn't particularly useful. It wasn't meant to be useful for the end user and they didn't have an answer for why they were trying to use it, but I didn't go so far as to make it "private"
 
@roganjosh except deprecations (backwards compatibility)
 
@PIngu Not necessarily. A nested list can follow my rule of thumb just as easily as a "shallow" list
 
5:24 PM
If you have documentation of a public API then I'd argue that whatever isn't there is undocumented and should be ignored by end-users anyway.
 
@MisterMiyagi To the library itself it's needed, I just didn't feel the need to make it "private". I just thought it was odd that someone would therefore assume that they could do "something" useful. That's not really how I interpret "public" variables - "Oh, well I must be able to do something good with this"
 
Are Sequences supposed to be slice'able? The docs seem reluctant to make a clear statement.
@roganjosh Whenever you have problems with publicity, just ask your friends to take a look as well.
 
@Kevin should i resort to list comprehsion and convert each of the element into a inividual, list object; and proceed ?
 
@roganjosh Seems to me as if it does something useful, then. Just not for ComplaintFiler27.
 
@MisterMiyagi as far as I remember... a Sequence should implement __getitem__ but doesn't require it to actually support slicing...
 
5:28 PM
Oh, it's definitely needed for the library itself because it collects user objects throughout. I'm familiar with the view that _ effectively means you don't need to worry about it, I just didn't know that the reverse could ever imply that there was some reason you'd need it. Apparently to some people it does :P
 
@MisterMiyagi are deques sequences?
 
@AndrasDeak My dreams will be crushed if I answer "yes", won't they?
 
@PIngu Yeah, that could work. Here's a prototype that doesn't use list comprehensions. It would be pretty easy to convert it.
 
@AndrasDeak I've spent some time pondering this and I think you're alluding to something I might not know about in the deprecation system
 
import itertools
def janky_combinations(seq):
    x = []
    for item in seq:
        if not isinstance(item, list):
            item = [item]
        x.append(item)
    return list(itertools.product(*x))
    #list() call not strictly neccessary here, but one thing at a time

seq = ["a","b",["c","d"]]
print(janky_combinations(seq)) #[('a', 'b', 'c'), ('a', 'b', 'd')]
seq = ["a",["b","c"],["d","e"]]
print(janky_combinations(seq)) #[('a', 'b', 'd'), ('a', 'b', 'e'), ('a', 'c', 'd'), ('a', 'c', 'e')]
 
5:30 PM
@MisterMiyagi I can't bring myself to crush your dreams so I'll just sit here whistling...
 
@MisterMiyagi depends on your dreams :P
But if sequences need not be sliceable then there's probably no category that mandates sliceability
 
@roganjosh Good summary of my definition of "useless" that I never got around to describing. If deleting it makes the code break, it wasn't useless, regardless of ComplaintFiler27's opinion.
 
@Kevin thanks miracle maker, for the not so janky function
i never knew i could harness itertools this way
 
It's not that the variable itself has no use in any case (I maybe described the situation incorrectly). I think what they basically did was call dir() on Problem, saw Problem.jobs and therefore assumed that they would need to access it - they probably won't. If I'm breaking convention then I can just make it Problem._jobs and break nothing, I just didn't think I was communicating to the user that they would ever need that attribute by not making it private
 
Itertools is useful and cool and good
 
5:35 PM
@Kevin and sometimes evil? :p
 
@roganjosh so what's the documentation status?
 
In other words, where I can make a clear-cut call of YAGNI, I'll make it private. If I have no reason to assume they won't need it under some unforeseen use-case, I just leave it be
 
Problem is a class or a module?
 
@AndrasDeak The variable is not documented in the docstring because it's internally built by the class
Problem is a class
 
with classes i think it's better to be stingy with parts that are intended for internal use
 
5:36 PM
@roganjosh Personally, I only make something private if the user playing with it would be truly catastrophic. If the class can't delete files or fire a radiation beam, then the user can touch all the attributes they want.
 
if someone needs it, they'll find it anyways, is the stance i take
 
The reason they'd catch it in dir() is because I make an effort to init empty collections in __init__ so that you can see all the attributres
 
I, too, like my attributes to exist by the time __init__ finishes
 
@JonClements Oh well, that's a comfort at least.
 
@JonClements Evil in, evil out. Although admittedly it may exponentially increase the evil in the middle.
 
5:41 PM
sum(itertools.count(1)) is always fun... :p
 
i really wouldn't blame itertools there :P
 
had i been taught this earlier, i could have saved days of time..
It not too late nevertheless. Thanks for helping me through this pitfall, you have taught me a lesson of lifetime
 
👍
 
And the answer to "do you have a good reason to do otherwise" is... No. no you don't. :P
 
i need to rewire my previous code and make sure it abides by the rule of thumb
 
5:44 PM
Rule of thumb: if you and a coworker disagree about a design choice you have to decide with a thumb war.
 
@AndrasDeak I'm not sure I like that approach - puts me at a distinct disadvantage...
 
paws and claws allowed if your argument needs to be especially convincing.
 
This looks like fun
 
A Slack thumb war :)
 
 
1 hour later…
7:14 PM
Hi! i'm trying to install PyGObject via Pycharm in a Python 3.9 venv and I'm getting this: ERROR: Could not build wheels for pycairo which use PEP 517 and cannot be installed directly. How would you people suggest to go about that? Use an older version of Python, get a pre-built wheel of pycairo?
 
Are you on Windows? I didn't realize there was an up-to-date PyGObject installer
 
When pip fails, the next thing I try is looking for a wheel, usually at lfd.uci.edu/~gohlke/pythonlibs/#pycairo. I see there's a 3.9 build available...
 
Oh, sorry, yeah, I'm on Linux. Fedora to be specific. I could use a dnf-distributed package, but I want to make sure that at one point I'm able to package my app as a neat Windows installer, so I prefer to use venv
Yeah, so @Kevin my bad for not saying I'm on Linux. There are pre-built wheels on PyPi, too, but none for Linux. Maybe I'm missing something, maybe a whl for Linux cannot be built that straightforward?
 
I don't see how installing cairo via pip (on linux) will make it easier to package for Windows
 
It's not that I want to install it specifically via pip, it's rather that I could use system interpreter with PyGObject installed using dnf , but I want to use venv and have PyGObject in this venv to be independent from system env
 
7:22 PM
Fair enough. Unfortunately I can't help there because I've only ever installed pygobject stuff via the package manager
 
github.com/pygobject/pycairo/commit/… at least indicates that they think 3.9 is supported...
 
I'm surprised that the error message actually contains that grammar bug github.com/gfduszynski/cm-rgb/issues/45
@KrzysiekSetlak does --no-use-pep517 work? Never seen that and I don't know what PEP 517 is about, but someone one the internet recommended it.
 
PEP 517 -- A build-system independent format for source trees. No idea why this would make it incompatible with usual install approaches
 
Is this about pyproject.toml?
 
Reply hazy
 
7:28 PM
According to this, a simple pip install should work
 
When I tune my crystal ball to build problems, I just get elevator music
 
Well, --no-usepep517 only lead me to a complaint about pkg-config not found... So to install using pip in a venv, I'd have t set up the entire shell environment
 
...unless they were too stupid to list all those dependencies in their setup file, in which case you may actually have to install them manually beforehand
 
> According to this, a simple pip install should work

So my thought process is "I wish that worked, so I'll try and maybe it will" and... I tried it, but no from within PyCharm, but from bash instead and it's... Busy. Doing something. So maybe it's a good sign. But on the other hand, wait, I've just re-thought @Aran-Fey 's question

>I don't see how installing cairo via pip (on linux) will make it easier to package for Windows

shoot, I'm dumb, I'm hell bent on cramming Linux binaries inside... I'll have to package it on Windows anyway and I have wheels there
 
I get a vibe of competence from their github, so I don't think they'd make their userbase do anything too hacky to accomplish some reasonable use-case.
 
7:35 PM
Yeah, I'm doing a U-turn, I'm booting my Windows machine, screw development on Linux
I mean screw it only in this single case
 
Using GObject in Windows is a mess, so good luck
Although, to be fair, everything in the G-family is a mess, always.
 
@KrzysiekSetlak how old is your pip?
Although if it knows about PEP 517 it probably can't be too old
 
>Although, to be fair, everything in the G-family is a mess, always.

I don't disagree, just wanted to give it a go
>KrzysiekSetlak how old is your pip?

Brand new!
 
OK, thanks
 
But nevermind, I've already switched to Windows and I'll see if it's easier here
 
7:43 PM
Giving up on life so easily?
 
*Narrator: It wasn't. And yet, it was. Because such is the duality of GObject.*
 
Vague question: Is there a way to precisely store a constructible number in a non-recursive data structure? I thought I could do it as <rational> + <rational>*sqrt(<rational>) but I don't think I can represent sqrt(sqrt(sqrt(2))) that way
 
Oh, no, I'm just choosing my battles. I promised to explore something for someone so I just want to bite into it ASAP and focus on the point and keep technicalities as simple as possible
But if it was just soemthing I did "for me" as a hobby, I'd probably be on the very opposite end of the spectrum, spending half a night to do it in a way that some damaged part of my brain that drives me most of the time would approve as "elegant"
 
@Kevin Is sqrt(sqrt(sqrt(2))) constructible?
 
Sorry for a overly complex sentence, but the bottom line is this "elegant" would haunt me, though I can't define it :D
 
7:47 PM
If wikipedia is to be believed, then sqrt(sqrt(sqrt(2))) is indeed constructible
 
Yeah, I'm reading the "algebraic constructibility" section. I was never any good at geometry. So yeah, it is. But then it seems like you can generate constructibles from other constructibles recursively. Which... sounds unpromising.
 
Yeah.
I wonder if there's a formal term for whether a set's elements have a "canonical" representation. Integers can be described as finite digit sequences, rationals as a ratio of coprime integers... But there's seemingly nothing like that for constructible numbers, and reals are right out
Unless... Maybe you can do something cool with continued fractions
 
I'm pretty sure concepts like "canonical representation" go out the window with hardcore math.
 
00:00 - 20:0020:00 - 00:00

« first day (3861 days earlier)      last day (1070 days later) »