« first day (1564 days earlier)      last day (3387 days later) » 

12:01 PM
I wouldnt use php for one :D
Any objects that are intended for use in the multi-threaded parts of your application should extend Threaded.
:D:D:D:D:D
 
12:18 PM
@Ffisegydd poor everyone in UK
 
hello
 
hello
 
what is this word "hello!"?
 
Hello is a leafy green or purple edible biennial plant.
 
Who has a few million quid to lend me to buy some land and build a house? zoopla.co.uk/for-sale/details/32039651#GvfBdj4ZYPD8eKVP.97 :)
 
12:23 PM
never seen a hello grow back on the second year in Finland...
 
12:37 PM
Should I use py.test or unittest?
Umm, it was opinion-based, nvm
 
The thing about not needing __init__.py in Python 3.x (so if foo doesn't have __init__.py, then foo.bar etc also don't need it to be loaded as modules) - does that mean that if I use __init__.py anywhere, I still have to use it everywhere?
 
yaaaahahah
is there isplitlines
 
12:54 PM
Does anyone know of a float hash collision in Python 3?
 
In [19]: hash(-1.0)
Out[19]: -2

In [20]: hash(-2.0)
Out[20]: -2
:P
 
Well, that was easy :-)
 
If hash returns -1 then it means something seriously messed up has occurred, and typically the numbers return themselves, so by default hash(-1) returns -2
 
def hash(obj): return 4 - even easier :p
 
12:58 PM
In fact! Look at this.
class Hasher(object):
    def __hash__(self):
        return -1

h = Hasher()
print(hash(h)) # -2
 
Meanwhile in Finland... #BlizzardOf2015 http://t.co/CsZZl9DXpw
 
That was taught to me by a ninja.
 
What? Why is it -2?
 
never seen any ninja
 
Ok, that's actually a very cool thing to know, but I was looking for a "genuine" collision caused by the algorithm - along the lines of (0.739564, 3.678e55) or whatever.
 
1:00 PM
@Robert because magic.
"Genuine"!? "GENUINE"!? D:
 
You know what I mean :-P
 
There is far too much magic going on in this explicit is better than implicit language
 
s/genuine/accidental/
 
>>> hash( 2 ** 64)
1
 
Surely all collisions are accidental?
 
1:01 PM
@AnttiHaapala Because if you did see the ninja - they're obviously not a very good ninja are they? :p
 
>>> hash(2 ** 64) == hash(1)
 
goes off muttering to ask SO why Python has self on every class function
That's weird, they closed it.
 
Well, calling a collision caused by special-casing -1.0 accidental strikes me as analogous to "I'm going to walk forward windmilling my arms, and if you get punched it'll be an accident" ...
 
Just iterate through all possible floats twice and compare. Easy.
 
When I said class, I possibly meant object
 
1:04 PM
Of course!
 
@Ffisegydd maybe use a hash table to store the results, for fast lookups
 
@Robert naaaah. O(N**2) is fine.
 
a curiosity:
>>> class x():
...     def __hash__(self):
...         return -1
...
>>> hash(x())
-2
 
21
A: Why do -1 and -2 both hash to -2 in Python?

andrew cookeUpdate - i think this now a wiki, please feel free to add more info. -1 is a reserved value at the C level (of CPython - see comments from DSM about this being "as expected" in ironpython and pypy) . See this Quora answer: If you write a type in a C extension module and provide a tp_hash ...

 
1:07 PM
@AnttiHaapala That's what @Ffisegydd said?
 
no, he didnt
anw:
>>> {float('nan'): True}
{nan: True}
 
I'm just confident enough to be pretty sure he did :) he just wrapped the hash in a print. Or if not, what's the difference?
 
I always liked
d = {float('nan'):1, float('nan'):2, float('nan'):3, float('nan'):4}

print(d) # {nan: 1, nan: 2, nan: 3, nan: 4}
 
>>> dct = {float('nan'): True}
>>> print(dct[float('nan')])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: nan
@RobertGrant No he didn't. I'm sorry, is this a five minute argument, or the full half hour?
 
