Re: Array of hash table
jyoti690sa...@gmail.com wrote: > Hello, > >Can any one tell me how to create >graph={ > "nodes": [ > { > "id": "n0", > "label": "A node", > "x": 0, > "y": 0, > "size": 3 > }, > { > "id": "n1", > "label": "Another node", > "x": 3, > "y": 1, > "size": 2 > }, > { > "id": "n2", > "label": "And a last one", > "x": 1, > "y": 3, > "size": 1 > } > ], > "edges": [ > { > "id": "e0", > "source": "n0", > "target": "n1", > "label" : "dfghujikoi" > }, > { > "id": "e1", > "label" : "dfghujikoi", > "source": "n1", > "target": "n2" > > }, > { > "id": "e2", > "source": "n2", > "target": "n0", > "label" : "dfghujikoi" > } > ] > } > > using python? > > its like a hash table and value is an array of hash table ? > I tried but it was giving error of "List out of index" . (1) Was that something like >>> [][1] Traceback (most recent call last): File "", line 1, in IndexError: list index out of range ? Please always copy and paste the traceback, don't rephrase. (2) Show us the code that caused the error. If you provide some context it is easier for us to identify your problem. But if I were to guess: are you coming from a language where lists grow automatically? In Python they don't. Instead of mylist = [] for i in range(3): mylist[i] = 42 # WRONG, raises IndexError you usually write mylist = [] for i in range(3): mylist.append(42) though in this particular case mylist = [42] * 3 would work, too. -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
Devin Jeanpierre wrote: > On Thu, Jan 8, 2015 at 6:43 PM, Dave Angel wrote: >> What you don't say is which behavior you actually expected. Since 0**0 >> is undefined mathematically, I'd expect either an exception or a NAN >> result. > > It can be undefined, if you choose for it to be. You can also choose > to not define 0**1, of course. No you can't -- that would make arithmetic inconsistent. 0**1 is perfectly well defined as 0 however you look at it: lim of x -> 0 of x**1 = 0 lim of y -> 1 of 0**y = 0 > If 0**0 is defined, it must be 1. I > Googled around to find a mathematician to back me up, here: > http://arxiv.org/abs/math/9205211 (page 6, "ripples"). Not quite. I agree that, *generally speaking* having 0**0 equal 1 is the right answer, or at least *a* right answer, but not always. It depends on how you get to 0**0... Since you can get difference results depending on the method you use to calculate it, the "technically correct" result is that 0**0 is indeterminate. But that's not terribly useful, and mathematicians with a pragmatic bent (i.e. most of them) define 0**0 == 1 on the basis that it is justifiable and useful, while 0**0 = 0 is justifiable but not useful and leaving it as indeterminate is just a pain. One argument comes from taking limits of x**y. If you set x to zero, and take the limit as y approaches 1, you get: lim of y -> 0 of 0**y = 0 But if you set y to 0, and take the limit as x approaches 0, you get: lim of x -> 0 of x**0 = 1 There is a discontinuity in the graph of x**y, and no matter what value you define 0**0 as, you cannot get rid of that discontinuity. Hence indeterminate. Here's another argument for keeping it indeterminate. Suppose we let 0**0 = some value Q. Let's take the logarithm of Q. log(Q) = log (0**0) But log (a**b) = b*log(a), so: log(Q) = 0*log(0) What's log(0)? If we take the limit from above, we get log(x) -> -infinity. If we take the limit from below, we get a complex infinity, so let's ignore the limit from below and informally write: log(Q) = 0*-inf What is zero times infinity? In the real number system, that is indeterminate, again because it depends on how you calculate it: naively it sounds like it should be 0, but infinity is pretty big and if you add up enough zeroes in the right way you can actually get something non-zero. There's no one right answer. So if the log of Q is indeterminate, then so must be Q. But there are a host of good reasons for preferring 0**0 = 1. Donald Knuth writes (using ^ for power): Some textbooks leave the quantity 0^0 undefined, because the functions 0^x and x^0 have different limiting values when x decreases to 0. But this is a mistake. We must define x^0=1 for all x , if the binomial theorem is to be valid when x=0, y=0, and/or x=-y. The theorem is too important to be arbitrarily restricted! By contrast, the function 0^x is quite unimportant. More discussion here: http://mathforum.org/dr.math/faq/faq.0.to.0.power.html > I expected 1, nan, or an exception, but more importantly, I expected > it to be the same for floats and decimals. Arguably, *integer* 0**0 could be zero, on the basis that you can't take limits of integer-valued quantities, and zero times itself zero times surely has to be zero. But in practice, I agree that 0**0 should give the same result regardless of the type of zeroes used, and if the result is a number rather than a NAN or an exception, it should be 1. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
Marko, your argument is "this function x**y(a, x) must be continuous on [0, inf), and to be continuous at 0, 0**0 must be a". Since there are many possible values of a, this is not a "justification", this is a proof by contradiction that the premise was faulty: x**y(a, x) doesn't have to be continuous after all. 0**0 is 1, which makes some functions continuous and some functions not, and who cares? It's 1 because that's what is demanded by combinatorial definitions of exponentiation, and its origins in the domain of the natural numbers. Knuth says that thought of combinatorially on the naturals, x**y counts the number of mappings from a set of x values to a set of y values. Clearly there's only one mapping from the empty set to itself: the empty mapping. Number theory demands that performing multiplication among an empty bag of numbers gives you the result of 1 -- even if the empty bag is an empty bag of zeroes instead of an empty bag of fives. The result does not change. Either of those ideas about exponentiation can be thought of as descriptions of its behavior, or as definitions. They completely describe its behavior on the naturals, from which we derive its behavior on the reals. -- Devin On Thu, Jan 8, 2015 at 11:28 PM, Marko Rauhamaa wrote: > Devin Jeanpierre : > >> If 0**0 is defined, it must be 1. > > You can "justify" any value a within [0, 1]. For example, choose > >y(a, x) = log(a, x) > > Then, > > limy(a, x) = 0 >x -> 0+ > > and: > >lim[x -> 0+] x**y(a, x) = a > > For example, > >>>> a = 0.5 >>>> x = 1e-100 >>>> y = math.log(a, x) >>>> y >0.0030102999566398118 >>>> x**y >0.5 > > > Marko > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
On Fri, Jan 9, 2015 at 12:49 AM, Steven D'Aprano wrote: > Devin Jeanpierre wrote: > >> On Thu, Jan 8, 2015 at 6:43 PM, Dave Angel wrote: >>> What you don't say is which behavior you actually expected. Since 0**0 >>> is undefined mathematically, I'd expect either an exception or a NAN >>> result. >> >> It can be undefined, if you choose for it to be. You can also choose >> to not define 0**1, of course. > > No you can't -- that would make arithmetic inconsistent. 0**1 is perfectly > well defined as 0 however you look at it: > > lim of x -> 0 of x**1 = 0 > lim of y -> 1 of 0**y = 0 This is a misunderstanding of limits. Limits are allowed to differ from the actual evaluated result when you substitute the limit point: that's what it means to be discontinuous. What you call making arithmetic "inconsistent", I call making the function inside the limit discontinuous at 0. > >> If 0**0 is defined, it must be 1. I >> Googled around to find a mathematician to back me up, here: >> http://arxiv.org/abs/math/9205211 (page 6, "ripples"). > > Not quite. I agree that, *generally speaking* having 0**0 equal 1 is the > right answer, or at least *a* right answer, but not always. It depends on > how you get to 0**0... You don't "get to" a number. Those are limits. Limits and arithmetic are different. (Well, sort of. :) > Since you can get difference results depending on the method you use to > calculate it, the "technically correct" result is that 0**0 is > indeterminate. No, only limits are indeterminate. Calculations not involving limits cannot be indeterminate. -snip- > log(Q) = 0*-inf > > What is zero times infinity? In the real number system, that is > indeterminate, again because it depends on how you calculate it In the real number system, infinity does not exist. It only exists in limits or extended number systems. > : naively it > sounds like it should be 0, but infinity is pretty big and if you add up > enough zeroes in the right way you can actually get something non-zero. > There's no one right answer. So if the log of Q is indeterminate, then so > must be Q. > > But there are a host of good reasons for preferring 0**0 = 1. Donald Knuth > writes (using ^ for power): > > Some textbooks leave the quantity 0^0 undefined, because the > functions 0^x and x^0 have different limiting values when x > decreases to 0. But this is a mistake. We must define x^0=1 > for all x , if the binomial theorem is to be valid when x=0, > y=0, and/or x=-y. The theorem is too important to be arbitrarily > restricted! By contrast, the function 0^x is quite unimportant. > > More discussion here: > > http://mathforum.org/dr.math/faq/faq.0.to.0.power.html I've already been citing Knuth. :P >> I expected 1, nan, or an exception, but more importantly, I expected >> it to be the same for floats and decimals. > > Arguably, *integer* 0**0 could be zero, on the basis that you can't take > limits of integer-valued quantities, and zero times itself zero times > surely has to be zero. No. No no no. On natural numbers no other thing makes sense than 1. All of the definitions of exponentiation for natural numbers require it, except for those derived from analytical notions of exponentiation. (Integers just give you ratios of natural exponentials, so again no.) -- Devin -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
Devin Jeanpierre writes: [...] > domain of the natural numbers. Knuth says that thought of > combinatorially on the naturals, x**y counts the number of mappings > from a set of x values to a set of y values. It's the other way around, of course: from a set of y values to a set of x values. Which reminds me of a question that once made me smile, even laugh, and still does: 2**3 is almost 3**2 but not quite - what gives? > Clearly there's only one mapping from the empty set to itself: the [...] -- https://mail.python.org/mailman/listinfo/python-list
Re: Announce: PyPrimes 0.2.1a
On Fri, 09 Jan 2015 11:50:26 +1100, Chris Angelico wrote: > On Fri, Jan 9, 2015 at 11:41 AM, Steven D'Aprano > wrote: >> "oh, pip did the wrong thing again? you can fix that by standing on one >> leg, >> sacrificing a goat to the Great Old Dark Ones, deleting these files, or >> possibly some other ones, and if the phase of the moon is exactly right >> it will behave as you want..." > > Replacing an existing package, without changing the version number, > *is* messy. It's not pip's fault that it's hard. That's like saying > "Oops, I committed this to source control and pushed it out to all > users, but there's a big file in it and I want to delete it so they > don't have to download it". Sure, that's possible, but it's not a normal > action, so you'll have to jump through some hoops to make it all work > properly. > > Or have you been having this whole sacrificing a goat thing with a > normal workflow? > > ChrisA why not simply cheat & call it V 0.2.3 :-) it is not as if there is any regulation concerning what can & cannot constitute a minor release it is all at your own discretion. -- Stamp out philately. -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
On Fri, Jan 9, 2015 at 12:58 AM, Devin Jeanpierre wrote: >> Arguably, *integer* 0**0 could be zero, on the basis that you can't take >> limits of integer-valued quantities, and zero times itself zero times >> surely has to be zero. I should have responded in more detail here, sorry. If you aren't performing any multiplication, why does it matter what numbers you are "multiplying"? Doing no multiplications of five is the same as doing no multiplications of two is the same as doing no multiplications of... 0. You can define it to be 0 but only if you are multiplying an empty bag of zeroes, but it's hard to imagine what makes an empty bag of zeroes different from an empty bag of fives. It really surely is *not* the case. Obviously, this kind of ridiculousness comes naturally to Java and C++ programmers, with their statically typed collections. It's no surprise that's where the Decimal spec came from. ;) -- Devin -- https://mail.python.org/mailman/listinfo/python-list
Re: py2c - an open source Python to C/C++ is looking for developers
On Monday, July 30, 2012 at 6:27:04 AM UTC-7, Ramchandra Apte wrote: > I created py2c ( http://code.google.com/p/py2c )- an open source Python to > C/C++ translator! > py2c is looking for developers! > To join create a posting in the py2c-discuss Google Group or email me! > Thanks > PS:I hope this is the appropiate group for this message. this is actually a great project, because i see a lot of programmers embedding the whole python into their c++ application even the python compiler and all its libraries. and i hope this could solve that problem one day... look what matlab did matlab to C/C++ which is great and what python was missing was that feature. python is so good for algorithm development and c/c++ is so easy for machines to execute. -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
Chris Angelico : > I'm not a mathematical expert, so I don't quite 'get' this. How does > this justify 0**0 being equal to 0.5? Many operations like this are defined in terms of some very strong argument of uniqueness. Ultimately, the key point is safety in mathematical deductions. One minimal requirement would be: limf(x, y) (x, y) -> (0, 0) must be defined (See http://en.wikipedia.org/wiki/Limit_of_a_func tion#Functions_of_more_than_one_variable>). If you get sloppy, there is a real risk of terrible logical mistakes and wrong results. I think having 0**0 return a value is as irresponsible as having 0/0 return a value. (The very same principle is used to define 0+0 and 0*0 as well.) Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
Steven D'Aprano : > mathematicians with a pragmatic bent You shouldn't call engineers and scientists mathematicians ("with a pragmatic bent"). Rigor is an absolute requirement for any mathematics. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
Steven D'Aprano : > Devin Jeanpierre wrote: > No you can't -- that would make arithmetic inconsistent. 0**1 is > perfectly well defined as 0 however you look at it: You *could* leave 0**1 undefined. You *could* leave 7+0 undefined. However, that would make mathematical proofs more complex as they would be riddled with if/else branches. That's the whole point of silly "no-op" definitions such as a+0 or b**1; they make mathematical proofs much more concise and feasible. It is precious to be able to have such "ideal" cases defined, and you'd like to do it everywhere. Unfortunately, it is not possible everywhere so you just have to supply the necessary if/else branches in your proof. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
I think we're in violent agreement here, nevertheless I think you're right for the wrong reasons. See below... Devin Jeanpierre wrote: > On Fri, Jan 9, 2015 at 12:49 AM, Steven D'Aprano > wrote: >> Devin Jeanpierre wrote: >> >>> On Thu, Jan 8, 2015 at 6:43 PM, Dave Angel wrote: What you don't say is which behavior you actually expected. Since 0**0 is undefined mathematically, I'd expect either an exception or a NAN result. >>> >>> It can be undefined, if you choose for it to be. You can also choose >>> to not define 0**1, of course. >> >> No you can't -- that would make arithmetic inconsistent. 0**1 is >> perfectly well defined as 0 however you look at it: >> >> lim of x -> 0 of x**1 = 0 >> lim of y -> 1 of 0**y = 0 I should have used "x" for the variable in both expressions: lim of x -> 0 of x**1 = 0 lim of x -> 1 of 0**x = 0 > This is a misunderstanding of limits. Limits are allowed to differ > from the actual evaluated result when you substitute the limit point: > that's what it means to be discontinuous. That's true, if the function is discontinuous. But it's irrelevant here. Neither x**1 nor 0**x are discontinuous, they're both continuous, and both have the same limit for x->0 in the first place and x->1 in the second. However you do it, 0**1 must be 0. > What you call making arithmetic "inconsistent", I call making the > function inside the limit discontinuous at 0. I don't understand what you're trying to say here. You can't just arbitrarily declare that 0**1 equals something other than 0 (or for that matter, doesn't equal anything at all). 0**1 = (5-5)**1 = 5-5 = 0 If you want to say that 0**1 != 0, then you likewise have to say that 5-5 != 0, otherwise arithmetic is inconsistent. Can we agree that 0**1 is well-defined and get back to 0**0? >>> If 0**0 is defined, it must be 1. I >>> Googled around to find a mathematician to back me up, here: >>> http://arxiv.org/abs/math/9205211 (page 6, "ripples"). >> >> Not quite. I agree that, *generally speaking* having 0**0 equal 1 is the >> right answer, or at least *a* right answer, but not always. It depends on >> how you get to 0**0... > > You don't "get to" a number. Those are limits. Limits and arithmetic > are different. > > (Well, sort of. :) Yes, sort of :-) Of course you can "get to" numbers. We start with counting, that's a way to "get to" the natural numbers, by applying the "successor" function repeatedly until we reach the one we want. Or you can "get to" pi by generating an infinite sequence of closer and closer approximations. Or an infinite series. Or an infinite product. Or an infinite continued fraction. All of these "ways to get to pi" converge on the same result. If 0**0 has a value, we can give that number a name. Let's call it Q. There are different ways to evaluate Q: lim x -> 0 of sin(x)/x gives 1 lim x -> 0 of x**0 gives 1 lim x -> 0 of 0**x gives 0 0**0 = 0**(5-5) = 0**5 / 0**5 = 0/0 gives indeterminate So we have a problem. Since all these "ways to get to Q" fail to converge, the obvious answer is to declare that Q doesn't exist and that 0**0 is indeterminate, and that is what many mathematicians do: http://mathworld.wolfram.com/Indeterminate.html However, this begs the question of what we mean by 0**0. In the case of m**n, with both m and n positive integers, there is an intuitively obvious definition for exponentiation: repeated multiplication. But there's no obvious meaning for exponentiation when both m and n are zero, hence we (meaning, mathematicians) have to define what it means. So long as that definition doesn't lead to contradiction, we can make any choice we like. Hence some mathematicians decide that things like the Binomial Theorem are far more important than 0**x, and so they define 0**0 as 1. They can justify that definition, of course, it's not just arbitrary, but the important thing is that mathematicians working in other fields can and do sometimes use a slightly different definition, one where 0**0 is indeterminate. http://www.askamathematician.com/2010/12/q-what-does-00-zero-raised-to-the-zeroth-power-equal-why-do-mathematicians-and-high-school-teachers-disagree/ >> Since you can get difference results depending on the method you use to >> calculate it, the "technically correct" result is that 0**0 is >> indeterminate. > > No, only limits are indeterminate. Calculations not involving limits > cannot be indeterminate. Do tell me what 0/0 equals, if it is not indeterminate. > -snip- >> log(Q) = 0*-inf >> >> What is zero times infinity? In the real number system, that is >> indeterminate, again because it depends on how you calculate it > > In the real number system, infinity does not exist. It only exists in > limits or extended number systems. Yes, you are technically correct, the best kind of correct. I'm just sketching an informal proof. If you want to make it vigorous by using limits, be my guest. It doesn't change the conclusion. [...] >> Ar
Re: Decimals and other numbers
On Fri, Jan 9, 2015 at 9:20 PM, Steven D'Aprano wrote: > On the basis that m**n means m multiplied by itself n times: > > 5**4 = 5*5*5*5 = 625 > > that gives us: > > 0**0 = zero multiplied by itself zero times. > > You can multiply 0 by any number you like, and the answer will always be 0, > not 1. Even if that other number is 0, the answer is still 0. 5 * 0 * 0 * 0 * 0 = 0 You can multiply 5 by 0 any number of times you like, and the answer will always be 0... unless you never multiply it by 0 at all, in which case it'll be 5. Multiplying 0 by any number, including 0, is 0... but *not* multiplying 0 by 0 doesn't have to give 0. 0**0 is the result of not multiplying any zeroes together, so it doesn't follow the rules of multiplying zeroes together. Look at it another way. 6**x modulo 10 will always be 6, right? 6, 36, 216... the rules for multiplying mean that the last digit will be consistent. (That's how we can know what the last digits of Graham's Number are, despite having no way to even comprehend its scale.) So what's 6**0? Is that going to end with 6, too, to be consistent? No, because we're not multiplying any sixes in, so the answer's simply 1. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
PythonFOSDEM 2015 and Plush Snake
Hi all, I am really happy to announce we found a correct plush snake for Python. There is a survey and a post about this plush: http://pythonfosdem.tumblr.com/post/107584468521/survey-will-you-be-interested-by-a-plush-snake If you come at PythonFOSDEM 2015 and you think you will buy this snake, please, fill the survey. The minimal quantity for this item is 48 for the supplier, and I need to know an approximative quantity for PythonFOSDEM. Thank you, Stephane -- Stéphane Wirtel - http://wirtel.be - @matrixise -- https://mail.python.org/mailman/listinfo/python-list
Why do the URLs of posts here change?
I have come across this in the past, but today it annoyed me enough that I'm asking for an explanation. Posts on this newsgroup/mailing list are archived on the web, but the URLs seem to change, which leaves dead links if you search for things. For example, today I searched for a quote about floating point equality by William Kahan, and I came across this post by me: https://mail.python.org/pipermail/python-list/2008-February/468598.html But that's a dead link! Here's Google's cache of it: http://webcache.googleusercontent.com/search?client=opera&rls=en&q=cache:i0cWb0Tjxe0J:https://mail.python.org/pipermail/python-list/2008-February/468598.html%2Bfloating+point+superstition+equality&oe=utf-8&channel=suggest&gws_rd=ssl&hl=en&&ct=clnk And here is the actual URL, as it appears today: https://mail.python.org/pipermail/python-list/2008-February/481374.html Why has the URL changed? Surely this is a bug? Where can I report it? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
Marko Rauhamaa wrote: > Steven D'Aprano : > >> mathematicians with a pragmatic bent > > You shouldn't call engineers and scientists mathematicians ("with a > pragmatic bent"). Rigor is an absolute requirement for any mathematics. I wasn't referring to engineers, scientists, short-order cooks or cat walk models. I was referring to mathematicians. Mathematicians with a pragmatic bent. Or to put it another way, the intersection between the set of pragmatic people and the set of mathematicians. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Announce: PyPrimes 0.2.1a
alister writes: > why not simply cheat & call it V 0.2.3 :-) it is not as if there is > any regulation concerning what can & cannot constitute a minor release > it is all at your own discretion. Not a regulation, but a convention which it is good etiquette to follow http://semver.org/>. Version strings are a communication, and communication is only useful if conventions of meaning are more or less reliable. -- \“I hate it when my foot falls asleep during the day, because | `\that means it's gonna be up all night.” —Steven Wright | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Announce: PyPrimes 0.2.1a
On Fri, 09 Jan 2015 22:01:38 +1100, Ben Finney wrote: > alister writes: > >> why not simply cheat & call it V 0.2.3 :-) it is not as if there is any >> regulation concerning what can & cannot constitute a minor release it >> is all at your own discretion. > > Not a regulation, but a convention which it is good etiquette to follow > http://semver.org/>. Version strings are a communication, and > communication is only useful if conventions of meaning are more or less > reliable. true, but this is a modification to the released code so a minor release change could be justified, especially so early in the development cycle it would not do to make a habit of it though -- The last time I saw him he was walking down Lover's Lane holding his own hand. -- Fred Allen -- https://mail.python.org/mailman/listinfo/python-list
hello please can you help me with the below problem am facing
Please how can I make an .exe executable app out of my python script easily -- https://mail.python.org/mailman/listinfo/python-list
Re: Why do the URLs of posts here change?
> Posts on this newsgroup/mailing list are archived on the web, but the URLs > seem to change, which leaves dead links if you search for things. Steven, It's a known issue, but one which appears to be somewhat unavoidable, at least in Mailman 2.x. The problem is that every now and then, postmas...@python.org gets a legitimate request from someone for a message to be deleted from the list archive. The way this is done, is that the message is removed from the underlying mbox file, and the archive regenerated. That changes the counter for every message after that point - or maybe every message in the generated archive. (I have no idea why the numerical basename of your subject message would have changed so much. Maybe there is just a single ever incrementing counter for a given Mailman installation.) >From a technical standpoint, these sorts of requests are pretty futile, since comp.lang.python/python-list@python.org is archived in so many places, but that doesn't make the requests any less legitimate. Consequently, when they arrive at the postmaster address, they are generally taken care of in short order. In my experience, they have generally fallen into two categories: 1. Safety. I recall one request where a woman accidentally posted using an otherwise private email address. She was being stalked by her ex-husband, and that address was unknown to him. 2. Defamation. There was a spate of recent messages (in Italian) defaming a couple people, accusing them of being Nazis or pedophiles. I will point out one class of messages which aren't deleted: those which demonstrate people's stupidity. People do dumb things - e.g., fly off the handle during a flame war - which they sometimes later realize reflects rather poorly on them (in future job searches and so forth). Those sorts of message deletion requests are rejected. That all said, I don't know if Mailman 3 (or some other archiver than pipermail) will improve on this problem. I suggest a post to mailman-us...@python.org if you're curious about the Mailman state-of-the-art in this area. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Why do the URLs of posts here change?
Steven D'Aprano wrote: > I have come across this in the past, but today it annoyed me enough that > I'm asking for an explanation. > > Posts on this newsgroup/mailing list are archived on the web, but the URLs > seem to change, which leaves dead links if you search for things. > > For example, today I searched for a quote about floating point equality by > William Kahan, and I came across this post by me: > > https://mail.python.org/pipermail/python-list/2008-February/468598.html > > But that's a dead link! Here's Google's cache of it: > > http://webcache.googleusercontent.com/search?client=opera&rls=en&q=cache:i0cWb0Tjxe0J:https://mail.python.org/pipermail/python-list/2008-February/468598.html%2Bfloating+point+superstition+equality&oe=utf-8&channel=suggest&gws_rd=ssl&hl=en&&ct=clnk > > And here is the actual URL, as it appears today: > > https://mail.python.org/pipermail/python-list/2008-February/481374.html > > > Why has the URL changed? Surely this is a bug? Where can I report it? This is a flaw of the mailman software. http://wiki.list.org/display/DEV/Stable+URLs suggests that the developers are aware of it. I don't know if there is a version available that has stable urls... -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
I want to emphasis that I'm not really arguing that 0**0 should evaluate as 0. That's probably the least useful thing we can have out of the four possibilities: - return 1 - return NAN - raise an exception - return 0 But in the spirit of the Devil's Advocate, I mentioned that there was an argument to be made for having integer 0**0 return 0. Intuitively, we have: 0**5 = 0 0**4 = 0 0**3 = 0 0**2 = 0 0**1 = 0 0**0 = ? It's not hard to see that 0**n = 0 for every n except 0, so why make an exception for 0? I stress that there are *better* arguments for making that exception and having 0**0 defined as 1. My argument is merely that there is *an argument* for having 0**0 return 0. I could put it this way: If you start with nothing and raise it to the power of nothing, then there is nothing to exponentiate and you're left with nothing. More below. Chris Angelico wrote: > On Fri, Jan 9, 2015 at 9:20 PM, Steven D'Aprano > wrote: >> On the basis that m**n means m multiplied by itself n times: >> >> 5**4 = 5*5*5*5 = 625 >> >> that gives us: >> >> 0**0 = zero multiplied by itself zero times. >> >> You can multiply 0 by any number you like, and the answer will always be >> 0, not 1. Even if that other number is 0, the answer is still 0. > > 5 * 0 * 0 * 0 * 0 = 0 Where did the 5 come from? You're effectively saying that 0**0 becomes 5*0**0, then cancelling the 0**0 because they're all zeroes and so don't matter, leaving 5. And that simply doesn't work. If it did work, there's nothing special about 5, we could use 18 instead: 0**0 = 5*0**0 => 5 but 0**0 = 18*0**0 => 18 therefore 5 = 18. Yay maths! :-) > You can multiply 5 by 0 any number of times you like, and the answer > will always be 0... unless you never multiply it by 0 at all, in which > case it'll be 5. Multiplying 0 by any number, including 0, is 0... but > *not* multiplying 0 by 0 doesn't have to give 0. 0**0 is the result of > not multiplying any zeroes together, so it doesn't follow the rules of > multiplying zeroes together. If you want to be vigorous, we're both talking nonsense. Exponentiation in terms of repeated multiplication only works for non-zero powers. Talking about "multiplication by itself zero times" raises the question "what the hell do you mean by multiplication by itself zero times?" There are ways to make this vigorous. The problem is, with 0**0, you get a different answer depending on how you make it vigorous. Hence 0**0 is indeterminate. > Look at it another way. 6**x modulo 10 will always be 6, right? 6, 36, > 216... the rules for multiplying mean that the last digit will be > consistent. (That's how we can know what the last digits of Graham's > Number are, despite having no way to even comprehend its scale.) Oh, after going through some of the discussions on Python-ideas, I'm pretty sure I comprehend its scale... > So > what's 6**0? Is that going to end with 6, too, to be consistent? No, > because we're not multiplying any sixes in, so the answer's simply 1. Why 1? Why not 3? Or 0? The answer is, it needs to be 1 to be consistent with the Index Laws such as a**(b-c) = a**b / a**c. That's a good answer, and it works great for a=6: 6**0 = 6**(2-2) = 6**2 / 6**2 = 36/36 = 1 (There's nothing special about 2, I could have used 0 = 97-97, or any other positive value.) But it doesn't work when the base is zero: 0**0 = 0**(2-2) = 0**2 / 0**2 = 0/0 = Oops. There's that pesky indeterminate result again. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Why do the URLs of posts here change?
Skip Montanaro wrote: >> Posts on this newsgroup/mailing list are archived on the web, but the >> URLs seem to change, which leaves dead links if you search for things. [...] > That all said, I don't know if Mailman 3 (or some other archiver than > pipermail) will improve on this problem. I suggest a post to > mailman-us...@python.org if you're curious about the Mailman > state-of-the-art in this area. Thanks for the explanation! -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Comparisons and sorting of a numeric class....
Chris Kaynor wrote: > Lately, I've been doing quite a bit of work in lua, and many times have > wished that empty strings, tables, and 0 acted "falsey", but at the same > time, previously working in Python, there were plenty of times I wished > they acted "truthy". It merely depends on what algorithm I am using at the > time... Please do elaborate. I've never found myself in a situation where I have wanted empty containers to be truthy, and I can't think of what such a situation would be like. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
ANN: eGenix pyOpenSSL Distribution 0.13.7
ANNOUNCING eGenix.com pyOpenSSL Distribution Version 0.13.7 An easy-to-install and easy-to-use distribution of the pyOpenSSL Python interface for OpenSSL - available for Windows, Mac OS X and Unix platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.13.7.html INTRODUCTION The eGenix.com pyOpenSSL Distribution includes everything you need to get started with SSL in Python. It comes with an easy-to-use installer that includes the most recent OpenSSL library versions in pre-compiled form, making your application independent of OS provided OpenSSL libraries: http://www.egenix.com/products/python/pyOpenSSL/ pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS- aware network applications as well as certificate management tools: https://launchpad.net/pyopenssl/ OpenSSL is an open-source implementation of the SSL/TLS protocol: http://www.openssl.org/ NEWS This new release of the eGenix.com pyOpenSSL Distribution updates the included OpenSSL version to the latest OpenSSL 1.0.1h version and adds a few more context options: New in OpenSSL -- * Updated included OpenSSL libraries from OpenSSL 1.0.1j to 1.0.1k. See https://www.openssl.org/news/secadv_20150108.txt for a complete list of changes. The following fixes are relevant for pyOpenSSL applications: - CVE-2014-8275: OpenSSL accepts several non-DER-variations of certificate signature algorithm and signature encodings. OpenSSL also does not enforce a match between the signature algorithm between the signed and unsigned portions of the certificate. By modifying the contents of the signature algorithm or the encoding of the signature, it is possible to change the certificate's fingerprint. - CVE-2014-3572: An OpenSSL client will accept a handshake using an ephemeral ECDH ciphersuite using an ECDSA certificate if the server key exchange message is omitted. This effectively removes forward secrecy from the ciphersuite. - CVE-2015-0204: An OpenSSL client will accept the use of an RSA temporary key in a non-export RSA key exchange ciphersuite. A server could present a weak temporary key and downgrade the security of the session. - CVE-2014-3570: Bignum squaring (BN_sqr) may produce incorrect results on some platforms, including x86_64. This bug occurs at random with a very low probability, and is not known to be exploitable in any way, though its exact impact is difficult to determine. - CVE-2015-0205: An OpenSSL server will accept a DH certificate for client authentication without the certificate verify message. This effectively allows a client to authenticate without the use of a private key. This only affects servers which trust a client certificate authority which issues certificates containing DH keys: these are extremely rare and hardly ever encountered. Please see the product changelog for the full set of changes: http://www.egenix.com/products/python/pyOpenSSL/changelog.html pyOpenSSL / OpenSSL Binaries Included - In addition to providing sources, we make binaries available that include both pyOpenSSL and the necessary OpenSSL libraries for all supported platforms: Windows x86 and x64, Linux x86 and x64, Mac OS X PPC, x86 and x64. We've also added egg-file distribution versions of our eGenix.com pyOpenSSL Distribution for Windows, Linux and Mac OS X to the available download options. These make setups using e.g. zc.buildout and other egg-file based installers a lot easier. DOWNLOADS The download archives and instructions for installing the package can be found at: http://www.egenix.com/products/python/pyOpenSSL/ UPGRADING Before installing this version of pyOpenSSL, please make sure that you uninstall any previously installed pyOpenSSL version. Otherwise, you could end up not using the included OpenSSL libs. ___ SUPPORT Commercial support for these packages is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. MORE INFORMATION For more information about the eGenix pyOpenSSL Distribution, licensing and download instructions, please visit our web-site or write to sa...@egen
Re: Decimals and other numbers
On Fri, Jan 9, 2015 at 11:24 PM, Steven D'Aprano wrote: >> 5 * 0 * 0 * 0 * 0 = 0 > > Where did the 5 come from? > > You're effectively saying that 0**0 becomes 5*0**0, then cancelling the 0**0 > because they're all zeroes and so don't matter, leaving 5. And that simply > doesn't work. If it did work, there's nothing special about 5, we could use > 18 instead: > > 0**0 = 5*0**0 => 5 > > but 0**0 = 18*0**0 => 18 > therefore 5 = 18. > > Yay maths! :-) To clarify, I'm following this sequence: 5 * 0**4 = 5 * 0 * 0 * 0 * 0 = 0 5 * 0**3 = 5 * 0 * 0 * 0 = 0 5 * 0**2 = 5 * 0 * 0 = 0 5 * 0**1 = 5 * 0 = 0 5 * 0**0 = 5 = ? Multiplication by zero is idempotent; any number of multiplications beyond the first won't change the result. But that doesn't mean that never multiplying by zero will have the same result. I think it's fairly obvious in this example that the pattern does NOT continue to the case where you're multiplying in no zeroes. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Comparisons and sorting of a numeric class....
On Fri, Jan 9, 2015 at 11:27 PM, Steven D'Aprano wrote: > Chris Kaynor wrote: > >> Lately, I've been doing quite a bit of work in lua, and many times have >> wished that empty strings, tables, and 0 acted "falsey", but at the same >> time, previously working in Python, there were plenty of times I wished >> they acted "truthy". It merely depends on what algorithm I am using at the >> time... > > > Please do elaborate. I've never found myself in a situation where I have > wanted empty containers to be truthy, and I can't think of what such a > situation would be like. It's a matter of what you're comparing against. If you might have a thing and might not, the obvious way to arrange things is to have the thing be true and the non-thing be false. That works nicely if that "thing" is an object that's always True, and the "non-thing" is None; for instance, I might have a socket object, and I might not, so I can use "if not self.socket: self.connect()" to ensure that I have one (assuming that self.connect() will throw an error if it fails to establish, blah blah, handwave away the details). This does NOT work if a socket object might be false, so I'd have to explicitly check "if self.socket is None:". Similarly, there are times when the user might have entered a string or might not - say you have an optional parameter "--name" which, if omitted, defaults to some sort of arbitrarily-assigned name; to distinguish between "--name=" and not providing that parameter at all, the logical way is to have name be either a string or None. Again, "if name" would make good sense as meaning "if the --name parameter was provided", rather than "if the --name parameter was provided and not the empty string". If it helps, think of a "nullable field" in databasing. Python's truthiness model is pretty consistent (apart from a few oddities like midnight being false), so I'm not advocating making this change. I'm just explaining the case where the opposite choice does make sense. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Non-unique dirs in sys.path
I'm having some trouble understanding why my Python 2.7.9 has the '%PYTHONHOME%\lib\site-packages' listed multiple times. I cooked up this .bat file to demonstrate the issue: @echo off setlocal set PYTHONPATH= python -c "import sys; [sys.stdout.write('%%s\n' %% p) for (i,p) in enumerate(sys.path)]" | sort --ignore-case which produces: f:\Documents and Settings\Gisle Vanem\Programdata\Python\Python27\site-packages f:\windows\system32\python27.zip<< !! doesn't exist, but okay. G:\Programfiler\Python27 g:\Programfiler\Python27\DLLs g:\Programfiler\Python27\lib g:\Programfiler\Python27\lib\lib-tk g:\Programfiler\Python27\lib\plat-win g:\Programfiler\Python27\lib\site-packages << !! g:\programfiler\python27\lib\site-packages << !! ... Why are these listed twice with different casing? One would assume that Python on Win32 would be case-insensitive. Some .pth-file to blame here? I've checked that PYTHONPATH is not defined elsewhere. Like in: HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment or HKCU\Environment -- --gv -- https://mail.python.org/mailman/listinfo/python-list
Begginer Question , what i need for web app and site
Hello all coming from java and c++ now going with python what setup do i need to run full python stack for web application . what i need is web framework and back-end . what usually be in the java world tomcat and servlets or jsp and pure java backend for processing data . what will be the Equivalent in python world ? Thanks! -- https://mail.python.org/mailman/listinfo/python-list
Re: Why do the URLs of posts here change?
On Friday, January 9, 2015 at 4:26:58 PM UTC+5:30, Steven D'Aprano wrote: > I have come across this in the past, but today it annoyed me enough that I'm > asking for an explanation. > > Posts on this newsgroup/mailing list are archived on the web, but the URLs > seem to change, which leaves dead links if you search for things. > > For example, today I searched for a quote about floating point equality by > William Kahan, and I came across this post by me: > > https://mail.python.org/pipermail/python-list/2008-February/468598.html > > But that's a dead link! Here's Google's cache of it: > > http://webcache.googleusercontent.com/search?client=opera&rls=en&q=cache:i0cWb0Tjxe0J:https://mail.python.org/pipermail/python-list/2008-February/468598.html%2Bfloating+point+superstition+equality&oe=utf-8&channel=suggest&gws_rd=ssl&hl=en&&ct=clnk > > And here is the actual URL, as it appears today: > > https://mail.python.org/pipermail/python-list/2008-February/481374.html > > > Why has the URL changed? Surely this is a bug? Where can I report it? Theres a new app/service that should solve your problem: Its from google... and called groups -- https://mail.python.org/mailman/listinfo/python-list
Re: Why do the URLs of posts here change?
On Fri, Jan 9, 2015 at 8:09 AM, Rustom Mody wrote: > Theres a new app/service that should solve your problem: > Its from google... and called groups > It solves one problem (moving archive URLs) by, I think, ignoring the other (archive posts which should really be removed). Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Comparisons and sorting of a numeric class....
Chris Angelico : > I'd have to explicitly check "if self.socket is None:". That is the only way in Python. Wrong: return f() or g() or h() Right: rv = f() if rv is not None: return rv rv = g() if rv is not None: return rv return h() > I'm not advocating making this change. Has someone proposed a change? Marko -- https://mail.python.org/mailman/listinfo/python-list
Why does argparse return None instead of [] if an append action isn't used?
I noticed in use that if an option with the 'append' action isn't used, argparse assigns None to it rather than an empty list, & confirmed this interactively: #v+ >>> import argparse >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', action='append') _AppendAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, default=None, type=None, choices=None, help=None, metavar=None) >>> parser.add_argument('--bar', action='append') _AppendAction(option_strings=['--bar'], dest='bar', nargs=None, const=None, default=None, type=None, choices=None, help=None, metavar=None) >>> parser.parse_args('--foo 1 --foo 2'.split()) Namespace(bar=None, foo=['1', '2']) #v- This makes it a bit more trouble to use: if options.bar: for b in options:bar do_stuff(b) instead of for b in options.bar do_stuff(b) which is (of course) what I was doing when I discovered the None. Is there any benefit to the user from this, or is it just an "accident" of the way argparse is written? -- The history of the world is the history of a privileged few. --- Henry Miller -- https://mail.python.org/mailman/listinfo/python-list
Re: Why does argparse return None instead of [] if an append action isn't used?
> I noticed in use that if an option with the 'append' action isn't > used, argparse assigns None to it rather than an empty list, & > confirmed this interactively: I don't use argparse (or optparse), being a getopt Luddite myself, but can you set the default for an action in the add_argument call? Skip -- https://mail.python.org/mailman/listinfo/python-list
Help configuring visual studio to compile python extensions
I've installed Microsoft Visual Studio 10.0. Here are the steps I've been taking. My python version is Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32. (Sorry for the long output.) >cd "c:\Program Files (x86)\Microsoft Visual Studio 10.0"\vc >vcvarsall.bat > >SET VS90COMNTOOLS=%VS100COMNTOOLS% c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>pip install scandir Collecting scandir Using cached scandir-0.9.tar.gz Installing collected packages: scandir Running setup.py install for scandir building '_scandir' extension C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\Python34\include -Ic:\Python34\include /Tc_scandir.c /Fobuild\temp.win-amd64-3.4\Release \_scandir.obj _scandir.c C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:c:\Python34\libs /LIBPATH:c:\Python34\PCbuild\amd64 /EXPORT:PyInit__scandir build\temp.win -amd64-3.4\Release\_scandir.obj /OUT:build\lib.win-amd64-3.4\_scandir.pyd /IMPLIB:build\temp.win-amd64-3.4\Release\_scandir.lib /MANIFESTFILE:build\temp.win-amd64-3.4\Release\_scandir.pyd.manifest Creating library build\temp.win-amd64-3.4\Release\_scandir.lib and object build\temp.win-amd64-3.4\Release\_scandir.exp _scandir.obj : error LNK2001: unresolved external symbol _PyObject_SelfIter _scandir.obj : error LNK2001: unresolved external symbol _PyObject_GenericGetAttr _scandir.obj : error LNK2019: unresolved external symbol __imp__PyErr_WarnEx referenced in function _win32_warn_bytes_api _scandir.obj : error LNK2019: unresolved external symbol __imp__PyExc_DeprecationWarning referenced in function _win32_warn_bytes_api _scandir.obj : error LNK2019: unresolved external symbol __imp__PyErr_Occurred referenced in function _path_converter _scandir.obj : error LNK2019: unresolved external symbol __imp__PyBytes_FromObject referenced in function _path_converter _scandir.obj : error LNK2019: unresolved external symbol __imp__PyErr_Clear referenced in function _path_converter _scandir.obj : error LNK2019: unresolved external symbol __imp__PyExc_ValueError referenced in function _path_converter _scandir.obj : error LNK2019: unresolved external symbol __imp__PyUnicode_AsUnicodeAndSize referenced in function _path_converter _scandir.obj : error LNK2019: unresolved external symbol __imp__PyUnicode_FromObject referenced in function _path_converter _scandir.obj : error LNK2019: unresolved external symbol __imp__PyErr_Format referenced in function _path_converter _scandir.obj : error LNK2019: unresolved external symbol __imp__PyExc_TypeError referenced in function _path_converter _scandir.obj : error LNK2019: unresolved external symbol __imp___Py_NoneStruct referenced in function _path_converter _scandir.obj : error LNK2019: unresolved external symbol __imp__PyLong_FromUnsignedLong referenced in function _find_data_to_statresult _scandir.obj : error LNK2019: unresolved external symbol __imp__PyFloat_FromDouble referenced in function _find_data_to_statresult _scandir.obj : error LNK2019: unresolved external symbol __imp__PyLong_FromUnsignedLongLong referenced in function _find_data_to_statresult _scandir.obj : error LNK2019: unresolved external symbol __imp__PyLong_FromLong referenced in function _find_data_to_statresult _scandir.obj : error LNK2019: unresolved external symbol __imp__PyStructSequence_New referenced in function _find_data_to_statresult _scandir.obj : error LNK2019: unresolved external symbol __imp__PyEval_RestoreThread referenced in function __fi_close _scandir.obj : error LNK2019: unresolved external symbol __imp__PyEval_SaveThread referenced in function __fi_close _scandir.obj : error LNK2019: unresolved external symbol __imp__Py_BuildValue referenced in function __fi_next _scandir.obj : error LNK2019: unresolved external symbol __imp__PyErr_SetFromWindowsErr referenced in function __fi_next _scandir.obj : error LNK2019: unresolved external symbol __imp__PyErr_NoMemory referenced in function __fi_next _scandir.obj : error LNK2019: unresolved external symbol __imp__PyErr_SetNone referenced in function __fi_next _scandir.obj : error LNK2019: unresolved external symbol __imp__PyExc_StopIteration referenced in function __fi_next _scandir.obj : error LNK2019: unresolved external symbol __imp__PyObject_Free referenced in function _fi_dealloc _scandir.obj : error LNK2019: unresolved external symbol __imp___PyObject_New referenced in function __iterfile _scandir.obj : error LNK2019: unresolved external symbol __imp__PyArg_ParseTupleAndKeywords referenced in function _scandir_helper _scandir.obj : error LNK2019: unresolved external symbol __imp__PyStructSequence_InitType referenced in function _PyInit__scandir _scandir.obj : error LNK2019: unresolved ext
Re: Comparisons and sorting of a numeric class....
Chris Angelico writes: > for instance, I might have a socket object, and I might not, so I can > use "if not self.socket: self.connect()" ... This sounds like you want a Maybe or Option object. Marko's suggestion rv = f() if rv is not None: return rv rv = g() if rv is not None: return rv return h() seems unspeakably ugly. Rather than None on failure maybe f() and g() could return an empty list on failure, or a one-element list containing the item on success. That uses lists to simulate a Maybe type. Then the above could go (Python 3, untested): def tries(): yield from f() yield from g() yield [h()] return tries().next() -- https://mail.python.org/mailman/listinfo/python-list
Re: Comparisons and sorting of a numeric class....
On Sat, Jan 10, 2015 at 2:06 AM, Paul Rubin wrote: > Chris Angelico writes: >> for instance, I might have a socket object, and I might not, so I can >> use "if not self.socket: self.connect()" ... > > This sounds like you want a Maybe or Option object. That's exactly what it is - a name that's always bound to either None or a socket object. Since a socket object is always true, I can safely use the above code. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Why does argparse return None instead of [] if an append action isn't used?
On 1/9/15 9:44 AM, Adam Funk wrote: This makes it a bit more trouble to use: if options.bar: for b in options:bar do_stuff(b) instead of for b in options.bar do_stuff(b) This doesn't answer why the value defaults to None, and some people may recoil at it, but I've used: for b in options.bar or (): do_stuff(b) -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Comparisons and sorting of a numeric class....
Paul Rubin : > Marko's suggestion > > rv = f() > if rv is not None: > return rv > rv = g() > if rv is not None: > return rv > return h() > > seems unspeakably ugly. Well, "unspeakably" is exaggeration IMO. It is a bit lengthy but it is crystal clear. While the "or" pattern is neat, I wouldn't make too much of it. > Rather than None on failure maybe f() and g() could return an empty > list on failure, or a one-element list containing the item on success. > That uses lists to simulate a Maybe type. > > Then the above could go (Python 3, untested): > > def tries(): > yield from f() > yield from g() > yield [h()] > return tries().next() I think the medicine in this case is worse than the disease. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Help configuring visual studio to compile python extensions
On 09/01/2015 14:58, stephen.bou...@gmail.com wrote: I've installed Microsoft Visual Studio 10.0. Here are the steps I've been taking. My python version is Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32. (Sorry for the long output.) cd "c:\Program Files (x86)\Microsoft Visual Studio 10.0"\vc vcvarsall.bat SET VS90COMNTOOLS=%VS100COMNTOOLS% c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>pip install scandir Collecting scandir Using cached scandir-0.9.tar.gz See https://docs.python.org/3/extending/windows.html I'll admit to being a little annoyed that scandir says it supports Python 3 but only provides a 2.7 exe on pypi. Worse even my normal backup failed me http://www.lfd.uci.edu/~gohlke/pythonlibs/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Why does argparse return None instead of [] if an append action isn't used?
On 2015-01-09, Skip Montanaro wrote: >> I noticed in use that if an option with the 'append' action isn't >> used, argparse assigns None to it rather than an empty list, & >> confirmed this interactively: > > I don't use argparse (or optparse), being a getopt Luddite myself, but > can you set the default for an action in the add_argument call? Well, duh! That works, thanks. (I can't explain why I didn't think of that.) >>> import argparse >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', action='append',default=[]) _AppendAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, default=[], type=None, choices=None, help=None, metavar=None) >>> parser.add_argument('--bar', action='append',default=[]) _AppendAction(option_strings=['--bar'], dest='bar', nargs=None, const=None, default=[], type=None, choices=None, help=None, metavar=None) >>> parser.parse_args('--foo 1 --foo 2'.split()) Namespace(bar=[], foo=['1', '2']) >>> parser.parse_args('--foo 1 --bar 2'.split()) Namespace(bar=['2'], foo=['1']) >>> parser.parse_args([]) Namespace(bar=[], foo=[]) -- Slade was the coolest band in England. They were the kind of guys that would push your car out of a ditch. --- Alice Cooper -- https://mail.python.org/mailman/listinfo/python-list
Re: Help configuring visual studio to compile python extensions
On Sat, Jan 10, 2015 at 2:23 AM, Mark Lawrence wrote: > I'll admit to being a little annoyed that scandir says it supports Python 3 > but only provides a 2.7 exe on pypi. If you can wait for 3.5, you might find it in the standard library. PEP 471 was accepted, and I believe that means scandir will be arriving at some point. (Not sure when, though.) At that point, 2.7 will be the primary target for the PyPI distribution. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Why does argparse return None instead of [] if an append action isn't used?
On 01/09/2015 03:44 PM, Adam Funk wrote: I noticed in use that if an option with the 'append' action isn't used, argparse assigns None to it rather than an empty list, & confirmed this interactively: #v+ import argparse parser = argparse.ArgumentParser() parser.add_argument('--foo', action='append') _AppendAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, default=None, type=None, choices=None, help=None, metavar=None) parser.add_argument('--bar', action='append') _AppendAction(option_strings=['--bar'], dest='bar', nargs=None, const=None, default=None, type=None, choices=None, help=None, metavar=None) parser.parse_args('--foo 1 --foo 2'.split()) Namespace(bar=None, foo=['1', '2']) #v- Isn't that the exact behaviour documented here: https://docs.python.org/3/library/argparse.html#default where it says that the default for the default argument is None ? I think Skip is right: you should be able to just add default = [] to your arguments in the add_argument call. Wolfgang -- https://mail.python.org/mailman/listinfo/python-list
Re: what is Jython?
On 2015-01-09, Chris Angelico wrote: > Jython isn't a combination of Python and Java; it's Python, > implemented in Java. Does that answer your question? Just to clarify, Jython 1) is a Python compiler that compiles Python source code into JVM bytecode (class, jar, whatever) that runs on a standard Java runtime. Python programs compiled with Jython can call standard Java libraries and and can call or be called by code written in Java. 2) is a Python compiler that is written in Java. AFAK, these are in principal orthogonal. Number 1) is the important part and does not require that 2) be true. The Jython compiler could (in theory) be implemented in C, Fortran, or BASH, but there are some practical advantages to using Java to write a compiler that generates JVM bytecode. -- Grant Edwards grant.b.edwardsYow! RELATIVES!! at gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: what is Jython?
On Sat, Jan 10, 2015 at 3:06 AM, Grant Edwards wrote: > Just to clarify, Jython > > 1) is a Python compiler that compiles Python source code into JVM > bytecode (class, jar, whatever) that runs on a standard Java > runtime. Python programs compiled with Jython can call standard > Java libraries and and can call or be called by code written in > Java. > > 2) is a Python compiler that is written in Java. > > AFAK, these are in principal orthogonal. Number 1) is the important > part and does not require that 2) be true. The Jython compiler could > (in theory) be implemented in C, Fortran, or BASH, but there are some > practical advantages to using Java to write a compiler that generates > JVM bytecode. Indeed. The point of Jython is that it compiles to Java byte-code, putting it on par with languages like NetRexx as alternative ways to create .class files. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Non-unique dirs in sys.path
On Fri, Jan 9, 2015 at 6:14 AM, Gisle Vanem wrote: > Why are these listed twice with different casing? One > would assume that Python on Win32 would be case-insensitive. > Some .pth-file to blame here? I checked my own Python 2.7 installation and discovered that I have the same problem, although without the different casing. Perusing the .pth files in site-packages turns up setuptools.pth, which just contains the site-packages path. Removing that file solves the issue for me. -- https://mail.python.org/mailman/listinfo/python-list
Re: Why do the URLs of posts here change?
On Friday, January 9, 2015 at 7:46:42 PM UTC+5:30, Skip Montanaro wrote: > On Fri, Jan 9, 2015 at 8:09 AM, Rustom Mody wrote: > > Theres a new app/service that should solve your problem: > > Its from google... and called groups > It solves one problem (moving archive URLs) by, I think, ignoring the other > (archive posts which should really be removed). > > > Skip Is it? Ok lets test that. This is posted from google-groups. After posting I shall remove it -- https://mail.python.org/mailman/listinfo/python-list
Re: Why do the URLs of posts here change?
On Sat, Jan 10, 2015 at 3:52 AM, Rustom Mody wrote: > Is it? > Ok lets test that. > This is posted from google-groups. > After posting I shall remove it Remove it from GG, maybe, but I doubt very much it'll be removed from the python.org archive. It's virtually impossible to remove something from everywhere... you have to find every copy and hope none have been web-archived yet. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Why do the URLs of posts here change?
On Friday, January 9, 2015 at 10:27:53 PM UTC+5:30, Chris Angelico wrote: > On Sat, Jan 10, 2015 at 3:52 AM, Rustom Mody wrote: > > Is it? > > Ok lets test that. > > This is posted from google-groups. > > After posting I shall remove it > > Remove it from GG, maybe, but I doubt very much it'll be removed from > the python.org archive. It's virtually impossible to remove something > from everywhere... you have to find every copy and hope none have been > web-archived yet. > > ChrisA Precisely my point. Removing something from the web is really a meaningless activity [apart from some moral feel-good factor] If that gesture means something to you, GG provides it And to the best of my knowledge it does not screw up links like mailman. We can test in some limited way that but I dont know how to do any test which will be reasonably exhaustive -- https://mail.python.org/mailman/listinfo/python-list
[OT] x**y == y**x
On 09 Jan 2015 11:07:51 +0200, Jussi Piitulainen wrote: [snip] > Which reminds me of a question that once made me smile, even laugh, > and still does: 2**3 is almost 3**2 but not quite - what gives? If you've never looked at the set of reals (x,y) satisfying x**y == y**x, it's worth a visit. -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list
Re: Generate jpg files using line length (pixels) and orientation (degrees)
On Thursday, 8 January 2015 20:54:38 UTC-6, Denis McMahon wrote: > On Thu, 08 Jan 2015 22:07:03 +, Denis McMahon wrote: > > > On Thu, 08 Jan 2015 09:09:18 -0800, semeon.risom wrote: > > > >> Simple question. I hope. . > > To follow up, below is a solution to the problem you stated. > > #!/usr/bin/python > > import Image, ImageDraw, math > > def makeimg(length, orientation): > """ > Make an image file of a black 4 pixel wide line of defined length > crossing and centered on a white background of 800 px square, save > as a png file identifying line length and orientation in the file > name. > param length - pixels, length of the line > param orientation - degrees, orientation ccw of the line from +ve x > axis > Files are saved in imgs subdir, this must already exist. > File name is image_lll_ooo.jpg > lll = length, ooo = orientation, both 0 padded to 3 digits > """ > > # check length is +ve and not greater than 800 > if length < 0: > length = length * -1 > if length > 800: > length = 800 > > # check orientation is positive in range 0 .. 179 > while orientation < 0: > orientation = orientation + 360 > if orientation > 179: > orientation = orientation % 180 > > # calculate radius in pixels and orientation in radians > radius = length / 2 > orient = math.radians(orientation) > > # calculate xy coords in image space of line end points > x1 = int(400 + (radius * math.cos(orient))) > y1 = int(400 - (radius * math.sin(orient))) > x2 = int(400 + (-radius * math.cos(orient))) > y2 = int(400 - (-radius * math.sin(orient))) > > # create an image > img = Image.new('RGB', (800,800), 'rgb(255, 255, 255)') > # create a draw interface > draw = ImageDraw.Draw(img) > > # draw the line on the image > draw.line([(x1, y1), (x2, y2)], fill='rgb(0, 0, 0)', width=4) > > # determine file name, save image file > fn = 'imgs/image_{:03d}_{:03d}.jpg'.format(length,orientation) > img.save(fn) > > # stepping through ranges of values > for length in range(100, 601, 100): > for orientation in range(0, 171, 10): > makeimg(length, orientation) > > # using lists of values > for length in [50, 150, 250, 350, 450, 550, 650]: > for orientation in [0, 15, 40, 45, 60, 75, 90, 105, 120, 135, 150, > 165]: > makeimg(length, orientation) > > > > > -- > Denis McMahon, denismfmcma...@gmail.com Thank you for the help btw. I think I'm close to a solution, but I'm having issue feeding the coordinates from my csv file into the formula. This is the error I get: Traceback (most recent call last): File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w corr.py", line 68, in makeimg(length, orientation) File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w corr.py", line 40, in makeimg orientation = orientation % 180 TypeError: unsupported operand type(s) for %: 'list' and 'int' >>> and here's the code: from PIL import Image, ImageDraw from numpy import math # import csv import csv f = open('C:\Users\Owner\DesktopStimuli Generation\Coordinates\file.csv', 'rb') rdr = csv.reader(f) f.seek(0) i = 0 a = [] b = [] for row in rdr: a.append(row[0]) b.append(row[1]) def makeimg(length, orientation): """ Make an image file of a black 4 pixel wide line of defined length crossing and centered on a white background of 800 px square, save as a png file identifying line length and orientation in the file name. param length - pixels, length of the line param orientation - degrees, orientation ccw of the line from +ve x axis Files are saved in imgs subdir, this must already exist. File name is image_lll_ooo.jpg lll = length, ooo = orientation, both 0 padded to 3 digits """ # check length is +ve and not greater than 800 if length < 0: length = length * -1 if length > 800: length = 800 # check orientation is positive in range 0 .. 179 while orientation < 0: orientation = orientation + 360 if orientation > 179: orientation = orientation % 180 # calculate radius in pixels and orientation in radians radius = length / 2 orient = math.radians(orientation) # calculate xy coords in image space of line end points x1 = int(400 + (radius * math.cos(orient))) y1 = int(400 - (radius * math.sin(orient))) x2 = int(400 + (-radius * math.cos(orient))) y2 = int(400 - (-radius * math.sin(orient))) # create an image img = Image.new('RGB', (800,800), 'rgb(255, 255, 255)') # create a draw interface draw = ImageDraw.Draw(img) # draw the line on the image draw.line([(x1, y1), (x2, y2)], fill='rgb(0, 0, 0)', width=4) # determine file name, save image file fn = 'imgs/image_{:03d}_{:03d}.jpg'.format(length,orientation) img.save(fn)
Re: Generate jpg files using line length (pixels) and orientation (degrees)
On Fri, Jan 9, 2015 at 12:49 PM, wrote: > On Thursday, 8 January 2015 20:54:38 UTC-6, Denis McMahon wrote: > > On Thu, 08 Jan 2015 22:07:03 +, Denis McMahon wrote: > > > > > On Thu, 08 Jan 2015 09:09:18 -0800, semeon.risom wrote: > > > > > >> Simple question. I hope. . > > > > To follow up, below is a solution to the problem you stated. > > > > #!/usr/bin/python > > > > import Image, ImageDraw, math > > > > def makeimg(length, orientation): > > """ > > Make an image file of a black 4 pixel wide line of defined length > > crossing and centered on a white background of 800 px square, save > > as a png file identifying line length and orientation in the file > > name. > > param length - pixels, length of the line > > param orientation - degrees, orientation ccw of the line from +ve x > > axis > > Files are saved in imgs subdir, this must already exist. > > File name is image_lll_ooo.jpg > > lll = length, ooo = orientation, both 0 padded to 3 digits > > """ > > > > # check length is +ve and not greater than 800 > > if length < 0: > > length = length * -1 > > if length > 800: > > length = 800 > > > > # check orientation is positive in range 0 .. 179 > > while orientation < 0: > > orientation = orientation + 360 > > if orientation > 179: > > orientation = orientation % 180 > > > > # calculate radius in pixels and orientation in radians > > radius = length / 2 > > orient = math.radians(orientation) > > > > # calculate xy coords in image space of line end points > > x1 = int(400 + (radius * math.cos(orient))) > > y1 = int(400 - (radius * math.sin(orient))) > > x2 = int(400 + (-radius * math.cos(orient))) > > y2 = int(400 - (-radius * math.sin(orient))) > > > > # create an image > > img = Image.new('RGB', (800,800), 'rgb(255, 255, 255)') > > # create a draw interface > > draw = ImageDraw.Draw(img) > > > > # draw the line on the image > > draw.line([(x1, y1), (x2, y2)], fill='rgb(0, 0, 0)', width=4) > > > > # determine file name, save image file > > fn = 'imgs/image_{:03d}_{:03d}.jpg'.format(length,orientation) > > img.save(fn) > > > > # stepping through ranges of values > > for length in range(100, 601, 100): > > for orientation in range(0, 171, 10): > > makeimg(length, orientation) > > > > # using lists of values > > for length in [50, 150, 250, 350, 450, 550, 650]: > > for orientation in [0, 15, 40, 45, 60, 75, 90, 105, 120, 135, 150, > > 165]: > > makeimg(length, orientation) > > > > > > > > > > -- > > Denis McMahon, denismfmcma...@gmail.com > > Thank you for the help btw. I think I'm close to a solution, but I'm > having issue feeding the coordinates from my csv file into the formula. > > This is the error I get: > Traceback (most recent call last): > File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w > corr.py", line 68, in > makeimg(length, orientation) > File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w > corr.py", line 40, in makeimg > orientation = orientation % 180 > TypeError: unsupported operand type(s) for %: 'list' and 'int' > >>> > > and here's the code: > > from PIL import Image, ImageDraw > from numpy import math > > # import csv > import csv > f = open('C:\Users\Owner\DesktopStimuli Generation\Coordinates\file.csv', > 'rb') > rdr = csv.reader(f) > f.seek(0) > i = 0 > a = [] > b = [] > for row in rdr: > a.append(row[0]) > b.append(row[1]) > > def makeimg(length, orientation): > """ > Make an image file of a black 4 pixel wide line of defined length > crossing and centered on a white background of 800 px square, save > as a png file identifying line length and orientation in the file > name. > param length - pixels, length of the line > param orientation - degrees, orientation ccw of the line from +ve x > axis > Files are saved in imgs subdir, this must already exist. > File name is image_lll_ooo.jpg > lll = length, ooo = orientation, both 0 padded to 3 digits > """ > > # check length is +ve and not greater than 800 > if length < 0: > length = length * -1 > if length > 800: > length = 800 > > # check orientation is positive in range 0 .. 179 > while orientation < 0: > orientation = orientation + 360 > if orientation > 179: > orientation = orientation % 180 > > # calculate radius in pixels and orientation in radians > radius = length / 2 > orient = math.radians(orientation) > > # calculate xy coords in image space of line end points > x1 = int(400 + (radius * math.cos(orient))) > y1 = int(400 - (radius * math.sin(orient))) > x2 = int(400 + (-radius * math.cos(orient))) > y2 = int(400 - (-radius * math.sin(orient))) > > # create an image > img = Image.new('RGB', (800,800), 'rgb(255, 255,
Re: hello please can you help me with the below problem am facing
On Friday, January 9, 2015 at 3:47:27 AM UTC-8, mubarak idris wrote: > Please how can I make an .exe executable app out of my python script easily http://www.py2exe.org/ -- https://mail.python.org/mailman/listinfo/python-list
cx_Oracle, callfunc and varray
Hi I'm trying to return a simple array of numbers from a package using cx_oracle (5.1.2). I believe this is possible. I've not been able to find anything that suggest it isn't create or replace TYPE NUMARRAY -- Simple VArray of numbers is VARRAY(3) OF NUMBER; / create or replace PACKAGE SIMPLEPACKAGE AS FUNCTION DoSomethingSimple( cust_id INTEGER) RETURN numarray; FUNCTION DoSomethingSimpler( cust_id INTEGER) RETURN INTEGER; END SIMPLEPACKAGE; / create or replace PACKAGE BODY SIMPLEPACKAGE AS FUNCTION DOSOMETHINGSIMPLE( cust_id INTEGER) RETURN numarray AS simple_array numarray := numarray(); BEGIN simple_array.extend; simple_array(1) := cust_id; simple_array.extend; simple_array(2) := cust_id; simple_array.extend; simple_array(3) := cust_id; RETURN SIMPLE_ARRAY; END DOSOMETHINGSIMPLE; FUNCTION DOSOMETHINGSIMPLER( cust_id INTEGER) RETURN INTEGER AS BEGIN RETURN cust_id; END DOSOMETHINGSIMPLER; END SIMPLEPACKAGE; / The python (2.7) is very simple import cx_Oracle if __name__ == '__main__': with cx_Oracle.connect('soe', 'soe', 'oracle12c2/soe') as connection: try: cursor = connection.cursor(); ArrayType = cursor.arrayvar(cx_Oracle.NUMBER,3) NumberType = cursor.var(cx_Oracle.NUMBER) cursor.callfunc("SIMPLEPACKAGE.DOSOMETHINGSIMPLER", NumberType, [99]) cursor.callfunc("SIMPLEPACKAGE.DOSOMETHINGSIMPLE", ArrayType, [99]) except cx_Oracle.DatabaseError as dberror: print dberror finally: cursor.close() The call to return works just fine. The call to return the function gives the error ORA-06550: line 1, column 13: PLS-00382: expression is of wrong type ORA-06550: line 1, column 7: PL/SQL: Statement ignored Any ideas what I'm doing wrong? Dom -- https://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle, callfunc and varray
In Dom writes: > create or replace PACKAGE SIMPLEPACKAGE > AS > FUNCTION DoSomethingSimple( > cust_id INTEGER) > RETURN numarray; > FUNCTION DoSomethingSimpler( > cust_id INTEGER) > RETURN INTEGER; > END SIMPLEPACKAGE; > / > Any ideas what I'm doing wrong? Is RETURN INTEGER; allowed? -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list
Re: Non-unique dirs in sys.path
Ian Kelly wrote: I checked my own Python 2.7 installation and discovered that I have the same problem, although without the different casing. Perusing the .pth files in site-packages turns up setuptools.pth, which just contains the site-packages path. Removing that file solves the issue for me. That was the case here too! Deleted my setuptools.pth and the "problem" was gone. It would be nice to know how these .pth files are involved in extending the 'sys.path[]'. Who does that and how? Any good reference on that? -- --gv -- https://mail.python.org/mailman/listinfo/python-list
class-based class decorator
Hi, I am trying to write a class decorator that checks whether deprecated parameters with non-default arguments are used. More complete code is here: http://pastebin.com/ZqnMis6M. In the code below, how should I modify __call__ such that f.bar(old="oh no") prints "hello world"? I thought it would be a fun way to play with the inspect module, but my head is numb now and I am thirsty for a beer! import inspectimport functools import warnings class check_deprecated_args(object): """ Class decorator that checks whether deprecated parameters with non-default arguments are used Parameters -- deprecated_params : tuple tuple of strings of parameters that should raise a DeprecationWarning, if they are used with non-default arguments Raises -- DeprecationWarning : if deprecated parameters are used with non-default arguments in the class's constructor. """ def __init__(self, deprecated_params): self.deprecated_params = deprecated_params def __call__(self, cls): @functools.wraps(cls) def inner(*used_args, **used_kwargs): print "called" # insert sneaky 'inspect' code here #pprint( dict(inspect.getmembers(cls)) ) return cls # --- this is wrong, it should return the Foo instance object! return inner if __name__ == "__main__": @check_deprecated_args(deprecated_params=("old", "older")) class Foo(object): def __init__(self, old=True, older=None, new="yaay"): pass def bar(self, old=True, new=True): print "hello world" f = Foo(new="great", old="obsolete", older="stop using it") print repr(f) print f.bar(old="oh no") Regards, Albert-Jan ~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~ -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] x**y == y**x
Peter Pearson : > If you've never looked at the set of reals (x,y) satisfying x**y == > y**x, it's worth a visit. Thanks, it was. The graph's something like this: | : * | : * | : * | : * 6 + : * * | : *** | : * ** | : * ** | :*** 5 + :* ** | : * ** | : *** | : * ** | :* ** 4 + : * ** | : *** | : * ** | :* ** | : * ** 3 + : *** | : * ** | : *** | : ** * | : ** *** 2 + : ** * | : ** ** | : ** *** | : ** ** | : ** 1 +.**. | **: | ** : | **: | ** : +*+-+-+-+-+-+ 1 2 3 4 5 6 where the line and the arc intersect at (e, e). Where can I read more on the topic? Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Generate jpg files using line length (pixels) and orientation (degrees)
On Friday, 9 January 2015 12:18:46 UTC-6, Joel Goldstick wrote: > On Fri, Jan 9, 2015 at 12:49 PM, wrote: > > > On Thursday, 8 January 2015 20:54:38 UTC-6, Denis McMahon wrote: > > > On Thu, 08 Jan 2015 22:07:03 +, Denis McMahon wrote: > > > > > > > On Thu, 08 Jan 2015 09:09:18 -0800, semeon.risom wrote: > > > > > > > >> Simple question. I hope. . > > > > > > To follow up, below is a solution to the problem you stated. > > > > > > #!/usr/bin/python > > > > > > import Image, ImageDraw, math > > > > > > def makeimg(length, orientation): > > > """ > > > Make an image file of a black 4 pixel wide line of defined length > > > crossing and centered on a white background of 800 px square, save > > > as a png file identifying line length and orientation in the file > > > name. > > > param length - pixels, length of the line > > > param orientation - degrees, orientation ccw of the line from +ve x > > > axis > > > Files are saved in imgs subdir, this must already exist. > > > File name is image_lll_ooo.jpg > > > lll = length, ooo = orientation, both 0 padded to 3 digits > > > """ > > > > > > # check length is +ve and not greater than 800 > > > if length < 0: > > > length = length * -1 > > > if length > 800: > > > length = 800 > > > > > > # check orientation is positive in range 0 .. 179 > > > while orientation < 0: > > > orientation = orientation + 360 > > > if orientation > 179: > > > orientation = orientation % 180 > > > > > > # calculate radius in pixels and orientation in radians > > > radius = length / 2 > > > orient = math.radians(orientation) > > > > > > # calculate xy coords in image space of line end points > > > x1 = int(400 + (radius * math.cos(orient))) > > > y1 = int(400 - (radius * math.sin(orient))) > > > x2 = int(400 + (-radius * math.cos(orient))) > > > y2 = int(400 - (-radius * math.sin(orient))) > > > > > > # create an image > > > img = Image.new('RGB', (800,800), 'rgb(255, 255, 255)') > > > # create a draw interface > > > draw = ImageDraw.Draw(img) > > > > > > # draw the line on the image > > > draw.line([(x1, y1), (x2, y2)], fill='rgb(0, 0, 0)', width=4) > > > > > > # determine file name, save image file > > > fn = 'imgs/image_{:03d}_{:03d}.jpg'.format(length,orientation) > > > img.save(fn) > > > > > > # stepping through ranges of values > > > for length in range(100, 601, 100): > > > for orientation in range(0, 171, 10): > > > makeimg(length, orientation) > > > > > > # using lists of values > > > for length in [50, 150, 250, 350, 450, 550, 650]: > > > for orientation in [0, 15, 40, 45, 60, 75, 90, 105, 120, 135, 150, > > > 165]: > > > makeimg(length, orientation) > > > > > > > > > > > > > > > -- > > > Denis McMahon, denismf...@gmail.com > > > > Thank you for the help btw. I think I'm close to a solution, but I'm having > issue feeding the coordinates from my csv file into the formula. > > > > This is the error I get: > > Traceback (most recent call last): > > File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w > corr.py", line 68, in > > makeimg(length, orientation) > > File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w > corr.py", line 40, in makeimg > > orientation = orientation % 180 > > TypeError: unsupported operand type(s) for %: 'list' and 'int' > > >>> > > > > and here's the code: > > > > from PIL import Image, ImageDraw > > from numpy import math > > > > # import csv > > import csv > > f = open('C:\Users\Owner\DesktopStimuli Generation\Coordinates\file.csv', > 'rb') > > rdr = csv.reader(f) > > f.seek(0) > > i = 0 > > a = [] > > b = [] > > for row in rdr: > > a.append(row[0]) > > b.append(row[1]) > > > > > > def makeimg(length, orientation): > > """ > > Make an image file of a black 4 pixel wide line of defined length > > crossing and centered on a white background of 800 px square, save > > as a png file identifying line length and orientation in the file > > name. > > param length - pixels, length of the line > > param orientation - degrees, orientation ccw of the line from +ve x > > axis > > Files are saved in imgs subdir, this must already exist. > > File name is image_lll_ooo.jpg > > lll = length, ooo = orientation, both 0 padded to 3 digits > > """ > > > > # check length is +ve and not greater than 800 > > if length < 0: > > length = length * -1 > > if length > 800: > > length = 800 > > > > # check orientation is positive in range 0 .. 179 > > while orientation < 0: > > orientation = orientation + 360 > > if orientation > 179: > > orientation = orientation % 180 >
Re: Help configuring visual studio to compile python extensions
This page helped me sort everything out: http://www.falatic.com/index.php/120/a-guide-to-building-python-2-x-and-3-x-extensions-for-windows. -- https://mail.python.org/mailman/listinfo/python-list
Re: Generate jpg files using line length (pixels) and orientation (degrees)
On 01/09/2015 04:51 PM, semeon.ri...@gmail.com wrote: On Friday, 9 January 2015 12:18:46 UTC-6, Joel Goldstick wrote: On Fri, Jan 9, 2015 at 12:49 PM, wrote: (double-spaced nonsense mostly trimmed) i = 0 a = [] b = [] What are a and b supposed to contain? Please use more informative names for them. it looks like they are intended to be lists of floats, but you're then stuffing them with strings. for row in rdr: a.append(row[0]) b.append(row[1]) perhaps something like: a.append(float(row[0])) b.append(float(row[1])) def makeimg(length, orientation): Probably should add some type checking here, since you're having repeated errors. if type(length) not is float or type(orientation) not is float: . some educational error message showing what the types and values actually are. Note I'm NOT recommending you code it this way. Just add the check till you've narrowed down the errors. . Unfortunately getting a new error. Traceback (most recent call last): File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w corr.py", line 68, in makeimg(length, orientation) File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w corr.py", line 40, in makeimg orientation = orientation % 180 TypeError: not all arguments converted during string formatting I think that's because the % operator means an entirely different thing if orientation is mistakenly passed as a string. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Generate jpg files using line length (pixels) and orientation (degrees)
> Unfortunately getting a new error. > > Traceback (most recent call last): > File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w > corr.py", line 68, in > makeimg(length, orientation) > File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w > corr.py", line 40, in makeimg > orientation = orientation % 180 > TypeError: not all arguments converted during string formatting My guess is that orientation contains a string that doesn't contain a '%' character: Python 3.4.2 (default, Oct 8 2014, 10:45:20) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 'this is a string' % 180 Traceback (most recent call last): File "", line 1, in TypeError: not all arguments converted during string formatting -- https://mail.python.org/mailman/listinfo/python-list
Re: Help configuring visual studio to compile python extensions
On 09/01/2015 22:14, stephen.bou...@gmail.com wrote: This page helped me sort everything out: http://www.falatic.com/index.php/120/a-guide-to-building-python-2-x-and-3-x-extensions-for-windows. That's good to know both for you and me but in future could you please quote some context, thanks :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Generate jpg files using line length (pixels) and orientation (degrees)
On 09/01/2015 21:51, semeon.ri...@gmail.com wrote: [As per Dave Angel snip all the double spaced nonsence] Please access this list via https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Non-unique dirs in sys.path
On Fri, Jan 9, 2015 at 2:24 PM, Gisle Vanem wrote: > Ian Kelly wrote: > >> I checked my own Python 2.7 installation and discovered that I have >> the same problem, although without the different casing. Perusing the >> .pth files in site-packages turns up setuptools.pth, which just >> contains the site-packages path. Removing that file solves the issue >> for me. > > > That was the case here too! Deleted my setuptools.pth and the "problem" > was gone. It would be nice to know how these .pth files are involved in > extending the 'sys.path[]'. Who does that and how? Any good reference on > that? The automatically imported site module processes the .pth files. https://docs.python.org/2/library/site.html -- https://mail.python.org/mailman/listinfo/python-list
Re: [ANN] EasyGUI_Qt version 0.9
On Wednesday, December 31, 2014 at 4:24:50 PM UTC-6, André Roberge wrote: > EasyGUI_Qt version 0.9 has been released. This is the first announcement > about EasyGUI_Qt on this list. > > Like the original EasyGUI (which used Tkinter), > EasyGUI_Qt seeks to provide simple GUI widgets > that can be called in a procedural program. > > EasyGUI_Qt is NOT event-driven: all GUI interactions are invoked by simple > function calls. > > The archetype is get_string(message) > which pops a box whose purpose is exactly the same as Python's input(prompt), > that is, present the user with a question/prompt, have the user enter an > answer, and return the provided answer as a string. Thus > easygui_qt.get_string() can be used as a drop-in replacement for > input(). > > Similarly, instead of using a print() function to display a message, > show_message() is used which pops a message window. > > EasyGUI_Qt requires PyQt4 and is really targeted for Python 3.3+ - although > it can work (possibly with some unicode problems ...) using Python 2.7. > > More information can be found at > http://easygui-qt.readthedocs.org/en/latest/index.html > > Feedback is most welcome, including reporting bugs to > https://github.com/aroberge/easygui_qt/issues > > Happy 2015 everyone, > > André Roberge Very nice, thanks. One issue is the format returned for the calendar selection. For today, the string returned is "Fri Jan 9 2015". My script needs to convert the date to a datetime.date, and having the month returned as a string instead of an integer makes this harder. -- https://mail.python.org/mailman/listinfo/python-list
Re: Help configuring visual studio to compile python extensions
On Friday, January 9, 2015 at 8:58:59 AM UTC-6, stephen...@gmail.com wrote: > I've installed Microsoft Visual Studio 10.0. Here are the steps I've been > taking. > > My python version is Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, > 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32. > > (Sorry for the long output.) > > >cd "c:\Program Files (x86)\Microsoft Visual Studio 10.0"\vc > >vcvarsall.bat > > > >SET VS90COMNTOOLS=%VS100COMNTOOLS% > c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>pip install scandir > Collecting scandir > Using cached scandir-0.9.tar.gz > Installing collected packages: scandir > Running setup.py install for scandir > building '_scandir' extension > C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c > /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\Python34\include -Ic:\Python34\include > /Tc_scandir.c /Fobuild\temp.win-amd64-3.4\Release > \_scandir.obj > _scandir.c > C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL > /nologo /INCREMENTAL:NO /LIBPATH:c:\Python34\libs > /LIBPATH:c:\Python34\PCbuild\amd64 /EXPORT:PyInit__scandir build\temp.win > -amd64-3.4\Release\_scandir.obj /OUT:build\lib.win-amd64-3.4\_scandir.pyd > /IMPLIB:build\temp.win-amd64-3.4\Release\_scandir.lib > /MANIFESTFILE:build\temp.win-amd64-3.4\Release\_scandir.pyd.manifest >Creating library build\temp.win-amd64-3.4\Release\_scandir.lib and > object build\temp.win-amd64-3.4\Release\_scandir.exp > _scandir.obj : error LNK2001: unresolved external symbol > _PyObject_SelfIter > _scandir.obj : error LNK2001: unresolved external symbol > _PyObject_GenericGetAttr > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyErr_WarnEx referenced in function _win32_warn_bytes_api > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyExc_DeprecationWarning referenced in function _win32_warn_bytes_api > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyErr_Occurred referenced in function _path_converter > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyBytes_FromObject referenced in function _path_converter > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyErr_Clear referenced in function _path_converter > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyExc_ValueError referenced in function _path_converter > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyUnicode_AsUnicodeAndSize referenced in function _path_converter > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyUnicode_FromObject referenced in function _path_converter > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyErr_Format referenced in function _path_converter > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyExc_TypeError referenced in function _path_converter > _scandir.obj : error LNK2019: unresolved external symbol > __imp___Py_NoneStruct referenced in function _path_converter > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyLong_FromUnsignedLong referenced in function _find_data_to_statresult > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyFloat_FromDouble referenced in function _find_data_to_statresult > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyLong_FromUnsignedLongLong referenced in function > _find_data_to_statresult > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyLong_FromLong referenced in function _find_data_to_statresult > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyStructSequence_New referenced in function _find_data_to_statresult > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyEval_RestoreThread referenced in function __fi_close > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyEval_SaveThread referenced in function __fi_close > _scandir.obj : error LNK2019: unresolved external symbol > __imp__Py_BuildValue referenced in function __fi_next > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyErr_SetFromWindowsErr referenced in function __fi_next > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyErr_NoMemory referenced in function __fi_next > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyErr_SetNone referenced in function __fi_next > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyExc_StopIteration referenced in function __fi_next > _scandir.obj : error LNK2019: unresolved external symbol > __imp__PyObject_Free referenced in function _fi_dealloc > _scandir.obj : error LNK2019: unresolved external symbol > __imp___PyObject_New referenced in function __iterfile > _scandir.obj : error LNK2019: unresolved external symbol > __im
Re: [ANN] EasyGUI_Qt version 0.9
On Friday, 9 January 2015 19:09:15 UTC-4, stephen...@gmail.com wrote: > Very nice, thanks. > > One issue is the format returned for the calendar selection. For today, the > string returned is "Fri Jan 9 2015". My script needs to convert the date to a > datetime.date, and having the month returned as a string instead of an > integer makes this harder. Unfortunately, this is the default calendar widget from Qt - I just use the default: ... def confirm(self): self.date = self.cal.selectedDate() Perhaps I can find something in the docs to see if I could have the format configurable. -- https://mail.python.org/mailman/listinfo/python-list
Re: [ANN] EasyGUI_Qt version 0.9
On Friday, 9 January 2015 19:09:15 UTC-4, stephen...@gmail.com wrote: > On Wednesday, December 31, 2014 at 4:24:50 PM UTC-6, André Roberge wrote: > > EasyGUI_Qt version 0.9 has been released. This is the first announcement > > about EasyGUI_Qt on this list. > > > > Like the original EasyGUI (which used Tkinter), > > EasyGUI_Qt seeks to provide simple GUI widgets > > that can be called in a procedural program. > > > > EasyGUI_Qt is NOT event-driven: all GUI interactions are invoked by simple > > function calls. > > > > The archetype is get_string(message) > > which pops a box whose purpose is exactly the same as Python's > > input(prompt), > > that is, present the user with a question/prompt, have the user enter an > > answer, and return the provided answer as a string. Thus > > easygui_qt.get_string() can be used as a drop-in replacement for > > input(). > > > > Similarly, instead of using a print() function to display a message, > > show_message() is used which pops a message window. > > > > EasyGUI_Qt requires PyQt4 and is really targeted for Python 3.3+ - although > > it can work (possibly with some unicode problems ...) using Python 2.7. > > > > More information can be found at > > http://easygui-qt.readthedocs.org/en/latest/index.html > > > > Feedback is most welcome, including reporting bugs to > > https://github.com/aroberge/easygui_qt/issues > > > > Happy 2015 everyone, > > > > André Roberge > > Very nice, thanks. > > One issue is the format returned for the calendar selection. For today, the > string returned is "Fri Jan 9 2015". My script needs to convert the date to a > datetime.date, and having the month returned as a string instead of an > integer makes this harder. Would today's date be represented as the string "09.01.2015" useful to you? (I found out how to do this.) If so, I could perhaps add an argument like numeric_format = True. André -- https://mail.python.org/mailman/listinfo/python-list
Re: class-based class decorator
On Sat, Jan 10, 2015 at 8:26 AM, Albert-Jan Roskam wrote: > I am trying to write a class decorator that checks whether deprecated > parameters with non-default > > arguments are used. More complete code is here: http://pastebin.com/ZqnMis6M. > In the code below, > Any particular reason to make this a class decorator, rather than a function decorator on __init__? After all, __init__ is where you're defining the deprecated parameters. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
On Fri, Jan 9, 2015 at 2:20 AM, Steven D'Aprano wrote: -snip- > I don't understand what you're trying to say here. You can't just > arbitrarily declare that 0**1 equals something other than 0 (or for that > matter, doesn't equal anything at all). You can, actually. It's just silly. (Similarly, you can declare that 0**0 is something other than 1 (or for that matter, doesn't equal anything at all), but it's silly.) > Can we agree that 0**1 is well-defined and get back to 0**0? Believe it or not I actually misread your whole thing and thought we were talking about 0**0. Otherwise I would've been much briefer... >>> Not quite. I agree that, *generally speaking* having 0**0 equal 1 is the >>> right answer, or at least *a* right answer, but not always. It depends on >>> how you get to 0**0... >> >> You don't "get to" a number. Those are limits. Limits and arithmetic >> are different. >> >> (Well, sort of. :) > > Yes, sort of :-) I was alluding to the definition of the reals. > Of course you can "get to" numbers. We start with counting, that's a way > to "get to" the natural numbers, by applying the "successor" function > repeatedly until we reach the one we want. Or you can "get to" pi by > generating an infinite sequence of closer and closer approximations. Or an > infinite series. Or an infinite product. Or an infinite continued fraction. > All of these "ways to get to pi" converge on the same result. Yes, all numbers can be represented as a converging limit. However, that does not mean that the way you compute the result of a function like x**y is by taking the limit as its arguments approach the input: that procedure works only for continuous functions. x**y is not continuous at 0, so this style of computation cannot give you an answer. > If 0**0 has a value, we can give that number a name. Let's call it Q. There > are different ways to evaluate Q: > > lim x -> 0 of sin(x)/x gives 1 > > lim x -> 0 of x**0 gives 1 > > lim x -> 0 of 0**x gives 0 This is a proof that f(x, y) = x**y is not continuous around 0, 0. It is not a proof that it is undefined at 0, 0, in fact, it says nothing about the value. > 0**0 = 0**(5-5) = 0**5 / 0**5 = 0/0 gives indeterminate Here is a nearly identical "proof" that 0**1 is "indeterminate": 0 = 0**1 = 0**(5 - 4) = 0**5 / 0**4 = 0/0 gives indeterminate. The fact that you can construct a nonsensical expression from an expression doesn't mean the original expression was nonsensical. In this case, your proof was invalid, because 0**(X-Y) is not equivalent to 0**X/0**Y. > So we have a problem. Since all these "ways to get to Q" fail to converge, > the obvious answer is to declare that Q doesn't exist and that 0**0 is > indeterminate, and that is what many mathematicians do: That isn't what "indeterminate" means. > However, this begs the question of what we mean by 0**0. > > In the case of m**n, with both m and n positive integers, there is an > intuitively obvious definition for exponentiation: repeated multiplication. > But there's no obvious meaning for exponentiation when both m and n are > zero, hence we (meaning, mathematicians) have to define what it means. So > long as that definition doesn't lead to contradiction, we can make any > choice we like. Sorry, I don't follow. n**0 as repeated multiplication makes perfect sense: we don't perform any multiplications, but if we did, we'd be multiplying 'n's. 0**m as repeated multiplication makes perfect sense: whatever we multiply, it's a bunch of 0s. Why doesn't 0**0 make sense? We don't perform any multiplications, but if we did, we'd be multiplying 0s. If we don't perform any multiplications, the things we didn't multiply don't matter. Whether they are fives, sevens, or zeroes, the answer is the same: 1. >>> Since you can get difference results depending on the method you use to >>> calculate it, the "technically correct" result is that 0**0 is >>> indeterminate. >> >> No, only limits are indeterminate. Calculations not involving limits >> cannot be indeterminate. > > Do tell me what 0/0 equals, if it is not indeterminate. 0/0 is undefined, it isn't "indeterminate". Indeterminate forms are a way of expressing limits where you have performed a lossy substitution. That is: "the limit as x approaches a of 0/0" is an indeterminate form. >> In the real number system, infinity does not exist. It only exists in >> limits or extended number systems. > > Yes, you are technically correct, the best kind of correct. > > I'm just sketching an informal proof. If you want to make it vigorous by > using limits, be my guest. It doesn't change the conclusion. No, the point is that limits are irrelevant. As has been proven countlessly many times, x**y is not continuous around the origin. This has no bearing on whether it takes a value at the origin. > > [...] >>> Arguably, *integer* 0**0 could be zero, on the basis that you can't take >>> limits of integer-valued quantities, and zero times itself zero times >>> surely has t
Is anyone else unable to log into the bug tracker?
I'm having trouble logging into the bug tracker. Is anyone else having the same problem, that is, your user name and password worked earlier but doesn't work now? http://bugs.python.org/ (Yes, I've checked the capslock key.) Before I request a new password, I want to check whether it is me or everyone. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Is anyone else unable to log into the bug tracker?
On 01/09/2015 05:48 PM, Steven D'Aprano wrote: > > I'm having trouble logging into the bug tracker. Is anyone else having the > same problem, that is, your user name and password worked earlier but > doesn't work now? I was just able to log in both using the Google short cut, and with my name/password (not Google). -- ~Ethan~ signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Is anyone else unable to log into the bug tracker?
Ethan Furman wrote: > On 01/09/2015 05:48 PM, Steven D'Aprano wrote: >> >> I'm having trouble logging into the bug tracker. Is anyone else having >> the same problem, that is, your user name and password worked earlier but >> doesn't work now? > > I was just able to log in both using the Google short cut, and with my > name/password (not Google). Thanks. Problem solved. It was just me. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
Steven D'Aprano wrote: I'm just sketching an informal proof. If you want to make it vigorous I think the usual term is "rigorous", unless the mathematician is taking some kind of stimulant... :-) -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
Steven D'Aprano wrote: Arguably, *integer* 0**0 could be zero, on the basis that you can't take limits of integer-valued quantities, and zero times itself zero times surely has to be zero. It's far from clear what *anything* multiplied by itself zero times should be. A better way of thinking about what x**n for integer n means is this: Start with 1, and multiply it by x n times. The result of this is clearly 1 when n is 0, regardless of the value of x. > 5**4 = 5*5*5*5 = 625 No: 5**4 = 1*5*5*5*5 5**3 = 1*5*5*5 5**2 = 1*5*5 5**1 = 1*5 5**0 = 1 -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Why do the URLs of posts here change?
Skip Montanaro wrote: The way this is done, is that the message is removed from the underlying mbox file, and the archive regenerated. That changes the counter for every message after that point Would it help to replace the message with a stub instead of deleting it altogether? -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Begginer Question , what i need for web app and site
> Hello all > coming from java and c++ now going with python > what setup do i need to run full python stack for web application . > what i need is web framework and back-end . > what usually be in the java world tomcat and servlets or jsp and pure java > backend for processing data . > what will be the Equivalent in python world ? > Thanks! Django (https://www.djangoproject.com/) is pretty popular. -- https://mail.python.org/mailman/listinfo/python-list
Re: Why do the URLs of posts here change?
On Sat, Jan 10, 2015 at 2:21 PM, Gregory Ewing wrote: > Skip Montanaro wrote: >> >> The way this is done, is >> that the message is removed from the underlying mbox file, and the >> archive regenerated. That changes the counter for every message after >> that point > > > Would it help to replace the message with a stub > instead of deleting it altogether? I had the same thought, but apparently not, according to the page Peter Otten linked to: http://wiki.list.org/display/DEV/Stable+URLs ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Decimals and other numbers
On Fri, Jan 9, 2015 at 7:05 PM, Gregory Ewing wrote: > It's far from clear what *anything* multiplied by > itself zero times should be. > > A better way of thinking about what x**n for integer > n means is this: Start with 1, and multiply it by > x n times. The result of this is clearly 1 when n > is 0, regardless of the value of x. > >> 5**4 = 5*5*5*5 = 625 > > No: > > 5**4 = 1*5*5*5*5 > 5**3 = 1*5*5*5 > 5**2 = 1*5*5 > 5**1 = 1*5 > 5**0 = 1 I never liked that, it seemed too arbitrary. How about this explanation: Assume that we know how to multiply a nonempty list numbers. so product([a]) == a, product([a, b]) = a * b, and so on. def product(nums): if len(nums) == 0: return ??? return reduce(operator.mul, nums) It should be the case that given a list of factors A and B, product(A + B) == product(A) * product(B) (associativity). We should let this rule apply even if A or B is the empty list, otherwise our rules are kind of stupid. Therefore, product([] + X) == product([]) * product(X) But since [] + X == X, product([] + X) == product(X) There's only one number like that: product([]) == 1 (Of course if you choose not to have the full associativity rule for empty products, then anything is possible.) -- Devin -- https://mail.python.org/mailman/listinfo/python-list
Re: class-based class decorator
On Fri, Jan 9, 2015 at 2:26 PM, Albert-Jan Roskam wrote: > > > Hi, > > I am trying to write a class decorator that checks whether deprecated > parameters with non-default > > arguments are used. More complete code is here: http://pastebin.com/ZqnMis6M. > In the code below, > > how should I modify __call__ such that f.bar(old="oh no") prints "hello > world"? > I thought it would be a fun way to play with the inspect module, but my head > is numb now and I am thirsty for a beer! You can use inspect.getargspec to look up the default argument values for the target function. You can use inspect.getcallargs to map your *args and **kwargs to a dictionary of argument names and values. Since the target function will be the unbound __init__ method, you'll also want to pass in a dummy value like None for the self argument. Then you just look up each of the deprecated names in the result and flag any where the value doesn't match the default. If you were using Python 3.3+, then I would recommend using inspect.signature instead, which is a lot more powerful. But your code appears to be Python 2, so we work with what we've got. -- https://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle, callfunc and varray
On Fri, Jan 9, 2015 at 12:24 PM, Dom wrote: > Hi > > I'm trying to return a simple array of numbers from a package using cx_oracle > (5.1.2). I believe this is possible. I've not been able to find anything that > suggest it isn't I'm afraid I don't have an answer for you, but you would probably have better luck asking on the cx-oracle-users mailing list: https://lists.sourceforge.net/lists/listinfo/cx-oracle-users -- https://mail.python.org/mailman/listinfo/python-list