Re: [Tutor] How to paste text from from clipboard to command line?

2015-01-21 Thread Richard D. Moores
On Wed, Jan 21, 2015 at 8:10 AM, Steven D'Aprano wrote: > https://duckduckgo.com/?q=windows+command+line+paste Ah, check QuickEdit Mode in Properties. Thanks very much. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription option

Re: [Tutor] How to paste text from from clipboard to command line?

2015-01-21 Thread Richard D. Moores
On Wed, Jan 21, 2015 at 8:04 AM, Steven D'Aprano wrote: > Huh? Thanks for what? Please note the subject line. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

[Tutor] How to paste text from from clipboard to command line?

2015-01-21 Thread Richard D. Moores
Thanks, Dick Moores Python 3.4.1 Win 7 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to unpack python-dateutil-2.0.tar.gz

2012-10-19 Thread Richard D. Moores
On Fri, Oct 19, 2012 at 3:47 AM, eryksun wrote: > On Fri, Oct 19, 2012 at 5:53 AM, Richard D. Moores wrote: >> On Fri, Oct 19, 2012 at 1:55 AM, Mark Lawrence >> wrote: >>> >>> So what? Why should the way that Python software gets installed vary from >

Re: [Tutor] How to unpack python-dateutil-2.0.tar.gz

2012-10-19 Thread Richard D. Moores
On Fri, Oct 19, 2012 at 1:55 AM, Mark Lawrence wrote: > On 19/10/2012 02:55, Richard D. Moores wrote: >> >> On Thu, Oct 18, 2012 at 6:08 PM, Mark Lawrence >> wrote: >> >>> Could you please take a training course on how to use a search engine. >>>

Re: [Tutor] How to unpack python-dateutil-2.0.tar.gz

2012-10-18 Thread Richard D. Moores
On Thu, Oct 18, 2012 at 9:41 PM, eryksun wrote: > On Thu, Oct 18, 2012 at 11:55 PM, Steven D'Aprano wrote: >> >> Have you tried running `date` at the Windows command.com (or cmd.exe, >> or something, I never remember which)? What does it print? >> >> My guess is that it probably prints something

Re: [Tutor] How to unpack python-dateutil-2.0.tar.gz

2012-10-18 Thread Richard D. Moores
On Thu, Oct 18, 2012 at 7:17 PM, Steven D'Aprano wrote: > On 19/10/12 12:16, Richard D. Moores wrote: >> >> Running the example at >> >> <http://labix.org/python-dateutil#head-8d03c6c25ead6f9cab0cde83e6f672b52480ab90>, >> with Python 2.3.2 64-bit, &g

Re: [Tutor] How to unpack python-dateutil-2.0.tar.gz

2012-10-18 Thread Richard D. Moores
On Thu, Oct 18, 2012 at 6:08 PM, Mark Lawrence wrote: > Could you please take a training course on how to use a search engine. First > hit on google for "python dateutils install windows" is > http://stackoverflow.com/questions/879156/how-to-install-python-dateutil-on-windows You're assuming I h

Re: [Tutor] How to unpack python-dateutil-2.0.tar.gz

2012-10-18 Thread Richard D. Moores
Running the example at , with Python 2.3.2 64-bit, The importing goes OK, it seems, but: Python 3.2.3 (default, Apr 11 2012, 07:12:16) [MSC v.1500 64 bit (AMD64)] Type "help", "copyright", "credits" or "license" for m

Re: [Tutor] How to unpack python-dateutil-2.0.tar.gz

2012-10-18 Thread Richard D. Moores
On Thu, Oct 18, 2012 at 5:27 PM, Alan Gauld wrote: > On 19/10/12 01:01, Richard D. Moores wrote: >> >> Python 3.2.3 64 bit >> MS Windows 7 Home Premium 64-bit SP1 >> ... >> >> unpack a .tar.gz file. Please remind me. By trying with Peazip I got it unpac

Re: [Tutor] How to unpack python-dateutil-2.0.tar.gz

2012-10-18 Thread Richard D. Moores
On Thu, Oct 18, 2012 at 5:27 PM, Alan Gauld wrote: > On 19/10/12 01:01, Richard D. Moores wrote: >> >> Python 3.2.3 64 bit >> MS Windows 7 Home Premium 64-bit SP1 >> ... >> >> unpack a .tar.gz file. Please remind me. > > > Winzip or similar should c

[Tutor] How to unpack python-dateutil-2.0.tar.gz

2012-10-18 Thread Richard D. Moores
Python 3.2.3 64 bit MS Windows 7 Home Premium 64-bit SP1 I see python-dateutil recommended here from time to time, so I thought I'd try it out. I downloaded python-dateutil-2.1.tar.gz from http://pypi.python.org/pypi/python-dateutil but have forgotten how to unpack a .tar.gz file. Please remind me

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-06 Thread Richard D. Moores
On Sat, Oct 6, 2012 at 6:50 PM, Steven D'Aprano wrote: > On 07/10/12 12:08, Richard D. Moores wrote: >> >> On Sat, Oct 6, 2012 at 4:42 PM, Mark Lawrence >> wrote: >> >>> Use calendar.day_name. >> >> >> How? > > > By readi

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-06 Thread Richard D. Moores
On Sat, Oct 6, 2012 at 5:22 PM, eryksun wrote: > >>> from datetime import date > >>> date(2014, 2, 18).strftime("%A") > 'Tuesday' > > http://docs.python.org/library/datetime#strftime-and-strptime-behavior Or for Python 3.3,

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-06 Thread Richard D. Moores
On Sat, Oct 6, 2012 at 4:35 PM, Alan Gauld wrote: > On 07/10/12 00:19, Richard D. Moores wrote: > >> That "1" means Tuesday, right? But how can I use calendar to print out >> that word, "TUESDAY"? > > > days = ("Monday", >

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-06 Thread Richard D. Moores
On Sat, Oct 6, 2012 at 4:29 PM, Dave Angel wrote: > To turn an integer (0-6, or whatever) into a string, just use a tuple of > the same size: > > tran = ("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", > "SATURDAY", "SUNDAY") > i = 1 > print tran[i] > > (prints "TUESDAY") Why did you cho

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-06 Thread Richard D. Moores
On Sat, Oct 6, 2012 at 4:42 PM, Mark Lawrence wrote: > Use calendar.day_name. How? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-06 Thread Richard D. Moores
On Fri, Oct 5, 2012 at 7:15 AM, Walter Prins wrote: > Does this hint help? > import datetime mydate = datetime.date(2012,10,5) mydate = mydate + datetime.timedelta(days=30) print mydate > 2012-11-04 Yes! Thanks to all for their rapid responses. But now I'm thinking it would

[Tutor] Through a glass, darkly: the datetime module

2012-10-05 Thread Richard D. Moores
I thought it would be useful to have a script that would tell me what the date n days from today would be. The docs () seem to get me almost there. I can compute the number of days between 2 dates, and the number of days between a d

Re: [Tutor] Usefulness of BIFs all() and any()?

2012-09-25 Thread Richard D. Moores
On Tue, Sep 25, 2012 at 6:41 AM, Steven D'Aprano wrote: > There are over a dozen examples of any or all in the Python standard > library. How could I have gone about finding these examples? I tried searching the docs on any and all, but found them only in the BIF section,

Re: [Tutor] Usefulness of BIFs all() and any()?

2012-09-25 Thread Richard D. Moores
Thanks for the great instruction, Tutors. I'd been working over a script of mine that factors integers. I noticed that if all the prime factors of n are the same, then if f is one of the factors and p is the number of factors, n = f ^ p. I thought of using all() or any(), but couldn't see how to d

[Tutor] Usefulness of BIFs all() and any()?

2012-09-25 Thread Richard D. Moores
I was just perusing the Built-in Functions of Python 3.2 (< http://docs.python.org/py3k/library/functions.html>) and was wondering where would one ever use any() or all(). all(iterable) Return True if all elements of the iterable are true (or if the iterable is empty). Equivalent to: def all(iter

Re: [Tutor] Problem caused by installing 2.7.3

2012-08-31 Thread Richard D. Moores
On Fri, Aug 31, 2012 at 10:57 AM, eryksun wrote: > On Fri, Aug 31, 2012 at 12:49 PM, Richard D. Moores > wrote: > https://bitbucket.org/vinay.sajip/pylauncher > https://bitbucket.org/vinay.sajip/pylauncher/raw/tip/Doc/launcher.rst Thank you! You solved my pr

[Tutor] Problem caused by installing 2.7.3

2012-08-31 Thread Richard D. Moores
MS Windows 7 Home Premium 64-bit SP1 I've been using 3.x for a long time, but the other day I thought it would also be good to have the latest version of 2.x available. So I downloaded it and installed it. I have some useful (to me) scripts that I use frequently, that I call with Windows shortcut

Re: [Tutor] Why begin a function name with an underscore

2012-08-28 Thread Richard D. Moores
On Tue, Aug 28, 2012 at 1:21 AM, Timo wrote: > Op 28-08-12 10:06, Richard D. Moores schreef: >> What if I wanted 3., 1234., etc. to be considered ints, as they are by >> _validate_int() ? > > >>>> isinstance(3., (int, float)) > True > > Because 3. is

Re: [Tutor] Why begin a function name with an underscore

2012-08-28 Thread Richard D. Moores
On Tue, Aug 28, 2012 at 12:13 AM, Jerry Zhang wrote: > > > 2012/8/28 Richard D. Moores > >> On Mon, Aug 27, 2012 at 6:33 PM, Japhy Bartlett >> wrote: >> >> > something like: >> > >> > def _validate_int(obj): >> > "&qu

Re: [Tutor] Why begin a function name with an underscore

2012-08-27 Thread Richard D. Moores
On Mon, Aug 27, 2012 at 6:33 PM, Japhy Bartlett wrote: > something like: > > def _validate_int(obj): > """Raise an exception if obj is not an integer.""" > m = int(obj + 0) # May raise TypeError. > if obj != m: > raise ValueError('expected an integer but got %r' % obj) > > >

[Tutor] Why begin a function name with an underscore

2012-08-27 Thread Richard D. Moores
I've been going through Steven D'Aprano's pyprimes () and have many questions. One is why begin a function name with an underscore. He has several functions that do this. Two are: def _validate_int(obj): """Raise an exception if obj is not an intege

Re: [Tutor] pickle problems

2012-08-24 Thread Richard D. Moores
Case Van Horsen wrote the following to me about gmpy2.is_prime. I post it with his permission. Dick Moores The summary: gmpy2.is_prime() just provides direct access to the underlying library (GMP or MPIR) function. Depending on the library and version, the behavior is subtly different. With the

Re: [Tutor] pickle problems

2012-08-23 Thread Richard D. Moores
On Wed, Aug 22, 2012 at 8:39 PM, Dave Angel wrote: > On 08/22/2012 07:32 PM, Richard D. Moores wrote: >> >> >> My code uses gmpy2.is_prime() (lines 79 and 89). is_prime() is VERY fast. > > You do know that this gmpy2 function is only statistically correct ? Yes.

Re: [Tutor] pickle problems

2012-08-22 Thread Richard D. Moores
On Wed, Aug 22, 2012 at 11:54 AM, Steven D'Aprano wrote: > On 23/08/12 02:17, Richard D. Moores wrote: >> >> I've incorporated many of the suggestions I've received here, plus some >> important tips from Case Van Horsen, the gmpy2 maintainer, and I believe one

Re: [Tutor] pickle problems

2012-08-22 Thread Richard D. Moores
I've incorporated many of the suggestions I've received here. Here's a function, factor_integer(), for quickly factoring any integer up to 1e17: . Larger integers will be factored eventually -- the wait can be long or short. Probably long if they require the services

Re: [Tutor] pickle problems

2012-08-12 Thread Richard D. Moores
On Sun, Aug 12, 2012 at 10:49 AM, eryksun wrote: > On Sun, Aug 12, 2012 at 10:58 AM, Dave Angel wrote: > Good catch in Kent Johnson's code. Maybe he'll search for his name and > find this. It should be `r = r // factor`. The fault was probably mine. Kent wrote this in 2004, in Python 2.x. When

Re: [Tutor] pickle problems

2012-08-12 Thread Richard D. Moores
On Sun, Aug 12, 2012 at 2:13 AM, Richard D. Moores wrote: . > But what > about case where factors.dat is empty? Is there a test for that? I just discovered os.path.getsize('factors.txt') and that factors.txt has a size of 2 bytes when "empty". (I changed the file ex

Re: [Tutor] pickle problems

2012-08-12 Thread Richard D. Moores
On Sun, Aug 12, 2012 at 1:00 AM, Alan Gauld wrote: > On 12/08/12 03:43, Richard D. Moores wrote: > >> === >> if "factors.dat": > > This is testing if the string is True, which it always is. > I assume you intended something like > > if os.path.

Re: [Tutor] pickle problems

2012-08-12 Thread Richard D. Moores
On Sat, Aug 11, 2012 at 9:51 PM, eryksun wrote: > On Sat, Aug 11, 2012 at 11:19 PM, Richard D. Moores > wrote: >> >>> To clarify, you can store multiple pickles in a file, but each needs >>> its own load. So you'd have to maintain a session dictionary for th

Re: [Tutor] pickle problems

2012-08-11 Thread Richard D. Moores
On Sat, Aug 11, 2012 at 6:58 PM, eryksun wrote: > On Sat, Aug 11, 2012 at 9:18 PM, eryksun wrote: >> > To clarify, you can store multiple pickles in a file, but each needs > its own load. So you'd have to maintain a session dictionary for the > factors of new integers. Then append the pickled se

Re: [Tutor] pickle problems

2012-08-11 Thread Richard D. Moores
On Sat, Aug 11, 2012 at 6:18 PM, eryksun wrote: > On Sat, Aug 11, 2012 at 6:30 PM, Richard D. Moores wrote: >> >> I wrote pickle_attempt.py as an exercise to try to learn to use the >> pickle module. See the version I edited for Tutor, >> pickle_attempt_for_web.py

[Tutor] pickle problems

2012-08-11 Thread Richard D. Moores
64-bit Win 7 Python 3.2.3 (default, Apr 11 2012, 07:12:16) [MSC v.1500 64 bit (AMD64)] I wrote pickle_attempt.py as an exercise to try to learn to use the pickle module. See the version I edited for Tutor, pickle_attempt_for_web.py at . To show the problems, I've pas

Re: [Tutor] Installing the uncertainties module

2011-10-29 Thread Richard D. Moores
On Sat, Oct 29, 2011 at 22:06, Lie Ryan wrote: > On 10/30/2011 03:55 PM, Richard D. Moores wrote: >> >> Hm. Problem: >> >>>>> import tarfile >>>>> tar = tarfile.open("C:\Users\Richard\Desktop\uncertainties-1.8.tar.gz") >> >>

Re: [Tutor] Installing the uncertainties module

2011-10-29 Thread Richard D. Moores
On Sat, Oct 29, 2011 at 21:37, Richard D. Moores wrote: > > > On Sat, Oct 29, 2011 at 18:31, Richard D. Moores wrote: >> >> The uncertainties module (<http://packages.python.org/uncertainties/>) >> is now available for 64-bit Python 3.2. I've downloaded &g

Re: [Tutor] Installing the uncertainties module

2011-10-29 Thread Richard D. Moores
On Sat, Oct 29, 2011 at 18:31, Richard D. Moores wrote: > The uncertainties module (<http://packages.python.org/uncertainties/>) > is now available for 64-bit Python 3.2. I've downloaded > uncertainties-1.8.tar.gz. I need some utility that will handle both > .gz and .tar,

[Tutor] Installing the uncertainties module

2011-10-29 Thread Richard D. Moores
The uncertainties module () is now available for 64-bit Python 3.2. I've downloaded uncertainties-1.8.tar.gz. I need some utility that will handle both .gz and .tar, I presume. Looking for recommendations. Dick Moores Python 3.2.2 64-bit Win 7 ___

Re: [Tutor] How to "refresh" the interactive prompt?

2011-10-02 Thread Richard D. Moores
On Sun, Oct 2, 2011 at 01:47, Steven D'Aprano wrote: > Richard D. Moores wrote: >> >> Python 3.2.2, Win 7 >> >> When using the Python 3 interactive prompt, is there a way to quickly >> "refresh" the prompt? By "refresh" I mean get a new

[Tutor] How to "refresh" the interactive prompt?

2011-10-01 Thread Richard D. Moores
Python 3.2.2, Win 7 When using the Python 3 interactive prompt, is there a way to quickly "refresh" the prompt? By "refresh" I mean get a new interactive prompt with nothing imported and all things like a = "qwerty", n = 123, etc. no longer in effect. Not sure what the wording should be for tha

Re: [Tutor] What's the keyword for the Python creed?

2011-09-16 Thread Richard D. Moores
On Thu, Sep 15, 2011 at 23:47, Christian Witts wrote: > from __future__ import braces Ha! (2.7 and 3.x) Dick ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What's the keyword for the Python creed?

2011-09-15 Thread Richard D. Moores
Thanks, all. Good to have that at hand. antigravity: any more? Dick ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] What's the keyword for the Python creed?

2011-09-15 Thread Richard D. Moores
You know, at the interactive prompt you enter some Monty Python word that I can't remember, and you get a small list of pithy pythonic advice such as "explicit is better than implicit", etc. Thanks, Dick Moores ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] About installing 3.2.2

2011-09-13 Thread Richard D. Moores
On Mon, Sep 12, 2011 at 23:49, Richard D. Moores wrote: > On Mon, Sep 12, 2011 at 06:48, Prasad, Ramit > wrote: >> -Original Message- >> From: tutor-bounces+ramit.prasad=jpmorgan@python.org >> [mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On

Re: [Tutor] About installing 3.2.2

2011-09-12 Thread Richard D. Moores
On Mon, Sep 12, 2011 at 06:48, Prasad, Ramit wrote: > -Original Message- > From: tutor-bounces+ramit.prasad=jpmorgan@python.org > [mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of > Richard D. Moores > Sent: Sunday, September 11, 2011 10:03 PM &

Re: [Tutor] need advice about a dictionary ({})

2011-09-12 Thread Richard D. Moores
I'm the OP. Nick Zarr, alias Jack Trades, has done something really marvelous. He's made a thorough critique and refactoring of my phone_book.py, in its last incarnation as . See . He'll be making that part of his blog (

[Tutor] Can't edit a file I've opened with open(), then closed with close()

2011-09-11 Thread Richard D. Moores
Win 7, Python 3.2.1 I'm trying to improve my skills with opening text files, reading from them, and writing to them. But while I'm doing this sometimes I want to manually modify the text file I'm using, C:\t\text.txt . Say I've done this: >>> f = open(r"C:\t\test.txt", 'r+') >>> f.read() '0\n1\n

[Tutor] About installing 3.2.2

2011-09-11 Thread Richard D. Moores
Win 7, Python 3.2.1 I had downloaded python-3.2.2.amd64.msi and started the installation when I saw the attached. Does it mean that I would lose everything in the site-packages folder? Is this something even the Python newbie is supposed to know? Thanks, Dick Moores <>___

Re: [Tutor] need advice about a dictionary ({})

2011-09-10 Thread Richard D. Moores
On Sat, Sep 10, 2011 at 15:15, Jack Trades wrote: > On Sat, Sep 10, 2011 at 4:36 PM, Richard D. Moores > wrote: >> >> Your idea doesn't seem efficient for me -- >> lots of typing and editing. > > Not sure what you mean by that?  I've updated the gist wit

Re: [Tutor] need advice about a dictionary ({})

2011-09-10 Thread Richard D. Moores
On Sat, Sep 10, 2011 at 17:34, Alan Gauld wrote: > On 11/09/11 00:18, Richard D. Moores wrote: > >>> So you open the file and from that point on treat it exactly like a >>> dictionary. >> >> I'm still a bit shaky about dictionaries. > > But you start

Re: [Tutor] need advice about a dictionary ({})

2011-09-10 Thread Richard D. Moores
On Sat, Sep 10, 2011 at 17:34, Marc Tompkins wrote: > On Sat, Sep 10, 2011 at 4:18 PM, Richard D. Moores > wrote: >> >> On Sat, Sep 10, 2011 at 15:32, Alan Gauld >> wrote: >> >> > So you open the file and from that point on treat it exactly like a >&

Re: [Tutor] need advice about a dictionary ({})

2011-09-10 Thread Richard D. Moores
On Sat, Sep 10, 2011 at 15:32, Alan Gauld wrote: > On 10/09/11 19:08, Richard D. Moores wrote: > >> Some have suggested using the shelve module. I looked at it but >> couldn't see in detail how to use it. > > Did you read the help page? I did. I can see it would

Re: [Tutor] need advice about a dictionary ({})

2011-09-10 Thread Richard D. Moores
Jack Trades (actually Nick Zarczynski) just sent me this link to a "Simple phone book app", and has agreed to let me post it to this thread: Dick ___ Tutor maillist - Tutor@python.org To unsubscribe or cha

Re: [Tutor] need advice about a dictionary ({})

2011-09-10 Thread Richard D. Moores
Thanks so much, Jack. You've given me much to chew on. I began phone_book.py without much need for it -- I already had an RTF file with 786 lines that I "grepped" using a script I wrote with Tutor help long ago. I used an RTF file instead of a text file so that any URLs in it would be live. But I

Re: [Tutor] need advice about a dictionary ({})

2011-09-10 Thread Richard D. Moores
Thanks so much, Jack. You've given me much to chew on. I began phone_book.py without much need for it -- I already had an RTF file with 786 lines that I "grepped" using a script I wrote with Tutor help long ago. I used an RTF file instead of a text file so that any URLs in it would be live. But I

Re: [Tutor] need advice about a dictionary ({})

2011-09-10 Thread Richard D. Moores
So I've done quite a bit more work. With phone_book.py the user can not only access phone numbers by the person's initials, but can add items to the data file. I've also solved the problem of adding a person who's initials have already been used in a key. I've pasted phone_book_for_pasting.py at <

Re: [Tutor] need advice about a dictionary ({})

2011-09-08 Thread Richard D. Moores
On Thu, Sep 8, 2011 at 04:43, Peter Otten <__pete...@web.de> wrote: > Richard D. Moores wrote: > >> I've succeeded in writing a dictionary ({}) that I can use as a small >> personal phone book. The dictionary (very shortened and simplified) >> looks like this

Re: [Tutor] need advice about a dictionary ({})

2011-09-08 Thread Richard D. Moores
On Thu, Sep 8, 2011 at 04:43, Peter Otten <__pete...@web.de> wrote: > Richard D. Moores wrote: > >> I've succeeded in writing a dictionary ({}) that I can use as a small >> personal phone book. The dictionary (very shortened and simplified) >> looks like this

Re: [Tutor] need advice about a dictionary ({})

2011-09-08 Thread Richard D. Moores
On Thu, Sep 8, 2011 at 04:36, Christian Witts wrote: > On 2011/09/08 12:58 PM, Richard D. Moores wrote: > > I've succeeded in writing a dictionary ({}) that I can use as a small > personal phone book. The dictionary (very shortened and simplified) > looks like this in the scri

[Tutor] need advice about a dictionary ({})

2011-09-08 Thread Richard D. Moores
I've succeeded in writing a dictionary ({}) that I can use as a small personal phone book. The dictionary (very shortened and simplified) looks like this in the script; p = {} p['bp1'] = 'xxx' p['bp2'] = 'ooo' p['ch'] = 'zzz' p['me'] = 'aaa' p['mg'] = 'vvv' p['pu1'] = 'bbb' p['pu2'] = 'ccc' p['pw

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
On Thu, Sep 1, 2011 at 18:08, Steven D'Aprano wrote: > Richard D. Moores wrote: >> >> I'm trying to write a general test for hashability. How can I test if >> an object has both a  __hash__() method and an __eq__() method? > > > Just because an object

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
Ah. I'll follow you with that. Thanks, Dick On Thu, Sep 1, 2011 at 15:42, Chris Fuller wrote: > On Thursday 01 September 2011, Richard D. Moores wrote: >> On Thu, Sep 1, 2011 at 12:29, Chris Fuller >> >> wrote: >> > *Ahem* >> > >> > def is_

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
On Thu, Sep 1, 2011 at 12:29, Chris Fuller wrote: > *Ahem* > > def is_hashable(object): >   try: >        hash(object) >    except TypeError: >        return False > >    return True Why is that preferred to def is_hashable(object): try: hash(object) return True except

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
def is_hashable(object): try: hash(object) return True except TypeError: return False it is then. Thanks to all! Dick ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pyth

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
Thanks, James, from your ideas I've come up with this function as a general test for hashibility of any object: def is_hashable(object): try: if hash(object): return True except TypeError: return False But is it? It returns True for ints, floats, sets, tuples,

[Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
The glossary defines "hashable" as: hashable An object is hashable if it has a hash value which never changes during its lifetime (it needs a __hash__() method), and can be compared to other objects (it needs an __eq__() method). Hashable objects which compare equal must have the same hash value.

Re: [Tutor] program code for Python Programming for the Absolute Beginner, 3rd ed.?

2011-08-29 Thread Richard D. Moores
On Mon, Aug 29, 2011 at 00:19, TheIrda wrote: > on the left check the Programming, networking and security and look for your > book. > Click download and you can see the link to the source code and book related > software > > http://www.delmarlearning.com/companions/content/1435455002/downloads/in

[Tutor] program code for Python Programming for the Absolute Beginner, 3rd ed.?

2011-08-28 Thread Richard D. Moores
The book says the program code is in py3e_source.zip, at www.courseptr.com/downloads , but that leads to the book at with a "View Available Downloads" link that yields no downloads. Does anyone know where py3e_source.zip is? Or

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
On Wed, Aug 3, 2011 at 12:10, Peter Otten <__pete...@web.de> wrote: > Richard D. Moores wrote: > >> On Wed, Aug 3, 2011 at 10:11, Peter Otten <__pete...@web.de> wrote: >>> Richard D. Moores wrote: >>> >>>> I wrote before that I had pasted the f

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
On Wed, Aug 3, 2011 at 12:16, Steven D'Aprano wrote: > Richard D. Moores wrote: >> >> I wrote before that I had pasted the function (convertPath()) from my >> initial post into mycalc.py because I had accidentally deleted it from >> mycalc.py. And that there

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
On Wed, Aug 3, 2011 at 10:11, Peter Otten <__pete...@web.de> wrote: > Richard D. Moores wrote: > >> I wrote before that I had pasted the function (convertPath()) from my >> initial post into mycalc.py because I had accidentally deleted it from >> mycalc.py. And that

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
I wrote before that I had pasted the function (convertPath()) from my initial post into mycalc.py because I had accidentally deleted it from mycalc.py. And that there was no problem importing it from mycalc. Well, I was mistaken (for a reason too tedious to go into). There WAS a problem, the same o

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
Ops! I accidentally erased convertPath() from mycalc.py while trying out various things. It was my only copy of convertPath that had the docstring as posted, so I went to my initial post and copy-and-pasted it into mycalc.py. Now no problem: from Wing's shell: Python 3.2.1 (default, Jul 10 2

Re: [Tutor] Puzzled again

2011-08-02 Thread Richard D. Moores
On Tue, Aug 2, 2011 at 21:59, Dave Angel wrote: > When I paste that from your email into a file and run Python 2.7 on it, it > behaves fine with no errors.  That's in Linux. I should have said that I'm using Wing IDE Professional 4.0.3-1 (rev 24721), Windows Vista, and Python 3.2.1. > But the e

[Tutor] Puzzled again

2011-08-02 Thread Richard D. Moores
Puzzled again. Why the error. Line 36 is the line just above "import os.path". I have many other functions in mycalc.py with examples formatted exactly the same way. def convertPath(path):     """     Given a path with backslashes, return that path with forward slashes.     By Steven D'Aprano  07

Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Richard D. Moores
On Sun, Jul 31, 2011 at 10:34, Peter Otten <__pete...@web.de> wrote: > > Richard D. Moores wrote: > > >> What happens if the path looks like > >> > >> r"C:relative\path\to\my\file.txt" > >> > >> or > >> > >>

Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Richard D. Moores
On Sun, Jul 31, 2011 at 08:59, Sergey wrote: > Gotcha! > http://pymon.googlecode.com/svn/tags/pymon-0.2/Internet/rsync.py > 231-239 strings > > ## code ## > > def convertPath(path): >        # Convert windows, mac path to unix version. >        separator = os.path.normpath("/") >        if separat

Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Richard D. Moores
On Sun, Jul 31, 2011 at 03:34, Peter Otten <__pete...@web.de> wrote: > Sandip Bhattacharya wrote: > >> On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote: >>> File "c:\P32Working\untitled-5.py&quo

Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Richard D. Moores
On Sun, Jul 31, 2011 at 03:34, Peter Otten <__pete...@web.de> wrote: > > Sandip Bhattacharya wrote: > > > On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote: > >> File "c:\P32Working\untitled-5.py&q

Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Richard D. Moores
On Sat, Jul 30, 2011 at 23:32, Sandip Bhattacharya wrote: > > On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote: > > File "c:\P32Working\untitled-5.py", line 2 > >    return path.replace('\', '/') > >                      

[Tutor] How to replace the '\'s in a path with '/'s?

2011-07-30 Thread Richard D. Moores
64-bit Vista Python 3.2.1 I would like to write a function that would take a path such as 'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf' and return 'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' . I've tried this: def test(path): return path.replace('\', '/') print(test(

Re: [Tutor] Is the Python 3.2.1 documentation available as a .chm file?

2011-07-21 Thread Richard D. Moores
On Thu, Jul 21, 2011 at 04:59, Michael M Mason wrote: > Richard D. Moores wrote on 20 July 2011 at 18:11 >> On Wed, Jul 20, 2011 at 09:04, xDog Walker wrote: >> > On Wednesday 2011 July 20 06:41, Richard D. Moores wrote: >> > > Is the Python 3.2.1 documentation

Re: [Tutor] Is the Python 3.2.1 documentation available as a .chm file?

2011-07-20 Thread Richard D. Moores
On Wed, Jul 20, 2011 at 09:04, xDog Walker wrote: > On Wednesday 2011 July 20 06:41, Richard D. Moores wrote: >> Is the Python 3.2.1 documentation available as a .chm file from Python.org? >> > > http://www.python.org/ftp/python/3.2.1/python321.chm Did that work for you?

Re: [Tutor] Is the Python 3.2.1 documentation available as a .chm file?

2011-07-20 Thread Richard D. Moores
On Wed, Jul 20, 2011 at 07:28, Walter Prins wrote: > > > On 20 July 2011 15:06, Richard D. Moores wrote: >> >> On Wed, Jul 20, 2011 at 06:58, Flynn, Stephen (L & P - IT) >> wrote: >> > Saying that, there's nothing stopping you from taking the html ve

Re: [Tutor] Is the Python 3.2.1 documentation available as a .chm file?

2011-07-20 Thread Richard D. Moores
On Wed, Jul 20, 2011 at 06:58, Flynn, Stephen (L & P - IT) wrote: > Saying that, there's nothing stopping you from taking the html version > and compiling your own chm from it. Pretty easy to do. Great! But how? Dick ___ Tutor maillist - Tutor@python

[Tutor] Is the Python 3.2.1 documentation available as a .chm file?

2011-07-20 Thread Richard D. Moores
Is the Python 3.2.1 documentation available as a .chm file from Python.org? Thanks, Dick Moores ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Hello World in Python without space

2011-07-15 Thread Richard D. Moores
On Fri, Jul 15, 2011 at 21:38, Steven D'Aprano wrote: > > Richard D. Moores wrote: > >> But that makes me wonder if there isn't a simpler way to do it with >> Python -- to delete the contents of a file without deleting the file? > > Opening a file for writ

Re: [Tutor] Hello World in Python without space

2011-07-15 Thread Richard D. Moores
On Fri, Jul 15, 2011 at 17:16, Dave Angel wrote: > On 07/15/2011 07:39 PM, Richard D. Moores wrote: >> with open("C:/test/test.txt", "a") as file_object: >>      print("Hello, world!", file=file_object) >> >> Yes, that works for me with Wi

Re: [Tutor] Hello World in Python without space

2011-07-15 Thread Richard D. Moores
On Fri, Jul 15, 2011 at 16:21, xDog Walker wrote: > I believe on Windows, you can almost always use a forward slash in a path: > C:/somewhere/somewhereelse/ with open("C:/test/test.txt", "a") as file_object: print("Hello, world!", file=file_object) Yes, that works for me with Windows Vista

Re: [Tutor] Hello World in Python without space

2011-07-15 Thread Richard D. Moores
On Fri, Jul 15, 2011 at 14:47, Stefan Behnel wrote: > Richard D. Moores, 15.07.2011 23:21: >> What do I do to test.txt to make it "an object with a write(string) >> method"? > > Oh, there are countless ways to do that, e.g. > >  class Writable(object)

Re: [Tutor] Hello World in Python without space

2011-07-15 Thread Richard D. Moores
On Sun, Jul 10, 2011 at 05:05, Peter Otten <__pete...@web.de> wrote: > >>> help(print) > > shows > > print(...) >    print(value, ..., sep=' ', end='\n', file=sys.stdout) > >    Prints the values to a stream, or to sys.stdout by default. >    Optional keyword arguments: >    file: a file-like obje

Re: [Tutor] Python3 Tutorial question about a[:] = []

2011-02-16 Thread Richard D. Moores
On Wed, Feb 16, 2011 at 09:50, Brett Ritter wrote: > On Wed, Feb 16, 2011 at 12:39 PM, Richard D. Moores > wrote: >> from <http://docs.python.org/py3k/tutorial/introduction.html#lists> : >> >>>>> # Clear the list: replace all items with an empty list &

[Tutor] Python3 Tutorial question about a[:] = []

2011-02-16 Thread Richard D. Moores
from : >>> # Clear the list: replace all items with an empty list >>> a[:] = [] >>> a [] I've been using >>> a = [] >>> a [] What's the difference? Thanks, Dick Moores ___ Tutor maillist

[Tutor] mpmath now supports Python 3!

2011-02-06 Thread Richard D. Moores
Dick Moores ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] decimal module and precision

2011-02-01 Thread Richard D. Moores
On Tue, Feb 1, 2011 at 04:29, col speed wrote: > > You can always change the precision in decimal. Just an idea Not exactly sure what you mean. But I just tried using decimal to get 123.2345274523452345235432452345 ** 2.3 to 300 digits: >>> from decimal import Decimal as D >>> import decimal

  1   2   3   4   >