I'd like to pay for Robert to have a 12 hour argument please.
 
1:12 PM
cbg
@Ffisegydd My brain is melting.
 
@AnttiHaapala depends on how soon you explain how it's different, instead of just contradicting :)
 
Guess I'll stick with dicts then ... in case anyone is wondering, I would like two sets with identical float values but different iteration order.
... but dicts will do, if that's all I can get.
 
registers fakekickstarter.com
 
1:16 PM
hi everyone
 
Bah... no one's appreciating my generator function... I think it's quite nifty (and remarkably simple) sighs
 
i have got a question: if i yield something, but after an if-else-check, the element can't be treated, is this element still in the list ? So will it be yielded another time?
 
@MarkF6 nope - once it's yielded it's yielded
 
hm, ok. in this case, i have a question. (i will copy my code snipped)
 
@MarkF6 if it's long, please use dpaste or put it in a gist
 
1:20 PM
no it's not
have a look:
while True:
            yield self.env.timeout(10)
            if self.is_ontime:
                toy = yield self.orders.get()
                elf = self.best_candidate()
                while len(self.orders.items) >= 0 and elf is not None and self.is_san(toy.build_duration):
                    self.start_work(elf.id)
the problem is the yield of "toy".
but i need this to know the duration-time
(self.is_san)
if this element can't be treated, is it possible to re-add it?
 
Are you trying to make some sort of task queue with retries or something?
 
So you want to continuously go throug...yeah
Can't you put the if-logic in the self.orders.get()?
 
Added a new Q to canon list sopython.com/canon/65/…
 
yes. but i mean, i yield the element before the "while". But if the "while" is not True, the element is not treated and removed. But every element should be treated.
hm i have to see..
 
I suppose...yeah you need to build duration from the toy
Maybe if it makes sense to put that check inside the get then it's solved; otherwise someone cleverer than I will have to take over
 
1:27 PM
that does not really make sense, surely you know what value = yield expression does?
it is the value sent from the outside running the generator, or None if you just next()
 
thanks for random upvotes? :p
 
@Ffisegydd the accepted answer is missing half
it does not say about apply, and it does not say that you can pass in args that are not legal names as **kw and into **kw...
 
Umm... not sure this was completely well received, but oh well
 
also the question is not good, they are not method calls but declarations/definitions
 
If you can find an alternative then replace it :)
 
1:33 PM
209
Q: What does the Star operator mean in Python?

psihodelia Possible Duplicate: What does *args and **kwargs mean? What does the * operator mean in Python, such as in code like zip(*x) or f(**k)? How is it handled internally in the interpreter? Does it affect performance at all? Is it fast or slow? When is it useful and when is it not? Sh...

this one obviously :d
and open this q and close the other a duplicate of this :d
the first answer there is way better than the first in the other
 
yeah, but the title on the dupe is better
If we could find one that also includes the def(a, b, *, **kwargs) syntax... even better
 
the canonical target is
377
Q: What does ** (double star) and * (star) do for Python parameters?

ToddIn the following method calls, what does the * and ** do for param2? def foo(param1, *param2): def bar(param1, **param2):

and actually you cannot find * or ** with the matching
so it is pretty pointless, the dupe is found only if you know to call them star and double star
that is * and ** are not matched at all when asking a new question
neither for google
 
welcome @soField
 
_pickle.PicklingError: Can't pickle <function FilterClient.run.<locals>.<lambda> at 0x7ff306e0fea0>: attribute lookup <lambda> on filterdriver failed
:(
cant use pool map, sucks
because stupid python cant pickle lambdas :D
so how do i do it?
guess self is picklable
 
1:50 PM
@AnttiHaapala I asked this like a day ago...
 
everything picklable must be declared at module level
applies to multiprocessing etc. sucks.
 
not really, what you want to say is that everything picklable by default is in the module level
What are you using lambda for?
 
Cabbage!
 
Cbg
 
@poke cbg
 
1:58 PM
@ReutSharabani would have used for partial application
lambda foo: self.call_func(foo, bar, baz, frob)
to multiprocessing.map
 
so you're trying to pack lambdas and instance methods? :) good luck! (you're going to have a bad time)
 
