Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3003 > unrolled thread
| Started by | zildjohn01 <zildjohn01@gmail.com> |
|---|---|
| First post | 2011-04-11 16:17 -0700 |
| Last post | 2011-04-12 11:12 -0400 |
| Articles | 20 on this page of 67 — 29 participants |
Back to article view | Back to comp.lang.python
Feature suggestion -- return if true zildjohn01 <zildjohn01@gmail.com> - 2011-04-11 16:17 -0700
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-12 10:27 +1000
Re: Feature suggestion -- return if true Grant Edwards <invalid@invalid.invalid> - 2011-04-12 01:44 +0000
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-12 12:12 +1000
Re: Feature suggestion -- return if true Grant Edwards <invalid@invalid.invalid> - 2011-04-12 02:18 +0000
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-12 12:44 +1000
Re: Feature suggestion -- return if true Grant Edwards <invalid@invalid.invalid> - 2011-04-12 13:42 +0000
Re: Feature suggestion -- return if true "Martin v. Loewis" <martin@v.loewis.de> - 2011-04-17 12:03 +0200
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-18 09:36 +1000
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-12 12:20 +1000
Re: Feature suggestion -- return if true Zero Piraeus <schesis@gmail.com> - 2011-04-11 22:43 -0400
Re: Feature suggestion -- return if true Chris Angelico <rosuav@gmail.com> - 2011-04-12 12:44 +1000
Re: Feature suggestion -- return if true Chris Angelico <rosuav@gmail.com> - 2011-04-12 12:49 +1000
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-12 12:59 +1000
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-12 13:01 +1000
Re: Feature suggestion -- return if true Nobody <nobody@nowhere.com> - 2011-04-12 07:08 +0100
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-12 16:21 +1000
Re: Feature suggestion -- return if true Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-12 10:52 +0000
Re: Feature suggestion -- return if true scattered <tooscattered@gmail.com> - 2011-04-12 03:55 -0700
Re: Feature suggestion -- return if true "Colin J. Williams" <cjw@ncf.ca> - 2011-04-12 10:01 -0400
Re: Feature suggestion -- return if true Grant Edwards <invalid@invalid.invalid> - 2011-04-12 13:50 +0000
Re: Feature suggestion -- return if true Grant Edwards <invalid@invalid.invalid> - 2011-04-12 13:44 +0000
Re: Feature suggestion -- return if true Westley Martínez <anikom15@gmail.com> - 2011-04-12 07:05 -0700
Re: Feature suggestion -- return if true scattered <tooscattered@gmail.com> - 2011-04-12 07:58 -0700
Re: Feature suggestion -- return if true Westley Martínez <anikom15@gmail.com> - 2011-04-12 15:45 -0700
Re: Feature suggestion -- return if true Chris Angelico <rosuav@gmail.com> - 2011-04-13 08:52 +1000
Re: Feature suggestion -- return if true zildjohn01 <zildjohn01@gmail.com> - 2011-04-12 11:25 -0700
Re: Feature suggestion -- return if true Terry Reedy <tjreedy@udel.edu> - 2011-04-12 15:14 -0400
Re: Feature suggestion -- return if true alex23 <wuwei23@gmail.com> - 2011-04-12 21:05 -0700
Re: Feature suggestion -- return if true Teemu Likonen <tlikonen@iki.fi> - 2011-04-12 21:00 +0300
Re: Feature suggestion -- return if true Ian Kelly <ian.g.kelly@gmail.com> - 2011-04-12 12:25 -0600
Re: Feature suggestion -- return if true Neil Cerutti <neilc@norwich.edu> - 2011-04-12 20:13 +0000
Re: Feature suggestion -- return if true Neil Cerutti <neilc@norwich.edu> - 2011-04-12 20:16 +0000
Re: Feature suggestion -- return if true Ian Kelly <ian.g.kelly@gmail.com> - 2011-04-12 12:29 -0600
Re: Feature suggestion -- return if true Paul Rudin <paul.nospam@rudin.co.uk> - 2011-04-12 19:28 +0100
Re: Feature suggestion -- return if true Chris Rebert <clp2@rebertia.com> - 2011-04-12 13:26 -0700
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-13 08:34 +1000
Re: Feature suggestion -- return if true Ethan Furman <ethan@stoneleaf.us> - 2011-04-12 16:06 -0700
Re: Feature suggestion -- return if true Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-04-21 12:13 +0200
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-13 09:12 +1000
Re: Feature suggestion -- return if true Westley Martínez <anikom15@gmail.com> - 2011-04-12 16:15 -0700
Re: Feature suggestion -- return if true Ethan Furman <ethan@stoneleaf.us> - 2011-04-12 16:48 -0700
Re: Feature suggestion -- return if true Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-13 00:03 +0000
Re: Feature suggestion -- return if true Ethan Furman <ethan@stoneleaf.us> - 2011-04-12 19:42 -0700
Re: Feature suggestion -- return if true Chris Angelico <rosuav@gmail.com> - 2011-04-13 13:00 +1000
Re: Feature suggestion -- return if true James Mills <prologic@shortcircuit.net.au> - 2011-04-13 13:28 +1000
Re: Feature suggestion -- return if true Teemu Likonen <tlikonen@iki.fi> - 2011-04-13 13:58 +0300
Re: Feature suggestion -- return if true Chris Angelico <rosuav@gmail.com> - 2011-04-12 10:46 +1000
Re: Feature suggestion -- return if true Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-17 16:21 +1200
Re: Feature suggestion -- return if true Chris Angelico <rosuav@gmail.com> - 2011-04-17 14:31 +1000
Re: Feature suggestion -- return if true Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-17 08:45 +0000
Re: Feature suggestion -- return if true Chris Angelico <rosuav@gmail.com> - 2011-04-17 19:07 +1000
Re: Feature suggestion -- return if true Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-17 15:23 +0000
Re: Feature suggestion -- return if true Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-18 12:25 +1200
Re: Feature suggestion -- return if true Dave Angel <davea@ieee.org> - 2011-04-17 22:04 -0400
Re: Feature suggestion -- return if true Chris Angelico <rosuav@gmail.com> - 2011-04-18 12:10 +1000
Re: Feature suggestion -- return if true Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-19 12:35 +1200
Re: Feature suggestion -- return if true Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-04-19 09:42 +0300
Re: Feature suggestion -- return if true Chris Angelico <rosuav@gmail.com> - 2011-04-19 17:01 +1000
Re: Feature suggestion -- return if true "D'Arcy J.M. Cain" <darcy@druid.net> - 2011-04-17 08:33 -0400
Re: Feature suggestion -- return if true Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-17 15:10 +0000
Re: Feature suggestion -- return if true aahz@pythoncraft.com (Aahz) - 2011-04-18 09:11 -0700
Re: Feature suggestion -- return if true Greg Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-18 11:09 +1200
Re: Feature suggestion -- return if true Chris Angelico <rosuav@gmail.com> - 2011-04-12 10:51 +1000
Re: Feature suggestion -- return if true Paul Rubin <no.email@nospam.invalid> - 2011-04-11 23:58 -0700
Re: Feature suggestion -- return if true John Roth <johnroth1@gmail.com> - 2011-04-12 06:16 -0700
Re: Feature suggestion -- return if true Mel <mwilson@the-wire.com> - 2011-04-12 11:12 -0400
Page 2 of 4 — ← Prev page 1 [2] 3 4 Next page →
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2011-04-12 13:50 +0000 |
| Message-ID | <io1lav$b5s$3@reader1.panix.com> |
| In reply to | #3028 |
On 2011-04-12, James Mills <prologic@shortcircuit.net.au> wrote:
> On Tue, Apr 12, 2011 at 4:08 PM, Nobody <nobody@nowhere.com> wrote:
>> It should be abundantly clear that this only returns if the expression is
>> considered true, otherwise it continues on to the following statements.
>
> Uggh come on guys. We've been over this.
> You cannot make that assumption.
You most certain can. Try it yourself in an interpreter. The
OP's code snippit will not return if expr is false, rather it will
continue executing in the current context:
>>> def foo(expr):
... __temp__ = expr # these two lines are
... if __temp__: return __temp__ # the OP's code snippet
... print "the code snippet did not return"
...
>>> print foo(9)
9
>>>
>>> print foo(0)
the code snippet did not return
None
>>>
--
Grant Edwards grant.b.edwards Yow! One FISHWICH coming
at up!!
gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2011-04-12 13:44 +0000 |
| Message-ID | <io1kv3$b5s$2@reader1.panix.com> |
| In reply to | #3022 |
On 2011-04-12, James Mills <prologic@shortcircuit.net.au> wrote:
> On Tue, Apr 12, 2011 at 12:44 PM, Chris Angelico <rosuav@gmail.com> wrote:
>> That's still not equivalent. "return expr or None" will always
>> terminate the function. The OP's request was for something which would
>> terminate the function if and only if expr is non-false.
>
> The OP did not state this at all.
> There was never any mention of early termination
> of the function iif expr was True.
The OP said he wanted something with the semantics of
_temp_ = expr
if _temp_: return _temp_
That code snippet does not return if expr is false. What you proposed
returns None when expr is false.
--
Grant Edwards grant.b.edwards Yow! Well, I'm INVISIBLE
at AGAIN ... I might as well
gmail.com pay a visit to the LADIES
ROOM ...
[toc] | [prev] | [next] | [standalone]
| From | Westley Martínez <anikom15@gmail.com> |
|---|---|
| Date | 2011-04-12 07:05 -0700 |
| Message-ID | <mailman.260.1302617154.9059.python-list@python.org> |
| In reply to | #3012 |
On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote:
> On Tue, Apr 12, 2011 at 12:20 PM, James Mills
> <prologic@shortcircuit.net.au> wrote:
> > On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails <jason.swails@gmail.com> wrote:
> >> This is only true if n < 5. Otherwise, the first returns None and the
> >> second returns False.
> >
> > Which is why I said:
> >
> > return expr or None
> >
> > But hey let's argue the point to death!
>
> That's still not equivalent. "return expr or None" will always
> terminate the function. The OP's request was for something which would
> terminate the function if and only if expr is non-false.
>
> Chris Angelico
def bs(x):
while not x:
<modify x>
return x
Am I wrong here?
[toc] | [prev] | [next] | [standalone]
| From | scattered <tooscattered@gmail.com> |
|---|---|
| Date | 2011-04-12 07:58 -0700 |
| Message-ID | <9ed613bb-dfab-490b-9043-706b88846056@bl1g2000vbb.googlegroups.com> |
| In reply to | #3051 |
On Apr 12, 10:05 am, Westley Martínez <aniko...@gmail.com> wrote: > On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote: > > On Tue, Apr 12, 2011 at 12:20 PM, James Mills > > <prolo...@shortcircuit.net.au> wrote: > > > On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails <jason.swa...@gmail.com> wrote: > > >> This is only true if n < 5. Otherwise, the first returns None and the > > >> second returns False. > > > > Which is why I said: > > > > return expr or None > > > > But hey let's argue the point to death! > > > That's still not equivalent. "return expr or None" will always > > terminate the function. The OP's request was for something which would > > terminate the function if and only if expr is non-false. > > > Chris Angelico > > def bs(x): > while not x: > <modify x> > return x > > Am I wrong here?- Hide quoted text - > > - Show quoted text - I don't think that this is equivalent. The OP's original idea doesn't involve a loop, but this does - how could that be equivalent?
[toc] | [prev] | [next] | [standalone]
| From | Westley Martínez <anikom15@gmail.com> |
|---|---|
| Date | 2011-04-12 15:45 -0700 |
| Message-ID | <mailman.287.1302648317.9059.python-list@python.org> |
| In reply to | #3053 |
On Tue, 2011-04-12 at 07:58 -0700, scattered wrote: > On Apr 12, 10:05 am, Westley Martínez <aniko...@gmail.com> wrote: > > On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote: > > > On Tue, Apr 12, 2011 at 12:20 PM, James Mills > > > <prolo...@shortcircuit.net.au> wrote: > > > > On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails <jason.swa...@gmail.com> wrote: > > > >> This is only true if n < 5. Otherwise, the first returns None and the > > > >> second returns False. > > > > > > Which is why I said: > > > > > > return expr or None > > > > > > But hey let's argue the point to death! > > > > > That's still not equivalent. "return expr or None" will always > > > terminate the function. The OP's request was for something which would > > > terminate the function if and only if expr is non-false. > > > > > Chris Angelico > > > > def bs(x): > > while not x: > > <modify x> > > return x > > > > Am I wrong here?- Hide quoted text - > > > > - Show quoted text - > > I don't think that this is equivalent. The OP's original idea doesn't > involve a loop, but this does - how could that be equivalent? Not OP's idea, Angelico's.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-04-13 08:52 +1000 |
| Message-ID | <mailman.290.1302648750.9059.python-list@python.org> |
| In reply to | #3053 |
On Wed, Apr 13, 2011 at 8:45 AM, Westley Martínez <anikom15@gmail.com> wrote: >> I don't think that this is equivalent. The OP's original idea doesn't >> involve a loop, but this does - how could that be equivalent? > > Not OP's idea, Angelico's. I didn't actually advocate a loop, but that method could work too. It all depends on the actual code being executed. I'd still be in favour of shor-circuit Or operators for this, although it does cost readability. Side point: Interesting that I'm referred to by surname here. Seems there's a large number of people here named Chris - fits my theory that geeks are often named Chris, and vice versa! Chris Angelico aka Rosuav
[toc] | [prev] | [next] | [standalone]
| From | zildjohn01 <zildjohn01@gmail.com> |
|---|---|
| Date | 2011-04-12 11:25 -0700 |
| Message-ID | <d1b1ce01-caa4-4a86-b40d-2aaa9830134d@n10g2000yqf.googlegroups.com> |
| In reply to | #3051 |
Wow. Two dozen replies, the majority of which are arguing over whether the end of my snippet is reachable. I thought the behavior of if statements was well-established by this point. Regardless of James Mills's coding prowess, I suppose I should follow his advice and repost this to the python-ideas list instead.
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2011-04-12 15:14 -0400 |
| Message-ID | <mailman.277.1302635684.9059.python-list@python.org> |
| In reply to | #3072 |
On 4/12/2011 2:25 PM, zildjohn01 wrote: > Wow. Two dozen replies, the majority of which are arguing over whether > the end of my snippet is reachable. I thought the behavior of if > statements was well-established by this point. > > Regardless of James Mills's coding prowess, I suppose I should follow > his advice and repost this to the python-ideas list instead. I would not. I am 99.99% sure both the syntax (introducing '?') and the idea will be rejected. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2011-04-12 21:05 -0700 |
| Message-ID | <6effdb35-588f-441b-8fb5-5d1c36d51bc1@d26g2000prn.googlegroups.com> |
| In reply to | #3072 |
zildjohn01 <zildjoh...@gmail.com> wrote: > Regardless of James Mills's coding prowess[...] James is the sole dev of a very handy & elegant event framework: https://bitbucket.org/prologic/circuits/ Can you point out any equivalent achievements so we can compare? And make sure to carry that attitude of smug superiority over to python-ideas, they love it there.
[toc] | [prev] | [next] | [standalone]
| From | Teemu Likonen <tlikonen@iki.fi> |
|---|---|
| Date | 2011-04-12 21:00 +0300 |
| Message-ID | <87k4eze4dl.fsf@mithlond.arda> |
| In reply to | #3008 |
* 2011-04-12T10:27:55+10:00 * James Mills wrote:
> On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 <zildjohn01@gmail.com> wrote:
>> This is an idea I've had bouncing around in my head for a long time
>> now. I propose the following syntax:
>
> Maybe this is more appropriare for the python-ideas list ?
>
>> return? expr
>
> This syntax does not fit well within python ideology.
I'm a simple Lisp guy who wonders if it is be possible to add some kind
of macros to the language. Then features like this could be added by
anybody. Lisp people do this all the time and there is no need for
feature requests or any discussions.
(with-returns
;; some code
(return-if foo)
;; more code
(return-if bar))
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2011-04-12 12:25 -0600 |
| Message-ID | <mailman.271.1302632764.9059.python-list@python.org> |
| In reply to | #3068 |
On Tue, Apr 12, 2011 at 12:00 PM, Teemu Likonen <tlikonen@iki.fi> wrote: > I'm a simple Lisp guy who wonders if it is be possible to add some kind > of macros to the language. Then features like this could be added by > anybody. Lisp people do this all the time and there is no need for > feature requests or any discussions. > > (with-returns > ;; some code > (return-if foo) > ;; more code > (return-if bar)) Flow-control macros were suggested as part of PEP 343, but they were rejected by Guido based on this rant: http://blogs.msdn.com/b/oldnewthing/archive/2005/01/06/347666.aspx
[toc] | [prev] | [next] | [standalone]
| From | Neil Cerutti <neilc@norwich.edu> |
|---|---|
| Date | 2011-04-12 20:13 +0000 |
| Message-ID | <90jq3jFmucU4@mid.individual.net> |
| In reply to | #3073 |
On 2011-04-12, Ian Kelly <ian.g.kelly@gmail.com> wrote: > Flow-control macros were suggested as part of PEP 343, but they > were rejected by Guido based on this rant: > > http://blogs.msdn.com/b/oldnewthing/archive/2005/01/06/347666.aspx Flow control macros don't seem to create problems that exceptions didn't already create. Were context managers in existence at the time? -- Neil Cerutti
[toc] | [prev] | [next] | [standalone]
| From | Neil Cerutti <neilc@norwich.edu> |
|---|---|
| Date | 2011-04-12 20:16 +0000 |
| Message-ID | <90jq9qFebtU1@mid.individual.net> |
| In reply to | #3084 |
On 2011-04-12, Neil Cerutti <neilc@norwich.edu> wrote: > On 2011-04-12, Ian Kelly <ian.g.kelly@gmail.com> wrote: >> Flow-control macros were suggested as part of PEP 343, but >> they were rejected by Guido based on this rant: >> >> http://blogs.msdn.com/b/oldnewthing/archive/2005/01/06/347666.aspx > > Flow control macros don't seem to create problems that > exceptions didn't already create. Were context managers in > existence at the time? Oops! Exceedingly ignorant question considering the actual content of PEP 343. -- Neil Cerutti
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2011-04-12 12:29 -0600 |
| Message-ID | <mailman.272.1302633020.9059.python-list@python.org> |
| In reply to | #3068 |
On Tue, Apr 12, 2011 at 12:25 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote: > On Tue, Apr 12, 2011 at 12:00 PM, Teemu Likonen <tlikonen@iki.fi> wrote: >> I'm a simple Lisp guy who wonders if it is be possible to add some kind >> of macros to the language. Then features like this could be added by >> anybody. Lisp people do this all the time and there is no need for >> feature requests or any discussions. >> >> (with-returns >> ;; some code >> (return-if foo) >> ;; more code >> (return-if bar)) > > Flow-control macros were suggested as part of PEP 343, but they were > rejected by Guido based on this rant: > > http://blogs.msdn.com/b/oldnewthing/archive/2005/01/06/347666.aspx Sorry, that should have been PEP 340, which was rejected in favor of 343.
[toc] | [prev] | [next] | [standalone]
| From | Paul Rudin <paul.nospam@rudin.co.uk> |
|---|---|
| Date | 2011-04-12 19:28 +0100 |
| Message-ID | <87sjtnnx34.fsf@rudin.co.uk> |
| In reply to | #3068 |
Teemu Likonen <tlikonen@iki.fi> writes: > I'm a simple Lisp guy who wonders if it is be possible to add some kind > of macros to the language... As a (now somewhat lapsed) long-time lisp programmer I sympathise with the sentiment, but suspect that it's not going to gain serious traction in python circles.
[toc] | [prev] | [next] | [standalone]
| From | Chris Rebert <clp2@rebertia.com> |
|---|---|
| Date | 2011-04-12 13:26 -0700 |
| Message-ID | <mailman.282.1302640011.9059.python-list@python.org> |
| In reply to | #3068 |
On Tue, Apr 12, 2011 at 11:00 AM, Teemu Likonen <tlikonen@iki.fi> wrote: > * 2011-04-12T10:27:55+10:00 * James Mills wrote: >> On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 <zildjohn01@gmail.com> wrote: >>> This is an idea I've had bouncing around in my head for a long time >>> now. I propose the following syntax: >> >> Maybe this is more appropriare for the python-ideas list ? >> >>> return? expr >> >> This syntax does not fit well within python ideology. > > I'm a simple Lisp guy who wonders if it is be possible to add some kind > of macros to the language. Then features like this could be added by > anybody. Lisp people do this all the time and there is no need for > feature requests or any discussions. I think Ben "Yahtzee" Croshaw's comments on open-world sandbox video games (of all things) have a lot of applicability to why allowing full-on macros can be a bad idea. Paraphrasing liberally from his review of Far Cry 2: "Letting the [programmer] create their own [language constructs is] always done at the expense of proper [orthogonality, elegance, and coherence]. Maybe sometimes I don't want to create my own [programming language] experience. Maybe I want to have an experience that's been carefully crafted by professional [language] designers and [architects]. But [a] delusion has arisen that absolutely anyone can contribute something valid, regardless of qualifications. In TV news for example, you'll often see them pause to hear the opinion of a seventy-five-year-old housebound racist from Lemington. And now you get [languages] like [Lisp] that rely heavily on user-made [language constructs]. Which I prophesise doom for, because most people are not [language] designers, and you're just going to end up with oceans of slurry, as indeed we have. It's like giving someone a stack of paper and a [pen] and claiming that that's as good as the latest [New York Times] bestseller." IOW, a language is usually better for having such discussions and having a fairly coherent worldview enforced by the existence of a managing authority. Cheers, Chris -- http://blog.rebertia.com
[toc] | [prev] | [next] | [standalone]
| From | James Mills <prologic@shortcircuit.net.au> |
|---|---|
| Date | 2011-04-13 08:34 +1000 |
| Message-ID | <mailman.286.1302647690.9059.python-list@python.org> |
| In reply to | #3068 |
On Wed, Apr 13, 2011 at 6:26 AM, Chris Rebert <clp2@rebertia.com> wrote: > Paraphrasing liberally from his review of Far Cry 2: > "Letting the [programmer] create their own [language constructs is] > always done at the expense of proper [orthogonality, elegance, and > coherence]. Maybe sometimes I don't want to create my own [programming > language] experience. Maybe I want to have an experience that's been > carefully crafted by professional [language] designers and > [architects]. But [a] delusion has arisen that absolutely anyone can > contribute something valid, regardless of qualifications. In TV news > for example, you'll often see them pause to hear the opinion of a > seventy-five-year-old housebound racist from Lemington. And now you > get [languages] like [Lisp] that rely heavily on user-made [language > constructs]. Which I prophesise doom for, because most people are not > [language] designers, and you're just going to end up with oceans of > slurry, as indeed we have. It's like giving someone a stack of paper > and a [pen] and claiming that that's as good as the latest [New York > Times] bestseller." > > IOW, a language is usually better for having such discussions and > having a fairly coherent worldview enforced by the existence of a > managing authority. Are we done with this discussion yet ? :) *sigh* It was a slow day yesterday and I have a funny feeling it's going to be the same today! Regardless of anyone's subjective opinions as to what was clear - I still stand by what I said. Nice comments btw Chris :) cheers James -- -- James Mills -- -- "Problems are solved by method"
[toc] | [prev] | [next] | [standalone]
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2011-04-12 16:06 -0700 |
| Message-ID | <mailman.291.1302648982.9059.python-list@python.org> |
| In reply to | #3068 |
James Mills wrote:
> Are we done with this discussion yet ? :)
> *sigh* It was a slow day yesterday and I have
> a funny feeling it's going to be the same today!
>
> Regardless of anyone's subjective opinions as to what
> was clear - I still stand by what I said.
I think I see your point -- the OP said:
--> _temp = expr
--> if _temp: return _temp
which is where you're getting
--> return _temp or None
However, most everyone ('cept you, it seems! ;) understood that there
would be more lines of code such that if bool(expr) == False no return
is executed and the function keeps going merrily along. Like this:
--> def func():
--> var1 = something()
--> var2 = something_else('this')
--> return? var1.hobgle(var2)
--> var3 = last_resort(var1)
--> return var3.wiglat(var2)
Looking back at the whole post now, I see nothing there to concretely
make that point except the question mark on the return.
Hope this helps.
~Ethan~
[toc] | [prev] | [next] | [standalone]
| From | Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> |
|---|---|
| Date | 2011-04-21 12:13 +0200 |
| Message-ID | <iop00o$b57$1@r03.glglgl.eu> |
| In reply to | #3097 |
Am 13.04.2011 01:06, schrieb Ethan Furman:
> --> def func():
> --> var1 = something()
> --> var2 = something_else('this')
> --> return? var1.hobgle(var2)
> --> var3 = last_resort(var1)
> --> return var3.wiglat(var2)
This makes me think of a decorator which can mimic the wantend behaviour:
def getfirst(f):
from functools import wraps
@wraps(f)
def func(*a, **k):
for i in f(*a, **k):
if i: return i
return func
# [BTW: a kind of "return decorator" would be nice here ;-)]
@getfirst
def func():
var1 = something()
var2 = something_else('this')
yield var1.hobgle(var2)
var3 = last_resort(var1)
yield var3.wiglat(var2)
yield "Even that did not work."
This has the advantage of being flexible about which condition to
evaluate: maybe the func does return tuples of which only the 2nd part
is relevant concerning the check. Then just do
def getfirst(f):
from functools import wraps
@wraps(f)
def func(*a, **k):
for i in f(*a, **k):
if i[1]: return i
return func
@getfirst
def func():
var1 = something()
var2 = something_else('this')
yield "first try", var1.hobgle(var2)
var3 = last_resort(var1)
yield "second try", var3.wiglat(var2)
yield "default value", "Even that did not work."
Disclaimer: Untested, but you should get the idea.
Thomas
[toc] | [prev] | [next] | [standalone]
| From | James Mills <prologic@shortcircuit.net.au> |
|---|---|
| Date | 2011-04-13 09:12 +1000 |
| Message-ID | <mailman.293.1302649963.9059.python-list@python.org> |
| In reply to | #3068 |
On Wed, Apr 13, 2011 at 9:06 AM, Ethan Furman <ethan@stoneleaf.us> wrote:
> I think I see your point -- the OP said:
> --> _temp = expr
> --> if _temp: return _temp
>
> which is where you're getting
> --> return _temp or None
>
> However, most everyone ('cept you, it seems! ;) understood that there would
> be more lines of code such that if bool(expr) == False no return is executed
> and the function keeps going merrily along. Like this:
> --> def func():
> --> var1 = something()
> --> var2 = something_else('this')
> --> return? var1.hobgle(var2)
> --> var3 = last_resort(var1)
> --> return var3.wiglat(var2)
>
>
> Looking back at the whole post now, I see nothing there to concretely make
> that point except the question mark on the return.
Ethan I actually really appreciate your comments. Thank you!
Yes I do understand there is probably more code that
follows the return? - but I made an assumption and I'm
not going back on it :)
Thanks for making the two sides obviously clear!
cheers
James
--
-- James Mills
--
-- "Problems are solved by method"
[toc] | [prev] | [next] | [standalone]
Page 2 of 4 — ← Prev page 1 [2] 3 4 Next page →
Back to top | Article view | comp.lang.python
csiph-web