« first day (3619 days earlier)      last day (1344 days later) » 

12:58 AM
hello guys
 
 
4 hours later…
5:01 AM
@harveyslash Hi
 
 
3 hours later…
7:51 AM
hi
I'm pretty new to python
 
greetings @Washery
 
I have a collection of objects I'd like to serialise into a JSON
I tried str(array) but it returns a string that cannot be parsed
@PSSolanki greetings
 
8:22 AM
@Washery then use a json serialiser module? docs.python.org/3/library/json.html#json.JSONEncoder
If they are built-in objects then json.dump should work out of the box
 
Happy programmers day guys
 
ok
so, python, right?
the poisonous snake
letmeaskyouonething
 
@CarlGentleman no
 
@CarlGentleman Yes!
 
not even venomous
@Praveen you too
 
8:29 AM
oh, it is just... a strong snake, it may be, idrk
do you have any tool to sef-generate a rest in python
a restfull http multiplexing server
 
@CarlGentleman please stop that
and don't use expletives here
 
restful apis autogene?
 
hi guys, i was thinking of making a gui that shows notification ones i get any notification or reputations here on SO, but for that, i need some kind of API from StackOverflow right? is there something i could use? or webscrapping? any suggestions?
 
@CarlGentleman you are not making sense. Stop posting half messages. Use proper English.
 
8:51 AM
@AndrasDeak how to use Jsonencoder?
It says Object is not JSON serializable
 
@Washery if your objects are not in the list of built-ins there you have to extend the encoder yourself. There's a paragraph there that explains how to do this; I checked before dropping the link
There's a high chance that there are other (probably non-stdlib) libraries that let you do the same thing but I've only ever needed to (de)serialize simple JSON
but at the end of the day if you have a custom object only you can say how it should be serialized to JSON, since JSON doesn't know about your objects
Just think of a python set. It doesn't have a JSON equivalent. How you serialize it to JSON is up to you.
you might even choose a different kind of serialization entirely if that fits your use case better
 
it's an object coming from a third-party library
unfortunately there's little documentation
 
Are you serialising or deserialising?
And what is your purpose with serialisation?
 
[in: a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d @ 647000 0.0001000 id=0000000000000000 ]
it's for handling bitcoin payments
I'd like to have a json representation output
 
okay
 
9:01 AM
say { payments: [ [txid: "", amount: "", height: ""] ] }
 
But you could make that JSON output without serializing the entire class?
Or whatever the object is that you're currently working with
 
I don't know as the documentation is lacking
printing out the array it's that string I posted before
[in: a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d @ 647000 0.0001000 id=0000000000000000 ]
 
Is this a webserver you're running?
 
yes
 
Ok, using what framework?
 
9:03 AM
I believe the array is a collection of objects representing payments
flask
 
Then look into flask-restful or marshmallow
 
ok
how to extract data from the payment object?
 
How do you get that object?
 
I get the array back from the library
given the array [in: a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d @ 647000 0.0001000 id=0000000000000000 ]
I guess I could cycle through all elements and somehow extract txid and amount
maybe dot notation? obj.num, obj.id
 
That probably isn't an array, it looks like a __repr__ of a request object or something. What is the library generating that?
 
9:08 AM
it is probably as I'm doing print(str(array)) for debug purposes
 
i just want to point that... as expected, flask-restful does NOT self-generate a restful API
 
I, nor anybody else, suggested it did
 
a good RESTful HTTP API
 
No they don't. Whatever excitable nature is behind your stream of consciousness has probably invented it
 
flask-restful
but flask is a dependency, and restful is still to be done
so, selling smoke
 
9:13 AM
They didn't sell anything. You actually have to put some work in to standardise a RESTful API. I'm bored of you and you've been kicked a few times; I'm getting inclined to do the same
 
okok
i am just here for giving tools, dont kick me
im working for free moreover, just to open source projects
 
Then stop the stream of consciousness that doesn't make sense. Once you get 3 kicks it gets more serious for you
 
