« first day (1782 days earlier)      last day (3159 days later) » 

7:00 PM
so you need to search for P on that sphere.
 
Yeah, all points on a sphere form a right angle with any antipode pair on the same sphere.
But since we have three points, we have three spheres, and need to find if they share any point(s) of intersection
 
take AB and the corresponding sphere, and search for the point P(C).
that's symmetric.
ah, ok. right. three spheres.
of course, they do
or not
damn
was going to sleep
thanks, Kevin
 
I'm inclined to think that they do, but I can't quite visualize it
 
cbg
 
and if P is on the sphere generated by AB, then CP is tangent to that sphere.
and apparently exists
 
7:09 PM
The sphere formed by AB and the sphere formed by BC intersect at a circle perpendicular to the plane ABC... Now the question is, does that circle intersect the sphere formed by AC? For ordinary acute-ish formations of ABC, it seems like it should
 
might also try a vector form
 
Yeah that's probably a more fruitful approach
 
DSM
Ooh, what did I miss? (rhetorical: I'll scan up)
 
ctrl-f for "Related to nothing"
 
DSM
Hmm. I think the answer is yes. If we choose the appropriate transformation, we should be able to make A, B, and C look like (1,0,0), (0,1,0) and (0,0,1) in an orthonormal basis, no? And if that's true, then P=(2/3,2/3,2/3) should give (A-p) ⊥ (B-p) etc.
 
7:18 PM
Since we're working with angles, I assume we can't use scaling (unless it's the same for each axis) or skewing
Not sure if that matters.
 
Hey guys, I'm using boto3 to lookup instances and get a specific value. However the response is a nested dictionary with lists. boto3.readthedocs.org/en/latest/reference/services/…
 
DSM
Hmm, that's true. We'd need to restrict ourselves to conformal transformations (angle-preserving.)
 
Does anyone happen to know how I would get a specific value in a nested dictionary?
 
@MoAli Generally, my_dict[key_1][key_2][key_3] etc etc
 
Trying that out.
 
7:23 PM
Ok, the more vectory problem statement of my question is, "Given three vectors A, B, and C. Find some vector P such that (A+P) dot (B+P) = 0 and (B+P) dot (C+P) = 0 and (A+P) dot (C+P) = 0."
 
cbg, all, bugrit
 
cbg Steve
 
@Kevin What if it's a list inside a dictionary?
 
In that case, the syntax is the same, but take care to use only integers as the key for the list.
 
Unfortunately the response doesn't use integers for the lists inside the dictionary :)
:( *
 
DSM
Every list can be indexed by integers.
(Well, okay, maybe not the empty list, but that's a corner case.)
 
@MoAli Interesting. I was talking about this with colleagues only yesterday.
 
@holdenweb It looks like I'll need to use some sort of loop to lookup my values.

http://boto3.readthedocs.org/en/latest/reference/services/ec2.html#EC2.Client.describe_instances
 
from collections import defaultdict
def tree(): return defaultdict(tree)
init_dict = {‘a’: {‘b’: {‘c’: 2}}}
my_dict = defaultdict(tree, init_dict)
 
most just write that as tree = lambda: defaultdict(tree) - and when did defaultdict take two arguments? :p
 
7:32 PM
Taking a look at defaultdict, thanks.
 
@holdenweb you've got curly quotes everywhere, unless my font is really messed up
 
That gives you a dictionary that you can add values to like my_dict['a']['b']['c'] - val` without worrying about whether the nested dicts exist or not
@davidism Looks OK in my browser
 
I think he wants to retrieve values from a nested dict that already exists, rather than add values to one.
 
Nope, they're definitely curly quotes.
 
Kevin is right.
 
7:34 PM
compare yours: , to '
 
They look curly to me.
 
Ah, QUOTES. YEah, just copied it from a Slack message. Sorry about that
 
@MoAli, ok, I'm looking at the return value structure of describe_instances. Is there any value in particular you're trying to fetch?
 
And obviously, with plain nested dicts you just do what @Kevin said some time ago
 
@Kevin For example the KernelId
 
7:35 PM
are we talking something like: value = reduce(dict.__getitem__, keys, the_dict) ?
I'm fairly sure there's loads of q/a's on the site on doing stuff like this in various ways... (he says before searching... but I'm sure I've answered a couple...)
 
@MoAli Try d["Reservations"][0]["Instances"][some_number]["KernelId"]
0 is probably a good starting point for some_number.
Possibly you can go higher if there is more than one instance (whatever an instance is)
 
why do I keep getting messages on linkedin? :|
 
@Kevin Thanks, I think I can work with this. It's still not finding the key but I get the structure
 
I'm a little worried that the function may be returning a string that only looks like a dict.
In which case you should probably call json.loads on it to get an actually useful object
 
@MoAli it's hard to tell exactly what you're confused about. The structure is clearly described in those docs. You navigate it just like you normally would in Python. What is the actual, specific problem you're having?
 
7:43 PM
@davidism My issue was that I didn't know you can query lists inside numbers using integers. So when looking up dict d["Reservations"][0] it makes sense how to query a list inside a dictionary and vice-versa
 
You realize you have an interactive interpreter whenever you're using Python, right? You could literally copy that example response into the interpreter and play around with it.
 
Query lists...inside numbers...using integers...?
 
s/numbers/dicts/ and it more closely resembles what I thought we were talking about ;-)
 
Yeah okay that makes more sense.
 
Ok, so A+P dot B+P = (Ax+Px)*(Bx+Px) + (Ay+Py)*(By+Py) + (Az+Pz)*(Bz+Pz) and with two other equations just like this I'm pretty sure I'm heading into a quagmire of unsolvable polynomials.
 
7:47 PM
@davidism I've been using the IDE, I just didn't know lists can be looked up by integers, I should have googled the error before asking.
 
I am having hard to time understanding this error or how I can fix this. I am using Python 3.4. My gist is here: gist.github.com/ahlusar1989/9250b4ebe33d18bbfc1f
 
Pro tip: have an interpreter opened next to your ide. I can't imagine developing without experimenting in parallel.
@ahlusar1989 what error? fix what? that's a lot of words
 
I receive this error: UnboundLocalError: local variable 'xml' referenced before assignment
 
@davidism Thanks.
 
it references the variable in the function
 
7:49 PM
words don't work here, only stack traces
 
How do I move it to global scope?
 
@ahlusar1989 while xml_string == True: is never True, because a string never equals a boolean.
 
It references line 25
xml_data = just_xml_data(xml_field)
 
Give us the actual error.
 
If you're trying to say "while xml_string is not empty", you should do while xml_string:
 
7:50 PM
Don't "helpfully" parse it for us, because it's unbelievably unhelpful.
 
that code appears to contain either an infinite loop, or a never-executing loop.
 
I am trying to contain a continue statement
 
I agree with davidism. Even if it was while xml_string:, xml_string never changes in the loop, so it loops forever
 
either way, the issue is that you return xml even if you never set it
 
@ahlusar1989 What does it mean to "contain" a continue statement?
 
7:51 PM
more like an empty loop, because if it's bool, it will fail before the loop.
 
All I am trying to to is pass in an xml string and convert it into a dictionary. the function should return a dictionary
 
If you're about to say "I initially had continue in there without a loop, but it gave me errors, so I added one", then you have a serious problem with your code structure
 
I probably do
I don't deny that
the while loop is to not break the loop
 
Not sure what you mean by that.
 
@MoAli x = d["Reservations"][0] is simply a shorthand for x = d["Reservations"]; x=x[0]
 
7:52 PM
@ahlusar1989 it sounds like you just don't understand what you're doing or what the data you're working with is. Unfortunately, we can't write your code for you.
 
I know - I had a working function and then my computer got wiped clean
That's not the problem
I am just creating a function to pass an xml string and return a dictionay
 
So wouldn't you just need this?
def just_xml_data(xml_string):
    xml_string = xml_string.replace('&', '')
    root = ElementTree.XML(xml_string) #serialize and parse into XML object
    xml = dict(flatten_dict(root))
    return xml
 
@holdenweb so I could possibly do something like

x = d["Reservations"]; x=x[0][0]["KernelId"] (second integer to access the Instances list)
That's good to know, thanks.
 
@Kevin the problem is that the XML data is malformed - hence the rationale for a try and accept
 
Hey guys, quick question(regarding wx like always)
 
7:55 PM
@davidism Better: use an IDE that includes an interactive interpreter
 
Ok, but if you catch the error, then you don't actually have any xml, because the xml generating function failed. So it doesn't make sense to try to return that xml that doesn't exist.
 
When I inserted an item into my listctrl, my entire window just froze - so I can't debug and see the error to search online
Do you guys know any possible cause from GUI related things that could cause the app window to freeze?
Usually what happens is I do something wrong on wxpython and it throws an error, and the app just would not respond while an error message is printed, but it wouldn't freeze.
 
Sure, hold on, psychically reading your code ... ... nothing.
6
 
@Kevin I have millions of rows with XML data. Many are malformed. Others are just fine
 
@OneRaynyDay GUI lock-ups usually happen when you never return control to the main loop, so the function never gets a chance to "catch its breath" and work on the event queue that governs screen repainting, window repositioning, etc
One possible cause of this is an infinite loop in your code.
 
7:58 PM
I want to skip over and trace the ones with errors and return the good ones
 
@MoAli Think about expressions. if d is a dict, then d["reservations"] is an item in that dict. If it's a list, then d["reservations"][0] is the first element of that list. If that element is a list then d["reservations"][0][0]is the first element of that list, and so on
 
@Kevin Ah okay, thank you! I'll go look for that. I do know that the freezing occurs within a for each
 
@Kevin so should it be along the lines of while len(xmlstring) > 0?
 
@ahlusar1989 Perhaps then the try should go around the code starting with xml_data = just_xml_data(xml_field) and ending with rows.append(row)
@ahlusar1989 No, don't have a loop at all.
 
@holdenweb Thanks, that's actually a really clear way of thinking about it.
Much appreciated.
 
7:59 PM
NP. It's confusing until you get it, and once you do you can't imagine how it took you so long
 
Okay
 
garlic all around, please
 
I need a lie down
 
@PeterVaro Ohh right right!
I'm still working on my component inventory project, got put on hold for quite some time while I finished university
 
@davidism I was wondering what that smell was :)
 
8:02 PM
@Kevin I just don't want to lose track of my loop ; there is alot going on
 
@ahlusar1989 at this point, you have recieved more than enough help. It sounds like you don't have the basis for understanding what to do, and unfortunately this room is not the right place. You have confused what you've written (which is wrong) with what you're trying to do. We can't help you any more.
 
@ahlusar1989 Just to be clear, putting continue inside just_xml_data will not cause the for row in dr loop to skip ahead one iteration.
 
garlic
 
brb
 
@davidism with all due respect, I am aware of what I am trying do - I just need to get some sleep
@Kevin I understand that
 
8:05 PM
go do that then, rather than acting confused here
 
Bleh I can't find a good NoSQL way to do this :\
 
I'm not acting - I am the spitting image of cognitive impairment after 72 hours of no sleep
 
DSM
Then take a nap. You should listen to me: I'm a doctor.
 
@ahlusar1989 please read this before continuing. I strongly suggest you read a tutorial and plan out your code on a whiteboard first.
 
I haven't busted out the "Trust me, I'm a doctor" on anyone (apart from girlfriend) yet. I'm biding my time for the perfect moment.
 
DSM
8:07 PM
@Ffisegydd: it can come in very handy. You need to work on looking intense when you say it, though: I practice in the mirror.
 
I can guarantee from personal experience that the single biggest improvement in your performance will come from sleeping until you can't sleep any more - which, after 72 hours, is likely to be twelve or fifteen hours
 
@DSM someone did point out to me the other week that "Surely every meeting/appointment you make is a doctor's appointment?"
 
DSM
I'm astonished to say I've never heard that before, not even once. (But then I forgot your Skin 2.0 routine..)
 
@DSM if it makes you feel any better... I haven't heard that before either...
 
I've gotten re-addicted to The Instance podcast D:
 
DSM
8:13 PM
"This site may be hacked."
@Kevin: FWIW I've now changed my mind, and suspect that it's not true that there's always such a point.
 
recabbage
 
Yay! I have 666 messages in my spam folder...
 
I had 666 helpful flags a couple weeks ago.
 
Getting 666 declined would be an achievement... how many times you'd end up being flag banned before getting to that level would take a lot of persistence :)
 
8:34 PM
2 hours into learning Python and list(range(10)) errors out even though it's straight from the docs
Any idea why?
Error message recieved is "TypeError: 'tuple' object is not callable"
 
DSM
Psychic guess: you rebound list or range accidentally
 
You've re-defined - ...
 
DSM
(I promise I started typing that before he mentioned the error..)
 
haha...apparently I did
Restarting IDLE fixed it!
 
Does the error message make sense now?
You're basically treating your re-bound tuple as a function and trying to call it.
 
8:37 PM
You get bonus marks though, if you named a tuple list :p
 
it actually all makes sense now...I have a function where I've defined list as [1,2,3]
forgot it was a keyword
 
Generally you should always avoid using builtin names as variables.
 
heya @NightShadeQueen
 
Some keywords you can't, such as trying to re-define def or for.
But list isn't a keyword, it's just a builtin function.
 
ah I see
makes a little more sense now how I could have so easily over written it
thanks for the info...was going crazy for the last hour trying to understand why it didn't work
 
DSM
8:40 PM
Next time break the problem down by throwing prints everywhere. print(range(10)); print(list(range(10)); print(list); etc. This helps even if you don't notice "hey, it thinks I'm calling a tuple. Syntactically, what am I calling? list and range. So I guess one of those is a tuple!"
 
I forget if you can do this in IDLE, but in ipython you can just type the name of something, followed by a question mark, and helpful text comes up. (ie 'list?')
 
DSM
I hate it when you figure out an ambiguous case seconds after you post.
 
Rhubarb
 
huh, interesting. enumerating through a dictionary makes the index start at one?
 
no, enumerate(my_dict) -> (0, key), (1, key), ...
 
8:53 PM
lol
 
oh derp I thought I discovered something interesting, but it was just my own bad code
Sprouts
 
@DSM Good tip, thanks!
 
9:20 PM
Wow... big orange moon today - puppy scared
 
Ouch! I went to check, that's the sun!
 
I did try and take a photo, but alas the camera on the phone is beep in low light
(so fairly sure it's not the Sun!)
 
9:37 PM
its because the moon is the closest to earth than its been in the last 15 years or something
our moon on monday was huuuuge
(or maybe it was sunday)
 
9:57 PM
@corvid thank you both - just looking for something where I can go 'back to basics' and learn good habits (or at least not bad practices) and move away from GAE..
@davidism Thanks, I will use that as a reference :)
 
GAE? chokes on his tea
I'd advise anyone to just get a $5 basic digital ocean account or something - that way you can learn loads on setting stuff up, scale it, etc... Never found a use for GAE/Heroku nad kin... (as yet)
 
@JonClements Yeah that's partly why I want to move away. It's been the only way so far I've done web stuff (in Python), want to go 'back to basics' as it were with Flask for it's lightweight-ness/flexibility and 'not-proprietary-ness'..
 
Yup - you'd also be able to use the right tools, learn some sys-admin stuff, etc... and as you say, get away from a specific environment
 
curious why not Heroku though?
 
Well, I've found its services less of a convenience and more of an annoyance
it obviously does fit some ways of working though which I quite liked... maybe I'm just old-school and just prefer a server to be specific to a task and configured exactly how I want it for the task at hand.
 
10:13 PM
@JonClements any opinion on AWS?
 
@OneRaynyDay no experience to have an opinion I'm afraid
If you're into heavy occasional processing then I believe it has advantages over paying for "idle" time
 
@JonClements ah, no problem! I was thinking of getting digital ocean account(but I develop on java spring), but some friends were suggesting heroku or aws
Not sure how heavy you mean by heavy :o
 
Well, if you want to outsource an occasional massive number crunching job that lasts a few hours, that can run in parallel etc...
then it's better to use AWS instead of keeping N many server/cloud instances about that you're paying for whether or not they're actually doing anything
 
Hm yeah I've just had a look at the two, definitely see what you mean re: customisability/lower-level as it were. I only really came across Heroku as the "thing you can immediately deploy to from git", which is a pretty cool novelty imo.
 
@JonClements Ah, let's say I want to constantly call an external api from my servlet for hours on end, should I resort to aws then?
 
10:20 PM
@OllieFord takes just a few moments to set up an appropriate commit hook with a good git setup, to do pretty much the same
@OneRaynyDay all depends... too many factors involved - choosing a good environment, eco-system, host, supplier etc... is so conditional on the actual task/thinking about future requirements etc... it's a judgement call
 
@JonClements yeah of course, that's why I say novelty. I'll probably check out digital ocean, dollar payments just sting because it can cost me more in bank fees than the actual payment (e.g. Google Drive)..
 
@JonClements ahh I see. I've made a couple dispatch servlets in java spring ready to deploy but I've never actually deployed one.
So I have 0 experience in this haha. I guess I'll stick with trial and error!
 
@OllieFord the trick there is to deposit into paypal your local currency, then since DO accept paypal, use that to avoid x-rates... although it's been a while, so that might be a "loop hole" that's been fixed
 
@JonClements Ah nice, if they do (Google didn't when I set up) that's great, thanks :)
 
11:18 PM
Is it possible to upload a new to public folder google drive/dropbox from python script without authecation?
I know dbinbox.com cloudwok.com do it but with no python api provide.
*new=file
 
sure ... copy C:\my_file C:\Users\MyUser\Dropbox\SomeFolder\my_file
or cp if you are on unix
and then dropbox will take care of it for you
@OllieFord I like digitalocean alot ... I used to like dreamhost ... but digital ocean will probably be my only host soon (I still like dreamhost quite a bit... but its pricy)
 
Thanks for reply! But this won't solve my issue. I am stuck building a python app for android in kivy. I want to add feature where all users can upload some data to common folder without authentication.
Apparently google's api needs authecation stackoverflow.com/questions/11432742/….
 
11:42 PM
@AbhishekBhatia write your own service that runs remotely. It knows the authentication for your dropbox, and accepts requests to add, list, and get files from all the clients. Now you just authenticate the clients with your service (oauth, etc.), and your dropbox credentials don't get leaked
 
Thanks davidism for the great idea! Apparently, I have no idea how to implement this. Can you please provide some links?
 
Step 1: write service that can upload, list, and get files from dropbox (simple python program, dropbox api)
Step 2: write api for this service (flask, oauth)
Step 3: use service (kivy app)
 
Step1 and Step3 I understand. Please elaborate step 2 more. I know little bit django.
 
I would start by searching. And Django's fine too, that was just an example.
 
Quick question: in the top most __init__.py of my package I configure the logger (standard library logging). However, for other modules to gain access to this logger, this setup must be done before they are imported. This means the import statements are not on the top of the script anymore. This is against pep 8 standard, I think. Is it ok though?
 
11:53 PM
@AbhishekBhatia please be wary that you're becoming what's called a help vampire... while we as a room do our best to help, there's a limit to our generosity. We're not here to hand hold you nor explain every single thing. Make an attempt at things yourself first, then if you have a specific issue, then talk about that...
 
@RenaeLider you should be configuring the logging before running the program, not before writing the program.
The whole point of the logging module is that you can just make calls to it, and configure it just in time.
 
so.... __init__.py is not the place to configure the logger? That's the first point of execution. everything else in the package is brought together in there.
 
importing your module should not be running it
that's the whole point of stuff like __name__ == '__main__', argparse, etc.
What are you doing to logging that requires everything else to import after it?
 

« first day (1782 days earlier)      last day (3159 days later) »