« first day (3264 days earlier)      last day (1678 days later) » 
01:00 - 23:0023:00 - 00:00

1:01 AM
Here's the code. bpaste.net/show/4Qop trying do same as teacher said but keep getting error !! ibb.co/RYKQPB6
 
1:18 AM
is that what you want?

    from collections import Counter

    names = ['csev', 'cwen', 'csev', 'zqian', 'cwen']
    counter = Counter(names)

    print(counter)
# -> Counter({'csev': 2, 'cwen': 2, 'zqian': 1})
@αԋɱҽԃαмєяιcαη
 
@ReblochonMasque Thanks, i just want to know how the teacher applied the code on print screen
 
you are welcome, @αԋɱҽԃαмєяιcαη, ask the teacher, maybe?
 
@ReblochonMasque it's online course via coursera, i need to search.
 
cbg
 
cbg
 
how can i take a series like this and initialize a new column in my dataframe, filling all of the remaining ~750 that dont match these index values and initailizing them to something like an empty string
125        [Requires 100% or more NP Gauge]
429      [Minimum of 10% NP Gauge Required]
519            [Minimum of 500 HP Required]
648    [Requires 10 or more Critical Stars]
649    [Requires 10 or more Critical Stars]
701         [Requires 10% or more NP Gauge]
744     [Requires 8 or more Critical Stars]
Name: Req, dtype: object
The square brackets are text not list
actually its not that bad just to init it to NaN I think
Is there an issue if I were to have a column with strings and fillna with False
 
2:03 AM
whoa, im having something weird happen
For some reason one of my columns displays differently depending on what my arg to isin() is
vs.
note i reran the first picture after the second pic to make sure i hadnt somehow nulled the values in the Effect column
what is going on there?
wait, i figured it out
 
@Aran-Fey hem, the output when directed to pipe is not line-buffered. try explicit flushes
 
3:09 AM
(Note to self: that accepted answer is not great, it contains a mix of speculation and 6-year-old mis/information)
 
4:04 AM
@smci So do you want to use it as the dupe target, or not? I'm a bit wary of hammering Pandas questions, after last time...
 
4:24 AM
@PM2Ring Yes I checked it's definitely a dupe of that target; (sorry I messed up on the previous one by being hasty). The target accepted answer is like C+, but we can use it. There are tons of duplicates of datetime conversion where the user didn't supply the format, or didn't get it right, or else the data had mixed formats.
 
 
2 hours later…
6:25 AM
cbg
 
 
1 hour later…
7:28 AM
recbg
 
user10984358
7:44 AM
Heya, can anyone tell me how this works and not run into a recursion depth error or something?
 
user10984358
41
A: Nested defaultdict of defaultdict

BrenBarnThere is a nifty trick for doing that: tree = lambda: defaultdict(tree) Then you can create your x with x = tree().

 
The defaultdict only holds a reference to the tree function, but it doesn't call it when a new defaultdict is instantiated. So no RecursionError.
 
user10984358
Is this the same like lambda holds executing a function?
 
user10984358
Is it normal for needing such a defaultdict or am I doing something wrong by needing this ?
 
It's certainly a niche thing, but it's not an indication that you're doing anything wrong
 
user10984358
7:50 AM
Thanks!
 
9:31 AM
Ola
 
hello
 
@champion-runner cbg
 
Any sources to learn scripting
?
like how to write good python scripts
 
are you familiar with programming at all?
 
10:09 AM
latex might be Turing complete but I've been struggling with loops and conditionals for an hour or more
\if \phi 210 {
    % \phi is not, in fact, equal to 210 here
} \fi
I'm probably missing something dumb but it's driving me crazy
 
hello can some one help me
chart.js with django
 
10:48 AM
@MisterMiyagi Yup
@MuhammedBilal If u want for rest Framework then this steemit.com/utopian-io/@steempytutorials/…
 
11:11 AM
@champion-runner thanks let me try this one
youtube.com/watch?v=B4Vmm3yZPgc i was following this tutorial but at the end i stuck very badly in single problem ..
Displaying empty chart . ;(
 
 
1 hour later…
12:27 PM
@AndrasDeak Are you missing \repeat ? My two minutes of googling led me here which has given me enough false confidence to offer this suggestion, Cbg BTW ;)
It turns out there is a library that allows for Python integration into latex as well but that will probably just complicate things in general although it might make this one task simpler, see this
 
cbg
@Dodge thanks, but no. I was using \foreach defined by TikZ.
And variables get assigned in a weird way so \if inside a \foreach tends to do surprising things. I ended up ditching the conditional altogether
 
Hmm, this is concerning... I started Firefox fifteen minutes ago and it still hasn't opened yet. It's just sitting there consuming 30% CPU.
 
How many tabs do you have? :D Any iowait?
 
12:42 PM
Weird stuff has been happening ever since my computer powered off while I was halfway through installing a Visual Studio update. I think my computer's haunted now.
 
I have 490 right now and first startup takes a few minutes and a lot of IO while it goes through some kind of database to reconstruct the pages or something
 
I have zero tabs open, because the window is not open.
 
I take it you're not letting it reopen your tabs from the last session?
 
@AndrasDeak 490 what?
 
tabs
 
12:44 PM
[screams, and falls out of chair]
 
I had two tabs open when I did a force reset this morning (a new part of my routine, since my computer now freezes every day without fail), so I don't think it's because of tab overload
 
:/
Windows finally gets that regular restart
 
I'm using Chrome right now, which started up in three seconds. I don't like it.
@AndrasDeak I'm surprised anyone showed up at all, really. Memes about depressed millennials aside, I expected "if you show up, we'll shoot you" to be a pretty effective deterrent.
 
I guess everyone was hoping that they'd refrain from shooting as long as they are on the right side of the fence :)
 
I think the original plan was to have more people than bullets
 
12:53 PM
and you can spare a factor of 2 in people if you naruto-run out of the bullets' way
 
Yes it's hard to aim while laughing hysterically
 
But if the guards also watched Naruto, then they may be using the secret technique of "hide a second bullet in the shadow of the first one", so it's a wash
In related "the government has evidence of aliens that they're tired of sitting on, and are now trying to casually introduce to the public" news, Navy confirms that video published by Blink 182 is an authentic unidentified flying object
 
the Blink-182 link is news to me
I haven't read any of those recent UFO posts since xkcd.com/2156, I just expect them all to say "yes, UFOs as in Unidentified Flying Object, because we don't know what they are"
 
That's pretty much what the navy said, yeah
 
websites accosting people for their email addresses and permission to perpetually send alerts is the worst part about contemporary web design
 
