i have a clarification regarding built in function,in some scripts it is being used and it is give n: if _name_ == '_main_' why this is being used in the scripts?
On 1/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Send Tutor mailing list submissions to tutor@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/tutor or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of Tutor digest..." Today's Topics: 1. Re: Need help with rewriting script to use Decimal module (Dick Moores) 2. import glob.glob('*.py') (J?nos Juh?sz) 3. Re: import glob.glob('*.py') (Kent Johnson) 4. Apologies... (Tim Golden) 5. 'root' dir of a package from within the package ? (Dave S) 6. Re: is gotchas? (Hugo Gonz?lez Monteverde) 7. Re: 'root' dir of a package from within the package ? (Michael Lange) ---------------------------------------------------------------------- Message: 1 Date: Mon, 08 Jan 2007 04:20:24 -0800 From: Dick Moores <[EMAIL PROTECTED]> Subject: Re: [Tutor] Need help with rewriting script to use Decimal module To: Terry Carroll <[EMAIL PROTECTED]>, tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="us-ascii"; format=flowed At 06:32 PM 1/7/2007, Terry Carroll wrote: >I may add this algorithm to the cookbook. You should. Dick ------------------------------ Message: 2 Date: Mon, 8 Jan 2007 13:56:23 +0100 From: J?nos Juh?sz <[EMAIL PROTECTED]> Subject: [Tutor] import glob.glob('*.py') To: tutor@python.org Message-ID: < [EMAIL PROTECTED]> Content-Type: text/plain; charset="US-ASCII" Hi All, I am playing with reportlab and I would like to make a directory where I can place all of my projects as ___.py files. A project file should be like this: test.py-------- title="Test project" duedate = '2007-02-28' description = "description _________" detailed=""" detaileddetaileddetaileddetaileddetaileddetaileddetailed detaileddetaileddetaileddetaileddetaileddetaileddetailed detaileddetaileddetaileddetaileddetaileddetaileddetailed detaileddetaileddetaileddetaileddetaileddetaileddetailed detaileddetaileddetaileddetaileddetaileddetaileddetailed """ test.py-------- I plan to make a python script, that collect all the projectfiles from that folder and render them as a report summary. I planned to import these files as modules like for filename in glob.glob('*.py'): if '_' in filename: continue import filename render(filename) Probably you have better ideas to do that. Yours sincerely, ______________________________ Janos Juhasz ------------------------------ Message: 3 Date: Mon, 08 Jan 2007 08:38:42 -0500 From: Kent Johnson <[EMAIL PROTECTED]> Subject: Re: [Tutor] import glob.glob('*.py') To: J?nos Juh?sz <[EMAIL PROTECTED]> Cc: tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed J?nos Juh?sz wrote: > I plan to make a python script, that collect all the projectfiles from > that folder and render them as a report summary. > I planned to import these files as modules like > > for filename in glob.glob('*.py'): > if '_' in filename: continue > import filename > render(filename) This won't work, the import statement does not take a variable as an argument. You need something like module = __import__(filename) render(module) You will want to take care that your modules don't have any side effects on import. > > Probably you have better ideas to do that. You might want to look at the existing Python document generation tools. There is a summary here (be sure to read the comments and the original post just below this one): http://www.voidspace.org.uk/python/weblog/arch_d7_2006_12_30.shtml#e599 In particular PythonDoc supports structured comments that are similar to what you outlined and has pluggable output generators that could be used to drive ReportLab. Kent ------------------------------ Message: 4 Date: Mon, 08 Jan 2007 16:49:24 +0000 From: Tim Golden <[EMAIL PROTECTED]> Subject: [Tutor] Apologies... To: tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed ... my many apologies to the readers of the tutor list. I went away for a week without suspending delivery just as my company changed name - and decided to send an irritating response to anything directed at the old name. The list admin has very properly unsubscribed the old address (otherwise you'd be seeing loads more of the things!). Sorry again. Hope it didn't spoil your new year. TJG ------------------------------ Message: 5 Date: Mon, 8 Jan 2007 19:24:37 +0000 From: Dave S <[EMAIL PROTECTED]> Subject: [Tutor] 'root' dir of a package from within the package ? To: Python Tutor <tutor@python.org> Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="us-ascii" Hi all, I have written a python package, which works fine, the 'root' directory is 'my_app' with sub directories within in, complete with there __init__.py files. I need to work out the path to the root directory from within the app, os.path gives me pythons path! - oh and its in XP. Any suggestions ? Dave ------------------------------ Message: 6 Date: Tue, 09 Jan 2007 00:28:08 -0600 From: Hugo Gonz?lez Monteverde <[EMAIL PROTECTED]> Subject: Re: [Tutor] is gotchas? To: tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed > Hmmm! Hmmm! > Lookee here: > ## console session > >>> a=[1,2] > >>> b=[1,2] > >>> a is b > False > >>> c='1' ## one byte > >>> d='1' ## one byte > >>> c is d > True > >>> c='1,2' > >>> d='1,2' > >>> c is d > False > > The Hmmm! is emmitted because I'm thinking that if everything is an > object in python, then why does `c is d` evaluate to True when > the assigned value is 1 byte and evaluate to False when the assigned > value is more that 1 byte? One and two byte strings are currently optimized in cPython as the same object, referenced multiple times. Note that this is not to be relied upon! Jython, Ironpython, Python3000 or cPython itself may break it! Still cannot find a reference doc for this.... Hugo ------------------------------ Message: 7 Date: Tue, 9 Jan 2007 11:55:10 +0100 From: Michael Lange <[EMAIL PROTECTED]> Subject: Re: [Tutor] 'root' dir of a package from within the package ? To: [EMAIL PROTECTED] Cc: tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=US-ASCII On Mon, 8 Jan 2007 19:24:37 +0000 Dave S <[EMAIL PROTECTED]> wrote: > Hi all, > > I have written a python package, which works fine, the 'root' directory > is 'my_app' with sub directories within in, complete with there __init__.py > files. > > I need to work out the path to the root directory from within the app, os.path > gives me pythons path! - oh and its in XP. > > Any suggestions ? > Hi Dave, app_root = os.path.abspath(sys.path[0]) or, within the main executable .py file, app_root = os.path.abspath(os.path.dirname(__file__)) should do the trick. I hope this helps Michael ------------------------------ _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor End of Tutor Digest, Vol 35, Issue 27 *************************************
-- Vanam
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor