« first day (2345 days earlier)      last day (2619 days later) » 

 
4 hours later…
4:43 AM
@AndrasDeak But it say it say no module found on tkinter
 
 
2 hours later…
7:00 AM
Cabbage
@RaghulM Tkinter is actually a 3rd-party module, but it is included with the standard Python 3 distribution, and it is often bundled with Python 2, but not always. However, in Python 2 the module name is Tkinter so you import it like this:
import Tkinter as tk
@ZeroPiraeus "what I could do to make this code better" Nuke it from orbit.
 
Hey there sorry total novice here,
I have python 3.5 installed atm with some packages. If I upgrade to 3.6, do I have to reinstall also the packages I installed from pip?
 
7:16 AM
@Gruber Yes and no. pip creates a cache on your HD, so it won't need to re-download the packages.
Which OS are you using?
 
windows
32bit
also I'm doing some funky stuff (kinda)
basically I'm using a portable version of python, winpy 3.5.3
since I work usually on both my desktop and laptop
I've made a common synced python folder
 
Ok. I use Linux, so I can only offer limited help. When you install stuff with pip do you need to be admin, or can you do it as a normal user?
 
I'm doing all as admin
as of now this portable solution is working nicely
but I wanted to upgrade to play around with those sexy f-strings
and as far as I can tell doing pip list is returning none of the packages I previously installed with 3.5
 
:) The good news is that you can take a "snapshot" of all the stuff that pip has installed and use that snapshot to quickly install it all to a different Python version. The snapshot is a simple text file containing the names and versions of the packages. Conventionally, this file is named "requirements.txt". You can create it like this:
pip freeze > requirements.txt
 
oh I see
is it like virtualenv_
?
ah no I get it
it gives me a list to quickly reinstall the stuff i need
 
7:26 AM
And then you can install all the stuff with
pip install -r pip_requirements.txt
 
I see, so basically yes I have to reinstall all but is quite quick and easy to do so :)
 
But you need to make sure you use the right pip.
 
oh
mmm
 
So use Python3.5's pip to make the snapshot, and Python 3.6's pip to do the re-installation.
The safe way to do that is to call Python's pip module, eg
 
both have 9.0.1 so should be good isnt'it?
 
7:28 AM
python3.6 -m pip install -r pip_requirements.txt
 
I see, well thank you for the heads up! ;)
 
@Gruber The version of pip isn't the issue. pip needs to know where stuff is installed, so you need to use the python3.5 one when making the snapshot, and the python3.6 one when re-installing.
 
nice pretty clear!
 
On Linux, I have a pip3.6 command; I'm not sure how the naming works on Windows. But if you use the python3.6 -m pip install -r pip_requirements.txt method (or however you invoke a specific Python version on Windows) then it will work properly.
However, many people advise against installing stuff with pip to the main Python directories. It's cleaner to use virtual environments. I must admit that I don't use virtual environments, but I only have a handful of 3rd-party modules.
But if you do intend to install lots of stuff, using virtual envs is not only cleaner, it's safer. That's because different packages may have clashing requirements, and if they get installed into the same place you will have Big Problems.
If you want more details on the requirements.txt stuff, see pip.readthedocs.io/en/1.1/requirements.html
 
7:47 AM
@PM2Ring perhaps you should :D
 
Yes, perhaps I should. :)
 
trying virtual environments would take 5 minutes of your life, the same amount of time you otherwise spend wondering how they work because you didn't use them :D
it is the same as with python 3.6 :D
 
@AnttiHaapala Fair enough. I do need to learn how to use virtual environments...
 
8:11 AM
Thank you @PM2Ring!
One thing that is not very clear to me tho is this: if I use a venv and install via pip in that venv some packages then I guess is only with that venv that is going to work when activated correct?
how do you do then if you want to create a general script and use it globally on your pc?
like I'm tryiing to make a small script to use as a wrapper for ImageMagick
this script use the click package (btw is there a proper difference between module and package? or are they kind of interchangeable?) to create a CLI to do some watermarking operations in folders on my ssystems
How should I go with a venv setup if I want to use my script globally in these folders?
 
8:25 AM
@PM2Ring Speaking of which …
 
@ZeroPiraeus I don't know hive, but what the hell is that answer?
@Gruber Correct
 
