Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-08 Thread Dick Moores
At 06:32 PM 1/7/2007, Terry Carroll wrote:
>I may add this algorithm to the cookbook.

You should.

Dick




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] import glob.glob('*.py')

2007-01-08 Thread János Juhász
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 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] import glob.glob('*.py')

2007-01-08 Thread Kent Johnson
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

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Apologies...

2007-01-08 Thread Tim Golden
... 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
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] 'root' dir of a package from within the package ?

2007-01-08 Thread Dave S
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
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] is gotchas?

2007-01-08 Thread Hugo González Monteverde

>   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

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor