« first day (1835 days earlier)      last day (3108 days later) » 
00:00 - 13:0013:00 - 00:00

1:13 PM
@TigerhawkT3 sadly - it's something that does need to be taken into consideration
 
I guess we'll just deal with it.
Anyway, I gotta go to sleep. Rhubarb to you all.
 
Anonymous
Is it me, or is this a bad way to fetch an JSON API
 
Anonymous
api_url = 'http://api.example.com/list.json'
response = urlopen(api_url).read().decode('utf8')
data = json.loads(response)
print(data['name'])
 
Anonymous
Because, I keep getting errors randomly
 
Anonymous
 
Anonymous
1:20 PM
Just in case someone is interested to see the error
 
@samayo the error is pretty clear.
 
Anonymous
@Ffisegydd Name or service not found ?
 
Anonymous
I am a beginner in this, so it's a bit confusing.
 
Anonymous
Why does it even work and arbitrarily stop without any change in the API?
 
@samayo incidentally, I wouldn't call a file all.py if I were you.
 
Anonymous
1:36 PM
@Ffisegydd trust me, if you were me .. you wouldn't reuse a single line from my project. But this is for learning purpose, like a pet project. So, first I have to make sure it works, then I will re-write everything
 
@samayo yes but my point was that by using all.py if you import all then you'll be shadowing the builtin all function which can cause all manner of strange and hard-to-debug errors down the line.
 
Anonymous
Well, I thought when you normal import something it is imported from some place I don't even know where it is. I didn't think a name of a file would conflict with the modules, specially given the fact the modules are not in the same dir as all.py
 
Anonymous
Well, I will rename it to something else.
 
@samayo Consider the following code:
x = [True, True, False]
print(all(x)) # False, as not all the elements are True

import all # Importing your all.py file
print(all(x)) # Error.
That's why you typically don't name files that overshadow builtins
As to your original error, without the actual code it'd difficult to tell your problem.
 
@samayo Your all.py file is a module, so if you did import all in another script in the same directory it'd import the stuff you've defined in all.py
 
1:42 PM
But the urllib error suggests that it can't open the page.
 
Anonymous
Hm, interesting. So, the only way to get past the import problem would be to give the files a unique name. as for as the urllib I think the API has a rate limit, and when surpassed it returns a JSON 404 response.
 
Anonymous
I think that might be the issue.
 
That sounds like something an API could do.
 
@samayo That code's only fetching a single JSON object. So what do you mean you "keep getting errors randomly"? Does your real code have a loop that tries to fetch a bunch of different JSON objects from the same domain? The server may not like it if you hit it with a bunch of requests like that in rapid succession. ... As you might guess, I wrote that before I saw your last post. :)
 
Anonymous
@PM2Ring Yeah, you are right. It is in a loop, I just omitted that part
 
Anonymous
1:55 PM
Here is dpaste cc @Ffisegydd
 
Anonymous
I am actually using time.sleep(10) to get past the rate limit.
 
Anonymous
But, since the data is huge, maybe there are some additional limits in play
 
2:47 PM
Does Python searches classes' scope when look for a variable ? Apparently no ! Therefore the (LEGB) rule doesn't apply to classes paste.ofcode.org/xdeP4wUpwszKns9SfX66Lw
That's strange
 
Your python code is not doing what you think it's doing.
Try print(Whatever.X)
 
@samayo domain resolution failure?
 
Anonymous
@RamchandraApte Nope. The domain works just fine, because the loop fetches the API and stops with the shown error randomly.
 
@samayo seems like something wrong with the internet somewhere: askubuntu.com/questions/185070/…
 
@Ffisegydd I know that works
But why methods don't look for their vars inside the class first ?
 
2:54 PM
@samayo try with wget and delaying and investigate
 
Anonymous
@RamchandraApte No doubt it is an internet issue :) But, the fact it works and stops is where the mystery is.
 
@samayo try ping investigate packet loss. Also try wget, it may give a better error
 
@direprobs If they did that how would the interpreter know whether you were talking about a local var or a class attribute with the same name?
 
Anonymous
@RamchandraApte it is working fine.
 
Anonymous
resolving api.example.com (api.example.com) ... 192.30...
connecting to api.example.com (api.example.com) | 192.30|:443... connected.
HTTP request sent, awaiting response ... 200 OK
Length: 165847 (162K) [application/json]
 
