Re: BeautifulSoup

2005-08-19 Thread Paul McGuire
Mike -

Thanks for asking.  Typically I hang back from these discussions of
parsing HTML or XML (*especially* XML), since there are already a
number of parsers out there that can handle the full language syntax.
But it seems that many people trying to parse HTML aren't interested in
fully parsing an HTML page, so much as they are trying to match some
tag pattern, to extract or modify the embedded data.  In these cases,
fully comprehending HTML syntax is rarely required.

In this particular instance, the OP had started another thread in which
he was trying to extract some HTML content using regexp's, and this
didn't seem to be converging to a workable solution.  When he finally
revealed that what he was trying to do was extract and modify the URL's
in a web pages HTML source, this seemed like a tractable problem for a
quick pyparsing program.  In the interests of keeping things simple, I
admittedly provided a limited solution.  As you mentioned, no
additional attributes are handled by this code.  But many HTML scrapers
are able to make simplifying assumptions about what HTML features can
be expected, and I did not want to spend a lot of time solving problems
that may never come up.

So you asked some good questions, let me try to give some reasonable
answers, or at least responses:

1. "If it were in the ports tree, I'd have grabbed it and tried it
myself."
By "ports tree", I assume you mean some directory of your Linux
distribution.  I'm sure my Linux ignorance is showing here, most of my
work occurs on Windows systems.  I've had pyparsing available on SF for
over a year and a half, and I do know that it has been incorporated (by
others) into a couple of Linux distros, including Debian, ubuntu,
gentoo, and Fedora.  If you are interested in doing a port to another
Linux, that would be great!  But I was hoping that hosting pyparsing on
SF would be easy enough for most people to be able to get at it.

2. "How well does it deal with other attributes in front of the href,
like ?"
*This* version doesn't deal with other attributes at all, in the
interests of simplicity.  However, pyparsing includes a helper method,
makeHTMLTags(), that *does* support arbitrary attributes within an
opening HTML tag.  It is called like:

anchorStart,anchorEnd = makeHTMLTags("A")

makeHTMLTags returns a pyparsing subexpression that *does* comprehend
attributes, as well as opening tags that include their own closing '/'
(indicating an empty tag body).  Tag attributes are accessible by name
in the returned results tokens, without requiring setResultsName()
calls (as in the example).

3. "How about if my HTML has things that look like HTML in attributes,
like ?"
Well, again, the simple example wont be able to tell the difference,
and it would process the ATTRIBUTE string as a real tag.  To address
this, we would expand our statement to process quoted strings
explicitly, and separately from the htmlAnchor, as in:

htmlPatterns = quotedString | htmlAnchor

and then use htmlPatterns for the transformString call:

htmlPatterns.transformString( inputHTML )

You didn't ask, but one feature that is easy to handle is comments.
pyparsing includes some common comment syntaxes, such as cStyleComment
and htmlComment.  To ignore them, one simply calls ignore() on the root
pyparsing node. In the simple example, this would look like:

htmlPatterns.ignore( htmlComment )

By adding this single statement, all HTML comments would be ignored.


Writing a full HTML parser with pyparsing would be tedious, and not a
great way to spend your time, given the availability of other parsing
tools.  But for simple scraping and extracting, it can be a very
efficient way to go.

-- Paul

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Version of TAR in tarfile module? TAR 1.14 or 1.15 port to Windows?

2005-08-19 Thread Martin v. Löwis
Claudio Grondi wrote:
> What TAR version is built into the tarfile module?

None: the tarfile module is not built on top of
GNU tar. Instead, it is a complete reimplementation.

> Is there a TAR 1.14 or 1.15 port to Windows
> available in Internet for download (which URL)?

http://sources.redhat.com/cygwin/

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Well, another try Re: while c = f.read(1)

2005-08-19 Thread Robert Kern
James wrote:
>>for data in iter(lambda:f.read(1024), ''):
>>for c in data:
> 
> What are the meanings of Commands 'iter' and 'lambda', respectively? I
> do not want you to indicate merely the related help pages. Just your
> ituitive and short explanations would be enough since I'm really newbie
> to Python.

No sorry, that's not how the newsgroup works. You read the documentation 
first, then come back with specific questions about what you didn't 
understand or couldn't find.

http://www.catb.org/~esr/faqs/smart-questions.html

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Well, another try Re: while c = f.read(1)

2005-08-19 Thread James
> for data in iter(lambda:f.read(1024), ''):
> for c in data:

What are the meanings of Commands 'iter' and 'lambda', respectively? I
do not want you to indicate merely the related help pages. Just your
ituitive and short explanations would be enough since I'm really newbie
to Python.

-James

-- 
http://mail.python.org/mailman/listinfo/python-list


Well, another try Re: while c = f.read(1)

2005-08-19 Thread en.karpachov
On 18 Aug 2005 22:21:53 -0700
Greg McIntyre wrote:

>   f = open("blah.txt", "r")
>   while True:
>   c = f.read(1)
>   if c == '': break # EOF
>   # ... work on c
> 
> Is some way to make this code more compact and simple? It's a bit
> spaghetti.
> 
> This is what I would ideally like:
> 
>   f = open("blah.txt", "r")
>   while c = f.read(1):
>   # ... work on c

for data in iter(lambda:f.read(1024), ''):
 for c in data:
  # ... work on c

-- 
jk
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Binary Distribution of pyMinGW-241

2005-08-19 Thread A.B., Khalid
This is to inform those interested in Python and MinGW that a binary
distribution of pyMinGW-241 is now available. This is mainly a
packaging of the March release in binary form for those who are finding
it difficult to build Python or its standard extensions in MinGW.


WHAT'S INSIDE
-
- pyMinGW-License
- pyMinGW-Readme
- Python-License
- python.exe
- python24.dll
- pythonw.exe
- w9xpopen.exe
- python_icon.exe
+ Dlls:
  - tcl84.dll
  - tclpip84.dll
  - tk84.dll
  - zlib.pyd
  - _bsddb.pyd
  - _socket.pyd (Without IPv6 support, as MinGW still lacks it)
  - _ssl.pyd
  - _testcapi.pyd
  - _tkinter.pyd
  - bz2.pyd
  - pyexpat.pyd
  - select.pyd
  - unicodedata.pyd
  - winsound.pyd
+ Include:
  pyconfig.h
+ Lib:
  + distutils
+ command
  - build_ext.py
- ccompiler.py
- cygwinccompiler.py
- unixccompiler.py
+ Libs:
  - libpython24.a
+ tcl:
  + tcl84
  + tk84



Get it from here:
http://jove.prohosting.com/iwave/ipython/pyMinGW.html


Regards
Khalid

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Moinmoin config

2005-08-19 Thread mbstevens
Mark wrote:
> The missing link under /var/www/html was exactly the problem.  Somehow
> missed this in the labyrinth of setup instructions.
> 
> I have another question, and as of yet, have not found another
> discussion group for moinmoin, so sorry, but here goes:
> 
> I have a table and would like the table borders to go away.  Although
> it doesn't talk about border widths explicitliy, the HelpOnTables seems
> to point to this :
> 
> 
> 
> But that does nothing to the border lines.  Adjusting width in the same
> line does work to change the size of the table, but it doesn't seem to
> understand 'border'.
> 
> Anyone know how to make the borders disappear?
> 
> Thanks
> Mark
> 
I would try a stylesheet forum or an (X)HTML forum for this 
question, but first look here,

http://lynx.fnal.gov/runjob/HelpOnConfiguration/CascadingStyleSheets

and then look here,

http://www.w3.org/TR/REC-CSS2/tables.html#borders

But, if the information you're putting in the table is not
true tabular data, consider more semantic markup.
--
mbstevens
http://www.mbstevens.com/cgi/mkatt.pl?name=python/Critique_Generator

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: BeautifulSoup

2005-08-19 Thread Mike Meyer
"Paul McGuire" <[EMAIL PROTECTED]> writes:

> Here's a pyparsing program that reads my personal web page, and spits
> out HTML with all of the HREF's reversed.

Parsing HTML isn't easy, which makes me wonder how good this solution
really is. Not meant as a comment on the quality of this code or
PyParsing, but as curiosity from someone who does a lot of [X}HTML
herding.

