« first day (906 days earlier)      last day (4057 days later) » 

2:35 AM
If I use the command: data = open('file.txt').read(), will it automatically close the file?
 
 
1 hour later…
3:36 AM
numpy or matplot lib?I am looking for existing python library for plotting dynamic graphs(multi axis) and having the feature of displaying the labels as we move the cursor along the graph.DOes it exists or Do I have write my own starting from the scratch.Any pointers towards it??
 
 
2 hours later…
5:40 AM
No. it wont automatically close the file. for that purpose, use a context manager like 'with':
with open('file.txt') as fp:
data=fp.read()
I somehow dont know how to put indentation here in the chat code. I guess you will figure it out
 
 
2 hours later…
8:10 AM
@jakebird451 Yes, Python will automatically close the file.
This seems to be a bit of a Python urban myth
When the refcount for the file object drops to zero, file_dealloc in fileobject.c gets called, which closes the file if it is open.
It's a bit more complicated in Python 3 because file objects are really io objects internally, but again, when the refcount falls to zero, _PyIOBase_finalize in iobase.c gets called, which closes the file if it is open.
The reason for using with open(...) as f: is that this ensures that the file is closed when the block is exited even if there is still a reference to the file. This is important if you need to be sure that the file is closed in the presence of caches and memoization and other things that might hold on to a reference without you knowing about it.
But in open(...).read() there are clearly no references to the file object remaining, so this isn't a plausible worry.
 
 
1 hour later…
9:30 AM
morning
 
morning
 
some guy just downvoted a perfectly good answer
 
and ...?
 
2
A: integer part of the root withot using functions

VolatilityThis should suffice: >>> int(17**0.5) 4 17**0.5 generates the square root of 17, and int basically removes the decimals, leaving you with the "integer part of the root". Without using any functions, and if you want an integer result, complex code (like your own) is needed. However, if a float...

 
beat him with cotton balls until he bloods!
;)
 
9:36 AM
argh, didn't work
there we go!
 
Let's not enable people asking "how can I solve this problem without using any features?". The way to compute the integer part of the square root of x in Python is to call int(sqrt(x)). Your teacher may not like it, but we don't care.
 
The same question was about 3/4 days ago I think
 
9:59 AM
morning chuds
 
hullo
 
10:11 AM
hi, there I'm looking for some help with fabric...
 
its always a happy moment when I answer a python question with my limited knowledge cheers
 
i simply want to run a process and let the process running
sudo('python runapp.py')
but naturally the ssh connection will disconnect.. err
perhaps someone has a clue
0
Q: Running a python app on AWS with fabric

RParadoxI'm trying to run a python web app on AWS. It works fine if I log into AWS with SSH. But with fabric this does not work. I tried: run('python app.py &') And: sudo('python app.py &') No repsonse: $ python awsstart.py run [ec2-user@XYZ] run: python app.py & $ (empty)

 
10:52 AM
'lo pythoneers.
 
hoihoi
 
11:08 AM
y'ello
 
hey you 2
 
11:58 AM
hi
 
12:41 PM
keeping up the periodic "Hello" every ~30 minutes
Hello
 
@mgilson it's a noble job... :)
 
Hey Jon
How're you today? how's the foot healing?
 
Hey Matt - how goes it?
Foot is fine now... just with mates for a few days sorting stuff out...
 
Pretty well. I discovered Sphinx last night
 
Ummm okay - bit slow on the uptake there, then? :)
 
12:44 PM
I'm in science ... Around here you get an 'Atta-boy' if you actually choose to use comments
But yeah, I s'pose I am probably the last one to know.
 
You get 'atta-boy' - almost sounds like you get ostracised?
 
I spent like 4 hours last night re-writing my docstrings to make the html look prettier ... and I still need to figure out how to get it to organize stuff.
Nah -- comments are OK, but they're not nearly as common as they need to be
(especially considering some of the ugly things people do to try to get the code to go 2% faster)
 
I've heard of people avoiding using functions because they're concerned about the time to allocate and free a stack frame.
I've been systematically getting rid of "macros" in the code that I work on in favor of functions...
 
Hey - I heard that if you comment out all the code - it runs really really quickly
 
12:59 PM
Well, you need to leave a few statments in there, otherwise the compiler will complain, but yeah, it really does go fast if you do that.
 