i do some jokes and that, but i am trying to express something, i dont understand y u kick me all the time
 
ok I was successful to run a loop and get each object to print out amount and txid
 
9:17 AM
@CarlGentleman you were kicked because you changed nothing in your behaviour after my warnings around the first two kicks. You are welcome to ask and talk about python problems. Repeating the same badly formed question in such an off-putting style will reliably lead to you being kicked.
 
how do I create a schema with marshmallow?
class Payment(Schema):
txid = fields.Str()
amount = fields.Decimal()
confirmations = fields.Integer()
 
It tells you right in the first example; result = schema.dump(album)
At the moment, though, you were stuck on _de_serializing an input. Have you first fixed that?
 
I can loop through each object
 
9:31 AM
@CoolCloud There is a Stack Exchange API
 
10:01 AM
@roganjosh oh, ill take a look there, but do you know any other methods?
 
Why would you need another method vs. the actual API?
 
"I need an API" "Here's the API" "Any other method?"
 
okay thats true, im dumb.
Thanks a ton i found a python wrapper for it.
 
10:15 AM
one more quick help, i took a look and found out i needed the inbox part from the API but in the python wrap i cant find the inbox, is there any way you guys know ?
 
I've never used either the API or a wrapper for it sorry. What is the wrapper?
 
You found the wrapper, or you found the inbox-equivalent feature?
 
i couldn't find the "inbox-equivalent feature"
 
I don't think there is one. From this it looks like you pass the API endpoints as strings
 
10:24 AM
oh, im completely new to this, any way you could give a brief explanation?
i believe i need some kind of authorization. The only time ive used an api is a for the website and it was pretty simple too. Dont know how these works 😬
 
You can see that the library is very small. It's not doing an awful lot; it looks like it holds session data to keep you authenticated with the site's API and you query it much like you would via the actual API I linked earlier. If I had to guess, you'd use inbox = SITE.fetch('users/<your_id_here>/inbox')
 
oh okay cool, how to get the id?
 
@CoolCloud refer back to my original link that tells you how to get the credentials
@CoolCloud Look at your own profile. See the number in the URL?
 
wow thanks let me try it out
 
Your ID is 13382000; a pleasingly-round number. I'm jealous.
 
10:32 AM
You do need some auth too for inbox. Maybe an f-key...
Some access token
 
how to receive the access token?
 
Yeah, that's in the link I gave originally - here
 
@roganjosh 😂
 
@CoolCloud you might want to read the API's documentation first
I used it once and all information was given there...
 
do you have that code? or some thing so i can refer?
 
10:37 AM
@CoolCloud seriously?
 
nah, ill find a way😂
 
I actually was reading, thanks, will take a closer look
 
10:55 AM
"Send a user to stackoverflow.com/oauth, with these query string parameters" it says thesem but how do i pass these parameters? + it says that the app must be under a registered domain, so what does it actually mean?
 
Did you get an access token?
I still have the github open. Pay attention to this and the line below. Just register to get your API access - I don't think you need to worry about the redirect
 
oh so how to actually receive an access token ?
 
I don't know officially what the "registered domain" means in this case or how it checks that. But you can buy domains, like I bought jpilkington.com. That costs me money, and then I have to use letsencrypt to get SSL tokens so you can access via https (the latter being free)
@CoolCloud you really need to get used to researching things yourself. I gave you the official guide; there's no reason I, or anyone else, would be better at figuring it out than you - we'd all be working off the same documentation
 
Oh, your a data scientist, great!.
Im, at the same time, trying to figure out, but it all seems new to me, thanks for the help though
 
You realise that we all spend most of our time thoroughly confused? If you're not, then you're not pushing the envelope of your understanding
 
11:04 AM
Understood😂
 
11:31 AM
I've just seen this: res = {k: sum(x[1] for x in v) for k, v in groupby(sorted(chain.from_iterable(map(dict.items, (d1, d2, d3))), key = lambda x: x[0]), key=lambda x: x[0])}. Ouch.
 
