Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Kharya posted:

Basically it comes down to, "If it ain't broke, don't fix it."
But...it is broken. You have completely different environments on your dev and production servers, so you have no way to know whether code that you push out will actually work. That defeats the entire purpose of having a dev server.

Adbot
ADBOT LOVES YOU

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Veritron posted:

[-D AE_Title]
Application Entity title? I smell DICOM!

I worked for a medical imaging company that had its own horrific (Ruby) script to generate and send DICOM files.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Ryouga Inverse posted:

Don't check in commented out code because you're half done with it. Check in only code that builds.
Commented-out code doesn't affect whether the project builds :downs:

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

niteice posted:

From some old LaTeX code I wrote:
code:
% it rotates variables by 90 degrees
No, I don't know what that means.
I believe it multiplies by i (\sqrt{-1}).

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
If you want a laugh, I strongly recommend searching phpfreaks.com's forums for all of Q695's posts:

http://www.phpfreaks.com/forums/index.php?action=profile;area=showposts;u=70191

haku posted:

You have programming training?!?! :eek:

Q695 posted:

Yes, I have a degree in IT (my BS), focusing in Web Development (my AAS), and looking for work more along the lines of QA and eventually becoming an architect. Why is that so shocking?
(emphasis mine)

edit:

aaah hahahaha
http://www.phpfreaks.com/forums/index.php/topic,240167.0.html is pure gold. Q695 believed that using an HTML <input> type of 'password' automatically encrypted the data (with SSL) before sending it to the server.

Q695 posted:

Why did a college professor lie to me about it then? Why wouldn't password automatically encrypt the data when sending it?

I can appreciate not being knowledgeable; you have to learn somehow. He's just so arrogant in his stupidity, when his suggestions are almost all bad ideas and he's proven wrong by smarter people in almost every post. He's a jackass to people that try to help him, too: http://www.phpfreaks.com/forums/index.php/topic,240090.0.html

Lysidas fucked around with this message at 03:13 on Mar 19, 2010

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

TRex EaterofCars posted:

That reminds me of php's microtime() function. Goddamnit whoever wrote that is a cocksucker.

If you're unfortunate enough to use PHP on Windows, microtime() will make you want to tear your eyes out.

code:
Value returned from microtime(): 0.73437900 1272042042
Type of value returned from microtime(): string
A string!? What kind of brain damage do you have to suffer from in order to think that this is a good idea?

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

nielsm posted:

from O(n) to O(n^2)

It seems to be worse than that when you allow backreferences

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

NotShadowStar posted:

Here's the thing about school that they don't teach you: to think about what you're hearing. In this case, whenever somebody tells you to do the same thing in every instance, you should immediately start coming up with a counter-example and take them to task. This isn't being That Jerk In Class, this is seeing if their case holds up in every instance, or watch them fall apart because what they told you wasn't correct.

This is a good point, but if you're learning introductory programming it isn't really worth it.

When I was a TA for elementary Java programming, I got a lot of success out of telling the students "here's a rule; treat it as the truth until you learn why it isn't".

For example:

quote:

If you're having trouble with the first few assignments, here's some advice. Every program that you write should have this structure:
code:
public class WhateverNameYouWant
{
    public static void main(String[] args)
    {
        // YOUR CODE GOES HERE
    }
}

It let the students concentrate on what they needed to know at the moment and not on the boilerplate magic characters that let their programs compile. Of course by week 3 or 4, they're making classes that don't need a public static void main, but by then they learn why they were inserting that stuff in the first place and why they don't need it now.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

NotShadowStar posted:

One of the big reasons why I left the biological sciences was the code was universally terrible. Outstandingly so. Like 'well that's brilliant that it works, but you shouldn't be doing it'. The tool authors didn't know what the gently caress, refused to listen to anyone who had actual experience in the 'real world' (me), and I couldn't talk to the PIs because they're like 'it works who gives a gently caress'. Which left people like me trying to glue this wretched poo poo together was left holding the bag.

GrumpyDoctor is right; this is all scientific programming. When I started to implement an algorithm for my bioinformatics research, my advisor told me:

quote:

I can tell you've worked in industry, since you want your implementation to be perfect. Don't worry about that. Make it work well enough, get results, publish the paper, and move on.
The pressures that we're under in academia ("publish or perish") are guaranteed to produce horrible code that works just well enough to get results out of.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Zombywuf posted:

