« first day (2474 days earlier)      last day (2471 days later) » 

7:00 PM
most straightforward questions are not asked because a proper MCVE ends up giving you the answer
 
that's my point
 
@Suisse you have to export every time you start a terminal, and in the same terminal that you run the code.
 
reaalllyy
oha
 
on linux you can set envvars for a given process if that's better
$ GOOGLE_APPLICATION_CREDENTIALS=keyfile.json python3 your_file.py
 
I'm on mac now
should be the same
yes
 
7:02 PM
yup
 
andras, your line means, everytime the your_file.py is called it should call export first?
 
my line means that you can set that envvar without affecting the rest of your shell; it probably doesn't help you much
as far as I know that is an alternative to exporting the variable
 
your line helps me a lot
it worked..
there is not a way to give this keyfile.json in my code?
in node.js I could do that
 
there almost certainly is at least one
 
but its ok, thx
 
7:06 PM
if that really has to be an envvar, then I don't know
 
@Suisse You might be able to use os.putenv, but please read the warning: Note. On some platforms, including FreeBSD and Mac OS X, setting environ may cause memory leaks. Refer to the system documentation for putenv.
 
@AnttiHaapala they just posted another question
 
:|
inb4 davidism unsubscribes from
 
@AndrasDeak or just goes on a rage and closes every question in the tag
 
7:14 PM
@Suisse On Linux, you could define GOOGLE_APPLICATION_CREDENTIALS in your ~/.bashrc file, and that wouldmake that env var available in every shell, but IIRC, OS X behaves a little differently re: ~/.bashrc, so that may not work.
 
you can do the same thing on OSX @PM2Ring
 
@PM2Ring what is this ~/.bashrc file?
 
google it ^
.bashrc, .bash_profile, .profile
 
Alright here's the MCVE
 
ok thank you
 
7:16 PM
@Programmer there's no class definition
 
$wc -l ~/.bash_profile
     126
 
without a class no wonder you don't get the behaviour of a bound method
so what are those functions in your pastebin?
 
@AnttiHaapala really?
 
if those are outside a class, they can't know what a self is...what am I missing?
 
7:17 PM
@AnttiHaapala there's a bunch of other problems with their code, I was going to dupe close it in a second
 
I'm attempting to replace them using setattr. Am I mistaken for doing so?
 
@Programmer I'm really confused what problem you are trying to solve, why not... just create a class
 
that question is still better than any one that I've read today.
 
do you guys use a tool to verify you have docstrings? I thought that pydocstyle was doing this... but >.> it's not
 
yeah, sorry, I don't get it either, but in my case this might be my fault too
 
