Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

06-14-2012 , 04:32 PM
Quote:
Originally Posted by unluckyboy
okay i dl the development tools i got the information now thanks!
there's nothing to download, just click F12
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 04:34 PM
Quote:
Originally Posted by MrWooster
and will contain the time 23:59:60
**** is gonna get so crazy! you have no idea! already purchased 5 cases of beer
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 04:47 PM
Quote:
Originally Posted by NoahSD
Yeah. There's one every few years. It's because 1) the Earth spins very slightly slower than one spin per 24 hours and 2) the Earth's rotation actually slows down sporadically due to a whole variety of things.

I'm not really convinced that making sure that the sun is at its highest point at exactly noon (as opposed to like 30 seconds off) if you're right in the middle of a time zone is worth the confusion, but it's also not much confusion.

It causes a bit of a mess for Unix time.
Ye. There is quite an in depth discussion going on about it on HN.

http://news.ycombinator.com/item?id=4112002
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 04:49 PM
g_m and t_c, I was actually thinking more about how you test a single function. So a simplistic example is you have a function like:

Code:
def can_retire(person):
   return person.age > 65 && person.savings > 50
If that's my function and I'm using TDD I'd probably just write a few tests and then write the function. While true TDD (I believe) says first write a test based on a person's age. Then when you've got that passing, write a test based on their savings. And so on...

It's always seemed like a bit of a waste in many cases. Also what languages do you use? I started refactoring our Java code the other day to make it more testable and the amount of dependency injection needed started feeling crazy to me (even using Google's framework for that).
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 04:59 PM
god i hate setting up libraries in python they should all be .exe files that set themselves up. takes me an hour each time to figure out how to do it
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 05:32 PM
Quote:
Originally Posted by NoahSD
Yeah. There's one every few years. It's because 1) the Earth spins very slightly slower than one spin per 24 hours and 2) the Earth's rotation actually slows down sporadically due to a whole variety of things.

I'm not really convinced that making sure that the sun is at its highest point at exactly noon (as opposed to like 30 seconds off) if you're right in the middle of a time zone is worth the confusion, but it's also not much confusion.

It causes a bit of a mess for Unix time.
It's about the long run. Either you have leap seconds, or the differences tend to build up and eventually the sun is at its highest point at exactly 6pm if you're right in the middle of a time zone.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 05:34 PM
Quote:
Originally Posted by unluckyboy
god i hate setting up libraries in python they should all be .exe files that set themselves up. takes me an hour each time to figure out how to do it
Wat

No really.

What is the hard part?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 05:43 PM
Quote:
Originally Posted by unluckyboy
god i hate setting up libraries in python they should all be .exe files that set themselves up. takes me an hour each time to figure out how to do it
I assume you're Windows? Are you using Spyder + python(x,y)? It's a great IDE + python build that comes standard with a ton of libraries, and getting a new library is almost always as simple as easy_install libname.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 06:13 PM
Quote:
Originally Posted by jjshabado

If that's my function and I'm using TDD I'd probably just write a few tests and then write the function. While true TDD (I believe) says first write a test based on a person's age. Then when you've got that passing, write a test based on their savings. And so on...
If that's true TDD, I don't do that. I'll make sure I have test cases for both age and savings and combos of them, but I won't religiously make sure only the age tests are passing before I write the savings, etc. I think that's sort of silly, tho I could see its purpose while learning to develop good habits I guess.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 06:22 PM
It's the "do one thing" school of thought.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 07:57 PM
Quote:
Originally Posted by Neil S
Wat

No really.

What is the hard part?
Yeah, you are almost certainly doing something very very wrong if you're having trouble installing python packages. Pretty much everything can be installed by downloading the package, unzipping it and then from the command line:

Code:
python setup.py install

Even easier is intstall setuptools/pip and then you can just "pip install somepackage" and it will download and install it for you.


There are a few packages that can be a bit of a pain in the ass to get to build correctly using "python setup.py install" but for those there are usually pre-built binaries available (numpy/scipy/matplotlib etc)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 09:54 PM
shabby,

absolutely i test and write those things separately. like kerowo said, "do one thing" -- i can barely do one thing at a time, why would i try to do more than one?

but more significantly, sure, it looks dumb when you're dealing with two super simple predicates. but what about when your function looks like this:

Code:
def can_retire(person):
    old_enough = (person.age > 65 and person.country="US") or (person.age > 55 and person.country="socialism")
    money = [ money += account_balance for account in person.retirement_accounts() ]
    enough_money = money > 1000000
    dependents_ok = check_dependents(person.dependents)
    ...
still want to write those all at once and just kind of think up test cases as you go? i sure don't!

(astute observers will note that each of my predicates belongs in a separate function with its own tests. if i didn't notice that up front, refactoring to this better solution is going to be a hell of a lot easier with tests in place!)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 09:56 PM
and yeah hearty lawls @ "why aren't they all just EXEs?"

Last edited by tyler_cracker; 06-14-2012 at 09:56 PM. Reason: if you had said "why aren't they all just DEBs?", you could have had me on your side tho :)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 10:41 PM
t_c,

wtf sort of wizardry is this!?!

Code:
money = [ money += account_balance for account in person.retirement_accounts() ]
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 11:24 PM
Quote:
Originally Posted by Neko
t_c,