1:07 PM
If I recall the video correctly (I haven't watched it since Saturday), there's fairly convincing evidence that it's not just a stationary object that merely appears to be zipping over the water. The cameras have some sophisticated tracking utilities.
I'd wager 5 quatloos that it's something like "the sunlight is glinting off each individual wave to create the illusion of a single moving object", except I won't because it's impossible to settle the bet unless we can hack into the database where the classified incident report will be
 
they should just release all the data and let the internet figure it out
 
I think they're reticent to do so since it would reveal information about the technical specs of the plane that captured the footage. There was a similar problem the other week when The Orange Man tweeted a picture taken by a surveillance satellite, which the Internet used to make a ton of deductions about its orbital path and optical resolution etc
 
well the other option is to directly ask the Russians...
 
Ah, I'm back in Firefox. I had to terminate the hanging processes and open it in safe mode.
Took me a while to figure out how to do that, because the Firefox help site says "to start Firefox in safe mode, first open Firefox regularly, then navigate to this menu..."
firefox.exe -safe-mode is what I wanted, for the record
 
1:27 PM
I've never had to use that. I wonder if that's even a thing on linux
 
I think all it does is disable all your addons, so there probably isn't much OS-specific magic they'd need to reimplement.
So it's probably a thing on all platforms.
 
   -safe-mode
          Starts Firefox ESR in safe mode, i.e. disabling all extensions and showing a bit more debugging messages.
yup
So perheps it was an addon of yours that was stuck?
 
morning everyone!
 
Possibly. All I've got is Adblock and Greasemonkey, but they're both sufficiently complex that either one could enter a non-halting state that persists across restarts
... Not that "loop forever" requires all that much complexity I guess
 
1:43 PM
hi everyone
 
hello
 
@AndrasDeak I'm dying over here.
ah you edited it.
 
2:19 PM
I feel like I missed something special
 
only if your day is extremely uneventful :P
 
so far, it has been
 
@inspectorG4dget in case you're too bored, nudge nudge gitter.im/stenotype/community#
 
@Arne I actually started writing up the skeleton for that last week. I'll see if I can push something this weekend
@AndrasDeak your greetings make you sound like the devil :P
 
2:32 PM
and here I was, still fiddling with the definitions and meta-project stuff =D
 
2:48 PM
nahh... I didn't do anything fancy. Just trying to come up with shorthands for various things. It actually sounds more impressive than it really is
 
3:08 PM
We'll see, looking forward to the PR. If you drop a message somewhere with your gh account i can make you a collaborator and you can push directly to a branch in the repo, and you get CI runs before sending the PR.
 
3:20 PM
Mildly interesting: every spanning tree of a fully connected graph with four nodes
Yes, I'm annoyed that some of the diagonals aren't exactly 45 degrees
 
Oh, so that's what a "spanning tree" is...
 
Maybe if I use an even image width...
Much better. Please do not look at the previous image.
 
@Kevin annoyance does not come close to the rage and pain contained in these diagonals...
 
Are spanning trees non-redundant by definition, because I could envision a few more in this case if not
 
on a totally unrelated sidenote: does anyone here have experience using LGTM for Python on GitHub?
 
3:25 PM
If by "redundant" you mean "there's more than one path between two nodes", then yes, spanning trees are non-redundant
 
yup
 
I've got an image of the spanning trees for a graph of size 5, but it's disruptively large. There are 125 of them after all.
 
@Kevin do you exclude rotations and permutions? most of the trees should be practically the same
 
I did not exclude rotations. If you do, there are only four unique spanning trees, which you can see if you go down the rightmost column of the image.
The boys are all here: Folding Table, N, U, and Arrow
 
U goes by the nickname C
 
3:29 PM
If you're saying "remove the rotations from your 5-graph image and it will be reasonably sized", that's a good idea. Now to squint my brain until I figure out how to do that.
Proving two graphs are identical modulo rotation sounds fun or terribly difficult. Notice I haven't used xor in the previous sentence.
 
just plot every fifth item
 
@Kevin I consider it my duty to make annoying, obvious comments. having good ideas to make your work better via painfully difficult proofs, that I leave to you. :)
 
Correction: if you exclude rotations and mirroring, there are four unique spanning trees. With just rotation, there are five because N and Backwards N are distinct.
 
3:45 PM
@MisterMiyagi In mathspeak, we call them isomorphic.
 
@Dodge I bet that's where "tree" comes into play
 
@AndrasDeak Re: the non-redundancy question?
 
@Dodge can you give an example of a spanning tree that's missing from Kevin's image?
 
@Code-Apprentice lines connecting all of the dots but that is "redundant" and apparently not what the term tree inherently means
 
@Dodge yes, that would not be a tree.
 
3:57 PM
@Dodge yeah
 
@Code-Apprentice my mathspeak force is low today, I am afraid.
 
The term is "acyclic" I think
 
yup, you can't have any cycles in a tree
@MisterMiyagi Although, if we were narrowing it down to just non-isomorphic graphs, we would have to combine folding table and C because they are isomorphic graphs.
 
I'd guess all but arrow are the same fundamental tree type
just a hunch for @Kevin to ponder
since all non-arrows are basically strings, but arrow has one root node with three children
 
4:02 PM
@MisterMiyagi oh...you are right. N is isomporhic to C and folding table, too.
 
there are only two distinct topologies, line and comb
 
I can probably find all topologically distinct trees but it will take me like O(N^4) time
 
4:20 PM
Ah, I thought of an efficient way to do it. Actually, never mind, it doesn't work.
I could have just not said anything but I want everyone to feel my disappointment vicariously
 
Turns out, "All topologically distinct trees with N nodes" is not isomorphic to "all topologically distinct spanning trees of an undirected fully connected graph"
(for certain definitions of "tree")
These are topologically distinct trees

  0
 / \
1   2


1
 \
  0
   \
    2

But they aren't topologically distinct graphs
 
there is probably no point to building an actual graph and trying edges in it. After all, nodes should be indistinguishable. you only need to find the distinct tree shapes, which are determined by branching size, not connectivity of distinguishable nodes.
@Kevin disappointment is just the feeling of having learned something you did not know before. in the harshest way possible.
 
Brute-forcing every graph would probably take less development time than determining the clever way to find all distinct tree shapes
 
4:46 PM
@Aran-Fey This gives me no additional motivation because I already have this image hanging on every wall of my house
 
Hrmm, I guess I'm late finding out about Komi-san
 
My permutator is almost working, except it never permutes N into backwards N
So by "almost working" I guess I mean "not working"
 
Is there a good dupe target for "why do I get an infinite loop when I insert elements to the list I'm iterating on"? stackoverflow.com/questions/58066930/…
 
5:05 PM
I think I fixed it, but I don't know why it was broken and I don't know why the change I made did anything.
 
Dupe target needed for this... There are 249 questions with "groupby as_index False"
 
Here are the topologically distinct spanning trees of size 5, apparently. I expected more of them.
 
@Kevin with the equinox it's perfectly adequately spooky
 
Ah, that explains it. Only on the equinox can my crystal ball peer into my own future and pull solutions from ontological paradox space.
 
now write an extension that untangles the top row middle one
 
5:12 PM
Or just find planar trees to begin with
 
I was just about to say, "I wish it would choose a planar representation when one is available".
 
detecting overlaps sounds like a pain to implement
 
by definition, there is always a planar representation for any tree
 
Since I'm brute forcing every graph, I could easily select the planar representation, if I had a good way to detect crossovers
 
it might scale better to find a unique for each and then untangle those
 
5:14 PM
@Code-Apprentice But is there a planar representation of a tree if the nodes are arranged around the perimeter of a circle?
I'm guessing "yes" but I have 0% of a proof
 
@Kevin yah, that's a little harder to prove, I think
 
We know the answer is "yes" for up to N=6, which is encouraging
 
right, there's a clear solution to fix that one in the middle of the top row
 
flip the bottom 3 nodes across the vertical axis
I wonder how hard it is to turn that into a recipe. If there's a crossing, replace half the offending endpoints
I guess it could be non-halting in itself
 
I have a book at home with a bunch of planar graph algorithms. I wonder if it has an algo for creating spanning trees...
 
5:31 PM
Ah, good, oeis.org/A000055 verifies that my tree counts are correct up to N=6
I'm running my program for N=7 now but it's been going for thirty minutes and I'm not optimistic it will finish before the sun explodes
Apparently counting unique spanning trees a hard problem
 
@Kevin but is it OP hard?
 
P, NP, OP, take your pick
 
If you do it, it's GG.
 
wim
Any problem can be OP hard, for sufficiently stupid OP
 
anyone here know much about Julia, the programming language? I'm looking for confirmation/verification that it was written in python, way back when
 
5:47 PM
Half-baked theory: take a spanning tree and choose an arbitrary node to be the "root". Give each node a unique number from 0 to N, with the restriction that no node can have a number smaller than its parent's. Arrange the nodes on the perimeter of a circle in order, like the numbers on a clock. The graph will be planar, maybe.
Oops, found a counterexample.
 
Does anyone know of a website where one could POST a request to, which then parses the request and shows details about the request?
 
Maybe if you number them in preorder traversal order...
 
Sort of a reversed Postman
 
Something like httpbin.org?
 
@inspectorG4dget Here are the first few public commits of Julia, with the second one being the first commit that adds code. Looks like Scheme to me.
 
5:59 PM
@Aran-Fey Exactly! Thank you very much!
 
@Kevin many thanks. That's exactly what I needed
 
cbg
 
stackoverflow.com/a/52342352/953482 is how I found the original commits, for the record. Silly that there isn't a button in the GUI for this.
 
wim
thought julia was implemented in C
 
I saw C get mentioned a couple pages of commits later, so maybe they ported it over.
 
6:04 PM
sorry, didn't copy over right. trying to read 2 text files in squence. first works fine, but then when it hits the 2nd one, it always jumps to my exception block. any ideas? gist.github.com/biggidvs/3def448ca6410f490445487adbc27a5f
 
What exception are you getting? If you're not sure, always make sure that your try-excepts emit diagnostic information for errors that you don't have a specific solution for.
In other words, never do except: pass
 
Yup
 
Yeah, definitely don't do that.
 
I have a feeling that right_data.txt does not exist in the same directory as left_data.txt. Either that, or it doesn't have read permissions for your user
 
6:06 PM
sorry was editing it to fix it
both files do exist. looking into exception now
 
It's all fine and good to prevent errors from reaching stdout, so they don't frighten the user... But if you do that, you should at least write the exception to a log file
 
I also suggest picking up context managers as a habit
 
It's saying no such file or directory, but the file is there.
 
it probably isn't
or it is and you don't have permissions to read it
 
It's definitely in the same spot as the first file, spelled correctly and I'm the only admin on the machine
So it's wonky
 
6:08 PM
IIRC you were using files to pass messages between separate processes. If you're still doing that, there might be a race condition here. Maybe the other process is momentarily deleting right_data.txt before writing new data to it
 
wonder if i need to enter the full path instead?
 
I bet python is not trolling you so there's something off about your assumptions
 
Or maybe the writing process is putting the file in some kind of write-only mode that makes read() calls fail until it's done writing
 
@Kevin nah, i figured the threading out. this is for the standings screen.
 
if the two files are in the same directory, then being able to read the first would imply the ability to read the second
 
6:09 PM
So only this will read that file and nothing else has it open
@inspectorG4dget i agree but it's not.
@Kevin it's failing on the open step and jumping to exception
 
@biggi_ Typically not. Python is pretty good at understanding relative paths. But go ahead and use an absolute path if you want.
 
I'll give that a shot.
 
Your assumptions are 1. the file really is there with the right permissions, 2. the file name is spelled correctly, including weird non-printable unicode characters. Either of these is incorrect.
 
It will at least eliminate the possibility that your current working directory is something you didn't expect
 
@biggi_ are you sure you have the correct permissions on the file?
 
6:10 PM
Do you still have an editor window holding it open? Or a debug Python session holding it open? Try using lsof.
 
"oops, I was in myproject/testing/files, not myproject/prod/files" or the like
 
Oh, and cbg
 
I'm pretty sure I'm in the right path. I'm verifying that now, then I'll move on.
 
do os.listdir('.') from within your python script to verify that your file is actually there
 
6:12 PM
Hmmm just to make sure it wasn't spelling I changed the name to just 1.txt and 2.txt and now neither is reading.
 
equinox again
 
But it's most defiantly in the same directory
 
trying to get the text of an href
so for <a href='queue/%3Chotspot%2D00%3A26%3ABB%3A05%3ABB%3A10%3E/'>&lt;hotspot-00:26:BB:05:BB:10&gt;</a><br />
it's should give hotspot-00:26:BB:05:BB:10
i used the following
 
@AndrasDeak what do you mean equinox again?
 
@αԋɱҽԃαмєяιcαη BeautifulSoup is usually pretty good at that kind of thing
 
6:14 PM
@αԋɱҽԃαмєяιcαη why not &lt;?
 
@biggi_ It's a running joke -- earlier today my code mysteriously stopped working and started working again. And because today is the equinox, it must have been caused by planetary alignment.
 
yeah, that ^
 
@inspectorG4dget it's giving None
 
does a ' vs " for filename matter?
 
6:15 PM
In a filename, yes. For string syntax, no.
 
String literals behave almost exactly the same way regardless of whether they're delimited by quote marks or apostrophes.
 
@αԋɱҽԃαмєяιcαη next attempt should be correct
 
The exception being, quote-delimited strings can't contain un-escaped quote marks, and apostrophe-delimited string can't contain un-escaped apostrophes
'ab"cd' is legal syntax, and "ab'cd" is legal syntax, but 'ab'cd' isn't and "ab"cd" isn't
 
absolute paths work
 
@AndrasDeak tried it but it's still giving None
 
6:17 PM
@biggi_ if you possibly have the files open in another editor (like say, notepad), you might still get an error because of the way Windows does read-locking. But that should still be a different error than "No such file or folder". I'm still leaning towards the file isn't where python is looking for it
 
@αԋɱҽԃαмєяιcαη I can't even
 
@inspectorG4dget nope, absoulte paths work just fine.
has to be some directory thing
 
where are you running python from?
 
vscode
 
@αԋɱҽԃαмєяιcαη If you're saying "I followed the formatting guide and applied it to my code and it still produces the wrong output", the formatting guide is for making your code appear correctly in chat. It has nothing to do with the code you're running.
 
6:19 PM
@biggi_ which directory is your python file in?
 
the same as the 2 text files
 
@Kevin please give me the link for how to post code here in chat
 
@biggi_ in your python code, add print(os.getcwd()) and verify that what it prints is in fact the directory that contains those two files
 
Andras gave it to you twice, though, so...
 
6:20 PM
for link in soup.find_all('a'):
    print(link.get('&lt;'))
I've applied it against <a href='queue/hs%2D%3Chotspot1%3E/'>hs-&lt;hotspot1&gt;</a><br /> but giving None
@Kevin hopefully it's ok now ?
 
wim
not an answer (and wrong anyway) stackoverflow.com/a/55099405/674039
 
@αԋɱҽԃαмєяιcαη Well, we're making progress. an MCVE would be nice.
 
@Kevin MCVE meant ?
 
appropriate use of the service
 
6:23 PM
@inspectorG4dget so you're right. The .py file is inside a folder that's inside the cwd apparently and it's using the parent folder as the cwd that does indeed have a backup of that file in it.
I made the assumption that the cwd would be where the .py is, not the parent folder that nothing else is used from
 
enjoy!
 
it would've been more fun if you had a backup of the other file as well, and you wouldn't have realized for a long while that your data was stale
 
I apprecaite it!
@AndrasDeak yea....bad file storage habits came to bite me in the butt here
 
@biggi_, how are you running your program? Typically when you run a python file from the command prompt, the CWD will be whatever directory the command prompt is in. If you're running it from an IDE, the rules might be more arcane
Maybe your IDE is configured to set the root directory of the project as the current working directory
 
6:29 PM
Oops, I missed that.
 
Yup, it's just easy to hit F5 and let it go.....plus debugging built in
And when I have about as much idea of what I'm doing as a 3 year old playing Mario Kart for the first time (that was a fun experience this weekend), debugging helps :)
 
Every once in a while an IDE can cause mysterious behavior because it's trying to do too much on your behalf. I think it's PyCharm that causes properties to execute because it likes to iterate over an object's attributes for diagnostic purposes.
And since properties can execute arbitrary code, this can lead to strange and surprising behavior
I guess the lesson is "if the program fails mysteriously, try running it from cmd at least once"
 
