Re: Why Python 3?

2014-04-20 Thread Chris Angelico
On Mon, Apr 21, 2014 at 1:43 PM, Steven D'Aprano wrote: >> Both explicit forms can be done cleanly without empowering the language >> with the magic of int/int->float. > > It's hardly magic, and I really am having difficult in working out > exactly what your objection to it is. Is it really as sim

Re: Why Python 3?

2014-04-20 Thread Chris Angelico
On Mon, Apr 21, 2014 at 1:43 PM, Steven D'Aprano wrote: >> Explicitly choosing float division: >> >> x / float(y) > > But here you're not choosing an *operator*, you're choosing a *type*. > With this model, how do I distinguish between floor division and true > division using, say, Fractions? Ear

Re: Why Python 3?

2014-04-20 Thread HoneyMonster
On Mon, 21 Apr 2014 10:00:01 +1000, Chris Angelico wrote: > On Mon, Apr 21, 2014 at 9:50 AM, Walter Hurry > wrote: >> I would use Python 3 in a flash if only wxPython would support it. > > There seems to be a "Project Phoenix" (found it at the other end of a > Google search) with that goal. I've

Re: Why Python 3?

2014-04-20 Thread Steven D'Aprano
On Mon, 21 Apr 2014 09:24:09 +1000, Chris Angelico wrote: > On Mon, Apr 21, 2014 at 8:52 AM, Gregory Ewing > wrote: >> Chris Angelico wrote: >> >>> Truncating vs true is not the same as int vs float. If you mean to >>> explicitly request float division, you call float() on one or both >>> argumen

Re: Why Python 3?

2014-04-20 Thread Steven D'Aprano
On Sun, 20 Apr 2014 14:40:38 -0700, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> On Mon, Apr 21, 2014 at 2:22 AM, Ian Kelly >> wrote: >> > When I'm writing a generic average function, I probably don't know >> > whether it will ever be used to average complex numbers. >> >> Thi

Re: Why Python 3?

2014-04-20 Thread Ian Kelly
On Apr 20, 2014 8:01 PM, "Gregory Ewing" wrote: > > Ian Kelly wrote: > >> def average(values): >> return sum(values) / len(values) >> >> This works for decimals, it works for fractions, it works for complex numbers, it works for numpy types, and in Python 3 it works for ints. > > > That depend

Re: Why Python 3?

2014-04-20 Thread Gregory Ewing
Richard Damon wrote: If you thing of the Standard Deviation being the Root Mean Norm2 of the deviations, it has a very similar meaning as to over the reals, a measure of the "spread" of the values. NumPy appears to handle this: http://docs.scipy.org/doc/numpy/reference/generated/numpy.std.html

Re: Why Python 3?

2014-04-20 Thread Mark Lawrence
On 21/04/2014 00:50, Walter Hurry wrote: On Sat, 19 Apr 2014 20:25:32 -0700, Paul Rubin wrote: Terry Reedy writes: LibreOffice bundles 3.3. So anyone who does Python scripting in LibreOffice is using Python 3. Actually, I believe LO uses Python internally for some of its scripting. If so, eve

Re: Why Python 3?

2014-04-20 Thread Terry Reedy
On 4/20/2014 7:13 PM, Gregory Ewing wrote: Terry Reedy wrote: On 4/19/2014 9:06 PM, Gregory Ewing wrote: Similarly, when you write // you're explicitly requesting integer division. One is requesting 'floor division' >>> 3.0//2.0 1.0 The name 'floor division' and the float result are inte

Re: Why Python 3?

2014-04-20 Thread Chris Angelico
On Mon, Apr 21, 2014 at 9:50 AM, Walter Hurry wrote: > I would use Python 3 in a flash if only wxPython would support it. There seems to be a "Project Phoenix" (found it at the other end of a Google search) with that goal. I've no idea what its status is, but you could help that project along by

Re: Why Python 3?

2014-04-20 Thread Gregory Ewing
Ian Kelly wrote: def average(values): return sum(values) / len(values) This works for decimals, it works for fractions, it works for complex numbers, it works for numpy types, and in Python 3 it works for ints. That depends on what you mean by "works". I would actually find it rather dis

Re: Why Python 3?

2014-04-20 Thread Walter Hurry
On Sat, 19 Apr 2014 20:25:32 -0700, Paul Rubin wrote: > Terry Reedy writes: >> LibreOffice bundles 3.3. So anyone who does Python scripting in >> LibreOffice is using Python 3. Actually, I believe LO uses Python >> internally for some of its scripting. If so, everyone using LO is >> indirectly us