I assume it's a random code dump in the hope of bootstrapping a sockpuppet. Google got me nothing.
 
@Gruber Sorry, I can't help you with that. I don't use Windows. And I don't know a lot about virtual environments. I assume you just need to add that virtualenv to your command PATH somehow.
 
Then again, it could as easily be a steganographic dead drop from a TLA field agent ;-)
is pleased that The Americans is back
 
@PM2Ring Interesting and pretty simple too I guess!
 
8:39 AM
Huh? rhettinger just posted a Python 2 answer: stackoverflow.com/a/42872051/4014959
I dare @AnttiHaapala to post a comment advising him to upgrade to Python 3. :)
 
I double that dare.
 
9:01 AM
in C, 14 secs ago, by Peter Varo
user image
 
@ZeroPiraeus He fixed it in response to a comment of mine (now deleted).
 
But but but ... why delete the comment? If I'd successfully corrected RH, I'd screencap it, and go looking for a print shop that does A2 colour laser printing.
 
:) Yeah, in retrospect, maybe I shouldn't have deleted it. Oh well.
 
9:46 AM
@PM2Ring oops, in this case sorry for the misinformation @Raghul
cbg
 
 
2 hours later…
user6845426
11:33 AM
cbg
 
dyb
12:35 PM
Hello folks, i just can't seem to find the answer anywhere...
 
hello
 
dyb
I'm trying to compare keys in a dict against each other to check if any of them is close to any other.
i tried k-10 < k < k+10
But that returns True everytime ^^
My keys are floats, if one key is 10.0 and there's a key that is "10 away" like 19.2 i want to return both of them...
 
yes, because k-10<k<k+10 is mathematically always true
you need k1 and k2 if you're comparing two keys
abs(k1-k2)<10 and you need to set k1,k2 according to your application
you'll likely have to loop over the dict twice: first for k1, then for each k2
but note that this condition is not transitive
if you have k1=1, k2=8, k3=15, then k1 and k2 are close, k2 and k3 are close, but k1 and k3 are not close
so you can't give a partitioning of your elements based on this
(I'm saying this because I saw your last question where you were partitioning a list of tuples based on equal elements)
 
dyb
I see, so with this method i can create lists: [k1,k2],[k2,k3]?
 
well, yeah
if your keys and thresholds are such then it's possible that you get a partitioning, but that's not guaranteed
for instance if you know that the keys should be integers but there are rounding errors, then you can compare them with a threshold of, say 0.25, and be sure that keys around ~1 and around ~2 are grouped separately, but 0.99 and 1.01 both belong to group "~1"
do you see what I mean?
without extra info about the keys you can't be sure
 
1:05 PM
cbg
 
cbg
 
where is everybody?
 
weekend
 
I'm still here. I've been messing around with PIL / Numpy stuff. stackoverflow.com/a/42874813/4014959
 
I am starting to implement my senior thesis algorithm
in C blus blus :(
 
1:15 PM
:(
 
Yesterday I learned about Oganesson, element 118, named after Yuri Oganessian, a Russian physicist of Armenian heritage. It's only the 2nd element to be named after a living person.
 
I'm here
Mendeleevium the first?
 
@RobertGrant He died some time before Mendeleevium was named. ;)
 
@PM2Ring Armenia used to be pretty good in chemistry during soviet times. Now, we are doing literally nothing in science
 
dyb
Thank you Andras Deak! I think i'll be able to do it now.
 
1:19 PM
no worries
 
how hard is it to officially publish a paper?
are there too many formalities ?
 
@khajvah That's a shame, but I guess it's understandable. It's not cheap to do cutting-edge research in the sciences.
 
@PM2Ring professors aren't getting remotely enough. In fact, I, a lazy programmer, earn like 3-4 times more than an average professor
 
@PM2Ring ah fair enough
I was just pretty excited to think of another element named after a person at all
 
and I don't even have a bachelors degree yet
 
1:27 PM
@khajvah depends on the subject and the paper and the referee, really
 
@RobertGrant There's a fair few of those, but you generally have to be dead to get an element named after you.
 
@AndrasDeak have you published anything?
 
yup
 
I think my senior thesis might be worth it.
 
In physics, "formalities" are not an issue. If you're doing it right, your output is naturally publishable in format
 
1:28 PM
It is a solution of routing problem in mobile adhoc networks
 
the narrowest bottleneck is the importance of your research relative to the profile of the given journal
 
Wiki says 12 other elements named in honor of people: curium, einsteinium, fermium, mendelevium, nobelium, lawrencium, rutherfordium, seaborgium, bohrium, meitnerium, roentgenium, copernicium; five more were named for places/things that had been named after people: samarium, gadolinium, berkelium, flerovium, livermorium)
 
once the editor thinks that the paper might be on topic, it's sent to a few referees, who judge by their own tastes and by their image of the given journal
they might say that "yeah this is great, but not for this journal"
 
I guess I will decide after I implement and see how it performes
 
CS probably has a different culture
 
1:30 PM
I read some papers on my topic, they weren't very hard to write
 
1:42 PM
Is this code too messy? This OP thinks so. So I wrote him a new answer.
 
no
 
Thanks, khajvah.
 
maybe variable names are short
 
@khajvah I suppose some of them are. Partly that's because I'm using Ali Assaf's Algorithm X code, which uses X and Y. Most of the names in the code I wrote myself are more meaningful, apart from for loop variables. But short names just make code cryptic, I wouldn't call it messy, per se.
 
yeah, the functions are short and kinda cute. Not messy at all
 
1:59 PM
Ta. I'm not claiming that the core Algorithm X code is easy to understand. You really need to be familiar with the algorithm to follow it properly. It's been a few years since I studied Algorithm X, and I wouldn't like to try to explain how that code works without referring to Knuth or Ali Assaf's articles. :)
 
non-trivial algorithms are not easy to understand by reading an implementation
even stuff like merge-sort would be hard to understand without reading English description
I found Python bindings for ns-3. No need for C++
so happy
 
@IljaEverilä I'm more confused about it than I was yesterday
 
2:15 PM
JWT?
 
Yeah
Mostly about how to safely store keys in the browser
 
Depends, I guess
 
Do you just hope that an attacker doesn't get access to the Javascript runtime?
 
localStorage etc. are one XSS away from leaking, and http-only secure cookies require CSRF protection.
 
Yeah, exactly
And http-only only works if you're hitting the same domain
These are my troubles
 
2:20 PM
Yeah. And you'd also better be sure that the library you use enforces the signing etc. you've chosen instead of happily reading "alg": "none" and dropping sign checks :P
 
Yeah I'm happy with that because that's easy to test for and fix
The other stuff seems like fundamental problems
 
I guess http only would be the more secure approach, but as is usual security and "usability" are orthogonal...
 
Yeah and then it's not stateless, and only works coming from the same hostname
 
Been feeling that server side sessions weren't such a bad idea after all :P
 
Haha
Having said that, would that protect against an attacker who's inside the Javascript runtime?
 
2:29 PM
Tried and true and what not
Server side sessions? Not if the token resides in JS readable storage.
But the sessions would be dead simple to revoke
Compared to JWT
 
But even if it doesn't reside there, if you can still call the code to do something, a cookie will just be sent automatically anyway
So if an attacker can run some code, he can do Stuff
 
True, XSS would still allow performing actions
But they couldn't steal the session and you'd require password or some such for really important stuff
But yeah, XSS would ruin the day still
 
Yeah I wonder if I'm a bit too down on JWT in that case
I'm reading that localStorage content is also only readable by the domain that wrote it, so again, perhaps it's not so bad
XSS aside, which seems to be a ubiquitous problem
 
Have you read this and the linked articles in it?
You may or may not agree with all of the critique, but it's a good read still
 
Yeah that's where I started :)
 
2:48 PM
From a layman, I guess in the end you'll have to weigh the threats and accept some level of security. For example accept that your sessions will leak in case of XSS (and ssl mishaps, mainly not having it).
 
Yeah true
I'm also debating this with a chap on hackernews - I'll ask about whether it's any worse than any other XSS and report back :)
 
3:05 PM
Small difference between http-only cookies and localStorage: an XSS attack can grab what's in localStorage; it can't see what's in the cookie
 
Yeppers, the token itself is safe in httponly cookie, but XSS could still perform evil actions.
 
Yeah
 
3:58 PM
Damn security is annoying
What about the tokens expiring every 5 minutes and having to grab a new one from the serving domain
Then there's only a tiny window to do something from external, mitigating the localStorage attack
Still, XSS really does ruin everything :)
 
"XSS" as in xtra sucky situation
 
 
1 hour later…
dupehammer hinders roomba, just sayin' :P
 
Is roomba > dupe?
in terms of choosing what to do with a question?
 
with a shitty question, and for me: yes
the answer has been deleted at least, so even with a dupe closure it will get roombad eventually
bah new answer
back to square 1 :P
 
hehe
 
engaging pressure
 
5:19 PM
you did this to yourself
 
5:38 PM
love couldn't-give-any-less-shit askers with an attitude
 
well next time don't pick up the phone.
 
lol:D
you're right, dear
 
lol was just about to post that too
 
5:57 PM
@idjaw @AndrasDeak I can openhammer that piece of garbage for reclosure as OT if you like ...
Also cbg
Not far off deletion anway, I suppose.
 
recbg
why is there no 13 inch macbook with 16gb of ram
oh they do have the option but it adds up to $1800
just slightly less than my car
 
I bet your car hasn't got an all-aluminium chassis or a dashboard thing that lights up though, eh?
 
or a touchbar
or usbc
or an apple logo
a coveted apple logo
no. it doesn't. that's why!
 
but it has a usb port
actually, mid 2012 Macbook pro seems to be good
of course after upgrading to SSD and more RAM
of course I have to overcome the teenage-girl-syndome and buy a 5 year old laptop
 
6:15 PM
2012, eh? You could get a laptop from a manufacturer that didn't obviously hate you …
 
I like MacOS, unfortunately
but yeah, I could totally live wiht Linux/FreeBSD
 
6:43 PM
Lenovo is cool. One of few manufacturers that provide the option of proper 4 core processor for 13 inch models
 
@ZeroPiraeus nah, I can delvote in 2 days, no rush
also, answer is pressurized now into deletion, so roomba will eat it (in ~30 days or something)
 
I love that lean brick design
 
I use a T460 (not the p). It's great, but then my last three laptops have been T series so I'm obviously biased.
 
and actually hsa a proper 4 core processor
the rest of the ultrabooks all have 2 core low power stuff
 
well, ultrabook
it's hard to have a body builder which lives on light instead of protein
 
this has it
 
7:14 PM
Standard caveat: the sound is terrible, as it is on every Thinkpad ever made. Your choices are:
1. External speakers
2. Headphones
3. Embarrassment
 
owned a thinkpad. Can confirm that speakers are horrible.
 
built-in laptop speakers are a joke
 
yes in general
I think speakers on a laptop should never be considered in a decision
 
I'm supposed to own skull candy speakers (whatever those are) inside my inspiron, but whoever wants proper sound should use headphones/external ones depending on preference and application
 
I don't think anybody listens to music with laptop speakers
 
7:16 PM
I do sometimes when I don't have other options
 
I see
;)
 
Keyboard is fantastic though (again, as always), which IMO should be a higher priority for a programmer than it generally is.
 
yup
 
the other caveat is that it might be a little heavy
but that's not a deal breaker
 
the thinkpad keyboards are solid. yes.
 
7:18 PM
Weight builds character ;-)
 
I don't mind some weight as long as there's long battery life
speaking as someone whose laptops have always started from ~1.5 hours battery life:/
 
IIRC from reports, the T460p is underwhelming on battery life unless you get the 6-cell battery (which uglifies and heavyens it, obviously). In fact, ISTR that was the thing that eventually pushed me to the non-p model. I don't care so much about brute processing power.
 
I'd only want an 8-core CPU out of pride, but really I don't need it
4x2 negotiable
 
@ZeroPiraeus the one in their website has 6 cell minimum
 
Oh, er, 9-cell then? The big one.
 
7:33 PM
yup, 6 is the default on decent ones
or maybe not?
I'm only closely aware of typical computer specs every 4-5 years when I'm buying a new one:P
 
haha yeah pretty much same
 
so here is the bad thing about living in a 3rd world country
the website sells for 1.5k
but that would cost twice as much in here
 
and you have half as much money?
 
Lenovo are a PITA when it comes to shipping abroad / accepting foreign credit cards. I got a colleague to buy mine and bring it down to Chile for me.
 
well I have money but I won't pay that much
 
8:16 PM
> "The inheritance relationship is really just the redecoration of functions and variables in a subscope." - Bob Martin
Thoughts?
@ZeroPiraeus can you use your dupe-hammer?
 
@AaronHall No, it was me that tagged it .
 
I already closed it.
I had to go to the library so I wouldn't be tempted by Breath of the Wild.
 
here "going to the library" is a euphemism for going to the pub
 
Yeah except I had to get work done.
 
haha
I totally get it. I'd do the same
 
8:26 PM
These are basically all one bug, need to stop putting off a release: github.com/mitsuhiko/flask-sqlalchemy/milestone/5
The problem is that every time I fix it, new corner cases pop up.
 
is this a symptom of having to put together more unit tests
 
the obvious solution is to shift your paradigm to a sphere
 
Then I'll just get edge cases.
@idjaw well, there were tests, and they pass every time I add new functionality. The problem is there's a bunch of unknown cases that happened to work and also should keep working.
 
"every case is an edge case" sounds like a maintainer's nightmare
 
I was reading a bit of the code for flask-sqlalchemy, and it would require a bit of time for me to really focus on that and understand what is going on to be able to write effective tests to help out.
 
8:31 PM
I just keep adding the bug reports as tests. I don't think it's possible to preemptively come up with the tests since I don't use SQLAlchemy in the ways that it's failing.
 
right. same here. My usage of sqlalchemy is quite minimal
and for the times I've used it, I've never done anything advanced to get to this point of reproducing these edge case bugs
 
I found some blatantly obsolete comments on one of Martijn's popular answers. What do you think is more useful: flagging anyway, or leaving a comment for him directly?
completely no-rush thing, they just don't apply to the current state of the answer
on the one hand I wouldn't necessarily bother Martijn with it, on the other hand it's most natural for him to handle it
nevermind, it might not be obsolete after all:D
(I checked the history and I'm clearly missing something)
I'll reconsider when I'll have slept more
 
9:14 PM
can someone help me with parsing a list of dictionaries?
pastebin.com/3vt6xbrL I want to grab the value of each "Value": occurence
 
That looks like json, have you tried using a json parser?
 
it was from an api url and last time I dealt with a json url it had .json at the end so I assumed it wasn't this time
 
Or in other words: what part are you having trouble with?
Lots of APIs spew JSON without the suffix
 
I don't know where to start with it tbh
but I have worked with json succesfully
so I will try that out in a bit thanks
 
Do you happen to use requests for fetching the content?
 
9:19 PM
nah should I?
just been using json libraries
 
Depends. If you've already downloaded the content, then just use the stdlib json module for parsing. But if you want to download it now or in the future over HTTP, do give it a try.
Parsing JSON responses with it is pretty much requests.get(some_url).json()
 
ah yes i actually do use requests then mb
 
Those values seem to be contained in a nested dictionary under the key "Temperature". Just use a list comprehension to form a new list from the data, picking the values from the items.
values = [item["Temperature"]["Value"] for item in data]
 
9:42 PM
yes thats perfect thanks, I'm suprised I didn't notice it
have you guys tried the mobile version of chat on your desktops?
Im using it right now and I prefer it, its cleaner imo
 
cleaner, and also lacking a lot of features
well, not on my desktop, but on my phone
 
Ah I haven't noticed the features yeah, also It only lists members, not whos online or offline just a list of them
 
that's the same with the desktop version
there's no "online" or "offline", only users in a room
 
nah on desktop peoples profiles who are online are fully lit while others seem to be not 'lit' in a way
hard to explain
 
Yeah they become more transparent
 
9:51 PM
that's purely a function of their last message in my experience
> seen 45s ago, talked 1d ago
transparent ^
> seen 10s ago, talked 2d ago
even more transparent ^
 
The silent ghosts...
 
Giving the case I have 30 methods in a class (level1, level2, level3), is there some way I can call a method by strings? For example, in a for loop, I write self.("level"+i), or something similar to that.
 
DSM
Yes, but having so many numerical suffixes on names is a sign you've taken a wrong turn.
 
There is, but you shouldn't. Read up on dispatch tables.
 
Thanks, I will read about dispatch tables
 
10:02 PM
… or perhaps just refactor to have a single method that takes the integer as an argument, which I guess is what @DSM is alluding to. Depends on what kind of mistake you've made ;-)
 
and how many (>=30)
and @Pichi if by any chance you find a way to do something like self.("level"+i): don't do it, and check with us first
 
DSM
Yeah, the right sol'n depends on the content of the methods.
 
Now that I checked it's 54 methods... lol, 30 was an example that there is a lot of methods
 
46
Q: Why store a function inside a python dictionary?

mdeutschmtlI'm a python beginner, and I just learned a technique involving dictionaries and functions. The syntax is easy and it seems like a trivial thing, but my python senses are tingling. Something tells me this is a deep and very pythonic concept and I'm not quite grasping its importance. Can someone p...

^ possibly a good starting point.
 
Thanks, I found that searching in google
 
10:07 PM
And going forward (and apparently reiterating DSM's note): if you find yourself annotating numbers to variables/methods, you're likely doing it wrong.
 
DSM
I can't think of a good use case for fifty-four separate methods all of the pattern levelN.
 
Codecs?
 
I have a Canvas with a lot of circles and each circle will do something completely different
When I click them
 
DSM
And you want to encode the difference in "28" vs "41"? That seems unwise.
 
but hexadecimal is confusing
 
10:09 PM
@PichiWuana Oof. Even Dante only had nine.
 
lol
 
"I need to add a level between 2 and 3...oops"
 
That one's level_mezzanine, I think.
 
@AndrasDeak Are you trying to give an example of a problem that could appear in the future?
 
"Giving the case I have 31 methods in a class (level1, level2, level2b, level3),..." ;)
@PichiWuana not seriously; frankly your current design is self-evidently sub-optimal
 
10:14 PM
Hmm
How could I improve it? Let's say having a game-platform (not my case but similar) where you can replay the levels you already passed. You have a menu button "Levels", for example
And there you get a list of the levels
 
probably based on what Zero said
you read in the level as input, and handle the differences inside
don't tell me that there's literally nothing common among those 54 cases
or you need to have something you can index into (where a dispatch table or something similar comes into play)
 
There is some common things, like, each one will have labels, entries, pictures
 
@PichiWuana aargh, LPTHW flashback! … do not describe data in code, do not describe data in code …
 
What do you mean?
 
possibly that if you have a labyrinth level 5, don't have your level5 method contain a map = '''...''' string that is the map layout itself
 
10:24 PM
Hmmm
 
Sorry, it's an in-joke of sorts. There's a terrible-but-popular Python book called Learn Python The Hard Way, which teaches all kinds of bad habits to beginners that they'll then struggle to unlearn. Hiding data in logic is one of those bad habits.
 
in-joke for people with dark humour :P
 
Hiding data in logic... I don't seem to understand what you mean
 
Ok, so imagine a FPS. Your code should describe the physics, and your (external) data should describe the terrain, and you'll regret it if you mix them up.
 
what Zero probably means is that you should typically read that data from someplace else
then when you later say "damn level 5 doesn't have an exit", you can easily fix it in the data
 
DSM
10:30 PM
Programming is about choosing appropriate abstractions, ones which make operations on them simple. Names aren't really objects in Python, and so they're much harder to work with if you store information there.
 
Aah, I think one thing you mean is that I should create my levels from an external place (e.g. database)
 
or write an obfuscated bash script that generates it, which you can call with subprocess ;)
 
So when I want to change something in my level
I go to my database
 
@AndrasDeak Exercise: write a bash script to call with subprocess that reaches back into the running VM and rewrites your code on the fly.
 
DSM
That's scary enough I'm going to flee. :-) Weekend rhubarb for all!
 
10:35 PM
rbrb
 
rhubarb
 
@PichiWuana database, or just a file
 
@RobertGrant Yes
 
Am I nitpicking if I strongly complain to newspapers about bad spelling errors?
 
10:49 PM
I think it's a good idea
At least tweet them to mock them into getting better
 
Some newspapers have whole twitter accounts dedicated to their spelling mistakes.
 
That's a cool bot
 

« first day (2345 days earlier)      last day (2619 days later) »