3:03 PM
@samayo yeah, repeat wget with 10s delay and check when it fails
 
@direprobs: You may enjoy studying Facts and myths about Python names and values by SO veteran Ned Batchelder.
 
Anonymous
@RamchandraApte Ah, I didn't know you meant that. You really think wget will give a better explanation for the error?
 
@PM I didn't get you first comment, but I thought that classes would implement the same mechanism for function (LEGB), since a class is a self-contained namespace
 
@samayo Possibly, just try.
 
Anonymous
It is going to get tricky to do a delay and repeat command in wget, but I'll try
 
3:07 PM
@samayo ah yeah, windows, but I think there is a delay command in wget IIRC
wget -w
(-w is delay flag)
 
@direprobs Sorry, I can't hang around to discuss this further, it's getting late here. Hopefully, that article I linked will help you to understand why the Python name resolution scheme (both in general & in classes) works the way it does.
 
@TigerhawkT3 Yes, the point of from __future__ import print is to use Python 3 "a little bit" as you say. If you don't understand the utility of this sort of thing, it's probably because you don't maintain a cross-version library.
 
rhubarb
 
rhubarb to PM 2Ring; cbg to everybody else.
 
@PM2Ring No problem
 
3:10 PM
cbg Patrick
 
Anonymous
@RamchandraApte for i in {1..1000}; do wget url --wait=30
 
Anonymous
do you see anything wrong with at?
 
Anonymous
ah, forgot done
 
Anonymous
for i in {1..1000}; do wget url --wait=30; done
 
looks gud
 
Anonymous
3:18 PM
Warning: Wildcards not supported in HTTP
 
Anonymous
hm...
 
Anyone is able to answer my question ? It's really itching me
 
This seems relevant
 
Yes, it is relevant. As described there, class variables are meant to be found from self.
"Enclosing" is done partly by traversing the call chain.
Also, it references the canonical source, PEP 227. Look for the section there that starts with "Names in class scope are not accessible."
 
3:46 PM
So its a design issue not a programming issue
I mean by that, classes can behave like functions, however, the would make names obscure ?
 
3:58 PM
As I read and understood from the PEP, it's a design trade off
 
I think it was a design decision done partly to avoid programming issues. It doesn't really add any serious issues -- you can always get to the class variables.
 
Yes, True
I was wondering what they didn't use the same mechanism that's used for functions
This also will force programmers to qualify each time they want to use a class's variable
 
