« first day (3279 days earlier)      last day (1894 days later) » 
00:00 - 19:0019:00 - 00:00

00:39
can anyone help me to solve my question?stackoverflow.com/questions/58218685/…
00:56
@ValiValizada Per @glibdud's comments exchange with you, please edit your question to explain (near the top) what is wrong with your code (item.findAll("table",{class:"com"}).text returns empty list) and show what you've tried to debug it. On SO you're expected to make some effort to debug your own issue, and post that in your question.
@ValiValizada Debugging scraping is often annoying. Start with simple code that works, then refine it bit-by-bit until you find the part that breaks/doesn't work. Then post both. You have to do that, not us. Also it would help if you posted some source HTML, so we have a reproducible MCVE. Currently your post just looks like "Write my scraper for me". That's borderline off-topic and won't attract answers.
 
3 hours later…
04:18
Howdy folks. Learning python right now, and was trying out square roots. I noticed that doing sqrt(5) * sqrt(5) yields 5.000000000000001. This must be due to rounding error introduced either during the square rooting or during the multiplication, right? I didn't botch anything, I think.
Is there a way to get the correct answer, or can I only truncate toward zero? I'm learning python for my data mining class, so high precision values are important, but so is accuracy.
04:35
@smci thanks for editing the question, sorry i do understand now what you mean but i need to get it soon and tried lots of ways and also research and get nothing
@smci is ** these signs means the code is not working because of that line?
cbg
Having a bit of an issue testing a flask app with pytest. I place form components on a form at runtime using setattr. This lets me specify components based on config. Nice bonus is fairly atomic testing of components in isolation in tests. Problem is that my setattr seems to persist between tests, even though the app is running in a different fixture.
I know this because all the tests run in isolation, but when run together, different tests fail based on the order the tests are run (I managed this by changing filenames). The diag print statements I've put in place confirm I'm doing my setattrs as expected, but also show them persisting between tests, even when using multiple fixtures.
Hmm if I do `importlib.reload(mymodule)` right before the setattr operation, this works.
But I think reloading a module in production just to enable testing is silly.
 
2 hours later…
06:18
def open_file(filepath):
    with open(filepath, 'rb') as test_f:
        if binascii.hexlify(test_f.read(2)) == b'1f8b':
          with gzip.open(filepath) as mdfile:
            return mdfile
        else:
          with open(filepath) as mdfile:
            return mdfile

def foo(fname):
  fh=open_file(fname)
  next(fh)
I am wringting a simple function to return filehandle according to file type
opening the same file two times is not a good idea, and you can't use with if you want to use the file outside of the function
ya ok, the idea is to get a file handle from opne_file which handles the decision to open file with gzip or normal open
according to file type
def open_file(filepath):
    file = open(filepath, 'rb')
    header = file.read(2)
    file.seek(0)

    if binascii.hexlify(header) == b'1f8b':
        return gzip.GzipFile(fileobj=file)
    else:
        return io.TextIOWrapper(file)
^ something like that should work
hmm, actually I'm not sure if GzipFile and TextIOWrapper close the underlying file...
TextIOWrapper does, but I'm too lazy to test GzipFile
def open_file(filepath):
    with open(filepath, 'rb') as test_f:
        if binascii.hexlify(test_f.read(2)) == b'1f8b':
          return gzip.open(filepath)
        else:
          return open(filepath)
Isimply doing this now, will close file handle in my foo function
yes, the with closes the file
06:34
@wim why do you think this post is good content? It just rehashes both project's quickstart guide and heavily leans on other blog entries like this one for the actual yet sparse content.
06:51
i have a text ="/home/yo/prodigy//log_archive/20191002/sometext_raw_cm/stats/yoyo_20191002.stat.timely.gz"

