« first day (1872 days earlier)      last day (3301 days later) » 

00:41
does anyone know off hand of any good articles about paper airplane physics (as applicable mostly to game programing ... I found one article its ok ... but meh) maybe I just need to play around with this idea until it "feels" right ... its just a dumb pet project im messing with
00:51
@AdamSmith yeah yeah, I wanted to the latter. Thank you! I guess I missed a parentheses - that was the problem.
Oh oops, I wrote yeah twice - makes me sound impatient but it was just a typo my bad
how to: from sys import stdout.write ???
01:08
@CSᵠ huh?
i just want to use write, not stdout.write
you can MAYBE do from sys.stdout import write but I doubt it.
how about from sys import stdout; write = stdout.write
sounds good
ty!
quittin' time! rhubarb
rhubarb!
 
2 hours later…
03:09
I am a brown cat
03:41
Morning all
hello kitty
04:11
@corvid any reason why brown?
04:36
cbg all
04:47
cbg
hey, Jon having a good morning I hope
05:41
Same old - same old - you?
05:58
Hi Good Morning to all,/
morning
Can anybody help me in subprocess.check_output()?
I am executing commands through subprocess.check_output().
If the command gets failed or any error then it is stopping my whole application, but i don't want that, i want even if command fails it should give some warning and continue its next instruction
Can any1 help me how to achieve that
sounds like you should be posting a question on Stack Overflow with more details ... A common problem with check_output() is that newbies don't realize it's just one among many wrappers for subprocess.Popen()which do slightly different, rather specialized things
Ok I ll post the question with more details.
thanks @tripleee
06:13
@Chirag Put it in a try block and catch the exception - see docs.python.org/2/library/… - that even names the exception that'll be raised for you...
Ok, Let me try this
Thanks @JonClements
 
2 hours later…
07:59
Hey up all
cabbage
cbg all!
hey, hey @JonClements, how's life there?
08:12
same old matey - you?
also :) actually I have just finished my personal site -- what do you think about it?
(btw I finally forced myself to watch the ninth season of DW.. so far, my opinion is pretty much the same as before: one of my favourite show is still in a terrible state)
@PeterVaro yeah... I haven't been enjoying it
@PeterVaro Interesting concept with the slider...
@JonClements some say, it is a bit confusing at first.. was it for you?
Well.. I didn't see what it was for until I started moving it, then it did take a few seconds for it to click :(
hmm.. what do you think, how could it be more obvious, what to do?
(I mean, it is clearly takes 2-3 seconds for everyone to understand what is going on)
(although I still think this kind of split-context is the best way to communicate the duality I have :P)
08:19
The few seconds doesn't matter - I'm just glad I'm not the only one that's taken that to figure it out. I like it :)
:)
@JonClements btw in february I'm going to visit my brother again (my fourth visit to london) and I will finally take The Making of Harry Potter tour!
have you tried it?
@Peter nope - something I do want to do though :)
judging by the videos and images -- it should be awesome! :)
@PeterVaro : Superb Site.. WOnderful work
Cbg ;)
@PeterVaro very nice effect :)
08:48
thank you guys!
\o @Jon! HB?
@IanClark always the same old - hb u? :p
Hah - I saw that! Yeh very well thanks, any holiday plans?
Err... not really... :(
Oh noes :( - are you taking any time off?
08:53
Well... there's no current plans to
Shame - you don't seem to ever take time off?
I sleep occasionally? :p
Yeh.. that's all you're getting!
09:48
CBG all
Cabbage!
I don’t want to buy a new mouse :(
10:10
Then don't!
Plug one's cabbage into the computer via USB.
(cabbage)
Actually OT: What do you guys make of the new type hinting?
dawns on him that the acronym for on-topic and off-topic are the same for naive, unthinking individuals
I strongly believe that type hinting is useless and I don't use it
Or maybe I misinterpreted the question
10:26
@IntrepidBrit It’s good but I doubt it’s going to be used much in Python. Combined with mypy it’s really powerful though.
I think the way PyCharm handles type inference through doc strings is much nicer, more lightweight
(and encourages one to write doc strings)
I don't like the current proposed method as I think it makes code far less readable
Yeah
On the other hand, I look forward to using it when I'm embedded in a team and need to make sure that they're utilising my code correctly when I'm long gone
It's been my biggest argument against using Python in (large) professional environments
@PeterVaro Nice. I enjoyed your sketch and prototype portfolio that it links to, too. Particularly like "Twisted Leaves". I like the split on the main site - it's a nice way to illustrate your two specialities (same goes for CV layout)
And a lovely Christmas cabbage to one and all, bugrit
bugrit @holdenweb, December again!
I'm making a class which pulls settings out of an ini file and creates class attributes for them. I can easily add a getattr method which returns None if you try to access something that doesn't exist, but how can I catch it when you try to access class.attribute.subattribute and it doesn't exist? Currently it complains that None type does not have attribute x
Yeah, been back six months now - and WHAT a six months. Hired, let go and hired again
10:54
Oof - didn't realise you'd had a rollercoaster on the employment front. All stable now?
@Oliver Well clearly if you are returning None is won't have the attributes you (ahem) attribute to it
quite
Can I catch accesses to attributes of an attribue that doesn't exist?
@JRichardSnape Just accepted an offer this morning. As to stable, it's a startup, so who knows, but it has the makings of an interesting project
How to catch that is interesting, though. It sorta seems to go against the Python "we're all adults here" philosophy @oliver
@holdenweb Ah well - interesting can trump stable sometimes.
@Oliver take a look at something like Mock for that - what's the real requirement, anyway?
10:57
I suppose exceptions with be more pythonic. I just like the easy way I can just create my class called settings and use it like

if settings.enable_this_mode:
do_things()
If you want second-level attributes to be available clearly you have to return an object with the same __getattr__()method
And third, and fourth ...
Well let's not go crazy, I was just thinking to the second level so I can implement sections in the ini file
Ah - so you want settings and subsettings sort of idea? Would you not be better with a config file?
ConfigObj is a common solution to stuff like that
Does sound like you might be re-implementing a wheel
hmmm. I'm using safeConfigParser at the moment, but bundling it in a custom class
11:01
Sounds like ConfigObj is right to me. Do I recall it wasn't being actively maintained, though?
So not re-inventing the wheel, then. Don't think ConfigObj needs a lot of maintenance, does it? Don't know whether fuzzyman still looks after it or not
Ahh no, someone's taken it on on Github. As you imply, I guess it's pretty stable
Ahh no I fixed it
I think I'm dragging from memory a conversation about Py3 compatability, but it's obviously a non-issue (i.e. ignore me)
In the 'getattr call at the top level, I return none but also create an emptysection() object at the attribute name. The emptysection class also has a 'getattr method which returns none
Take that, PEP20!
11:06
Does anyone have any xp with forcing content types to be refreshed with Django 1.8+? Looking at stackoverflow.com/questions/26464838/… they suggest using update_all_contentypes() - which no longer exists, but calling update_contenttypes() with my app_config doesn't even exist because it has no models_module ref, no idea why
11:17
@JRichardSnape thank you! :)
11:56
@oliver That should do it
@IanClark It's clearly been a while since I touched Django. Sorry
12:10
Just installing 158MB of updates on a Raspberry Pi (twiddles thumbs)
Man that must have been an OLD image
Cᴀʙʙᴀɢᴇ
do u even unicode?
Sorry?
cel
cel
12:31
Anyone familiar with memory usage debugging in multiprocessing processes?
I somehow have to figure out what is eating so much memory
but multiprocessing makes things tricky :(
Just ask the question, if anyone knows they'll answer :)
cel
cel
that was my question :D
> Anyone familiar with memory usage debugging in multiprocessing processes?
?
cel
cel
well, the first two things
:)
I am looking for clues how to do memory debugging when using multiprocessing
^ That is a question :)
cel
cel
12:35
pfft, that is not a question :p
@cel we ask people to ask their actual question, rather than "Does anyone know X?" because I might well be a world-leading expert in X but until I know your issue, I don't want to speak up.
cel
cel
@Ffisegydd, fair enough
Fizzy's statement was there somewhere on the SOPython website. Did not find it atm. :(
The main reason being that as soon as I say "I know X" then I'm engaging. If it turns out you have a 30s question then that'd be fine, but if it's actually a 2h question then I may not want/have time to help. You'd probably be fine with "Sorry but I don't have time for your 2h question" but unfortunately we've had people in the past that weren't, and would bug the world-leading expert.
13:21
Similarly, whenever anyone comes in with a Flask question, I want to say "ask again when davidism is online" but I don't want to reveal his secret identity to a possible clinger.
It makes me sad that I can't praise the prowess of my peers to random strangers :-(
I noticed something counter-intuitive (in Python 2.6.6) the other day:
cache = {}

def get_cache(x):
    ''' retrieve / update cache using `get` '''
    res = cache.get(x)
    if res is None:
        res = cache[x] = x
    return res

def in_cache(x):
    ''' retrieve / update cache using `in` '''
    if x in cache:
        return cache[x]
    else:
        res = cache[x] = x
        return res
get_cache is significantly slower than in_cache
I'd expect cache.get() to have a small function call overhead, which x in cache would not have. But I don't know if that would make it significantly worse.
There's a bit of variation depending on the ratio of cache hits / misses, but generally the get version is at least 50% slower. Here's the rest of my timing code, in case anyone wants to run it.
from timeit import Timer
from random import randint

funcs = (in_cache, get_cache)

def time_test():
    ''' Print timing stats for all the functions '''
    for func in funcs:
        fname = func.func_name
        print('\n%s\n%s' % (fname, func.__doc__))
        setup = 'from __main__ import data, ' + fname
        cmd = 'for v in data: %s(v)' % (fname,)
        r = Timer(cmd, setup).timeit(1)
        print(r)
        cache.clear()

datasize = 10000
maxdata = 100
data = [randint(1, maxdata) for i in xrange(datasize)]
It's not easy doing accurate timing tests on stuff like this since you can't do valid repetitions without clearing the cache, and clearing a dictionary is a very slow operation.
in_cache
 retrieve / update cache using `in`
0.00214853934456

get_cache
 retrieve / update cache using `get`
0.00267669397308
Yep, it's slower.
@Kevin True, but I was hoping that the function call overhead would be more than offset by the fact that it's only doing one lookup on the key instead of 2.
Your figures are similar to mine.
13:33
Did you do dis.dis and check?
@BhargavRao No, but I just had a look at the C source. :)
in performs two lookups in the C source?
Oh, I see. One for in, one for return cache[x].
I'd guess that, in general, invoking a Python method is an order of magnitude slower than invoking C code. So it doesn't surprise me that one method call is slower than two lookups.
Maybe it would be different if the lookups were O(N) and N was really big.
Exactly. FWIW, the C source for the relevant parts of the dict .get and __contains__ methods are virtually identical, from what I could see. dictobject.c
For extra credit, determine the necessary size of a list where x in my_list and my_list.index(x) take the same amount of time to execute. Assume that x appears only once, at the end of the list.
Or, wait, is that scenario isomorphic to this? They might never be equal.
It's too early for C internals -_-
@Kevin: cache.get() calls a c method of the cache object; ... in cache calls a c method of the cache object (__contains__) so the difference is most likely the name lookup
13:44
For extra extra credit, correct my extra credit challenge so it is actually solvable and interesting.
name lookup implying lookup of get?
Yeah, that's what I thought.
import timeit
d = {}
f = d.get
def a(): d.get(0)
def b(): f(0)
def c(): 0 in d
for func in (a,b,c): print timeit.timeit(func)
#result:
#0.229808841972
#0.188042389738
#0.150414332964
This seems to indicate that just doing obj.name is a big contributor
People have been known to optimize those accesses in extremis
@holdenweb Aha! Ok. This seems to be an improvement, although it's not quite as fast as `in_cache():
def get_cache_defarg(x, get=cache.get):
    ''' retrieve / update cache using defarg `get` '''
    res = get(x)
    if res is None:
        res = cache[x] = x
    return res
cache.get(x) ?
13:49
There's still a 0.03 discrepancy between b and c which I have no explanation for.
except possibly "calling a Python function is expensive even if you didn't need to use attribute access to do it"
But that makes me sad and so I will refuse to believe it.
@holdenweb It's a silly example. The real code is for a memoizing decorator, which does res = cache[x] = f(x), but I wanted to get rid of the overhead in calling f(x) to get more accurate figures on the speed difference between get and in.
Well, calling a Python function is expensive.
QED.
It would be fun if Martijn, replies to this
@BhargavRao I guess it's a reasonable comment. Or maybe it should be a brand-new question.
I don't think it would be out of character for Martijn to reply... Saying "try asking that as a new question and I'll answer it"
Mod's have the ability to move as comment. So I guess he can move it to his answer and reply to him.
14:00
I'm thinking of posting a comment: "If you write a nice question perhaps Martijn will answer it for you...". And telling him to delete his not-an-answer.
Yep, that would be better.
Oh. I just noticed that question's from March 2013.
And mmortberg has been a member for 2 months but has never asked or answered a question.
lurker :D
OP of 'variable' is local and global Python replied to my comment but not my answer, even though the latter came first. [suspicious_fry.gif]
And none of the answers I posted today have gotten any votes or comments. Maybe I'm hellbanned, or am a ghost without knowing a la Sixth Sense.
And for some reason comments made by ghosts are readable but not answers.
None of you need to make the obligatory "does anybody hear the wind blowing" joke.
Actually, if you all remained silent for the next thirty minutes or so, that would be a pretty good spin.
14:24
I haven't even bothered answering any Python questions today. But I got 35 points for a simple trig / geometry Q on SE.Mathematics. And I scored rather well yesterday on this Python Q about hashing function objects, but I think some of those points were mainly spill-over due to the question being popular.
I've not found time to answer since 26th
I haven't been able to answer in almost 24 hours.
I can only answer in the morning because my contempt for humanity rises with the sun.
My last answer was that type-hints in python3.5 which I discussed with DSM.
I may or may not have thought "you are not worthy of receiving my help, lowly worm" in the last three days.
14:29
@BhargavRao Looks like you're up for a 500 point bounty "present" soon, though - stackoverflow.com/questions/30109030/how-does-strlist-work
OP of Tokeniser integers in a string is playing games with me. His post says his sample input has commas, but his comment says there are no commas.
Quelle surprise, my answer answers the question you asked, not the question you meant to ask.
@JRichardSnape Yep. Thanks to Madara.
(P.s. see the second answer there) :D
OP of 'variable' is local and global Python is aware of his indentation problems but apparently can't be bothered to correct them.
Why can't OPs be like me and feel a hot wash of shame whenever they make the slightest error, and scramble to fix it ASAP?
@Kevin It'd be better if you give the OP the link to ast docs. He might get a clue or two
@BhargavRao I saw it. Impressive work on your part
14:32
I love a good hot wash of shame.
@JRichardSnape Thanks. :)
@BhargavRao True that. linking imminent.
Discovered something nice in Python3.5. (Winter bash question ready :P )
@Kevin And what the yam does he mean by "If I load if the file without reading it"? Presumably, the 2nd "if" should be "in", but still...
@BhargavRao Strategic. Rouse interest early
@PM2Ring Translation "when coding, I shut my eyes and hope for the best"
14:42
@JRichardSnape Hehe. Few string methods are 60 times faster in Python3.5 compared to Python3.4. :D
But yeah. I need to do a bit research on them
@PM2Ring I interpreted that as "if I try literal_eval(my_file)..."
Which would indeed produce that error AFAIK
Lol, the latest question. I have a stack gimme the queue
Dear Python devs, please change literal_eval's error message to something sensible like "expected a string, got a {actual type of argument} instead" rather than ValueError: malformed string
Programming tip of the day: __int__ is a method and it is not the same as __init__
@Kevin Ah, of course.
@Kevin That would be helpful.
14:48
Prime generator in python is funny to me because OP complains that his prime generator never produces 15 or 33.
Extra comedy: it does produce both of those numbers.
But only in 3.X, peculiarly.
Oh, it's probably because filter works differently.
Yep in 2.7 it attempts to exhaust an infinite iterator and hangs
Aargh, OP of 'variable' is local and global Python "one more thing"'d me
@Kevin They gave you an iPhone?
I wish.
cbg all!
Why would you ever wish to get an iPhone -_-
hides
Because it is an iPhone.
14:54
So I can sell it :-)
If I ever get into the mobile apps biz, I'll need one.
user559633
iOS is still the best phone os :)
howdy!
I kind of want to try the mobile app stuff on the side.
@idjaw Morning!
:) hey! what's the good word today
15:00
@tristan the game of which linux derivative is the best? :p
user559633
@Programmer debian for that one:)
@Kevin Here's a Python 2 version:
def sequence(n):
    i = 1
    while True:
        i += 2
        yield i
        if i > n:
            break

def prime_generator(n):
    i = 2
    it = sequence(n)
    while i < n:
        yield i
        it = iter(filter(lambda x, i=i: x % i, it))
        i = next(it)

for j, i in enumerate(prime_generator(100), 1):
    print(j, i)
Yep, looks good to me.
And that default arg trick should be familiar to anyone who's written callbacks.
Yep :-)
15:07
@PM2Ring I have used "callbacks", but not in Python :/ I don't get it. Can haz explanation?
It takes i from the outer lexical scope?
It's a solution to a common "gotcha". Guess the output of this code:
functions = []
for i in range(10):
    functions.append(lambda: i**2)
print functions[3]()
3 squared should be 9, yes? Surprise! The output is 81.
The key point is that default arg assignment happens when the function is defined, so it's a handy way to create a static value in a Python function.
user559633
@Kevin Wrong. The output is SyntaxError: Missing parentheses in call to 'print'
Ooooh, so that's the same in JS. I should have guessed that! :)
user559633
15:10
( ͡~ ͜ʖ ͡°)
<)   )╯i am an insufferable human
 /    \
haha
INDIA: concerns over potential flooding as up to 500mm of rain may fall in next few days in areas around Chennai. PA https://t.co/ymEC4Elyuc
user559633
Cuddladore :3 best pokeman
Jeez. :/ Didn't you just git hit recently too?
Stay safe, Chennaians.
15:12
RemcoGerlich's answer to that prime generator question uses a closure to create the static var, but I prefer the default arg method. It's more compact, is flatter, and in my tests it tends to run faster.
user559633
Chennaise. Chennaikans. Chennaizens
Gesundheit
Gee, 4theye, I'm amazed you guys haven't been washed away by now.
@thefourtheye The map looks horrifying
15:14
What is worrying is, the death rate is still high :(
@thefourtheye :((
Hmmm, Avinash Raj is also from that coast. Hope he's safe. :)
If all I'm doing is using a class as a dumb data store, is it more efficient to use a namedtuple? Does it matter?
Without running any tests, I expect the answers to be "yes" and "no"
That's pretty much what I figured.
user559633
15:24
@MorganThrapp I mean, there's a deepquoted starred message in the archive of this room suggesting profiling, but namedtuples and slots can be assumed to give performance bumps for long-lived objects with xx,xxx namespace lookups or for many small objects
A namedtuple uses __slots__ instead of a __dict__ for its attributes, so it's much more conservative of RAM.
stackoverflow.com/review/first-posts/10402149 @MartijnPieters your answer was used an audit :P
user559633
Margin Peters
The question has no votes and the answer has 15. Only margin can do such stuff. :D
I was going to have an early night... Oh well. :) Time to go & read some more Discworld.
Rʜᴜʙᴀʀʙ
15:32
Rbrb PM.
Optional parameters in python are basically just a dict of values, right?
or a tuple of values
I am afraid to answer that question on account of what you'll do with the knowledge.
I worry the follow-up will be "ok, now how do I access that dict, if all I have is the function object?"
I don't know if it's possible but if it is, it is Deep Magic
Are "immutable dicts" just tuples, though?
15:34
Well, I guess it's possible
an immutable dict would have better lookup times than a tuple of tuples.
>>> def f(x=23): print x
...
>>> print f.func_defaults
(23,)
Real deep magic there, Past Me.
user559633
you could go up the stack and grab those values, even without func defaults
Hard mode: using that and f.func_code.co_varnames, construct a dict containing only names and values of variables with defaults.
user559633
harder mode: ^ but with python 3
Doesn't inspect module do this for you?
15:40
>>> def f(x=23): print(x)

>>> import inspect
>>> inspect.getargspec(f)
ArgSpec(args=['x'], varargs=None, keywords=None, defaults=(23,))
Harder-than-it-looks mode?
inspect.signature(f).parameters # OrderedDict([('x', <Parameter "x=23">)])
>>> def f(a,b, x=23, y=42, **kargs): pass
...
>>> dict(zip(reversed(inspect.getargspec(f).args), reversed(inspect.getargspec(f).defaults)))
{'y': 42, 'x': 23}
Oh, vaultah beat me to it.
@SterlingArcher How did you manage to pass that audit? Of course my post needs some kind of corrective action! :-D
Hehe, @Martijn Take a look at this when you are free.
:D
15:45
@MartijnPieters well it helps that I remembered you wrote the answer lol
@BhargavRao meh, they could just google that. lxml docs do tell you there is a .parent reference..
I've seen it before somewhere
It's been used in audits 4 times so far, everyone has miraculously passed.
It's pretty easy to spot an audit when the answer is well detailed lol
omg it's margin peter
15:48
@corvid You’re off by a small martijn there.
3
@Martijn it would be kind of cool if you were in some way responsible for catching robo-reviewers without actually going out to find them.... your vast quantity of answers serve that purpose for you while you go sock puppet hunting :p
Hi Jon <3
cabbage
cbg davidism
morning Davidism
15:59
Bleh, I hate writing regex. :(
Regex: Easier than writing code.

« first day (1872 days earlier)      last day (3301 days later) »