Qualifying from within an instance to use a class variable is no different whatsoever than qualifying to use an instance variable.
(For reads, that is -- which, based on your code snippet, is what I assume we're discussing.)
 
4:13 PM
I still don't get that
 
What don't you get?
In your code snippet if you had printed self.X you would have gotten the other one.
 
Yes I know
but resolving the names to the class is much more clearer to me
I don't know the inner details, but I think that would be clear to anyone, isn't it ?
 
The scoping rules were essentially added for variables you couldn't otherwise get to. Yes, you could do something with classes, but then what do you do with super classes? If it makes you feel better, you could consider it to be a pure efficiency play, because the function variables are completely known at compile time, but the same is not true of class variables.
 
So the qualification story is about supporting inheritance ?
PEP: "An alternative would have been to allow name binding in class
scope to behave exactly like name binding in function scope. This
rule would allow class attributes to be referenced either via
attribute reference or simple name. This option was ruled out
because it would have been inconsistent with all other forms of
class and instance attribute access, which always use attribute
references. Code that used simple names would have been obscure"
 
Yes, I read that to say that accessing immediate class variables without qualification would be different than either accessing instance variables or superclass variables. Also, because classes are open (new variables could be added at any time) you would need to have a check the class, then check the globals load, in addition to the check the instance, then the class, then the superclass, ... load.
 
4:28 PM
My brain is all about implementing it like function, I can't get this at all
I read tons of words, still don't get their idea yet
Do other languages like Java have the same behavior too ?
 
I don't use Java, but Java is statically typed. Python is open. You can add methods to classes later. You can even reuse class methods in a different class later. A method is not at all the same as a sub-function.
>>> class foo(object):
...     def a(*args):
...         print(args)
...
>>> class bar(object):
...     a = classmethod(foo.a)
...
>>> x = bar()
>>> x.a()
(<class '__main__.bar'>,)
Classes are completely orthogonal to functions. It is only a thin wrapper around a function that describes what class it belongs to and this can be added, removed, or replaced.
>>> class foobar(object):
...     pass
...
>>> foobar.a = classmethod(foo.a)
>>> foobar().a()
(<class '__main__.foobar'>,)
>>> def b(*args):
...     print(args)
...
>>> foobar.b = classmethod(b)
>>> foobar().b()
(<class '__main__.foobar'>,)
 
4:50 PM
Exactly
I think I'm going to forget about that
Since I'm new to OOP, dwelling in such details is advanced to me
How it feels when you have a question and you thirst to get the answer ?
But what I really understood was, saying X inside a class is obscure, but using class.X is clear. That's what I really understood from the PEP.
+ Since instances use qualification and to access a name of a class you would qualify (e.g class.name) getting rid of qualification inside the class would be inconsistent. Since in either cases we use qualification, it would be more appropriate to use qualification inside the class too. That's probably their logic.
 
5:17 PM
Does anyone know a good dupe target for stackoverflow.com/q/33332539/2301450 ?
 
cabbage
 
cbg, doniyor
 
Oh, I found something in the /canon: stackoverflow.com/questions/2612802/…
Sorry, @Patrick, I didn't notice the array2 = array part...
 
I think either one could be a dupe target -- they both convey the idea that assignment just binds a reference.
The one in the canon is good.
 
5:24 PM
We can suggest 2 dupe targets
The "Possible duplicate" and the one I'll choose
 
I added the possible dupe -- hammer it!
 
Oh. Huh, it didn't work
 
It did for a minute. I wonder if someone killed my comment?
Let me try again.
 
Did you cast the close vote?
 
5:30 PM
That's the problem :(
 
Didn't want to detract from the glory of your dupehammer.
Well, I've re-commented now.
Seems to still be there -- look good to you?
 
Yeah :)
 
Anyway rhubarb for now -- have to go put everything back in my cube after they moved it 3 feet :(
 
take care Patrick
The above "take care" seems amiss, a simple "rbrb" would probably be okay
 
6:08 PM
Welp, rhubarb for all
 
6:45 PM
Greetings to all!
 
hello!
 
Hi idjaw, what's new?
How did you decide on the van Legogh avatar?
 
exploring my new house, trying to learn how to be handy. Never owned a home before :). Waiting for my kids to wake up to go to the park, so I'm just fixing up a set of helper methods for work to help communicate with the OpenStack Ironic API.
how about you?
 
Afternoon nap huh? I should take one of those.
 
Oh... for the Legogh, I saw it on Reddit, and my beard gets reddish when I let it grow...so the look kinda resembled me...so I decided to go for it.
 
6:59 PM
I just got out of church and I'm trying to finish my required 2nd cup of tea for the day. I'd usually go to the Python office hours meetup, but I'm supposed to be at a birthday get together... in about a minute...
tea's only about 20% drunk - though I suppose I could dump it in a to-go cup
 
you could go for fashionably late and enjoy the tea :)
 
that's a very good idea
I think I'm probably safe endorsing people on LinkedIn for Python if they've demonstrated the skill here, right?
 
@idjaw Threads and processes are awesome and amazing and everything good in the world
 
absolutely. Especially here.
@AmagicalFishy I'm glad to see your enthusiasm over threads! :) I take it your code is working then? :)
@AaronHall why thank you. :)
 
It's working pretty awesomely. I rewrote everything to forgo the use of Pool.map() and instead manage the threads/processes myself via threading.Thread and multiprocessing.Process subclasses ;D :D
The one problem I have left is trying to figure out why this multiprocessing.JoinableQueue() is hanging when I try to join() it
but otherwise everything is running crystal clear and it is amazing :D thanks so much for your help yesterday
wait
whoops.
 
7:10 PM
it wasn't exactly me :)
 
i confused you for tristan for a second there
haha, yeah. my bad. :D
 
it's all good :)
I was a bit confused at first
 
I don't blame you. you should've just rolled with the punches and said "you're welcome. i'm probably the best helper ever." ;)
 
I gotta head out again. cheers.
:)
good luck with your code @AmagicalFishy
 
have fun at the park
 
7:13 PM
thanks! :D
 
Thanks @AaronHall :) enjoy the party
 
user559633
8:04 PM
@AmagicalFishy and what does join() do? are you giving it a timeout? does a queue ever return or terminate?
 
@tristan I figured out my problem! I had to switch a Queue.Queue() to a multiprocessing.Queue()
 
user559633
And what's the difference between the two?
 
What i ended up doing was a "for entry in list(Queue.Queue().queue): multiprocessing.Queue().put"
Queue.Queue() isn't processor aware
while multiprocessing.Queue() is
 
user559633
:) You should be proud of yourself -- you're getting through this and learning very quickly
 
At first, my program uses like 20 - 30 threads to fetch a bunch of stuff, but then it switches to multiple processes to parse it all :D
I wouldn't have known the most efficient path if it weren't for your advice! :v
 
user559633
8:15 PM
you can probably simplify that for loop to only use one type of queue, otherwise you're shuffling through a queue that lives in one proc only to dump into one that multi procs are aware of
 
haha, that's exactly what i did!
 
user559633
especially because the GIL only let one thread enqueue/dequeue anyway
 
After realizing that anything can task_done() from a multiprocessing.queue(), I just switched everything to that
 
user559633
for single proc things, the big advantage of a queue is the ease of using timeouts etc
 
user559633
8:17 PM
haha oh god, i just realized that you're this far down the rabbithole when all you wanted to do was write some logs
 
hahaha
 
user559633
 
what the code does now is start at ~20 threads, then stops those threads and starts parsing everything from ~ 5 - 6 processes. then, those processes fill a queue
which a single thread takes and writes to a file
that is the most perfect .gif I've ever seen
 
user559633
yeah -- perfect on having a single thread handling the file. unless you're writing a huge amount or really often, that's far easier to "reason about" than semaphores
 
what is a "huge amount" ? (I'm still not that great w/ limits on .csv files and stuff)
right now it should come out to a csv file w/ about 10,000 rows
and ~100 columns
 
user559633
8:21 PM
e.g. something that will either constantly grab the GIL or hold it for a long time -- writing to a network attached storage device is such a thing
 
should I have two threads each w/ a separate file TAGTEAM-WRITING!?!?
 
user559633
you can do that and then merge them together later
 
Ah! alright, that's definitely not my case; but the tagteam idea is tantalizing
it looks like about 5gb of RAM is used up max
is there a point in creating more processes than I have cores?
 
user559633
for one of my applications, it made the most sense to start a handful of procs on a server that each use a single thread (each is polling and writing over a high-latency/unreliable link), which each log to their own APPLICATION_THREAD_N.logand then i have a separate script that just looks at the epoch seconds and writes them to application_coalesced.log
 
user559633
@AmagicalFishy depends if the procs are using 100% of their cores and how your OS handles such a thing
 
8:24 PM
that is a good idea
(they're definitely not. more processes it is!)
 
user559633
if you have 8 cores and 8 processes and each interpreter process/virtual machine is fully utilized, then it's probably not going to give you anything
 
user559633
my crystal ball says that you won't get linear gains fwiw due to task switching/interrupts
 
user559633
which is to say, 64 procs won't give you 8x performance of 8 procs
 
You have a crystal ball?
 
Ah! Alright, I'll keep it at 8. It was going pretty quickly, anyway
 
user559633
8:26 PM
yeah, i got hit in the beanbags with a baseball when i was 8 ohh you meant
 
"the beanbags"
 
i love that show
 
user559633
alright, going to surprise the girlfriend with some dinner. have a good night all
 
g'night! thanks again
 
 
2 hours later…
10:16 PM
Anyone know how to create global hotkeys for mac?
 
10:35 PM
3
Q: How is it possible to have global hotkeys in OSX?

cipricusBy "global" I mean that kind of shortcuts that I am using in Windows and that are set within and for an application but that can be used when that application is hidden or minimized (not on top). (e.g. the ones discussed here.) I see that in this article here on "OS X Mavericks: Use global keybo...

 
10:54 PM
I meant in python
@JGreenwell (ping)
 
11:09 PM
Has any1 else faced this issue? github.com/itdxer/neupy/issues/27
I can't seem to figure it through the src code: github.com/itdxer/neupy/blob/master/neupy/algorithms/…
anyone with memmap experience that could help me?
 
00:00 - 13:0013:00 - 00:00

« first day (1835 days earlier)      last day (3108 days later) »