Re: [Tutor] regex to promote Py 2 to Py 3?

2013-04-16 Thread Jim Mooney
> Generally the 2to3 script does an OK job. If you're using Windows it's > [Python_Dir]\Tools\Scripts\2to3.py. > > http://docs.python.org/3/library/2to3 Thanks. I didn't know where to find it and thought I had to install it. I opened a command window in my Python3

Re: [Tutor] How did this decimal error pop up?

2013-04-16 Thread Jay Lozier
On 04/16/2013 01:43 PM, Jim Mooney wrote: I was doing a simple training prog to figure change, and wanted to avoid computer inaccuracy by using only two-decimal input and not using division or mod where it would cause error. Yet, on a simple subtraction I got a decimal error instead of a two de

Re: [Tutor] regex to promote Py 2 to Py 3?

2013-04-16 Thread eryksun
On Tue, Apr 16, 2013 at 9:02 PM, Jim Mooney wrote: > So for online progs, examples, ebooks, etc, that still have Py 2 > examples I can copy, has anyone come up with a nice regex package to > do most of the conversions and produce a mostly Py3 from a Py2? That > might make some things a bit easier.

Re: [Tutor] regex to promote Py 2 to Py 3?

2013-04-16 Thread Michael Weylandt
On Apr 16, 2013, at 21:02, Jim Mooney wrote: > I already tried an example I copied from something online, in Py 2, > that had a ton of print statements. So I did some fast search and > replace to make them Py 3 with (), since I'm using Py 3. (Except Wing > 101 won't do Replace All for some reas

[Tutor] regex to promote Py 2 to Py 3?

2013-04-16 Thread Jim Mooney
I already tried an example I copied from something online, in Py 2, that had a ton of print statements. So I did some fast search and replace to make them Py 3 with (), since I'm using Py 3. (Except Wing 101 won't do Replace All for some reason I haven't figured out, so it's a bit tedious) So for

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Sander Sweers
On 04/17/2013 02:34 AM, eryksun wrote: > I just went through the steps. You don't even need your password. > Enter your email address in the bottom field of the list info page: > > http://mail.python.org/mailman/listinfo/tutor > > Click the button that says "Unsubscribe or edit options". Then sim

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread eryksun
On Tue, Apr 16, 2013 at 8:15 PM, eryksun wrote: >> Can someone please do me the favor and remove me from this god forsaken >> email list I am sorry I signed up all it has done is taken over my phone and >> rings all night long with emails I am not interested in any more because it >> is just too m

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread eryksun
On Tue, Apr 16, 2013 at 7:57 PM, Virgilio Rodriguez Jr wrote: > Can someone please do me the favor and remove me from this god forsaken > email list I am sorry I signed up all it has done is taken over my phone and > rings all night long with emails I am not interested in any more because it > is

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Steven D'Aprano
On 17/04/13 01:58, Andy McKenzie wrote: 1) Python 2.7 or 3.x? I know I'm going to want to do some work with NLTK (which appears to only have an alpha version out for Python 3), but I've just gone through the hassle of dealing with an upgrade from PHP 4 to 5.3, and I'd rather not start learning

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Andy McKenzie
On Tue, Apr 16, 2013 at 7:39 PM, Alan Gauld wrote: > On 16/04/13 22:20, Andy McKenzie wrote: > > For instance: output of running print_r on a very short dictionary from >> PHP: >> >> Array >> ( >> [key3] => thing3 >> [key2] => thing2 >> [key1] => thing1 >> ) >> >> And running ppri

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread eryksun
On Tue, Apr 16, 2013 at 6:17 PM, Dave Angel wrote: > Someone else may know if "identical" has some exceptions. But as for where > to put it, you'd need it for any module (including your own script) which is > going to use the newer print() function. I think any differences will result from the I

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Alan Gauld
On 16/04/13 22:20, Andy McKenzie wrote: For instance: output of running print_r on a very short dictionary from PHP: Array ( [key3] => thing3 [key2] => thing2 [key1] => thing1 ) And running pprint on the same dict in Python: {'key1': 'thing1', 'key2': 'thing2', 'key3': 'thing3

Re: [Tutor] How did this decimal error pop up?

2013-04-16 Thread eryksun
On Tue, Apr 16, 2013 at 6:10 PM, Hugo Arts wrote: i = 0 for _ in range(1000): > i += 0.1 > i > 99.99986 > > That should, by all the laws of math, be 100. But it isn't. Because the > computer can't store 0.1 in a float, so it stores the closest possible > number it can instea

Re: [Tutor] How did this decimal error pop up?

2013-04-16 Thread Dave Angel
On 04/16/2013 06:10 PM, Hugo Arts wrote: The other option, and probably the simplest to use, is python's built in decimal module, which provides a special class that implements perfectly accurate decimal calculations. Why don't we use it for all applications, you might ask? Well, it is extre

Re: [Tutor] oops - resending as plain text

2013-04-16 Thread eryksun
On Tue, Apr 16, 2013 at 6:09 PM, Dave Angel wrote: > If the conversion itself will catch the errors, then you can just use > try/catch to make such errors more polite to your users. That's the case if > they enter "charlie" when you're asking for a salary value. But if they > were to put 7.500

Re: [Tutor] How did this decimal error pop up?

2013-04-16 Thread Hugo Arts
On Tue, Apr 16, 2013 at 7:43 PM, Jim Mooney wrote: > I was doing a simple training prog to figure change, and wanted to avoid > computer inaccuracy by using only two-decimal input and not using division > or mod where it would cause error. Yet, on a simple subtraction I got a > decimal error inste

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Dave Angel
On 04/16/2013 05:47 PM, Andy McKenzie wrote: On Tue, Apr 16, 2013 at 5:31 PM, Dave Angel wrote: To get 3.x functionality, you'd want to use from __future__ import print_function and I do not think that works in 2.6 or older versions. It also can be awkward even in 2.7 if you're mi

Re: [Tutor] oops - resending as plain text

2013-04-16 Thread Dave Angel
On 04/16/2013 05:46 PM, Jim Mooney wrote: Further question. If I round the input right at the beginning, round(paid,2) does that mean I still have the original error from using .76 even before math, or does the rounding kill it? I would guess not if it's binary, You guess right. round() funct

Re: [Tutor] oops - resending as plain text

2013-04-16 Thread Jim Mooney
Further question. If I round the input right at the beginning, round(paid,2) does that mean I still have the original error from using .76 even before math, or does the rounding kill it? I would guess not if it's binary, although Python must have a way to handle money amounts. I'm only on Chapter

Re: [Tutor] Tutor Digest, Vol 110, Issue 69

2013-04-16 Thread Jim Mooney
> Now that Joel Goldstick has pointed out the reason, you may wonder what to do > now. Answer? Use the decimal module: > > http://docs.python.org/2/library/decimal.html > > Although, you might prefer Doug Hellmann's introduction: > > http://pymotw.com/2/decimal/ Thanks. I was about to ask that bu

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Andy McKenzie
On Tue, Apr 16, 2013 at 5:31 PM, Dave Angel wrote: > On 04/16/2013 05:20 PM, Andy McKenzie wrote: > >> >> >> > > >>> >>> Thanks for the advice, folks. Given that it looks like the biggest >> changes >> are unicode handling (which I'm not going to need any time soon) and the >> way the pri

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Dave Angel
On 04/16/2013 05:20 PM, Andy McKenzie wrote: Thanks for the advice, folks. Given that it looks like the biggest changes are unicode handling (which I'm not going to need any time soon) and the way the print function works, I decided to stick with 2.7. I'm an IT guy, though unemploye

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Andy McKenzie
On Tue, Apr 16, 2013 at 4:18 PM, Dave Angel wrote: > On 04/16/2013 11:58 AM, Andy McKenzie wrote: > >> Hey folks. >> >> I'm just starting to pick up Python, and I'd like to avoid some of the >> mistakes I made in the past. To elaborate on that, my primary >> programming/scripting experience is P

Re: [Tutor] oops - resending as plain text

2013-04-16 Thread Dave Angel
On 04/16/2013 01:48 PM, Jim Mooney wrote: I accidentally sent as HTML so this is a resend in case that choked the mailing prog ;') I was doing a simple training prog to figure monetary change, and wanted to avoid computer inaccuracy by using only two-decimal input and not using division or mod w

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Dave Angel
On 04/16/2013 11:58 AM, Andy McKenzie wrote: Hey folks. I'm just starting to pick up Python, and I'd like to avoid some of the mistakes I made in the past. To elaborate on that, my primary programming/scripting experience is PHP, with a little bit of Perl thrown in. Like so many people who wri

Re: [Tutor] oops - resending as plain text

2013-04-16 Thread Sander Sweers
On 04/16/2013 07:48 PM, Jim Mooney wrote: > I accidentally sent as HTML so this is a resend in case that choked > the mailing prog ;') > > I was doing a simple training prog to figure monetary change, and > wanted to avoid computer inaccuracy by using only two-decimal input > and not using divisio

Re: [Tutor] oops - resending as plain text

2013-04-16 Thread Don Jennings
On Apr 16, 2013, at 1:48 PM, Jim Mooney wrote: > I accidentally sent as HTML so this is a resend in case that choked > the mailing prog ;') > > I was doing a simple training prog to figure monetary change, and > wanted to avoid computer inaccuracy by using only two-decimal input > and not using

Re: [Tutor] oops - resending as plain text

2013-04-16 Thread Joel Goldstick
On Tue, Apr 16, 2013 at 1:48 PM, Jim Mooney wrote: > I accidentally sent as HTML so this is a resend in case that choked > the mailing prog ;') > > I was doing a simple training prog to figure monetary change, and > wanted to avoid computer inaccuracy by using only two-decimal input > and not usin

[Tutor] How did this decimal error pop up?

2013-04-16 Thread Jim Mooney
I was doing a simple training prog to figure change, and wanted to avoid computer inaccuracy by using only two-decimal input and not using division or mod where it would cause error. Yet, on a simple subtraction I got a decimal error instead of a two decimal result, as per below. What gives? cost

[Tutor] oops - resending as plain text

2013-04-16 Thread Jim Mooney
I accidentally sent as HTML so this is a resend in case that choked the mailing prog ;') I was doing a simple training prog to figure monetary change, and wanted to avoid computer inaccuracy by using only two-decimal input and not using division or mod where it would cause error. Yet, on a simple

[Tutor] Fwd: Hello, and a newbie question

2013-04-16 Thread leam hall
Python 2.x if you're working on existing servers like RHEL. If you're having fun on a desktop, Python 3. Free on-line college level class just started: https://class.coursera.org/interactivepython-002/class/index BTW, PHP ROCKS! :P Leam -- Also a PHP programmer -- Mind on a Mission

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Alan Gauld
On 16/04/13 16:58, Andy McKenzie wrote: 1) Python 2.7 or 3.x? I know I'm going to want to do some work with NLTK (which appears to only have an alpha version out for Python 3), but I've just gone through the hassle of dealing with an upgrade from PHP 4 to 5.3, and I'd rather not start learning

[Tutor] Hello, and a newbie question

2013-04-16 Thread Andy McKenzie
Hey folks. I'm just starting to pick up Python, and I'd like to avoid some of the mistakes I made in the past. To elaborate on that, my primary programming/scripting experience is PHP, with a little bit of Perl thrown in. Like so many people who write in PHP, I was entirely self-taught, and woul