> -- Paul
> (Download pyparsing at http://pyparsing.sourceforge.net.)

If it were in the ports tree, I'd have grabbed it and tried it
myself. But it isn't, so I'm going to be lazy and ask. If PyParsing
really makes dealing with HTML this easy, I may package it as a port
myself.

> from pyparsing import Literal, quotedString
> import urllib
>
> LT = Literal("<")
> GT = Literal(">")
> EQUALS = Literal("=")
> htmlAnchor = LT + "A" + "HREF" + EQUALS +
> quotedString.setResultsName("href") + GT
>
> def convertHREF(s,l,toks):
> # do HREF conversion here - for demonstration, we will just reverse
> them
> print toks.href
> return "" % toks.href[::-1]
>
> htmlAnchor.setParseAction( convertHREF )
>
> inputURL = "http://www.geocities.com/ptmcg";
> inputPage = urllib.urlopen(inputURL)
> inputHTML = inputPage.read()
> inputPage.close()
>
> print htmlAnchor.transformString( inputHTML )

How well does it deal with other attributes in front of the href, like
?

How about if my HTML has things that look like HTML in attributes,
like ?

 Thanks,
   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python jobs

2005-08-19 Thread Aahz
In article <[EMAIL PROTECTED]>, Mike Meyer  <[EMAIL PROTECTED]> wrote:
>
>Maybe the Python jobs lists needs a "available developers"
>counterpart? Or would it be to big/dynamic to maintain using whatever
>is behind the jobs list?

Part of the reason the Jobs page hasn't moved to a wiki is that often
people sending in job ads are insufficiently technical to handle the
formatting.  That presumably wouldn't be true for an "available
developers" wiki...
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Save Binary data.

2005-08-19 Thread Mike Meyer
Larry Bates <[EMAIL PROTECTED]> writes:

> Directories with large numbers of files was a problem in FAT16 and
> FAT32 filesystems but not really a problem in NTFS or Linux (at
> least that I've found).

Depends on how you define "large" and what Linux file system you're
using. Of course, if you open the directory in a GUI directory
browser, you're probably going to be unhappy no matter what the
underlying file system.

The standard Unix solution to this is to break the files out into
subdirectories. Create a subdirectory with the name being the first
few letters of the file name, and then store the file in that
subdirectory. Easy to do programmatically, it's still easy to find
files "by hand", and you can make it as fine-grained as you want.

http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: global interpreter lock

2005-08-19 Thread Mike Meyer
Bryan Olson <[EMAIL PROTECTED]> writes:
> I don't see much point in trying to convince programmers that
> they don't really want concurrent threads. They really do. Some
> don't know how to use them, but that's largely because they
> haven't had them. I doubt a language for thread-phobes has much
> of a future.

The real problem is that the concurrency models available in currently
popular languages are still at the "goto" stage of language
development.  Better models exist, have existed for decades, and are
available in a variety of languages.

It's not that these languages are for "thread-phobes", either. They
don't lose power any more than Python looses power by not having a
goto. They languages haven't taken off for reasons unrelated to the
threading model(*).

The rule I follow in choosing my tools is "Use the least complex tool
that will get the job done."  Given that the threading models in
popular languages are complex and hard to work with, I look elsewhere
for solutions. I've had good luck using async I/O in lieue of
theards. It's won't solve every problem, but where it does, it's much
simpler to work with.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python jobs

2005-08-19 Thread Mike Meyer
"Terry Reedy" <[EMAIL PROTECTED]> writes:
> generally counter-indicated unless the name (.marketplace) or charter say 
> otherwise.  Exceptions would be a low volume of things of direct and narrow 
> interest.  So I consider the rare job announcements posted here ok.  The 
> same for book announcements.

The key words here are "of direct and narrow interest". Job postings
that don't mention Python in c.l.python are spam, nothing else.

Maybe the Python jobs lists needs a "available developers"
counterpart? Or would it be to big/dynamic to maintain using whatever
is behind the jobs list?

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Moinmoin config

2005-08-19 Thread Mark
The missing link under /var/www/html was exactly the problem.  Somehow
missed this in the labyrinth of setup instructions.

I have another question, and as of yet, have not found another
discussion group for moinmoin, so sorry, but here goes:

I have a table and would like the table borders to go away.  Although
it doesn't talk about border widths explicitliy, the HelpOnTables seems
to point to this :



But that does nothing to the border lines.  Adjusting width in the same
line does work to change the size of the table, but it doesn't seem to
understand 'border'.

Anyone know how to make the borders disappear?

Thanks
Mark

-- 
http://mail.python.org/mailman/listinfo/python-list


Version of TAR in tarfile module? TAR 1.14 or 1.15 port to Windows?

2005-08-19 Thread Claudio Grondi
I need to unpack on a Windows 2000 machine
some Wikipedia media .tar archives which are
compressed with TAR 1.14 (support for long file
names and maybe some other features) .
It seems, that Pythons tarfile module is able to list far
more files inside the archives than WinRAR or 7zip or
TotalCommander, but will it unpack all available files
(largest archive size 17 GByte)?

If tarfile is build on TAR 1.14 or TAR 1.15 it will be
probably ok, so my questions are:

What TAR version is built into the tarfile module?

Is there a TAR 1.14 or 1.15 port to Windows
available in Internet for download (which URL)?

Claudio



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get a unique id for bound methods?

2005-08-19 Thread Bengt Richter
On Fri, 19 Aug 2005 16:33:22 -0700, "Russell E. Owen" <[EMAIL PROTECTED]> wrote:
[...]
>
>The current issue is associated with Tkinter. I'm trying to create a tk 
>callback function that calls a python "function" (any python callable 
>entity).
>
>To do that, I have to create a name for tk that is unique to my python 
>"function". A hash-like name would be perfect, meaning a name that is 
>always the same for a particular python "function" and always different 
>for a different python "function". That would save a lot of housekeeping.
>
Why do you need a name? Can you post an example snippet that shows
a callback function being used with Tkinter as you would wish?
I have a feeling there is a much simpler solution than you are imagining ;-)

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


wanna stop by my homemade glory hole?

2005-08-19 Thread Steph
my husband is installing an extra bathroom poolside.  there is a perfect size 
hole (unless you have a huge cock) to stick your dick through into the adjoing 
room.  come around the side of my house(perfect if you look like a repair man) 
enter into the unfisnished bathroom and I'll service you from the other side.  
you can leave when your done, no talking or small talk.  i want to do this 
before the hole gets patched up. its been a huge fantasy of mine ever since 
I've seen a glory hole online. you can email me for a time convienient for you. 
im home all-day most days so my schedule is open. do you prefer a certain color 
of lipstick? check out my pic and email here under kallegirl26 
www.no-strings-fun.net/kallegirl26 
ready and waiting, me ;o)


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trying to check the creation date of a file

2005-08-19 Thread John Machin
David Fickbohm wrote:
> People,
> 
> I am trying to determine the creation date of files in a folder. 
> I am using the following code to find the folder and confirm that files
> exist in the folder.

Presumably you meant "intend to use the following pseudocode" (not "am 
using the following code")  -- many of the statements (marked XXX below) 
are just not valid Python.

>  If someone could give me an idea how to check a
> creation date it would be appreciated.
> Thanks
> dave
> 
> def delete_old_files  (t:\dm\~\users)
XXX
> # find files and delete files created more than XX number of days
> ago 
> update_exist = 0
Did you mean "file_delete = 0"?

> 
> input_dir = t:\dm\~\users\.yy\
XXX
> 
> if os.path.exists (input_dir) :
> files = os.listdir (input_dir)
> else:
> print "Unable to find input file dir: %s !!!" % input_dir
> sys.exit(2)
> 
> if len(files):
Not necessary -- "for file in files" does nothing gracefully if files is 
empty. If it were necessary, "if not files:" is suggested as an 
alternative to "if len(files)".
> for file in files :
> 
> file = os.path.join(input_dir) #all files in output
> directory will be csv or xls, can be deleted if old enough   

I think you mean "file = os.path.join(input_dir, file)"

> 
> if os.path.isfile(file):   #need to check ext not file, file
> name changes each day
> if re.search(t:\dm\~\users\x\) and  #creation date
XXX
You don't need the re module to check if the file's extension is "csv" 
or "xls"


> gt x number of days ago 
> t:\dm\~\users\davef.input_list.delete(file)
XXX
> 
> file_delete = 1
> 
> if file_delete:
> 
> print "\n file deleted: \n%s" %
> str(t:\dm\~\users\x.input_list)
> 
> return file_delete 

Now, to answer your question: You have obviously read the docs on the os 
module; what did you not understand about os.stat()?

I suggest you contemplate the following real-not-pseudo-code and then 
examine the relevant sections of the docs for os.stat(), the stat 
module, and the time module.

C:\junk>type st_ctime.py
import os, stat, time

def get_create_time(path):
 int_time = os.stat(path)[stat.ST_CTIME]
 str_time = time.ctime(int_time)
 return str_time

if __name__ == "__main__":
 import glob, sys
 for arg in sys.argv[1:]:
 for path in glob.glob(arg):
 create_time = get_create_time(path)
 print path, create_time
C:\junk>st_ctime.py *c*.py
checkmodules.py Fri Jun 24 22:32:57 2005
ivancodecs.py Mon Jul 11 10:03:23 2005
st_ctime.py Sat Aug 20 09:22:00 2005

C:\junk>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle.load not working?

2005-08-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:

> oh, well how do I make "derek" be an instance of 'chatuser' ?

Spot the difference::

 In [228]: class A: pass
.228.:

 In [229]: a = A

 In [230]: repr(a)
 Out[230]: ''

 In [231]: b = A()

 In [232]: repr(b)
 Out[232]: '<__main__.A instance at 0x4075e52c>'

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get a unique id for bound methods?

2005-08-19 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>,
 Benji York <[EMAIL PROTECTED]> wrote:

>Russell E. Owen wrote:
>> The id of two different methods of the same object seems to be the 
>> same, and it may not be stable either.
>
>Two facts you're (apparently) unaware of are conspiring against you:
>
>1) the "id" of an object is consistent for the lifetime of the object, 
>but may be reused after the object goes away
>
>2) methods are bound on an as-needed basis and then normally discarded 
>(unless you do something to keep them around)

Thank you and Bengt Richter. You both explained it very well.

The current issue is associated with Tkinter. I'm trying to create a tk 
callback function that calls a python "function" (any python callable 
entity).

To do that, I have to create a name for tk that is unique to my python 
"function". A hash-like name would be perfect, meaning a name that is 
always the same for a particular python "function" and always different 
for a different python "function". That would save a lot of housekeeping.

Does the built-in hash function actually do the job?

If I centralize all tk callback management and keep objects that 
represent the tk callback around then I can avoid the whole issue. I was 
hoping to avoid that, because it complicates housekeeping and adds a 
risk of memory leaks (at least I think so; right now tk deallocates its 
callback functions in the few cases I care about so I don't worry about 
it.)

-- Russell

P.S. Paolino: thank you also for your kind reply. Your suggestion sounds 
very useful if I only want a hash for a bound function, but in this case 
since I want a hash for any callable entity I'm not sure it'll work.
-- 
http://mail.python.org/mailman/listinfo/python-list


Karrigell tutorial published

2005-08-19 Thread Luis M. Gonzalez
Karrigell has new tutorial here:
http://karrigell.sourceforge.net/en/tutorial.html

For those who don't know what Karrigell is, I'd just say that it is the
most pythonic, simple, fun, straightforward and full-featured web
framework available today.

Check it out! http://karrigell.sourceforge.net/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: global interpreter lock

2005-08-19 Thread Bryan Olson
Donn Cave wrote:
 >  Bryan Olson wrote:
 >>On a uniprocessor system, the GIL is no problem. On multi-
 >>processor/core systems, it's a big loser.
 >
 >
 > I rather suspect it's a bigger winner there.
 >
 > Someone who needs to execute Python instructions in parallel
 > is out of luck, of course, but that has to be a small crowd.

Today, sure. The chip guys have spoken and the future is mult-
core.

 > I would have to assume that in most applications that need
 > the kind of computational support that implies, are doing most
 > of the actual computation in C, in functions that run with the
 > lock released.

That seems an odd thing to assume.

 > Rrunnable threads is 1 interpreter, plus N
 > "allow threads" C functions, where N is whatever the OS will bear.
 >
 > Meanwhile, the interpreter's serial concurrency limits the
 > damage.  The unfortunate reality is that concurrency is a
 > bane, so to speak -- programming for concurrency takes skill
 > and discipline and a supportive environment, and Python's
 > interpreter provides a cheap and moderately effective support
 > that compensates for most programmers' unrealistic assessment
 > of their skill and discipline.  Not that you can't go wrong,
 > but the chances you'll get nailed for it are greatly reduced -
 > especially in an SMP environment.

I don't see much point in trying to convince programmers that
they don't really want concurrent threads. They really do. Some
don't know how to use them, but that's largely because they
haven't had them. I doubt a language for thread-phobes has much
of a future.


-- 
--Bryan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stdin -> stdout

2005-08-19 Thread John Machin
limodou wrote:
> 2005/8/19, max(01)* <[EMAIL PROTECTED]>:
> 
>>hi.
>>
>>i was wondering, what's the simplest way to echo the standard input to
>>the standard output, with no modification.
>>
>>i came up with:
>>
>>...
>>while True:
>>   try:
>> raw_input()
>>   except EOFError:
>> break
>>...
>>
>>but i guess there must be a simpler way.
>>
>>using bash i simply do 'cat', *sigh*!
>>
>>bye
>>
>>max
>>
>>ps: in perl you ca do this:
>>
>>...
>>while ($line = )
>>   {
>> print STDOUT ("$line");
>>   }
>>...
> 
> 
> Try this.
> 
> import sys
> 
> line = sys.stdin.readline()
> while line:
> sys.stdout.write(line)
> line = sys.stdin.readline()
> 

Try this:

import sys
for line in sys.stdin:
sys.stdout.write(line)



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie Question

2005-08-19 Thread John Machin
Tom Strickland wrote:
> I have a file that contains many lines, each of which consists of a string 
> of comma-separated variables, mostly floats but some strings. Each line 
> looks like an obvious tuple to me. How do I save each line of this file as a 
> tuple rather than a string? Or, is that the right way to go?
> 
> Thank you.
> 
> Tom Strickland 
> 
> 

You will probably be able to read the file using the csv module.

But what do you want to do with the data? Transcribe it into some other 
format just for a learning exercise?  What do you mean by "save as tuple"?

A few more clues might save you from being (a) ignored and/or (b) 
deluged with irrelevant responses from well-intentioned wanting-to-help 
people who have guessed wrongly what you are rabbiting on about ...

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get a unique id for bound methods?