I once worked on something with the DOD what did some signal processing, where the code was written in C on Unix like 20 years ago, and then re-written into C++ on windows or something... and then we had to translate that into C#... anyway... I don't remember the specifics, only that is was EXTREMELY scientific and mathematical code, written 20 years ago.. by non-programmers... and then we had to change it.. there were parts of the code... oh man... you don't wanna know how ugly...
Not a single comment, and half the functions had no meaningful names, the ones with meaningful names made no sense and didnt come from anywhere
There were redundant cycles everywhere, and some of the code had hard-coded variables that didnt even make any sense
like.. at some point the code had a statment "Variable = 1" (some variable name = some number.. dont remember specifics) and then it was used later "if Variable = 1" ... like it could be anything else....
Horrible horrible horrible.
also, some constants that were used in some of the calculations seems to be totally arbitrary, but if modified at all... bam - no work.
Anyway - scientists who try to write code.... shudder
 
I've heard many horror stories about bad scientific code. It shakes my faith in the community a bit. One scientist uses integer division instead of float, and as a result his simulation indicates that eating lead paint chips is good for you.
 
Sounds like some code I had to work with.
Written by pricey consultants, though.
No comments, and most of all no clue about programming.
How the hell those cowboys ever got paid?
 
Ideally, there's enough peer review to catch those kind of mistakes, but does that happen in practice? Does a second scientist rewrite the simulation from the ground up? Or does he just run paintChipsEatingSimulator.py on his own machine and say, "looks good to me"?
 
I had moments where banging my head on my desk, hard, was more pleasurable than having to deal with the monumental gaffes the code was pulling.
 
1:11 PM
@MartijnPieters you're disregarding how awesome most pricey consultants are at shifting blame when the feces hit the fan.
 
like bypassing the indexes; just pull out all the data items (1000s by the time I came to it) and then filter the resulting list manually.
 
Ahh, but the whole point of a consultant is that their job security is through code obscurity...
 
except the data items had to be pulled out of the persistent tree all over the place, causing the system to swap like mad.
 
So, anyone have any other ideas about this problem:
2
Q: faster Django csv generation on the fly

tr33housI am writing a csv file generator that's filtering through about seven million db entries. {mySQL backend} This part is especially slow and I was wondering if there is a way to make it much faster. I was thinking of wiring to a temp file first before serving it then deleting the file. Is there a...

 
If, instead, the indexes had been consulted to just pull out the 3 items they needed...
 
1:12 PM
@MartijnPieters, I think bozos like that are hired because they are more charismatic than the stereotypical introvert programmer.
 
Ah nice! I got one of those once, some query was getting a list of id's, and then there was a separate query on a related table for EVERY SINGLE ONE of the id's returned by the first query.
I commented someone should come up with a way to join results from two tables... I don't think everyone at that time understood...
 
Yup, these were gaffes in that direction,
but this was with a persistent tree storage. The ZODB, if you are familiar with it.
with a dedicated 'catalog', an indexing service.
 
I once worked on a system which allowed the user to write little programs in flowchart form. The flowchart was then applied to each row of a moderately large database. This took so long that the programs had to be run overnight using a complicated batch-processing system. I was asked to look at speeding this up.
I discovered that the flowchart programs were stored as a set of records in a table in the database. In order to execute the flowchart on a row, the system would open a connection to the database, fetch the first instruction from the flowchart, and close the database connection.
Then it evaluated the instruction and determined which instruction to run next.
 
@Kevin -- I think there's a general distrust of simulations in the scientific community in general (maybe for that reason). It's not uncommon for scientist A to verify what scientist B saw using a different code.
It's also (at least for me) pretty important to compare simulation results against actual data.
 
Which resulted in another database query. Basically, the system was interpreting 3-address code, except that every instruction fetch involved a database query across a network!
 
1:17 PM
If my simulation says "eat lead paint" and I feed it to my son and he turns out dumb as a brick, then I know I need to fire up pdb to figure out where my code when wrong.
 
That's an ineffective QA cycle unless you have infinity sons.
 
Don't you think there are lots of parents out there willing to donate their children to science?
 
Even outside of simulations, it's something I worry about. Like, performing analysis on a big database of real-world data, and you transform the data the wrong way.
See the zillion questions on SO that are like, how do I pass my 5d numpy array into this function?
For all we know, they're trying to pound a square peg into a round hole. And we cheerfully recommend the band saw.
 
There really should exist support groups for software developers.
 
Isn't this it?
Hi, my name is Martijn Pieters and I am a Software Engineer.
There, I've admitted to it...
That's the first step, right?
 
