Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Keep-trying-until-it-works

Name: Anonymous 2011-04-23 0:42

Due to lack of gotos, this is the shortest way I can come up with to tell python to keep doing something until it actually works (in my case, loading a webpage) is this:

tempvar = 1
while tempvar == 1:
    try:
        <stuff that will either work or cause an exception>
        tempvar = 0
    except:
        pass


in c++ i could just

lbl: try{stuff} catch {goto lbl;}

better way?

Name: !89o8tyI8Nk 2011-04-23 0:49

EXPERT PROGRAMMERS already know any potential scenarios during which an exception will be generated, and thus, try-catch-goto is inefficient and for fucking BEGINNERS.

Name: Anonymous 2011-04-23 0:52

that's the best way to do it, friend.

Name: Anonymous 2011-04-23 0:56

he uses exceptions in c++
fucking java programmers

Name: Anonymous 2011-04-23 1:17

>>4

What's the matter, too enterprise for you?

Name: Anonymous 2011-04-23 1:33

RAII is preferred over explicit exception handling in C++ due to the nature of how stack unrolling is implemented.

Furthermore, you should never use exception handling to communicate an expected error state such as an HTTP 404 response on an HTTP socket connection--that should be handled by return codes in C++.

Name: Anonymous 2011-04-23 1:42

>>6
First of all, bitch, it's STACK UNWINDING, not fucking stack unrolling.  You stupid fuck.  Second, I WILL FUCKING USE EXCEPTIONS ALL I WANT.  I WILL USE THEM 20 TIMES PER FUNCTION AND NEST TRY BLOCKS OVER 9000 TIMES.  YOU CAN FUQIN SUCK MY DICK, CUNTFAG, GODFUCKINGDAMN.

Name: not >>6 2011-04-23 1:47

>>7
You're free to use what you want, but you should keep in mind that exceptions are very slow, especially if used for mundane stuff. Common exception implementations will eventually thunk to kernel mode and cause context switches. If you use a debugger, multiply that slowdown by another large amount. Exceptions are not lightweight (compared to their local equivalent: goto).
THis doesn't mean that error handling should be performed by goto, just that exceptions should not be used to pass mundane non-abnormal behavior information around, especially if it's something you do often.

Name: Anonymous 2011-04-23 1:51

>>7
It's people like you who are the cause of all of today's bloatware. Go get fucked.

Name: Anonymous 2011-04-23 1:55

>>7
Exceptions? Like "out of place calls?"
out of normal run-time?
Dood, optimise your thinking. Go take some LSD. or some E. Seriously. It helped me expand my programming boundaries. I'm not BSing you.
AND also you could simply use FUNCTIONS? Maybe? Will that help? Or use Classes if applicable? I think both of those are avail in C++ (topic)?

Name: Anonymous 2011-04-23 1:56

Speaking of Topic-
>>1
You're doing it wrong. Feed the data of the loaded page TO python via pipes. :) .

Name: !89o8tyI8Nk 2011-04-23 1:58

>>7

u mad?

u mad.

Name: Anonymous 2011-04-23 2:00

You want to make sure it's really actually E that you're taking tho! You're, sadly enough, safer taking LSD probably. :) :D ... MADE IN THE USA, MOFOS! HAHAHhahahaa :D

Name: Anonymous 2011-04-23 2:02

"Don't use exceptions for expected conditions" always sounds a lot like "we didn't really design for exceptions so if you throw one you'll probably crash the program / leak memory / corrupt data, so only do it if you pretty much have to crash anyway".  Is there any justification for this ‘principle’?

Name: EVER SINCE 2011-04-23 2:04

Ever since they killed the site WAY BACK WHEN with the user reviews of pills, there has been no safe look-up to know what press is worth a shit. LET ME Clarify that- don't take Extasy now bkus u cannot verify it (short of using strips - use your own strips you can verify :).

Name: Anonymous 2011-04-23 2:04

This is pretty weird. Keep trying it until it works? What if it never works? You would want to have some kind of limit.

Name: Anonymous 2011-04-23 2:06

>>14
Yes there is usually a way to clear it up. That's why they say that.
*witness*

Name: Anonymous 2011-04-23 2:07

>>16
no dont beat your head against a wall.
"those who try again & again without a change are retarded" ~ Or something like that.

Name: >>8 2011-04-23 2:10

>>9
I do? How? My software is pretty fast and lean. I even warned the person what are the pitfalls when using exception handling, especially native one.
>>10
I don't even know what you're talking about.
>>12
Huh? You have to try harder 0/10. Why would I be upset about what other people choose to do with their own code, especially if I'm not the one working on it? back to /b/.

Name: Anonymous 2011-04-23 2:12

>>19
Then WRRRYYYYYY r u evn ON here?
Yes ---- to /b with u! :P

Name: Anonymous 2011-04-23 3:11

I use exceptions and setjmp all over the code, because C++ doesn't allow continuations and I hate it. The more problematic C++ programs are, the sooner C++ will die. If you hate your language, write the worst code possible.

Name: Anonymous 2011-04-23 3:14

Also, I've `map` and `fold` functions in C++. They return their result using circular buffers of global variables and take macros instead of lambdas, so no need for GC.

Name: Anonymous 2011-04-23 3:17

For a greater effect I preprocess C++ code with `m4` and `sed`.If it was hard to write it should be hard to understand.

Name: Anonymous 2011-04-23 3:18

>>21
You can implement light-weight continuations in C++ use OS-specific fibers.

>>22
I have map and fold functions that communicate results via wait-free/lock-free queues associated with the current task context.

Name: Anonymous 2011-04-23 3:22

>>24
Yes. And they return it using exception handling mechanism, that is generated by m4.

Name: Anonymous 2011-04-23 3:23

>>24
In fact, if you look at the runtime source code for your favourite functional language, you'll see that many of them use the same underlying OS specific fiber APIs to implement continuations.

Name: Anonymous 2011-04-23 3:23

BTW, never use templates because #define is enough.

Name: Anonymous 2011-04-23 3:25

even better: never use #define, just copy-paste expanded versions everywhere.

Name: Anonymous 2011-04-23 3:27

>>28
If somebody ask you, what the hell are you doing, just say that you havent noticed similiarities.

Name: Anonymous 2011-04-23 3:30

And never use functions where you can inline them into single big routine of 10 pages of code. I once wrote a 2000 lines C++ program consisting of a single main() with a bunch of gotoes (work like continuations!).

Name: Anonymous 2011-04-23 5:44

>>16
It's a script to gather data that's going to have to run for days.  Whether it crashes or hangs forever trying to continuously reload a page doesn't really make a difference.  At least if it keeps trying there's a chance it'll come back to life.

Name: Anonymous 2011-04-23 6:30

Name: Anonymous 2011-04-23 6:41

>>31
In CL, this would be written as:
(loop (ignore-errors (yourcode)))

Name: Anonymous 2011-04-23 6:48

How about:

while True:
  # herp
  if condition:
    # derp
    break


...?


I'm not a pythonist, so sorry if syntax sucks.

Name: Guido van Rossum !GO9STjdhn2!LeWQGdzAW+mR5bL 2011-04-23 6:50

>>34
That was Pythonic!

Name: Anonymous 2011-04-23 6:51

>>34
lbl: try{stuff} catch {goto lbl;} still more elegant.

Name: Anonymous 2011-04-23 6:51

In JavaScript:

while (true) {
  try {
    // yo'ure koed ehre
  } catch (e) {
    continue;
  }
}

Name: >>34 2011-04-23 6:54

>>36
What part of "I'm not a pythonist" is too hard for you to comprehend? Or do you just like to make yourself feel better by trolling randomly?

Python sucks; we all know that. There's no need to piss on me for making a simple suggestion.

Name: Guido van Rossum !GO9STjdhn2!LeWQGdzAW+mR5bL 2011-04-23 7:04

>>38
I was just pointing out the remarkable quality of the boilerplate Python forces you to write for a so-simple task.
I'm sorry if you took that as an insult to your person, I'm sure you're a respectable member of our society that works hard to make the world a better place, my comment was not meant to offend you!

Name: Anonymous 2011-04-23 11:20

YOU CAN STEAL MY FARTS, BUT YOU CAN'T STEAL MY GNU FREEDOM!

Name: Anonymous 2011-04-23 11:37

>>40
YOU CAN CUM IN YOUR MOTHER'S ROTTEN PUSSY AND SUCK AND SWALLOW SHIT FROM HER ANUS, BUT YOU CAN'T STOP POSTING USELESS STUPIDITY THAT NOBODY CARES ABOUT!

Name: Anonymous 2011-04-23 14:11

OVER 20LBS OF PUSSY AND ASS!!!

Name: Anonymous 2011-04-23 14:24

I TYPE IN BOLD TEXT

Name: Anonymous 2011-04-23 15:02

I TYPE IN BOLD TEXT

Name: Anonymous 2011-04-23 15:05

[o][b][u]I TYPE IN BBCODE[/u][/b][/o]

Name: Anonymous 2011-04-23 15:07

>>42
Fuck off, shitposter. I can't even be bothered using BBCode anymore.

Name: Anonymous 2011-04-23 15:25

>>20
FUCK OFF, SHITPOSTER.

Name: Anonymous 2011-04-23 19:20

while (!@func());
PHP

Name: !5E3nN0p1F2!a1uzMeFZoxIYYz+ 2011-04-23 21:07

NIGGERS!

Name: Anonymous 2011-04-23 21:10

someone in here last night was trying to do something in Python that should have been done outside of the PY app. Did they get that cleared up, I wonder?

Don't change these.
Name: Email:
Entire Thread Thread List