Tell me that when you've got an IP address conflict.

That has absolutely nothing to do with hardware failure (e.g. capacitors exploding, dielectric breakdown and electromigration in CMOS transistors, very noisy inputs to a crappy power supply causing odd spikes in voltage at seemingly-random intervals).

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Munkeymon posted:

AFAIK Open Office still has this problem

This is oddly reminiscent of Wine developers' complaints about having to faithfully reproduce bugs in the Win32 API, since lots of programs depended on or worked around those bugs :v:

I seriously doubt that this is the real explanation, but it wouldn't surprise me.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Beef posted:

How often does a new Ruby or Python update gently caress up your code, either directly or indirectly through incompatible libraries? I usually have enough of a library hell in C/C++, Java and in lesser degree Common Lisp.

Python 2 releases: typically not much. You might see some breakage if you were using strings as exceptions:
code:
Python 2.4.3 (#1, Sep 21 2011, 19:55:41) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> raise "some string"
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
some string
code:
Python 2.7.2+ (default, Oct  4 2011, 20:06:09) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> raise "some string"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: exceptions must be old-style classes or derived from BaseException, not str
You might also have some problems if you were using the new keywords in 2.6 as variable names. A friend of mine was working on a 100K+ LOC code base that had variables named as everywhere, and he said that it was a royal pain to get everything running on 2.6.

Python 2.x -> 3, though: :stare:
(Actually it's not that bad. Run the code through 2to3.py, fix anything that it couldn't, remove some unnecessary calls to list that it isn't smart enough to omit, and you'll probably be fine. This is only for pure Python code: I don't think there's an automated way to update extension modules written in C.)

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

LOOK I AM A TURTLE posted:

Vaguely on the subject of "input" in Python: One time a coworker of mine wrote code that essentially did this:

code:
def awesome_function():
    if something():
        input = do_a_thing()

    ...

    if input:
        <code that always gets executed because input never evaluates to false>

What are you talking about? Assuming that something() can return True and do_a_thing() can return False,

code:
In [1]: def something():
   ...:     return True
   ...: 

In [2]: def do_a_thing():
   ...:     return False
   ...: 

In [3]: def awesome_function():
   ...:     if something():
   ...:         input = do_a_thing()
   ...:     if input:
   ...:         print('input was True here')
   ...:         

In [4]: awesome_function()

In [5]:
It's almost certainly unintended (and a bug) that input defaults to true, but you seem to be wrong that the if input: code always executes.

EDIT: unless my assumptions are wrong and I just made an rear end out of myself, of course. That seems pretty likely in retrospect. It seemed like you were saying that input is always true because it's a built-in function, but you might have also meant that something() and do_a_thing() return values such that the code always executes. Either way, overwriting built-in names is often a surprise to people coming from other languages.

Lysidas fucked around with this message at 16:58 on Jan 18, 2012

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

tef posted:

I dunno. Once the big libraries are across (NumPy, Django) and stable I can see python 3 replacing 2 a little more.

NumPy already works flawlessly with Python 3, as does IPython, SciPy, NetworkX, BioPython, CVXOPT, etc. etc. etc. I use Python 3 exclusively in my research. It's really coming along. Hell, the development version of matplotlib even seems to work. (I tried a released version a few weeks ago, maybe 1.1.0, and setup.py build crashed and burned. Looks like it's actually building successfully now!)

I'd guess that Django will support Python 3 within a year, two at most. It also looks like (hopefully) Ubuntu 14.04 LTS will only install Python 3 by default, with 2.7 as optional and semi-deprecated. Arch already does this; if you install Python you get Python 3. RHEL will probably be on 2.6/2.7 for the next 20 years though.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
More Python 3 :smug:-ness

