Re: Feature suggestion -- return if true
zildjohn01 writes: > _temp = expr > if _temp: return _temp I'm trying to figure out a context where you'd even want that, and I'm thinking that maybe it's some version of a repeat-until loop? Python doesn't have repeat-until and it's been proposed a few times. -- http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents
[email protected] wrote: Do I have your permission to quote your reply intact in threads where the patent, etc, issues arise, and they often do on other sites. TIA... Feel free, the more folks we have dialoging about this issue, the better for everyone who values freedom. -- http://mail.python.org/mailman/listinfo/python-list
Hello Friends
The most sexiest collection of bollywood. just visit www.hottesthitsbollywood.blogspot.com www.bollywoodhotactresspicz.blogspot.com www.bollywoodhotphotoz.blogspot.com www.bollywoodhotactresswallpapers.blogspot.com www.bollywoodhotwallpaperz.blogspot.com www.onlineshoppingpk.blogspot.com www.bollywoodhotpik.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
geremy condra wrote: Software is another sort of animal entirely. Because software is not just > based on mathematics--- IT IS mathematics. I am extremely skeptical of this argument. ... as are a great number of other people; corporations, lawyers, venture capitalists, SPAM SPAM SPAM... That is what made the last Supreme Court decision (from this argument in part) so important... because for the first time the U.S. Supreme Court is beginning to buy it ... in part. See Groklaw here if you're not familiar with the issue: http://www.groklaw.net/staticpages/index.php?page=2009022607324398 In this case, the court left software patents intact for the moment, but they slammed the door shut on Bilski... and the interesting thing here is that what Bilski was claiming to have invented is similar is most respects to all other "software idea patents," and for similar mathematical reasoning. It was a slam dunk, by the way... here is a block quote from Groklaw you might find interesting: = block quote = If you are a lawyer wondering why some argue that software is mathematics, and hence ineligible for patent protection, or are just interested to know why software developers, particularly those who develop Free and Open Source software, almost to a man oppose software patents, you might enjoy reading Groklaw's An Explanation of Computation Theory for Lawyers, as well as the amicus briefs and articles marked with the discreet red stars [*], below. Donald Knuth, called the "father" of the analysis of algorithms, stated: "Basically I remain convinced that the patent policy most fair and most suitable for the world will regard mathematical ideas (such as algorithms) to be not subject to proprietary patent rights." Also, there is a 30-minute movie, Patent Absurdity: How software patents broke the system, which explains it well. =/block quote= it isn't clear to me that software and computation are synonymous. Lambda calculus only models computation, and software has real properties in implementation that are strictly dependent on the physical world (see above) I think it's quite reasonable to contend that the existence of lambda calculus no more rules out the applicability of patents to software (which I detest) than it rules out the applicability of patents to hardware (which I find only slightly less ridiculous) or other meatspace inventions. The difference is that while hardware may be "described" by mathematics (all of it is, actually) software IS the description. You know this to be true, because you prove it everyday... yourself. How many times have you had a problem, and rather than sit down with your pad of paper and a slide rule (or your TI-89 Platinum) YOU solved the problem right there on the screen... er, I mean... the machine solved the problem for you, uh, after you wrote out the symbols ... ??? We don't think out our problems on paper much these days... we just enter them into the 'ol terminal and play with it there... frankly, that is what appeals to me with languages like Python, Haskell, and Erlang... they are my research engines ... they take the place of paper and pencil and slide rule and calculator (and counting on ones fingers) ... but its still little 'ol me doing the thinking... the days of doing multiple differential equations on a black-board (or white board) are long gone for most of us. The handwriting is on the wall (not so much wishful thinking as just noting that everyone including Supreme Court justices are beginning to get it). It is equally important that *all* software engineers and FOSS developers *get it!* We need everyone on board with this... really... the time is critical for everyone to understand this... what is actually at stake is freedom... what we need to focus on is ending software patents forever... now. kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents
rusi wrote:
From
http://www.cse.uconn.edu/~dqg/papers/cie05.pdf
may be of interest (and also other papers of Peter Wegner questioning
the universality of Turing machines lambda calculus etc)
This is very interesting indeed.
see: http://en.wikipedia.org/wiki/Lambda_calculus
This block quote below is sited from the above link... and gets at
my point in a simple way... but the remaining article is worth a read
too. This goes somewhat beyond the simple single taped Turing machine
concept. We are not talking about the 'universality' of the machine...
only that the software running in the machine is 'equivalent' to the
lambda calculus.
Software itself (the source symbols specifically) can be argued to
be nothing more nor less than another form of the symbols themselves
used in the lambda calculus. In fact, we ought to be able to build an
interpreter for reading and running lambda notation, or translating pure
lambda notations into any source lang we desire. Why not?
see also, for interest only:
http://lambda-the-ultimate.org/node/1490
=block quote=
Lambda calculus and programming languages
As pointed out by Peter Landin's 1965 paper A Correspondence between
ALGOL 60 and Church's Lambda-notation, sequential procedural programming
languages can be understood in terms of the lambda calculus, which
provides the basic mechanisms for procedural abstraction and procedure
(subprogram) application.
Lambda calculus reifies "functions" and makes them first-class objects,
which raises implementation complexity when implementing lambda
calculus. A particular challenge is related to the support of
higher-order functions, also known as the Funarg problem. Lambda
calculus is usually implemented using a virtual machine approach. The
first practical implementation of lambda calculus was provided in 1963
by Peter Landin, and is known as the SECD machine. Since then, several
optimized abstract machines for lambda calculus were suggested, such as
the G-machine[12] and the categorical abstract machine.
The most prominent counterparts to lambda calculus in programming are
functional programming languages, which essentially implement the
calculus augmented with some constants and datatypes. Lisp uses a
variant of lambda notation for defining functions, but only its purely
functional subset ("Pure Lisp") is really equivalent to lambda calculus.
=/block quote=
kind regards,
m harris
--
http://mail.python.org/mailman/listinfo/python-list
Help with pygtk About Dialog
How can I use a png/jpeg/gif image file to set the logo in gtk.AboutDiaog box of pyGTK ? -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
Ian Kelly wrote: > The desktop > is all that is left... and that is dying... rapidly. Their lockin is well > entrenched (like Borg implants ) but the number of mom& pops ( like my > entire extended family, for instance) who are moving to Ubuntu (themselves) > is astounding! It will not be long and Microsoft will die... and none too > soon. So what is that number? Anecdotes are unreliable; I would like to see the actual data. The only non-techie I personally know who uses Linux is my wife, and she only uses it because it's what's installed at home. My brother-in-law was a Linux fan at one time but has regressed. This is very difficult... and I'm not dodging the ball here... its just the truth. The 'market share' data are bogus. Reason? ... because the free software 'market' is not a market. It is not measured in any way, and it is almost impossible to determine therefore in any accurate fashion. There really are no data... what we need here is a census of sorts. Here is an anecdote for you... our tax prep this year was done on-line via Firefox. We use software through a large and well-known tax company which for this purpose supports *only* Firefox 3.6 or higher... go figure. Is not that interesting..? I know, just an anecdote. Here is another anecdote for you the university is supporting *only* Firefox for Moodle and Blackboard usage... very interesting. Well, since most students are carrying a Mac Book, and the rest are running Ubuntu, they really cannot support *only* IE can they? They are supporting one browser, and Firefox got the job. I know, just an anecdote. IE is dead. It is flat dead... almost nobody is using it... The market data are worthless in this discussion, because free software and free software platforms are not measured in the 'market'. Please allow me one more anecdote... I have purchased several machines over the last ten years... all of them preloaded with Windows (something) and all of them running IE (something). NONE of those machines ever saw the light of day as "Windows" machines. I purchased the hardware *only* recovered my cost on the M$ license, and quickly loaded my linux system of choice... and I've used them all, believe me. The point here is that the 'market' data would show that my machines were purchased, installed, and running... activated even. But the truth is that *Best Buy* activated them, not me, and Microsoft is claiming that I am using their popular operating system (which I'm not) and the market data shows Microsoft doing so well in the Desktop market. The truth is something quite different. I am not and have not used Microsoft products for over 12 years now. (not at all) And, all of my systems today are running *only* free software (not even kernels with 'blobs' in them). I use only free (as in freedom) software on all of my systems (Desk and server) as does my *entire* family (well, I influenced them, of course). I read in the blogs today that Microsoft is now claiming that Windows 7 has 39% market share... SPAM SPAM SPAM SPAM SPAM I don't like SPAM ! ... just eggs and ham...Give me a break !!! I don't even know one person who has Win7 installed, running, and likes it... not even one. Where is all this 39% market share...?? Probably the numbers from *Best Buy* on preloads... that get reloaded... or corporations that buy bulk preloads, and then reload their images over the top... kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list
full reload of fastcgi
A recent problem with a fastcgi script leads me to ask if there's any well defined way to fully reload a python fastcgi process. I know that people do tricks like unloading/reloading all modules, but it seems there's no obvious way to get python to restart itself. I believe that the server is apache based with mod_fcgid. The script in question suffers from two problems 1) it runs out of a zip file and the software can be upgraded by moving a new zip file into place. 2) A cron job pulls new data into place which the script should notice. The last is easy we can just re-read the data files before acting on the request, but it seems much harder to reload all modules from the zipfile. An easy way out is to just halt the running script when a software change is detected. That means we must run with the old software for at least one request and could be dangerous if an import is required during the last request. Normally the upgrade process is supposed to move software into place and then new data and then restart the fastcgi scripts; for whatever reason the error seems to have been that the process was restarted with old data around. Any ideas? -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Signal on qt
hello i have this:
def mytest(self):
for a in xrange(self.tableWidget.rowCount()):
self.combo_test = QtGui.QComboBox()
self.connect(self.combo_test,
QtCore.SIGNAL("currentIndexChanged(int)"), self.metto_test)
self.combo_test.addItems(self.lista_def)
self.tableWidget.setCellWidget(a, 4, self.combo_test)
def metto_test(self, index):
print index
I he no connection what is wrong?
Thanks
Luca
--
http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Tue, 12 Apr 2011 16:21:43 +1000, James Mills wrote:
> On Tue, Apr 12, 2011 at 4:08 PM, Nobody 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.
The code snippet is absolutely clear. It is ordinary Python code:
_temp = expr
if _temp: return _temp
You should notice the lack of "else: return None" in that code snippet.
The only assumption being made is that the OP means what he says.
I suppose you can assume that he means something else if you like, but
then you have no possible way of knowing what he actually means ("well, I
*said* conditional return, but I *meant* BEGIN and END delimiters like in
Pascal...").
Personally, I like the idea of a conditional return, but I *hate* the
proposed syntax. But I don't think it's useful enough to deserve a new
keyword either.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Apr 12, 2:21 am, James Mills wrote: > On Tue, Apr 12, 2011 at 4:08 PM, Nobody 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. > > cheers > James > > -- > -- James Mills > -- > -- "Problems are solved by method" I'm puzzled as to why you seem to be parsing the OP's statements different from everybody else. The only assumption that people other than you seem to be making is that they are assuming that the OP meant what he said. He *gave* a definition of what he meant by return? and the definition he actually gave has the property that it terminates the function only when the condition is true, whereas your suggested translation *always* terminates the function call. I agree with "Nobody" that the OP's intention was "abundantly clear". Your "return expr or None" suggestion was not an unreasonable try - but it doesn't provide something which is equivalent to what the OP gave. On the other hand, your persistence in defending your original statement as a plausible translation of return? after the difference has been pointed out by various posters *is* starting to become unreasonable. -- http://mail.python.org/mailman/listinfo/python-list
Off to Europython?
For anyone who's off to EuroPython this year and already has their ticket - please take a quick look at my talk proposal "Introducing Django REST framework" and consider giving it your vote. Here: http://goo.gl/cntAj The biggest take away from the talk will be why I think it's hugely important that the web APIs we're building ought to also be Web browse-able and self-documenting. (and how that's almost entirely not the case at the moment) I've given the talk to small audiences before but it'd be awesome to give it at EuroPython. Anyways, thanks for your consideration! Cheers, Tom Talk summary: * RESTful Web APIs and Django - what batteries aren't in the box. * An introduction to the framework - What it is, what problems it tries to solve. * Why it's so important that Web APIs should be Web browse-able. * A live coding demonstration. * Audience discussion. -- http://mail.python.org/mailman/listinfo/python-list
Re: [even more OT than before] Arithmetic [was Free software versus software idea patents]
On Mon, 11 Apr 2011 15:55:37 -0700, geremy condra wrote: >> Ah, I didn't know that! How wonderful! But in any case, Presburger >> arithmetic is much weaker than even Peano arithmetic. >> >> http://en.wikipedia.org/wiki/Presburger_arithmetic >> >> So, let me re-phrase my statement... in any realistically complex >> arithmetic that is consistent with operations performed for real-world >> applications (e.g. multiplication, division, exponentiation, ...), one >> cannot demonstrate a bullet-proof proof of 1+1=2. Better? :) > > Well, Peano arithmetic is normal, everyday arithmetic fully axiomatized, > and Presburger arithmetic is a subset of it, so we can utilize the fact > that 1 + 1 = 2 is provable in Presburger arithmetic (damn is my spell > checker getting a workout on this sentence) to prove it in Peano > arithmetic, and therefore in everyday use. Alas, that's not the case. Peano arithmetic is undecidable: http://mathworld.wolfram.com/PeanoArithmetic.html Oh, and this may be of interest: http://scienceblogs.com/goodmath/2006/06/extreme_math_1_1_2.php -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with regex needed
Thanks everybody , and especially Chris - i used split and it took me 15
mins to make it work :)
The final version looks like:
from datetime import datetime, date, time
today_day = datetime.now()
time_tuple= today_day.timetuple()
hhh = open("file_with_data.data",'r')
for nnn in hhh:
if nnn.split()[2] == str(time_tuple[1]).strip(' \t\n\r') and
nnn.split()[4] == str(time_tuple[0]).strip(' \t\n\r') and nnn.split()[3]
== str(time_tuple[2]).strip(' \t\n\r') :
print nnn
Cheers and good day everyone
Yuri
On Tue, Apr 12, 2011 at 8:58 AM, Chris Rebert wrote:
> On Mon, Apr 11, 2011 at 10:20 PM, Yuri Slobodyanyuk
> wrote:
> > Good day everyone,
> > I am trying to make this pretty simple regex to work but got stuck,
> > I'd appreciate your help .
>
> "Some people, when confronted with a problem, think 'I know, I'll use
> regular expressions.' Now they have two problems."
>
>
> > 111 Fri 4 8 2011
> > 2323232 Fri 4 15 2011
> > 4343434 Fri 4 22 2011
> > 8522298 Fri 4 29 2011
> > .
> > 5456678 Fri 10 28 2011
> > 563 Fri 11 4 2011
> > 4141411 Fri 11 11 2011
> > 332 Fri 11 18 2011
>
> There's no need to use regexes to parse such a simple file format.
> Just use str.split() [without any arguments] on each line of the file,
> and do the field equality checks yourself; your code will simpler.
> Relevant docs: http://docs.python.org/library/stdtypes.html#str.split
>
> Cheers,
> Chris
> --
> http://blog.rebertia.com
>
--
Taking challenges one by one.
http://yurisk.info
http://ccie-security-blog.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Help with regex needed
On Tue, 12 Apr 2011 15:06:25 +0300
Yuri Slobodyanyuk wrote:
> Thanks everybody , and especially Chris - i used split and it took me 15
> mins to make it work :)
That's great. One thing though...
> for nnn in hhh:
> if nnn.split()[2] == str(time_tuple[1]).strip(' \t\n\r') and
> nnn.split()[4] == str(time_tuple[0]).strip(' \t\n\r') and nnn.split()[3]
> == str(time_tuple[2]).strip(' \t\n\r') :
You are running split() on the same string three times and running
strip on the same time tuple each time through the loop. I know that
you shouldn't optimize before testing for bottlenecks but this is just
egrecious as well as making it more difficult to read. Consider this.
year = str(time_tuple[0]) # strip() not really needed here
mon = str(time_tuple[1])
day = str(time_tuple[2])
for nnn in [x.split() for x in hhh]:
if nnn[2] == mon and nnn[3] = day and nnn[4] = year:
If strip() were needed you could leave off the argument. The default
is to strip all whitespace from both ends. In fact, read up on locales
to see why it is a good idea to omit the argument.
--
D'Arcy J.M. Cain | Democracy is three wolves
http://www.druid.net/darcy/| and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Apr 12, 12:58 am, Paul Rubin wrote: > zildjohn01 writes: > > _temp = expr > > if _temp: return _temp > > I'm trying to figure out a context where you'd even want that, and I'm > thinking that maybe it's some version of a repeat-until loop? Python > doesn't have repeat-until and it's been proposed a few times. I've wanted that a few times, frequently in a situation where I'm doing validity checking, and I either want to continue after calling a validity check or return immediately with some kind of error object. For example: returnif self.isitaboojum(snark) This works nicely if the checking routine either returns False or an error object. It also works if the method is doing some kind of a ladder evaluation of several distinct conditions, and it wants to return the first one it finds. Also, I wouldn't want a returnif in a loop. Following on with this idea, loop control would be more of a breakif or continueif statement. John Roth -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On 2011-04-12, James Mills wrote: > On Tue, Apr 12, 2011 at 12:18 PM, Grant Edwards > wrote: >> You stated that >> >> ??return? >> >> was equivalent to >> >> ??return or None > > This is _not_ what I said. > > Quoting from my earlier post: > > """ >>return? expr > > This syntax does not fit well within python ideology. > >> be expanded to >> >>_temp = expr >>if _temp: return _temp > > This could be simplified to just: > > return expr or None > """ You just said it again: that the OP's "return? expr" is the same as "return exrp or None". It isn't. The OP's construct didn't return if expr wasn't true. Your construt does. > Please read carefully before putting words in my mouth. I wasn't putting words in your mouth. You said the same thing again in the post to whic I'm replying. > I stated very clear y that return? expr didn't seem fitting > in the python ideology as syntax for this behavior. I don't care about syntax. What you proposed doesn't have the same _semantics_ as what the OP proposed. -- Grant Edwards grant.b.edwardsYow! I'd like MY data-base at JULIENNED and stir-fried! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On 2011-04-12, James Mills wrote: > On Tue, Apr 12, 2011 at 12:44 PM, Chris Angelico 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.edwardsYow! Well, I'm INVISIBLE at AGAIN ... I might as well gmail.compay a visit to the LADIES ROOM ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On 2011-04-12, James Mills wrote: > On Tue, Apr 12, 2011 at 4:08 PM, Nobody 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.edwardsYow! One FISHWICH coming at up!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Tue, 2011-04-12 at 04:22 -0500, harrismh777 wrote: > Ian Kelly wrote: > >> > The desktop > >> > is all that is left... and that is dying... rapidly. Their lockin is > >> > well > >> > entrenched (like Borg implants ) but the number of mom& pops ( like my > >> > entire extended family, for instance) who are moving to Ubuntu > >> > (themselves) > >> > is astounding! It will not be long and Microsoft will die... and none > >> > too > >> > soon. > > > So what is that number? Anecdotes are unreliable; I would like to see > > the actual data. The only non-techie I personally know who uses Linux > > is my wife, and she only uses it because it's what's installed at > > home. My brother-in-law was a Linux fan at one time but has > > regressed. > > This is very difficult... and I'm not dodging the ball here... its > just the truth. The 'market share' data are bogus. Reason? ... because > the free software 'market' is not a market. It is not measured in any > way, and it is almost impossible to determine therefore in any accurate > fashion. There really are no data... what we need here is a census of sorts. > Here is an anecdote for you... our tax prep this year was done > on-line via Firefox. We use software through a large and well-known tax > company which for this purpose supports *only* Firefox 3.6 or higher... > go figure. Is not that interesting..? I know, just an anecdote. > Here is another anecdote for you the university is supporting > *only* Firefox for Moodle and Blackboard usage... very interesting. > Well, since most students are carrying a Mac Book, and the rest are > running Ubuntu, they really cannot support *only* IE can they? They are > supporting one browser, and Firefox got the job. I know, just an anecdote. > > IE is dead. It is flat dead... almost nobody is using it... > > The market data are worthless in this discussion, because free > software and free software platforms are not measured in the 'market'. > Please allow me one more anecdote... I have purchased several machines > over the last ten years... all of them preloaded with Windows > (something) and all of them running IE (something). NONE of those > machines ever saw the light of day as "Windows" machines. I purchased > the hardware *only* recovered my cost on the M$ license, and quickly > loaded my linux system of choice... and I've used them all, believe me. > The point here is that the 'market' data would show that my > machines were purchased, installed, and running... activated even. But > the truth is that *Best Buy* activated them, not me, and Microsoft is > claiming that I am using their popular operating system (which I'm not) > and the market data shows Microsoft doing so well in the Desktop market. > The truth is something quite different. I am not and have not used > Microsoft products for over 12 years now. (not at all) And, all of my > systems today are running *only* free software (not even kernels with > 'blobs' in them). I use only free (as in freedom) software on all of my > systems (Desk and server) as does my *entire* family (well, I influenced > them, of course). > > I read in the blogs today that Microsoft is now claiming that > Windows 7 has 39% market share... SPAM SPAM SPAM SPAM SPAM I don't > like SPAM ! ... just eggs and ham...Give me a break !!! I don't > even know one person who has Win7 installed, running, and likes it... > not even one. Where is all this 39% market share...?? Probably the > numbers from *Best Buy* on preloads... that get reloaded... or > corporations that buy bulk preloads, and then reload their images over > the top... > > > > kind regards, > m harris > > > > The pre-builts from Best Buy that get reloaded, reloaded with what? I live in California, the center of software development. I only know one person who uses Linux, and they only use it for work (he doesn't even live in CA anymore). I have say your delusions about the use of free software are somewhat hilarious. -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On 12-Apr-11 06:55 AM, scattered wrote: On Apr 12, 2:21 am, James Mills wrote: On Tue, Apr 12, 2011 at 4:08 PM, Nobody 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. cheers James -- -- James Mills -- -- "Problems are solved by method" I'm puzzled as to why you seem to be parsing the OP's statements different from everybody else. The only assumption that people other than you seem to be making is that they are assuming that the OP meant what he said. He *gave* a definition of what he meant by return? and the definition he actually gave has the property that it terminates the function only when the condition is true, whereas your suggested translation *always* terminates the function call. I agree with "Nobody" that the OP's intention was "abundantly clear". Your "return expr or None" suggestion was not an unreasonable try - but it doesn't provide something which is equivalent to what the OP gave. On the other hand, your persistence in defending your original statement as a plausible translation of return? after the difference has been pointed out by various posters *is* starting to become unreasonable. In my view, the suggestion would add complexity to the language without sufficient benefit. Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.setdefault()
On Mon, 2011-04-11 at 19:58 -0700, rantingrick wrote: > > > >>> dict.update(D, cobblerexistingkeys=False) Fix'd Much yummier now. -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote: > On Tue, Apr 12, 2011 at 12:20 PM, James Mills > wrote: > > On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails > > 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: return x Am I wrong here? -- http://mail.python.org/mailman/listinfo/python-list
download web pages that are updated by ajax
Hi, I want to download a web page that is updated by AJAX. The page requires no human interaction, it is updated automatically: http://www.ncbi.nlm.nih.gov/nuccore/CP002059.1 If I download it with wget, I get a file of size 97 KB. The source is full of AJAX calls, i.e. the content of the page is not expanded. If I open it in a browser and save it manually, the result is a file of almost 5 MB whose content is expanded. (1) How to download such a page with Python? I need the post-AJAX version of the page. (2) Can it be done with wget or some other command-line utility? I would be interested in that too. Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Apr 12, 10:05 am, Westley Martínez wrote: > On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote: > > On Tue, Apr 12, 2011 at 12:20 PM, James Mills > > wrote: > > > On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails > > > 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: > > 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? -- http://mail.python.org/mailman/listinfo/python-list
Re: OT] Free software versus software idea patents
Hi Westley... > The pre-builts from Best Buy that get reloaded, reloaded with what? I > live in California, the center of software development. I only know one > person who uses Linux, and they only use it for work (he doesn't even > live in CA anymore). I have say your delusions about the use of free > software are somewhat hilarious. It would be mighty interesting to know what you have done for the FOSS community as a whole without want of monetary payment and/or recognition. -- 73... Bazza, G0LCU... Team AMIGA... http://homepages.tesco.net/wisecracker/ http://main.aminet.net/search?readme=wisecracker http://mikeos.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
Paul Rubin wrote: > zildjohn01 writes: >> _temp = expr >> if _temp: return _temp > > I'm trying to figure out a context where you'd even want that, and I'm > thinking that maybe it's some version of a repeat-until loop? Python > doesn't have repeat-until and it's been proposed a few times. I can imagine return? tree_node.left return? tree_node.right although my real code would probably be more like if tree_node.left is not None: return "left", tree_node.left if tree_node.right is not None: return "right", tree_node.right where adding the "left" and "right" markers makes the return? feature impossible to use. The proposed feature reminds me of the `zod` function (was that the actual name?) that returned 0 rather than bringing on a ZeroDivideError. It would cement a strange corner-case into the language. Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: OOP only in modules
Hi Andrea,
excuse my beeing criptic (you wrote: "I have some troubles
understanding what you mean") but I coudn't to go on too long.
Now I can conclude my speech...
When I was younger I transformed a big Clipper program in
simil-C in order to apply cflow... and I succeeded...
but Clipper wasn't OO!
To better explain I must introduce cflow...
From: http://www.gnu.org/software/cflow/manual/cflow.txt
/* whoami.c - a simple implementation of whoami utility */
#include
#include
#include
#include
int who_am_i (void) #~13
{
struct passwd *pw;
char *user = NULL;
pw = getpwuid (geteuid ()); #~18
if (pw)
user = pw->pw_name;
else if ((user = getenv ("USER")) == NULL) #~21
{
fprintf (stderr, "I don't know!\n");#~23
return 1;
} #~26
printf ("%s\n", user);
return 0;
}
int main (int argc, char **argv) #~31
{
if (argc > 1)
{
fprintf (stderr, "usage: whoami\n");#~35
return 1;
}
return who_am_i (); #~38
}
Running `cflow' produces the following output:
$ cflow whoami.c
main() :
| ~ all C programs start with main()
+-- fprintf() ~ called from #~35
+-- who_am_i()
# 2instances.py
# from: http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm
# w/ some adds up
class C:
def __init__(self, val):
self.val = val
def f(self):
print "hello, my value is:", self.val
# create two instances
a = C(27)
b = C(42)
def E():#~15
print 'hello '+ F()
G() #~17
def F():#~18
return raw_input('Addressed to ') #~19
def G():#~21
print 'Hello world'
# first try sending messages to the instances
a.f(),''
# hello, my value is 27
b.f()
# hello, my value is 42
# now call the method explicitly via the class
C.f(a)
# hello, my value is 27
# Addressing functions
E() #~35
G() #~36
""" call tree w/o classes and objects:
E() #~15 called from #~35
+-- F() #~1816
|+-- raw_input('Addressed to ') # called from 19
+-- G() #~2118
G() #~2136
"""
Beeing the script so small, the above call tree can be
build up by hand, but in every case in am not able to
incorporate classes, instances and method calls...
Instead, if I move "all" the OO references to a module
(for example m2instancesOO.py saved in the same dir as the
part w/o OO)
I could fictitiously trasform OOP in "procedural" programming,
getting therefore only function definitions and calls.
It not an easy task... therefore I called help.
in my experience, I am convinced that call trees (together with xref)
are the main tools to understand not trivial python programs.
Instead of using debuggers, with these tools (and with the
judicious use of trace) you can solve any bug and besides that
acquire a better understanding of the program.
Another advantage of moving OO stuff to modules is the "sharp
increase in re-usability of code...
In my understanding modules are the python's implementation
of libraries very much used by other languages.
Bye.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents (was: Python benefits over Cobra)
On 7 apr, 09:39, Steven D'Aprano wrote: > It's astonishing how anti-Mono FUD just won't die. (Something can be > true, and still FUD. "Oh no, people might *choke* on a peanut, or have an > allergic reaction, we must label every piece of food May Contain Nuts > just in case, because you never know!!!") > Look, patent threats are real, but we don't gain anything by exaggerating > the threat, and we *especially* don't gain anything by treating one patent > holder as the Devil Incarnate while ignoring threats from others. Regardless of source, the obvious conclusion from the patent FUD is this: - Python might infinge on a patent, never use Python. - Mono might infinge on a patent, never use Mono. - Java might infinge on a patent, never use Java. - .NET might infinge on a patent, never use .NET. - The C compiler might infinge on a patent, never use C. - Your code might infinge on a patent, never program anything. - Software on your computer might infinge on a patent, never dear to use it. - Hardware on your computer might infinge on a patent, turn it off. - Risk of litigation is a greater concern than anything a computer can do for you. - Get rid of your computer before you get sued. - A slide ruler is a hell of an invention. -- http://mail.python.org/mailman/listinfo/python-list
Re: threading.Semaphore (quite long)
In article , Thomas Rachel wrote: > >I want to implement an alternative concept to worker threads processing >a job queue. The alternative consists of threads being the jobs >themselves and thus running only this one job. The job threads are >started after a Semaphore's acquire() "giving the OK" to do so. The >Semaphore's release() gets called inside the jobs/threads, saying >"done, the next one please". > >But the program doesn't always stop on Ctrl-C. > > [...] > >0. (First and in general) Am I doing "bad things" when calling release() >at a completely different place than acquire() with a Semaphore? I used >to believe that's why there are Semaphores? Should be fine. >1. Is a bug report useful, or would that worsen the problem, as the race >condition doesn't disappear completely? If you can demonstrate that the problem occurs outside signals (keyboard interrupt uses a signal), that would be more interesting (signals and threads are often problematic). >2. Is in, in general, an error to work with Semaphores (ore, more >general with Locks) in the MainThread? Or should this be done in a >separate thread being informed about a keyboard exception by the main >thread? Outside of signals, there should not be a problem with that. I don't have time to look further, I just noticed that nobody responded. -- Aahz ([email protected]) <*> http://www.pythoncraft.com/ "At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-)" --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22 -- http://mail.python.org/mailman/listinfo/python-list
Re: Dump interpreter history?
In article , Terry Reedy wrote: >On 4/11/2011 11:54 AM, Aahz wrote: >> In article, >> Ken D'Ambrosio wrote: >>> >>> Hey, all. A co-worker asked me a question, and I've got no idea how (or >>> if) it can be done. Bottom line: he'd like to save off the text from an >>> interpreter session, his thinking being that you've already tried to get >>> what you want, and now you just need to gussy it up in an editor. >> >> I've never used it myself, but IIRC ipython does what you want very >> nicely. > >Idle will save the contents of the shell window, including opening slash >line and prompts. The problem is that normally you *don't* want the prompts. I believe IPython handles that. -- Aahz ([email protected]) <*> http://www.pythoncraft.com/ "At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-)" --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22 -- http://mail.python.org/mailman/listinfo/python-list
Re: argparse and default for FileType
> Open up a bug report on the Python bug tracker and assign it to the user > "bethard", who is the author of argparse. He's usually pretty responsive. Thank you for the answer, I will. Paolo -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Tue, Apr 12, 2011 at 1:15 AM, harrismh777 wrote: > geremy condra wrote: >>> >>> Software is another sort of animal entirely. Because software is not >>> just >>> > based on mathematics--- IT IS mathematics. > >> I am extremely skeptical of this argument. > > ... as are a great number of other people; corporations, lawyers, > venture capitalists, SPAM SPAM SPAM... That's irrelevant to me. I'm much more concerned about your abuse of mathematics in pursuit of politics than I am about your politics, which (in broad strokes) I agree with. > That is what made the last Supreme Court decision (from this argument in > part) so important... because for the first time the U.S. Supreme Court is > beginning to buy it ... in part. > > See Groklaw here if you're not familiar with the issue: > > http://www.groklaw.net/staticpages/index.php?page=2009022607324398 > > In this case, the court left software patents intact for the moment, but > they slammed the door shut on Bilski... and the interesting thing here is > that what Bilski was claiming to have invented is similar is most respects > to all other "software idea patents," and for similar mathematical > reasoning. It was a slam dunk, by the way... here is a block quote from > Groklaw you might find interesting: > > = block quote = > If you are a lawyer wondering why some argue that software is mathematics, > and hence ineligible for patent protection, or are just interested to know > why software developers, particularly those who develop Free and Open Source > software, almost to a man oppose software patents, you might enjoy reading > Groklaw's An Explanation of Computation Theory for Lawyers, as well as the > amicus briefs and articles marked with the discreet red stars [*], below. > Donald Knuth, called the "father" of the analysis of algorithms, stated: > "Basically I remain convinced that the patent policy most fair and most > suitable for the world will regard mathematical ideas (such as algorithms) > to be not subject to proprietary patent rights." Also, there is a 30-minute > movie, Patent Absurdity: How software patents broke the system, which > explains it well. > =/block quote= I'm familiar with the case, and agree with Knuth (and you) that math should not be patentable. I'd also agree that algorithms are mathematics. Critically, algorithms *are not* software. >> it isn't clear to me that software and >> computation are synonymous. Lambda calculus only models computation, >> and software has real properties in implementation that are strictly >> dependent on the physical world > > (see above) In your rush to misunderstand this you haven't addressed it yet. >> I think it's quite reasonable to >> contend that the existence of lambda calculus no more rules out the >> applicability of patents to software (which I detest) than it rules >> out the applicability of patents to hardware (which I find only >> slightly less ridiculous) or other meatspace inventions. > > The difference is that while hardware may be "described" by mathematics > (all of it is, actually) software IS the description. Software does not, in general, describe hardware. > You know this to be > true, because you prove it everyday... yourself. How many times have you had > a problem, and rather than sit down with your pad of paper and a slide rule > (or your TI-89 Platinum) YOU solved the problem right there on the screen... > er, I mean... the machine solved the problem for you, uh, after you wrote > out the symbols ... ??? We don't think out our problems on paper much > these days... we just enter them into the 'ol terminal and play with it > there... frankly, that is what appeals to me with languages like Python, > Haskell, and Erlang... they are my research engines ... they take the place > of paper and pencil and slide rule and calculator (and counting on ones > fingers) ... but its still little 'ol me doing the thinking... the days of > doing multiple differential equations on a black-board (or white board) are > long gone for most of us. This does not even provide evidence towards your claim that software describes hardware, let alone prove it. It does reinforce my growing suspicion that you do not work in mathematics at a professional or research level, though. > The handwriting is on the wall (not so much wishful thinking as just > noting that everyone including Supreme Court justices are beginning to get > it). It is equally important that *all* software engineers and FOSS > developers *get it!* We need everyone on board with this... really... the > time is critical for everyone to understand this... what is actually at > stake is freedom... what we need to focus on is ending software patents > forever... now. Why is it that the trolls on this board always say this? I'm genuinely baffled by that. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
Can not uninstall activepython. Missing msi ?
Hi, I want to uninstall Active Python 2.6.2.2 and upgrade. Certain things are not working and it's probably time to upgrade anyway. When I try to uninstall it says "missing msi". Before I delete all the folders and clean the registry out is there something I can try to have a normal or more graceful uninstall? Using WinXP. Thanks, Lee G. -- http://mail.python.org/mailman/listinfo/python-list
Re: 3.2: email.message.get_payload() delivers str, but send_message expect bytes
On 08.04.11 13:43, Axel Rau wrote: > line 167, in sub > return _compile(pattern, flags).sub(repl, string, count) > TypeError: sequence item 1: expected bytes, str found I just filed issue 11837. Axel -- http://mail.python.org/mailman/listinfo/python-list
Re: OOP only in modules
On Tue, 2011-04-12 at 08:33 -0700, newpyth wrote:
> """ call tree w/o classes and objects:
> E() #~15 called from #~35
> +-- F() #~1816
> |+-- raw_input('Addressed to ') # called from 19
> +-- G() #~2118
>
> G() #~2136
> """
>
> Beeing the script so small, the above call tree can be
> build up by hand,
IMO, in any real-world application your call-graph is miles long. This
is really not much more than a stack trace.
> It not an easy task... therefore I called help.
> in my experience, I am convinced that call trees (together with xref)
> are the main tools to understand not trivial python programs.
> Instead of using debuggers,
Even better, since the real world usually involves non-trivial programs,
is to learn to use debuggers and the provided tools. I've not had any
issues read the strack-trace generated by an exception in an OO Python
application [as I maintain a >100,000 line and growing component
oriented Python applications
]
> with these tools (and with the
> judicious use of trace) you can solve any bug and besides that
> acquire a better understanding of the program.
> Another advantage of moving OO stuff to modules is the "sharp
> increase in re-usability of code...
Only if your code remains as trivial as your examples.
> In my understanding modules are the python's implementation
> of libraries very much used by other languages.
Making these kind of analogies is not helpful and will only confuse. C
uses libraries, .NET uses assemblies, Python uses modules... and how
these function and perform differs in important ways.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents
On 4/11/2011 4:36 AM, rusi wrote: http://www.cse.uconn.edu/~dqg/papers/cie05.pdf may be of interest (and also other papers of Peter Wegner questioning the universality of Turing machines lambda calculus etc) Thank you for that reference. In summary, it says that while Turing machine are universal for finite function calculations, infinite interactive processes are not (finite) function calculations, and therefore need an extension to TMs. This is pretty obviously correct. Python iterators, and especially generators, implement the extension that the authors call 'persistent Turing machines' (PTMs, section 6.2), except that iterators (and generators by default) operate in 'pull' mode, while they describe PTMs as operating in 'push' mode (as with generator.send()). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On 4/12/2011 4:15 AM, harrismh777 wrote: Anyone here who does not understand how absurd software patents can get should contemplate the following (based on a real patent from about 20 years ago, when CDroms were new. A Methods for Ensuring that the Correct CDROM is in the CDROM drive. While the correct cdrom is not in the drive: Display a message asking the user to insert the correct CD. Buried in a page of verbiage, that was it, completely obvious and unoriginal. That is what made the last Supreme Court decision (from this argument in part) so important... because for the first time the U.S. Supreme Court is beginning to buy it ... in part. What might help lawyers understand the obsurdity of software patents would be to have them contemplate the possibility of patents on laws and legal arguments, so that a legislature could not write a law, nor a lawyer submit a legal brief, without possibly having to pay royalties or violate a patent. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents
> I don't even know one person who has Win7 installed, running, and likes >it... > not even one. Hi, m harris, nice to meet you. Now you do. To the online community: Is there a name for trolling for A by advocating for not-A in a way that discredits your point of view an case so that A now seems much more reasonable? It's not really "concern trolling". What would this be called? -- http://mail.python.org/mailman/listinfo/python-list
Re: Dump interpreter history?
On 4/12/2011 12:12 PM, Aahz wrote: In article, Terry Reedy wrote: Idle will save the contents of the shell window, including opening slash line and prompts. The problem is that normally you *don't* want the prompts. I believe IPython handles that. I have already had in mind that IDLE should be able to deal with this issue. http://bugs.python.org/issue11838 -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
* 2011-04-12T10:27:55+10:00 * James Mills wrote: > On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 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)) -- http://mail.python.org/mailman/listinfo/python-list
Re: [even more OT than before] Arithmetic [was Free software versus software idea patents]
On Tue, Apr 12, 2011 at 4:34 AM, Steven D'Aprano wrote: > On Mon, 11 Apr 2011 15:55:37 -0700, geremy condra wrote: > > >>> Ah, I didn't know that! How wonderful! But in any case, Presburger >>> arithmetic is much weaker than even Peano arithmetic. >>> >>> http://en.wikipedia.org/wiki/Presburger_arithmetic >>> >>> So, let me re-phrase my statement... in any realistically complex >>> arithmetic that is consistent with operations performed for real-world >>> applications (e.g. multiplication, division, exponentiation, ...), one >>> cannot demonstrate a bullet-proof proof of 1+1=2. Better? :) >> >> Well, Peano arithmetic is normal, everyday arithmetic fully axiomatized, >> and Presburger arithmetic is a subset of it, so we can utilize the fact >> that 1 + 1 = 2 is provable in Presburger arithmetic (damn is my spell >> checker getting a workout on this sentence) to prove it in Peano >> arithmetic, and therefore in everyday use. > > Alas, that's not the case. Peano arithmetic is undecidable: > > http://mathworld.wolfram.com/PeanoArithmetic.html Presburger arithmetic is a subset of Peano Arithmetic, ie, all statements which are true in Presburger Arithmetic are true in Peano arithmetic, and all statements which are false in Presburger arithmetic are false in Peano arithmetic. A bullet-proof proof of the fact you listed exists in Presburger arithmetic. By implication the statement is therefore proven true in Peano arithmetic. Also, undecidable does not mean that *no* statement can be proven formally true or false, only that statements which cannot be proven true or false exist within the confines of those axioms, ie, an axiomatic system is undecidable if there exists an expressible statement within it that is independent of all of the axioms. As you note below, there are other proofs under ZF (and optionally C). > Oh, and this may be of interest: > http://scienceblogs.com/goodmath/2006/06/extreme_math_1_1_2.php It's fine until you get to the end, then it drops into a completely incorrect interpretation both of what R&W were doing and of Godel's work. By the way, if you're interested in this sort of thing, Paul Bernays' (the 'B' in NBG set theory, the other two being no less than von Neumann and Godel) book on axiomatic set theory is cheaply available through Dover and is really, really good at getting to the meat on this sort of thing. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents
On Tue, Apr 12, 2011 at 10:48 AM, CM wrote: >> I don't even know one person who has Win7 installed, running, and likes >>it... >> not even one. > > Hi, m harris, nice to meet you. Now you do. > > To the online community: Is there a name for trolling for A by > advocating for not-A in a way that discredits your point of view an > case so that A now seems much more reasonable? It's not really > "concern trolling". What would this be called? Harrisment. /I'm sorry, this is abuse... Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Tue, Apr 12, 2011 at 12:00 PM, Teemu Likonen 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Tue, Apr 12, 2011 at 12:25 PM, Ian Kelly wrote: > On Tue, Apr 12, 2011 at 12:00 PM, Teemu Likonen 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: download web pages that are updated by ajax
On Tue, Apr 12, 2011 at 7:47 AM, Jabba Laci wrote: > Hi, > > I want to download a web page that is updated by AJAX. The page > requires no human interaction, it is updated automatically: > http://www.ncbi.nlm.nih.gov/nuccore/CP002059.1 > > If I download it with wget, I get a file of size 97 KB. The source is > full of AJAX calls, i.e. the content of the page is not expanded. > If I open it in a browser and save it manually, the result is a file > of almost 5 MB whose content is expanded. > > (1) How to download such a page with Python? I need the post-AJAX > version of the page. I've heard you can drive a web browser using Selenium (http://code.google.com/p/selenium/ ), have it visit the webpage and run the JavaScript on it, and then grab the final result. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents
On Tue, Apr 12, 2011 at 10:32 AM, Terry Reedy wrote: > On 4/11/2011 4:36 AM, rusi wrote: > >> http://www.cse.uconn.edu/~dqg/papers/cie05.pdf >> >> may be of interest (and also other papers of Peter Wegner questioning >> the universality of Turing machines lambda calculus etc) > > Thank you for that reference. In summary, it says that while Turing machine > are universal for finite function calculations, infinite interactive > processes are not (finite) function calculations, and therefore need an > extension to TMs. This is pretty obviously correct. > > Python iterators, and especially generators, implement the extension that > the authors call 'persistent Turing machines' (PTMs, section 6.2), except > that iterators (and generators by default) operate in 'pull' mode, while > they describe PTMs as operating in 'push' mode (as with generator.send()). I didn't read the paper, but I believe Turing Machines are infinite. Interactive processes don't seem, at least to me, to change the applicability of Turing Machines - you merely pretend you have a bunch of squares preinitialized with your various inputs. If you have an infinite number of inputs, that's fine, you can have them with a preinitialized turing machine. -- http://mail.python.org/mailman/listinfo/python-list
Re: OOP only in modules
newpyth writes: > Hi Andrea, > excuse my beeing criptic (you wrote: "I have some troubles > understanding what you mean") but I coudn't to go on too long. > Now I can conclude my speech... > When I was younger I transformed a big Clipper program in > simil-C in order to apply cflow... and I succeeded... > but Clipper wasn't OO! > To better explain I must introduce cflow... > From: http://www.gnu.org/software/cflow/manual/cflow.txt > [...] Apart from literate programming noone codes trying to write such a linear work flow, for many good reasons. You should find the right metaphor to solve your problem and code it, then you can analyze the real call graph with the right tools, like for example http://pycallgraph.slowchop.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
Teemu Likonen 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with regex needed
Thanks for the insight, while this code will run once a week and
optimization isn't really a must here, it is
still a good idea not to leave half-baked code behind me, especially given
that it will be running on this server for the next 13 years ;)
I have one doubt though . Doesn't using the list comprehension here increase
number of loops per the same string ?
for nnn in [x.split() for x in hhh]:
My vision here is that after doing the comprehension it would look:
for nnn in [1st_field,2nd_field,3rd_filed,...,nth_filed]:
... and therefore would do number of loops equal to number of fields while
we really need just one ?
Thanks
Yuri
On Tue, Apr 12, 2011 at 3:50 PM, D'Arcy J.M. Cain wrote:
> On Tue, 12 Apr 2011 15:06:25 +0300
> Yuri Slobodyanyuk wrote:
> > Thanks everybody , and especially Chris - i used split and it took me 15
> > mins to make it work :)
>
> That's great. One thing though...
>
> > for nnn in hhh:
> > if nnn.split()[2] == str(time_tuple[1]).strip(' \t\n\r') and
> > nnn.split()[4] == str(time_tuple[0]).strip(' \t\n\r') and
> nnn.split()[3]
> > == str(time_tuple[2]).strip(' \t\n\r') :
>
> You are running split() on the same string three times and running
> strip on the same time tuple each time through the loop. I know that
> you shouldn't optimize before testing for bottlenecks but this is just
> egrecious as well as making it more difficult to read. Consider this.
>
> year = str(time_tuple[0]) # strip() not really needed here
> mon = str(time_tuple[1])
> day = str(time_tuple[2])
>
> for nnn in [x.split() for x in hhh]:
>if nnn[2] == mon and nnn[3] = day and nnn[4] = year:
>
> If strip() were needed you could leave off the argument. The default
> is to strip all whitespace from both ends. In fact, read up on locales
> to see why it is a good idea to omit the argument.
>
> --
> D'Arcy J.M. Cain | Democracy is three wolves
> http://www.druid.net/darcy/| and a sheep voting on
> +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner.
>
--
Taking challenges one by one.
http://yurisk.info
http://ccie-security-blog.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
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 -- http://mail.python.org/mailman/listinfo/python-list
Testing changes to Python code on the fly: reload() + alternatives?
Hi all,
I have a couple of questions that I was hoping people might be able to provide
suggestions on.
1) Is it possible to reload a class using the reload() method? For instance,
suppose you have the following files:
my_module/
__init__.py
MyClass.py
#init.py
from MyClass import MyClass
#MyClass.py
class MyClass:
def __init__(self):
print("Before...")
Is it possible to load the class, change the print statement (e.g.
print("after...")), and have the changes take effect right away?
The above method does not work:
In [1]: import my_module
In [2]: my_module.MyClass()
Before...
Out[2]:
In [3]: reload(my_module)
Out[3]:
In [4]: my_module.MyClass()
Before...
Out[4]:
Is there anyway to make this work while keeping MyClass in the main "my_module"
namespace?
2) More generally though, what is the best way to go about testing changes to
code as you are writing it?
It would be very convenient to be able to use reload() along the lines of the
above so that I could test changes to a small part of some class/function/etc
without having to reload the entire state from scratch.
Another option of course would be to just run everything as a standalone
script, but then you lose the ability to be able to easily inspect the objects
you are working and change them on the fly, except perhaps by using PDB.
Any suggestions would be greatly appreciated.
Thanks!
Keith
--
http://mail.python.org/mailman/listinfo/python-list
Re: Signal on qt
I don't know what are you trying with this for, but I think you may be
connecting signal to a combo_test and after that changing combo_test, losing
connection, but I'm not really sure. Anyway, this is a python list for PyQt
(I think you are using it) you should ask in PyQt list.
2011/4/12 luca72
> hello i have this:
> def mytest(self):
>for a in xrange(self.tableWidget.rowCount()):
>self.combo_test = QtGui.QComboBox()
>self.connect(self.combo_test,
> QtCore.SIGNAL("currentIndexChanged(int)"), self.metto_test)
>self.combo_test.addItems(self.lista_def)
>self.tableWidget.setCellWidget(a, 4, self.combo_test)
> def metto_test(self, index):
>print index
>
> I he no connection what is wrong?
>
> Thanks
>
> Luca
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Tue, Apr 12, 2011 at 3:22 AM, harrismh777 wrote: > This is very difficult... and I'm not dodging the ball here... its just > the truth. The 'market share' data are bogus. Reason? ... because the free > software 'market' is not a market. This is just word-play. It has no bearing on the accuracy of the data, because the data are not necessarily based on sales. > It is not measured in any way, and it is almost impossible to determine > therefore in any accurate fashion. There > really are no data... what we need here is a census of sorts. There is at least one method of measuring it without resorting to sales figures: logging user-agent data from web browsers. Is it perfectly accurate? Of course not. But there are a number of different organizations that do this, sampling hundreds of thousands of different websites, and they consistently report that the various versions of Windows have a total usage share ranging from 80% to 90%. That at least gives us an upper and lower bound with a great deal of confidence. In the same data, Apple systems range from about 7% to 15%, and Linux musters a meager 1% to 3%. > IE is dead. It is flat dead... almost nobody is using it... > > The market data are worthless in this discussion, because free software > and free software platforms are not measured in the 'market'. Did you actually look at the links I provided you with? FOSS browsers are absolutely represented there. Again, that data is not based on sales! It is based on user-agent logging. > Please allow > me one more anecdote... I have purchased several machines over the last ten > years... all of them preloaded with Windows (something) and all of them > running IE (something). NONE of those machines ever saw the light of day as > "Windows" machines. I purchased the hardware *only* recovered my cost on the > M$ license, and quickly loaded my linux system of choice... and I've used > them all, believe me. > The point here is that the 'market' data would show that my machines were > purchased, installed, and running... activated even. Wrong! The data that I am talking about would report those as Linux systems, provided that you use them for web-browsing. Otherwise, it would not report them at all. > ... just eggs and ham... Give me a break !!! I don't even know one > person who has Win7 installed, running, and likes it... not even one. I have it installed and running, and I like it for what it is. An easy-to-use platform with a wide range of software options that requires little time investment from me for installation, configuration, and maintenance. I would not and do not use it for everything, but I am able to appreciate the convenience. So now you can say that you know one person. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents
On 4/12/2011 2:44 PM, Dan Stromberg wrote: On Tue, Apr 12, 2011 at 10:32 AM, Terry Reedy wrote: On 4/11/2011 4:36 AM, rusi wrote: http://www.cse.uconn.edu/~dqg/papers/cie05.pdf may be of interest (and also other papers of Peter Wegner questioning the universality of Turing machines lambda calculus etc) Thank you for that reference. In summary, it says that while Turing machine are universal for finite function calculations, infinite interactive processes are not (finite) function calculations, and therefore need an extension to TMs. This is pretty obviously correct. Python iterators, and especially generators, implement the extension that the authors call 'persistent Turing machines' (PTMs, section 6.2), except that iterators (and generators by default) operate in 'pull' mode, while they describe PTMs as operating in 'push' mode (as with generator.send()). I didn't read the paper, If you are interested in the subject, I recommend it. It is pretty clear and not long. but I believe Turing Machines are infinite. An 'effective' algorithm/TM turns a finite input into a finite output in a finite time, without outside intervention, and then halts. The Halting Problem arose because of the requirement that effective machines halt, and indeed, a particular proof that a particular algorithm halts on all inputs in the defined domain is part of the proof that it is 'correct'. Interactive processes don't seem, at least to me, to change the applicability of Turing Machines - you merely pretend you have a bunch of squares preinitialized with your various inputs. If you have an infinite number of inputs, that's fine, you can have them with a preinitialized turing machine. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with regex needed
On Tue, 12 Apr 2011 22:11:55 +0300
Yuri Slobodyanyuk wrote:
> Thanks for the insight, while this code will run once a week and
> optimization isn't really a must here, it is
> still a good idea not to leave half-baked code behind me, especially given
> that it will be running on this server for the next 13 years ;)
You don't want to embarrass yourself in 13 years, eh? :-)
> I have one doubt though . Doesn't using the list comprehension here increase
> number of loops per the same string ?
Nope. It just optimizes the code a bit.
> for nnn in [x.split() for x in hhh]:
> My vision here is that after doing the comprehension it would look:
> for nnn in [1st_field,2nd_field,3rd_filed,...,nth_filed]:
for nnn in hhh:
becomes
for nnn in ('a b c', 'd e f', 'g h i'): # loops three times
for nnn in [x.split() for x in hhh]:
becomes
for nnn in [['a','b','c'],['d','e','f'],['g','h','i']: # still three
> ... and therefore would do number of loops equal to number of fields while
> we really need just one ?
The number of loops is still the number of objects (strings) in hhh.
The only difference is that in the former case you need to split the
variable inside the loop causing the production and destruction of an
extra object.
Be careful though. You can optimize your loops by doing too much in
the for statement. You would be hard put to find a case where
optimization is worth more than readability.
--
D'Arcy J.M. Cain | Democracy is three wolves
http://www.druid.net/darcy/| and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On 2011-04-12, Ian Kelly 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On 2011-04-12, Neil Cerutti wrote: > On 2011-04-12, Ian Kelly 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: drawing polygons in Google Earth using wxpython
On Mar 20, 10:20 pm, "!!AhmedLegend!!" wrote: > ...i am working on my graduation project and i need to draw some > polygons in Google Earth map automatically using python so any one was > subjected to something like that or have a solution plz respond > ASAP ...given that i was able to open Google Earth from python and > focus on a certain point and also i have no previous background with > using kmlthanks in advance Checkout http://zoolboolcode.blogspot.com/ for examples on how to use python to draw shapes into GE. Hope it helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Tue, Apr 12, 2011 at 11:00 AM, Teemu Likonen wrote: > * 2011-04-12T10:27:55+10:00 * James Mills wrote: >> On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Tue, Apr 12, 2011 at 12:37 PM, Ian Kelly wrote: > On Tue, Apr 12, 2011 at 3:22 AM, harrismh777 wrote: >> It is not measured in any way, and it is almost impossible to determine >> therefore in any accurate fashion. There >> really are no data... what we need here is a census of sorts. > > There is at least one method of measuring it without resorting to > sales figures: logging user-agent data from web browsers. Is it > perfectly accurate? Of course not. But there are a number of > different organizations that do this, sampling hundreds of thousands > of different websites, and they consistently report that the various > versions of Windows have a total usage share ranging from 80% to 90%. > That at least gives us an upper and lower bound with a great deal of > confidence. In the same data, Apple systems range from about 7% to > 15%, and Linux musters a meager 1% to 3%. This data is of course skewed a bit toward computers that people are using web browsers on. Also, something like LWN tends to get more Linux users, while microsoft.com tends to get more windows users. Also, some sites only allow IE (often for rather capricious reasons), so some *ix users tell their browsers to pretend to be IE to get around the restriction - and sometimes it's just easier to pretend to be IE all the time, even when you don't really need to. And IE runs on Solaris, albeit in what is probably now an ancient version. A better measure would probably come from getting various companies managing various links of the internet backbone to set up passive fingerprinting machines. The cost of covering such links would probably be minimal, and the performance impact likely zippo, but the companies doing the work would probably not benefit much - so unless someone like Redhat or Canonical, or even Apple step up and fund it, it probably won't happen. http://en.wikipedia.org/wiki/TCP/IP_stack_fingerprinting http://lcamtuf.coredump.cx/p0f.shtml -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Tue, Apr 12, 2011 at 2:51 PM, Dan Stromberg wrote: > This data is of course skewed a bit toward computers that people are > using web browsers on. Right, Linux servers are most likely underrepresented. At best the data indicates what the population at large is using on their desktops. > Also, something like LWN tends to get more > Linux users, while microsoft.com tends to get more windows users. That's why it's important to look at a large number of sites and take more than one source of data into account. > Also, some sites only allow IE (often for rather capricious reasons), > so some *ix users tell their browsers to pretend to be IE to get > around the restriction - and sometimes it's just easier to pretend to > be IE all the time, even when you don't really need to. That is one potential issue, although I really doubt that it accounts for more than a couple of percent of the IE usage data. > And IE runs > on Solaris, albeit in what is probably now an ancient version. It also runs on Macs. Fortunately, it is standard practice to include the OS in the user-agent string, so there is no need to guess it based on the browser. -- http://mail.python.org/mailman/listinfo/python-list
Re: Copy-on-write when forking a python process
Heiko, Thank you for pointing out POSH. I have used some of python's other shared memory facilities, but was completely unaware of POSH, it seems nice. Also, I agree that shared memory would solve the use-case I outlined above, but it is not hard to imagine a slightly different case where the child processes do want to mutate the dictionary, but do not want the changes to show up in the parent process' dictionary. If shared memory is used, then a more complicated algorithm would be needed to get the desired behavior. Long story short, shared-memory is great for some things. Copy on write is great for some other things. Sometimes they are easily interchangeable, sometimes they are not. Many, if not most languages, allow the operating system to perform optimizations when a program forks that python does not allow due to the way it counts references. Many programs would be easier to write if python allowed the os to use cow. However, since I have gotten no other feedback in this list, I think that I will post this in python-ideas as well. Thanks, --jac On Apr 8, 4:29 pm, Heiko Wundram wrote: > Am 08.04.2011 20:34, schrieb jac: > > > I disagree with your statement that COW is an optimization for a > > complete clone, it is an optimization that works at the memory page > > level, not at the memory image level. In other words, if I write to a > > copy-on-write page, only that page is copied into my process' address > > space, not the entire parent image. To the best of my knowledge by > > preventing the child process from altering an object's reference count > > you can prevent the object from being copied (assuming the object is > > not altered explicitly of course.) > > As I said before: COW for "sharing" a processes forked memory is simply > an implementation-detail, and an _optimization_ (and of course a > sensible one at that) for fork; there is no provision in the semantics > of fork that an operating system should use COW memory-pages for > implementing the copying (and early UNIXes didn't do that; they > explicitly copied the complete process image for the child). The only > semantic that is specified for fork is that the parent and the child > have independent process images, that are equivalent copies (except for > some details) immediately after the fork call has returned successfully > (see SUSv4). > > What you're thinking of (and what's generally useful in the context > you're describing) is shared memory; Python supports putting objects > into shared memory using e.g. POSH (which is an extension that allows > you to place Python objects in shared memory, using the SysV > IPC-featureset that most UNIXes implement today). > > -- > --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list
Re: download web pages that are updated by ajax
> I've heard you can drive a web browser using Selenium > (http://code.google.com/p/selenium/ ), have it visit the webpage and > run the JavaScript on it, and then grab the final result. Hi, Thanks for the info. I tried selenium, you can get the source with the get_html_source() function but it returns the original HTML, not the DOM. For the problem, I found a _general solution_ at http://simile.mit.edu/wiki/Crowbar . "Crowbar is a web scraping environment based on the use of a server-side headless mozilla-based browser. Its purpose is to allow running javascript scrapers against a DOM..." A _specific solution_ for my case is to use BioPython: --- from Bio import Entrez id='CP002059.1' Entrez.email = '[email protected]' handle=Entrez.efetch(db='nucleotide',id=id,rettype='gb') local_file=open(id,'w') local_file.write(handle.read()) handle.close() local_file.close() --- Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Wed, Apr 13, 2011 at 6:26 AM, Chris Rebert 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" -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Tue, 2011-04-12 at 07:58 -0700, scattered wrote: > On Apr 12, 10:05 am, Westley Martínez wrote: > > On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote: > > > On Tue, Apr 12, 2011 at 12:20 PM, James Mills > > > wrote: > > > > On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails > > > > 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: > > > > 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Testing changes to Python code on the fly: reload() + alternatives?
On 4/12/2011 3:26 PM, Keith wrote: 1) Is it possible to reload a class using the reload() method? Yes, but instances of the old version will remain instances of the old version, which will not go away until all its instances and other references go away. So reload is deceptive, which is why it was semi-hidden away in 3.x in the inspect module. >>> class C: pass >>> c = C() >>> class C: pass # simulate reload >>> c2 = C() >>> id(c.__class__) 16018776 >>> id(c2.__class__) 16039320 2) More generally though, what is the best way to go about testing changes to code Restart from the beginning. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: OT] Free software versus software idea patents
On Tue, 2011-04-12 at 15:38 +0100, [email protected] wrote: > Hi Westley... > > > The pre-builts from Best Buy that get reloaded, reloaded with what? I > > live in California, the center of software development. I only know one > > person who uses Linux, and they only use it for work (he doesn't even > > live in CA anymore). I have say your delusions about the use of free > > software are somewhat hilarious. > > It would be mighty interesting to know what you have done for the FOSS > community > as a whole without want of monetary payment and/or recognition. > > > > > -- > 73... > > Bazza, G0LCU... > > Team AMIGA... > > http://homepages.tesco.net/wisecracker/ > > http://main.aminet.net/search?readme=wisecracker > > http://mikeos.berlios.de/ > Nothing. I'm not a charity. -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Wed, Apr 13, 2011 at 8:45 AM, Westley Martínez 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
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~
--
http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents
On Tue, 2011-04-12 at 11:13 -0700, geremy condra wrote: > On Tue, Apr 12, 2011 at 10:48 AM, CM wrote: > >> I don't even know one person who has Win7 installed, running, and likes > >> it... > >> not even one. > > > > Hi, m harris, nice to meet you. Now you do. > > > > To the online community: Is there a name for trolling for A by > > advocating for not-A in a way that discredits your point of view an > > case so that A now seems much more reasonable? It's not really > > "concern trolling". What would this be called? > > Harrisment. > > /I'm sorry, this is abuse... > > Geremy Condra That was harristerical. -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Wed, Apr 13, 2011 at 9:06 AM, Ethan Furman 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"
--
http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote:
> 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~
The question mark makes the programmer look like he wasn't sure of what
he was doing at the time. "Hmm, should I return this object or not?"
--
http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
Westley Martínez wrote:
On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote:
--> def func():
--> var1 = something()
--> var2 = something_else('this')
--> return? var1.hobgle(var2)
--> var3 = last_resort(var1)
--> return var3.wiglat(var2)
The question mark makes the programmer look like he wasn't sure of what
he was doing at the time. "Hmm, should I return this object or not?"
Yeah, I'm definitely -1 on the ?, as well as -1 on the idea. All other
major flow control uses indentation, and this does not.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Tue, 12 Apr 2011 13:37:08 -0600, Ian Kelly wrote: > There is at least one method of measuring it without resorting to sales > figures: logging user-agent data from web browsers. Is it perfectly > accurate? Of course not. But there are a number of different > organizations that do this, sampling hundreds of thousands of different > websites, and they consistently report that the various versions of > Windows have a total usage share ranging from 80% to 90%. That at least > gives us an upper and lower bound with a great deal of confidence. In > the same data, Apple systems range from about 7% to 15%, and Linux > musters a meager 1% to 3%. Yes, but it's the most important 1%. *wink* Seriously, I would expect that Linux is seriously under-reported in surveys based on user-agent, for various reasons, starting with the number of people who have their user-agent set to claim to be IE on Windows even when they're running (say) Konqueror on Linux. Nevertheless, I'd be gratified if Linux marketshare of the desktop was as high as 5%. That would be awesome. Another interesting source of data might be on-line games that offer clients for multiple platforms. E.g. EVE Online (to pick an old, well established one that just so happens to use Python as its scripting engine). -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Tue, 12 Apr 2011 13:43:00 -0400, Terry Reedy wrote: > Anyone here who does not understand how absurd software patents can get > should contemplate the following (based on a real patent from about 20 > years ago, when CDroms were new. > > A Methods for Ensuring that the Correct CDROM is in the CDROM drive. > > While the correct cdrom is not in the drive: >Display a message asking the user to insert the correct CD. > > Buried in a page of verbiage, that was it, completely obvious and > unoriginal. There's no doubt that, for some reason, the US Patent Office has an institutional blind-spot in certain areas. As the joke goes, you can take any existing patent, scrawl "on the Internet" over it in red crayon, and they will grant you a patent on it. But I'm also sure that if you look hard enough, there will be hardware patents that are as inane. For the longest time, you could patent perpetual motion machines. Now you can patent perpetual motion machines so long as you don't use the words "perpetual motion" or "free energy". The real question should not be "how bad are the worst patents?", or "how good are the best patents?", but "overall, does the patent system make things better or worse in general, and how can we reduce the harm done in favour of more good?". (I'll also point out that there's remarkably little evidence that *hardware* patents promote and support innovation and invention, even though it is conventional wisdom that it does. People on *both* sides of the debate are amazingly resistant to the idea of evidence-based policy.) >> That is what made the last Supreme Court decision (from this argument >> in part) so important... because for the first time the U.S. Supreme >> Court is beginning to buy it ... in part. > > What might help lawyers understand the obsurdity of software patents > would be to have them contemplate the possibility of patents on laws and > legal arguments, so that a legislature could not write a law, nor a > lawyer submit a legal brief, without possibly having to pay royalties or > violate a patent. That would be a patent on a business process, which is allowed. In fact, as I recall, at least one lawyer has made an attempt to patent a business process relating to law. Too-lazy-to-google-for-it-ly y'rs, -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Tue, 12 Apr 2011 16:48:31 -0700, Ethan Furman wrote:
> Westley Martínez wrote:
>> On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote:
>>> --> def func():
>>> --> var1 = something()
>>> --> var2 = something_else('this') --> return?
>>> var1.hobgle(var2)
>>> --> var3 = last_resort(var1)
>>> --> return var3.wiglat(var2)
>>
>> The question mark makes the programmer look like he wasn't sure of what
>> he was doing at the time. "Hmm, should I return this object or not?"
>>
>>
> Yeah, I'm definitely -1 on the ?, as well as -1 on the idea. All other
> major flow control uses indentation, and this does not.
Neither return nor raise use indentation, and you don't get much more
major than those. Nor do list comps or generator expressions.
Indentation is not appropriate here because it doesn't involve a block of
code. The whole point is that it just involves a single expression.
But in any case, I'm -1 on any syntax involving ? in Python, and +0 on
the concept on a conditional return. I suspect it's too specialised to be
worth special syntax or a keyword, but I can definitely see some uses for
it.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Free software versus software idea patents
On Tue, Apr 12, 2011 at 4:56 PM, Steven D'Aprano wrote: > That would be a patent on a business process, which is allowed. In fact, > as I recall, at least one lawyer has made an attempt to patent a business > process relating to law. IBM tried patenting the business of patent trolling, which I found hilarious. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
Re: Can not uninstall activepython. Missing msi ?
Looks like this is resolved for you, http://community.activestate.com/node/6558 On Tue, Apr 12, 2011 at 10:13 AM, goldtech wrote: > Hi, > > I want to uninstall Active Python 2.6.2.2 and upgrade. Certain things > are not working and it's probably time to upgrade anyway. When I try > to uninstall it says "missing msi". > > Before I delete all the folders and clean the registry out is there > something I can try to have a normal or more graceful uninstall? Using > WinXP. > > Thanks, > > Lee G. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
[Bug / Feature Request] IDLE Shell
Hello folks, In the IDLE shell when pressing the key combos "Control+Up" and "Control+Down" the insertion cursor should jump to the nearest prompt (>>>) above or below it's current position respectively. Note: In the Editor Window of IDLE the current behavior is for the insertion cursor to jump to the next block (which is just fine for the Editing Source code!) HOWEVER in the shell we need a much more intelligent behavior. py> shell != editor True -- http://mail.python.org/mailman/listinfo/python-list
Re: [Bug / Feature Request] IDLE Shell
On Wed, Apr 13, 2011 at 11:50 AM, rantingrick wrote: > In the IDLE shell when pressing the key combos "Control+Up" and > "Control+Down" the insertion cursor should jump to the nearest prompt > (>>>) above or below it's current position respectively. > > Note: In the Editor Window of IDLE the current behavior is for the > insertion cursor to jump to the next block (which is just fine for the > Editing Source code!) HOWEVER in the shell we need a much more > intelligent behavior. Not to be rude or anything - but why can't you get the latest IDLE source code, patch it, test it, see how you like it and if you feel it useful, share the patch and/or file a bug with the patch. cheers James -- -- James Mills -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
Steven D'Aprano wrote:
On Tue, 12 Apr 2011 16:48:31 -0700, Ethan Furman wrote:
Westley Martínez wrote:
On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote:
--> def func():
--> var1 = something()
--> var2 = something_else('this') --> return?
var1.hobgle(var2)
--> var3 = last_resort(var1)
--> return var3.wiglat(var2)
The question mark makes the programmer look like he wasn't sure of what
he was doing at the time. "Hmm, should I return this object or not?"
Yeah, I'm definitely -1 on the ?, as well as -1 on the idea. All other
major flow control uses indentation, and this does not.
Neither return nor raise use indentation, and you don't get much more
major than those. Nor do list comps or generator expressions.
The indentation for return and raise is the next coded line. List comps
and gen exps are basically uber-functions, and regardless of how you
categorize them when they finish it is easy to see where control goes to
next because of indentation. With this idea flow can leave the function
with no indentation clue, making it easy to miss (assuming, of course,
it's not some bright syntax highlighted color).
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Wed, Apr 13, 2011 at 12:42 PM, Ethan Furman wrote: > The indentation for return and raise is the next coded line. List comps and > gen exps are basically uber-functions, and regardless of how you categorize > them when they finish it is easy to see where control goes to next because > of indentation. With this idea flow can leave the function with no > indentation clue, making it easy to miss (assuming, of course, it's not some > bright syntax highlighted color). So if I have a function that can early-abort, I should indent after that? def foo(param): resource=malloc(5) # Shtarker, zis is Python! We don't malloc here! if not resource: return 0 resource[param]=5 del resource return 1 Now, this pattern of "attempt to acquire resource, return if unable to" is probably better recoded as "acquire resource and have it throw an error if it can't"; but if you're eyeballing for control-flow changes, a called function throwing an error is even less obvious than an if: return. Where should the indentation go? As I understand it, Python uses indents the way C uses braces - to delimit blocks of code. The only reason to indent in foo() above would be if the if has an else: if not resource: return 0 else: resource[param]=5 del resource return 1 or, flipping that the other way around: if resource: resource[param]=5 del resource return 1 return 0 but both of these are grossly inferior to: def foo(param): resource=generate_resource() resource.dosomething(param,5) return 1 However, what's to tell you that generate_resource() will throw a KaosError if Siegfried is around? (Oh, and apologies to all for picking a different comedy source for my references. Sometimes even a python has to get smart...) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 91, Issue 89
Sent from my iPhone On Apr 12, 2011, at 8:05 PM, [email protected] wrote: > Send Python-list mailing list submissions to >[email protected] > > To subscribe or unsubscribe via the World Wide Web, visit >http://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body 'help' to >[email protected] > > You can reach the person managing the list at >[email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-list digest..." > Today's Topics: > > 1. Re: Feature suggestion -- return if true (Ethan Furman) > 2. Re: [OT] Free software versus software idea patents > (Steven D'Aprano) > 3. Re: [OT] Free software versus software idea patents > (Steven D'Aprano) > 4. Re: Feature suggestion -- return if true (Steven D'Aprano) > 5. Re: [OT] Free software versus software idea patents > (geremy condra) > 6. Re: Can not uninstall activepython. Missing msi ? > (Sridhar Ratnakumar) > 7. [Bug / Feature Request] IDLE Shell (rantingrick) > 8. Re: [Bug / Feature Request] IDLE Shell (James Mills) > 9. Re: Feature suggestion -- return if true (Ethan Furman) > 10. Re: Feature suggestion -- return if true (Chris Angelico) > Westley Mart�nez wrote: >> On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote: >>> --> def func(): >>> --> var1 = something() >>> --> var2 = something_else('this') >>> --> return? var1.hobgle(var2) >>> --> var3 = last_resort(var1) >>> --> return var3.wiglat(var2) >> The question mark makes the programmer look like he wasn't sure of what >> he was doing at the time. "Hmm, should I return this object or not?" > > Yeah, I'm definitely -1 on the ?, as well as -1 on the idea. All other major > flow control uses indentation, and this does not. > > ~Ethan~ > > On Tue, 12 Apr 2011 13:37:08 -0600, Ian Kelly wrote: > >> There is at least one method of measuring it without resorting to sales >> figures: logging user-agent data from web browsers. Is it perfectly >> accurate? Of course not. But there are a number of different >> organizations that do this, sampling hundreds of thousands of different >> websites, and they consistently report that the various versions of >> Windows have a total usage share ranging from 80% to 90%. That at least >> gives us an upper and lower bound with a great deal of confidence. In >> the same data, Apple systems range from about 7% to 15%, and Linux >> musters a meager 1% to 3%. > > Yes, but it's the most important 1%. > > *wink* > > > Seriously, I would expect that Linux is seriously under-reported in > surveys based on user-agent, for various reasons, starting with the > number of people who have their user-agent set to claim to be IE on > Windows even when they're running (say) Konqueror on Linux. Nevertheless, > I'd be gratified if Linux marketshare of the desktop was as high as 5%. > That would be awesome. > > Another interesting source of data might be on-line games that offer > clients for multiple platforms. E.g. EVE Online (to pick an old, well > established one that just so happens to use Python as its scripting > engine). > > > > > -- > Steven > > On Tue, 12 Apr 2011 13:43:00 -0400, Terry Reedy wrote: > >> Anyone here who does not understand how absurd software patents can get >> should contemplate the following (based on a real patent from about 20 >> years ago, when CDroms were new. >> >> A Methods for Ensuring that the Correct CDROM is in the CDROM drive. >> >> While the correct cdrom is not in the drive: >> Display a message asking the user to insert the correct CD. >> >> Buried in a page of verbiage, that was it, completely obvious and >> unoriginal. > > There's no doubt that, for some reason, the US Patent Office has an > institutional blind-spot in certain areas. As the joke goes, you can take > any existing patent, scrawl "on the Internet" over it in red crayon, and > they will grant you a patent on it. > > But I'm also sure that if you look hard enough, there will be hardware > patents that are as inane. For the longest time, you could patent > perpetual motion machines. Now you can patent perpetual motion machines > so long as you don't use the words "perpetual motion" or "free energy". > > The real question should not be "how bad are the worst patents?", or "how > good are the best patents?", but "overall, does the patent system make > things better or worse in general, and how can we reduce the harm done in > favour of more good?". > > (I'll also point out that there's remarkably little evidence that > *hardware* patents promote and support innovation and invention, even > though it is conventional wisdom that it does. People on *both* sides of > the debate are amazingly resistant to the idea of evidence-based policy.) > > > >>> That is what made the last Supreme Court decision (from this argument >>> in part) so important... because for th
Re: Feature suggestion -- return if true
On Wed, Apr 13, 2011 at 1:00 PM, Chris Angelico wrote: > def foo(param): > resource=malloc(5) # Shtarker, zis is Python! We don't malloc here! > if not resource: return 0 > resource[param]=5 > del resource > return 1 In Python this can probably be done and perhaps is slightly more readble with the "with" statement and a context manager: def foo(param): try: with ResourceAllocator(5) as resource: resource[param] = 5 return 1 except: return 0 Now I know I'm only adding to the discussion (argument) but hey it's all in good fun until someone looses an eyeball! cheers James -- -- James Mills -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
zildjohn01 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. -- http://mail.python.org/mailman/listinfo/python-list