instance methods do work
 
really? that's interesting, they're not picklable by default afaik
 
bc it is class.method(self, foo, bar, baz, frob)
 
Oh, so they're class methods, not instance methods
 
2:00 PM
and the instance is picklable by the virtue "copy the attrs"
no, instance method
and python 3.4
or it is some trickery by multiprocessing.
 
if they werent things would be quite bad indeed
 
just try using an instance method with a Pool object and check
It didn't work for me a while ago
 
hmhm
TypeError: can't pickle instancemethod objects
haha :P
wokrs in py3
 
Everything works in py3. Py3 is where dreams come true and everyone is in a perpetual state of bliss.
 
user559633
2:04 PM
Python 3 is the Ruby of Python
 
>>> import pickle
>>> class Foo():
...     def bar(self):
...         print(self.baz)
...
>>> f = Foo()
>>> f.baz = 42
>>> f.bar()
42
>>> pick = pickle.dumps(f.bar)
>>> pickle.loads(pick)()
42
 
behold
 
user559633
just randomly apply spacing
 
yet another reason to kill python2
lets indent it as wrong as possibly
 
2:04 PM
I'm down to my last two tea bags and shopping doesn't arrive until tomorrow - this makes Puppy feel sad :*(
 
@JonClements recycling time :)
 
can we start a wiki on
 
user559633
i'm mildly embarrassed to live in new york right now, given that a few centimeters of snow resulted in a declaration of a state of emergency
 
"what things are better on the other side of the fence?"
 
@tristan we get a millimetre of snow and the whole country gets ground to a halt... a few centimetres and the whole country would be in a state of war
 
2:07 PM
we get a millimetre of snow and the whole country gets ground to a halt... a few centimetres and the whole country would be in a state of war (after the snow has finally melted) - FIFY
 
user559633
@AnttiHaapala yeah, i recently got back from russia where the snow was 2 meters tall and the salt water was frozen. in new york, it gets a bit dusted and the subway gets shut down and you can get arrested for being outside after midnight
 
user559633
@JonClements oof, i'm afraid that papa america and baby england are both going to shite together
 
@JonClements I don't remember that :)
@tristan my politics may be off, or based on the Chernobyl Diaries, but possibly those things are also the case in Russia all the time :)
 
user559633
russia: it's like a snow globe, but the flurries are bits of radiated pollution and if you shake it too much they send you a secret prison
 
Idea for a Russian horror film: Ghoulag
2
 
2:14 PM
btw about that access tokens in the post:
66
Q: Should revisions that contain credentials be deleted?

FlexoWe see quite a lot of flags like: Revision 1 contained real credentials Up to now I've handled these by forwarding them to community managers or developers who have the power to permanently banish revisions from the database. To be frank this strikes me as a significant waste of effort inv...

-> my flag was declined
 
user559633
@RobertGrant that's f-ing brilliant
 
I do think that it's the turn of the ghoul to be overused in popular horror
Except whoever goes first has to have the bit in their movie where they look up what a ghoul is and explain it to the audience, so possibly being the second or third movie is better
 
My money is on blob monsters. They're pretty self-explanatory, so you can skip some exposition there.
 
user559633
you see, it's like a zombie, but not a comment on consumerism and it eats already dead bodies
 
user559633
holy shit, ghouls are the anti-zombie
 
2:21 PM
Plus, blob monster romance isn't totally out of the question, so you can get a piece of the Twilight demographic.
 
umm... I don't want upvotes... but can someone suggested a good name for the function in this answer I've changed it from take_until to drop_after, but neither seemed right
 
@Kevin are speaking blob monsters called clob monsters?
 
user559633
i don't know why i'm just processing that now. ghouls attack and eat dead bodies; zombies are dead, which means Ghouls v Zombies is both canon and made for market
 
and take_until_and_including is just yuck
 
Yes, and blob monsters that leave a mess behind are called slob monsters.
 
user559633
2:22 PM
up_to @JonClements?
 
