|
singletons are to globals as flow-control exceptions are to GOTODirk Pitt posted:Wat? nice stealth edit
|
# ¿ Jun 18, 2013 21:51 |
|
|
# ¿ May 10, 2024 05:53 |
|
Dirk Pitt posted:Didn't mean to ghost edit. I agree with your post. Just frustrated my team sees anything more advanced than a 'systemcontext' singleton as "too complicated." it's all right, I stealth-edit pretty much every post I make. just thought it was funny that I spotted yours. everyone is welcome here
|
# ¿ Jun 18, 2013 22:50 |
|
OBAMA BIN LinkedIn posted:c++ owns you rear end burgers and if you disagree you need to get the gently caress out forever. jk this is the terrible programmer safe zone, you're welcome to post here. some sick burns itt
|
# ¿ Jun 22, 2013 00:46 |
|
dur posted:this client has terrible data so today i wrote a bad script to count annotations with bad geometry backseat scriptin' code:
hth fakeedit: this is a bad post but w/e
|
# ¿ Jun 26, 2013 00:35 |
|
polpotpi posted:java is the only language versatile enough to be used on the fronted and backend. the goddamn internet runs on java. you can get paid to write code in java. dur posted:python owns
|
# ¿ Jun 28, 2013 00:59 |
|
yeah basically that behavior is to discourage people from using/modifying nonlocal variables without being very explicit about it, to help avoid confusion about where exactly symbols are coming from (confusion on the part of maintainers, not the machine) the same thing happens if you try to assign to a global variable within a function (but lol if you use global variables) in both cases, python (3, the one true python) provides a way to explicitly specify nonlocal variables that you're going to modify within an inner scope: "nonlocal foo[, bar[, baz...]]" (or in the case of globals, 'global foo' etc) it's slightly counterintuitive when you first run into it, but I can see why they did it re the lambda example: we actually had a thread about closures & such a few months back. might have had a discussion in this very thread, I forget. anyway, if memory serves, you can get the behavior you want by doing something like code:
code:
I like closures I like python PleasingFungus fucked around with this message at 17:34 on Jul 18, 2013 |
# ¿ Jul 18, 2013 17:31 |
|
dur posted:i wrote some python today, can y'all tell me how bad it is (it's bad because it's python but i mean besides that) honestly, it looks generally fine. not familiar with arcpy, but nothing there looks obviously wrong. I'd probably rewrite getValueList() as: Python code:
|
# ¿ Jul 23, 2013 23:19 |
|
prefect posted:i think that looks pretty cool, but i am also fond of perl, so you might want to reconsider that code eh, it's pretty idiomatic. grab an iterator, map a single function on it, feed that into a set and then into a list. it's admittedly borderline - one more operation, and I'd definitely want to split it onto multiple lines - but I think it's ok. actually, on further consideration, this is probably about right: Python code:
|
# ¿ Jul 23, 2013 23:25 |
|
Jerry SanDisky posted:can you just use a set comprehension on that first line? yes, I literally did two posts up from the one you quoted. but then I decided that it was too many things going on in one line, and split it up to make it easier to read. dur's original code was Python code:
Java code:
Java code:
|
# ¿ Jul 24, 2013 00:33 |
|
just noticed something else:Python code:
actually, now that I'm looking at it Python code:
honestly I just like playing with python and list comprehensions. I admit it. Jerry SanDisky posted:no, calling set() on a list comprehension is not a set comprehension o oops yeah, that's a reasonable tweak
|
# ¿ Jul 24, 2013 00:42 |
|
tef posted:(ps technically he called it on a generator comprehension). I thought that at first, but then I noticed this bit Python code:
you could rewrite that bit, but I was trying for a minimum-impact change. tef posted:ps should i make a smart dog book thread in CoC and then argue about stuff? yes then link it here or in the other programming thread
|
# ¿ Jul 24, 2013 00:45 |
|
Jerry SanDisky posted:why am i so loving bad at python you got that backwards, the set comprehension is orders of magnitude slower per your numbers gently caress if I know why, though Shaggar posted:switch 2 java or c# ftw
|
# ¿ Jul 24, 2013 00:56 |
|
Jerry SanDisky posted:foo_comp uses the set comprehension, foo_set uses the set() builtin. they both ran 100k times and foo_comp took 13 seconds less?? oh, I was misreading it. I think I might just be really bad at reading your posts.
|
# ¿ Jul 24, 2013 01:08 |
|
PleasingFungus posted:I think I might just be really bad.
|
# ¿ Jul 24, 2013 01:09 |
|
dur posted:well the selectlayerbyattributes query needs things to be in parenthesis, not square brackets. that's how someone else on the arcgis.com forums did it so i stole it. that is extremely silly, and certainly bad practice, but I can't bring myself to be upset about it. (the teddy in your av probably helps. ) the post you quoted suggests one way to be a little more explicit about what you're doing vis-a-vis string formatting: Python code:
|
# ¿ Jul 24, 2013 01:38 |
|
Shinku ABOOKEN posted:as someone who doesn't use python that syntax looks awful as someone who uses python & loves list comprehensions, I am baffled and faintly horrified. that code is incomprehensible. I'll second the question re indentation.
|
# ¿ Jul 24, 2013 04:40 |
|
googling finds context: it's a fragment of a program that solves the Zebra Puzzle specifically, it's a fragment of one of these programs; though notably, these two are also both incomplete. still looking at indentation. I tried a few different variants, but they were clearly both (a) wrong and (b) broke tables. PleasingFungus fucked around with this message at 04:54 on Jul 24, 2013 |
# ¿ Jul 24, 2013 04:50 |
|
okay, got it, maybe. it iterates over assignments of (house number) permutations to elements, filtering out impossibilities at each stage; at the end, an iterator is returned that only yields one element, the solution.Python code:
in the end, a pruned subset of P(5)^5 = ~25E9 possibilities are examined; the code is from an attempt to minimize on possibilities examined. that only took 35 minutes to figure out. good code!
|
# ¿ Jul 24, 2013 05:15 |
|
sorry it's worth noting that the explanation in my last post is still wrong, I... think. the conditionals are definitely being evaluated top-to-bottom, but something is traveling bottom-to-top; otherwise how did (WATER, ZEBRA) get into the innermost loop? functional programming is hard
|
# ¿ Jul 24, 2013 05:34 |
|
dur posted:holy gently caress dude and here I thought I was just sperging about Proper Usage! super glad I could help.
|
# ¿ Jul 24, 2013 22:54 |
|
MeruFM posted:This is definitely the most complex a single list comprehension should be I don't understand. why include the conditional check if it's always going to return True?
|
# ¿ Jul 24, 2013 22:55 |
|
some day I will work in a company with a rich testing environment that day is not today
|
# ¿ Jul 25, 2013 03:19 |
|
wait, you're the guy who claims that java/python/etc aren't "real programming languages" (as opposed to esoteric academic functional languages, aka, all functional languages) your opinions are a very strange mix.
|
# ¿ Jul 25, 2013 05:24 |
|
FamDav posted:gently caress all of you hey hey hey hey rude
|
# ¿ Jul 25, 2013 21:22 |
|
Symbolic Butt posted:I think I use way too much breaks and continues in my code. this seems improbable
|
# ¿ Aug 26, 2013 23:05 |
|
Shaggar posted:altho that's some serious p-langer syntax so whatever it is probably cant even do transactions. the style is unusual for the language, but I think it might actually be c++ syntax. don't know any other language that has both arrows and double-colon operators. JewKiller 3000 posted:he does it once in a while to make the other posts more believable lol if you haven't realized shaggar is the best poster in yospos
|
# ¿ Aug 27, 2013 17:25 |
|
Mr SuperAwesome posted:like C works great when you create a load of structures so you can use dot notation and stuff and basically make it like a normal language, apart from everything being really linuxy and stupid and lets stick some control characters all over the place to read and write poo poo thats a good idea. c is portable assembly set your expectations accordingly
|
# ¿ Sep 3, 2013 17:00 |
|
Shaggar posted:nothing soothes my autism like good data design
|
# ¿ Sep 18, 2013 20:25 |
|
I never worked with SQL long enough to develop a good intuition for joins. that'll probably bite me in the rear end someday. rip.
|
# ¿ Sep 19, 2013 00:53 |
|
Bloody posted:you wanna know an awful lang? oh my god
|
# ¿ Sep 22, 2013 16:47 |
|
Zlodo posted:its not "worrying about stack allocation details", its being able to say "pass this thing by value because i know its small" and even if at high level you dont necessarily have to care being able to pass value types around efficiently is the difference between "wee lets use option types everywhere bc its neat and almost free" and "better be careful not to overuse those because theyre pointlessly slow" 'why isn't Java C?'
|
# ¿ Sep 23, 2013 22:00 |
|
Zlodo posted:profiling is useful when considering an optimization that comes at a cost of your program's readability/maintainability/flexibility/stability which is not what is being discussed here except that, in java, allocating objects on the heap is both natural, easy to read, and correct. this is because Java is not C. like any optimization, arguing that objects should be allocated on the stack is a decision that should be handled case-by-case and justified by profiling. it is not a default. because Java is not C.
|
# ¿ Sep 23, 2013 23:41 |
|
FamDav posted:are you telling me that this mostly java that's correct. the contents of variables a are b are not swapped by that code. going back to jewkiller's post: code:
code:
this is something that fucks beginners up pretty often.
|
# ¿ Sep 24, 2013 21:46 |
|
Pollyanna posted:ummmm idk i guess its frustrating trying to get a gui going in python cause there's no great choice out there but also i dunno what to do next, sure there's django n poo poo but im not really a web developer/database admin. most things seem oriented to web development this days in fact I always used tkinter back when I was doing python gui stuff. anything you make with tkinter will be incredibly ugly but it's pretty easy to get going iirc. (IDLE is a fine tkinter product, if you want an example of tkinter-ugly.)
|
# ¿ Sep 26, 2013 00:21 |
|
Pollyanna posted:okay, that makes sense. i get that objects n methods are good for simulating irl circumstances but how does that translate to a broader programming perspective, like for example how would you use oop for abstract things like an IM client? what would a typical class be in that regard? something like class Message? sure. let's look at an im client. say it has a class Window, which represents an open chat window. Let's give it a TextInputField, a Scrollbar, and a list of Messages. The Messages have an author and some text for the actual message... basically, the idea is that you break things down into natural components, and nest them inside each other, so that you can more easily abstract what's going on. the ConversationDisplay doesn't really know anything about what's going on inside the Messages; all it does is ask them how much space they need & then position them accordingly. likewise, the Messages don't know what they're being used for; for all they know, they could be displayed in a corner-of-the-screen notification bubble. everything is split up to be as simple as possible so you don't have to worry how everything combines with everything else; each class only has to deal with its own area of concern. classes are, in the end, a tool for making programs easier to understand.
|
# ¿ Sep 26, 2013 01:08 |
|
sulk rackin' up the wrongposts like there's no tomorrow
|
# ¿ Sep 26, 2013 02:59 |
|
Nomnom Cookie posted:java will complain if you do stuff with null (nil). objc is more laid back and just lets the nil propagate to somewhere a user can see it. whaaaa
|
# ¿ Sep 26, 2013 18:26 |
|
Shinku ABOOKEN posted:shamezone lolllll
|
# ¿ Oct 1, 2013 16:15 |
|
Soricidus posted:You can't even just implement a well-known algorithm yourself because you can't trust the compiler. this is a funny troll
|
# ¿ Oct 18, 2013 22:54 |
|
|
# ¿ May 10, 2024 05:53 |
|
Shinku ABOOKEN posted:is azure a comedy option or legit good? http://www.techweekeurope.co.uk/news/microsoft-azure-fail-security-certificates-109344?ModPagespeed=noscript quote:Everything went according to plan for the Azure storage service – except for one thing. On 7 January, the team renewed the three certificates, for Windows Azure Storage Blobs, Tables and Queues, and created a new build of the services, which they then deployed. result: entire azure service goes down for twelve hours, for the second year in a row. idk if it's any good but it'd def. the comedy option.
|
# ¿ Oct 22, 2013 19:15 |