Re: [Tutor] [Python-ideas] import imports

2009-01-27 Thread spir
Le Mon, 26 Jan 2009 22:38:24 -, "Alan Gauld" a écrit : > "spir" wrote > > > Here are some ideas around import. I wish to receive comments > > > The module attribute __all__ allows defining names to be exported. > > I always use it for my own modules, and also sometimes define it in > > ext

Re: [Tutor] [Python-ideas] import imports

2009-01-27 Thread Alan Gauld
"spir" wrote "Secure import" means that I, as client of the imported module, know that this module defines __all__. I can then safely import all. I still don;t agree that simply defining __all__ means you can "safely" import all. all restricts what the module exposes it does nothing to pre

Re: [Tutor] [Python-ideas] import imports

2009-01-27 Thread A.T.Hofkamp
Hai Denis, spir wrote: "Secure import" means that I, as client of the imported module, know that this module defines __all__. I can then safely import all. I can even precisely know which names are defined simply by reading __all__. The common practice of defining __all__ on top of a module hel

Re: [Tutor] import site failed (WinXP)

2009-01-27 Thread Kent Johnson
On Tue, Jan 27, 2009 at 12:34 AM, Alexei Vinidiktov wrote: > Hello, > > Since yesterday I've been having problems running Python. I've been > getting the error "import site failed; use -v for traceback". IDLE > won't start either. > > The traceback seems to sugget that Python "cannot import name a

Re: [Tutor] using a for loop with feedparser

2009-01-27 Thread Tonu Mikk
Kent, you are absolutely correct. I did not need the line number 5 at all. This was my first program that addressed a "real life" scenario. I am excited that it worked. Thank you, Tonu Kent Johnson wrote: On Mon, Jan 26, 2009 at 4:53 PM, Tonu Mikk wrote: I now have a new question re

Re: [Tutor] import site failed (WinXP)

2009-01-27 Thread Kent Johnson
On Tue, Jan 27, 2009 at 11:24 AM, Alexei Vinidiktov wrote: > 2009/1/27 Kent Johnson : >> My best guess is that somehow Python is finding the wrong >> encodings\aliases.py. > > I can't find an aliases.py file within the encodings folder. Should it be > there? Yes, you should have a file C:\Pytho

[Tutor] Fwd: import site failed (WinXP)

2009-01-27 Thread Kent Johnson
Forwarding to the list -- Forwarded message -- From: Alexei Vinidiktov Date: Tue, Jan 27, 2009 at 11:24 AM Subject: Re: [Tutor] import site failed (WinXP) To: Kent Johnson 2009/1/27 Kent Johnson : > On Tue, Jan 27, 2009 at 12:34 AM, Alexei Vinidiktov > wrote: >> Hello, >> >>

Re: [Tutor] import site failed (WinXP)

2009-01-27 Thread Alexei Vinidiktov
2009/1/27 Kent Johnson : > On Tue, Jan 27, 2009 at 11:24 AM, Alexei Vinidiktov > wrote: >> 2009/1/27 Kent Johnson : > >>> My best guess is that somehow Python is finding the wrong >>> encodings\aliases.py. >> >> I can't find an aliases.py file within the encodings folder. Should it be >> there? >

Re: [Tutor] import site failed (WinXP)

2009-01-27 Thread Kent Johnson
On Tue, Jan 27, 2009 at 11:43 AM, Alexei Vinidiktov wrote: > 2009/1/27 Kent Johnson : >> On Tue, Jan 27, 2009 at 11:24 AM, Alexei Vinidiktov >> wrote: >>> 2009/1/27 Kent Johnson : >> My best guess is that somehow Python is finding the wrong encodings\aliases.py. >>> >>> I can't find an

Re: [Tutor] Python Program: Newton's Method

2009-01-27 Thread bob gailer
I neglected to mention that we'd like you to always reply-all so a copy goes to the list. All of us participate and learn. Donna Ibarra wrote: The numbers that are outputted are not exactly correct as they should be for Newtons Method: OK - thanks - now please give us a few sample numbers, th

Re: [Tutor] import site failed (WinXP)

2009-01-27 Thread Alexei Vinidiktov
2009/1/28 Kent Johnson : > On Tue, Jan 27, 2009 at 11:43 AM, Alexei Vinidiktov > wrote: >> 2009/1/27 Kent Johnson : >>> On Tue, Jan 27, 2009 at 11:24 AM, Alexei Vinidiktov >>> wrote: 2009/1/27 Kent Johnson : >>> > My best guess is that somehow Python is finding the wrong > encodings\

Re: [Tutor] import site failed (WinXP)

2009-01-27 Thread Alan Gauld
"Alexei Vinidiktov" wrote I've conducted another experiment. I created several text files with a Notepad that contained text 'alia' in their names and none of them were visible after I had saved them to the disc. Now that is strange! Does "alia" mean something in your local language (assumi

Re: [Tutor] import site failed (WinXP)

2009-01-27 Thread Alexei Vinidiktov
2009/1/28 Alan Gauld : > > "Alexei Vinidiktov" wrote > >> I've conducted another experiment. I created several text files with a >> Notepad that contained text 'alia' in their names and none of them >> were visible after I had saved them to the disc. > > Now that is strange! Does "alia" mean somet

Re: [Tutor] Possible to search text file for multiple string values at once?

2009-01-27 Thread Scott Stueben
As I think more about how to best do this, I wonder if/how python script would import File A with search values, File B to be searched, and write each full line containing any of those results to File C. The code could be set to look for the same input file (A, with the search values), and the same

Re: [Tutor] Possible to search text file for multiple string valuesat once?

2009-01-27 Thread Alan Gauld
"Scott Stueben" wrote As I think more about how to best do this, I wonder if/how python script would import File A with search values, File B to be searched, and write each full line containing any of those results to File C. The code could be set to look for the same input file (A, with the

[Tutor] operator, mult

2009-01-27 Thread col speed
Hello there, I got the following function while googling: def totient(n): """calculate Euler's totient function. If [[p_0,m_0], [p_1,m_1], ... ] is a prime factorization of 'n', then the totient function phi(n) is given by: (p_0 - 1)*p_0**(m_0-1) * (p_1 - 1)*p_1**(m_1-1) * .

Re: [Tutor] operator, mult

2009-01-27 Thread John Fouhy
2009/1/28 col speed : > Hello there, > I got the following function while googling: > > def totient(n): > """calculate Euler's totient function. > > If [[p_0,m_0], [p_1,m_1], ... ] is a prime factorization of 'n', > then the totient function phi(n) is given by: > > (p_0 - 1)*p_

Re: [Tutor] operator, mult

2009-01-27 Thread col speed
That's what I thought , but I tried it to no avail. Plus the syntax is wrong. Thanks anyway Colin 2009/1/28 John Fouhy > 2009/1/28 col speed : > > Hello there, > > I got the following function while googling: > > > > def totient(n): > > """calculate Euler's totient function. > > > > If

Re: [Tutor] import site failed (WinXP) (Solved)

2009-01-27 Thread Alexei Vinidiktov
2009/1/28 Alexei Vinidiktov : > 2009/1/28 Alan Gauld : >> >> "Alexei Vinidiktov" wrote >> >>> I've conducted another experiment. I created several text files with a >>> Notepad that contained text 'alia' in their names and none of them >>> were visible after I had saved them to the disc. >> >> Now