@Kevin you maybe want to have exactly the same plot, except the girl is now a blob monster. This would allow yet more female fans to transpose themselves into an even more shell-like character
 
user559633
stop_before?
 
@JonClements take_through or take_through_to
 
does json.load try to slurp the whole file?!?!?
 
user559633
@AnttiHaapala yes
 
2:23 PM
sucks
 
And since it's already an Americanism, why no take_thru
 
user559633
slurps
 
I am trying json.load over ssh and from sys.stdin
 
user559633
no no no, do not encourage 'thru'
 
ofc the closing does not work over ssh
 
2:24 PM
Ummm.... takewhile_including ?
 
takewhile???
it should be take until not :D
 
take_until_and_one_more_past_that
 
Or takeuntil_not could work
 
ah no :D
 
I've spent more time trying to work out a decent name than it actually took to the write the yamming thing
 
2:25 PM
not so good either
 
Big Brother @Kevin Got thy holy gold?
 
Not yet :-)
 
user559633
lazy google: is there a simple way to make a jinja macro that supports label and title attributes
 
0 results found for: jinja. Thank you for using the Kevin knowledge engine.
 
writing :
 
2:26 PM
@Kevin That's sad :-( .... The parenthesis should be the other way round
 
def takewhile(predicate, iterable):
    # takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4
    for x in iterable:
        if predicate(x):
            yield x
        else:
            break
is takewhile
your func would be
 
@BhargavRao All in good time :-)
 
Tomorrow perhaps .... All the best
 
@tristan and then I guess zombies attack ghouls because ghouls keep trying to eat them. Makes sense!
writes a schlocky horror book
 
user559633
well, zombies have to attack people to bring up their armies
 
2:27 PM
def take_while_and_yet_once_more_after_explicitly_forbidden(predicate, iterable):
     for x in iterable:
          yield x
          if predicate(x):
              break
 
user559633
and ghouls don't attack humans
 
user559633
and for the zombies to scheme, they'd already have to be the smart kind of zombie that can plan, so that makes them cinema-ready for a love story
 
user559633
we're basically writing the plot for Twilight: Whatever-Number-It-Is-At-Plus-1
 
A star-crossed zombie-ghoul romance, where the ghoul keeps eating the zombie and the zombie is oblivious because it's dead
 
@AnttiHaapala I did have the following drafted:
def take_until(predicate, iterable):
    if not callable(predicate):
        predicate = lambda L: L == predicate
    for it in iterable:
        yield it
        if predicate(it):
            return
 
user559633
2:33 PM
@RobertGrant sounds like my first marriage
 
@AnttiHaapala but then you can also add a kwarg arg for a default function instead of eq blah blah blah... then build a lot of functions around it... oh what fun
 
and then you should write it in C
so isnt it better to do a delay function
delay_false(foo, 1)
it would be more generic
 
@tristan oh dear :(
 
user559633
(ha ha not really, i've yet to trick someone into a legal arrangement with me)
 
First they have to legalise marriage to... that
 
user559633
2:38 PM
all love is equal, even to obligate cannibals
 
That's quite a mouthful
 
user559633
fine young cannibals. that's what the ghouls v. zombies love story will be named
 
s/yo/h/ for the porn spinoff
 
Re-cbg
 
user559633
cbg vaultah
 
2:41 PM
def delay_false_by(predicate, n=1):
     counting = None
     def pred(x):
          nonlocal counting
          if not pred(x):
              if counting is None:
                  counting = n
         if counting is None:
             return True
         counting -= 1
         return bool(counting > 0)
    return pred
 
Vampires are also dead, so that's another twist at the end of one of the movies
 
@JonClements ^
 
Final pan away from peace treaty after decades-long accidental war between ghouls and zombies, to the Jar-Jar ghoul accidentally eating a vampire
 
user559633
O_____O chills
 
It's so bad I actually want to write it
To the sopython wiki!
 
user559633
2:43 PM
*** you have been banned from sopython ***
 
user559633
brb switching computers
 
downloads sopython source code; registers soapathon.com
 
user559633
toopython
 
Damnit! Knew we shouldn't have made it OSS!
 
user559633
just go the microsoft model and bribe one of us into claiming that sopython contains something proprietary
 
2:46 PM
I thought that was SCO
 
user559633
microsoft funded SCO and gave money to red hat to push the case along
 
Oh, okay :)
 
darn it: Sorry, python.so is not available :)
 