2005-08-19 Thread Paolino
Russell E. Owen wrote:

> The "hash" function looks promising -- it prints out consistent values 
> if I use it instead of "id" in the code above. Is it stable and unique? 
> The documentation talks about "objects" again, which given the behavior 
> of id makes me pretty nervous.
> 
I dont know how the hash of a bound method is calculated,but as the 
function of the method is a stable and referenced object and as 
instances lives are in your hands,then an id(self)^id(self.meth.im_func) 
should be a chance for that 'hash' function.

def methodId(boundMethod):
   return id(boundMethod.im_self)^id(boundMethod.im_func)

class cls(object):
   def __init__(self):
 print methodId(self.meth1)
 print methodId(self.meth2)
   def meth1(self):
 pass
   def meth2(self):
 pass

c = cls()
print methodId(c.meth1)
print methodId(c.meth2)

I think this is giving what you expected.

Regards Paolino





___ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python jobs (was Re: Python for Webscripting (like PHP))

2005-08-19 Thread Terry Reedy

"Gregory Piñero" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I'd love Python work, just like everyone else here.  On a related topic, 
>what's the >policy/etiquette of posting a resume on here, or mentioning 
>what kind of work >you're looking for?

I would take absence of such postings, even though you can imagine *lots* 
of people have had the same idea, as an indication that it is against 
policy/etiquette.  If 1 person does it, we could easily have 10 or 100 a 
day ;-).

>  And what's the policy in general for most newsgroups and mailing lists?

For mainline newsgroups, such as the comp.*, commercial annoucements are 
generally counter-indicated unless the name (.marketplace) or charter say 
otherwise.  Exceptions would be a low volume of things of direct and narrow 
interest.  So I consider the rare job announcements posted here ok.  The 
same for book announcements.  In either case, such are positive news for 
what is still a minority, just becoming mainstream, language.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list

Re: wanna stop by my homemade glory hole?

2005-08-19 Thread Stephen Kellett
 >wanna stop by my homemade glory hole?

I don't think anyone on this group will be interested in trying their 
Python with that. Take it somewhere else.
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while c = f.read(1)

2005-08-19 Thread John Machin
[EMAIL PROTECTED] wrote:
> Alright, everyone seems to have gone off on a tangent here, so I'll try
> to stick to your code...
> """
> This is what I would ideally like:
> 
> 
>   f = open("blah.txt", "r")
>   while c = f.read(1):
>   # ... work on c
> 
> 
> But I get a syntax error.
> 
> 
> while c = f.read(1):
>^
> SyntaxError: invalid syntax
> 
> """
> 
> That's because you are using an assignment operator instead of a
> comparison operator. It should have been written like this:
> 
> while c == f.read(1):
> 
> that would be written correctly, though I don't think that is your
> intention.
> Try this novel implementation, since nobody has suggested it yet.
> -
> import mmap
> 
> f  = open("blah.txt", 'r+') #opens file for read/write
> c = mmap.mmap(f.fileno(),0) #maps the file to be used as memory map...
> 
> while c.tell() < c.size():
> print c.read_byte()
> ---
> That accomplishes the same thing.
> 

Dear Sir or Madam,
I refer you to your recent post -- the one that started with "d'oh".
Regards,
John
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while c = f.read(1)

2005-08-19 Thread Bengt Richter
On Fri, 19 Aug 2005 16:31:47 +1000, John Machin <[EMAIL PROTECTED]> wrote:

>Bengt Richter wrote:
>> On 18 Aug 2005 22:21:53 -0700, "Greg McIntyre" <[EMAIL PROTECTED]> wrote:
>> 
>> 
>>>I have a Python snippet:
>>>
>>> f = open("blah.txt", "r")
>>> while True:
>>> c = f.read(1)
>>> if c == '': break # EOF
>>> # ... work on c
>>>
>>>Is some way to make this code more compact and simple? It's a bit
>>>spaghetti.
>>>
>>>This is what I would ideally like:
>>>
>>> f = open("blah.txt", "r")
>>> while c = f.read(1):
>>> # ... work on c
>>>
>> 
>> How about (untested):
>> 
>>for c in iter((lambda f=open('blah.txt', 'r'): f.read(1)), ''):
>># ... work on c
>> 
>:-)
>Bengt, did you read on to the bit where the OP wanted to do it "more 
>nicely"? YMMV, but I think you've strayed into "pas devant les enfants" 
>territory.
>(-:
>
LOL. Mais non ;-) OTOH, I think this might cross the line:

f = open('blah.txt')
while [c for c in [f.read(1)] if c!='']:
# ... work on c

;-)

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Database of non standard library modules...

2005-08-19 Thread Nigel Rowe
Steve Holden wrote:

> Robert Kern wrote:
>> Jon Hewer wrote:
>> 
>>>Is there an online database of non standard library modules for Python?
>> 
>> 
>> http://cheeseshop.python.org/pypi
>> 
> While cheeseshop might resonate with the Monty Python fans I have to say
> I think the name sucks in terms of explaining what to expect. If I ask
> someone where I can find a piece of code and the direct me to the cheese
> shop, I might look for another language.
> 
> regards
>   Steve

To be fair, it's really the "Python Package Index", it just happens to be
stored on a machine called cheeseshop.


-- 
Nigel Rowe
A pox upon the spammers that make me write my address like..
rho (snail) swiftdsl (stop) com (stop) au
-- 
http://mail.python.org/mailman/listinfo/python-list


servers in python

2005-08-19 Thread Max
I am writing a Hashcash program in python. Rather than create an email 
client plugin, I have done this thru a proxy server which adds the 
Hashcash before forwarding.

What I want to know is whether this is safe. I currently use this code:

class HashcashServer (smtpd.PureProxy):
 def process_message (self, peer, mailfrom, rcpttos, data):
 if peer[0] in trusted_peers:
 # add Hashcash and forward
 else:
 pass

where trusted_peers is a list of peers that are allowed to use the 
service (it is currently just ["localhost"]).

Is there risk of any hacking, or of this becoming an open relay?

--Max
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trying to check the creation date of a file

2005-08-19 Thread Larry Bates
use os.stat docs are here:
http://docs.python.org/lib/module-stat.html

Larry Bates

David Fickbohm wrote:
> People,
> 
> I am trying to determine the creation date of files in a folder. 
> I am using the following code to find the folder and confirm that files
> exist in the folder.  If someone could give me an idea how to check a
> creation date it would be appreciated.
> Thanks
> dave
> 
> def delete_old_files  (t:\dm\~\users)
> # find files and delete files created more than XX number of days
> ago 
> update_exist = 0
> 
> input_dir = t:\dm\~\users\.yy\
> 
> if os.path.exists (input_dir) :
> files = os.listdir (input_dir)
> else:
> print "Unable to find input file dir: %s !!!" % input_dir
> sys.exit(2)
> 
> if len(files):
> for file in files :
> 
> file = os.path.join(input_dir) #all files in output
> directory will be csv or xls, can be deleted if old enough   
> 
> if os.path.isfile(file):   #need to check ext not file, file
> name changes each day
> if re.search(t:\dm\~\users\x\) and  #creation date
> gt x number of days ago 
> t:\dm\~\users\davef.input_list.delete(file)
> 
> file_delete = 1
> 
> if file_delete:
> 
> print "\n file deleted: \n%s" %
> str(t:\dm\~\users\x.input_list)
> 
> return file_delete 
> 
> Dave Fickbohm
> Data Mining Analyst
> Homegain+
> 1250 45th St.
> Emeryville, CA, 94608
> Phone 510 594 4151 - Voice
>   510 655 0848 - Fax
> 
> 

-- 
http://mail.python.org/mailman/listinfo/python-list


looking to GIVE my first oral favor

2005-08-19 Thread allie
im new to this, i guess you can say im still curious about having extra marital 
lovers.  i've only had 1 encounter with a married man and I loved it so much.  
its such a strong burning desire now.  when I look at men, i'm always wondering 
how they look nude, or their cock size. basically, i want to find a man to have 
his way with me and really show me the ropes of being a lover to another man on 
the side. exchange face and cock pics with me here under luvnlady3050 
http://www.no-strings-fun.net/kallegirl26 
kisses, me



-- 
http://mail.python.org/mailman/listinfo/python-list


trying to check the creation date of a file

2005-08-19 Thread David Fickbohm
People,

I am trying to determine the creation date of files in a folder. 
I am using the following code to find the folder and confirm that files
exist in the folder.  If someone could give me an idea how to check a
creation date it would be appreciated.
Thanks
dave

def delete_old_files  (t:\dm\~\users)
# find files and delete files created more than XX number of days
ago 
update_exist = 0

input_dir = t:\dm\~\users\.yy\

if os.path.exists (input_dir) :
files = os.listdir (input_dir)
else:
print "Unable to find input file dir: %s !!!" % input_dir
sys.exit(2)

if len(files):
for file in files :

file = os.path.join(input_dir) #all files in output
directory will be csv or xls, can be deleted if old enough   

if os.path.isfile(file):   #need to check ext not file, file
name changes each day
if re.search(t:\dm\~\users\x\) and  #creation date
gt x number of days ago 
t:\dm\~\users\davef.input_list.delete(file)

file_delete = 1

if file_delete:

print "\n file deleted: \n%s" %
str(t:\dm\~\users\x.input_list)

return file_delete 

Dave Fickbohm
Data Mining Analyst
Homegain+
1250 45th St.
Emeryville, CA, 94608
Phone 510 594 4151 - Voice
  510 655 0848 - Fax


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python jobs (was Re: Python for Webscripting (like PHP))

2005-08-19 Thread Aahz
In article <[EMAIL PROTECTED]>,
Erik Max Francis  <[EMAIL PROTECTED]> wrote:
>Peter Decker wrote:
>>
>> Then start looking for telecommuting people. There are lots of us who
>> can use work and have excellent telecommuting references, but who
>> don't happen to live in a major metro area!
>
>And then there's some in the Bay Area who wouldn't mind telecommuting, 
>either ... :-)

We do a *lot* of telecommuting.  I'm working from home today, for
example, because I needed to deal with the plumber.  And we have two
people in Seattle out of seven fulltime people.  However, it's our
experience that people are more productive when they show up at the
office regularly -- the two Seattle people had lots of experience with
our product before they worked independently, and the two of them do
share an office.

(They work across the street from Elliott Bay Books, the bastards.)
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get a unique id for bound methods?

2005-08-19 Thread Bengt Richter
On Fri, 19 Aug 2005 13:29:19 -0700, "Russell E. Owen" <[EMAIL PROTECTED]> wrote:

>I have several situations in my code where I want a unique identifier 
>for a method of some object (I think this is called a bound method). I 
>want this id to be both unique to that method and also stable (so I can 
>regenerate it later if necessary).
>

>I thought the id function was the obvious choice, but it doesn't seem to 
>work. The id of two different methods of the same object seems to be the 
>same, and it may not be stable either. For instance:
>
The id function works, but you are applying it to transient objects, which
is what bound methods are unless you cause them to persist one way or another.

>class cls(object):
>  def __init__(self):
>print id(self.meth1)
>print id(self.meth2)
>  def meth1(self):
>pass
>  def meth2(self):
>pass
>
>c = cls()
>3741536
>3741536
This means that self.meth1 only existed long enough to be passed to id,
and when id was done with determining its id, self.meth1 was freed.
Then self.meth2 was created, and happened to use a representation space
with the same id as was used for self.meth1. If the two objects (bound methods
here) existed at the same time, they would be guaranteed not to have the same id
unless they were actually the same object.

>print id(c.meth1)
>3616240
>print id(c.meth2)
>3616240
This happened to re-use a representation space with another id.
>
>I guess that just means bound methods aren't objects in their own right, 
>but it surprised me.
No, they are objects in their own right. You were surprised by your
[mis]interpretation of the above results ;-)
>
>The "hash" function looks promising -- it prints out consistent values 
>if I use it instead of "id" in the code above. Is it stable and unique? 
>The documentation talks about "objects" again, which given the behavior 
>of id makes me pretty nervous.
>
>Any advice would be much appreciated.
>
If you want a particular bound method to have a stable and persistent id,
make it persist, e.g.,

 >>> class cls(object):
 ...   def __init__(self):
 ... print id(self.meth1)
 ... print id(self.meth2)
 ...   def meth1(self):
 ... pass
 ...   def meth2(self):
 ... pass
 ...
 >>> c = cls()
 49219060
 49219060
 >>> print id(c.meth1)
 49219020
 >>> print id(c.meth2)
 49219020

Ok, those were transient, now nail a couple of bound methods down:
 >>> cm1 = c.meth1
 >>> cm2 = c.meth2

And you can look at their id's all you like:

 >>> print id(cm1)
 49219020
 >>> print id(cm2)
 49219060
 >>> print id(cm1)
 49219020
 >>> print id(cm2)
 49219060

But every time you just evaluate the attribute expression c.meth1 or c.meth2
you will get a new transient bound method object, with a new id:

 >>> print id(c.meth1)
 49219180
 >>> print id(c.meth2)
 49219180

But the ones we forced to persist by binding the expression values to cm1 and 
cm2
above still have the same ids as before:

 >>> print id(cm1)
 49219020
 >>> print id(cm2)
 49219060

So the question would be, why do you (think you ;-) need ids for
these bound methods as such? I.e., what is the "situation" in your code?

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get a unique id for bound methods?

2005-08-19 Thread Benji York
Russell E. Owen wrote:
> The id of two different methods of the same object seems to be the 
> same, and it may not be stable either.

Two facts you're (apparently) unaware of are conspiring against you:

1) the "id" of an object is consistent for the lifetime of the object, 
but may be reused after the object goes away

2) methods are bound on an as-needed basis and then normally discarded 
(unless you do something to keep them around)

An illustration:

class cls(object):
   def meth1(self):
 pass
   def meth2(self):
 pass

c = cls()
m1 = c.meth1
print id(m1)
-1209779308
m2 = c.meth1
print id(m2)
-1209652732

> I guess that just means bound methods aren't objects in their own right, 
> but it surprised me.

Nope, they're objects, they just don't tend to be around very long.

> The "hash" function looks promising -- it prints out consistent values 
> if I use it instead of "id" in the code above. Is it stable and unique? 
> The documentation talks about "objects" again, which given the behavior 
> of id makes me pretty nervous.
> 
> Any advice would be much appreciated.

I think you'll get the best advice from this group if you tell us what 
the larger problem is that you're trying to solve.
--
Benji York

-- 
http://mail.python.org/mailman/listinfo/python-list


wanna stop by my homemade glory hole?

2005-08-19 Thread Lacy
my husband is installing an extra bathroom poolside.  there is a perfect size 
hole (unless you have a huge cock) to stick your dick through into the adjoing 
room.  come around the side of my house(perfect if you look like a repair man) 
enter into the unfisnished bathroom and I'll service you from the other side.  
you can leave when your done, no talking or small talk.  i want to do this 
before the hole gets patched up. its been a huge fantasy of mine ever since 
I've seen a glory hole online. you can email me for a time convienient for you. 
im home all-day most days so my schedule is open. do you prefer a certain color 
of lipstick? check out my pic and email here under kallegirl26 
www.no-strings-fun.net/kallegirl26 
ready and waiting, me ;o)


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while c = f.read(1)

2005-08-19 Thread Grant Edwards
On 2005-08-19, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Alright, everyone seems to have gone off on a tangent here, so I'll try
> to stick to your code...

> """
> This is what I would ideally like:
>
>
>   f = open("blah.txt", "r")
>   while c = f.read(1):
>   # ... work on c
>
>
> But I get a syntax error.
>
>
> while c = f.read(1):
>^
> SyntaxError: invalid syntax
>
> """
>
> That's because you are using an assignment operator instead of a
> comparison operator.

That's because he wants an assignment operator.  He also wants
"c = f.read(1)" to be an expression that evalutates to the
value of c after the assignment operator.

-- 
Grant Edwards   grante Yow!  .. I'm IMAGINING a
  at   sensuous GIRAFFE, CAVORTING
   visi.comin the BACK ROOM of a
   KOSHER DELI --
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Confused newbie needs help with "__init__() takes exactly 11 arguments (1 given)"

2005-08-19 Thread [EMAIL PROTECTED]
d'oh I'm an idiot... you are making a 'list' object.

-- 
http://mail.python.org/mailman/listinfo/python-list


How to get a unique id for bound methods?

2005-08-19 Thread Russell E. Owen
I have several situations in my code where I want a unique identifier 
for a method of some object (I think this is called a bound method). I 
want this id to be both unique to that method and also stable (so I can 
regenerate it later if necessary).

I thought the id function was the obvious choice, but it doesn't seem to 
work. The id of two different methods of the same object seems to be the 
same, and it may not be stable either. For instance:

class cls(object):
  def __init__(self):
print id(self.meth1)
print id(self.meth2)
  def meth1(self):
pass
  def meth2(self):
pass

c = cls()
3741536
3741536
print id(c.meth1)
3616240
print id(c.meth2)
3616240

I guess that just means bound methods aren't objects in their own right, 
but it surprised me.

The "hash" function looks promising -- it prints out consistent values 
if I use it instead of "id" in the code above. Is it stable and unique? 
The documentation talks about "objects" again, which given the behavior 
of id makes me pretty nervous.

Any advice would be much appreciated.

-- Russell
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while c = f.read(1)

2005-08-19 Thread [EMAIL PROTECTED]
Alright, everyone seems to have gone off on a tangent here, so I'll try
to stick to your code...
"""
This is what I would ideally like:


  f = open("blah.txt", "r")
  while c = f.read(1):
  # ... work on c


But I get a syntax error.


while c = f.read(1):
   ^
SyntaxError: invalid syntax

"""

That's because you are using an assignment operator instead of a
comparison operator. It should have been written like this:

while c == f.read(1):

that would be written correctly, though I don't think that is your
intention.
Try this novel implementation, since nobody has suggested it yet.
-
import mmap

f  = open("blah.txt", 'r+') #opens file for read/write
c = mmap.mmap(f.fileno(),0) #maps the file to be used as memory map...

while c.tell() < c.size():
print c.read_byte()
---
That accomplishes the same thing.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Idempotent XML processing

2005-08-19 Thread Will McCutchen
> Read up on XML canonicalization (abrreviated as c14n). lxml implements
> this, also xml.dom.ext.c14n in PyXML. You'll need to canonicalize on
> both ends before hashing.

I said normalization but I think canonicalization is the word I was
looking for.  I wasn't aware that lxml implented it (or that it had an
abbreviation), so that's good to know.  Thanks!


Will.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A script to run all of my project's pyunit tests

2005-08-19 Thread travislspencer
[EMAIL PROTECTED] wrote:
> for file in glob(projHome + "/tests/*.py"):
> start = file.rfind("/") + 1
> end = file.rfind(".")
> moduleName = file[start:end]
> module = __import__(moduleName)

  klass = module.__dict__[module.__name__]
  tests.append(unittest.makeSuite(klass, "test"))

> allTests = unittest.TestSuite(tests)
> runner = unittest.TextTestRunner(verbosity=2)
>
> runner.run(allTests)

This is still a kludge, but a different and less annoying one.  It
works as long as the TestCase class and module have the same name.

Back to the drawing board...

--
 
Regards,

Travis Spencer

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: global interpreter lock

2005-08-19 Thread Gregory Piñero
Would a cheap solution just be to run two python interpreters and have
the scripts communicating over COM or some other such thing?  I'd
imagine that would give you true parallelism.

-GregOn 8/19/05, Donn Cave <[EMAIL PROTECTED]> wrote:
In article <[EMAIL PROTECTED] >, Bryan Olson <[EMAIL PROTECTED] > wrote:
> km wrote:>  > Hi all,>  >>  > is true parallelism possible in python ? or atleast in the>  > coming versions ? is global interpreter lock a bane in this>  > context ?
>> No; maybe; and currently, not usually.>> On a uniprocessor system, the GIL is no problem. On multi-> processor/core systems, it's a big loser.I rather suspect it's a bigger winner there.
Someone who needs to execute Python instructions in parallelis out of luck, of course, but that has to be a small crowd.I would have to assume that in most applications that needthe kind of computational support that implies, are doing most
of the actual computation in C, in functions that run with thelock released.  Rrunnable threads is 1 interpreter, plus N"allow threads" C functions, where N is whatever the OS will bear.Meanwhile, the interpreter's serial concurrency limits the
damage.  The unfortunate reality is that concurrency is abane, so to speak -- programming for concurrency takes skilland discipline and a supportive environment, and Python'sinterpreter provides a cheap and moderately effective support
that compensates for most programmers' unrealistic assessmentof their skill and discipline.  Not that you can't go wrong,but the chances you'll get nailed for it are greatly reduced -especially in an SMP environment.
   Donn Cave, [EMAIL PROTECTED] --http://mail.python.org/mailman/listinfo/python-list 
-- Gregory PiñeroChief Innovation OfficerBlended Technologies(www.blendedtechnologies.com)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Confused newbie needs help with "__init__() takes exactly 11 arguments (1 given)"

2005-08-19 Thread [EMAIL PROTECTED]
it looks like your problem is in this line:
reviews = [Review(*[field.strip() for field in row]) for row in reader]

ouch! split that up a bit so we can understand what the heck you are
trying to do here. Also, it appears the whole thing is in these [ ] ?
why?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python classes taught

2005-08-19 Thread Simon Percivall
Yeha, sure. The Royal Institute of Technology in Stockholm, Sweden
teaches Python for some of its introductory programming and algorithm
courses.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Idempotent XML processing

2005-08-19 Thread Michael Ekstrand
On Aug 19, 2005, at 1:20 PM, Robert Kern wrote:
> Read up on XML canonicalization (abrreviated as c14n). lxml implements
> this, also xml.dom.ext.c14n in PyXML. You'll need to canonicalize on
> both ends before hashing.
>
> To paraphrase an Old Master, if you are running a cryptographic hash
> over a non-canonical XML string representation, then you are living in 
> a
> state of sin.

Canonicalization seems to be the needed thing. Looking at the protocol 
specification again, it mentions canonicalization; I had glossed over 
that previously because I was unware of any defined meaning it had. But 
the c14n module should provide the needed results (now that I've 
finally dug up documentation for it).

-Michael

-- 
http://mail.python.org/mailman/listinfo/python-list


A script to run all of my project's pyunit tests

2005-08-19 Thread travislspencer
Hey All,

I am trying to write a script that runs all of my pyunit tests for me.
Ideally, I would like to be able to drop a new module into my
project's test subdirectory, and the testing script will pick it up
automatically.

At the moment, I have it working but it is kinda a kludge because
every TestCase must provide a function that returns a TestSuite for
all of its tests.

Here is the basic process and a stripped down version of the script:

1. Locate each `.py' file in my project's test subdirectory.
2. Import the module found in step 1.
3. Get a TestSuite of all of the tests in the module imported in step
2.
4. Add the TestSuite from step 3 to a growing list of suites.
5. Make one granddaddy TestSuite from the list of all those fetched in
   steps 1 through 4.
6. Create a runner, pass it the uber TestSuite, and run all the tests.

My scripts to do these things is as follows:

==
import os, sys, unittest
from glob import glob

projHome = os.getenv("PROJ_HOME")
sys.path.insert(0, projHome + "/tests")
tests = []

for file in glob(projHome + "/tests/*.py"):
start = file.rfind("/") + 1
end = file.rfind(".")
moduleName = file[start:end]
module = __import__(moduleName)

tests.append(module.getTestSuite())
#---^
# The part that I'm not happy with.

allTests = unittest.TestSuite(tests)
runner = unittest.TextTestRunner(verbosity=2)

runner.run(allTests)
==

With this setup, every module has to have a `getTestSuite' function
that returns a TestSuite for the module.  This is suboptimal and
annoying.  The function looks like this is all of my TestCase
subclasses:

==
class MyTestCase(unittest.TestCase):
pass

def getTestSuite():
return suite

if __name__ == "__main__":
unittest.main()
else:
global suite

suite = unittest.makeSuite(MyTestCase, 'test')
==

The problem is that I can't figure out how to do something similar to
the TestCases' `unittest.makeSuite(MyTestCase, 'test')' in the script
that I'm using to run all of the tests.

If anyone has any help or suggestions, I would really appreciate it.

--


Regards,

Travis Spencer

-- 
http://mail.python.org/mailman/listinfo/python-list


[Jython-users] ANN: PyDev 0.9.7.99 released

2005-08-19 Thread Fabio Zadrozny
Hi All,

PyDev - Python IDE (Python Development Enviroment for Eclipse) version 
0.9.7.99 has just been released.

Check the homepage (http://pydev.sourceforge.net/) for more details.


Details for Release: 0.9.7.99

OK, what's with the strange release version number?... Well, this 
version undergone lot's of changes, so, PyDev will be waiting on 
feedback about them... only after that will it become 0.9.8!


Major highlights:

* PyDev has its first shot at Jython. you should be able to use many 
things already, meaning: all the common editor features and code completion.
* The debugger is working.


Others that are new and noteworthy:

* Code completion has been improved for supporting wild imports and 
relative imports better (sometimes it had some problems).
* There are hovers for the text and annotations (when you pass the 
mouse through an error it will show its description).
* Block comment (Ctrl+4) now uses the size defined for the print margin.
* New block-comment style added (Ctrl+Shift+4).
* New icons were created.
* wxPython completions now show.
* Many other bug-fixes as usual.

Note on Java 1.4 support: Currently Java 1.4 is not supported (only java 
5.0), altough we will try to add support for java 1.4 before the 1.0 
release.


Special thanks
---
This release would not be possible without help from:

OctetString, for the financial support for making jython support possible!
Aleks Totic, Scott Schlesier and Vitor Oba for the debugger patches!
Eduardo A. Hoff, for the new logo and changes on the site layout!

Cheers,

Fabio

-- 

Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com




---
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
___
Jython-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jython-users

-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: PyDev 0.9.7.99 released

2005-08-19 Thread Fabio Zadrozny
Hi All,

PyDev - Python IDE (Python Development Enviroment for Eclipse) version 
0.9.7.99 has just been released.

Check the homepage (http://pydev.sourceforge.net/) for more details.


Details for Release: 0.9.7.99

OK, what's with the strange release version number?... Well, this 
version undergone lot's of changes, so, PyDev will be waiting on 
feedback about them... only after that will it become 0.9.8!


Major highlights:

* PyDev has its first shot at Jython. you should be able to use many 
things already, meaning: all the common editor features and code completion.
* The debugger is working.


Others that are new and noteworthy:

* Code completion has been improved for supporting wild imports and 
relative imports better (sometimes it had some problems).
* There are hovers for the text and annotations (when you pass the 
mouse through an error it will show its description).
* Block comment (Ctrl+4) now uses the size defined for the print margin.
* New block-comment style added (Ctrl+Shift+4).
* New icons were created.
* wxPython completions now show.
* Many other bug-fixes as usual.

Note on Java 1.4 support: Currently Java 1.4 is not supported (only java 
5.0), altough we will try to add support for java 1.4 before the 1.0 
release.


Special thanks
---
This release would not be possible without help from:

OctetString, for the financial support for making jython support possible!
Aleks Totic, Scott Schlesier and Vitor Oba for the debugger patches!
Eduardo A. Hoff, for the new logo and changes on the site layout!

Cheers,

Fabio

-- 

Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Idempotent XML processing

2005-08-19 Thread Michael Ekstrand
On Aug 19, 2005, at 12:11 PM, Will McCutchen wrote:
>> In my current project, I am working with XML data in a protocol that 
>> has
>> checksum/signature verification of a portion of the document.
>> ...
>> the server sends me XML with empty elements as full open/close tags,
>> but toxml() serializes them to the XML empty element (), so
>> the checksum winds up not matching.
>
> Does it even make sense to use a checksum to verify XML, since there
> are basically[1] infinite ways to validly write equivalent XML data?
>
> [...]
>
> Again, I'm sorry because I didn't provide any real useful information,
> I just tried to poke holes in your current project.

I would agree that this mechanism doesn't make much sense. It certainly 
doesn't seem to fit well within the conventions most parsing 
ideologies; I don't know what parsing mechanism the protocol authors 
had in mind.

Unfortunately, I did not write the protocol... I must merely speak it.

- Michael

-- 
http://mail.python.org/mailman/listinfo/python-list


Python 2.1 Bible Source

2005-08-19 Thread SuppressedPen
Hi Everyone!

Just started with Python 2 weeks ago and I can't put it down it's to easy
and to powerful, I'm sure the goons will be after us for having it soon, Hi
Hi.

Was wondering if anyone might know where I can find the source code for
PYTHON 2.1 BIBLE book.  Apparently it was online until the publisher sold
the company.  I also understand it has been sold a second time since the
book was published.  Maybe someone has a copy?  Thanks. DOUG.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: BeautifulSoup

2005-08-19 Thread Paul McGuire
Here's a pyparsing program that reads my personal web page, and spits
out HTML with all of the HREF's reversed.

-- Paul
(Download pyparsing at http://pyparsing.sourceforge.net.)



from pyparsing import Literal, quotedString
import urllib

LT = Literal("<")
GT = Literal(">")
EQUALS = Literal("=")
htmlAnchor = LT + "A" + "HREF" + EQUALS +
quotedString.setResultsName("href") + GT

def convertHREF(s,l,toks):
# do HREF conversion here - for demonstration, we will just reverse
them
print toks.href
return "" % toks.href[::-1]

htmlAnchor.setParseAction( convertHREF )

inputURL = "http://www.geocities.com/ptmcg";
inputPage = urllib.urlopen(inputURL)
inputHTML = inputPage.read()
inputPage.close()

print htmlAnchor.transformString( inputHTML )

-- 
http://mail.python.org/mailman/listinfo/python-list


python classes taught

2005-08-19 Thread araki
anyone know of any college/school that is teaching the python language?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: BeautifulSoup

2005-08-19 Thread Paul McGuire
Steve -

Is there a chance you could post a before and after example, so we can
see just what you are trying to do instead of talking conceptually all
around it and making us guess?  If you are just doing some spot
translations of specific values in an HTML file, you can probably get
away with a simple (but readable) program using pyparsing.

-- Paul

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Idempotent XML processing

2005-08-19 Thread Robert Kern
Michael Ekstrand wrote:
> Hello all,
> 
> In my current project, I am working with XML data in a protocol that has
> checksum/signature verification of a portion of the document. There is 
> an envelope with a header element, containing signature data; following 
> the header is a body. The signatures are computed as cryptographic 
> checksums of the entire Body element, including start and end tags, 
> exactly as it appears in the data transmission.
> 
> Therefore, I need to extract the entire text of an element of an XML 
> document. I have a function that scans an XML string and does this, but 
> it seems like a rather clumsy way to accomplish this task. I've been 
> playing with xml.dom.minidom and its toxml() method, but to no avail - 
> the server sends me XML with empty elements as full open/close tags, 
> but toxml() serializes them to the XML empty element (), so 
> the checksum winds up not matching.
> 
> Is there some parsing mechanism (using PyXML or any other freely usable 
> 3rd party library is an option) that will allow me to accomplish this? 
> Or am I best off sticking with my little string scanning function?

Read up on XML canonicalization (abrreviated as c14n). lxml implements 
this, also xml.dom.ext.c14n in PyXML. You'll need to canonicalize on 
both ends before hashing.

To paraphrase an Old Master, if you are running a cryptographic hash 
over a non-canonical XML string representation, then you are living in a 
state of sin.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for Webscripting (like PHP)

2005-08-19 Thread Jeff Reavis
You might want to check out spyce. It uses a server page model (like
jsp and php) so you can embed python in html. It has the standard stuff
you would need for making a web site (session support, etc) and also
contains features like custom tags.

http://spyce.sourceforge.net/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: global interpreter lock

2005-08-19 Thread Donn Cave
In article <[EMAIL PROTECTED]>,
 Bryan Olson <[EMAIL PROTECTED]> wrote:

> km wrote:
>  > Hi all,
>  >
>  > is true parallelism possible in python ? or atleast in the
>  > coming versions ? is global interpreter lock a bane in this
>  > context ?
> 
> No; maybe; and currently, not usually.
> 
> On a uniprocessor system, the GIL is no problem. On multi-
> processor/core systems, it's a big loser.

I rather suspect it's a bigger winner there.

Someone who needs to execute Python instructions in parallel
is out of luck, of course, but that has to be a small crowd.
I would have to assume that in most applications that need
the kind of computational support that implies, are doing most
of the actual computation in C, in functions that run with the
lock released.  Rrunnable threads is 1 interpreter, plus N
"allow threads" C functions, where N is whatever the OS will bear.

Meanwhile, the interpreter's serial concurrency limits the
damage.  The unfortunate reality is that concurrency is a
bane, so to speak -- programming for concurrency takes skill
and discipline and a supportive environment, and Python's
interpreter provides a cheap and moderately effective support
that compensates for most programmers' unrealistic assessment
of their skill and discipline.  Not that you can't go wrong,
but the chances you'll get nailed for it are greatly reduced -
especially in an SMP environment.

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __del__ pattern?

2005-08-19 Thread BranoZ
Bryan Olson wrote:
>  > Use file that is writeable by A and B in a directory that is
>  > writeable only by root.
>
> Is that portable?

I have the feeling that you are asking if it works on Windows.
No idea! I have only user experience with Windows.

On UNIX it is as portable as 'flock', which means all modern
Unices (be careful about NFS).

> What's the sequence the program should try?

1.
open a file, which name was previously agreed on
(like /var/tmp/-)

If it fails, report error and exit. System error or
somebody has created unaccessible file by the same name.

2.
Try to aquire a flock on the descriptor from step 1.

If it fails, some running process already has the lock, exit

3.
lock will be released and lockfile closed automaticaly by OS
on process exit.

import sys, fcntl

try:
  lockfile=open('/var/tmp/test1', 'w')
  fcntl.flock(lockfile.fileno(),
fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
  print sys.exc_info()[1]
  sys.exit(-1)

You can flock any open file, no matter if it is read/write/append.

BranoZ

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Idempotent XML processing

2005-08-19 Thread Will McCutchen
> In my current project, I am working with XML data in a protocol that has
> checksum/signature verification of a portion of the document.
> ...
> the server sends me XML with empty elements as full open/close tags,
> but toxml() serializes them to the XML empty element (), so
> the checksum winds up not matching.

(This is a horrible response to your question, so I apologize in
advance.)

Does it even make sense to use a checksum to verify XML, since there
are basically[1] infinite ways to validly write equivalent XML data?

I would think the only way that a checksum would be a viable way to
verify a document is if you had some sort of standard normalized
format, and made sure the data was normalized both before you computed
and before you calculated the checksum.  That way, you would be sure
that, for instance, all insignificant whitespace was removed and all
empty elements were represented uniformly.

Again, I'm sorry because I didn't provide any real useful information,
I just tried to poke holes in your current project.


Will.

[1]  Unless all of your whitespace is significant

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while c = f.read(1)

2005-08-19 Thread Donn Cave
In article <[EMAIL PROTECTED]>,
 Antoon Pardon <[EMAIL PROTECTED]> wrote:
...
> But '', {}, [] and () are not nothing. They are empty containers.

Oh come on, "empty" is all about nothing.

> And 0 is not nothing either it is a number. Suppose I have
> a variable that is either None if I'm not registered and a
> registration number if I am. In this case 0 should be treated
> as any other number.
> 
> Such possibilities, make me shy away from just using 'nothing'
> as false and writing out my conditionals more explicitly.

Sure, if your function's type is "None | int", then certainly
you must explicitly check for None.  That is not the case with
fileobject read(), nor with many functions in Python that
reasonably and ideally return a value of a type that may
meaningfully test false.  In this case, comparison (==) with
the false value ('') is silly.

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


sequence slicing documentation

2005-08-19 Thread Steven Bethard
In trying to work out what's different between the start, stop and step 
of slice.indices() and the start, stop and step of sequence slicing[1] I 
found that some of the list slicing documentation[2] is vague.  I'd like 
to submit a documentation fix, but I want to make sure I have it right. 
  Here's what points (3) and (5) of the Sequence Types documentation say 
now:

"""
(3) If i or j is negative, the index is relative to the end of the 
string: len(s) + i or len(s) + j is substituted. But note that -0 is 
still 0.
...
(5) The slice of s from i to j with step k is defined as the sequence of 
items with index x = i + n*k such that $0 \leq n < \frac{j-i}{k}$. In 
other words, the indices are i, i+k, i+2*k, i+3*k and so on, stopping 
when j is reached (but never including j). If i or j  is greater than 
len(s), use len(s). If i or j are omitted then they become ``end'' 
values (which end depends on the sign of k). Note, k cannot be zero.
"""

I'd like to replace that second-to-last sentence in point (5) with the 
vague ``end'' description with something more explicit.  I'd like it to 
read something like:

"""
If k is positive and i or j is omitted, they will be replaced with 0 and 
len(s) respectively. If k is negative and i or j is omitted, they will 
be replaced with -1 and -len(s)-1 respectively.  Note that these 
replacements happen before the rule from point (3) is applied.
"""

I'd also like to put an example with point (5) to show this behavior in 
action. Something like:

"""
So for example::

 >>> seq = 'abcde'
 >>> len(seq)
 5
 >>> 'edc' == seq[:1:-1] == seq[-1:1:-1]
 True
 >>> 'ca' == seq[2::-2] == seq[2:-5-1:-2]
 True

Note however that manually applying the rule from point (3) (adding 
len(s) to any i or j that is negative) works for i, but does not work 
for j::

 >>> seq[5-1:1:-1]
 'edc'
 >>> seq[2:-1:-2]
 ''

This is because Python sees the -1 in the j position and applies the 
rule from point (3) again.
"""

If a few people could check over my logic here and make sure I'm not 
completely misguided, I'll post a documentation fix.

Thanks,

STeVe

[1] http://mail.python.org/pipermail/python-list/2005-August/293963.html
[2] http://docs.python.org/lib/typesseq.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Traceback Questions

2005-08-19 Thread Fernando Perez
ncf wrote:

> I'm just beginning with tracebacks, building off of what I see in
> asyncore's compact_traceback code, in order to hopefully store all the
> values from the location in which the exception occured.
> 
> I'm actually trying to make this into a python bug report system for my
> current project, and am seeking advice on how to use sys.exc_info()[2]
> better (the traceback element)
> 
> Does anyone have any advice on how I'd preform a traceback-based
> bugreport-like system? The more I work on this, the more I'm confusing
> myself. :\

You may want to look at ipython's CrashHandler system:

http://projects.scipy.org/ipython/ipython/file/ipython/trunk/IPython/CrashHandler.py

It does all of what you've described in your post automatically.  Some of it is
ipython-specific, but it should be easy enough to tweake it for your needs.

For download links (the above is an SVN source browsing link):

http://ipython.scipy.org

At some point I should really abstract this out, there seems to be a need for
it out there.

Cheers,

f

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __del__ pattern?

2005-08-19 Thread Bryan Olson
BranoZ wrote:
 > [EMAIL PROTECTED] wrote:
 >
 >>For a reasonably portable solution, leave the lock file open.
 >>On most systems, you cannot delete an open file,..
 >
 > On most UNIXes, you can delete an open file.
 > Even flock-ed. This is BTW also an hack around flock.

Yes, sorry; my bad.

 > Use file that is writeable by A and B in a directory that is
 > writeable only by root.

Is that portable? What's the sequence the program should try?


-- 
--Bryan
-- 
http://mail.python.org/mailman/listinfo/python-list


Idempotent XML processing

2005-08-19 Thread Michael Ekstrand
Hello all,

In my current project, I am working with XML data in a protocol that has
checksum/signature verification of a portion of the document. There is 
an envelope with a header element, containing signature data; following 
the header is a body. The signatures are computed as cryptographic 
checksums of the entire Body element, including start and end tags, 
exactly as it appears in the data transmission.

Therefore, I need to extract the entire text of an element of an XML 
document. I have a function that scans an XML string and does this, but 
it seems like a rather clumsy way to accomplish this task. I've been 
playing with xml.dom.minidom and its toxml() method, but to no avail - 
the server sends me XML with empty elements as full open/close tags, 
but toxml() serializes them to the XML empty element (), so 
the checksum winds up not matching.

Is there some parsing mechanism (using PyXML or any other freely usable 
3rd party library is an option) that will allow me to accomplish this? 
Or am I best off sticking with my little string scanning function?

TIA,
Michael

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stdin -> stdout

2005-08-19 Thread Steven Bethard
gry@ll.mit.edu wrote:
> import sys
> for l in sys.stdin:
> sys.stdout.write(l)

This is fine if you don't need the reads and writes of lines to run in 
lockstep.  File iterators read into a buffer, so you'll probably read 
4096 bytes from stdin before you ever write a line to stdout.  If that's 
okay, this is a good solution.  OTOH, if you want the reads and writes 
to run in lockstep, you should probably use this idiom:

import sys
for line in iter(sys.stdin.readline, ''):
 sys.stdout.write(line)

STeVe

P.S. You may also be able to get your version working using the -u 
(unbuffered) option to Python, but I couldn't.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: certificate-based authentication (Martin v. Löwis)

2005-08-19 Thread Dennis . Hoffman
> The standard xmlrpclib should work fine. You need to inherit from the
> SafeTransport class, overriding get_host_info to return the x509_info.
> You then pass an instance of your transport to the ServerProxy.


Ok - I have upgraded to the newer version of xmlrpclib that has the
'get_host_info' method.  I have created a new class (inherited from the
SafeTransport class), and overriden the get_host_info method.  So my
question now is where does the the x509_info come from?  Is that the
key/certificate comming back from the server?  If so, how do I get that?
If not, then where does it come from?  You must excuse my ignorance, as
this is all fairly new to me, and am still in the learning phase.
Thanks
Dennis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some questions

2005-08-19 Thread Magnus Lycka
Thomas Ganss wrote:
> My blind guess would have been that Tkinter was *not* the GUI of choice
> for *J*ython. 

With Jython you'd probably use Swing or SWT. It's certainly less
coding to get something working in Jython/Swing than with Java/Swing,
but I suspect that there is a cost in runtime performance which
might be a problem in some cases.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: determine variable type

2005-08-19 Thread Magnus Lycka
[EMAIL PROTECTED] wrote:
> trying to determine a variable type, specifically that a variable is an 
> integer.
> 
> i tried using type(var) but that only seemed to produce a response in the 
> command line.

You mean that if you do "type(var)" at the Python prompt, it gives
you a reply, but if you have a line with just that in a script, it
doesn't?

That has nothing to do with type checks. All Python expressions in
Python work like that. In interactive use, unused results are echoed
to the screen, but in scripts, they are not. How would you expect
the echoed value to be useful in your program?

In a script, you need to take care of the output of an expression
to get any use from it. A standalone expression on a line of its
own is legal Python code, but the result is thrown away... E.g.

var = 6
type(var) # Works, but meaningless, noone will know what happened
print type(var) # Like the interactive use (more or less)
var_type = type(var) # Now you have a variable containing the result
  # of the expression. You can use that later
if type(var) == int: # You can use the result in another construct...
 print "%i is an integer!" % var

But don't worry so much about type checking. That's typically not
so important in Python as is is in most other languages, in fact, if
you try to handle types too strictly in Python, you are throwing away
a lot of the benefits of Python's dynamic features.

Perhaps your code is useful with other types than integers, such as
the new decimal type or some upcoming money type. That typecheck might
just make it impossible to use your code in some completely meaningful
way. If you just did nothing, your code would probably throw an
exception if 'var' had a type that didn't make sense, and handling
that exception is probably not more difficult than to handle whatever
action you planned to take if var wasn't an int...

Python is much stricter in its type handling than e.g. C++, so don't
worry so much. Trying to add a string to an int etc, will raise a
sensible exception. It won't lead to any program crash or give any
bizarre result to your calculations.

If you're sanitizing user input, that's a good thing of course, but
then the safe thing would be to read strings (e.g. via raw_input) and
then inspect the string before you evaluate it or cast it to something
else. Actually, int() does this pretty well, so you could just do:

.while 1: # Loop until broken out of...
.response = raw_input('Number please: ')
.try:
.var = int(response)
.break
.except ValueError:
.print response, 'isn't a number!'



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stdin -> stdout

2005-08-19 Thread Steven Bethard
max(01)* wrote:
> i was wondering, what's the simplest way to echo the standard input to 
> the standard output, with no modification.

import sys
for line in iter(sys.stdin.readline, ''):
 sys.stdout.write(line)

Note that this uses the second form of iter(), which calls its first 
argument repeatedly until it returns the sentinel value (its second 
argument).

STeVe
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for Webscripting (like PHP)

2005-08-19 Thread Florian Lindner
Florian Lindner wrote:

> Hello,
> I've been using Python a lot for scripting (mainly scripts for server
> administration / DB access). All these scripts were shell based.
> 
> Now I'm considering using Python (with mod_python on Apache 2) for a web
> project, just how I've used PHP in some smaller Projects before ( print "foo" ?>)..
> 
> How suitable is Python for these kind of projects? What do think? Does the
> stdlib offers all basic functions for this kind of requirements?

An email I got from Dan Richter. Since he has problems with his news/mail
gateway I forward it with his permission for the benefit of others.

Florian

- - -

Python is great for "heavy lifting": when most of the work is done
behind the scenes and outputting the HTML is relatively trivial. An
example would be a program that searches archives or computes
derivatives.

But PHP is designed for web pages and is quite powerful. If you can
reasonably do a job in PHP, you probably should. Web sites written in
Python usually involve lots of statements like these:
  uri = os.environ['HTTP_URI']
  print '' + theTitle + ''
  print '''
  The answer to your question
  After lots of computing, here's what 
 we discovered.'''
And so on. As you can see, PHP allows you to embed HTML much more
gracefully, as well do other web-like things such as retrieve URL query
string parameters more easily. So PHP is preferable for most web sites.

Depending on what you want to do, you might also consider Perl and Java
Servlets.

- - -
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while c = f.read(1)

2005-08-19 Thread Steven Bethard
Antoon Pardon wrote:
> But '', {}, [] and () are not nothing. They are empty containers.
> And 0 is not nothing either it is a number. Suppose I have
> a variable that is either None if I'm not registered and a
> registration number if I am. In this case 0 should be treated
> as any other number.

This is why None is a singleton::

 if registration_number is None:
 # do one thing
 else:
 # do another

In the OP's case, if file.read() had happened to return None instead of 
the empty string, he probably would've wanted to do the same thing. 
OTOH, people on python-dev have said that the file.read() idiom of 
returning '' when it's done should be replaced by a true iterator, i.e. 
using StopIteration.  (I don't know the details of exactly how things 
would change, but I suspect this is something that will happen in Python 
3.0.)

STeVe
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stdin -> stdout

2005-08-19 Thread gry
import sys
for l in sys.stdin:
sys.stdout.write(l)

-- George

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie Question

2005-08-19 Thread gry
Yes, "eval" of data from a file is rather risky.  Suppose someone gave
you
a file containing somewhere in the middle:
...
22,44,66,88,"asd,asd","23,43,55"
os.system('rm -rf *')
33,47,66,88,"bsd,bsd","23,99,88"
...

This would delete all the files in your directory!

The csv module mentioned above is the tool of choice for this task,
especially if
there are strings that could contain quotes or commas.  Doing this
right is not
at all easy.  If you really want to roll your own, and the data is
KNOWN to be fixed
and very restricted, you can do something like:

"myfile" contains:
13,2,'the rain',2.33
14,2,'in spain',2.34

for l in open('myfile'):
x,y,comment,height = l.split(',')
x=int(x)
y=int(y)
height=int(height)
comment=comment.strip("' ") # strip spaces and quotes from front
and back

but beware this will break if the comment contains commas.

-- George

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie Question

2005-08-19 Thread Sion Arrowsmith
Tom Strickland <[EMAIL PROTECTED]> wrote:
>I have a file that contains many lines, each of which consists of a string 
>of comma-separated variables, mostly floats but some strings. Each line 
>looks like an obvious tuple to me. How do I save each line of this file as a 
>tuple rather than a string? Or, is that the right way to go?

Depending on exactly what format you've got, either .split(',') on
the line, or if this is insufficient look at the csv module. You'll
then need some way of turning the list of strings both of these
will give you into the mixed float/string tuple you want, which
could be somewhat tedious. Without knowing what these lines look
like, or what they represent, I can't begin to guess how you might
go about it. Actually, I can -- I'd start by considering whether a
dict might be more appropriate than a tuple and use csv.DictReader.

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: stdin -> stdout

2005-08-19 Thread Dan Sommers
On Fri, 19 Aug 2005 15:26:27 GMT,
"max(01)*" <[EMAIL PROTECTED]> wrote:

> ps: in perl you ca do this:

> ...
> while ($line = )
>{
>  print STDOUT ("$line");
>}
> ...

import fileinput
import sys

for line in fileinput.input():
sys.stdout.write(line)

Regards,
Dan

-- 
Dan Sommers

-- 
http://mail.python.org/mailman/listinfo/python-list


BeautifulSoup

2005-08-19 Thread Steve Young
I tried using BeautifulSoup to make changes to the url
links on html pages, but when the page was displayed,
it was garbled up and didn't look right (even when I
didn't actually change anything on the page yet). I
ran these steps in python to see what was up:

>>from BeautifulSoup import BeautifulSoup
>>from urllib2 import build_opener, Request
>>
>>req = Request('http://www.python.org/')
>>f = build_opener().open(req)
>>page = f.read()
>>f.close()
>>
>>len(page)
12040
>>
>>soup = BeautifulSoup()
>>soup.feed(page)
>>page2 = soup.renderContents()
>>len(page2)
11889

I have version 2.1 of BeautifulSoup. It seems that
other ppl have used BeautifulSoup and it works fine
for them so I'm not sure what I'm doing wrong. Any
help would be appreciated, thanks.

-Steve




Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie Question

2005-08-19 Thread BranoZ
[EMAIL PROTECTED] wrote:
> >>> x = '22,44,66,88,"asd,asd","23,43,55"'
> >>> y = eval(x)
> >>> y
> (22, 44, 66, 88, 'asd,asd', '23,43,55')
>
> And now, a question for the experts.

I'm no expert, just experienced.

> Does anyone have a pointer as to why my code might be
> dangerous?

Well, the smallest problem you have here is that you will
get an SyntaxError exception on badly formated input.

x = 'z,22,44,66,88,"asd,asd","23,43,55"'
eval(x)
NameError: name 'z' is not defined

In worse case, somebody will send you a carefuly formated
input that you will run blindy (just like in case of buffer
overflows).

CSV is easy with the module..

import csv

cr = csv.reader((x,))
print cr.next()
['z', '22', '44', '66', '88', 'asd,asd', '23,43,55']

Usually, you will use the csv module, like this:

import csv, sys

for line in csv.reader(sys.stdin):
  # print line[3]

BranoZ

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: global interpreter lock

2005-08-19 Thread Bryan Olson
km wrote:
 > Hi all,
 >
 > is true parallelism possible in python ? or atleast in the
 > coming versions ? is global interpreter lock a bane in this
 > context ?

No; maybe; and currently, not usually.

On a uniprocessor system, the GIL is no problem. On multi-
processor/core systems, it's a big loser.


-- 
--Bryan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stdin -> stdout

2005-08-19 Thread limodou
2005/8/19, max(01)* <[EMAIL PROTECTED]>:
> hi.
> 
> i was wondering, what's the simplest way to echo the standard input to
> the standard output, with no modification.
> 
> i came up with:
> 
> ...
> while True:
>try:
>  raw_input()
>except EOFError:
>  break
> ...
> 
> but i guess there must be a simpler way.
> 
> using bash i simply do 'cat', *sigh*!
> 
> bye
> 
> max
> 
> ps: in perl you ca do this:
> 
> ...
> while ($line = )
>{
>  print STDOUT ("$line");
>}
> ...

Try this.

import sys

line = sys.stdin.readline()
while line:
sys.stdout.write(line)
line = sys.stdin.readline()

-- 
I like python! 
My Donews Blog: http://www.donews.net/limodou
-- 
http://mail.python.org/mailman/listinfo/python-list


stdin -> stdout

2005-08-19 Thread max(01)*
hi.

i was wondering, what's the simplest way to echo the standard input to 
the standard output, with no modification.

i came up with:

...
while True:
   try:
 raw_input()
   except EOFError:
 break
...

but i guess there must be a simpler way.

using bash i simply do 'cat', *sigh*!

bye

max

ps: in perl you ca do this:

...
while ($line = )
   {
 print STDOUT ("$line");
   }
...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: global interpreter lock

2005-08-19 Thread Gregory Piñero
KM,



I eagerly await the answer to this question as well.  I'd love to
see this explained in laymen's terms.  From what I understand of
this issue, your best bet for getting parrelism is to use whatever the
OS provides and just have multiple python instances running... but then
I didn't understand the articles I've read about this so don't listen
to me.



-Greg
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python jobs (was Re: Python for Webscripting (like PHP))

2005-08-19 Thread Gregory Piñero
I'd love Python work, just like everyone else here.  On a related
topic, what's the policy/etiquette of posting a resume on here, or
mentioning what kind of work you're looking for?  And what's the
policy in general for most newsgroups and mailing lists?

-Greg
On 8/19/05, Steve Holden <[EMAIL PROTECTED]> wrote:
Aahz wrote:> In article <[EMAIL PROTECTED] >,> Steve Holden  <
[EMAIL PROTECTED] > wrote:>>>There's informal evidence that the Python secret is getting out. Sharpen>>up your resumes, guys, you may not have to limit Python to home usage>>soon :-)
>>> OTOH, the big sucking sound from Google and Yahoo (plus other places> like Ironport) is making it more difficult to hire Python programmers in> the Bay Area...Not to mention the large Python gravity field a few hundred miles South
emanating from Industrial Light and Magic.But don;t expect "Google and Yahoo suck" to be a popular compaint ;-)regards  Steve--Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/ --http://mail.python.org/mailman/listinfo/python-list
 -- Gregory PiñeroChief Innovation OfficerBlended Technologies(www.blendedtechnologies.com)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Save Binary data.

2005-08-19 Thread Benjamin Niemann
GMane Python wrote:

> Hello All.
>   I have a program that downloads 'gigabytes' of Axis NetCam photos per
>   day.
> Right now, I set up the process to put the images into a queue, and every
> 30
> or so seconds, 'pop' them from the queue and save them to disc.   I save
> them as individual files.
> 
>   I think that I'd like to modify it to save into one file 100-200 images,
> so that I don't have directories with 50,000-90,000 frames before handing
> that off to a DivX Encoder.
> 
>   I don't know if I need to use something like cPickle, or maybe just save
> them as a binary data file (which would be a temp file until later in the
> day when I open it to begin the encoding process.)
> 
> Can someone please help me with some direction?

You could use the tarfile module to create a single file holding a arbitrary
number of files - including compression, if you want, but if your images
are JPEGs then further compression is mostly a waste of CPU cycles. You can
extract the images later on with either a python script and tarfile or
using the standard commandline tool 'tar'.

If the images are uncompressed anyway, you could have a look at the netpbm
suite and its fileformat (which is pretty simple, but uncompressed and
would bloat JPEGs to a multiple of the original filesize) which supports
'image sequences'. Perhaps a DivX encoder could even support this
fileformat directly as input.

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Netware Python?

2005-08-19 Thread Larry Bates
I'm not really up on Netware, but I believe that Netware's
Open Enterprise Server is based on Suse Linux as the
underlying OS, so Python should run there just fine.

Google turned up the following that you might want to review:

http://www.python.org/workshops/2000-01/proceedings/papers/clements/clements.html
http://forge.novell.com/modules/xfmod/project/?jythonnwkit
http://www.novell.com/products/openenterpriseserver/

Larry Bates

GMane Python wrote:
> Hello all.  Looking, I have not found a version of Python which runs on
> Netware by Novell.  I wonder, since Java there is a Java for Netware, is
> this where Jython would come in as useful, to be able to use a Python script
> where Java is installed?
> 
> I'm interested in the threaded heartbeat program in the cookbook for my
> Netware environment, to be connected to a nice graphical front end on my
> Win32 station, to know when servers are up or down (well, since Netware is
> hardly ever down, when the WAN links are up or down)
> 
> -dave
> 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Save Binary data.

2005-08-19 Thread Larry Bates
Images are binary data, don't do anything to them just save them
to files on disk in their binary format.  The extra processing of
pickling them isn't going to help.  Directories with large
numbers of files was a problem in FAT16 and FAT32 filesystems but
not really a problem in NTFS or Linux (at least that I've found).
Appending 100-200 images together into a single file will surely
cut down on the number of files.  A lot depends on what the next
step in the process is expecting (e.g. individual files or a
a stream of data).  If it is individual files, you will have to
split them back apart anyway so keeping them as individual files
is a benefit.

Larry Bates

GMane Python wrote:
> Hello All.
>   I have a program that downloads 'gigabytes' of Axis NetCam photos per day.
> Right now, I set up the process to put the images into a queue, and every 30
> or so seconds, 'pop' them from the queue and save them to disc.   I save
> them as individual files.
> 
>   I think that I'd like to modify it to save into one file 100-200 images,
> so that I don't have directories with 50,000-90,000 frames before handing
> that off to a DivX Encoder.
> 
>   I don't know if I need to use something like cPickle, or maybe just save
> them as a binary data file (which would be a temp file until later in the
> day when I open it to begin the encoding process.)
> 
> Can someone please help me with some direction?
> 
> 
> Thank you!
> Dave
> 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Newbie Question

2005-08-19 Thread Michael . Coll-Barth
Tom,

Well, as one newbie to another, I tried this;

>>> x = '22,44,66,88,"asd,asd","23,43,55"'
>>> y = eval(x)
>>> y
(22, 44, 66, 88, 'asd,asd', '23,43,55')

given that x some how comes from a single line in your file.

BTW, do you get the tutor list as well?  My guess is that the 'experts' over
here might prefer that the newbies go over there for stuff like this.  

And now, a question for the experts.  Does anyone have a pointer as to why
my code might be dangerous?  I get the feeling that eval might not be a
'good' ( safe ) thing to use.

Michael

-Original Message-
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
n.org]On Behalf Of Tom Strickland
Sent: Friday, August 19, 2005 10:05 AM
To: python-list@python.org
Subject: Newbie Question


I have a file that contains many lines, each of which consists of a string 
of comma-separated variables, mostly floats but some strings. Each line 
looks like an obvious tuple to me. How do I save each line of this file as a

tuple rather than a string? Or, is that the right way to go?

Thank you.

Tom Strickland 


-- 
http://mail.python.org/mailman/listinfo/python-list
___
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie Question

2005-08-19 Thread Gabriel Cooper
look into the csv module. (for comma-separated-value text files.)

Tom Strickland wrote:

>I have a file that contains many lines, each of which consists of a string 
>of comma-separated variables, mostly floats but some strings. Each line 
>looks like an obvious tuple to me. How do I save each line of this file as a 
>tuple rather than a string? Or, is that the right way to go?
>
>Thank you.
>
>Tom Strickland 
>  
>

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implementing class methods in C

2005-08-19 Thread nmichaud

> If you implement _test in C, works none of the above.
> The only difference I can see is that:

> type(_test.func2)
> 
> is for Python implemented function and

> type(_test.func2)
> 
> for C implementation

> I would really like to know the answer too.
> How do you implement some methods in C without subclassing ?


But the strange thing is if I use new.instancemethod the c function
becomes bound (using my previous code for _test.c)

import _test

class Test:
def func1(self):
print "In class "+repr(self.__class__.__namd__)

import new
Test.func2 = new.instancemethod(_test.func2, None, Test)
del new

t = Test
type(_test.func2)   # returns 
type(T.func1)   # returns 
type(t.func1)   # returns >
type(T.func2)   # returns 
type(t.func2)   # returns >

So is seems like it is bound appropriately, but when called across the
C/Python api the first argument (self) of func2 is not separated
from the other arguments (and thus is not sent into the c
function as PyObject* self, but instead as part of PyObject* args)
-- 
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Aug 18)

2005-08-19 Thread Cameron Laird
QOTW:  "It seems to me that Java is designed to make it difficult for
programmers to write bad code, while Python is designed to make it
easy to write good code." -- Magnus Lycka

"Code attracts people that like to code. Tedious, repetitive c.l.py
threads attract people that like to write tedious, repetitive c.l.py
threads." -- Robert Kern


Yes, commercial Python training *is* available:

http://groups.google.com/group/comp.lang.python.announce/msg/f1bd9b8deac1cb39

You know how essential the Cookbook is.  Filling a slightly
different role is the Grimoire:
http://the.taoofmac.com/space/Python/Grimoire

The latest SPE "features a remote, encrypted and embedded
... debugger ...":
http://pythonide.stani.be

Paul Dale convincingly advertises O'Reilly's Safari service:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/115a242dc77b0057/

Python is a superb vehicle for several niches generally 
thought exclusive to other languages, such as automation
of Windows processes.  Another too-little-known such 
strength is Python's adeptness with native Mac OS X 
applications:  
http://developer.apple.com/cocoa/pyobjc.html

mensanator introduces enough of bit arithmetic to explain
popcount and Hamming distance:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/e0716ffcf80af3a2/

PEP editors David Goodger and Barry Warsaw refine PEP
organization:
http://mail.python.org/pipermail/python-list/2005-August/294467.html



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/   

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance. 
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all
The old Python "To-Do List" now lives principally in a
SourceForge reincarnation.
http://sourceforge.net/tracker/?a

RE: Adobe COM with Python

2005-08-19 Thread Tim Golden
[Andy W]
| I wanting to print the PDF to a printer which is set to print 
| to file, 
| so efectively i end up with a ps file.
| 
| so 1 pdf becomes 1 ps file

It't not quite clear to me what you *want* to do as opposed
to what actually happens when you try. If I understand, you
have a PDF file, and you *want* to output it as a Postscript
file. (And you want to automate that arrangement).

If that's the case, I can think of two approaches, neither using
COM -- which may be a valid third approach. The first is to use
the possibly deprecated Acrobat Reader command-line switches to
print a file and pass a file name. There's some information here:

http://www.stillhq.com/ctpfaq/2002/03/c45.html#AEN103

and if you want to get hold of an older version of Acrobat,
try oldversion.com

The second is to use ghostscript from

http://www.cs.wisc.edu/~ghost/

to generate a ps file from a pdf file.

Hope that helps.
TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python html

2005-08-19 Thread Fuzzyman
I do exactly that in my Python CGI proxy (approx). I wrote a very
simple parser called scraper.py that makes it easy.

It won't choke on bad html either.

http://www.voidspace.org.uk/python/recipes.shtml

All the best,

Fuzzyman
http://www.voidspace.org.uk/python

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: global interpreter lock

2005-08-19 Thread Grant Edwards
On 2005-08-20, km <[EMAIL PROTECTED]> wrote:

> is true parallelism possible in python?

No, not for some values of "true parallelism".

> or atleast in the coming versions?

Not that I'm aware of.

> is global interpreter lock a bane in this context?

In what context?

-- 
Grant Edwards   grante Yow!  I think I'll do BOTH
  at   if I can get RESIDUALS!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adobe COM with Python

2005-08-19 Thread Andy W
I wanting to print the PDF to a printer which is set to print to file, 
so efectively i end up with a ps file.

so 1 pdf becomes 1 ps file

Tim Golden wrote:
> [Andy W]
> 
> | What i want to do is use, python COM to fireup Adobe and 
> | print the pdf 
> | file to a printer.
> 
> If that's all you want to do, have a look at this:
> 
> http://timgolden.me.uk/python/win32_how_do_i/print.html
> 
> Or you could try for a Ghostscript solution.
> 
> (Additionally, I seem to remember that the Acrobat COM object is
> really only designed to work in Internet Explorer. That was a version
> or so ago -- of both -- so I may be off beam).
> 
> TJG
> 
> 
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GIS Related Scripting Issue

2005-08-19 Thread Dan Patterson
you might want to try
http://forums.esri.com/forums.asp?c=93
and post in the geoprocessing section with code details
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Mike Rose wrote:
>
>> I am currently using ArcGIS 9.1 and was referred to this list to ask my
>> question.  I am using a python script to loop through a series of
>> features, select all polygons that are within 5 miles, run statistics on
>> those selected polygons, then append the values to a new database(dbf).
>> I am not sure if I am going about this correctly or not, but my script
> < is definitely not working.  I am getting an error when it tries to
>> append to the dbf.
>
> can you perhaps post the error message?
>
> 
>
> 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Module Name Conflicts

2005-08-19 Thread Rocco Moretti
[EMAIL PROTECTED] wrote:
> I have a java program in a package called 'cmd'. This of course
> conflicts with the builtin python package of the same name. The thing
> is, I need to be able to import from both of these packages in the same
> script. I can import either one first, but any future attempt to import
> from cmd.* will look up the first cmd that was imported, so the second
> package is essentially eclipsed. I've tried fiddling with sys.path and
> sys.packageManager.searchPath, to no avail. To answer the obvious first
> suggestion, no I can't rename the java package to 'Cmd' or anything
> like that. Any ideas?
> 
> -Smurf

Never used it myself, but you can try to use the builtin 'imp' module.

Python Library Reference
3.21 imp -- Access the import internals

This module provides an interface to the mechanisms used to implement 
the import statement. It defines the following constants and functions:

...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Database of non standard library modules...

2005-08-19 Thread Jeff Schwab
Steve Holden wrote:
> Robert Kern wrote:
> 
>> Jon Hewer wrote:
>>
>>> Is there an online database of non standard library modules for Python?
>>
>>
>>
>> http://cheeseshop.python.org/pypi
>>
> While cheeseshop might resonate with the Monty Python fans I have to say 
> I think the name sucks in terms of explaining what to expect. If I ask 
> someone where I can find a piece of code and the direct me to the cheese 
> shop, I might look for another language.

I think it's just meant to be a handy moniker.  An acronym like CPAN 
doesn't exactly clear everything up in one shot, either, but at least 
other Perl users know what you mean when you say it.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Adobe COM with Python

2005-08-19 Thread Tim Golden
[Andy W]

| What i want to do is use, python COM to fireup Adobe and 
| print the pdf 
| file to a printer.

If that's all you want to do, have a look at this:

http://timgolden.me.uk/python/win32_how_do_i/print.html

Or you could try for a Ghostscript solution.

(Additionally, I seem to remember that the Acrobat COM object is
really only designed to work in Internet Explorer. That was a version
or so ago -- of both -- so I may be off beam).

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie Question

2005-08-19 Thread Tom Strickland
I have a file that contains many lines, each of which consists of a string 
of comma-separated variables, mostly floats but some strings. Each line 
looks like an obvious tuple to me. How do I save each line of this file as a 
tuple rather than a string? Or, is that the right way to go?

Thank you.

Tom Strickland 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adobe COM with Python

2005-08-19 Thread Andy W
What i want to do is use, python COM to fireup Adobe and print the pdf 
file to a printer.

import win32com.client
import pythoncom

pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMENTTHREADED)
acro = win32com.client.DispatchEx('PDF.PdfCtrl.1')


The above does not work, Do i need to install the SDK as well ?

I'm new to this COM stuff as you can guess.

Benjamin Niemann wrote:
> Andy W wrote:
> 
> 
>>I'm wanting to automate Adove Acrobat Reader using Com thru Python and
>>win32com, but i can't find any documentation for the Adobe stuff? Has
>>anyone done anything with Acrobat COM ?
>>
>>I've searched Google groups and the web but am unable to find anything.
> 
> 
> I have not hacked Acrobat yet, but done a bit with InDesign - Adobe's
> documentation is less than perfect, but still pretty good. You might look
> at
> 
> - in InDesign I could easily map the methods and attributes from the JS
> documentation to COM calls (the JS members start with lowercase - e.g.
> 'properties' -, while COM need uppercase - 'Properties').
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >