[Tutor] Tutor Digest, Vol 35, Issue 27

raghu raghu vgvr620034 at gmail.com
Tue Jan 9 13:46:02 CET 2007


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, tutor-request at python.org <tutor-request at python.org> wrote:
>
> Send Tutor mailing list submissions to
>         tutor at 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
>         tutor-request at python.org
>
> You can reach the person managing the list at
>         tutor-owner at python.org
>
> 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 <rdm at rcblue.com>
> Subject: Re: [Tutor] Need help with rewriting script to use Decimal
>         module
> To: Terry Carroll <carroll at tjc.com>, tutor at python.org
> Message-ID: <7.0.1.0.2.20070108030915.06936058 at rcblue.com>
> 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 <janos.juhasz at VELUX.com>
> Subject: [Tutor] import glob.glob('*.py')
> To: tutor at python.org
> Message-ID:
>         <
> OF92E1CB82.D1735DF2-ONC125725D.0046431C-C125725D.004713FE at velux.com>
> 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 <kent37 at tds.net>
> Subject: Re: [Tutor] import glob.glob('*.py')
> To: J?nos Juh?sz <janos.juhasz at VELUX.com>
> Cc: tutor at python.org
> Message-ID: <45A24962.3030604 at tds.net>
> 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 <mail at timgolden.me.uk>
> Subject: [Tutor] Apologies...
> To: tutor at python.org
> Message-ID: <45A27614.6020006 at timgolden.me.uk>
> 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 <pythontut at pusspaws.net>
> Subject: [Tutor] 'root' dir of a package from within the package ?
> To: Python Tutor <tutor at python.org>
> Message-ID: <200701081924.38050.pythontut at pusspaws.net>
> 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 <hugonz-lists at h-lab.net>
> Subject: Re: [Tutor] is gotchas?
> To: tutor at python.org
> Message-ID: <45A335F8.2050106 at h-lab.net>
> 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 <klappnase at freenet.de>
> Subject: Re: [Tutor] 'root' dir of a package from within the package ?
> To: pythontut at pusspaws.net
> Cc: tutor at python.org
> Message-ID: <20070109115510.78172072.klappnase at freenet.de>
> Content-Type: text/plain; charset=US-ASCII
>
> On Mon, 8 Jan 2007 19:24:37 +0000
> Dave S <pythontut at pusspaws.net> 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 at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> End of Tutor Digest, Vol 35, Issue 27
> *************************************
>



-- 

                                           Vanam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070109/62946071/attachment.html 


More information about the Tutor mailing list