Re: Integer and float division [was Re: Why Python 3?]

2014-04-20 Thread Gregory Ewing
On Sat, 19 Apr 2014 19:37:31 +1000, Chris Angelico wrote: > In Python 3, you have to say "Oh but I want my integer division to result in an integer": I don't see why that's such a big hardship. There are clear advantages to having an explicit way to request non-floor division. Whatever way is

Re: how to string format when string have {

2014-04-20 Thread Tim Chase
On 2014-04-20 15:34, Mariano DAngelo wrote: > I have the following string: ... > but since the string have { i can't. > Is there a way to solve this? I second Chris Angelico's suggestion about using the older percent formatting: nginx_conf = ''' server { listen 80; server_name dev

Re: Why Python 3?

2014-04-20 Thread Chris Angelico
On Mon, Apr 21, 2014 at 8:52 AM, Gregory Ewing wrote: > Chris Angelico wrote: > >> Truncating vs true is not the same as int vs float. If you mean to >> explicitly request float division, you call float() on one or both >> arguments. You're being explicit about something different. > > > If you kn

Re: Why Python 3?

2014-04-20 Thread Gregory Ewing
Terry Reedy wrote: On 4/19/2014 9:06 PM, Gregory Ewing wrote: Similarly, when you write // you're explicitly requesting integer division. One is requesting 'floor division' >>> 3.0//2.0 1.0 In general that's true, but I'm talking about a context in which you have some expectations as to t

Re: Why Python 3?

2014-04-20 Thread Gregory Ewing
Chris Angelico wrote: Truncating vs true is not the same as int vs float. If you mean to explicitly request float division, you call float() on one or both arguments. You're being explicit about something different. If you know you're dealing with either ints or floats, which is true in the va

Re: how to string format when string have {

2014-04-20 Thread Chris Angelico
On Mon, Apr 21, 2014 at 8:34 AM, Mariano DAngelo wrote: > And I want to format like this: > > context = { > "project_name":project_name, > "project_url":project_url, > } > > nginx_conf.format(**context) > > > but since the string have { i can't. > Is there a way to solve this? Are you in full

how to string format when string have {

2014-04-20 Thread Mariano DAngelo
I have the following string: nginx_conf = ''' server { listen 80; server_name dev.{project_url}; location / { proxy_pass http://127.0.0.1:8080; include /etc/nginx/proxy.conf; } location /media { alias /home/mariano/PycharmProjects/{project

Re: Why Python 3?

2014-04-20 Thread Richard Damon
On 4/20/14, 5:40 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> On Mon, Apr 21, 2014 at 2:22 AM, Ian Kelly wrote: >>> When I'm writing a generic average function, I probably don't know whether >>> it will ever be used to average complex numbers. >> >> This keeps coming up in t

Re: Why Python 3?

2014-04-20 Thread Terry Reedy
On 4/20/2014 5:40 PM, Roy Smith wrote: In article , Chris Angelico wrote: On Mon, Apr 21, 2014 at 2:22 AM, Ian Kelly wrote: When I'm writing a generic average function, I probably don't know whether it will ever be used to average complex numbers. This keeps coming up in these discussion

Re: Why Python 3?

2014-04-20 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Apr 21, 2014 at 2:22 AM, Ian Kelly wrote: > > When I'm writing a generic average function, I probably don't know whether > > it will ever be used to average complex numbers. > > This keeps coming up in these discussions. How often do you really > wr

Re: [OT] Testing and credentials best practices?

2014-04-20 Thread Roy Smith
In article <267e12d3-ea01-4886-bfa7-5c7270adb...@googlegroups.com>, Miki Tebeka wrote: > Greetings, > > How do you deal with tests (both on dev machine and Jenkins) that need > credentials (such as AWS keys)?. I know of the following methods: > > 1. Test user with known (stored in source cont

Re: Why Python 3?

2014-04-20 Thread Michael Torrie
On 04/20/2014 12:02 PM, Bernd Waterkamp wrote: > Michael Torrie schrieb: > >> For example, RHEL 6 is Red Hat's most current enterprise distribution and >> it does not yet even ship Python 2.7, to say nothing of Python 3. RHEL >> 7 has python 2.7 as the default system dependency, and currently doe

Re: symple programming task

2014-04-20 Thread Ivan Ivanivich
On Sunday, April 20, 2014 10:43:37 PM UTC+4, Ivan Ivanivich wrote: > hi all, i have simple programming task: > > > > [quot] > > If we list all the natural numbers below 10 that are multiples of 3 or 5, we > get 3, 5, 6 and 9. The sum of these multiples is 23. > > > > Find the sum of all the

Re: symple programming task

2014-04-20 Thread Joel Goldstick
On Sun, Apr 20, 2014 at 3:02 PM, Chris Angelico wrote: > On Mon, Apr 21, 2014 at 4:43 AM, Ivan Ivanivich > wrote: > > [quot] > > If we list all the natural numbers below 10 that are multiples of 3 or > 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. > > > > Find the sum of all the mul

Re: symple programming task

2014-04-20 Thread Peter Otten
Ivan Ivanivich wrote: > hi all, i have simple programming task: > > [quot] > If we list all the natural numbers below 10 that are multiples of 3 or 5, > we get 3, 5, 6 and 9. The sum of these multiples is 23. > > Find the sum of all the multiples of 3 or 5 below 1000. > [/quote] > > this task f

Re: symple programming task

2014-04-20 Thread Chris Angelico
On Mon, Apr 21, 2014 at 4:43 AM, Ivan Ivanivich wrote: > [quot] > If we list all the natural numbers below 10 that are multiples of 3 or 5, we > get 3, 5, 6 and 9. The sum of these multiples is 23. > > Find the sum of all the multiples of 3 or 5 below 1000. > [/quote] > > this task from http://pr

symple programming task

2014-04-20 Thread Ivan Ivanivich
hi all, i have simple programming task: [quot] If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. [/quote] this task from http://projecteuler.net/ site I wrote

Re: Why Python 3?

2014-04-20 Thread Bernd Waterkamp
Michael Torrie schrieb: > For example, RHEL 6 is Red Hat's most current enterprise distribution and > it does not yet even ship Python 2.7, to say nothing of Python 3. RHEL > 7 has python 2.7 as the default system dependency, and currently does > not yet have any python3 packages in the official

Re: Why Python 3?

2014-04-20 Thread CHIN Dihedral
On Saturday, April 19, 2014 12:50:09 PM UTC+8, Ethan Furman wrote: > On 04/18/2014 08:28 PM, Anthony Papillion wrote: > > > > > > What is the general feel of /this/ community? I'm about to start a > > > large scale Python project. Should it be done in 2 or 3? What are the > > > benefits, aside

Re: [OT] Testing and credentials best practices?

2014-04-20 Thread Chris Angelico
On Mon, Apr 21, 2014 at 2:36 AM, Miki Tebeka wrote: > How do you deal with tests (both on dev machine and Jenkins) that need > credentials (such as AWS keys)?. I know of the following methods: > > 1. Test user with known (stored in source control) limited credentials > 2. ~/.secrets (or any other

Re: Why Python 3?

2014-04-20 Thread Chris Angelico
On Mon, Apr 21, 2014 at 2:22 AM, Ian Kelly wrote: > When I'm writing a generic average function, I probably don't know whether > it will ever be used to average complex numbers. This keeps coming up in these discussions. How often do you really write a function that generic? And if you do, isn't

Re: Why Python 3?

2014-04-20 Thread MRAB
On 2014-04-20 17:22, Ian Kelly wrote: On Apr 19, 2014 2:54 PM, "Chris Angelico" mailto:ros...@gmail.com>> wrote: > > On Sun, Apr 20, 2014 at 6:38 AM, Ian Kelly mailto:ian.g.ke...@gmail.com>> wrote: > >> Or you just cast one of them to float. That way you're sure you're > >> working with floa

[OT] Testing and credentials best practices?

2014-04-20 Thread Miki Tebeka
Greetings, How do you deal with tests (both on dev machine and Jenkins) that need credentials (such as AWS keys)?. I know of the following methods: 1. Test user with known (stored in source control) limited credentials 2. ~/.secrets (or any other known location) RC file which is not in source c

Re: Why Python 3?

2014-04-20 Thread Ian Kelly
On Apr 19, 2014 2:54 PM, "Chris Angelico" wrote: > > On Sun, Apr 20, 2014 at 6:38 AM, Ian Kelly wrote: > >> Or you just cast one of them to float. That way you're sure you're > >> working with floats. > > > > Which is inappropriate if the type passed in was a Decimal or a complex. > > In that cas

Re: ctypes: returning an array from a subroutine

2014-04-20 Thread Alex van der Spek
Many hours later I found a working solutions in ctypes: The below makes sense to me but I am still at a loss why the first solution did not work. Anybody willing to explain for my better understanding? Regards, Alex van der Spek _snns = ctypes.w

Re: Integer and float division [was Re: Why Python 3?]

2014-04-20 Thread Steven D'Aprano
On Sun, 20 Apr 2014 15:38:03 +0300, Jussi Piitulainen wrote: > Steven D'Aprano writes: > >> It doesn't round, it truncates. >> >> [steve@ando ~]$ python2.7 -c "print round(799.0/100)" 8.0 >> [steve@ando ~]$ python2.7 -c "print 799/100" 7 > > Seems it floors rather than truncates: > > $ python2

Re: Why Python 3?

2014-04-20 Thread Michael Torrie
On 04/20/2014 02:47 AM, Ian Foote wrote: >> Depends on what OS you want to be running on. I don't know of any >> currently-supported Enterprise distributions (long-term support) >> that ship with Python 3.4. > > I don't know if you'd count it as an "Enterprise" distribution, but > ubuntu 14.04 (

Re: Integer and float division [was Re: Why Python 3?]

2014-04-20 Thread Jussi Piitulainen
Steven D'Aprano writes: > It doesn't round, it truncates. > > [steve@ando ~]$ python2.7 -c "print round(799.0/100)" > 8.0 > [steve@ando ~]$ python2.7 -c "print 799/100" > 7 Seems it floors rather than truncates: $ python2.7 -c "from math import trunc;print trunc(799./-100)" -7 $ python2.7 -c "f

ctypes: returning an array from a subroutine

2014-04-20 Thread Alex van der Spek
I have a C code function like this: ++ int __declspec(dllexport) __stdcall bnd2prb(float *in, float *out, int init) {enum {OK, Error, Not_Valid}; ... return(OK): } ++ And in Python I am trying to call this C function: ++

Re: Why Python 3?

2014-04-20 Thread Tim Chase
On 2014-04-20 09:43, Steven D'Aprano wrote: > So really the advice comes down to: > > - if you can, use the latest version of Python, which is 3.4; > > - if you must, use the version of Python provided by your operating > system, which could be anything from Python 2.3 to 3.3; > > - if you hav

Integer and float division [was Re: Why Python 3?]

2014-04-20 Thread Steven D'Aprano
On Sat, 19 Apr 2014 19:37:31 +1000, Chris Angelico wrote: > On Sat, Apr 19, 2014 at 7:25 PM, Ian Kelly > wrote: >> The change from / denoting "classic >> division" to "true division" really only affects the case where both >> operands are integers, so far as I'm aware. If you want to divide two

Re: Why Python 3?

2014-04-20 Thread Steven D'Aprano
On Sat, 19 Apr 2014 09:26:53 -0400, Roy Smith wrote: > One of the problems is you don't know in advance if something is going > to stop you. By committing to P3 now, you are eliminating from possible > future use, all of those third-party modules which only support P2. And > you don't know which

Re: Why Python 3?

2014-04-20 Thread Steven D'Aprano
On Fri, 18 Apr 2014 23:40:18 -0700, Paul Rubin wrote: > It's just that the improvement > from 2 to 3 is rather small, and 2 works perfectly well and people are > used to it, so they keep using it. Spoken like a true ASCII user :-) The "killer feature" of Python 3 is improved handling of Unicode,

Re: Why Python 3?

2014-04-20 Thread Steven D'Aprano
On Fri, 18 Apr 2014 21:50:09 -0700, Ethan Furman wrote: > Use Python 3 if you can. The best reason not to is if you have some > critical library that you absolutely need and it's not yet available on > 3. That's good advice, but it isn't just applicable to Python 3, it applies to *any* critic

Re: Why Python 3?

2014-04-20 Thread Ben Finney
Paul Rubin writes: > [people I know] use whatever is in the OS distro, and that is > generally still 2.6 or 2.7. When the OS contains *both* Python 2 and Python 3, does Python 3 count as “in the OS”? Or will you only count Python 3 as “in the OS” when Python 2 is not present at all in the OS?

Re: Why Python 3?

2014-04-20 Thread Ian Foote
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20/04/14 03:34, Michael Torrie wrote: > On 04/18/2014 10:49 PM, Andrew Berg wrote: >> Python 3 is not the future; it is the present. If you're >> developing an application, just use Python 3.4 and don't look >> back unless you absolutely positively