What, no asspressions?
 
I'd suggest them if I knew how they worked. Sadly, I didn't invest time in doing that
 
using two identical lambdas instead of an itemgetter(0)
the more I keep looking at that the worse it gets
found it
 
I'm glad that they compacted the 3 lines of code for merging dictionaries down to one line, though. Much clearer.
 
Unfortunately that's exactly what OP asked for...
 
11:40 AM
They asked for a one-liner, doesn't mean you have to serve them up a swamp monster
 
It doesn't?
 
mmm, ok, maybe it does :P
 
11:53 AM
Finally got it all registered, and got a client id as well as access key and now api sends me lots of json, and its hard to understand whats going on, is there any app thats simplifies the way json looks?
 
Two ways. json.dump(object, file, indent=4) or copy/paste to jsonlint.com
jsonlint is handy because it works with python objects even if they aren't valid JSON (which they won't be, on account of them being lists/dicts)
 
I just got this error
Error: Parse error on line 1:
{ 'backoff': 0, 'has_
--^
Expecting 'STRING', '}', got 'undefined'
 
Stab in the dark - you've got jsonlines
Actually, it can't be JSON at all because you've got single quotes
 
What else could it be😂
 
You'll need to tell me how you got that error
@CoolCloud a dictionary
 
12:00 PM
i just pasted the code and pressed validate and boom, error pops
 
To jsonlint?
 
yep
 
Well, sure, see again:
 
@roganjosh could it be a dictionary? it seems so messy, my eyes hurt😂
 
4 mins ago, by roganjosh
jsonlint is handy because it works with python objects even if they aren't valid JSON (which they won't be, on account of them being lists/dicts)
 
12:01 PM
you saw the future!!
 
I never said that JSONlint was going to accept it; it will still fix the indentation for you
 
yes, it did, thanks! i can read through now, atleastt
 
It's what I use to fix questions on SO that don't bother fixing the indentation. I cba taking the string and dumping it to a file to fix; just pass it through jsonlint
 
You just really saved my eyes !
Pretty much done with the backend, now have to make a front-end for this
 
12:54 PM
@roganjosh Lol :p
 
 
1 hour later…
2:24 PM
Hi, i actually got it all setup but then the requests part, i seem like i need to get the access code,manually i can type it in and click on ok and copy the access code, but isnt there a automatic way to do it? using requests or oauth im not sure, ive tried googling it, but there are veryy few examples to it. Could anyone help me out?
 
Both of those are bundled into the wrapper?
 
like?
 
oh, come on. I linked the line of code that showed where you passed your auth token
 
Yes? i passed it like site.access_token = ......
 
2:39 PM
I guess you'll have to figure out what your wrapper is doing
 
*bracing for desperate questions about what their wrapper is doing*
 
<has prepared a list of reponses>
 
@roganjosh have you, though?😂
 
Well, not for that, but I'm waiting for the response
 
@AndrasDeak its fine, i might just leave it like this for now, maybe figure it out later.
 
2:42 PM
I think you get the point... at this point
 
yep
 
@CoolCloud I have more faith in you than that. You should too
 
@roganjosh ahh yes hopefully, ill complete. Will let you know. Thanks for alll the helps !
 
user12867493
POST methods expects all parameters to be submitted as a form, not on the query string when I do requests.post(). Any ideas why?
 
Precisely for the reason it says? GET requests will put the parameters into the URL and POST will put them in the body of the request
You'll need to say what threw that error
 
user12867493
2:55 PM
I added headers but now another error
 
