« first day (1587 days earlier)      last day (3364 days later) » 

12:00 AM
CBG
 
12:19 AM
2
Q: Killing Thread and releasing memory in Python

Andrew FountI'm killing thread like shown here: Is there any way to kill a Thread in Python? But I noticed, that memory is not released (gc.get_objects() keeps growing and growing). In fact these objects are lists, dicts etc., not files. Id there any way to manually release resources?

maybe cv? I dunno at this point ...
 
1:02 AM
ug im grumpy ... user questions seem extra aweful today .... im going home
 
 
2 hours later…
2:44 AM
@AnttiHaapala I have heard a similar one. A mathematician was attending an interview. The interviewer asked him, if he finds a building on fire on his way to work, what he would do. He thought for a while and said, I would call the fire station and ambulance and use water to contain the fire. The interviewer was satisfied but he just wanted to test him again and asked, what if the building is not on fire. The mathematician thought for a while and said he would said the building on fire.
The interviewer, in shock, asked why, why would you do that?

The mathematician said, now I reduced the problem to another problem for which I know the solution already :D :D :D
 
3:46 AM
Sometimes it's impossible not to feel slightly dirty even when you're only trying to educate ...
 
DSM
4:20 AM
Late-night cabbage for all.
 
cbg @DSM (although it'll be rbrb very soon for me)
 
DSM
Wish I could say the same. We're giving a presentation Friday at 9:00 AM which needs to be reviewed tomorrow afternoon, which means everything needs to be done tomorrow morning, and there's about two days' worth of work left. So it's going to be a long night. :-/
 
Oof. Have fun with that then ...
 
4:41 AM
cbg
 
 
2 hours later…
6:38 AM
CBG ALL
 
@d-coder Cabbage.
 
@thefourtheye nice (though s/said/set/)
 
I need to convert .doc file to .docx file
any ideas ?
 
use word
that is a problem even microsoft can't do properly
 
@AnttiHaapala ??? saids should be replaced with set?
 
6:40 AM
using Python
 
@thefourtheye set on fire = start a fire
 
:D
 
Oopsie :D
 
kind of critical mistake when it occurs near the punchline
 
I am using docx module to read .docx so I need to convert .doc to .docx
 
6:42 AM
you know, converting doc to docx aint gonna be easy with python
as I said even microsoft can't do it properly
your best bet would be to drive ms word or (libre|open)office through some kind of automation
 
I have looked into that. Changing just the file extension will do no good
 
anyway I am pretty sure that everyone would say the same with me
 
Okay.
 
no one here has certainly not tried to convert doc to docx, in python, while retaining formatting or tables or anything such
 
Any modules to read .doc files ? I need to do some parsing and text extraction on .doc
 
6:46 AM
there is POI for java and apache that sort of comes close to supporting a reasonable subset of features of both and sort of supporting the conversion
@d-coder that could be an easier one
if you're on linux there is already some commands that can render a doc into plaintext on command line
other than that I am not aware of which is decent, so I suggest google again
find something that supports python 3 too, if it doesn't it is a dead end :d
 
Windows 7
What is pyuno BTW ?
 
dunno
ah
for apache openoffice
automation
it can do the thing with openoffice
 
Not with MS Word ?
 
no
msword you need to use ole automation
 
win32com
 
I might have some luck with that ?
 
yeah
definitely more than any of the doc and docx readers
in any case writing a doc / docx is easy, not reading and understanding
 
I see
 
7:05 AM
say, you have a phrase book of foreign language
with it, it is very easy to "speak" the language, so that all the output you give are proper in that language, but when listening, then the ppl can say whatever not in the book
 
7:44 AM
I am ROTFLING
 
@AnttiHaapala Did you see the best part? Click on the image :)
 
ahhahaaaa :D
 
8:16 AM
hmm damnit
with open(logfile) as f:
I have this kind of code...
now the problem ofc is that .. logfile might be an open file
I guess I need to wrap the whole stuff in a function
that is if isinstance(logfile, str): with open() as f: doit(f); else doit(logfile)
 
8:49 AM
cbg
 
9:10 AM
Cbg :)
 
heh, I like how my C quip is still in the favourites list
 
mm?
I cant see
since I have a small display
 
I have a small display too, only 1920x1080
 
"that's why C is so great, the precision with which you can shoot yourself in the foot is unmatched"
I beg to disagree
indeed the precision is not great.
 
9:21 AM
C is great; the precision is unmatched. what's the problem?
:D
 
yes, but once the aim point settles on the head, the ballistic deviation is 0
 
instead you aim at your left feet but because of rule X you will hit undefined behavior and the gun shoots yourself in head instead (which of course is legal c)
nope, that is not the C I know
 
9:25 AM
re-cbg
 
@AnttiHaapala, I'll split hairs on this later, only on my first espresso
 
:D
maybe I should need another coffee too
and cbg.seek(0); s = cbg.read(); print(s, file=fizzygood)
 
I like the file kwargs to print so much
 
it is definitely better than some fun part to print statement
>>> print 42, a
42
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'a' is not defined
like, wtf?
same for print >> sys.stdout, 42, a
damnit removed the question that I was answering
 
9:40 AM
is the orderer of closing a file is important?
 
what do you mean?
 
that is closing the file reader object before closing the file writer object.
 
DSM
Most of the way through an all-nighter cabbage for all.
 
cbg
@AvinashRaj Nope. as long you don't try to performs actions on the file (read/write) after you've closed it.
for performance reasons it might be smart to explicitely close all file readers ASAP
 
9:47 AM
@DSM Oh gawd.... I feel for ya - at least my last couple of days haven't been like that :)
 
@Martijn cbg
@puredevotion Yup - a good rule of thumb is to release any resource acquired as soon as you're done...
 
@JonClements ah, so people noticed. :-P
I had to trim that list as I ran over the maximum length.
Hence the bronze badges for another 23 tags.
 
Yeah yeah... stop boasting :)
 
9:50 AM
@JonClements I even sometimes explicitly kill variables to save RAM (ok, large data project, exceptional situation).
 
I want to read .doc file in python so I'm convertng .doc to .txt and do some extraction. Anyone has better ideas ? Better modules.. ?
 
I'm pretty sure theres a library that reads .doc and .docx files
 
I am nearing mjölnir in
729 ^
 
found one for reading .docx
not .doc
 
10:02 AM
aren't docx just zip file with some xml and binary blobs?
 
why $(tput <expr>) is not working but the good ol' escape notation does?
cbg(all) # btw
 
user559633
cbg varo
 
heya @tristan
 
can someone confirm my answer is legit? stackoverflow.com/questions/28603159/…
 
10:10 AM
is there any meta post about closing the question immediately if op fails to show his attempts?
 
there are some really shitty answers there
 
user559633
"ARTEMIVSK, Ukraine - A Ukrainian call for international peacekeepers to calm its war-ravaged east ran into quick trouble Thursday after pro-Russian separatist rebels and Russian officials said any such mission violated the peace deal reached last week."

oh russia
 
ooop :D
@tristan maybe should ask for the peacekeepers from russia
 
user559633
haha, yeah. russia attacks after the ceasefire "hey, if you bring in international help, that violates the ceasefire"
 
user559633
i have this really annoying habit of waking up in the middle of the night and being too tired to code, but too awake to sleep. i think i'm going to start coding in ruby so i can be productive when mentally cloudy
 
10:19 AM
Russia's peacekeepers will ensure that peace is not broken when the secured areas are being annexed to Russia
oops, I guess after that statement I cannot visit Russia anymore
 
user559633
s/peacekeepers/unmarked military coming over in tanks to visit their grandmothers/
 
user559633
yeah, as someone that goes multiple times a year, maybe i shouldn't talk
 
I haven't been to Russia since '91
 
user559633
beautiful country
 
I've family in Tomsk and St. Petersburg
 
user559633
I want to go to both of those places. I'm thinking I'll go to St Petersburg later this year.
 
doesn't really answer at all - link only
been to moscow only
 
StPb is amazing
Tomsk is kinda meh
 
stpb could be nice to go, easy to pop in by train from here :P
 
yeah
I'm going to Amsterdam this year, I think
just to relax
 
10:27 AM
hmmm ...
is it like a special place to relax? :D
 
user559633
I'm going to do the trans siberian railway within the next 10 years, so i was planning on popping out along the way
 
recommended, on my bucket list too
 
@AnttiHaapala, nah
 
cousin did that in 2009
 
it's either Paris or Amsterdam this year
 
10:29 AM
@MarkR. was thinking about coffeeshops :D
 
yeah, I know, I haven't smoked for years, not my cup of tea
 
I cough enough without any inhaled smoke anw :D
 
hehe
 
user559633
@AnttiHaapala are you going to do the full trip? I was thinking of doing vladivostok (after coming from tokyo) and staying on the north fork
 
@tristan ah, dunno, maybe branch off to transmongolian :D
if would go then would take wife and go all the way down to vietnam
 
user559633
10:41 AM
oh, not a bad idea at all. i have some friends in vietnam, so maybe a trip down the more interesting route would be in order
 
@d-coder have you had a look at wv? en.wikipedia.org/wiki/Wv_(software)
or pyuno, but you need the libre-office libraries for that (which I can imagine will be large)
 
@tristan yeah I doubt there is much to see en route as such... only the stops :D
except at the end
@tristan back then my cousin was vegetarian :D so on stops he'd buy everything, let his friend to taste them and he ate all that didnt have meat :D
 
user559633
i have to figure out how i want to book it -- there are 4 or 5 places that i want to get out and walk around
 
user559633
haha, that's amazing
 
but he did also branch to transmongolia, went to thailand by land
 
user559633
10:52 AM
i'd go back to thailand. not sure that i want to take the connecting route from beijing to bangkok though
 
user559633
i haven't been to singapore though, so that could be cool.
 
user559633
what would be really great would be to try to convince one of my chinese speaking friends to come along, because then my party would have 100% coverages of languages along the way
 
I have been only to singapore airport, should pop out, I have 1 friend there
(a finn)
the singapore airport is a must for connecting flights
it always is among the tops for making a connection, and for a reason
 
re-cbg
 
user559633
cbg @Ffisegydd
 
10:55 AM
re-re-cbg
 
cbg(all, tone=tired)
 
user559633
i want to do the trans siberian as part of a circumnavigation (or whatever the generic travel version of the word is) of the globe
 
1 my friend has been on a trip for 3 months now
I am green with envy
 
user559633
what i have in mind will take ~ a year
 
woulde be good if there was a chance to do contracting work :D
along the way
 
user559633
11:01 AM
why not just take the time?
 
My friend has been backpacking across South America for the last year. I am not green with envy. I like my things. I like my comforts. I know this makes me boring, and I'm sure having this kind of experience is magical and life-changing. But f*** that s***.
 
I agree with @Ffisegydd, I like having room service and a car+driver
 
yeah the backpackers are a different breed
 
Inbreeding?! lul wut?
 
@AnttiHaapala where on this map are you?
 
user559633
11:03 AM
i'd be doing a mix of backpacking and staying with friends
 
In this case, he's an asshole.
 
yeah, I feel to comprehend what the whole west EU did to be considered assholes
 
@Vader asshholes obviously
would have thought you'd have figured out by now :D
 
I'd love to move to Bjork actually.
 
user559633
heh, i'm the mtfl and i'm "freak"
 
11:04 AM
@AnttiHaapala naaah, you're a good guy
 
user559633
i could see living in "Bjork" from may to september
 
I'd love to move to Iceland.
 
user559633
split the time between reykjavik, akureyri, and travel
 
+1 for closed ports
 
Such a beautiful place.
 
11:05 AM
Why Fizzy? I thought that having comforts was your cup of tea? A lot of the stuff to do in Iceland are adrenaline pumping banter Ah, you so shallow :P
 
Am I the only one here who is American? This almost never happens
 
good asshole
 
@Intrepid Gotta love some BANTER. But I'd just love to drive around it and take photographs. Relax in Reykjavik. I know they do a lot of adrenaline stuff, but it's also a relaxing place.
Get a cabin in the middle of nowhere, sit in front of the fire and drink Brennivin.
 
All the Icelandic people I know are mad as cheese. Love them to bits though
 
@Ffisegydd the backpackers "save the last penny" are annoying
 
11:07 AM
Aieeeee. The Black Death! Never again
 
need to up a bit from backpacker
 
Don't fancy the food too much though. I'll pass on the fermented shark.
 
@tristan have you done backpacking?
 
Food in iceland is of a really good standard from my experiences
 
I mean, if I need to go on transsiberian express ofc I'd use a backpack, but woulkdnt ever want to behave like one
 
user559633
11:09 AM
@AnttiHaapala only a little, ~3 weeks
 
I hate fish. But I'd go back for some fermented shark. It's different
 
I mean I go to vietnam and there are lots of ppl wqho need to wear theugliest clothes possible, look like they never go to shower, and hold the lonely planet guide in one hand
and then they bargain for the cheapest price possible bc they want to spend less than 10 $ a day
 
I'd say fighting to spend "a minimal" amount is the most responsible way to backback travel, otherwise tourists really mess up the local economy by inflation
 
then actually they end up being more than the locals bc they are so stupid
nope, they are messing already
everyone there knows that if someone is dressed up cheaply they want to bargain the lowest price possible but they are not price aware, then they pay more.
whereas if you dress up like the local and you know the language and you go to places where they don't speak english you pay the same price like everyone else
 
Yep, and besides, isn't that the goal of being authentic? It's just that people are rubbish and fail spectacularly
Especially being of British stock. The key I've found is speaking louder and more slowly. They'll pick up English eventually. That's how it works right?
 
11:16 AM
:D
now that's really annoying
 
Sometimes I want to cringe implode when I see my compatriots abroad.
 
@puredevotion: Thank you!
Now I'm getting some com-error for using win32com
 
well I certainly can't help with that :D
 
[python-win32] Dispatch error 'CoInitialize has not been called'
 
user559633
@IntrepidBrit You have to speaker it louder, more slowly, and in an increasingly frustrated tone.
3
 
user559633
11:20 AM
Don't use Windows.
 
+1
to "Don't use windows"
 
@tristan clicks fingers That's what I've been doing wrong.
 
+1 to don't use windows.
 
user559633
The only way to make the hurting stop is to not use Windows. Seriously. Well, up until systemd fucks messes up Linux and makes it a nightmare
 
why would systemd mess up linux
the current one for all the plugandpray stuff is pretty messed up anyway
 
user559633
11:30 AM
yeah binary log files yeah! yeah just be pid 1 because yam everyone else when the massive attack and bug surface of an init manager that needs reboots to upgrade, ignores standards
 
user559633
just really too much to list because it's so stupidly monolithic
 
reboots to upgrade... mmm...
 
user559633
everything redhat touches is crap
 
user559633
and for systemd specific, it just ignores all unix philosophies that have given us such great platforms.
 
I don't even list my RHCE anymore because RH is just becoming Oracle
not renewing it either
 
11:55 AM
unix philosophies :d
Many UNIX programs do quite trivial things in isolation, but, combined with other programs, become general and useful tools.
but the C compiler itself is not trivial
 
too broad
The 'answer' on it also needs flagging as NAA.
 
@MartijnPieters some downvoting needed @ stackoverflow.com/questions/625083/…
there are so much errors and also some NAAs
 
user559633
12:10 PM
Haha, dog with a bone on that one.
 
actually the whole question is such crap that if it was removed everyone would be better served :D
 
12:49 PM
I wish we had a close reason "This question is so bad, it gave me eye cancer.".
 
yes
should delete the question altogether
no one would behurt, all the answers are that sort of crap what you get when the question is bad
or should close it as a duplicate
of some newer
 
Interesting, I can't make range produce a list of numbers dynamically.
 
x = 5
range(start = 1, stop = x)
 
nope, that's not the problem
range does not have kw arguments
you need to write range(1, x)
it is because if you do range(1) then 1 is the "end"
and if you do range(1, x) then x is the "end"
 
12:56 PM
Ah so that's what that message means. Interesting.
I would think python would be thrilled if I provided explicit argument names.
 
yes
and the documentation sucks too
 
cbg
 
doesn't mention anything here still about it not accepting kwargs
 
To be frank, the error is very explicit.
 
@MartijnPieters OP has edited to add explanation... in the form of a video :facepalm:
 
12:59 PM
I just thought it doesn't evaluate my x or sth.
 
It's weird, because user-defined functions will let you supply ordinary parameters as keywords.
>>> def f(x,y):
...     print x
...     print y
...
>>> f(y=23, x=42)
42
23
 
It would appear some functions are special.
 
the reason is that range uses tuple parsing instead of pyparseargs and kwsorwhatsit
here
    start = PyLong_FromLong(0);
    if (!start) {
        Py_DECREF(stop);
        return NULL;
    }
    step = PyLong_FromLong(1);
    if (!step) {
        Py_DECREF(stop);
        Py_DECREF(start);
        return NULL;
    }
interesting checks btw :D
 
Ah, the language reference has something to say. "CPython implementation detail: An implementation may provide built-in functions whose positional parameters do not have names, even if they are ‘named’ for the purpose of documentation, and which therefore cannot be supplied by keyword. In CPython, this is the case for functions implemented in C that use PyArg_ParseTuple() to parse their arguments."
 
if you fail to do PyLong_FromLong(0) then there's nothing you can do anymore :D
could as well abort the interpreter there...
 
DSM
1:13 PM
Well, that was a long night, but I think it was productive: there's only a bit of writing to do and a few more charts to generate, and that's it. Might hit the deadline after all.
 
1:25 PM
@unutbu no tabs in repr. — Antti Haapala 1 min ago
What does repr mean in this context?
 
@DSM we believe in you.
 
@Kevin no tabs visible in the repr of the code pasted into python
 
FWIW, the code in question is available here and the raw text does have mixed spaces/tabs
 
what's this about?
 
in any case
that question is not useful as such
 
1:29 PM
So arguably the OP did give fully reproducing code, albeit one that's dozens of files large
 
an there are
but it is still unarepro
 
0
Q: Maybe monad in Python with method chaining

lazy pythonI'm trying to implement the Maybe monad in python. However what I also want is some kind of a chaining ability. So I have a class: class Maybe: def __init__(self, val): self.val = val def do(self, func): # Bind function if self.val: return func(self.val) ...

is it just me or it looks terribly unpythonic?
 
@Kevin op is running python 2 code with python 3
@MarkR. well, functional is unpythonic
 
and no it is not the correct way
@MarkR. the maybe should be a full proxy class
 
1:38 PM
PyMonad seems to be doing this
still icky
 
hmm
why?
do you think the AttributeError on NoneType is somehow better?
 
no
 
maybe should close it as too broad
it is not a great question at all
it basically asks: "how do I write Maybe in python"
 
1:53 PM
@AnttiHaapala - What's wrong with that? It's a unusual idiom for python, but still a reasonably good question.
 
no it is not
it is an interesting topic, but the question is not good on stackoverflow
 
Why not? It's clear what's being asked and it's on topic.
 
"Questions which are too broad, unclear, incomplete or primarily opinion-based may be put on hold by the community until they are improved."
so what to answer: write the library like pymonad??
 

« first day (1587 days earlier)      last day (3364 days later) »