wtf sort of wizardry is this!?!

Code:
money = [ money += account_balance for account in person.retirement_accounts() ]
it's psuedocode cleverly disguised as python.

here's a version that actually works:

Code:
>>> money = sum([ account['balance'] for account in ({'balance': 10}, {'balance': 20}) ])
>>> money
30
if you just meant the list comprehension part, that's a python list comprehension .
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 11:34 PM
ha. I have to admit that after seeing you could use any punctuation for search/replace in vim I had a brief pause where I wondered if somehow I was missing out on a similarly face-palmingly convenient method of using += in list comprehensions.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 11:37 PM
having sat down to write it, i can attest that sum() is pretty face-palmingly convenient.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2012 , 11:48 PM
In a somewhat similar vein, given:

Code:
class O:
    def __init__(self,i):
        self.i = i
    def double(self):
        self.i = 2*self.i
os = [O(x) for x in range(10)]
I have in past written code like:

Code:
  
for o in os:
    o.double()
or

Code:
  
[o.double() for o in os]
when all along I probably should have been writing

Code:
map(O.double,os)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2012 , 12:24 AM
If this video doesn't convince you to learn Erlang....Nothing will.

http://www.youtube.com/watch?v=xrIjfIjssLE

Quote:
Hello Joe!
Hello Mike!
Hello Robert!
Hello Joe!
Hello Mike!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2012 , 12:30 AM
i think the list comprehension form is the clearest, but i've been reading a lot of python lately. as someone who has hacked in perl and scheme, i am content with your use of map().

the first form is good for dumb old languages like fortran and C
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2012 , 01:23 AM
Quote:
Originally Posted by Neko
If this video doesn't convince you to learn Erlang....Nothing will.

http://www.youtube.com/watch?v=xrIjfIjssLE
tdd: when you want to test your code without touch-tone dialing your colleagues!

i like how the dude's test for his bug fix is "i think i remember a function called multi, so i'll just delete this m and re-run my test".

it is pretty hot that the original call stays alive through the patching process. i went to a talk on erlang once and it seemed cool because of **** like that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2012 , 01:36 AM
hey i meant to respond to this.

Quote:
Originally Posted by Jbrochu
Not really headed anywhere but just making sure I understood the conversation. I've never heard of doing testing that way.
oh ok. seemed like it might be a leading question the way you were phrasing it; my last job was filled with haters who had a million excuses for why they "couldn't" write automated tests for their code.

Quote:
None of my classes ever taught me anything about testing, and in my current workplace we don't have a formal testing program in place. I pretty much write my code and test it as I go. Then we usually release it in beta for feedback, and clean up any issues that arise from that.
none of this is uncommon. testing belongs more to engineering than to computer science, so its adoption in universities is slow. most software engineers and their employers don't understand testing at all.

Quote:
Testing is one of the issues that makes me nervous about interviewing for a full time developers position outside my current company.
for run-of-the-mill development, i wouldn't ding a recent grad/junior engineer for poor exposure to automated testing. i do expect you to understand (or be prodded a bit to discover) the benefits of testing and maybe a basic idea of how unit tests work and what a mock/fake/double is.

on the bright side, you've uncovered an area of your ignorance, which means you can eradicate it! there are bajillions of books and blogs on the topic. i'm partial to Uncle Bob because he's not afraid to get the haters mad.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2012 , 01:55 AM
I find the second and third versions quite jarring, because they mix up two paradigms.

Code:
for o in os:
    o.double()
is imperative code. You are telling the computer what to do.

Code:
[o.double() for o in os]
is declarative. It looks like it describes something. In fact it does. It is an expression whose value is a new list [None, None, None, ... None]. I'm surprised by this list -- it doesn't seem like producing it was the desired effect of the code -- and I may also be surprised that the code has side effects.

In a purely functional language, it's difficult to write code that affects state, and you tend to isolate those parts of the code that must perform input and output or other side effects. In a procedural or imperative language, it's difficult, ugly or impossible to write declarative code, so you tend to change state with every line of code. Python gives you both, and each has its place.

If you find the map and list comprehensions flow better, maybe it would be good to write the whole program in a more functional style. So you would have
Code:
class O:
    ...
    def double(self):
        return self.i * 2 # or return O(self.i * 2) if that is what is desired
or
Code:
def double(o):
   return O(o.i * 2)
class O:
    ...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2012 , 04:59 AM
Quote:
Originally Posted by unluckyboy
god i hate setting up libraries in python they should all be .exe files that set themselves up. takes me an hour each time to figure out how to do it
Meh I don't think running an entire virtual machine just to get python libraries working would be fun :P

TDD: Not writing much code lately but I never really followed it to the letter. Writing code still is art in my opinion and religious TDD is kind of like following formalized math just for the sake of it. Also I usually start coding with a piece of paper and a pen, basically doing some high level design up front. I think if you do strict TDD you tend to worry too much about the trees and forget the forrest at times (at least I tend to if I force myself into 100% TDD)

Re dude that enver heard of TDD: Google it, read the wiki article on it, find some youtbe video on it and do a little program following the principles as strictly as possible. That will probably already put you ahead of many people in standard job interviews.

Last edited by clowntable; 06-15-2012 at 05:07 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2012 , 07:17 AM
4k ... first!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m