user12867493
header = {"site": "stackoverflow", "option_id": option_id, "key" : REDACTED", "access_token": "REDACTED"}
            response2 = requests.post("https://api.stackexchange.com/2.2/comments/"+lines[i]+"/flags/add", headers=header)
 
user12867493
{'error_id': 400, 'error_message': 'site is required', 'error_name': 'bad_parameter'}
 
That's why I said "body"
 
user12867493
So what's wrong with it?
 
user12867493
I gave a site...
 
2:58 PM
I think you might need to use data and pass a dict, but I'm looking into the docs and I'm not sure it will work with the SO API
 
Is "stackoverflow" actually a valid "site" name?
 
@Daniil What are you working on?
 
user12867493
@CoolCloud Just playing around with flagging through the SE API.
 
user12867493
@AndrasDeak Yeah, I managed to flag manually with that (i.e. putting the API route in the browser).
 
What way did you pass in the access codes?
 
user12867493
2:59 PM
Strings
 
@CoolCloud >:|
 
no like the code used.
 
user12867493
What do you mean?
 
@AndrasDeak which emoji is it though 😂
 
@CoolCloud not a happy one
 
3:01 PM
@CoolCloud You have to stop waiting for others to do your learning for you. This is not sustainable. See also en.wikipedia.org/wiki/Cargo_cult_programming
 
user12867493
@roganjosh Thanks, it worked.
 
@AndrasDeak i did not ask him to do the LEARNING for me, i just asked the method he used, so maybe i could reproduce it.
Its fine, i dont think i can explain what i mean through words, ill do more research
 
Hi. Has anyone used speech_recognition package here? I am using exact same code as provided here. But I am getting 'json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)'
 
That error isn't thrown by the package, it's thrown by the built-in JSON module
 
What could I be doing wrong here?
 
3:10 PM
It's not JSON
You'll need to show what you're actually doing
 
ahh. Actually it is a bit all over the place. let me clean and consolidate it some where and get back to you.
 
All you (might) need to know is that whatever you're passing to the library is not JSON
 
3:28 PM
@roganjosh Here's the link to the cleaned code : pastebin.com/dSfanYpy
 
@jatin that doesn't help me, sorry. I don't know what half those methods are, or why audio has anything to do with json
Maybe someone else with more familiarity with the library can help
 
Considering that the speech-recognition module was last updated more than 2 years ago, it's entirely possible that it no longer works. I'd try it out, but the dev apparently couldn't be arsed to include all dependencies, and I really don't feel like installing them manually
 
Actually I am following a tutorial which was published on May 2020 and the voice recognition work fine for the tutor.
Unless the tutor has uploaded an old video
 
3:56 PM
Upadte : PyAudio shows 'OSError: No Default Input Device Available'.
'
 
sounds like an improvement
 
soundless improvement
 
4:12 PM
<admires the new acoustic buffering in room 6>
 
4:41 PM
Does Tkinter has any role in web development using python?
 
4:58 PM
Nope
 
 
2 hours later…
6:34 PM
This is a first: A person I tried to help demanded proof I couldn't reproduce their error.
 
 
2 hours later…
8:15 PM
Update: Problem solved. Any guesses how? Restart. I just restarted the PC and it started working. I spent so much time trying to get to the bottom of this and solve it. Neither did I save time nor did I get to know the problem. But solved it anyway. Thanks.
 
 
1 hour later…
9:39 PM
Hi, here i am again, i was wondering if anyone knew how to get url from selenium after navigating to later pages, the only thing i searched and came up with was driver.current_url but i want the url after the user has navigated forward or logged in, any ideas?
 
@CoolCloud Have you read a selenium tutorial?
 
@AndrasDeak thats where i found driver.current_url from have been searching SO, but cant still cant find any new methods.
 
Can confirm that current_url does what you want
 
current_url gives me the url that i specify to them right?
but after they navigate through
i want the url
 
9:52 PM
it gives you the url that's currently in the url bar
 
i already specified driver.get('www.google.com') so current_url will be 'www.google.com' aight?
 
if the browser has finished loading that website and the user hasn't navigated anywhere else, yes
...and you haven't been redirected
 
but i want the user to search something and get that url
any ways?
 
well, how do you know when the user has finished their search?
Wait for that to happen, then use current_url. Can't help you more than that cause I'm going to bed
 
when the page has changed, right?
@Aran-Fey Thanks for the idea!!
 

« first day (3619 days earlier)      last day (1344 days later) »