code:
Python 3.2.2+ (default, Dec 19 2011, 12:03:32) 
[GCC 4.6.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> None < False == 0 < True == 1 < {} < [] < '' < '0' < ()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: NoneType() < bool()
It looks like booleans are still implicitly converted to ints though:
code:
>>> 2 > False
True
>>> True + 3j
(1+3j)
There wasn't a boolean type in the language until 2.3 -- True and False were added in 2.2.1 but were just different names for 1 and 0 (look here for details).

Hell, until 3+, you could assign to True and False:
code:
Python 2.7.2+ (default, Jan  7 2012, 07:34:05) 
[GCC 4.6.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> True = []
>>> True.append('butts')
>>> True
['butts']
I don't have any 3.0 or 3.1 installations handy, but that raises a SyntaxError in 3.2.

EDIT: Looks like this was a 3.0 thing: http://docs.python.org/py3k/whatsnew/3.0.html#changed-syntax

Lysidas fucked around with this message at 03:17 on Jan 20, 2012

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
The matrix operations on dict :) python-ideas thread seems to me like it belongs in this thread.

julien tayon posted:

Proposing vector operations on dict, and acknowledging there was an
homeomorphism from rooted n-ary trees to dict, was inducing the
possibility of making matrix of dict / trees.

Since, linear algebrae on dict was coldly welcomed, I waited to have
some code to back me up to push my reasoning furhter, and it happily
worked the way books predicted.


This was the reasoning :
- dict <=> vector
- Vectors + linear algebrae <=> matrix
- Most of Rooted Trees <=> dict( dict( ... ) ) **
- Matrix * Vector = Vector2 <=> Matrix * tree1 = Tree2

The details of the proposal make a surprising amount of mathematical sense, but to me (and everyone who replied on the mailing list) the implementation is bizarre.

julien tayon posted:

Sturla Molden posted:

Why would you want to use a hash table (Python dict) for linear algebra?
* Because it naturally provides matrix. And matrix are an easy way to
formalize and standardize tree manipulations which are a growing
concern in real life computer craft.

* Because actual CS is precise but not exact, and that metrics on
objects enable more exact comparison :

== is the actual way to compare it is precise
, but metrics (cos, norm, dot) enable
is_close_to( Value , modulo error )

For instance no actual langage can tell if two floats are equal,
because, there are error margins.

pi != 3.14159
pi is close to 3.1 [+-.05]

Exactitude and precision are not the same.
:stare: Am I crazy, or does that answer have very little to do with the question?

Sturla Molden posted:

julien tayon posted:

It is stupid to code matrix with an hash, I just say as there is a
strong analogy between dict and vectors,

No there is not. A vector is ordered, a hash-table (dict) is unordered.

- In a vectorlike structure, e.g. a Python list, element i+1 is stored subsequently to element i.

- In a hash-table, e.g. a Python dict, element hash(i+1) is not stored subsequently to element hash(i).

I can see how you can view dicts as a sorted set of key-value pairs in terms of the natural ordering of the keys, but this guy doesn't seem to be able to articulate an answer to "why the hell do you want to do this; if you're going to do linear algebra on sparse matrices why don't you use any of the appropriate SciPy classes that benefit from decades' worth of optimization (e.g. using LAPACK)"

Maybe he's a genius and the joke's on me, but his inability (or unwillingness) to answer simple questions makes me wonder:

julien tayon posted:

Steven D'Aprano posted:

Otherwise, this looks rather like a library of functions looking for a
use. It might help if you demonstrate what concrete problems this helps
you solve.
Since 95% of the functions are method of a dict, I guess, we may call
it an object.

(maybe stealth) EDIT: I should have looked closer at that SciPy page -- one of the sparse matrix types is based on a dictionary of keys. It looks like the main advantages of this type are that they're easy to build, certain matrix operations are fast (e.g. addition), and you can very easily transform them to other SciPy matrix types when you need to do anything more advanced.

I'm starting to think that the only horror is wanting to include a watered-down version of SciPy matrix manipulation in the standard library.

Lysidas fucked around with this message at 18:15 on Feb 8, 2012

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

tef posted:

it sounds like an algorithmic circle jerk :q:

So is that like dining philosphers

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

hobofood posted:

CInt casts as int

I haven't used VB.NET, only VBscript -- does cint still clamp the value to a 16-bit signed integer (i.e. -32768 to 32767)? :suicide:

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Suspicious Dish posted:

the top result for "php mysql tutorial" also has this issue.

This site and page are hilarious.

quote:

Why Would I Want A Database?
  • Banner Rotation. ...
  • Forums. ...
  • Databases. One quite obvious example is sites which get all there information from a database. For example Script Avenue is run by a few scripts, which gain all their information from a large database. All the different script categories can be accessed in one script by just changing the URL to access a different part of the database.
  • Websites. ...

Why would I want a database? Why, to have a database of course! I'd love to have one of those sites which get "all there information from a database". The "Websites" bullet point is actually describing a template system, but it isn't too far off.

I hate this site for the bad writing more than I dislike the horrible technical advice.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
If your boss suggests hiring a second inexperienced code monkey to help the first, show him a clip from the end of Simpsons S05E11 - "Homer the Vigilante" (after the townspeople start to dig for treasure and fail to find anything):

"I guess we're not going to find anything."
"Uh, how are we going to get out of here?"
"We'll dig our way out!"
"No, no, dig up, stupid!"

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

rjmccall posted:

It's trying to lazily generate the list of 9s, but IEEE limits the precision as an optimization so that the implementation can use less memory. Let me unpack that a bit. A real computer has to do arithmetic in fixed chunks of bits, so you have to think of a number as an infinite stream of these chunks of bits. If you've ever done stream programming, you know that it's more efficient to work with streams with buffering on. Since you're constantly finishing with some chunks and needing more, this has to be a circle buffer to keep the GPU up with the memory bus, and you've got a second buffer which is taking the result, which is called double-buffering. It's the size of these buffers that's different when you have a float or a double, got it? So where does this 8 come from? First thing you've got to understand is that, like that dude said on reedit, an integer is really equal to a repeating bunch of nines. Now, in the first version of floating-point numbers, there was this bug when you had a bunch of nines like that, and a couple nines from somewhere else, and you were multiplying them together, and the multiplier would do one multiply and put a chunk into the result buffer, and it would forget that it needed to do a carry on that chunk, so you got 9 * 9 == 81 and it would put down 81 in the buffer and then it would overwrite that 1 with the next 9 which it correctly carried from the next multiplication, see, 99 * 9 == 810 + 81 == 891. If this doesn't make sense, just remember, it's was a bug, right? But they didn't notice right away, because there weren't enough DBAs looking at the problem, so it just stayed in for awhile, and ever since they've had to emulate that bug perfectly because IEEE is a standard and it's supposed to be portable. And the reason the 8's all the way back is because, remember, it's 9s all the way down on the integral side, and you have to multiply them all by the two 9s on the other side, so you've got plenty of places where this bug can show up. Anyway, that's why I do all my currency calculations with regexps, and if you've got a problem with that, just remember, optimization is the way the devil gets ya.

This reads a lot like TimeCube :stare:

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Suspicious Dish posted:

And at least people aren't linking Djikstra on my rear end and calling me human scum this time.

The core Linux kernel developers are extremely competent C programmers, and their views on this subject are pretty informative.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

ToxicFrog posted:

The entire windows command line is a horror. I dare you to figure out consistent rules for wildcard expansion and quoting in that fucker. There aren't any because that isn't always handled by the shell but by the program you're invoking.

Close, but the truth is worse. I'm having a hard time finding a definitive source for this, but everything I've read says that wildcard expansion is handled by the filesystem driver :stonk:

EDIT: This might count as definitive: the FindFirstFile Win32 API function can take a wildcard as its argument. You're correct that programs are free to interpret wildcards themselves (and I bet a depressing number of programs do), but there is a common function available.

Lysidas fucked around with this message at 19:59 on Jul 20, 2012

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Strong Sauce posted:

I'm pretty sure golbez was joking, what with the downs smiley and all.

That, or he was saying that he felt like it was a stupid question as he was asking it -- along the lines of "I feel like I should know this, but ..."

IPython is a fantastic enhancement to Python's REPL. It does a whole lot more, too, but that's most of what I use it for.

Some languages like R are (almost) all REPL. Running a script in "batch mode" is no different than typing each line in sequence, unlike e.g. Python. The Python interactive interpreter behaves a bit differently than when an entire script is parsed in to VM bytecode before executing it.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
Bug #54547: wrong equality of string numbers

quote:

I'm just gonna paste in that PHP Sadness article to show why this is such a big
issue.

According to php language.operators.comparison, the type-coercing comparison
operators will coerce both operands to floats if they both look like numbers,
even if they are both already strings:

If you compare a number with a string or the comparison involves numerical
strings, then each string is converted to a number and the comparison performed
numerically.
This can become especially important in situations where the developer chooses
to use == to compare two values which will always be strings. For example,
consider a simple password checker:

if (md5($password) == $hash) {
print "Allowed!\n";
}

Assume that the $hash is loaded from a known safe string value from a database
and contains a real MD5 hash. Now, suppose the $password is "ximaz", which has
an all-numeric hex-encoded MD5 hash of "61529519452809720693702583126814". When
PHP does the comparison, it will print "Allowed!" for any password which matches
even the first half of the hash:

$ php -r 'var_dump("61529519452809720693702583126814" ==
"61529519452809720000000000000000");'
bool(true)

The solution, of course, is "never use type-coercing comparison operators" - but
this remains an easily-overlooked bug factory for beginning and even
intermediate developers. Some languages solve this situation by having two
separate sets of comparison operators for numeric or string comparisons so that
the developer can be explicit in their intent without needing to manually cast
their arguments.

Comparing two strings and finding that they're tested for numeric equality is utterly ridiculous.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
Poe's Law definitely seems to apply to that.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
Using "months" as a unit of time is enough of a pain that Python's built-in timedelta objects don't support it. timedeltas represent an absolute time duration, and (as was shown in the previous few posts) months don't work that way. The dateutil package's relativedelta object provides this functionality though -- as the name suggests, the duration of time represented by one of these objects is relative to what you're adding it to.

Python code:
In [1]: from dateutil.relativedelta import relativedelta

In [2]: from datetime import date

In [3]: halloween = date(2012, 10, 31)

In [4]: one_month = relativedelta(months=1)

In [5]: halloween - one_month
Out[5]: datetime.date(2012, 9, 30)

In [6]: halloween - 8 * one_month
Out[6]: datetime.date(2012, 2, 29)

In [7]: (halloween - 8 * one_month) - one_month
Out[7]: datetime.date(2012, 1, 29)

In [8]: halloween - 9 * one_month
Out[8]: datetime.date(2012, 1, 31)

