« first day (2490 days earlier)      last day (2459 days later) » 
00:00 - 18:0018:00 - 00:00

12:01 AM
git is awesome
 
 
5 hours later…
5:15 AM
recbg
 
6:02 AM
Hey everyone :)
My csv file looks like this (the strings are separated by commas)
#, ,S,c,h,i,m,m,y,J,R,2,G,Y,Y,2,Q
 
 
1 hour later…
7:15 AM
Good morning cbg!
 
7:37 AM
You'd think it'd be easy to import arbitrary modules/packages in a language like python, but no...
Looks like I'll be subclassing MetaPathFinder today
 
8:13 AM
99% sure it isn't really necessary
 
I'm trying to do it just by instantiating the predefined loader/finder/spec classes, but haven't had much luck so far
def import_package_from_path(name, path):
    origin = str(path/'__init__.py')
    loader = importlib.machinery.SourceFileLoader(name, origin)
    spec = importlib.util.spec_from_file_location(name, origin, loader=loader)
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    return module
throws a "parent module not loaded" error
 
8:39 AM
Welp, that was an easy fix. Just had to add the module to sys.modules before executing it.
 
 
2 hours later…
jjj
10:51 AM
Hey whats the best way of importing a module1 from a package into an environment where some dependency for module2 from the same package cant be fulfilled?
 
What do you mean, best way? It sounds like that should fail.
 
jjj
well, it does :) I'd like to know whats a general approach here. If I need to use the same submodule in two different packages, should I just copy the submodule?
It feels like im doing something wrong, but not sure where
 
maybe that submodule should just be a module?
 
jjj
11:13 AM
oh right this makes a lot of sense
thanks!
 
11:29 AM
@Rawing as per this answer your solution seems to be a mixture of 2 different solutions
does the simpler "for python 3.5" version not work?
cbg
 
@AndrasDeak That works for modules (i.e. .py files) but not packages (i.e. folders with .py files)
 
ah, I see
 
12:09 PM
how can i compile vim with python??
 
@Ananthu - not understanding your question, please restate it
 
Why would you want to do that?
 
I want to install the u complete me plugin on vim
but is showing the error that vim need to be compiled with vim
 
Did you follow those steps?
 
@Ananthu I doubt that
 
12:16 PM
@Ananthu --enable-pythoninterp=yes does that. if you are on a mac, just brew install vim.
 
using ubuntu
 
12:29 PM
Cabbage
 
cbg, other PM
 
Should this question be closed with a custom close reason to migrate to the Spanish StackOverflow? The OP clearly can write ok in English, but even if they translate their question text to English it's still hard to read their code, since all the comments & many of the variable names are in Spanish. stackoverflow.com/questions/45597677/…
 
"don't migrate crap"
 
We don't migrate to cross language sites any way
 
Ah, ok. Then I guess we can just close it as unclear, and let the OP migrate it themself.
 
12:34 PM
Yup, closed
 
Thanks, Bhargav prabhu.
 
107
Q: How do I deal with non-English content?

Cool GuyWhat action should I take if I come across non-English content? Does the amount of non-English content make any difference? Return to FAQ index

@PM2Ring lol, np. :D
 
what could be the fastest way to check if a dataframe has only headers
 
I'm not a pandas person, but I'm going to guess that headers_only = not bool(df) works
 
First, ask yourself if you absolutely require the fastest way, because "what is the fastest way to do X?" typically requires 1,000 times more mental labor than "what is a reasonably efficient way to do X?"
And in some cases the former is impossible to answer objectively because a month from now someone might invent an algorithm that requires one less CPU cycle than whatever you slaved over. Unless you analyze every combination of assembly opcodes that have fewer opcodes than your solution, you can't prove you didn't overlook something.
For anything nontrivial we're talking like 10^150 combinations
 
12:47 PM
@pythonRcpp i would say df.shape[0] == 0
 
@Kevin I got it Kevin. I think its a NP-Complete proble by using the word "fastest"
 
and perhaps check df.shape[1] > 0 to make sure the dataframe does have headers too...
 
One of the nicest comments I ever got on SO:
Wow. Are there any textbooks available from you? — Max Herrmann 2 mins ago
 
"Man, this Kevin character is really harping over one minor part of the question without addressing the actual underlying problem", one may think. It shouldn't be too surprising when a programmer freaks out about one out-of-place word -- it just means the parser/compiler they work with all day is rubbing off on them ;-)
s/newsletter/textbook about git commands/
 
@Kevin heh :)
 
12:53 PM
if df.empty:
    print('DataFrame is empty!')
 
Fun fact: direct replies don't work in multi-line messages.
 
Thanks @Metaphox
 
Oh really?
Are you sure about that
… Kevin?
 
@pythonRcpp you're welcome. i'd argue that 'empty' is not always the same as 'having only headers' though, depends on whether 'having 0 header' can be counted 'having headers'.
 
Fun fact: direct replies don't work in fixed-font multi-line messages.
 
1:07 PM
@Kevin :P
 
\o cbg
 
@Rawing not bool(thing) sounds exactly like not thing
 
1:45 PM
> Because the thing about repairing, maintaining, and cleaning is it’s not an adventure. There’s no way to do it so wrong you might die. It’s just work. And the bottom line is some people are okay going to work, and some people, well, some people would rather die. Each of us gets to choose.
^ I saw this speech on TV in the context of family therapy sessions, but it struck me how it also applies to our collective profession
I'm most engaged in writing programs when I'm trying to solve a puzzle, whether it be in the realm of high-level design, or cutting an O(N^2) algorithm down to (ON log N), or even just trying to interpret requirements in a way that isn't contradictory. But not all programming is puzzle solving.
Sometimes you need to write a hundred lines of braindead code that glues module X to module Y. Sometimes you need to check all your functions to verify that they still do the same thing that their docstrings describe. Sometimes you need to see if your GUI would look better with 14 point fonts than with 12 point fonts.
I'm more inclined to spend four hours writing an automated optimal font size chooser, than to spend half an hour manually trying out numbers to see which one makes the window content overflow its container's boundaries
Perhaps being able to tolerate boredom is the difference between programmers that ship, and programmers that have a hundred repositories of half finished projects
3
 
cbg
 
cbg
 
2:00 PM
cast your votes. What am I doing today:

1. Tech debt project
2. Continuing Udemy course for Docker
3. It doesn't matter, the world is ending.
 
Whichever is most boring.
 
number 2
number 3 would have required some coordination to put together a survival group to start our own government and rule the post-apocalyptic world
we need to get there first
room 6 will be the dominating power of the new world
 
3
Can we decide the type of government we want to run? keep in mind the methods we've been using lead us to this state :D
 
All of the anti-zombie theorycrafting in the world won't make up for the fact that I can't sustain a light jog long enough to lose a Walker in pursuit of my tasty brainmeats.
 
Kevin, you're our maester. We need you at the home base.
you won't be running.
you're too valuable
 
2:07 PM
Remember me as I lived, rather than "that guy who was ignominiously torn apart in season 1 episode 3"
My odds are even worse in a Mad Max apocalypse because the bad guys can move faster than 3 mph
 
morning cabbage all
@idjaw 2 before lunch, 1 after lunch
 
a sound plan
 
unless you find 1 interesting intellectually
 
1 is a bit annoying because it got taken over by someone as their brain child
 
if it's just boring garbage that must be done, then save it for after lunch
 
2:09 PM
so it's hard to try to figure things out from their brain
it can actually be interesting but there is a layer of "UGH" to get to it which is what is motivating me NOT to go forward
 
question; for anyone who has hired a developer, which tool worked the best? I feel like there is a severe lack of devs right now
 
“tool”?
 
i.e., Hired.com, linkedin, etc
 
I don’t think you should start calling developers you want to hire “tools”.
 
I've accepted my role as a tool for someone else's success a long time ago
thanks for reminding me, crow.
sigh...
 
2:12 PM
xD
 
@corvid what about SO jobs?
I mean... seems legit?
 
finding good developers is really hard.
 
Am bad at into Englishing
 
english harder
 
so… drink more tea?
@WayneWerner worked for me at least
 
2:16 PM
Psh, am Merican
 
I've never got any serious job offer from hired.com though
 
hired.com sounds more like a platform you go to once you were hired…
 
jjj
xd
 
Guessing that "gethired.com" was already taken and the domain name ransom was too high.
 
@poke oh you! :P
roomsixwantsyou.com
we can make some good coin. who's in
first filtering is trying to decipher Kevin's puzzles
 
2:24 PM
There are two ways to solve my portion of the interview. You can either submit a correct answer, or press "continue" without writing anything after noticing that nothing in the prompt actually asks you to solve my riddles
 
genius
 
The old "the door was unlocked the entire time"
 
@WayneWerner cbg \o :D
Great guess who got pulled into meetings all morning :\
 
2:42 PM
yay meetings
Reminds me of a story I heard about telegraph operators they were hiring. A guy walks in and says he's there to interview, and there are like 5 candidates also waiting. After a couple of minutes he gets up and walks into the office, where they offer him the job. Apparently they had been tapping out on the telegraph: "If you want the job, please come into the telegraph office", and he was the first one to pay attention
 
2:59 PM
ok
discovered a new thing
R&D/PoC dockerizing integration level stack to make things faster for testing
now I'm motivated
maybe I can think OSS while doing it too
 
3:14 PM
+1
 
cbg all
 
cbg
how are things
 
cbg
 
Humming along. We onboarded our first test user this morning!
 
cool
 
3:40 PM
Head tracking goggles for my quadcopter: store.dji.com/product/dji-goggles
My mouse is over the "buy" button.
 
recbg
 
Nice
 
... I didn't ever want a quadcopter until you said that
 
@davidism have you seen this video yet?
 
Yeah, that's a pretty old one.
I like the table idea.
 
3:54 PM
yeah that's the super best
I really want that mavic pro
 
oh my awesome. i'm drooling over that.
 
So if I understand OAuth correctly, I shouldn't go around publishing my client_id and client_secret. Which means I can't have the client_id and client_secret in my source code if I'm planning on publishing my program. Which means writing OAuth applications in python is like shooting yourself in the foot.
 
2 days ago, by davidism
I'd do it the same way you manage secrets for anything else: a file that isn't committed, loaded by the thing that is.
 
I still don't really understand the idea
 
So every user would have to obtain their own id and secret?
That's supposed to be something developers do, not users
 
4:09 PM
If it's a per user application, yes. Sopython doesn't require this because it's an app running on a server.
 
The client id and client secret are supposed to be per-client. If you want to have multiple users sharing the same oauth creds, make a web app so they can't take the credentials for themselves
 
I thought the client_id and client_secret are assigned to the app? I think the app itself is considered the OAuth client here (hence "client id" and "client secret")
what's different for each user are the access token and refresh token, no?
 
In some cases. Not in the one you're describing.
If you don't want other users to use the quota for your app token, you need to require them to get their own app token.
 
I love the idea of drones... I want my own drone... However, the last 4 times I've seen someone flying one has been in public parks or at a public beach. And because I have a 3 and 4 year old playing near by, each time I approached the individual and asked them to stop. 3 people were cooperative, 1 was not.
I'm asking you guys, what do you think. Would you approach a person flying a drone? Would you ask them to fly it or stop it? Basically, am I the jerk here?
 
Hmmm. It seems odd that the user would have to go through an additional registration process.
 
4:14 PM
No one's ever approached me for flying at the park or the beach, but I don't hover around people.
@Rawing it's not
 
davidism makes sure he doesn't play the creeper role when droning about
davidism is a good drone pilot
be like davidism
 
A lot of people approach me to ask questions and say "hey I found the pilot, cool".
 
Oh, yeah, that's a challenge alright
 
So to use this app, the user first creates a Dropbox account. Then he registers an application to obtain his client_id and client_secret. Then he inputs those into my app. Then he's presented with a authorization request "Do you want to allow the app you created just now to access your files?".
 
I'd compare the danger of drones towards other highly kinetic games likely to be played at a park, such as baseball or frisbee. If you're not concerned about a pop fly from a nearby game beaning your kid in the head, but you are concerned about falling drones, maybe there is a double standard at play.
 
4:18 PM
In Orange County, CA, it's against the law to be within 500 feet of others and to do it at a public park... including beaches.
 
Or perhaps the correct amount of drone concern should be baseball_concern * d_m / b_m, where b_m is the mass of a baseball and d_m is the mass of a drone.
 
Good point... I'll think on that
 
Assuming that drones and baseballs have identical terminal velocity, and that the trauma from a drone collision is primarily due to blunt impact and not being cut up by its propellers
 
I'm concerned less about mass and more about unpredictable flying broken propeller shrapnel.
 
Also assuming that the cost of trauma in terms of both money and quality of life is roughly linearly proportional to the total kinetic energy impacted upon the victim
 
The news likes to play up drama. Don't fly stupid and you're fine. It's equivalent to worrying about any other freak accident.
 
I was just going to say that eye injuries are what I'd expect from propeller shrapnel
 
See, I know that... but don't quite feel it.
 
but nothing more than that
but that's the kind of injury I'd expect from any object rotating with high velocity, like a weed whacker
which I wouldn't operate near my children's faces
 
that is good advice
 
4:24 PM
My uneducated assumption is that most drone crashes would occur when the battery dies or the drone loses connection with the remote. In either case I'd expect the propellers to stop spinning near-immediately, and reduce in RPM pretty substantially by the time they drop to toddler-face altitude
Cases where the drone rams into the ground while being fully powered and controlled by the operator can be avoided by the operator not being an idiot
 
apparently in the linked case the operator clipped a tree
 
I'm trying to create a Makefile for my Python project and I want to run source ./project/bin/activate but Make doesn't seem to handle source the way I want it to. Does anyone know how to achieve this?
 
Lesson: avoid obstacles
 
As a general rule, I make efforts to avoid having my safety being decided by the degree of idiocy of others.
 
If you drive on streets that have other drivers, good luck with that ;-)
 
4:30 PM
@simeg you wouldn't activate an env using make
 
Impossible to avoid in absolute terms. But I try to minimize my exposure. My task to is to measure my exposure accurately. These questions help me do that. You all have reduced my anxiety regarding the matter a marginal amount. Consequently, I can likely estimate the risk of drones more accurately.
 
Each line within a make task is a new shell, environment changes don't persist
 
@davidism why is that? Do I really have to remember this long command each time I want to start up my virtual env?
 
rbrb
 
Yes, you have to activate your env when you want to activate your env.
Most shells allow alias commands.
Make is a different process, source is a shell command, not a make command.
 
4:34 PM
Ok I see. Are there any other options besides an alias? I wouldn't know how to create a single global alias to support every project, because every project has a unique name
 
I would... not use a makefile
 
How do you Python people do it? :)
 
unless there are things that setup.py won't do
 
that's the simplest python package
I use that + pipenv
 
4:36 PM
@davidism @WayneWerner These links seems just like something I need, thanks!
another unrelated question
I can't seem to get pip install <package> working without using sudo
python was installed using brew
 
--user
or, just create a virtualenv
either way
 
yeah I read something about that, will that still make it globally accessible?
using --user
 
where globally is just your user, yes
 
For your user, it should. Kevin'd!
 
it installs things to....
 
4:38 PM
ok, that should be fine. Nice, thanks again (high-fives)
 
well, somewhere on your local drive :P
 
well re-cbg... for ever good news out of the meeting there are countering bad news :\ In the end the solutions I thought of will not work, but the new solution I have is just as much work :\
 
~/Library/Python/<version>/lib/python/site-packages
@MooingRawr when one door closes, etc. etc.
 
@WayneWerner yup, pip is nice enough to tell me that :)
 
I mean, if you care enough to actually need to know where it goes
 
4:40 PM
I sometimes like to read the source of what I've installed, so I do end up caring
 
Welp... I just got pulled into another 2 hour meeting in the morning tomorrow just to discuss the new solution. yuppie. I don't want these doors or windows to open and close :\ darn those functional contractors. anyways how's your day so far?
 
going well, I guess
 
and I thought my day was bad
we got our carpets cleaned last night and now my shoes don't have any traction so I can't push my chair around my cubicle
 
that's terrible... are your coworkers willing to help push you around
 
I have not yet been able to garner any sympathy
 
4:53 PM
you have mine
 
thats inhuman
 
I suggest cleats.
 
Or bubblegum
 
Perhaps a rope & pulley system of some kind
 
I was thinking something similar. But you'd have to leverage pre-existing muscle memory. Otherwise, you might as well just stand up and push the chair yourself... and that's obviously absurd
 
5:00 PM
Or the fire extinguisher
 
I think I might still have my crampons in the car
 
Upload yourself into the cybernet so that you no longer have a meaningful location in space
 
@excaza Excellent
 
then I can live on forever in the SOPython chatroom
free to harass people to read the documentation until the end of days
 
The cybernet is a lot like the internet except there's a lot more neon green lines
 
5:03 PM
Is the question I linked a good enough dupe target for this Tkinter question? stackoverflow.com/questions/45618788/…
 
Argh, multilingual code. How am I supposed to know what Successo means???
 
I think it's a kind of ice cream
 
@Kevin Yeah, it does make it harder when you don't read Italian. But I think the problem's in the 3rd line from the end.
 
The core issue is the same as in your proposed dupe target, so I don't think you're going to find a better one than that
 
Rightio
 
5:08 PM
Perhaps it's because the OP didn't provide a properly minimal CVE, but I have a feeling that they won't be able to effortlessly apply the lesson of the target to their own code. But we can only handhold so much I suppose
 
Martellato!
The OP hasn't responded to the comments. Hopefully, that's because he's diligently reading my links...
 
It's a pleasant but rare treat when an OP thanks you for hammering their post with a target they found really informative.
 
Would claiming an inability to generalize a dupe target to the source question be adequate reason to challenge the dup.
I still ask dups
And I am grateful when someone else finds the dup for me
It's almost always because I couldn't think of the right way to ask
 
"My question is different from the target because of X, Y and Z" is adequate, ""I can't articulate why my problem is different from the target, I just know the solution doesn't work for me" not so much
In the latter case you might be justified asking a new question. "I have code X, and I was directed to solution Y, but when I try it I get output Z, which is wrong"
But that's just my opinion.
 
5:23 PM
@Kevin True, it's not very minimal, but at least it looks complete, which as you well know is a rarity with Tkinter questions. :)
 
Mm hmm, it is so.
 
OTOH, I can't see a Tk() call there, so I guess it's not completely complete. :)
 
hello all o/
 
\o Hi there! I'm new.
 
5:28 PM
@MikaelN ditto
 
Welcome.
 
Greetings, new people. Please take a few moments to read our room rules.
 
Got it.
 
Me too. I was half expecting the rules to have something about idle "hi"s.
 
No hi in here, only salad.
 
5:34 PM
We don't often say "hi" here. Instead, we say "cabbage". :D sopython.com/salad
 
We ask pretty much everyone to read the rules regardless of how they introduced themselves
 
Any tips on working with completely randomly encoded text files? Keep getting encoding errors and have tried several packages to no avail.
 
Well sprouts. Green bean, laurel.
 
cbj all
can i make my python script a chrome extension
 
Looking through the questions on this site, I didn't realise how many people use frameworks
@SohaibAsif a plugin?
 
5:38 PM
@BrandonLipman I don't suppose you could work with the data exclusively through the bytes type? I don't think it's possible to get encoding errors with those.
 
yes a plugin or extension
 
@Kevin I don't think so since the data needs to be somewhat clean ie names and emails.
 
then trial and error until you find a suitable one?
 
ps that was the first result from a Google search, I haven't read that article so cannot comment on how 'good' it is, but it answers your question
 
5:40 PM
@kevin Tried this but can't get it to work. github.com/LuminosoInsight/python-ftfy
 
and by suitable I mean "in which the file looks like text and ő doesn't look like õ (that's latin2 vs latin1)
 
@Daruchini thank you so much just needed the guidance that you provide thanks again
 
and recbg
 
Yes. Tried that but still encounter more encoding issues for non-UTF-8 characters.
 
that just means that it's not utf8...
 
5:42 PM
Good deed done for the day
 
for encoding in encodings:
    try:
        textdat = bytesdat.decode(encoding)
        if looks_like_legit_text(textdat):
            break
    except UnicodeDecodeError:
        pass
else:
    raise WorldIsEndingException('No valid encoding found')
that's what I had in mind ^
or whatever the proper decoding error is
 
aw man just spent a good 15 minutes writing an answer to a question and then it got deleted </3
 
gus how to remove extra brackets in json while printing


a = {
'test': 'test'
}
b = json.dumps(a)
print b

here bracket is also priting , how to remove that
 
@jeyanthinath: Even in chat, you still have to provide a clear problem description and an MCVE.
 
sure
 
5:54 PM
actually, that's pretty runnable save import json
 
Stupid solution: print(b[1:-1])?
 
Unclear why you would want to do such a thing, but lazy solution:
>>> import json
>>> a = {"test": "test"}
>>> json.dumps(a)
'{"test": "test"}'
>>> json.dumps(a).strip("{}")
'"test": "test"'
 
I suspect an XY problem
 
'Course, now you have no direct way of decoding that string back into a meaningful data structure. In Python or any other language.
It's not JSON anymore once you mangle the syntax
 
which editors/IDE do you guys use/recommend?
 
Notepad++ and a command line works for me.
 
Sublime Text 3
 
@Kevin old school
 
Old school would be ed, which is the standard editor, by the way
 
I'm perpetually unproductive though, so, y'know, grain of salt.
 
5:58 PM
@KevinMGranger
>>> a = { 'test' : { 'test1': 'test1' }}
>>>
>>>
>>> json.dumps(a).strip('{}')
'"test": {"test1": "test1"'


in this case it is failing :(
@Daruchini I would suggest pycharm , but I am using vscode
 
Out of curiosity: do you only convert to json so that you can print it without braces?
 
I've used phpstorm before, i think its in the same family
 
@jeyanthinath Oops. Guess you ought to use Rawing's suggestion, then.
 
Joking aside, VS code is pretty nice. But then again so is ed
 
@KevinMGranger I occasionally use sed to remove trailing spaces from my Python scripts. But I usually invoke it via a little Bash script that can run the sed command on multiple files.
 
00:00 - 18:0018:00 - 00:00

« first day (2490 days earlier)      last day (2459 days later) »