I've decided to thank you all in my thesis Acknowledgements :3
 
anyway, jacket potatoes, with chilli and grated cheese for a late lunch, rbrb for a bit
 
user559633
2:54 PM
@Ffisegydd haha, did i get referenced as tristan or mtfl or not at all?
 
I haven't actually written it yet. But I'll put you top of the list!
 
@Ffisegydd so your ack. section is now "Here's thanks to some very strange people I've never met, but they seemed to welcome me to their cult group"?
 
@Ffisegydd "And special thanks to Devastator, john27 and SirHumpalot on the internet"
 
I need to sneak some form of "cabbage" into it.
Maybe a closing quote like "So long and thanks for all the cabbage"
 
user559633
awww :) thanks @Ffisegydd
 
user559633
2:56 PM
maybe an acrostic?
 
@Ffisegydd does this mean I need to tell you my real name?
 
user559633
when i strike it big with my own company, i'm going to buy everyone in the room a curry
 
@JohanLarsson cbg
 
When you strike it big you're going to give me a job, and if you could strike it big in 2 months or so that'd be great.
 
@tristan that sounds awesome. Hope it'll survive the journey!
 
2:58 PM
Hello (I don't speak Python)
 
@JohanLarsson then this may help :)
 
user559633
@Ffisegydd actually yeah. I have a lot of ML needs
 
"Man Love"?
 
@RobertGrant I'm a somewhat regular lurker here though.
 
user559633
3:00 PM
That's obviously what I meant.
 