i need to extract /sometext*/ from this , trying to create a regex reg=re.compile('/(sometext)./')
/sometext_cane_be_anything_between_slashes/
So "sometext" is always the same and the part you want to extract is "_raw_cm"?
user10984358
hey guys, not a complete python question but a yes or no answer will suffice, will a change from bash to zsh affect my venvs or anything python related?
don't think so
07:14
@TheNamesAlc if you have anything python related (such as PYTHONPATH) in your .bashrc/_profile/... then yes
07:32
@smci there's no guarantee with a sleazebag advisor. Nothing they can do beyond charge him with misconduct.
@Ungeheuer that's normal and there's no general solution beyond testing equality with some tolerance. Related reading: stackoverflow.com/questions/588004/… and stackoverflow.com/questions/686439/… and links therein
@Aran-Fey i need sometext_raw_cm
sometext is always there
user10984358
@MisterMiyagi I had it set for a submission as part of my course work, I'll just hardcode the path in the script, I guess that should work
however i cannot split by / and take it positionally
(?<=/)sometext[^/]*
exactly ...
works perfectly
but my try re.compile('/(sometext)./') was wrong
i want to learn making regex like you :(
07:49
FWIW, /(sometext.*?)/ would also work, so you were pretty close
@AndrasDeak And that's exactly why I said your knee-jerk answer without having read the question properly sounded bad. But crucial new context the OP added on the question is their degree hasn't been awarded yet. So I guess they have to accept a written promise to attribute them fully and equally. And have a spy in the audience.
Oops, charge her with misconduct
@ValiValizada No, ** is for highlighting text in bold, but don't put it in a code sample i.e. inside `` backticks. It looks like you added it yourself in revision 5. If you didn't mean to then edit it again to remove it.
@ValiValizada: anyway the important point is that the question is not ok, it shows no effort to debug your own code, and asking other people for debugging your code is not allowed on SO. Please update the question with some debugging effort before it gets closed.
Actually, debugging efforts are not needed as long as there's a proper MCVE
We only demand efforts for writing new code
@AndrasDeak And there isn't. I had also suggested posting some source HTML, to make an MCVE. I'm tired of responding on that so I won't be any further.
07:58
Yup
08:16
@smci i know what you mean but i do not know how to make it, i am not a programmer i write it using tutorials. if you help me it would be great at least you can tell how to edit it for more precise information for the people answers
@ValiValizada Read the BeautifulSoup documentation and tutorials. Do type(item) to find out what type of object item is. Then read its help in the BeautifulSoup documentation. We get that for item in soup.select(".info") and names = item.findAll("table",{class:"com"}).text returned empty list. Try typing simpler BeautifulSoup commands in interactively into a Python shell to see which item.findAll(...) command returns non-empty results...
...It might be best if you just pick some simpler BeautifulSoup tutorials on specific webpages, type in their commands and see how they work. That's where most of us started. There are lots of video lectures and video tutorials too out there. Find one that you find useful.
@smci but it is http requests and this is unique website and i can not adapt it to the tutorials
08:48
@wim sorry, but I've had my fair share of "but the OP meant X when they said Y" concerning iterators/iterables. The OP asked about iterators, the accepted answer explained iterators, so I won't force iterables in there. The comments on the accepted answer give enough information for any hypothetical OP that actually meant X.
09:21
@Aran-Fey Just a minor point: you don't need binascii.hexlify to convert stuff to hex, you can do that very compactly using an f-string, eg f"{header:04x}"
perhaps he wants <3.6 compat (though I guess format can do that too)
Oops, that should be @pythonRcpp
if it was my code I wouldn't convert it to hex at all (:
Indeed. It's simpler to just test the header against b"\x1f\x8b"
But I figured that the hexlify / unhexlify issue was more important. They're rarely needed these days, except for Py2 compatibility. In Py3, you should be using bytes methods or formatting instead.
10:26
@wim Do you know why flit requires my email address and what I should do if I don't want to provide one?
 
1 hour later…
11:30
Umm... just watching some of the Extinction Rebellion videos - this is definitely the "coolest"... others are just people standing around hold placards or boring stuff...
Did you see the one on the BBC where they lost control of a fake blood hose?
That was at least... eventful :P
11:43
Ooo no... must look that one up :)
I'm just mesmerised with this one... I've had it on loop for a good 20 minutes now :)
heeeeellllpppppp I can't stop watching......!
> Sausage dogs fill cafe as Suffolk mass walk rained off
@roganjosh that's more like my piece of news ^
12:08
Post mortem: yesterday, I guessed that there must be a bug in my conversion code from degrees/arcminutes/arcseconds to degrees. That evening, I finally got a chance to review it...
degrees += (arcminutes + (arcseconds/60)/60)
🤔
Oh those pesky parentheses - at least they were balanced
I was going to say "This was only difficult to diagnose because I didn't upload all of my source files to github, a mistake I won't make again", but I notice that the file I uploaded this morning is missing the first half of its contents. Sloppy clipboard usage, Past Me.
It bothers me that u+1f914 THINKING FACE isn't in the Emoticons unicode block
12:23
🤔
Past Me could be a little better about commenting his code
Unicode consortium: we can't add any more symbols to the emoticon block, it's completely full
Me: 🤯
@JonClements Just got off my lunch break, opened my phone in the smoke shed and had one of those horrendous moments where I couldn't stifle giggling to myself thinking about it :/
I think we should have a 10 minute meeting here each day to do something like that... :)
@Kevin if only you had a piece of code that removes superfluous parentheses
12:29
@JonClements I'm on board with that :)
@AndrasDeak I couldn't even get that working on regular arithmetical expressions, running it on a Python statement is a galaxy beyond that
well regular arithmetical expressions are valid python statements so you should just aim for the latter ;)
That reminds me. Does anyone know why Kepler-63 is in both Cygnus and Andromeda? Is it just... A really fast moving star?
Really extremely fast, considering Cygnus and Andromeda aren't even adjacent from our point of view
12:35
Kepler-63	 01h 17m 07.6s 	+49° 32′ 54″ 	12.02 	5.52 	652 		has a transiting planet (b)
Kepler-63	 19h 16m 54.0s 	+49° 32′ 54″ 	12.02 		652 		has a transiting planet (b)
Two stars with the same name and distance from Earth and declination but different right ascension... What are the odds
is it not weird that there are two different right ascensions?
@roganjosh and just so we're not outdone... let's not bother with a fake blood hose... let's install a sprinkler system and recreate that scene from Blade :)
My scraper found 1,000+ other stars that show up twice in Wikipedia's listings. Not counting the stars in Argo Navis, which overlap 95% with Carina and friends
maybe worth asking on the respective talk pages?
perhaps information is leaking from a parallel universe
12:42
the archives are overcomplete.
I'd understand if it was an issue of "this star is right on the border between adjacent constellations so we just put them in both" but this is a difference of like 90 degrees
@JonClements Perfect :) When I get home, I'll see if I can dig out a vid of one of the undergrad lab experiments I designed. It's a bit hard to explain without pictures but very reminiscent of the hose incident. I hope I still have it
(no, it wasn't chewed up undergrads :P)
Errr.... slightly worried... but sounds cool
Undergrad labs were really boring (put a tonne of water in this vessel, turn the steam on, stand around for an hour and measure the temperature at the end). The best was putting dishes of wet sand in a wind tunnel and weighting them every 10 minutes for 3 hours. This, however... was a sight to behold when running if I do say so myself.
user10984358
13:08
hey guys, is there a python function that can skip n elements in an iterator?
user10984358
something that does this
user10984358
>>> l=iter(range(10))
>>> for _ in range(2):next(l)
...
0
1
>>> for i in l:
...     i
...
2
3
4
5
6
7
8
9
user10984358
I am skipping 2 elements in the iterator, is there a builtin that does that?
Umm... could use for i in itertools.islice(l, 2, None) ?
and that'll work on any iterables...
user10984358
thanks that does it I guess, also when does one have to go for itertools.dropwhile ?
13:10
when you need the functionality it provides
user10984358
lol, I guess I will see some other itertools tutorials than the one I am referring now
you could use it for what you just asked but islice is much more efficient for, well, slicing
if you had to do "start yielding values starting with the first negative one" you might use dropwhile
As much as I love itertools, you never have to use it. Don't feel like you'll get yelled at if you don't identify all the places you can wedge them into your code
yeah, they have very specific use cases, and even then you might use something else
Half the time I think "I could use takewhile here... Meh, I'll just write a loop and break at the appropriate time"
user10984358
13:13
noted!, thanks
@Kevin fake news! :p
same, the only time I could use dropwhile is "parse this file starting from a signature line", but I just use while val not in f.readline(): pass or something
"Don't feel like you'll get yelled at. I mean, you will get yelled at, but it's more fun for us if you're taken by surprise"
@AndrasDeak you mean you don't use dropwhile with a zero length deque? :)
In principle you could use itertools.product in every for loop in your code
13:15
@JonClements I don't think I'd need a zero-length deque
Why do [expr for x in range(10)] when you could do [expr for x, in itertools.product(range(10))]
the equivalent would be for line in dropwhile(lambda line: val not in line, f): except that would give me the signature line first
[expr for ((x,),), in itertools.product(itertools.product(itertools.product(range(10))))]
@Kevin I feel a fixed-point in the making.
I guess takewhile + zero-length deque would be the exact equivalent
13:25
could we embed sudoku on a torus?
Presumably you can embed any rectangle on a torus
yeah, just fold up over one side to get a cylinder, then connect the two circles
wait, I messed up, I need to think about this, probably best to start with basic examples... I have not adequately defined embed, but I am thinking of somehow embedding a sudoku puzzle in a way that adds additional restraints to the sudoku board.
You can shift (skew) two sides before connecting them, making the rectangle curve up along the torus. But I suspect that would make the sudoku part easily unsolvable.
that would imply that there are strips of rows coiling around the torus, either a few interlocking coils or a single large coil (if you shift the two sides by a single row)
Embedding it in the most straightforward way doesn't seem to create any new interesting restraints, since the "each row must have the numbers 1-9" rule doesn't change when the right end of the row connects with its left end
13:29
consider a sphere instead, and by embed I mean, try to "approximate" the sphere with a suitable rectangular mesh. So, if we had six puzzle slots for numbers, I would (although I have not given an algorithm to do so) expect it to form a cube.
Likewise for columns, and the 3x3 cell rule only cares about local geometry, which is flat
Then are there any spaces except 2d Euclidean space that allow for interesting sudoku puzzles?
Volumetric sudoku? I dunno.
I've seen a handful of "minesweeper on a sphere" games over the years, so it's not impossible to get a fresh twist on a simple puzzle in this fashion
Meh, more open ended, I need to really solidify the definitions better...
13:32
good morning everyone
The challenge of doing sudoku on a spherical-ish mesh is that you're definitely going to have some triangles (citation needed) so you have to decide what happens to a row when it runs into a tri
@Kevin For 6 you could approximate with a cube. Which has triangles but can also be decomposed entirely of squares.
Right, and for that reason I consider a cube to be not spherical-ish
It's a very No True Scotsman kind of definition
Hmm it occurs to me that a soccer ball truncated icosahedron approximates a sphere pretty well but it doesn't have any triangles
Maybe I should revise my definition to "you're definitely going to have some non-quadrilaterals"
Hmm... I'll need to keep this idea in mind for later.
Ah, I thought of a counterexample. There are convex solids with more than six 4-gonal faces.
Whether those solids can be used for "interesting" purposes is anyone's guess
A Rubik's cube is essentially one such solid, with 54 square faces
13:43
@Kevin Usually it assumed that the solid is hollow.
You can't prove that a Rubik's Cube isn't hollow. Unless you took one apart, but only unscrupulous people do that
@Kevin I suspect some kind of radar could deduce?
But then it's equivalent to a cube, which has 6 squares...
For certain definitions of "equivalent", sure
wim
wim
@Aran-Fey hmm, that's odd. it should be optional field according to the metadata spec.
flit bug I guess?
wim
wim
14:00
after a bit of digging, flit's email validator appears to have been there in order to save users from hitting this bug when uploading to pypi github.com/pypa/warehouse/issues/2679
The bug has since been fixed in PyPI APIs, so the restriction could be lifted from flit - easy issue for a PR?
14:24
@Dair A Sudoku grid is a square of squares, so you could map it onto a tesseract, but that probably doesn't lead to anything particularly interesting. :)
I never got into Sudoku. I've probably played less than 10 games. But I did get rather addicted to its more mathematical relative, KenKen. And I have messed around with latin squares a bit. I've got some reasonably efficient Python code that produces random latin squares which is significantly faster than Knuth's Dancing Links algorithm when generating large squares (order > 20 or so).
I've also done some stuff with mutually orthogonal latin squares, mostly in conjunction with magic squares, but here's some Python code for creating sets of them: math.stackexchange.com/a/1624875/207316
14:47
@PM2Ring Haha, it's kind of the opposite for me: I used to play Sudoku on the NintendoDS in like early high school. I've heard of Latin Squares (but never did anything with them) because of the Magic Square of Squares conjecture
@TheNamesAlc dropwhile & takewhile are for when you need to apply some condition that can't be done with islice. Think of it as like while vs for. Yes, you can do a for loop using while, but why would you, when a perfectly good for loop exists?
Also, that is super exciting to beat Knuth's algorithm!
@Dair Things get ugly very quickly with latin squares. Even the simple task of enumerating them is an open problem; the fact that the number grows very fast doesn't help. oeis.org/A002860
@PM2Ring If I had a nickel for every time I heard about an open problem in number theory getting ugly very quickly...
@Kevin Dair: asks questions about sudoku. Kevin: Reinvents all of combinatorial topology but with n-cuboids instead of simplicial complexes.
14:56
KenKen is a very good game, although I know it as "Keen" from the Simon Tatham puzzle collection chiark.greenend.org.uk/~sgtatham/puzzles/js/keen.html
I enjoyed obsessing over it after I was mostly done obsessing with Loopy (also very good)
@Dair Thanks. But as Knuth himself said, Algorithm X / Dancing Links isn't very clever. It's only slightly more efficient than a blind brute-force search: it's about the simplest algorithm that is guaranteed to find solutions for those sorts of combinatorial problems. So if you can apply some additional structure in your search you're likely to beat Algorithm X.
@wim I read in the documentation that the email is required, I haven't actually tried omitting it though
@PM2Ring But is your algorithm able to find the magic squares of squares?
But Algorithm X is certainly handy if you can't think of a better approach. If a combinatorial problem can be expressed as an Exact Cover problem, then it's very easy to feed it to Algorithm X.
Hmm it occurs to me that any triangle can be subdivided into three quads, so any conventional solid made of triangles has a quad counterpart with three times as many faces
15:04
@Dair I doubt it. It just does simple latin squares. And although you can make magic squares using a pair of mutually orthogonal latin squares, I don't think that MOLS code could be adapted to the magic square of squares problem. It only generates very simple sets of MOLS.
So there are many more sphere-like 4-gon-faced solids than just the rubik's balls I've been rendering
Sep 20 '18 at 19:52, by PM 2Ring
@FélixGagnon-Grenier Very useful. Here is an example I did a while ago that uses dicts with tuple keys for solving a couple of Exact Cover problems: polyomino packing and graph colouring.
Note that my avatar is made of 4-gons: it's a rhombic dodecahedron. It's a more practical shape for a D12 than a Platonic dodecahedron is because it's less spherical. So when you throw it, it stops rolling sooner.
Which reminds me. I should update that Algorithm X code on Mathematics.SE. It has a couple of tiny flaws, like that unnecessary mutable default arg.
I wonder how many solids there are that are composed only of congruent rhombuses. A random walk through wikipedia yields rhombic dodecahedron, Trigonal trapezohedron, and Rhombic triacontahedron
15:20
and cubes #wellactually
Cube is allowed in the congruent rhombus solid clubhouse, but it doesn't get invited to the parties
is one of those the parallelepiped?
yup, "trigonal trapezohedron" is a parallelepiped, apparently
so "trigonal" as in "having 120-degree rotational symmetry (C3)" along its body axis
something tells me "body axis" is the wrong word
It's strange to me that it has "trapez" in the name but the faces have to be rhombuses, not just trapezoids
@Kevin Dunno. But "There are infinitely many zonohedra with rhombic faces that are not all congruent to each other". en.wikipedia.org/wiki/Zonohedron
@Kevin yeah, what's up with rhombohedrons then
I bet you can't build a polyhedron from non-rhombic trapezoids
15:27
Perhaps there are rhombohedrons that are composed of rhombuses with different angles, although I struggle to imagine what that would look like
in that case "rhombic" is more about "less than square" than "more than trapezoidal"
@Kevin other kinds of parallelepipeds are just like that
stretch them vertically, flop the top over to the sides more
No wait, those are not all rhombuses. Some of them are generic parallelograms.
oh well, geometry has never been my strong suit
@AndrasDeak Strict trapezoid (exactly one pair of parallel sides), or casual trapezoid (at least one pair of parallel sides)? Because a regular old rectangle is a non-rhombic casual trapezoid
Which opens up a lot of possibilities for polyhedrons
Ah, you can divide a rectangle into two strict trapezoids by drawing a diagonal line through it, so maybe it's possible with either definition
cbg
so we doing geometry today?
Yeah
I was going to say "take a cube and divide each face into two casual trapezoids", but that doesn't work because not all the diagonal lines will meet another diagonal line
For the same reason that you can't color the edges of a cube so that every face has (red, blue, red, blue) edges in that order
15:43
@Kevin we've talked about this before and squares are also trapezoids when I'm talking :P And yeah, I should've said non-parallelogram trapezoids (that's what I meant)
If this edge-coloring property is true for all 4-gonal solids, then my division strategy is kaput
I guess it must be true for any solid with a vertex composed of three edges. Can't color three edges with two colors and have no adjacent identical colors.
Maybe I can find a solid whose vertices are all composed of an even number of edges?
@Kevin From my experience in building shapes out of magnetic balls, I suspect your strategy is doomed.
@Kevin like the rhombdodecahedron in PM's avatar?
<squints>
Ooh, that's promising. But edge-colorability is necessary for my division strategy, but not sufficient. Uh, I think.
Heck and darn, the green and blue vertices have only three edges
bah humbug
15:54
Cleverly hidden by a convenient camera angle
Sorry
PM shall forever be responsible for the crimes of rhombdodecahedronkind
Here's a different angle.
Jul 3 at 7:55, by PM 2Ring
@DeveshKumarSingh Something like that. ;) The shape in my avatar is a rhombic dodecahedron. It's just a shape I like, which I raytraced in POV-Ray. It's related to the cube & octahedron. I'll try to post an image that shows the relationship.
An octahedron has only vertices with four edges, but since the faces are triangles this isn't very useful to me
Jul 3 at 7:56, by PM 2Ring
user image
15:58
@Kevin I bet there's a simple theorem that tells you if it's possible and why not
For certain definitions of "simple", sure. "a monad is a monoid in the category of endofunctors" is simple if you know what all those words mean
The octahedron is the weird platonic solid because its vertices have an even number of edges.
The intersection of "solids whose vertices all have an even number of edges" and "solids made out of only quads" might be the empty set
Since we have one example of the former and three of the latter, and additional examples are scarce
at least you can make bold statements about "all solids made of quads whose vertices all have an even number of edges"
All circles with seven sides are also in the shape of a kitten
Does a torus count as a solid? You can make a wireframe out of that with only quads and four-edged vertices
Or do solids need to be isomorphic to spheres?
16:10
> Stereometry deals with the measurements of volumes of various solid figures (three-dimensional figures) including pyramids, prisms and other polyhedrons; cylinders; cones; truncated cones; and balls bounded by spheres.[1]
hmm
there's a hyperboloid on the Solid article, which is not topologically equivalent to a sphere
"solid" sounds like a very broad term. People usually mean "Platonic solids" by it I think. Which are polyhedrons. There's a large gap between those and the "solid" bag of the Venn diagram
Are solids necessarily solid...?
> A torus should not be confused with a solid torus, which is formed by rotating a disk, rather than a circle, around an axis. A solid torus is a torus plus the volume inside the torus. Real-world objects that approximate a solid torus include O-rings, non-inflatable lifebuoys, and ring doughnuts.
16:27
en.wikipedia.org/wiki/Toroidal_polyhedron - first diagram looks like it's all strict trapezoids
@Andras what was the site you suggested to get academic articles around the paywall please? I could have sworn I bookmarked what you suggested but I can't see to find it? It must have been on my now-deaded PC :/
sci-hub.tw
Thanks :)
no problem
16:40
Awesome, got it. Now to see if I've been treated kindly in a review :)
16:52
I suspect there are no convex polyhedra composed only of quads and four-edged vertices. Toroidal polyhedra aren't convex, and spherical-ish polyhedra are convex.
Hmm, I had a rough proof, but I just thought of a corner case
<hold music plays>
17:06
Ok, I'm back. Assume we have a convex polyhedron composed of quads and four-edged vertices. It has N faces and N vertices. The following properties must hold:
wim
wim
are there any languages where you can have keyword arg preceding positional? foo(b=1, a)
1. The sum of the interior angles of any quad must be 360°, so the sum of all interior angles of all quads must be 360° * N.
2a. If a vertex is convex, the sum of angles of adjacent edges must be less than 360. If a vertex is flat, the sum is 360.
2b. The polyhedron has at least one convex vertex.
2c. Therefore, the sum of all angles of all vertices is less than 360° * N.
The sum of all interior angles must equal the sum of all angles of all vertices, but from 1 and 2c we can see they are not equal. So this proves by contradiction that this polyhedron does not exist.
@wim *followed by
wim
wim
I'd thought ruby was allowing this, but I just checked in irb and could not get it working
how would that work?
wim
wim
17:08
the "b" name would be bound to "1" (raising exception if there isn't a b argument), and b is consumed - then a would be passed as the next positional arg
I could have been clearer ....
foo(b=1, 2)
it's a function call, not a function definition
Couldn't foo(a=1, 2, b=2) get a bit confusing?
wim
wim
I can't immediately think of any ambiguous case.
I guess I'm most interested in whether it's actually a syntax error because "it was too much a bother to implement" or "there is an ambiguous case that has no obvious resolution"
My suspicion is, there's a consistent resolution strategy that makes sense if you think about it long enough, but the average user is not going to think about it long enough
If you say that keyword-like args get popped off and everything else is filled as positional then that could be unambiguous. But then what if you pass positional args as keywords?
unless the positional is a catch-all *args
17:25
In this hypothetical language, given def f(a,b,c):, how should f(1,2,a=3) be resolved? a=3 b=1 c=2? Or crash with got multiple values for argument 'a'?
Python does the latter, in real life
I vote for the crash
I think the crash makes sense if you're going through the parameter list left-to-right and binding each value to either the specified name or the next unbound positional arg
It's a little awkward that in that case f(1, b=2, 3) is legal but f(1, a=2, 3) isn't. I think it asks the reader to put in a little more cognitive effort than they do now
"little more" being the weasel word there. If it's only 1 femto-effort more difficult, then maybe it's worth it.
wim
wim
17:47
I would have thought to get a=3 b=1 c=2 there
"bind named parameters first, then bind whatever's left" at least minimizes the chances of a multiple values error
wim
wim
"bind named parameters first, then bind whatever's left" is a good way to explain it
there are already weird edge cases in the current impl, e.g. you can't send self=self as named argument
In what context does that not work how you expect it to work?
wim
wim
oh my bad it was fixed
it used to be that you couldn't send MyClass.foo(self=my_instance, x=1, y=2) but it seems as though that has been lifted
>>> Foo.func(self=3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unbound method func() must be called with Foo instance as first argument (got nothing instead)
^ pythoff
wim
wim
17:59
Fixed in Python 3.2 it seems
I guess martelli was wrong when he claimed it was gonna be too slow to implement stackoverflow.com/questions/2443673/…
did 3.1 and 3.0 still have a concept of unbound methods?
@inspectorG4dget apparently they are answering questions about CS these days. Boaty is on quite the adventure.
18:20
Hmm, I don't think I actually proved that a {4,4} polyhedron would have the same number of faces and vertices. Such a property is not particularly common -- for example, four out of five platonic solids have unequal numbers of faces/vertices. Only the tetrahedron has four of both. But it's also the only platonic solid whose Schläfli symbol, {3,3}, is the same number repeated twice.
Since I'm looking for a {4,4} solid, maybe that too would have face/vertex count equality
wim
wim
Anyone see anything downvotable here? stackoverflow.com/a/44772528/674039 Is my description of the dict comparison logic wrong or inaccurate...?
Maybe I can do something with en.wikipedia.org/wiki/Euler_characteristic
@wim On first read it was unclear to me what happens when two dicts are compared and they have no keys in common, for example {1:2} < {3:4}.
wim
wim
hmm, yeah.
18:38
uff, apparently there are people who prefer list[:] over list.copy() because "it's faster" and "readability is the same"
wim
wim
...I am one of those people
because list.copy() doesn't exist, it's very slow :P
My expectation is that the "smallest key for which the corresponding values are unequal" logic looks over the union of the dict's keys, and a key that exists in one and not the other is automatically considered "values are unequal"
@wim err, I'm missing something here
@Aran-Fey list.copy didn't always exist... so list[:] or using copy.copy was the only way to do it...
So {1:2} < {3:4} because the smallest key, 1, has values 2 and <does not exist>, which are unequal
18:40
if I can choose between 3 special characters or a self-documenting function call then there's a clear winner IMO
was added in 3.3 I think?
lst[:] # make a copy
wim
wim
@roganjosh (for cross-compat code)
2020 can't come soon enough
wim
wim
lst[:] is better because it has :] in it 🤖
@Kevin ooh try {1j:2j} < {3j:4j}
18:44
Ah, I see that characterize "returns the smallest key in a for which b's value is different or absent" so that seems to support my guess
no ordering relation is defined for complex numbers. So there is something that Python 2 refuses to compare, who would have thought :>
@Aran-Fey anyway... I don't think b = a[:] is what's confusing to most - more seeing: a[:] = b
@JonClements even though that's close to something that can't be done another way
I'm pretty sure the only reason why people don't find [:] confusing is because that's how everybody has copied lists since forever
wim
wim
so to intentional trigger that side-effect, what do you do? put a custom __eq__ in one of the dicts values, that mutates itself?
@Aran-Fey probably
18:48
@Aran-Fey well, and the rise of numpy that took indexing to another level and continues to grow
wim
wim
I dunno, I'm kind of aware that list slicing is a copy and that [:] is a list slicing
I guess that shifts the mindset quite a bit to this being pretty normal
hey guys, i am trying to find out how int, char and double are represented in memory
Out of curiosity, how do you reverse lists, @Aran-Fey?
@roganjosh except arr[:] is not a copy
18:49
is this language specific? (i got this question from EPI)
wim
wim
it would be kind of cool if list slicing was a view, though
and I'm figuring list.copy only get introduced because it was the only builtin mutable that didn't have one
wim
wim
that way you could do stuff like L[low:hi].sort() without being rudely ignored
@wim yup
@roganjosh list[::-1], because I'm not aware of a decent alternative
18:51
and we could just use zip(lst, lst[1:])
Well... there's memoryview ?
I suppose there's list(reversed(lst))... but that has too many parentheses
wim
wim
[*reversed(lst)] # doesn't work in 2.x
@Permian Well, Python's int type is certainly implemented differently from, say, C++'s. It's hard to say anything about char and double because Python doesn't have those.
We've got strings and floats, but if you want to get technical, you can't just assume they're the same
@Aran-Fey I'm not sure where you're drawing the line
18:52
@Kevin my EPI for python says it does!
haha
@roganjosh 1 pair of parentheses ;P
lst[:] has none, so you want to be more explicit with list.copy(), but lst[::-1] I'd argue is less explicit
CPython's float is identical to C's double*, but that's an implementation detail and other distributions of Python are free to power their floats with something else
Lol, ok :P
it's not so much about being explicit as it is about being readable
basically I hate special characters
list(reversed(lst)) = 4 special characters, lst[::-1] = also 4 special characters, but more compact and therefore easier to parse mentally
18:55
(*give or take some header data that all Python objects have)
@AndrasDeak That's obviously a valid point. I think more what I was shooting for is that this syntax doesn't look quite so unclear these days (unless you don't know whether you have a list or an array, where .copy() might arguably be the safer ground)
typedef struct {
    PyObject_HEAD
    double ob_fval;
} PyFloatObject;
Tadaa, the Python float
But I don't suppose you'll get too much further without discovering that you have an array at some point. Maybe I'm wrong :)
@roganjosh I think Aran's suspected confusion comes from "hmm, that's an empty slice, why is it there? I'll just delete it"
cbg all
18:56
cbg
since the premise is typically that everyone else is dumb, you'd have to know what it's good for not to (dumbly) delete it
if i have a dict something like [415:10, 415:15, 415:20, 416:13, 416:10, 417:18, 417:20, 417:89, 417:82, 417:65] is there a way to average all of the keys? i.e. the end result would be [415:15, 416:11.5, 417:54.8]?
probably easy question, been kinda digging into it all day and can't quite seem to get it
It's not that I'm afraid of people confusing [:] for an empty slice, rather, I generally assume that nobody would have a clue what [:] does if it wasn't so commonly used for list copying. So the thought process I'm imagining wouldn't be "what's that empty slice" but rather "wtf is that"
That's not a dict and dicts can't have repeated keys
*list
18:59
That's also not legal list syntax :-)
It's not valid as a list either
wim
wim
@Aran-Fey they also make code harder to google
soooooo what would that be called then?
00:00 - 19:0019:00 - 00:00

« first day (3279 days earlier)      last day (1894 days later) »