1:29 PM
It's tricky because the most effective therapy we have is sharing the coding horrors we've experienced. But you can't complain about Bob's ugly-ass code if Bob is also at the developer support group.
 
Then you need to change jobs... :-P
 
The first rule about programming club, is that you don't talk about programming club....
 
Hmm, sounds like a graph problem. Programmers are nodes, and directional edges represent the relationship, "X has written code that caused Y to suffer". Each support group is a set of nodes, with the constraint that no two members may be connected by an edge.
Problem: Minimize the number of support groups.
 
Why is it the javascript room always appears to have flagged posts...
 
Ooh, shiny unicorns over at GitHub.
Clearly the load is a little high there.
 
1:36 PM
yeah - just noticed that LOL
 
We are currently investigating elevated exception rates.
 
Oh damn - now it works... I wanted to save the unicorn picture :(
 
It's a data URL
Message too long..
 
That's a fairly hefty data: URL.
 
1:43 PM
It is a fairly scary unicorn...
 
He probably is just upset because he didn't floss this morning.
(Or maybe because he doesn't have any legs)
 
Or a body
 
Whenever either of those things happen to me, I usually make a similar face.
 
Or that his penis is on his forehead, and when he isn't hard he is blind in one eye (also, if that is the case, he has no balls) - (sorry for the vulgarity, couldn't resist)
 
@mgilson That was not the look on the face of the victim in the latest Jonathan Creek story.
or did I just hand out a huge spoiler?
 
1:45 PM
Does this have anything to do with what I just said?
 
Oh god, I hope not.
 
@InbarRose: I was ignoring your latest comment..
Or rather, I was typing when you made it.
There, added a reply ref.
 
I noticed. It beeped at me.
 
@mgilson Good. Every time it beeps it means that you now owe me a bounty.
That's how it works around here.
:-D
 
1:50 PM
@MartijnPieters sure?
 
@InbarRose: I have the sound off..
 
Are you implying that if I offer a bounty on my most recent question that you'll answer it?
 
I'm implying that you are now obliged to gift me a bounty, your pick of answer.
is totally serious, of course.
 
@MartijnPieters I don't recall any pink unicorns in the last Jonathan Creek... (have we watched the same episode?)
 
Do I need to press the spoiler home?
I am of course referring to The Clue Of The Savant’s Thumb.
 
1:55 PM
Umm, might have to resort to using my phone as a wireless hotspot - scheduled power maintenance at my friends house...
(so bye, bye router... for an hour)
@MartijnPieters it was a good episode - but then I've always been a fan of Jonathan Creek - and I do have a bit of a thing for Sheridan Smith drool
 
Fans of Creek, represent!
Glad they are sticking to specials now, the quality has improved with waiting for proper ideas.
 
I don't even know what it is.
 
Although some aspects of the story were a little over the top.
@InbarRose: Mystery detective style story.
 
/me hides the fact that he never watched a single episode of of J. Creek
 
afternoon folks
 
2:00 PM
Some murder or disappearance takes place.
All very mysterious and apparently requiring supernatural explanations.
then Jonathan Creek, developer of advanced conjuring tricks steps in and shows how it was all done.
 
heya @BasJansen
 
With a splash of humour.
 
sounds like a weird show
 
Alan Davies is cool ;)
@MartijnPieters Have you watched the latest "Not Going Out" ?
 
Loads of them are up on YouTube in their entirety!
@JonClements I don't think I have.
@BasJansen: Start here: youtube.com/watch?v=dEoGd3UZlCY
 
2:05 PM
nooesssss, I barely have time to keep up with my books
let alone watching tv shows as well
 
BOOOOO!
 
Martijn, what's your opinion on working with data larger than the computer's memory, write it to a temporary file or use a database?
 
Umm - might win this game of "words with friends" - 4th round and it's 220 to 36...
ahhh, 310 to 46
 
@BasJansen: Depends on the data and usecases.
But with sqlite included with Python, it's not that hard to switch to using that.
It then is no longer a case of or, but your option becomes and instead.
Use a temporary file in the form of a SQLite database..
 
If we slided into the topic of games, and recreational activities, anyone here play baldurs gate?
 
2:13 PM
hmm
 
Okay - not a very fast connection in the dip of a hill, but at least it's still connected....
 
hehe
in JavaScript, 40 secs ago, by Neal
@rlemon noooo! django it up :-) [he says to the JS room]
 
i'd still be tempted to goto or instead of and, the size of data to be handled is directly dependant on the machine that is used to measure the data. 1 type of machine is guaranteed to create data larger than any computer's memory (that we have here)
so it makes sense to make it use a sqlite database straight away instead of starting to parse, notice mem runs low and then switch
 
2:57 PM
@MartijnPieters -- There's you're bounty ;-)
 
haha
I was just going to comment, that you guys are having a battle on that post
I was just watching your edits, adn your answers get bigger and bigger.
Amusing.
 
I don't much watch other posts
I usually post-edit.
 
Yeah, I do a lot of post-editing as well.
 
We know your trick @MartijnPieters. Post a simplified version of the answer that is correct as fast as possible, and then edit it up a few times till it is nice and robust, meanwhile positioning yourself as the first answer-er, and getting up votes.
A classy trick. :)
 
But, I think Martijn Dvorak'd me in the edit cycle.
 
3:00 PM
Yeah, Dvorak = so much faster.
 
Someday I'll learn it (maybe)
 
Hey, I first typed a comment to that question.
So I gave you a fair head-start! :-P
Even that comment got more votes than your post by now. :-D
 
Hehe. That does not count as a head-start from you. A headstart from you is that you don't answer for 1 hour. That is a head start, even then you could win! :P
 
For reference, what post are we talking about?
 
1
Q: if len(list) in Python

mjswartzI'm translating a Python code to C in order to take advantage of the parallelism available on HPC systems (its a painful process) and I've come across a conditional in Python the original programmer used that confuses me if rnum <> current_res: alim = 0 if len(f): alim = f[-1] W...

 
3:05 PM
Reminds me of an old, probably not true, but nevertheless good story: This engineer is called in because a machine broke down. He looks at it, makes a cross with chalk on some machine part and says 'replace this part'. He charges $50,000. The manager is out-raged and requests an itemized bill to justify the cost. The engineer replies: Chalk - $1, knowing where to make the cross $49,999. — user12889 Jul 28 '11 at 0:31
 
Hello
I was just reading an article, where DDOS'ers were labeled 'hackers'.
I don't think that is quite a correct term
Come to think of it, DDOS'ing has nothing to do with 'hacking' or circumnavigating security.
It's basically just a brute force move. Is it not?
 
Hacker is probably the most diversely used term I know these days.
 
The meaning of "hacker" has been badly diluted by the media.
 
"Hacker" has grown to cover two meanings.
 
It can mean whatever you want it to mean.
 
3:08 PM
Yeah
 
Ex. 13 year old girls "hacking" their friend's Facebook page.
When really, that friend just left their browser open and unattended.
 
some believe it to mean 'cracker' (malicious breaking of or into comptures), others would like the original meaning of skilled tinkerer to be the only meaning.
 
For me a hacker will always be someone who wears khaki, rides around in a skateboard and has a decent chance of nailing young Angelina Jolie.
 
I know that term, but don't use it because so few people recognize it
It's a little silly.
 
I always thought every hack was unique. But later I found its not. Rather most hackings are just common vulnerability
 
3:10 PM
I often read these articles, from the BBC and whatnot, and as you read you realize, or at least, I realize. That they have no idea what they are talking about.
 
That is true for most journalism, actually. :-)
 
It was shocking to me when I found out that typing commands on the shell didn't instantly conjure up 3D labyrinths of structured information where I would navigate using my superior keyboard mashing techniques.
 
@pcalcao haha
 
Any article that covers a subject you actually know enough about turns out to contain errors.
 
Yep, it's quite common on technical articles on mainstream journalism, but it does happen with any subject.
 
3:11 PM
@MartijnPieters I suppose that is true.
 
Because writers are rarely knowledgable about the subject matter to spot the errors themselves.
 
We just notice the technical idiocy easily because... we're tech people.
A friend of mine who's a psychologist almost pulls out his hair at certain articles about his area.
 
Community catches on pretty fast.
 
My friend is a doctor, when he watches house he is like "DUH.. I could have told you that...."
 
Still, I see a lot of people referring to cheaters in games as 'hackers', rather than the more correct term. Script kiddie
 
3:13 PM
Obligatory link: some file systems do involve flying around 3d labyrinths of information.
 
Did someone link to my Duck Typing answer on Programmers?
 
I did
 
is seeing some nice upvote action.
 
1
Q: How to differentiate between a Tuple and a simple String through "Duck Typing"?

PhilI'm relatively new to programming so I beg your pardon if I'm making a ridiculous mistake by referring to the following as Duck Typing. I have a procedure which receives either a string or a tuple (containing strings) as a single argument. Example: def proc(arg): try: arg is a tup...

 
@InbarRose: ah, that'd explain it. :-)
 
3:13 PM
Your welcome.
 
isinstance
That's a new one to me.
 
Really?
It is great, because you can check also a set of types
like, isinstance(x, (int, float, decimal))
 
This one just bit me:
7
Q: Bounty not awarded automatically — bug?

FraserI think this question's revisions and timeline may reveal a bug in the bounty system. The timeline summary as I see it is: Question asked Mar 17 Answer added Mar 18 Question edited (extended) and bounty added Mar 20 Answer edited and accepted Mar 21 Bounty ends "with no winning answer" Mar 28...

 
Would I follow it up with an if-statement?
 
bit you?
 
3:18 PM
only 50 points, but with J W at the top of the board ATM those would have been nice.
 
Oh, you edited an answer after a bounty.
Just delete the answer and post again (seems to be the way around the bug)
 
Anyone would think you were competitive Martijn ;)
 
No, then I definitely won't get a bounty. :-)
 
Oh, you treat it in an if statement
 
3:20 PM
@JonClements: Who, me? Once you get up there for a little while, it's harder to give up the top spot..
 
@Xeon It returns a bool which is something that you usually want in an if statement, but it can be used anywhere
 
"StackExchange is highly addictive; don't start!" ;)
 
It is better than using type(x) == str because it is a method.
 
@InbarRose Being not so experienced with functions, what purpose does arg serve? Most of the time I leave it blank
 
@Xeon In the case of the link and teh example I gave you, arg happens to be the name the OP used as his argument for the function...
But generally speaking, you can have extra args or kwargs on any method/function
 
3:21 PM
I know. I just never have put an argument into one
 
If you choose to.
You don't always need to.
 
What might you place into one?
For example.
 
122
Q: *args and **kwargs?

MacPythonSo I have difficulty with the concept of *args and **kwargs. So far I have learned that: *args = list of arguments -as positional arguments **kwargs = dictionary - whose keys become separate keyword arguments and the values become values of these arguments. ?? To be honest I don't understan...

Why repeat something that has already been explained? :)
 
Do kwargs have to do with nested dictionaries?
or am I a little off
 
nothing to do with nested anything
kwargs is "key word arguments"
like a dictionary is a collection of keywords and values.
so kwargs is a dict.
 
3:24 PM
Oh sorry. I was reading the question like it was the answer
lol
ok
 
wow - weird quesiton - closed quickly, and 1 minute later has 3 re-open votes...
 
Which one?
no, I don'th think so.
 
nah, the print 70% of whatever...
 
3:45 PM
i once heard a rumour about a tool that checks if i mixed tabs and spaces for indentation, does anyone know the name of it?
 
tabnanny
 
Or. any proper editor.
 
There is also pylint, but it does more than just tabs
 
4:07 PM
Dem power cuts.. :(
 
Today I learned, if you run python with the -t flag, it warns you about mixed tabs/spaces.
So you don't necessarily need an outside tool.
 
4:24 PM
Use -tt and it'll make it an error.
python -tt yourscript.py.
 
4:45 PM
does that apply to the parts it gets to or the whole program?
ie will it also complain about functions that don't get called?
 
@BasJansen: This is a compilation-stage test.
@BasJansen: so this applies per module.
 
allright
 
5:47 PM
Well, I'm going home. Think I'm going to code some basic graph structures and algorithms later on.
I need to get myself better hobbies.
 
You know that fear you have missed a test, or you don't know where it is?
I feel like that all the time at uni
it's horrible
Random much?
 
That's a recurring dream of mine, actually.
Oh no, my final is today, and I never went to a single class this semester!
I am no longer in school. I assume the dream will continue for the rest of my life.
In real-life college, I kept a text file of the most super important dates.
As long as I had unshakable faith that the text file was up-to-date, my mind was at ease.
 
My text file is google calendar,
 
Same, Kevin. And I am now too dependent on Google Calendar. If they ever take it down, like they are Google Reader, I'm going to be (more) aggravated... and lost.
 
 
2 hours later…
8:27 PM
Baiii
 

« first day (906 days earlier)      last day (4057 days later) »