That's good advice for sure
The way I wanted it to work (or thought it would have worked) was that way. But then again, I know nothing! And that's my story!
 
6:51 PM
Anyone else finding ... a nice filler object for demo code?
 
I don't use it myself, as I find it spooky, but I don't object to its use by others
 
I prefer pass where it's applicable, but I guess you can't assign that to anything
 
IIRC in older 3.X versions you couldn't use ... in as many contexts as nowadays. So compatibility with behind-the-curve users is a concern.
Ask me again in five years when even slowpokes have full Ellipsis access
 
indeed, I think earlier it was as good as pass except inside [] perhaps
 
(The people still using 2.7 even when they have the ability to upgrade will be dead to me, and won't count)
 
7:01 PM
anyone started using functools.singledispatch?
 
wim
I saw it yonks ago and thought "hey that's neat" but never had a need for it
I guess I just never write code that does different things depending on input type, in practice.
 
7:18 PM
Hi, hoping someone may be able to help me figure something out, or figure out what I need to learn for this. I'm at a company where we have our code in a subfolder to the root (a 'src' folder basically), so we have a shell script we execute to setup some env vars including PYTHONPATH. However, I'm trying to figure out if there's a better, more friendly way of setting this up? Feels cumbersome to run the setup script every time I need to startup the environment, and troublesome for new devs.
We do use docker, which makes it easy, but I'm hoping to figure out if there's something we can do if we want to just run stuff locally.
 
it really depends on what the setup is. With such a generic question, I can't give a more specific answer than "write code to check to see if the setup was already done, and don't do it a second time"
 
That's fair. Right now, in the project root we have some docker stuff, config stuff, etc. There's then a src and test subfolder. The setup script basically just adds the src folder to the PYTHONPATH. This way when we run gunicorn it picks up stuff properly, as well as IDEs knowing where stuff imports from.
Donno if it helps, but I'm hoping to move the team to pipenv, so I've been trying to see if pipenv has some functionality I can utilize.
 
import sys; if 'src' not in sys.path: print("The src director needs to be added to PYTHONPATH")
 
Is there a reason why that project isn't installed (i.e. importable) or always on the PYTHONPATH?
 
@Aran-Fey So that may be something for me to learn (I've only been doing Python for about a year, was a PHP dev before this), so not sure how to make the project itself importable, or what a better structure may be.
 
7:29 PM
@Rohit We have this exact same situation, and struggled with a few different ways to address. Being a fan of brute force, I updated our main scripts to set sys.path based on the current working dir, with the requirement that the current dir be the parent of the project source. I'm now getting rid of all of those, and just adding a .pth file to our virtualenv's site-packages directory, and things should be much simpler overall.
 
As for always on the PYTHONPATH, different team members seem to run the project from different directories, and there's resistance to creating a uniform pathing, so I was hoping to see if there's a relative system I could setup.
@PaulMcG Ah, I'm not aware of .pth files; I'll look into that. We're using virtual envs right now, so maybe that's the solution. If it works for virtual envs, I'm sure there's a solution for pipenv as well.
 
I wrote some code to compare and contrast singledispatch with my standard isinstance usage - and singledispatch feels like it's trying to be too clever...
 
I think venv is the more desired utility over pipenv - search this room archive for other comments.
 
Interesting, I'll look into it
 
venv/pipenv/pyenv/docker are all valid solutions to this. But resistence from the dev team to standardize paths is a pain. At the very least, you should be able to standardize the path for deploy-time, so everyone should dev towards that anyways
 
7:33 PM
I read online a bunch that pipenv was the way to move forward
 
pipenv definitely has the best PR
 
the history goes virtualenv > venv > pyenv > pyenv+venv > pipenv > conda
 
Ok, so moving us towards pipenv is a good idea, cool
 
@AndrasDeak would love to hear your reasons
 
7:35 PM
I only have the one post to go by, hold on
 
@Rohit I found this most helpful re: pth files: docs.python.org/3/install/…
 
Ok, I'll read all this up
 
7:54 PM
I occasionally have big type-based if-else blocks when I'm trying to recurse through JSON or what have you. Maybe I should give singledispatch a try the next time I need to do that.
 
if-else blocks are the basis of our society
 
if-else blocks are the powerhouse of the cell. Or, uh <I shuffle through my notecards> I think these are out of order
 
he comes
 
wim
69 days til advent of code
 
nice
 
8:01 PM
Ok, just tried it out. I'm a bit underwhelmed. I reduced the maximum indentation depth of my program by one level, at the expense of writing like three additional lines. Not something to write home about.
I think there are situations where the tradeoff would be worth it. Like... If I was operating on ten types instead of just three.
 
add up all those four spaces...now you see it's worth it
 
or will you just have tens more lines of code?
 
wim
anyone played with github package registry yet? how did it compare vs pypi?
 
Does it work like nix? If so, why not just use nix?
 
When my if-else block is larger than the screen, then breaking it up into individual functions may indeed be valuable.
 
8:04 PM
[[[[[2]]]]]
 
The examples in the docs seem to be non-recursive. Is that the use-case?
 
wim
presumably it can integrate better with github webhooks , pull requests, etc
 
@Kevin just call it machine learning
@wim any subtle incompatibilities yet? Something to extend and embrace? :P
 
@connectyourcharger Try this: [[[...]]]
 
nah I was just laughing at the amount of brackets
 
8:20 PM
oh you should definitely try that, then: L = [1] and L[0] = L
 
ah, the joy of recursive lists
they're just like santa's sack - they never end
 
or like that song I started singing way back when
 
8:38 PM
functional programmers would probably like the singledispatch method more... ... ...
 
wim
fun fact, singledispatch is from same author of black
here is his old blog post about it lukasz.langa.pl/8/single-dispatch-generic-functions
> some Haskellish solution to a self-inflicted problem
heh.
 
8:56 PM
@wim I am so not surprised
 
9:23 PM
Dupe needed, for the umpteenth asking: User accidentally reverses string instead of list-of-string
 
What would a duplicate for that question look like? "A: When writing code, use the correct variables instead of the wrong ones"?
 
@Aran-Fey No: sorted("backwards", reverse=True) on a string argument returns a list, not a string. Very simple.
 
sounds like hammering with RTFM to me
 
@smci I don't see how that's relevant to that question, but I'm admittedly already half asleep
 
Possible target: What is the difference between sorted(list) vs list.sort()?. I added a comment to that effect: Beware if you (accidentally) call sorted() on a string but think it's a list, you get a list back, not a string: sorted("abcd", reverse=True) gives ['d', 'c', 'b', 'a'] not "dcba"
 
9:43 PM
What's the most convenient way to import a namespace package without needing to fully qualify it each time? For example,

from namespace.pkg1.pkg2 import module_a
from namespace.pkg1.pkg2 import module_b
...
module_a.func('asdf', 1234)

somewhat sucks as I may have another `module_a` in another namespace package. Buuuut

import namespace.pkg1.pkg2.module_a
import namespace.pkg1.pkg2.module_b
...
namespace.pkg1.pkg2.module_a.func('asdf', 1234)

sucks more than just dealing with naming conflicts. I would like to:
 
I thought namespace packages were a "who ordered these?" thing
 
Well, I'm dealing with autogenerated python files from Google's protobuf compiler; that's sort of exactly why I'm trying to fight it for a more pythonic approach to importing those modules, instead of qualifying 5 levels deep.
 
I'd love to see the German translation
that's making my head hurt
 
10:53 PM
Is considered good practice to exit with 0 on KeyboardInterrupt?
Seems strange to me
What if someone calls your script from another script, program or chained shell and rely on checking exit code to see if it executed sucessfully?
 
01:00 - 23:0023:00 - 00:00

« first day (3264 days earlier)      last day (1678 days later) »