In [9]: halloween + one_month
Out[9]: datetime.date(2012, 11, 30)
In my opinion, this is the least painful way to interpret this kind of date manipulation.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Ithaqua posted:

That seems like a great example of code that can easily be refactored to be a lot more descriptive about what the gently caress it's actually doing.

I'd like to see how you can refactor that code to be more descriptive about how it works, given that there are entire papers written about the technique.

Sure, better comments make a world of difference, but attempting to make this code self-documenting is probably a serious waste of time.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

how!! posted:

why would you need to look through commit history to fix a bug? Just fix the bug. I've fixed many bugs, and can't tell you of a single time where I had to look through the history in order to fix it.

When I first started out, I used to do the long, thorough commit message every time. Until I realized its just wasted effort.

Tell me this again after working for a manufacturer of devices that are subject to FDA regulation :allears: "Oh, you found this rare but very serious bug that can destroy patient data? Who introduced it at what time, and what was the next released version that contains the bug?" Management would then talk to the sales team to find all affected customers (since not all of them upgraded the devices' software for every minor version) and we'd cut a hotfix release that was immediately distributed to whoever it affects.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

JetsGuy posted:

True. The larger point I was making was that in scientific programming the only concern is does it work, and beyond that there's not much concern about writing it in a certain "style".

A very important (and often overlooked) corollary to "does it work" is "when it fails, does it do so in an obvious, interpretable way?" The author of the Abandon Matlab blog wrote a pretty thorough post about this.

This is one of the reasons why I dislike the usage of Perl in bioinformatics analysis pipelines -- the language seems to encourage logic that plays fast and loose with data types and correctness of the results. If (for example) I'm adjusting base positions because of a difference in 0-based and 1-based indexing, I want to know right away if there are problems with the input data. If a file is corrupt and I try to add 1 to a string, Perl can happily turn "hello" into "hellp". Python requires you to convert strings to integers first, and you'll receive a very nice ValueError: invalid literal for int() with base 10: 'hello' when you try to do so.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
I use R quite a bit, and have taught some short courses on it for genetics grad students at my university. It's a very neat language; you can get a lot done without much code and the language's syntax is quite flexible. I use it for virtually all of my statistical and numerical analysis; I recently got a lot of use out of the survival and rpart packages.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Suspicious Dish posted:

If you have master based on origin/master and you do "git pull" or "git pull --rebase", it doesn't actually update the origin/master ref, which I found confusing.

Bare git pull does update all remote tracking branches for the remote that you're pulling from. It's git pull origin master that doesn't update the ref.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
On that note, I find it virtually impossible to get any work done without having gitk --all open.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

quiggy posted:

Ah, the server I ran it on is running 2.2 apparently. Welp :v:

Wow. Out of curiosity, what distribution/version? 2.2 was released in 2001 and hasn't had a release since 2003.

That random seed doesn't work on 3.3, incidentally.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
oh PHP :allears:

http://blog.kevburnsjr.com/how-to-prevent-a-leak-like-tumblrs posted:

[UDPATE] Turns out PHP returns 200 when it encounters a fatal error. Inconceivable.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

quote:

From: Sathyanathan, Justin
Sent: Monday, June 17, 2013 6:51 PM
To: 'git@vger.kernel.org'
Subject: RE: GIt error


Hi,

1.Iam getting error attached when cloning of repository is done:



2.Also, when file is tried to be added,it gives error below:

$ git add *
fatal: unable to stat 'src/development_architecture/integration_application_proj
ect_template/provider_archetype/provider_archetype/src/main/resources/archetype-
resources/__rootArtifactId__-data/src/main/java/com/accenture/afpj/sample/skelet
on/visitor/data/VisitorRepositoryJpaImpl.java
': Filename too long

Request you to help to resolve same asap as it is affecting the project.
Regards,
Justin,
-----------------------------------------------------------------------------------------------------
Sun Certified Enterprise Architect for Java EE platform | Certified TA | Java Capability | Accenture- India Delivery Center
AIM: justinsprabhu| +91-9611804388 (m)


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited.

Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy.

______________________________________________________________________________________

https://www.accenture.com

:stare: (emphasis mine)

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
Agreed. I'm amazed by how patient many of the list members are.

I also like the wording and tone of this response:

quote:

Please next time you ask consider doing two things:
  • If you post your message to several groups, take care to mention this fact in each of them.
  • Do not require anyone to do anything "ASAP" unless this claim is backed by your or your employer's wallet.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

QuarkJets posted:

Mathematician code is a million times worse. Here's a psuedocode example of something that I saw recently:

Python code:
#Note: all tabs are actual tabs rather than tab-expanded white space
def myclass(object):
    def __init__(self, a, b, c, d, e, f, g, h, i): 
        self.status = "none"
        if(a == 4):
           self.status = "4"
           return 4
        #other checks.  Also, variables d-f are never used

        if(self.status == "none"): 
            #do something

Variable names like that make sense when you're in the middle of implementing an algorithm from a paper or textbook, but you rename them after you get it working :argh:

e: and you haven't needed to extend object since December 2008 :v:

Lysidas fucked around with this message at 22:35 on Jun 21, 2013

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
I would have mentioned that too, but I figured it was a side effect of you typing pseudocode from memory. That "works" in 2.4 but not 2.6, and I don't have a 2.5 installation handy to see whether it works in that version.

Python code:
Python 2.4.3 (#1, Jan  9 2013, 06:47:03) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Test(object):
...   def __init__(self):
...     return 1
... 
>>> Test()
__main__:1: RuntimeWarning: __init__() should return None
<__main__.Test object at 0x2aba648c5750>
Python code:
Python 2.6.5 (r265:79063, Oct  1 2012, 22:04:36) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Test(object):
...   def __init__(self):
...     return 1
... 
>>> Test()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() should return None, not 'int'
Python code:
Python 3.3.1 (default, Apr 17 2013, 22:30:32) 
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class Test:
...   def __init__(self):
...     return 1
... 
>>> Test()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() should return None, not 'int'

Adbot
ADBOT LOVES YOU

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

QuarkJets posted:

Would the int even be accessible in any way? IE, if I called MyObject(args) would I get an int instances instead of a MyObject instance if that's what the constructor returns? :psyduck:

No; the value returned by __init__ is lost. Remember that all Python functions return None unless you specify otherwise -- if the return value of __init__ was used as the instantiated object you'd get None when creating an instance of any class.

Python __init__ methods are better described as "initializers" than "constructors". You can define a real constructor that returns the wrong thing, if you really want to:

Python code:
>>> class Test:
...   def __new__(cls):
...     return 1
... 
>>> t = Test()
>>> t
1

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply