« first day (2694 days earlier)      last day (2254 days later) » 
00:00 - 20:0020:00 - 00:00

12:00 AM
"if it's good python 2 code" Given what I've seen of the older files, that's exactly what I'm worried about. I've been here two years and I'd say at least half of that I've never looked at.
 
@wim "simply don'"... I had to Google that and didn't get a coherent answer. Do I have to accept I'm old? :(
Or just not American
 
wim
quoi?
 
Actually, I don't know your nationality. You went from UK to US, so presumably British
 
wim
I've lived and worked in UK and US but I'm from neither
 
Your initial comment to me.
 
wim
12:08 AM
I have no idea what you're talking about. Use the "reply" feature of chat
@roganjosh This messages has a little arrow because it's replying to that one up there
 
@wim I was talking about your initial comment to this
In hindsight I guess you typo'd your initial reply, deleted and rewrote. I thought I was missing out on some US lingo.
 
wim
ah, yes, that's exactly what happened. fat-fingered it.
 
Last week I helpfully linked to a BBC political article masquerading as some python documentation.
 
@wim: Hello. I think you wanted to talk to me.
 
wim
12:26 AM
Hi!
yep I was going to ask if you minded sharing your data from stackoverflow.com/reputation .. I was curious to plot them vs time and count how many times we crossed eachother
if you don't care or don't want to share it, that's fine
 
hmm... I wonder if this includes my downvotes.
 
wim
actually, it looks like it does
feel free to censor it, I don't need the post numbers
only the lines beginning with "--" are needed
 
cbg @Code-Apprentice
 
12:37 AM
How are you Wayne?
 
wim
thx, pastebin is blocked here but I will check it when I get home (or send to hey@wimglenn.com)
Is there any precedent in Python stdlibs for x == y raising an exception?
somehow I thought naive/aware datetimes did it, but seems they only raise for ordering comparisons not equality comparisons
 
The only example I can think of is == with two weakref.proxy objects for deleted objects.
numpy.dtype(numpy.int64) == 'asdf' raises an exception, but NumPy isn't stdlib and dtype == is crazy.
 
1:14 AM
Doing well, got my email server partially setup
As far as I can tell, the way I want things configured are not actually possible with postfix, so I decided to roll my own with aiostmpd
basically what I need is a normal email setup like (internet)--->(mail/relayserver)--->(home), and (internet)<----(mail/relayserver)<----(home), but not (internet)<----->(mail/relayserver)
from what I could find, you could make it a relay server, or not
but you can't make it a relay server for special snowflake circumstances
 
1:28 AM
anybody with sqlalchemy know how ?
I want to create an object like :
```
user = User(id =1)
```
without actually doing any database hits.
however, say I want to fetch other details of this user , i would like to just do :
user.full_name
atm it just returns null, but i would like sqlalchemy to do a db query only if user.full_name is requested.
 
Hm. That's interesting. How do you know that user even exists?
 
thanks for replying.
I am using flask login
flask login signs the cookie with my app secret, so there is no way a user can send in random user ids to fake himself
 
but you don't have any guarantee that the user still exists between this time they load a page and the next time
I mean, sure kind of... but you're still ignoring your DB as the ultimate source of truth
 
yeah, in my application there is . im storing it in sql, and if the user disappears from db, i have bigger problems to fix
 
also... are you finding that it's a lot of overhead to just go ahead and get it?
 
1:33 AM
i have a heartbeat query every 1 second , for about 500 to 1000 users simultaneously.
i dont want to do a db fetch for user everytime
 
cause sqlalchemy (I hope you're using flask-sqlalchemy) I'm pretty sure just does that kind of thing for you anyway
 
i am using flask sqlalchemy , yeah
 
I think either you're confused or I'm confused ;)
 
its probably me.
which part is confusing for you ?
i have this in my flask login's handler:
`
@login_manager.user_loader
def load_user(user_id):
return User.query.filter_by(id=user_id).options(load_only(
'id')).first()
`
so , every time a user wants to perform some action that requires him to be logged in, a db query is taking place.
 
enumerate(x) is "lazy" right? it doesn't iterate x until one iterates the enumerate right?
 
1:38 AM
@paul23 , this answer will be helpful :
https://stackoverflow.com/a/23663453/2670775
it says that enumerate() is equivalent to a function that has the yield keyword.
so i would say that it is lazy
@WayneWerner I just tried this:
`u = User(id=1)`
 
About your heartbeat query, actually. What is that for?
 
its a business requirement.
i need to update some db records based on what the user is doing.
It has to be on sql (cant use a faster cache server etc)
the heartbeat aspect of things cannot change.
when I was using laravel, there was a way to prevent this db query from happening.
It should probably even be fine if I just modify my login handler to return User(id=1).
The issue will arise when I want to send in additional details of the current user , or perform joins
@WayneWerner in a way, my question is somewhat about how to make sqlalchemy think that my new object was the result of a query with load_only
 
> i need to update some db records based on what the user is doing.
if you're updating the db then you're already there. Why not grab the user information at the same time?
 
its on different tables, with fairly complex joins
i dont want to increase the number of db hits
 
2:35 AM
I'm definitely missing some design decisions that you made, because there's no way I'd be storing information about my user or something they were doing without linking it back to the user's ID.
 
3:13 AM
sorry
i went away
@WayneWerner the issue will be that I cant find the email of the user by doing:
return current_user.email
current_user.email will return null because it wasn't initialised in the user loader decorator
 
3:46 AM
I have asked a question :
https://stackoverflow.com/questions/49062520/getting-sqlalchemy-models-columns-without-doing-query
 
 
1 hour later…
5:05 AM
cbg
 
5:44 AM
@paul23 that's something you can test in 3 lines
 
6:14 AM
I'm passing a query to a database via sqlalchemy and occasionally I get an error that requires I try again. What is a good idiom for automatically repeating that query attempt
repeat = True
while repeat:
    <do something that might break that I'd have to repeat>
    repeat = False
except ExpectError:
    time.sleep(5)
 
Yuck, a boolean. Why not use a break?
while True:
    try:
        <do something that might break that Id have to repeat>
        break
    except ExpectError:
        time.sleep(5)
 
6:31 AM
@Aran-Fey ahh yes! ty
 
6:48 AM
break unless breaks
 
 
1 hour later…
8:10 AM
cbg
 
8:45 AM
cbg
 
 
1 hour later…
10:06 AM
cbg all
it's possible to delete 2 items of a dictionary in such a way that if the first gives me KeyError, it still executes the second delete operation?
I don't want to nest 2 try/except
or I have to do if (key in dict) delete inside a loop?
 
10:32 AM
@Neoares The if statement seems the cleanest to me
 
yeah I ended up doing it
try:
    for key in ['state', 'entity_id']:
        if key in session:
            del session[key]
except KeyError:
    pass
omg the indentation
 
are you using tabs?
 
yes
 
there's your problem :P
 
are you gonna kill me? :(
I knew it xD
 
10:35 AM
no :P
 
btw, the try/except is useless there, right?
 
@Neoares yes
asking for forgiveness when looking before a leap
 
so you have your IDE configured to change tabs for spaces?
 
if you can call vim an IDE, yeah
but I rarely use it due to auto-indent
 
nice
vim looks even more complex than my 2GB RAM Java IDE
 
10:39 AM
it is complex, but it only takes a few days to learn the basics, and only a few months to learn a lot of bells and whistles that makes it truly awesome
I'm only a novice user though
 
yeah, I once downloaded a program called vim-tutorial or something, that helps you to learn vim
it's very interactive
 
vimtutor comes with vim on linux, I think
that's how I started learning vim when I first faced it
 
I first faced it at uni, I refused to learn it
moved fast to NetBeans / Eclipse
 
jjj
vim is awesome
 
vim is life
 
jjj
10:52 AM
I think I first started learning it when I wasn't able to exit it without closing the terminal :)
 
what? xD
so you started learning cause you were not able to do :wq?
what a paradox
 
jjj
Yeah, I think Ive read somewhere about mutt, and the default editor was vim. So I checked vim, and had to google some basic stuff (such as :wq). I really wanted to know how is that modular keymap supposed to be a good idea, aaand it turned out to be quite awesome
But maybe my memory is playing tricks on me, because :q is there on the main screen if you open vim without any file. Or maybe I opened some file first? Who knows? So many mysteries
 
what is the correct way to install pip on a mac?
i have python installed
git:(ts-js_test) ✗ python -v
# installing zipimport hook
import zipimport # builtin
 
@jjj also ctrl-c will tell you to press :q<Enter> to exit
 
jjj
I didn't know! Now when I'm thinking about it, I must have been a complete noob. Probably didn't even know about ctrl+c back then xD
 
11:05 AM
I tried this:
 python get-pip.py

python: can't open file 'get-pip.py': [Errno 2] No such file or directory
I can't remember how I installed python on this mac
 
jjj
^ and pip -h won't work?
 
$ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
$ python get-pip.py
Seems like the most common approach to me. ^
 
curl -O https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 260 100 260 0 0 998 0 --:--:-- --:--:-- --:--:-- 1000
➜ vie git:(ts-js_test) ✗ python get-pip.py
You're using an outdated location for the get-pip.py script, please use the one available from https://bootstrap.pypa.io/get-pip.py
 
curl -O bootstrap.pypa.io/get-pip.py
python get-pip.py
 
thx
Exception:
Traceback (most recent call last):
File "/var/folders/rk/p4n_9sq532x7h0kt68wvm07m0000gn/T/tmpr4yW14/pip.zip/pip/basecommand.py", line 215, in main
status = self.run(options, args)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip'
 
11:13 AM
I guess you will have to use sudo for this..
the other good option is to use virtualenv
then you won't have to use sudo if you install libraries inside the pip environment.
 
I don't care, I just want to be able to run tensor flow to train a python model
 
sudo python get-pip.py
Got for it.
 
jjj
@SuperUberDuper You are trying to modify the os python version, that's probably not the best idea.
 
its the script doing that
i have 0 clue about python
im a js dev)
 
It's ok to have 2 pythons at os level, don't uninstall rather install both 2.7 and 3.6 I have both curently..
I also use Anaconda python anaconda.org/anaconda/python This is the best.
 
My advice is go with Anaconda, it easier to go with it.
 
all these different versions of python, scary
thx
whats conda
conda install -c anaconda python
 
there are 2 primary version 2.7 and 3.x are almost all same (with minor differences) (you won't have much issue in between them.
 
* 3.x are all the same (almost)
for virtualenv no.
 
11:18 AM
brew install python3, run that?
 
it works with python 2.7 also
If you install anaconda it will install python 3 for you by default, it will come bundled with numpy, pandas, matplotlib and a bunch of other standard tools you might use.
it will also come with it's on pip
so if you did pip install <library> after installing anaconda it will just work.. (life will be much easier)
 
I installed anaconda before, I'm suprised pip didnt work in terminal
im reinstalling anaconda 3
wow 550 MB
 
yes, it comes bundle with technology that simplifies life.. :D
on a serious note: there is a light anaconda (which is minimalist)
 
got a link for the lite?
 
11:59 AM
SO i installed anaconda but now get
➜ ~ conda
zsh: command not found: conda
➜ ~
in terminal
 
did the install succeed? :P
 
jjj
is your conda dir in echo $PATH?
also, is there a way I could make this look better:
if ((u1, u2) in g1.edges() and (v1, v2) in g2.edges()) or (
    (u1, u2) not in g1.edges() and (v1, v2) not in g2.edges()):
 
not sure, perhaps define names for those pairs
well it's not XOR I guess...
 
no conda in path
 
>>> for i,j in product([False,True],repeat=2):
...     print(i,j,not i^j)
...
False False True
False True False
True False False
True True True
I'm not sure this one's much more readable/clear
 
jjj
12:08 PM
yeah.. XOR is not that clear to read, thanks though
 
is this a good solution @jjj askubuntu.com/a/908838
 
@jjj switching to upair/vpair or something similar might still help though
 
jjj
I'm thinking about that. But these pairs come from a cartesian product of two grpahs, so Im not sure if as it is isnt the cleanest way
@SuperUberDuper I think so, but its probably not in your root directory, so just skip the firs step
 
well it would semantically be the exact same thing, except (upair in g1.edges() and vpair in g2.edges()) or (upair not in g1.edges() and vpair not in g2.edges()) is a bit shorter and has fewer parentheses
 
jjj
Right
Melon Andras :)
 
12:21 PM
no problem, there's probably no good solution
 
12:50 PM
Huh, this is neat. A few months ago I remembered a show where shaolin martial artists apparently threw a needle through a sheet of glass, and I was pretty skeptical when I remembered this. Now I stumbled upon a relevant new video. It's still amazing, but my suspicions also seem correct based on this limited sample
 
I'm sure some of you people here are using S3 - any recommendation on a client that's not as ugly as boto3?
 
recbg
@ThiefMaster boto2
it is not as ugly, it is uglier
jokes aside, that's what I've been using
 
Probably CarrierWave. It just doesn't respond well when I import it into Python
 
I reran a job not once but twice today. When I noticed the first rerun I thought I was stupid last night and submitted the wrong job. Today I resubmitted it; turned out that the job file was wrong entirely. So I was stupid last night, for what it's worth, just in a different way as originally inferred
 
1:31 PM
@AndrasDeak Absolutely incredible. I think we may have seen the same older video. But this is still too cool.
 
No, it was old. Like '90s Hungarian talk show old.
 
I think mine was an old clip but not sure how old. Probably not then haha
 
1:46 PM
@AaronHall I started with Java and Python
I think it's a good combination
I studied at university of barcelona
 
They gotta put more spiral on that needle. Put your fingers on the laces
 
DSM
2:09 PM
Happy-to-see-Kevin-is-coming-around-on-sports cabbage :'-)
 
\o cbg
DSM, I was driving home yesterday and saw that hockey promotion CBC likes to do for this weekend. I didn't think they come to big cities :\
 
DSM
There's a compensation, though, in terms of being able to watch certain professional sports in person..
 
2:47 PM
@Neoares me too, but there's always the danger of angering Joel
 
3:02 PM
@RobertGrant tl;dr?
sorry but I'm at 100% workload
 
he shakes his cane at you
 
is cane an euphemism? I suck at english slang sorry
 
In my file here: github.com/ryankshah/Miraihilate/blob/develop/backend/… I am getting an error: AttributeError: 'socket' object has no attribute 'gethostbyaddr'
Yet gethostbyaddr is in the documentation
 
you can link to specific lines on github by clicking the line number
 
thanks
@madcrazydrumma that seems to be socket the module, not socket the name in the socket module
 
DSM
@madcrazydrumma: gethostbyaddr is a function in the socket module, not a method of a socket object.
 
cf. socket.gethostbyaddr vs socket.socket.gethostbyaddr
 
@Neoares don't be sorry, just read it later :)
 
@RobertGrant e_e
sure i will do
 
3:12 PM
Or don't, it's just one long whiny elitist rant.
well written though
 
Joel seems to concern himself with the elite, so elitism is sort of understandable
 
@AndrasDeak so how would I fix the issue?
 
use socket.gethostbyaddr rather than s.gethostbyaddr
 
do I have to just do socket instead of s?
 
yup
 
3:14 PM
Okay sweet
 
assuming you didn't mess up anything else due to similar misunderstandings ;)
 
The rest of the code works ;)
Thanks though!
 
no problem
 
I finally got time to play around with yield from, and how I just want to yield from everything \o/
 
Do you know much about the IPNetwork module?
 
3:20 PM
Me: How exactly do you get that result from the given input?
OP:
I know that's the answer — Coder 3 mins ago
 
cbg
Well, we learned a few days back that there's a library to administer electric shocks to your backside, I'm sure there's one to read your brain too.
Head-to-tail coverage
 
@Arne whiny and elitist are just namecalling though; he does at least explain himself :)
 
DSM
@Aran-Fey: heh. In this case I don't think it's too hard to figure out what the points need to be, but I grant you we shouldn't have to do the work.
 
for yield from create_i() in yield from create_range(range(10):
yield from pass
Blurgh how
 
DSM
yield from pass what now?
Where'd you see this monstrosity?
 
3:35 PM
i assume he wants to yield from passing data :D
 
@AndrasDeak know much about the IPNetwork module?
 
@Aran-Fey FWIW, 5.657 is the correct answer if you interpret that number-sequence string as a flattened list of x-and-y coordinate pairs. Most likely you already knew that and just want OP to show his work, but I figure let's make sure we're all on the same page
Quick proof of concept ideone.com/YD7H63
 
DSM
@Kevin: heh. With me it was min(math.hypot(*(p0-p1)) for p0,p1 in combinations(np.array(pp).reshape(-1, 2), 2)).
 
It's a reasonable assumption that they're x,y pairs, but I can't read the OP's code to save my life, so I figured it's better to get it straight from the horse's mouth
 
DSM
Yeah, I gave up just looking at it. I guess z = ((pp - pp[:, None])**2).sum(axis=2)**0.5; z[z>0].min() would work too.
 
3:44 PM
My jimmies get rustled pretty quick when I comment "OP, how did you get value XYZ?" and some third party replies "oh he probably did such-and-such" and maybe OP replies, "yeah, that sounds good, let's go with that". I don't want a plausible explanation for how to get XYZ, I want to know exactly how OP got it, and messages from anyone else reduces the likelihood that I'll get that info
But I digress. I'm not totally convinced that you can do divide-and-conquer to find the shortest distance in a point collection.
 
DSM
np.unique(np.hypot(*(pp-pp[:,None]).reshape(-1, 2).T))[1] There are almost more ways to do this than there are lines in his code!
 
@DSM yeah, that will be how all Python 4 code will look
 
DSM
Ouch. Did someone announce a dystopian Friday without warning me?
 
Oh - also, dystopian will be a built-in type in Python 4, so you can add type hints to any code that launches missiles, minimises unhappiness by launching the missiles, etc.
 
provider - how would you shorten this word to be less than 5 letters?
 
4:39 PM
The whiny rant part he pretty much admits himself. If I talk about why I think it's elitist I'll fill two pages worth of chat and end up being only marginally better than name calling
 
@MooingRawr pvdr
 
@AshishNitinPatil Did a professor reply to a student as an answer on that question? Thats nuts haha.
 
@Eman eh.... but on glance it doesnt look like provider oh well ill just go with prvid
thanks tho
 
@ZackTarr haha, seems like it :D
 
@MooingRawr Dare I ask what you need it for?
 
4:47 PM
someone was asking me to do it for them
i didnt ask them why.... and i just blurt out an answer
and then it got me curious... on what it should/would be...
 
You may or may not be searching for something that doesn't exist. There are 456,976 four-letter combinations, and ~150k English words, so at least two thirds of them can't have a unique designation, let alone a recognizable one
Or, hang on. Did I forget to carry a one there
Ok, so each word can have three designations with room left over, but still most of them will have like xes and zs in them and stuff
 
let's just hope hes commenting his code then :P
for all I know it might be some crazy OCD he likes to do instead of your standard x for throw away variable name, he might just know it's all providers and just wanted to shorten it. I'll ask next time I see him
 
5:02 PM
@madcrazydrumma literally nothing
prvdr
 
bjg
Does anyone have experience with machine learning of time series data? In particular I want to find a good technique which takes in a time series (or multiple time series) and predicts a binary outcome
 
5:18 PM
probable keywords: binary learning models, thresholding. But I'm unfamiliar with ML
 
bjg
ok, thanks, I've found a lot about forecasting time series but not much with predicting a binary outcome based on the time series
 
Does anyone know why from .x import y imports both y and x (i.e. the x module is added to the globals)? I asked a question about this ages ago, and my brother sparked my curiosity about the issue again because he says he always relies on that behavior in his code
 
@Aran-Fey: Are you in __init__.py?
 
@Aran-Fey please don't link your new questions here *runs away*
 
@user2357112 Hmm, yes, I think that is indeed the case. I did notice that the behavior is not reliable, but it didn't occur to me that it behaves differently in __init__.py
 
5:23 PM
 
Why is __init__.py special?
And why is it so hard to type __init__.py on mobile?
Hmm, the trick seems to be local namespace vs package namespace (I'll try to understand this later)
 
@user2357112 Yep, that explains everything, thanks
 
Oh, I think I see what's going on, thanks
 
5:57 PM
I'm currently running a virtual machine running some Linux OS and I'm trying to SSH into this using Python
 
Hey anyone used gevent in conjecture with sqlalchemy?
 
Here is the code I'm getting so far, but I'm not sure what IP/CIDR to use to try find the VM
 
Should I make a new session for each greenlet, or is reusing the main session better?
(I have about 900 greenlets at "once")
 
I ran the program and I constantly get code 35 if i print result, but got one 61 - could this be the VM? Even so, it doesn't return a 0 (success)
 
@madcrazydrumma code 35 is an ssl connect error, while code 61 is unrecognized encoding or something like that
 
6:06 PM
Yeah I looked it up, but I'm not sure why
I will eventually use paramiko but I am testing the connection first with a socket to see if the port is open
But i still have no idea how I would get to my VM
Also, would I have to install openssh-server?
 
I honestly have no idea what code you are referencing, I just recognized the error codes.
 
Apparently Windows 10 Creator's update doesn't play well with the version of VirtualBox that was installed on the company laptop.
 
I'm on a mac
Unless your statement was unrelated to my question :')
 
what question?
 
6:19 PM
Above ^
unless you can't see it
 
(That's my hint that I have no idea what you are talking about and so my comment was completely unrelated.)
That we are both playing with VMs is just a happy coincidence
 
Fair play ahaha
Know much about SSH with a vm?
Regardless of Python
 
are you running a vm then sshing to another machine? Or are you sshing from your host machine to a hosted VM?
 
6:35 PM
SSH from host to vm
I couldnt even use sudo apt-get install openssh-server
So maybe I have to get a different ISO or something? I'm trying to mimic an IoT device for a software program im writing for a project
@Code-Apprentice do you recommend any vm ISOs?
That have a default root user/pass combination already on the installation (as well as the user)?
 
I usually install directly from an Ubuntu ISO
 
Got a link?
 
6:53 PM
ubuntu.com
 
+1 thanks
 
:-|
 
google.com?
 
I've got it thanks haha
 
@madcrazydrumma AFAIK, regular ISOs work well for most VM softwares, but yeah, when I used to work with VMs (>2 years), you could download OS specific files for specific VM softwares, e.g. ubuntu.vbox, etc.
These would be slightly smaller in size and for some reason preferred over regular ISOs
(regular ISOs == ones that you get on specific distro's website)
 
Hmm is there a way to prevent "highly nested" try-except-else structures?
 
not writing them in the first place
 
try:
    r = request.get(...)
except requests.HTTPError:
    pass
else:
    try:
        r.json()
    except ValueError:
        pass
    else:
        try:
            #application logic with potential exceptions
        except:
            pass
That just starts to look messy
 
Do you want to put things after the top else? Isn't that a return None case eventually?
 
Like worst code ever award messy
 
7:22 PM
Looks fine to me.
 
The nesting depth is putting me off - as it isn't easy to see the normal flow of operation anymore. (Normal, 'linear', flow is now split up into 3 levels of indentation/nesting)
 
Refactor into a function then. That's how you break up nesting in general, it's not specific to try blocks.
 
Well if I ignore the benefits of else (IE by "knowing" I wouldn't have another point that throws a ValueError) I could just do
try:
    r = request.get(...)
    dat = r.json()
    #res of logic, like constructing the data object from the given json dict
except request.HTTPError:
    pass
except ValueError:
    pass
except IndexError:
    pass
 
7:53 PM
Whoever invented tea was a genius. It's amazing how a sip of colored hot water can almost make me forget that I'm sick and have a splitting headache
7
 
Oh yeah a little hot lemon tea does wonders.
 
especially with painkillers
@Aran-Fey let's call it a tie between evolution and some Chinese folks
 
sounds fair
 
00:00 - 20:0020:00 - 00:00

« first day (2694 days earlier)      last day (2254 days later) »