7:20 PM
Ugh, doing NFS stress testing at work, found an NFS stress tester called nfsometer - good news, it's Python! bad news, it's Python 2 >:[ (croaked on the first "print" statement)
 
how non-portable can it be? (honest question)
unicode filenames perhaps?
maybe try feeding it to 2to3 or something?
 
I thought it would be simpler to just add one column. I guess I'll write my own class, I just wasn't sure how to inherit the behavior instead of basically copy pasting it all...
 
@Programmer I still don't know the "why" here - are you just looking to add a single column? future you will thank current you for not trying to patch the actual object
 
@enderland Cool. I vaguely remembered that OS X shell doesn't source .bashrc for non-login shells. But I've hardly ever used OS X...
 
@AnttiHaapala found a duplicate for "do something on page load" and "bind click event" and "don't follow link"
 
7:22 PM
@PM2Ring it just calls it the bash_profile
there are probably other differences, though
pylint is crazy strict
 
@davidism :P
 
@enderland bash_profile and bashrc and profile are all different things stackoverflow.com/questions/415403/… (I mean on linux)
 
@enderland Yeah I just want to add a single column to the table.
 
"Sarah is 'trying [their] best"
 
@AndrasDeak you know I've never really looked into that before
 
7:25 PM
needs one dv
can't del, got acc :D
but soon they will be qb'd
 
ugh, I'm not mad at you Antti, just frustrated with general garlic today
 
:D you should try some :D
 
Also, I didn't downvote your answer.
 
puts things in perspective
 
puts?
 
7:27 PM
the q needs one dv
 
can you self delete a 0 or lower accepted answer?
 
@enderland no
 
not my answer
 
accept blocks
 
ah, undownvoted then - didn't realize you could not ever delete an accept, regardless of scores... that's weird
 
7:27 PM
ok 1 delv
it doens't matter either, but it will eat one of your daily dvs ;)
no that's not weird
 
@enderland 20k users can delvote
 
hmm 1 more delv
@PM2Ring ?
 
@AndrasDeak I know
 
it's not trivial, I mean, that accepted answers can be delvoted
 
@AnttiHaapala Where?
 
7:28 PM
link?
 
-3
Q: Render live values automatically in Flask app using AJAX

SarahI have some psycopg2 queries to a postgreSQL database. I want to display the results of these queries live on my web app, without having to refresh the page or click anything to fetch the data. For example, I have this query which fetches the number of users active: @app.route('/_userCount', me...

 
@enderland accepting an answer makes it undeletable, and makes the question ineligible for roomba
 
self-undeletable
 
@AnttiHaapala Gone
 
well that person is well on a way to a qban
 
7:29 PM
Thank you, this worked for me. It loads immediately, though I think after I first run it I have to refresh to get new values. I may put a setInterval on the ajax call to get around this problem, but thanks again! – Sarah 3 mins ago
woohoo :D they're learning
 
inb4 another question from them
 
"setInterval doesn't work"
(wrong order of arguments)
 
but more seriously. what's a good CI tool to verify docstring presence? pylint looks like a straightjacket of things I won't change, but it would find those errors
 
@AndrasDeak haha that's funny :D
 
Hello guys, please bare with me here... I need to remove some elements from a JSON array however we are using python to call the array... so i'm a bit turned around- should I be using python syntax to remove the elements from the array or json syntax? I realize this might be a question for a different/json chat room if so I'm sorry!
 
@AnttiHaapala its open now
 
@AnttiHaapala your request is granted
 
@ElizabethFuenzalida what exactly is the type of your data?
 
That question makes very little sense.
 
7:45 PM
@ElizabethFuenzalida try using Python syntax. I suggest this because json is not itself a language.
 
@ElizabethFuenzalida You should use JavaScript (not JSON, which is a data format not a language), if you're in JavaScript, otherwise you should use Python if you're in Python.
 
Don't manipulate the JSON directly - use json.loads to convert the JSON to a Python list, remove the items you don't want from the list, and then reconvert back to JSON using json.dumps
 
what does "call the array" mean
 
A lot of people look at syntax like {1:[2,3,(4,5)]} and think "look at all those symbols, must be JSON". Nope, it's perfectly ordinary syntactically valid Python.
 
That was next on my "doesn't make sense" list.
 
7:46 PM
@Kevin quoted for json?
sort of?
 
sorry for asking a lot.. but first steps are hard:
allUsers = mongo_users.find()
for user in allUsers:
    print (user.name)
 
I think people must assume that Python literal values can't be nested, and so anything that looks nested must not be Python
 
@Kevin the weirdness you can create visually with tuples/dicts doesn't help either, heh
 
it's a green bean, stop squashing her ya'll
 
I'm working on learning Python, and wondered how y'all prefer to work with Python on Windows platform. I know that Visual Studio has a Python extension, is that the way to go?
 
7:47 PM
@Suisse how many first steps do you exactly need? :P
 
hahaha
I am a centipede
 
@Ungeheuer yes, that is one thing that edits Python.
 
a human centipede
:O
 
I'm actually serious, you've been coming here with questions of varying clarity for months
 
Yeah, it's starting to get tired.
 
7:48 PM
haha ehm yess but aaaaa ... I am node.js developer and python is really new for me
 
@AndrasDeak I love how half the answers, and the editor of the question, are all people who frequent this room
 
@Ungeheuer - I am a low-tech IDE guy, so I use a simple text-editor that makes it easy to run the current script in a second pane, it's called 'sciTE'.
 
I am not working every day on it since I started some moths ago
 
@toonarmycaptain well wim did discuss it here first
 
Notepad++ and a command line is the One True Way to run Python... Except for all the other ways I guess
 
7:49 PM
but are those questions findable with google? or docu?
 
we were all surprised that he could delvote an accepted answer
 
hmm
 
I've heard a lot of good things about VS Code
 
I use Visual Studio Build Tools because I dislike IDEs. I just pop open Vim in terminal, write some code, compile, and run.
 
@Kevin @PaulMcG @davidism Thank you so much for your help this is all wonderful information. Sorry from the poorly phrased/ structured question- I'm retrieving search engine information from a google api and the file returned is called 'json_data' so I assumed that was the syntax but obviously I should have known json stands for javascript object notation so it's javascritp
 
7:50 PM
Anyone gotten the Python extension for VS Build Tools? There aren't any install directions on MSDN for that.
 
I've never seen visual studio but if you're using vim there's no need to improve on it at all ;)
 
Still hunting for em.
 
what was the question anyways Suisse... that snippet is pretty straight forward.
 
@AndrasDeak lol
 
@ElizabethFuenzalida you should really try to figure out the actual language your code is written in
 
7:50 PM
@Ungeheuer yeah, you tick the checkbox that says Python pretty much
Visual Studio 17 installer? I just ran that...
you can Modify in Programs and Features and might see ability to turn it on there
 
for user in allUsers:
    print (user._id)

AttributeError: 'dict' object has no attribute '_id'
 
So I'm using the Automate textbook, playing will all these methods for lists and dictionaries, and thinking that I'm never going to be able to remember the specific needed tool/code when I need it, and that a programmer's chief occupation must be googling "how do I" and chief skill knowing what to google and how to implement it...
 
@ElizabethFuenzalida - And JSON data does not preclude using the vastly superior Python language. Python's standard lib includes a json module for converting to and from JSON.
 
It's not there when I try to modify the build. I found an article for January of this year that said they removed Python from VS downloads, and that they'd be available separately, but of course that's not mentioned on docs.microsoft.com/en-us/visualstudio/python/installation
 
@Suisse unfortunately, this chat is not the place to get step by step help as you learn. We just aren't able to do that in a non-frustrating way. Instead, spend time reading tutorials and experimenting. You need to have a base understanding of Python before we can help you.
@Suisse please read skidmore.edu/~pdwyer/e/eoc/help_vampire.htm before continuing.
 
7:52 PM
I guess my question boils down to: Do I need Microsoft's Python stuff to write and run Python on a Windows machine?
 
@enderland that's not even correct. user is a dictionary, they're accessing attributes instead of indexing
 
Or maybe I'm just very, very green, and all of this will eventually get filed away in my head, like the scripts of Aladdin, and Holy Grail....
 
@toonarmycaptain Google never stops being useful, yeah. But over a long period of time you do internalize a good amount of knowledge.
 
@Ungeheuer - no you don't
 
@davidism I think that's what he's trying to do?
 
7:53 PM
it's not
This room was placed in timeout for 30 seconds; the garlic is too yam high, this is ridiculous
 
That's what we get for being the new #1 language!
 
I think the longest program I ever wrote without having to look a single thing up was like, 400 lines. Anything truly nontrivial requires reference.
 
The next timeout is longer.
 
@PaulMcG Thanks. I'll just go to python.org then. Are there any advantages derived from getting Microsoft's distribution?
 
lol
 
7:55 PM
^ it would probably be worth clarifying why that just happened, I don't think that the people you want to grok that will @davidism
 
^
 
I didn't even know MS had a distribution.
 
This room was placed in timeout for 15 seconds; to clarify
Do research before you ask. Have a basic understanding before you ask. Don't answer if these two things are obviously not fulfilled.
29
 
you should pin that
 
do you think people claim to be X developers to make an excuse of why they don't know basics of another language?
 
7:57 PM
Stick with the vanilla one from python.org
And make sure it's Python 3
 
@enderland couldn't do it ..
 
not 2
 
I want to see their code developed in X
 
@Suisse I misunderstood what you were trying to do
@Kevin I was wondering about that earlier, thinking that maybe part of the problem is that the whole "full stack" thing means people barely learn anything?
 
@PaulMcG They have/had an extension for Visual Studio that support Python (docs.microsoft.com/en-us/visualstudio/python/installation).
Thanks Paul, cleared all my confusion up!
 
7:59 PM
everywhere I when I search for loop through dictionary in python I get that what I am trying.
 
context switching is difficult for long term mastery, I've definitely experienced that in terms of learning
 
@enderland @Kevin thanks :P
answered
 
@AndrasDeak it's python- I just got a little turned around because i'm new to programming and not confident in what little (i think) i know- as @PaulMcG mentioned the script is converting to and from json so I started questioning what I should be doing @_@ sorry and thank you!
 
never too late to learn:)
 
@AnttiHaapala "we just This is very"
 
8:03 PM
@Kevin I think where this gets me is you should know the ideas for what you are doing in X to be able to search for another language with the same thing
 
yes
 
It's also never to late to get comfortable just trying things for yourself. Get used to using the Python interpreter for simple experiments, like converting to/from JSON. Get used to the help features in the interpreter, like help() and dir() that will give you insights into possible paths to take when you are stuck.
 
so, I guess I'm with you on wanting to see stuff in X. though this fits my experience in interviewing people, too, so... c'est la vie? I'm also not even that experienced myself so I shudder to think what it's like for people who have been doing this for a long time
 
@AndrasDeak yep! I'm actually super excited about learning programming! So far I find it really interesting, challenging, and a rewarding experience
 
i'm just seeing these questions in python, and know the basis of the answer because its close enough to C#, and I've written about 100 lines of python in my life
 
8:06 PM
@Kevin fix'd
 
@ElizabethFuenzalida do heed PaulMcG's advice: the interactive shell is really useful for getting hands-on experience
 
@ElizabethFuenzalida Welcome to the crazy world of Python. :) I see from your profile that you do some PHP and C#. Python is a bit different...
@ElizabethFuenzalida Anyway, JSON is a data format that was originally derived from JavaScript syntax, but it's so handy that most modern languages have ways of easily handling JSON. In Python, we have a standard library called json.
 
@PM2Ring but according to Kevin, not that different ;-)
 
dict.get(key) #was the solution thx for the garlic it worked
 
As well as JSON syntax looking like JavaScript, it's also very similar to (part of) Python syntax, but there are some very important differences.
 
8:08 PM
yes :) I see
 
also, JSON is sort of human-readable (unlike other typical textual storage formats such as xml)
 
xml is readable, just exhaustive
<name>@Kevin</name>
 
@Kevin which kevin are you
 
it's as readable as Fraktur
 
and verbose and bloviated
 
8:12 PM
The one that's home alone obviously
 
it can be read but usually not worth the effort
 
to be fair, reading unformatted json isn't exactly easy either
 
@ElizabethFuenzalida nitpicking here, but actually due to a mishap, it might not be valid Javascript either
but basically you're correct.
 
@MooingRawr oh you can't ping yourself. That's quite saddening to know :(
 
You get a ping if you reply to your own message
 
8:26 PM
yup
and a notification
 
@AnttiHaapala use recursion
:38316366 try this
@MooingRawr^
 
the important things in life
 
@MooingRawr That's? This is cheating... no this is madness...
 
now edit it to point to the same message :D
i.e. :38316410 :D
 
or better a future message? :o
 
8:30 PM
I remember Poke teaching me about editing to reply to same message, he was also a genius that predicted how to quote his own future message (no idea how he did that)
Next time I see poke I will have to ask him :(
welp my 20 minutes work compile time is used up back to work.
 
@AnttiHaapala Hmm... I like this idea
 
there's also this :P
 
we're almost up to 500...
 
@TemporalWolf ah * that was my current :D
 
You can edit to include future messages
 
8:34 PM
good idea :D
 
I wonder if it's trying to reply to a message outside this room
 
@AnttiHaapala linking to move messages of mine
 
hm does pycharm not edit/autocomplete for cgi file types?
 
@rawrrang umm? what cgi file types? there is no such file type as a "cgi"
 
im looking at a job.cgi that looks like python code
 
8:40 PM
if you mean a python script with extension .cgi, of course it does though perhaps you need to configure it a bit.
 
this gets launched from some html button
i see just need to config it to tell its a python file
 
if you tell PyCharm that cgi is a Python extension, then yes, it will complete
 
.cgi is apparently used in a non-standard way.
 
@TemporalWolf what do you mean?
 
"There is no such file type as 'cgi'"
 
8:53 PM
there is no file type as a "cgi". Just like there is not a file type called "web browser"
 
@AnttiHaapala wikipedia lists .cgi as a filetype...
 
that's their problem
 
lol
 
but where?
 
This is a list of file formats used by computers, organized by type. Filename extensions are usually noted in parentheses if they differ from the file format name or abbreviation. Many operating systems do not limit filenames to one extension shorter than 4 characters, as was common with some operating systems that supported the File Allocation Table (FAT) file system. Examples of operating systems that do not impose this limit include Unix-like systems, and Microsoft Windows NT, 95, 98, and Me which have no three character limit on extensions for 32-bit or 64-bit applications on file systems other...
 
8:57 PM
lol, even "file formats"
 
such garlic. :P
 
so, I write a program in C and compile it, its format is ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32...
then after I execute mv a.out foo.cgi its format changes to CGI script.
 
sounds about right...
just might have a couple errors
 
wait you mean file extension doesn't match file format!?
 
no, it is a CGI script, but its format is not CGI script.
 
9:04 PM
Using the .cgi extension is a fairly common way to mark a file as being a CGI script / executable. I guess some simple Web servers might even insist that all CGI programs use that extension, and all Web servers should certainly permit its use.
Conversely, even something that looks like a JPEG could really be a CGI script, eg
 
@PM2Ring it still works :P
 
I should hope so. :)
 
I find it mildly disturbing that something tells me such a thing when I am new here. Thank you for pointing that out
 
Was Kevin's edit tutorial message manually unpinned? Doesn't feell ike it's been two weeks.
 
I didn't unpin it.
 
9:15 PM
@PM2Ring this brings me back to when people had these in forum signatures everywhere
 
so who unpinned it
 
yup, been 2 weeks
weird
huh, I found a bug
 
Is that the standard amount of time for PSAs to stay at the top?
 
> You have starred and pinned this message.
 
9:19 PM
Umm if I go in the transcript it does tell me I can unpin it...
 
@KevinMGranger messages automatically get unpinned after that
 
... however I can't
 
I know the PHP room has an omnibus pinned message that includes multiple links, and they recreate it regularly
 
lol, that convo in here a few weeks ago left me with a time.py in my scratch dir... was confused why "import time" was not working, hah
 
manual unpins are visible there IIRC
 
9:19 PM
oh wat
if I unstar it, I can "pin" it again but it doesn't work either
 
Pinned it
 
@vaultah did you forge a request or how did you do it?
 
and that's how ROs star their own messages :P
 
@AndrasDeak yep, but I cannot "unstar it" because "you cannot star your own messages, duh.
 
@AnttiHaapala just clicked "pin this message" :D
 
9:22 PM
@AnttiHaapala you can "cancel stars"
 
@vaultah where
it didn't work anywhere
 
in the transcript
 
it didn't work :(
 
@enderland what version of Python where you running?
 
@vaultah python3, in this case, I guess technically though the import worked, but "from time import..." didn't work :)
 
9:27 PM
I mean, I figured out the cause but the import only fails in Python 3.4 or older
means you're running old Python :P
 
How can I get a decimal number (in this case 0.6) returned from a function? The way it is 0.6 is because 3 out of 5 of them have the same predicted and actual. Then you divide 3 by a number of items.

Here is the function I want def measure_accuracy(image_entries):

Let's assume I already put the following data set into image_entries

Data Set:

image_list = [
{ 'path':'1.jpg', 'actual':{'dog'}, 'predicted':{'dog'} },
{ 'path':'2.jpg', 'actual':{'dog'}, 'predicted':{'cat'} },
{ 'path':'3.jpg', 'actual':{'cat'}, 'predicted':{'cat'} },
 
poor @davidism
 
start by searching for "python round to decimal" if that's really what you want
 
@vaultah well that particular import failed because the method wasn't in my time.py script ;-)
but, it found my time.py in python3.6 correctly and that piece didn't fail on me at least? ha
 
how are you doing today?
 
9:38 PM
:38317205 We aren't lizards! (We're ssssnakessss).
3
 
@PM2Ring r/snek/ ?
 
@PM2Ring did I star that msg?
 
@AnttiHaapala Which message are you talking about?
 
that msg on the starboard... of yours...
I don't even remember starring it :D
 
@AnttiHaapala only you can see that
 
9:48 PM
but it is yellow... a bug perhaps?
 
@AnttiHaapala probably just a misclick
 
the first star was mine
 
Or is the act of starring separate from the act of a message appearing in the top n starred messages?
 
I wonder if there is a hotkey or sth.
 
So I have a question
 
9:49 PM
not unless you have userscripts
 
Are snakes lizards?
 
no
snakes and lizards are reptiles
bugs and beetles are insects
 
@AndrasDeak that's what I was trying to clarify. Thank you.
 
@AnttiHaapala Oh. As Andras said, only you can tell that. If the star looks yellow for you (or whatever special colour your theme uses), you clicked it. :)
 
This room was placed in timeout for 1 minute; let's review
2 hours ago, by davidism
Do research before you ask. Have a basic understanding before you ask. Don't answer if these two things are obviously not fulfilled.
That was satisfying. Now to go on a run and forget about this for a while.
 
9:53 PM
I thought you did go already
 
I drove home from work. Now I'm going for a run. I'm definitely not thinking about the pile of garlic we've accumulated today.
 

« first day (2474 days earlier)      last day (2471 days later) »