why is my subprocess.Popen process a zombie :(
 
user559633
@AnttiHaapala is it an async task? (without communication back over a pipe?)
 
AND what about the ghouls invading Middle Earth and being vanguished by Zom Bombadil
This thing has legs, people. Wasted, shuffling legs.
 
pipe
p = subprocess.Popen([ driver, cfile ] + run_info.files,
    stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
from multiprocessing process,
ahh I see
maybe it was stderr all over
since I am reading just stdout
 
I'd better be off
Rbrb
 
user559633
3:03 PM
take care
 
Bleh. 164 pages.
 
It is unclear even from the pseudocode what the OP is trying to do.
 
@tristan loool :d
I had forgotten status prints that go to stderr :d
 
The edit is still unclear
This question is fundamentally important, however... The question is specific! — zell 24 secs ago
 
I sometimes forget that RO's can see (removed) messages :p
 
3:16 PM
hi everyone
 
wb @MarkF6 :)
 
i've got a question: how can I sort entries in a csv-file using pandas? The sorting is a bit complicated. Let me explain...
 
user559633
hey markf6
 
The csv file looks like this:
 
user559633
have you tried help(df.sort) to look at your options @MarkF6?
 
3:19 PM
1,2014 1 1 0 1,5
2,2014 1 1 0 1,5
3,2014 1 1 0 1,5
4,2014 1 1 0 1,6
5,2014 1 1 0 1,6
6,2014 1 1 0 1,12
7,2014 1 1 0 1,17
8,2014 5 7 1 5,4
the first column: ID
second: date and time
third: duration
I'd like to sort the entries according to their "arrival_date" + duration
how is this possible?
 
why oh why do i get zombies
 
f.ex. the last entry is: 7 of may, 1:05 am
 
user559633
because the calling process has ended without being waited on @AnttiHaapala
 
user559633
and if it's not writing to a tty, then the calling shell has no reason to assume the procs
 
but doesnt subprocess wait...
Popen
 
3:22 PM
@Mark have you actually managed to get it into a DataFrame yet?
 
I mean my python code forks ncpu times
 
yes, one moment
 
and reads input until it is closed
 
If this was regular python and not pandas, I'd suggest rows.sort(key=lambda row: insert_expression_that_calculates_timestamp_of_arrival_date_plus_duration)
 
user559633
@AnttiHaapala subprocess won't wait on the procs if the task goes async, returns an exit code, or if it's not communicating directly back to the calling process
 
3:23 PM
... But I have no idea how dataframes work, so I won't suggest that
 
def convert_data(csv_path):
    store = pd.HDFStore(data_file)
    print('Loading CSV File')
    df = pd.DataFrame.from_csv(csv_path)
    print('CSV File Loaded, Converting Dates/Times')
    df['Arrival_time'] = map(convert_time, df['Arrival_time'])
    df['Rel_Arrival_time'] = (df['Arrival_time'] - T_REFERENCE.timestamp)/60.0
    print('Conversion Complete')
    store['toy_orders'] = df
 
@tristan must be the case of our queue stalling
mhmh
need to debug later
rbrb
 
my question is: how can I insert the sorting?
 
half serious answer: convert back to ordinary list, sort as I described above, convert into dataframe again
 
@MarkF6 honestly you could find this easily using Google.
 
3:30 PM
hm i spent more than 30min, didn't find anything :(
 
Try something like "pandas sort by column values"
And you'll probably get something like pandas.DataFrame.sort.
 
user559633
and then try "pandas cute bamboo" and then maybe "baby panda sneeze"
 
I have an unpopular opinion. I think pandas deserve to go extinct and the world will be better off without them. If your entire species is too disinterested in mating to keep a stable population, you are collectively a failure of natural selection.
 
okay... think I put a slight bit too much chilli in that one
either that, or I've suddenly decided to start crying, have a runny nose, my throat has decided to burn and my stomach is trying to digest itself...
 
user559633
@Kevin I actually agree. It's fighting natural order to support and encourage obvious failures of evolution and creating artificial selection in those best adapted to survive in a false environment
 
3:38 PM
@Kevin I guess you've been watching: youtube.com/watch?v=LZJ-_OTvsqo
 
devil's advocate: they were plenty interested in mating before we deforested their habitat and placed all of them in small dingy replicas of their original glorious homeland.
 
(panda part is in the last bit)
 
Scumbag humanity:
eradicate species' ecological niche;
"this species has no place in the world, better eradicate them"
 
user559633
@Kevin to lean into that: cats still mate even though now their natural habitat is sleeping on top of a computer keyboard.
 
Hacking the cuteness instinct of humans is their new niche :-)
 
3:42 PM
anyways... cup of tea, put something on netflix for a bit, maybe fall asleep on the couch... rbrb for now
 
Hmm, I guess that applies equally well to cats and pandas, actually. But pandas are less fit because you can't keep one in your house.
 
oh, on a side note - looks like a win for me:
0
A: Remove all elements from a list after a particular value

Anton ZuenkoWell, I was interested how fast each solution is. Here is the code and estimations: setup = """ from itertools import takewhile, dropwhile def dropwhile_v1(iterable, sentinel): return reversed(list(dropwhile(lambda x: x != sentinel, reversed(iterable)))) def dropwhile_v2(iterable, sentinel...

ahhh... not a fair test though...
 
user559633
i can't wait for systemd to get rejected so that my linux install will have systemd, upstart, init, and {{new alternative}} all running
 
@tristan you evil
 
user559633
thanks linux community for encouraging jack-assery by people writing a desktop environment that everyone hates
 
3:53 PM
upstart and init are just thin wrappers to systemd calls now
 
user559633
f-ing redhat
 
distros just leave them in so that people won't get confused immediately
you could always switch to gentoo, they have their own init system
 
user559633
lol gentoo
 
user559633
i'm more likely to switch back to freebsd
 
Hmm, I wonder why MarkF6 registered a new account to ask this question
 
3:56 PM
@Kevin what are you talking about? That's Stan not Mark. Totally different.
 
I guess it's just a big coincidence that their data looks similar ;-)
 
Conspiracy theory: it's two people in the same office looking to boost each other's rep.
 
re-cbg
 

« first day (1564 days earlier)      last day (3387 days later) »