[issue44624] Script name for venv PowerShell activate

2021-07-13 Thread Paul Watson


New submission from Paul Watson :

In the venv .\Scripts directory. the name 'Activate.ps1' does not conform to 
the PowerShell prescribed Verb-Noun format.

How about using 'Initialize-Python.ps1' as the script name? Or, something else 
that does conform to PowerShell standard naming.

--
components: Installation
messages: 397416
nosy: Paul Watson
priority: normal
severity: normal
status: open
title: Script name for venv PowerShell activate
type: enhancement

___
Python tracker 
<https://bugs.python.org/issue44624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42798] pip search fails

2020-12-31 Thread Paul Watson


New submission from Paul Watson :

Fresh install of 3.9.1
Created venv
Activated venv

(py3.9) 13:12:59.52  C:\venv\py3.9\Scripts
C:>pip search astronomy
ERROR: Exception:
Traceback (most recent call last):
  File "c:\venv\py3.9\lib\site-packages\pip\_internal\cli\base_command.py", 
line 228, in _main
status = self.run(options, args)
  File "c:\venv\py3.9\lib\site-packages\pip\_internal\commands\search.py", line 
60, in run
pypi_hits = self.search(query, options)
  File "c:\venv\py3.9\lib\site-packages\pip\_internal\commands\search.py", line 
80, in search
hits = pypi.search({'name': query, 'summary': query}, 'or')
  File 
"C:\Users\mike\AppData\Local\Programs\Python\Python39\lib\xmlrpc\client.py", 
line 1116, in __call__
return self.__send(self.__name, args)
  File 
"C:\Users\mike\AppData\Local\Programs\Python\Python39\lib\xmlrpc\client.py", 
line 1456, in __request
response = self.__transport.request(
  File "c:\venv\py3.9\lib\site-packages\pip\_internal\network\xmlrpc.py", line 
45, in request
return self.parse_response(response.raw)
  File 
"C:\Users\mike\AppData\Local\Programs\Python\Python39\lib\xmlrpc\client.py", 
line 1348, in parse_response
return u.close()
  File 
"C:\Users\mike\AppData\Local\Programs\Python\Python39\lib\xmlrpc\client.py", 
line 662, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: https://status.python.org/ for more information.">

(py3.9) 13:13:08.09  C:\venv\py3.9\Scripts
C:>python --version
Python 3.9.1

--
components: Demos and Tools
messages: 384133
nosy: Paul Watson
priority: normal
severity: normal
status: open
title: pip search fails
type: crash
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue42798>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35801] venv in 3.7 references python3 executable

2019-01-21 Thread Paul Watson


New submission from Paul Watson :

The documentation for venv in Python 3.7 references using `python3` to run 
venv. I do not find a `python3` executable in the kit.

https://docs.python.org/3.7/library/venv.html#module-venv

--
assignee: docs@python
components: Documentation
messages: 334165
nosy: Paul Watson, docs@python
priority: normal
severity: normal
status: open
title: venv in 3.7 references python3 executable
type: enhancement
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue35801>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32553] venv says to use python3 which does not exist in 3.6.4

2018-01-15 Thread Paul Watson

Paul Watson <paul.hermeneu...@gmail.com> added the comment:

Ok, I do find later on where it says to do something different on Windows. 
However, the first "Note" box in "28.3. venv" specifies using "python3". It 
does not say that this is for non-Windows systems. This should be changed.

Also, the path specified, "c:\Python35\python", would not be the default 
location for a Windows install. "C:\Program Files\Python36\python" or 
"C:\Program Files (x86)\Python36\python" should be specified.

I detest that it is this complex and verbose, but it is. Glossing over it does 
not help the user.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32553>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32553] venv says to use python3 which does not exist in 3.6.4

2018-01-15 Thread Paul Watson

Paul Watson <paul.hermeneu...@gmail.com> added the comment:

I am running 3.6.4 from a download on pythong.org yesterday.

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit 
(AMD64)] on win32

There is a python3.dll, but no python3 executable.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32553>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32553] venv says to use python3 which does not exist in 3.6.4

2018-01-14 Thread Paul Watson

New submission from Paul Watson <paul.hermeneu...@gmail.com>:

The 3.6.4 documentation on venv specifies using 'python3', but no python3 
executable is in the 3.6.4 kit.

https://docs.python.org/3/library/venv.html?highlight=venv#module-venv

--
assignee: docs@python
components: Documentation
messages: 309943
nosy: Paul Watson, docs@python
priority: normal
severity: normal
status: open
title: venv says to use python3 which does not exist in 3.6.4
type: enhancement
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32553>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Django or web2py

2011-09-08 Thread Paul Watson

I have read some of the talk around these two frameworks.

Would you say that web2py is more geared toward the enterprise?

Which one do you believe will be on Python 3 more quickly?
--
http://mail.python.org/mailman/listinfo/python-list


Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?

2010-11-11 Thread Paul Watson

On 2010-11-11 11:20, Stef Mientki wrote:

On 11-11-2010 19:01, Steve Holden wrote:

On 11/11/2010 9:22 AM, Stef Mientki wrote:

hello,

finally got Python running at my server.

Now I would like to replace the PHP server scripts with Python ( for easier 
maintenance).

But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ?
Google finds lots of links, but I can't find the answer.

thanks,
Stef Mientki

Stef:

Moving from one language to anther is not just a matter of
transliterating the code. Of you try that you will end up with a messy
code base that looks like PHP written in Python.

Steve I agree with you,
but  replacing a number of 3 to 10 lines of code scripts won't create a mess ;-)

cheers,
Stef

regards
  Steve


If there is no automated process to do the translation, then it should 
be avoided.  It is an opportunity for chaos to ensue.

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


Re: How do I skip over multiple words in a file?

2010-11-11 Thread Paul Watson

On 2010-11-11 08:07, chad wrote:

Let's say that I have an article. What I want to do is read in this
file and have the program skip over ever instance of the words the,
and,  or, and but. What would be the general strategy for
attacking a problem like this?


I realize that you may need or want to do this in Python.  This would be 
trivial in an awk script.

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


distutils, cygwin, 'not a regular file'

2010-09-14 Thread Paul Watson
So, what is not a regular file about this?  Is there any way to find out 
which files are being considered irregular?


$ uname -a
CYGWIN_NT-6.0-WOW64 pwatson 1.7.7(0.230/5/3) 2010-08-31 09:58 i686 Cygwin

$ cat setup.py

from distutils.core import setup

setup(
name='xlsexport',
version='0.3',

py_modules=['xlsexport']
)
20:47 pwatson [ pwatson:/cygdrive/c/Users/pwatson/bin/xlsexport] 12
$ python setup.py sdist
running sdist
warning: sdist: missing required meta-data: url
warning: sdist: missing meta-data: either (author and author_email) or 
(maintainer and maintainer_email) must be supplied

reading manifest file 'MANIFEST'
creating xlsexport-0.3
making hard links in xlsexport-0.3...
' not a regular file -- skipping
' not a regular file -- skipping
' not a regular file -- skipping
tar -cf dist/xlsexport-0.3.tar xlsexport-0.3
gzip -f9 dist/xlsexport-0.3.tar
removing 'xlsexport-0.3' (and everything under it)
--
http://mail.python.org/mailman/listinfo/python-list


Current install methodolgy eggs?

2010-09-12 Thread Paul Watson

What is the currently favored installation process for Python applications?

The last time I looked, it was eggs.  Is that still true?  Is there any 
integration of eggs and handling into the base Python distribution?  Is 
PEP 376 intended for applications written in Python, or just the Python 
distribution?


Any good links to source of information.  I would like to instill the 
habit of using a decent install process for even the smallest of utilities.

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


Re: Current install methodolgy eggs?

2010-09-12 Thread Paul Watson

On 2010-09-12 16:40, Ben Finney wrote:

This is a dream shared by many, but Distutils has much improvement to be
done yet. Recently — the past couple of years — a lot of progress has
been made on this front, and Python 3.x is getting many of the benefits;
look up the “Distutils2” efforts for more.


Many thanks for your comments, Ben.  Looks like I should learn distutils 
well.


I see the distutils2 work going on.  I hope it is designed to work with 
Python 2.x.  That would help it get some traction in existing packages.


Most platforms have an installation methodology.  Oracle Solaris (yea, 
hard for me to get use to as well) has pkgadd.  Microsoft has the .msi 
installer.  Do you think it would be possible to create a toolset that 
would produce installation kits in each of these forms?  That would make 
the install conform with the standard platform installer.  Is this 
worthwhile thinking about?

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


Re: llvm vs. parrot

2009-09-28 Thread Paul Watson
On Sun, 2009-04-12 at 06:18 -0700, Fuzzyman wrote:
 On Apr 11, 12:16 am, Paul Watson paul.hermeneu...@gmail.com wrote:
  Is Parrot out of favor these days?  It appears that Google is going to
  use llvm.
 
  http://code.google.com/p/unladen-swallow/
 
 Has Parrot ever been in favour?
 
 Actually they're quite different things.
 
 Michael
 --
 http://www.ironpythoninaction.com/

Are you saying they are quite different because llvm gets compiled
into native code and Parrot bytecode is still interpreted?

At the intermediate form, they seem quite similar.  Why do you say not?

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


Re: Can I replace this for loop with a join?

2009-06-21 Thread Paul Watson
On Mon, 2009-04-13 at 17:03 +0200, WP wrote:
 Hello, I have dictionary {1:astring, 2:anotherstring, etc}
 
 I now want to print:
 Press 1 for astring
 Press 2 for anotherstring etc
 
 I could do it like this:
 dict = {1:'astring', 2:'anotherstring'}
 for key in dict.keys():
  print 'Press %i for %s' % (key, dict[key])
 
 Press 1 for astring
 Press 2 for anotherstring
 
 but can I use a join instead?
 
 Thanks for any replies!
 
 - WP

In addition to the comments already made, this code will be quite broken
if there is ever a need to localize your package in another language.

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


GNUstep and Python

2009-06-21 Thread Paul Watson
Has anyone used GNUstep?

In addition to Objective-C, there are Java and Ruby bindings.

Has anyone created a Python binding to GNUstep?

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


llvm vs. parrot

2009-04-11 Thread Paul Watson
Is Parrot out of favor these days?  It appears that Google is going to
use llvm.

http://code.google.com/p/unladen-swallow/

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


Re: Tkinter book on current versions

2009-03-22 Thread Paul Watson
On Sat, 2009-03-21 at 08:10 -0700, W. eWatson wrote:
 Paul Watson wrote:
  Has anyone tried the Grayson book, Python and Tkinter Programming,
  with a recent version of Python?
  
  The first example code (calculator) generates a single row of buttons.
  Perhaps I have not applied the errata correctly.  Has anyone been
  successful?
  
  I am using:
  
  Python 2.5.2 (r252:60911, Dec  1 2008, 17:47:46)
  
 If you mean calc1.py, I had no trouble with calc1.py under 2.5, but calc2.py 
 uses Pmw, which I do not have. calc2 has a few problems with mixing tabs and 
 blanks.

Ok.  It works.  I did not type it in correctly.  Thanks for your
confirmation that it does work.

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


Re: Using python 3 for scripting?

2009-03-22 Thread Paul Watson
On Sun, 2009-03-22 at 17:00 +, Timo Myyrä wrote:
 Ok, I think I'll stick with the 2.6 then. I recall it gave 
 warnings about things that are deprecated in 3.0 so it will make 
 porting the scripts to 3.0 easier. 
 
 I might try 3.0 once I know what kind of scripts are needed.

Yes.  Develop your code using 2.6, then use the '2to3' utility to port
it to 3.0.

As others have mentioned, there are -many- third party packages which
are not available for 3.0 yet.

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


Tkinter book on current versions

2009-03-20 Thread Paul Watson
Has anyone tried the Grayson book, Python and Tkinter Programming,
with a recent version of Python?

The first example code (calculator) generates a single row of buttons.
Perhaps I have not applied the errata correctly.  Has anyone been
successful?

I am using:

Python 2.5.2 (r252:60911, Dec  1 2008, 17:47:46)

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


Re: newbie: precision question

2009-03-20 Thread Paul Watson
On Sat, 2009-03-21 at 04:12 +0100, Lada Kugis wrote:
 I'm a newbie learning python, so forgive for, what may seem to some,
 like a stupid question.
 
 I understand the basic integer and fp type, but what I'm having a
 little trouble are the long type and infinite precision type.
 
 Also, when I do
 
  math.pi - (math.sqrt(math.pi))**2.
 
 I get
 
 4.4408920985006262e-016
 
 Please, could someone in just a few words, in newbie speak, explain
 why does that happen ? And what do the types actually mean ? What I
 mean, how can something have infinite precision but still not return
 zero as a result. (Btw, I always thought floating points had precision
 up to 8 significant digits, doubles 16).
 
 Nice regards
 Lada

The types used here are 'float'.

 math.pi
3.1415926535897931
 type(math.pi)
type 'float'

Floating point is inherently imprecise.  Whatever encoding is used to
represent the number will have a finite size.  That finite size puts a
limit on the precision available.

 1.0/3
0.1
 type(1.0/3)
type 'float'

Do you see how small a number the result represents

 print %2.32f % (4.4408920985006262e-016)
0.00044408920985006262

Have you tried this in any other programming languages?

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


Re: help I'm getting delimited

2008-12-16 Thread Paul Watson
On Tue, 2008-12-16 at 08:26 -0800, aka wrote:
 Hi, I'm going nuts over the csv.reader and UnicodeReader class.
 Somehow I can't get this method working which is supposed to read a
 csv file which name is inputted but here now hardcoded. What I need
 for now is that the string version of the list is put out for control.
 Later on I will only need to read the first column (id) of the csv
 file to be able to fill in a session var with a list of all ids.
 inp = c:/temp/test.csv
 roles = []
 try:
 fp = open(inp, 'rb')
 reader = csv.reader(fp)
 for r in reader:
 rollen.append(r)
 except:
 msg = Er is iets mis met de UnicodeReader
 
 return dict(file=in,roles=str(roles))
 Any help greatly appreciated!
 Cheers

Did you intend inside the loop to write:

roles.append(r)

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


Re: Running Python 2 and Python 3 on the same machine

2008-12-06 Thread Paul Watson
On Sat, 2008-12-06 at 10:57 +0100, Martin v. Löwis wrote:
  Ok.  I built the source on an openSUSE 11.0 system.  I used 'sudo make
  altinstll'.  It created an executable /usr/local/bin/python3.0 file.
  Nothing was touched in /usr/bin.
 
 Ah, then you missed the fun part. Take a look at the install: target
 in the Makefile.
 
  I need to start writing some code with Python 3.  I want to write the
  code in such a way that it can be easily shared with others with the
  least difficulty and overhead as possible.  How should I write the code
  to enable this?  What, if anything, should I assume about another
  system's configuration?
 
 I don't quite understand the problem. Sharing code is very easy over
 the internet. You can upload it on PyPI (say), or mail it. So you
 must be asking for something else.
 
  As someone suggested before, naming the files as '.py3' is probably a
  bad idea in the long run.  It also does not really solve the problem.
  
  I could use a shebang.  But, what should it specify?  If I use
  'python3.0', then that will soon be quite old.  If I make up a link for
  python3 - python3.0, that would work, but then every other system that
  is to run the code must that link also.  However, I am thinking that
  this would be the best long term answer.
 
 Well, this will be rejected. It might be a good medium-term answer, but
 it is a *bad* long-term answer. In the long term, Python 2 will
 disappear, and we are stuck with calling the interpreter python3.
 
  If I write scripts for Python 3, another developer writes scripts for
  Python 2, and a common customer wants to install both of our packages
  onto a single machine, then what is the best plan for everyone to make
  that happen with as little difficulty as possible?
 
 My recommendation is to use distutils, for a long-term answer. People
 will run python3.0 setup.py install, and distutils' install_scripts
 will replace the shebang line with the actual path to Python 3.0.
 This has not only the advantage of continuing to work for 3.1; it has
 also the advantage that scripts installed into a private location will
 be run by the correct interpreter (rather than relying on the
 interpreter being in /usr/bin, or on PATH).
 
 For quick sharing, the shebang line #!/usr/bin/env python3.0 will
 be enough. When Python 3.1 gets released, you may find yourself writing
 scripts that run only on Python 3.x for x=1 (i.e. won't run on 3.0,
 because you use a new feature in 3.1). In that case, presence of a
 python3 executable won't help, either.
 
 Regards,
 Martin

Yes!  Finally we are getting somewhere.  I can see how this can work for
distributed packages.  I still have two questions.

I do not mean to take your individual time for this.  If there is
documentation I should read, please suggest it.

First, let's say that the package has been installed using distutils and
the shebang line is set to '#!/usr/local/bin/python3.0'.  Now, Python
3.1 is released with a number of speed performance improvements and
several security fixes.  The existing application is hardcoded to use
Python3.0 directly.  Does distutils include any mechanism to update this
setting so that the package will use a different interpreter?

Must the application be installed again in order to update the shebang
lines?

Second, we frequently have a number of standalone utilities written in
Python.  When the task requires excessive effort to write in a shell
script, Python is a great answer.

What is your recommendation for the shebang line on one-off, single .py
file utility scripts?

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


Re: Running Python 2 and Python 3 on the same machine

2008-12-05 Thread Paul Watson
On Fri, 2008-12-05 at 02:10 +0100, Martin v. Löwis wrote:
  Since the source code is incompatible, I was expecting the Python
  executable to have a new name such as 'python3'
 
 It does: the executable is called python3.0.
 
  or for the default
  source code filename to change to '.py3' or something.
 
 Such a proposal would be rejected. In a few years from now, Python 2
 will be gone, and we would be stuck with an ugly file extension
 (similar to how \windows\system is now an empty directory, and
 \windows\system32 actually contains the 64-bit binaries on x64)-
 
 Regards,
 Martin

I have to agree with Terry; installing the released python-3.0.msi
results in an executable named 'python.exe' in the filesystem.  I have
not built it yet, but I assume the *NIX package results in a 'python'
executable file.

For a machine that runs existing Python 2.x applications, what should be
in the PATH variable?

For *NIX machines, will 'python' be placed into /usr/bin?  If so, then
the Python scripts that start out with a shebang like the following will
have difficulty.

#!/usr/bin/python
#!/usr/bin/env python

Has there been any guidance issued?

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


Re: Running Python 2 and Python 3 on the same machine

2008-12-05 Thread Paul Watson
On Sat, 2008-12-06 at 01:27 +0100, Martin v. Löwis wrote:
  For *NIX machines, will 'python' be placed into /usr/bin?
 
 Not by default, no. Just try it and see for yourself.
 
 Regards,
 Martin

Ok.  I built the source on an openSUSE 11.0 system.  I used 'sudo make
altinstll'.  It created an executable /usr/local/bin/python3.0 file.
Nothing was touched in /usr/bin.

I need to start writing some code with Python 3.  I want to write the
code in such a way that it can be easily shared with others with the
least difficulty and overhead as possible.  How should I write the code
to enable this?  What, if anything, should I assume about another
system's configuration?

As someone suggested before, naming the files as '.py3' is probably a
bad idea in the long run.  It also does not really solve the problem.

I could use a shebang.  But, what should it specify?  If I use
'python3.0', then that will soon be quite old.  If I make up a link for
python3 - python3.0, that would work, but then every other system that
is to run the code must that link also.  However, I am thinking that
this would be the best long term answer.

#!/usr/bin/env python3

My existing /usr/bin directory has three entires for python.

python - python2.5
python2 - python2.5
python2.5

If I write scripts for Python 3, another developer writes scripts for
Python 2, and a common customer wants to install both of our packages
onto a single machine, then what is the best plan for everyone to make
that happen with as little difficulty as possible?

When we find out the answer to this, we can go back and talk about
Windows platforms.

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


Running Python 2 and Python 3 on the same machine

2008-12-04 Thread Paul Watson
The migration strategy detailed in PEP 3000 using 2to3 is quite nice.
However, I am looking for suggestions for migrating to 3 while I still
have code that requires 2.

Since the source code is incompatible, I was expecting the Python
executable to have a new name such as 'python3' or for the default
source code filename to change to '.py3' or something.

Yes, I have searched some on the web and the newsgroup, so please don't
beat me up if this is well known.  Thanks.

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


Re: any library for SOAP 1.1 or SOAP 1.2?

2008-03-11 Thread Paul Watson
On Fri, 2008-01-25 at 16:52 +0530, Amogh Hooshdar wrote:
 Hi,
 
 I wish to know which python library is popular for SOAP related
 programming, especially for sending SOAP requests and parsing SOAP
 responses.
 
 I can't find any such library in the Python standard library but I
 could find ZSI and soap.py libraries. However, ZSI does not support
 SOAP 1.2.
 
 Does anyone know about a library that supports SOAP 1.2 also?

Support for SOAP 1.2 is on the ZSI wishlist.  It may not happen until
you and I do it.  Have you found anything else?  Are you using ZSI?

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


SOAP access to SharePoint

2008-03-11 Thread Paul Watson
Has anyone successfully accessed a Microsoft SharePoint WSS using
Python?  No, not IronPython.  I need for this to be able to run on all
machines the customer might choose.

Which libs are you using?  ZSI, SOAPpy, soaplib, ???

http://wiki.python.org/moin/WebServices

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


Re: SOAP strategies

2008-02-19 Thread Paul Watson

On Sat, 2008-02-16 at 10:59 -0600, Paul Watson wrote:
 What are the reasonable current day choices and best bets for the future
 when doing SOAP programming in Python?  SOAP batteries do not appear to
 be in the standard Python distribution.
 
 Most of the SOAP related information I have been able to find on the web
 is from 2001-2002.  I am not sure if some packages are still maintained.
 Most of this is old news.
 
 http://soapy.sourceforge.net/
 http://pywebsvcs.sourceforge.net/ (SOAPpy)
and what is the relation of this to ZSI
 
 http://www.intertwingly.net/stories/2002/12/20/sbe.html
 http://www.ibm.com/developerworks/library/ws-pyth5/
 http://www.opensourcetutorials.com/tutorials/Server-Side-Coding/Python/python-soap-libraries/page1.html
 
 http://www.gossamer-threads.com/lists/python/python/619251  This is
 current, but is this a long term strategy or a short term tactic?

Have I offended?  My apologies if I have.  I thought I showed that I had
done some homework and used Google and did the other things to show that
I was willing to put forth some effort.  Please tell me if I have missed
something.  If I should look somewhere besides Python for doing SOAP,
then please say that also.  Thanks.

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


Re: SOAP strategies

2008-02-19 Thread Paul Watson
On Tue, 2008-02-19 at 10:01 -0800, Paul Boddie wrote:
 On 19 Feb, 16:59, Paul Watson [EMAIL PROTECTED] wrote:
 
  Have I offended?  My apologies if I have.  I thought I showed that I had
  done some homework and used Google and did the other things to show that
  I was willing to put forth some effort.  Please tell me if I have missed
  something.  If I should look somewhere besides Python for doing SOAP,
  then please say that also.  Thanks.
 
 There's a Wiki page here about Web services in Python:
 
 http://wiki.python.org/moin/WebServices
 
 I don't think that there's been a great deal of visible activity
 around SOAP in the Python community other than that you've already
 noticed. I entertained the idea of doing some more complete SOAP
 support as an add-on to the libxml2dom project, but not wanting to
 implement all the related specifications (schemas, service
 descriptions), I struggle to see the benefit compared to simpler
 solutions.
 
 That's not to say that SOAP has no value. Clearly, if you consider the
 different use cases, SOAP is probably more appropriate for some than
 other solutions would be. If one were exposing some kind of repository
 through some kind of Web service, I'd consider approaches like REST,
 along with technologies like WebDAV (which overlaps with REST), XML-
 RPC and SOAP. But if the Web service were to involve issuing
 relatively complicated queries, and/or the repository wasn't strictly
 hierarchical (or couldn't be elegantly represented in such a way),
 then it would arguably be less appropriate to deploy a pure REST
 solution, favouring XML-RPC and SOAP instead.
 
 What undermines SOAP for me is that if I'm not too interested in
 treating it like some kind of RPC mechanism, then I can get most of
 the pertinent benefits from exchanging plain XML documents. You can,
 of course, do SOAP like this, but the obligation to look after the
 boilerplate elements (which should permit lots of fancy features like
 routing, if such stuff is actually used in the real world) seems
 like a distraction to me.
 
 Paul

Many thanks for your comments.  I will take a look at the site.

My primary orientation is in accessing large (one or more terabyte)
databases and doing data integration (ETL, ELT, EAI, EII) work.  Any
other suggestions?

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


Re: SOAP strategies

2008-02-19 Thread Paul Watson

On Tue, 2008-02-19 at 10:01 -0800, Paul Boddie wrote:
 On 19 Feb, 16:59, Paul Watson [EMAIL PROTECTED] wrote:
 
  Have I offended?  My apologies if I have.  I thought I showed that I had
  done some homework and used Google and did the other things to show that
  I was willing to put forth some effort.  Please tell me if I have missed
  something.  If I should look somewhere besides Python for doing SOAP,
  then please say that also.  Thanks.
 
 There's a Wiki page here about Web services in Python:
 
 http://wiki.python.org/moin/WebServices
 
 I don't think that there's been a great deal of visible activity
 around SOAP in the Python community other than that you've already
 noticed. I entertained the idea of doing some more complete SOAP
 support as an add-on to the libxml2dom project, but not wanting to
 implement all the related specifications (schemas, service
 descriptions), I struggle to see the benefit compared to simpler
 solutions.
 
 That's not to say that SOAP has no value. Clearly, if you consider the
 different use cases, SOAP is probably more appropriate for some than
 other solutions would be. If one were exposing some kind of repository
 through some kind of Web service, I'd consider approaches like REST,
 along with technologies like WebDAV (which overlaps with REST), XML-
 RPC and SOAP. But if the Web service were to involve issuing
 relatively complicated queries, and/or the repository wasn't strictly
 hierarchical (or couldn't be elegantly represented in such a way),
 then it would arguably be less appropriate to deploy a pure REST
 solution, favouring XML-RPC and SOAP instead.
 
 What undermines SOAP for me is that if I'm not too interested in
 treating it like some kind of RPC mechanism, then I can get most of
 the pertinent benefits from exchanging plain XML documents. You can,
 of course, do SOAP like this, but the obligation to look after the
 boilerplate elements (which should permit lots of fancy features like
 routing, if such stuff is actually used in the real world) seems
 like a distraction to me.
 
 Paul

Many thanks for your comments.  I will take a look at the site.

My primary orientation is in accessing large (one or more terabyte)
databases and doing data integration (ETL, ELT, EAI, EII) work.  Any
other suggestions?

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


SOAP strategies

2008-02-16 Thread Paul Watson
What are the reasonable current day choices and best bets for the future
when doing SOAP programming in Python?  SOAP batteries do not appear to
be in the standard Python distribution.

Most of the SOAP related information I have been able to find on the web
is from 2001-2002.  I am not sure if some packages are still maintained.
Most of this is old news.

http://soapy.sourceforge.net/
http://pywebsvcs.sourceforge.net/ (SOAPpy)
   and what is the relation of this to ZSI

http://www.intertwingly.net/stories/2002/12/20/sbe.html
http://www.ibm.com/developerworks/library/ws-pyth5/
http://www.opensourcetutorials.com/tutorials/Server-Side-Coding/Python/python-soap-libraries/page1.html

http://www.gossamer-threads.com/lists/python/python/619251  This is
current, but is this a long term strategy or a short term tactic?

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


Scripting Visio using Python

2007-02-13 Thread Paul Watson
I would like to create some additional shapes in Microsoft Visio using 
the Python language.  It would appear that Visio can use any CLR 
language.  Has anyone done this?  Can I use the Python package from 
python.org, or must I use IronPython?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PythonCard

2007-01-30 Thread Paul Watson
Tequila wrote:
 I'm having some trouble starting PythonCard on my PC.
 
 I've downloaded and ran python-2.5.msi to install Python on my 
 machine.  And PythonCard-0.8.2.win32.exe to install PythonCard.
 
 When I try to run the program I get the following error:
 ==
 C:\Python25\Lib\site-packages\PythonCard\tools
 \codeEditorcodeEditor.py
 Traceback (most recent call last):
   File C:\Python25\Lib\site-packages\PythonCard\tools\codeEditor
 \codeEditor.py, line 13, in module
 from PythonCard import about, configuration, dialog, log, menu, 
 model, resource, util
   File C:\Python25\lib\site-packages\PythonCard\about.py, line 8, in 
 module
 import wx
 ImportError: No module named wx
 ==
 
 Does anyone know what the problem might be?
 
 Thanks,
 Tequila

It would appear that you need to install wxPython also.

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


Re: Learning to program in Python

2007-01-05 Thread Paul Watson
jbchua wrote:
 Hello everybody.
 
 I am an Electrical Engineering major and have dabbled in several
 languages such as Python, C, and Java in my spare time because of my
 interest in programming. However, I have not done any practical
 programming because I have no idea where to get started. I taught
 myself these languages basically by e-tutorials and books. This makes
 me feel as if I don't really know how to implement these languages.
 Does anybody have any advice on where to start applying my limited
 knowledge practically in order to advance my learning?

This would be a good site to investigate.

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


Re: what is this?

2007-01-04 Thread Paul Watson
Eric Price wrote:
 Hello;
 I'm studying some code examples from the python cookbook site. I came 
 across this:
 
 def colsplit(l, cols):
rows = len(l) / cols
if len(l) % cols:
rows += 1
m = []
for i in range(rows):
m.append(l[i::rows])
return m
 
 What I'd like to know is what is the double colon? What does it do?
m.append(l[i::rows])
 
 Thanks,
 Eric

http://docs.python.org/tut/tut.html
http://docs.python.org/tut/node5.html#SECTION00514
http://docs.python.org/ref/slicings.html

Probably most helpful to you is:

http://developer.mozilla.org/es4/proposals/slice_syntax.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what is this?

2007-01-04 Thread Paul Watson
Paul Watson wrote:
 Eric Price wrote:
 Hello;
 I'm studying some code examples from the python cookbook site. I came 
 across this:

 def colsplit(l, cols):
rows = len(l) / cols
if len(l) % cols:
rows += 1
m = []
for i in range(rows):
m.append(l[i::rows])
return m

 What I'd like to know is what is the double colon? What does it do?
m.append(l[i::rows])

 Thanks,
 Eric
 
 http://docs.python.org/tut/tut.html
 http://docs.python.org/tut/node5.html#SECTION00514
 http://docs.python.org/ref/slicings.html
 
 Probably most helpful to you is:
 
 http://developer.mozilla.org/es4/proposals/slice_syntax.html

Sorry.  Probably most helpful to you is:

http://docs.python.org/lib/built-in-funcs.html

slice(  [start,] stop[, step])
 Return a slice object representing the set of indices specified by 
range(start, stop, step). The start and step arguments default to None. 
Slice objects have read-only data attributes start, stop and step which 
merely return the argument values (or their default). They have no other 
explicit functionality; however they are used by Numerical Python and 
other third party extensions. Slice objects are also generated when 
extended indexing syntax is used. For example: a[start:stop:step] or 
a[start:stop, i].
-- 
http://mail.python.org/mailman/listinfo/python-list


Cannot build 2.5 on FC6 x86

2007-01-03 Thread Paul Watson
./configure
make
make test

The result appears to hang after the test_tkl... line.  I had to kill 
the 'make test' process which terminated it.  Any suggestions?


280 tests OK.
4 tests failed:
 test_optparse test_socket test_socket_ssl test_urllib2
35 tests skipped:
 test_aepack test_al test_applesingle test_bsddb185 test_bsddb3
 test_cd test_cl test_codecmaps_cn test_codecmaps_hk
 test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses
 test_gl test_imgfile test_linuxaudiodev test_logging test_macfs
 test_macostools test_nis test_normalization test_ossaudiodev
 test_pep277 test_plistlib test_scriptpackages test_socketserver
 test_startfile test_sunaudiodev test_tcl test_timeout
 test_urllib2net test_urllibnet test_winreg test_winsound
 test_zipfile64
2 skips unexpected on linux2:
 test_tcl test_logging

make: *** [test] Terminated
Terminated
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cannot build 2.5 on FC6 x86

2007-01-03 Thread Paul Watson
Martin v. Löwis wrote:
 Paul Watson schrieb:
 ./configure
 make
 make test

 The result appears to hang after the test_tkl... line.  I had to kill
 the 'make test' process which terminated it.  Any suggestions?
 
 There isn't (or shouldn't be) any test_tkl... line. What precisely
 was the line, and how long did you wait until you thought it hangs?
 
 Regards,
 Martin

Sorry, I mis-typed.  It is not test_tkl.  It was test_tcl...

The last line output was as shown below my mistyping.

I let it sit overnight one time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A question about unicode() function

2007-01-02 Thread Paul Watson
JTree wrote:
 Thanks everyone!
 
 Sorry for my ambiguous question.
 I changed the codes and now it works fine.
 
 
 
 JTree wrote:
 Hi,all
  I encountered a problem when using unicode() function to fetch a
 webpage, I don't know why this happenned.
  My codes and error messages are:


 Code:
 #!/usr/bin/python
 #Filename: test.py
 #Modified: 2006-12-31

 import cPickle as p
 import urllib
 import htmllib
 import re
 import sys

 def funUrlFetch(url):
 lambda url:urllib.urlopen(url).read()

 objUrl = raw_input('Enter the Url:')
 content = funUrlFetch(objUrl)
 content = unicode(content,gbk)
 print content
 content.close()


 error message:

 C:\WINDOWS\system32\cmd.exe /c python test.py
 Enter the Url:http://www.msn.com
 Traceback (most recent call last):
   File test.py, line 16, in ?
 content = unicode(content,gbk)
 TypeError: coercing to Unicode: need string or buffer, NoneType found
 shell returned 1
 Hit any key to close this window...

 Any suggestions would be appreciated!

 Thanks!

So...  How about posting the brief working code?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with small program

2006-12-31 Thread Paul Watson
Tim Roberts wrote:
 [EMAIL PROTECTED] wrote:
 Interesting impl in Python! I am wondering what if the requirement is
 to find the minimum number of coins which added to the fin sum...
 
 Given the set of coins in the original problem (100, 10, 5, 1, 0.5), the
 solution it provides will always be optimal.  Even if we change this to
 American coinage (50, 25, 10, 5, 1), I believe it is still optimal.
 
 It is certainly possible to construct a set of denominations for which the
 algorithm occasionally chooses badly.  For example, if you give it the set
 (40,35,10) and ask it to make change for 70, it will be suboptimal.

Tim,

Unless I am missing the point, the minimum number of coins from the set 
available will be chosen.  Surely this homework is past due by now.

$ cat coins.py
#!/usr/bin/env python
import sys

cointypes = (100, 10, 5, 1, 0.5)

def coins(fin, cointypes):
 needed = {}
 for c in cointypes:
 v, r = divmod(fin, c)
 if v  0:
 needed[c] = int(v)
 fin = r
 return needed

def doit(fin, cointypes = cointypes):
 h = coins(fin, cointypes)
 print '%.1f requires %d coins in hash ' % (fin, sum(h.values())), h

if __name__ == '__main__':
 doit(51)
 doit(127)
 doit(12.5)
 doit(70, (40,35,10))

 sys.exit(0)

$ ./coins.py
51.0 requires 6 coins in hash  {1: 1, 10: 5}
127.0 requires 6 coins in hash  {1: 2, 10: 2, 100: 1, 5: 1}
12.5 requires 4 coins in hash  {0.5: 1, 1: 2, 10: 1}
70.0 requires 4 coins in hash  {40: 1, 10: 3}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with small program

2006-12-24 Thread Paul Watson
smartbei wrote:
 Felix Benner wrote:
 smartbei schrieb:
 Hello, I am a newbie with python, though I am having a lot of fun using
 it. Here is one of the excersizes I am trying to complete:
 the program is supposed to find the coin combination so that with 10
 coins you can reach a certain amoung, taken as a parameter. Here is the
 current program:

 coins = (100,10,5,1,0.5)
 anslist = []
 def bar(fin, hist = {100:0,10:0,5:0,1:0,0.5:0}):
 s = sum(x*hist[x] for x in hist)
 l = sum(hist.values())
 if s  fin and l  10:
 for c in coins:
 if (s+c) = fin:
 hist[c] += 1
 bar(fin, hist)
 hist[c] -= 1
 elif l==10 and s==fin and not hist in anslist:
 #p1
 anslist.append(hist)

 bar(50)
 print anslist

 The problem is that if I run it, anslist prints as [{0.5: 0, 1: 0, 10:
 0, 100: 0, 5: 0}], which doesnt even add up to 50. When I check how
 many times the program has reached the #p1 by sticking a print there,
 it only reaches it once, and it comes out correct. why is it that this
 result is replaced by the incorrect final one?

 hist is stored in anslist as a pointer only, therfore the hist[c] -= 1
 operates on the same dict as is stored in the anslist. Try the following
 in the python interpreter:

 a = { 'key' : 1 }
 l = [a]
 l[0]['key'] -= 1
 a

 instead use:

 anslist.append(dict(hist.items))

 which will copy the dict.
 
 Thanks!
 BTW - its hist.items(), after that it worked.

An alternative.

cointypes = (100, 10, 5, 1, 0.5)
needed = {}

def coins(fin):
cur = fin
for c in cointypes:
v = int(cur / c)
if v  0:
needed[c] = v
cur -= v * c

if __name__ == '__main__':
coins(51)
print needed
coins(127)
print needed
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with small program

2006-12-24 Thread Paul Watson
Better alternative.

cointype = (100, 10, 5, 1, 0.5)

def coins(fin):
needed = {}
for c in cointypes:
v, r = divmod(fin, c)
if v  0:
needed[c] = v
fin = r
return needed

if __name__ == '__main__':
print coins(51)
print coins(127)
print coins[12.5)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: convert from date string to epoch

2006-12-15 Thread Paul Watson
Stefan Antonelli wrote:
 Hi,
 
 i have to convert several timestamps. The given format, eg -mm-dd 
 hh:mm:ss
 has to be converted to an epoch string. Is there any proper way to do this?
 
 If not, i have to split the given string and resolve this by a calculation?
 
 Thanks for help.
 
 Stefan.

I saw some code on the net.  ASPB I think.  I whacked a few more lines 
to be an example.

#!/usr/bin/env python
import httplib
import time

ht = httplib.HTTP('www.python.org')
fich='/index.html'
print fich,
ht.putrequest('GET', fich)
ht.endheaders()
errcode, errmsg, headers = ht.getreply()
print headers.dict
print headers.dict['server']
textoFecha=headers.dict['date']
print textoFecha
fecha = time.strptime(textoFecha,'%a, %d %b %Y %H:%M:%S %Z')
print fecha
print time.asctime(fecha)
print time.mktime(fecha)
print ===
fecha = time.strptime('2006-12-15 19:42','%Y-%m-%d %H:%M')
print fecha
print time.asctime(fecha)
print time.mktime(fecha)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to determine Operating System in Use?

2006-12-13 Thread Paul Watson
Ian F. Hood wrote:
 Hi
 In typically windows environments I have used:
 if 'Windows' in os.environ['OS']...
 to prove it, but now I need to properly support different environments.
 To do so I must accurately determine what system the python instance is 
 running on (linux, win, mac, etc).
 Is there a best practises way to do this?
 TIA
 Ian

The more significant question is why do you want to do this?  Are you 
writing an asset management tool?  Do you just want to tell the user 
what operating system they are using?  The reason may lead to a 
different solution.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ooopy: newbie cannot get basic functionality to work

2006-12-09 Thread Paul Watson
Andrew Sackville-West wrote:
 Hi list, 
 
 I am new to python and old to coding (as in I did it a long time
 ago). I've got a task that cries out for a scripted solution --
 importing chunks of ASCII data dumps from a point-of-sale system into
 an openoffice.org spreadsheet. What a great chance for me to get my
 coding skills back and learn python too!

The openoffice.org spreadsheet tool can read a CSV file. How about 
producing that first, just so you have something that works.  I agree, 
this sounds like a nice way to dive into Python, but you might want 
something that works first, even if it is not elegant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie: minidom

2006-11-11 Thread Paul Watson
Fredrik Lundh wrote:
 Danny Scalenotti wrote:
 
 I'm not able to get out of this ...

 from  xml.dom.minidom import getDOMImplementation

 impl = getDOMImplementation()  // default UTF-8
 doc = impl.createDocument(None, test,None)
 root = doc.documentElement
 root.setAttribute('myattrib', '5')

 print root.toxml()


 I obtain

 test myattrib=5/

 why not this?

 ?xml version=1.0 encoding=UTF-8?
 test myattrib=5/
 
 
 why?  the documents are equivalent, and any XML application that 
 requires an explicit UTF-8 encoding declaration is broken.
 
 /F

Explicit is better than implicit.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: codecs - where are those on windows?

2006-10-30 Thread Paul Watson
GHUM wrote:
 I stumbled apon a paragraph in python-dev about reducing the size of
 Python for an embedded device:
 
 
 In my experience, the biggest gain can be obtained by dropping the
 rarely-used
 CJK codecs (for Asian languages). That should sum up to almost 800K
 (uncompressed), IIRC.
 
 
 So, my question is: on Windows. where are those CJK codecs? Are they by
 any chance included in the 1.867.776 bytes of python24.dll ?
 
 Best wishes,
 
 Harald

If your installation directory is C:\Python25, then look in

C:\Python25\lib\encodings
-- 
http://mail.python.org/mailman/listinfo/python-list


PyXML not supported, what to use next?

2006-09-30 Thread Paul Watson
It would appear that xml.dom.minidom or xml.sax.* might be the best 
thing to use since PyXML is going without support.  Best of all it is 
included in the base Python distribution, so no addition hunting required.

Is this right thinking?  Is there a better solution?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: best small database?

2006-09-11 Thread Paul Watson
David Isaac wrote:
 I have no experience with database applications.
 This database will likely hold only a few hundred items,
 including both textfiles and binary files.
 
 I would like a pure Python solution to the extent reasonable.
 
 Suggestions?
 
 Thank you,
 Alan Isaac

If you want really simple, look at the anydbm module.  If nothing better 
is available, anydbm will use dumbdbm.  All of these are in the Python 
build, so you do not need to fetch/read/install anything additional.

Doing the DB-API would be much stronger, but might be overkill in your 
situation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: to thine own SELF be true...

2006-05-05 Thread Paul Watson
Michael Ekstrand wrote:
 On Fri, May 05, 2006 at 05:08:24PM +, Mark Harrison wrote:
 
Is there a way to get rid of those the self. references, or is this
just something I need to get my brain to accept?
 
 
 It's pretty much just something you'll need to get your brain to accept.
 You can replace self with something shorter, like s, but that's sure to
 cause mass confusion for other people who try to read your code.
 
 I, however, find that the self. references are a great benefit to
 readability, as it makes the scope of a variable quite easy to tell.  A
 lot of my C++ code is littered with `this-' or similar
 explicit-scope-description things...
 
 - Michael

This fits perfectly with Explicit is better than implicit.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing pyodbc

2006-04-30 Thread Paul Watson
timw.google wrote:
 I just downloaded the  pyodbc source to try and install on my Linux FC3
 box. I see that there is a setup.py file, but when I try to do a
 'python setup.py build' (or just 'python setup.py') I get
 
 Traceback (most recent call last):
   File setup.py, line 27, in ?
 revision = latest_revision('.')
   File setup.py, line 25, in latest_revision
 return int(output)
 ValueError: invalid literal for int(): exported
 
 The README.txt doesn't really say anything about how to install, exept
 that the easiest way is to use the Windows installer. That's fine for
 Windows, but what about Linux?
 
 Thanks for any help.

Have you read the http://sourceforge.net/projects/pyodbc/ summary page 
where the Operating System indicates which platforms are supported? 
That might be relevant information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: finding IP address of computer

2006-04-30 Thread Paul Watson
DarkBlue wrote:
 Chris wrote:
 
 
How do I find and print to screen the IP address of the computer my
python program is working on?
 
 
 def readip():
  import re, urllib
  f = urllib.urlopen('http://checkip.dyndns.org')
  s = f.read()
  m = re.search('([\d]*\.[\d]*\.[\d]*\.[\d]*)', s)
  return m.group(0)
 
 myip = readip()

IP address and other browser header information available at:

http://xhaus.com/headers
-- 
http://mail.python.org/mailman/listinfo/python-list


Is pwm Python MegaWidgets viable?

2006-04-02 Thread Paul Watson
Does pwm run well on Python 2.4?  The last release appears to be in 
2003.  The Manning discussion forum is dead.

Is there a better path to learning and producing tkInter apps?

Has there been any discussion of wxPython becoming part of the base 
Python distro?  A requirement here is to not require download/install of 
anything other than the Python release.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is pwm Python MegaWidgets viable?

2006-04-02 Thread Paul Watson
gregarican wrote:
 Paul Watson wrote:
 
 
Does pwm run well on Python 2.4?  The last release appears to be in
2003.  The Manning discussion forum is dead.

Is there a better path to learning and producing tkInter apps?


Has there been any discussion of wxPython becoming part of the base
Python distro?  A requirement here is to not require download/install of
anything other than the Python release.
 
 
 I can't vouch for Python 2.4, but I used the PMW library pretty
 extensively for an app that is based on Python 2.3. Tkinker itself
 offers most of the basic widgets that any Tk implementation does, and
 there's an online guide (can't recall the URL right now) to Tkinter
 that is great for an introduction tutorial. PMW is an add-on to Tkinter
 that is useful if there are specific widgets that you need that basic
 Tkinter doesn't provide and you don't feel like creating them from
 scratch. Just because it doesn't have a new release in the past couple
 of years doesn't mean that it's truly a dead project. Perhaps it's
 stabilized and there haven't been overwhelming requests for adding any
 new items to it. Using PMW won't help you learn Tkinter any quicker in
 any event. Just icing on the cake :-)

Many thanks for your reply.  I was setting out to make use of the 
Manning book by Grayson.  Perhaps I should just use online tutorial and 
such for learning plain-old tk first.  However, I have heard good things 
about the book.  Just trying to use what was already at hand.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ftp: get list of files

2006-02-09 Thread Paul Watson
Lawrence Oluyede wrote:
 eels [EMAIL PROTECTED] writes:
 
 
With yyy = ftp.retrlines('LIST') I get this listing at stdout, but I
need this information at variable yyy.
How can I resolve this problem?
 
 
 As written in the doc retrlines has an optional parameter (a callback 
 function)
 called on each line retrieved, so you can do something like this:
 
 from ftplib import FTP
 
 def writeline(data):
 fd.write(data + \n)
 
 f = FTP('ftp.kernel.org')
 f.login()
 
 f.cwd('/pub/linux/kernel')
 fd = open('README', 'wt')
 f.retrlines('RETR README', writeline)
 fd.close()
 f.quit()

How about a little more portability?

def writeline(data):
 fd.write(data + os.linesep)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using non-ascii symbols

2006-01-24 Thread Paul Watson
Christoph Zwerschke wrote:
 On the page http://wiki.python.org/moin/Python3%2e0Suggestions
 I noticed an interesting suggestion:
 
 These operators ≤ ≥ ≠ should be added to the language having the 
 following meaning:
 
   = = !=
 
 this should improve readibility (and make language more accessible to 
 beginners).
 
 This should be an evolution similar to the digraphe and trigraph 
 (digramme et trigramme) from C and C++ languages.
 
 How do people on this group feel about this suggestion?
 
 The symbols above are not even latin-1, you need utf-8.
 
 (There are not many usefuls symbols in latin-1. Maybe one could use × 
 for cartesian products...)
 
 And while they are better readable, they are not better typable (at 
 least with most current editors).
 
 Is this idea absurd or will one day our children think that restricting 
 to 7-bit ascii was absurd?
 
 Are there similar attempts in other languages? I can only think of APL, 
 but that was a long time ago.
 
 Once you open your mind for using non-ascii symbols, I'm sure one can 
 find a bunch of useful applications. Variable names could be allowed to 
 be non-ascii, as in XML. Think class names in Arabian... Or you could 
 use Greek letters if you run out of one-letter variable names, just as 
 Mathematicians do. Would this be desirable or rather a horror scenario? 
 Opinions?
 
 -- Christoph

This will eventually happen in some form.  The problem is that we are 
still in the infancy of computing.  We are using stones and chisels to 
express logic.  We are currently faced with text characters with which 
to express intent.  There will come a time when we are able to represent 
a program in another form that is readily portable to many platforms.

In the meantime (probably 50 years or so), it would be advantageous to 
use a universal character set for coding programs.  To that end, the 
input to the Python interpreter should be ISO-10646 or a subset such as 
Unicode.  If the # -*- coding: ? -*- line specifies something other than 
ucs-4, then a preprocessor should convert it to ucs-4.  When it is 
desireable to avoid the overhead of the preprocessor, developers will 
find a way to save source code in ucs-4 encoding.

The problem with using Unicode in utf-8 and utf-16 forms is that the 
code will forever need to be written and forever execute additional 
processing to handle the MBCS and MSCS (Multiple-Short Character Set) 
situation.

Ok.  Maybe computing is past infancy.  But most development environments 
are not much past toddler stage.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Need Help with Python/C API

2006-01-19 Thread Paul Watson
pycraze wrote:
 Hi guys,
 
 I Need to know how do i create a dictionary... eg:
 n = pali_hash
 n={}
 n={1:{ } }   -  i need to know how to make a key of a dictionary, to a
 dictionary using Python/C API's

It looks like you are asking how to create a dictionary (hash).  If it 
is more than that, then please add some information.

$ python
Python 2.4.1 (#1, Jul 19 2005, 14:16:43)
[GCC 4.0.0 20050519 (Red Hat 4.0.0-8)] on linux2
Type help, copyright, credits or license for more information.
  n = {}
  n[3] = 'abc'
  n['x'] = 7
  n
{'x': 7, 3: 'abc'}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Removing a substring from a string

2006-01-16 Thread Paul Watson
ankit wrote:
 Hi All,
 I want to remove a substring from a string without any additional
 tabs/returns in the output string. Is there any method availaible or
 how can I do it. For the ease, I am giving an example:
 
 [code]
 mainstr =
 ${if:isLeaf}
   Dont include this isLeaf=True
 ${/if:isLeaf}
 
 ${if:isStatic}
   include this isStatic=True
 ${/if:isStatic}
 
 ${if:!isLeaf}
include this isLeaf=False
 ${/if:!isLeaf}
 
 [/code]
 
 Now if I want to remove :
 [code]
 substr = 
 ${if:isLeaf}
   Dont include this isLeaf=True
 ${/if:isLeaf}
 
 [/code]
 
 Expected output is :
 [code]
 ${if:isStatic}
   include this isStatic=True
 ${/if:isStatic}
 
 ${if:!isLeaf}
include this isLeaf=False
 ${/if:!isLeaf}
 [/code]
 
 I am using mainstr.replace(substr, ) but it gives me additional
 carriage returns which leads to empty spaces as follows:
 
 Actual Output:
 [code]
 
 
 
 
 
 ${if:isStatic}
   include this isStatic=True
 ${/if:isStatic}
 
 ${if:!isLeaf}
include this isLeaf=False
 ${/if:!isLeaf}
 [/code]
 
 Note: See additional newlines before isStatic tag
 
 
 Any Suggestions ?

Are you using 'print' to get the output?  Please see the following code 
and note what the 'print' lines which have a comma at the end produce. 
The 'print' statement is not always suitable for producing closely 
controlled output.  Consider constructing the exact string you want and 
using a 'write' method.

$ cat ./jjj.py
#!/usr/bin/python

s = 'now'
print s
print s,
print s

x = s.replace('now', '')
print '%s' % x,
print 'then'
09:34 pwatson [ ruth:/home/pwatson ] 431
$ ./jjj.py
now
now now
  then
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: return values of os.system() on win32

2006-01-13 Thread Paul Watson
rbt wrote:
 Is it safe to say that any value returned by os.system() other than 0 is 
 an error?
 
 if os.system('winver') != 0:
 print Winver failed!
 else:
 print Winver Worked.
 
 Thanks!

What are you really seeking to do?  Are you wanting to detect if your 
code is running on a Windows machine?  Are you wanting to know the 
version number of Windows?  Why not use popen2() and see the output?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating shortcuts?

2006-01-13 Thread Paul Watson
Ron Griswold wrote:
 Hi Dennis,
 
 Yes, I am equating a unix soft link to a windows shortcut. Both act as
 links to a file or directory. 
 
 I have found that windows shortcuts do appear in linux dir listings with
 a .lnk extension, however the file is meaningless to linux. On the other
 hand, a linux soft link does not appear in a windows directory listing,
 not that I really want it to.
 
 As for os.link and os.symlink, these appear to be unix specific. It
 would be nice if os.symlink, when run on windows, would create a
 shortcut.
 
 Thanks,
 
 Ron Griswold
 Character TD
 R!OT Pictures
 [EMAIL PROTECTED]
 
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf
 Of Dennis Lee Bieber
 Sent: Friday, January 13, 2006 12:26 AM
 To: python-list@python.org
 Subject: Re: Creating shortcuts?
 
 On Thu, 12 Jan 2006 22:53:42 -0800, Ron Griswold
 [EMAIL PROTECTED] declaimed the following in comp.lang.python:
 
 
Is it possible to create a shortcut to a file in Python? I need to do
this in both win32 and OSX. I've already got it covered in Linux by
system(ln...).

 
 
   Are you equating a Windows shortcut to a Unix link? Soft
 link,
 at that, I suspect -- as a hard link can be done using os.link(), though
 a soft link can be done with os.symlink(). Lets see if my terminology is
 correct: a hard link is an additional directory entry pointing to a
 pre-existing file (with a count of how many entries exist for the file);
 a soft link is basically a special file that contains the full path to
 the actual file (and hence, could cross file system boundaries).
 
   I don't think Windows shortcuts are the same thing (as my
 memory
 struggles, I have vague inklings that NTFS actually supports Unix-like
 links, but practically nothing uses them). At best, they may be similar
 to a soft link, being a particular type of file, being that they are
 files with a .lnk extension (and hidden by the OS normally)

UNIX links and Windows .lnk files are not the same thing.

Links on UNIX, both soft and hard, are known by the filesystem.

.lnk files on Windows are recognized by the OS as indicating that a 
different file is to be used.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get Windows system information?

2006-01-13 Thread Paul Watson
Martin P. Hellwig wrote:
 [EMAIL PROTECTED] wrote:
 
 Does anybody know how to get the:

  Free hard disk space
  Amount of CPU load
  and Amount of RAM used

 on windows? I am making an artificial intelligence program that has
 moods based on how much stress the system is under, based on these
 parameters. I think it could possibly be done via COM. I am not looking
 for a cross-platform solution- just something that will work on
 Windows. Thank you for your help!

 
 Have a look at WMI* , it's specifically designed to getthat kind of 
 stuff, there is also a python layer for WMI**.
 
 * http://msdn.microsoft.com/library/en-us/wmisdk/wmi/wmi_reference.asp
 ** http://tgolden.sc.sabren.com/python/wmi.html
 
 hth

WMI sounds like the right way to go.  I recently had to whack a little 
WHS because I could find no Python interface without downloading 
additional modules.  Do you think Tim Golden would submit it for 
inclusion with the standard Python build?  If so, would that require 
pywin32 to be in the build or could Tim do this through ctypes?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling foreign functions from Python? ctypes?

2006-01-09 Thread Paul Watson
Neil Hodgson wrote:
 Paul Watson:
 
 I cannot find any way to get to GetVersionInfo in VBScript (cscript).
 
 
 Set objFSO = CreateObject(Scripting.FileSystemObject)
 Wscript.Echo objFSO.GetFileVersion(c:\bin\SciLexer.dll)

Many thanks.  Just what I needed.  (Short of ctypes.)  Thank you for 
tolerating a VBScript question here.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Viewing Binary Data

2006-01-08 Thread Paul Watson
Cuyler wrote:
 I would like to display a file in its binary form (1s and 0s), but I'm
 having no luck... Any thoughts would be most appreciated.

If you are on a UNIX system, or on Windows with Cygwin, you can use the 
'od' command to dump a file in hex or octal.

man od
od -Ax -tx1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling foreign functions from Python? ctypes?

2006-01-08 Thread Paul Watson
Martin v. Löwis wrote:
 Paul Watson wrote:
 
I need to call GetVersionInfo() and handle VERSIONINFO information.  I
thought that distutils might have something, but I do not see it yet.
Any suggestions?
 
 You could write this specific API in VB, and then run cscript.exe in
 a pipe; or you could write a wrapper module just for that specific
 API (in case PythonWin is too large for you).

I cannot find any way to get to GetVersionInfo in VBScript (cscript).

If so, this appears to leave me with no choice but to produce a Windows 
executable, whether a .exe or C code wrapped from Python.  Right?
-- 
http://mail.python.org/mailman/listinfo/python-list

Calling foreign functions from Python? ctypes?

2006-01-06 Thread Paul Watson
I need to call some Windows APIs.  Is the only way to download ctypes or 
the win32 interfaces?  Is there any plan to get ctypes batteries into 
the standard Python build?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling foreign functions from Python? ctypes?

2006-01-06 Thread Paul Watson
Neil Hodgson wrote:
Paul Watson:
 
 Is there any plan to get ctypes batteries into the standard Python build?
 
 
It is unlikely that ctypes will be included in the standard Python 
 build as it allows unsafe memory access making it much easier to crash 
 Python.

Does extending Python with any C/C++ function not do the same thing?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling foreign functions from Python? ctypes?

2006-01-06 Thread Paul Watson
Martin v. Löwis wrote:
 Paul Watson wrote:
 
I need to call some Windows APIs.  Is the only way to download ctypes or
the win32 interfaces?
 
 
 That depends on the specific win32 interface you want to call.
 Typically, the answer is yes.

I have used _winreg and I see winsound in the doc.

I need to call GetVersionInfo() and handle VERSIONINFO information.  I 
thought that distutils might have something, but I do not see it yet. 
Any suggestions?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: nesting for statements?

2005-11-27 Thread Paul Watson
[EMAIL PROTECTED] wrote:
 I'm not what you'd call a programmer of any sort, so perhaps this
 question may seem arcane and result in a plethora of you idiot
 threads, but here goes:
 
 ArcGIS 9.1 has a neat interface with python (2.1-2.4), allowing me to
 do all sorts of spatial operations within python, namely, repetitive
 functions.
 
 
 In the below code, I'm trying to iterate thru multiple values of the
 variable Discretisation error factor using a for statement that
 temporarily populates Disc, which is used as input in Discretisation
 error factor in the gp.TopoToRaster._sa function.
 
 
 For each iteration of Discretisation error factor, I'm trying to name
 the output file outa, outb, out
 
 Not quite sure how to implement that. There are lots of examples on
 nested for loops out there, but nothing on combing that with a output
 file naming sheme.
 
 The gp.TopoToRaster_sa function by itself without all the for
 statements works fine.
 
 Appreciate any help on this, other wise I have to manually  interpolate
 hundreds of LiDAR point clouds, each, 10 times for diff. values of DEF.
 
 
 
 # TopoToRaster_sample.py
 # Description: Interpolate a series of point features onto a
 rectangular raster using TopoToRaster
 # Requirements: None
 # Author: ESRI
 # Date: 12\\01\\03
 
 # Import system modules
 import sys, string, os, win32com.client
 
 # Create the Geoprocessor object
 from win32com.client import Dispatch
 gp = Dispatch(esriGeoprocessing.GpDispatch.1)
 
 # Check out any necessary licenses
 gp.CheckOutExtension(spatial)
 
 # Iterate 2 thru 4 in increments of 2 for DEF
 # Name the 2 dem outa and the 4 dem outb
 for x in range(2,4):
 Disc = int(x)
 names = [a,b]
 for y in names:
 Out_Dem = out+y
 
 
 try:
 
 # Process: Topo to Raster...
 gp.TopoToRaster_sa(C:\\temp\\falls_lidar.shp Z PointElevation,
Out_Dem, # Variable for name of output raster.
 This should increment name of output based on the for statement
5, # Output raster cell size: each pixel is 5
 feet by 5 feet
2103763.27 813746.12 2111850.32 822518.65,
 #extent of raster borders, SPF, NC, NAD83
20, # #Grid Margin
, #Smallest z value to be used in
 interpolation (optional)
, #Largest z value to be used in interpolation
 (optional)
NO_ENFORCE, #Drainage option
SPOT, #Spot data option
40, #Maximum number of iterations (optional)
, #Roughness penalty (optional)
Disc, #Discretisation error factor: This should
 increment DEF based on the for statement
0, #Vertical standard error (optional)
, #Tolerance 1 (optional)
 #Tolerance 2 (optional)
)
 except:
 print ERROR OCCURED
 print gp.GetMessages()

I think you want a filename generated for each pass through the loop.  I 
would suggest generating the filenames before you ever start the loop in 
a list.  Then, reference the filename list while you are in the loop. 
You could also construct the filename while you are in the loop.

sor = 2 # start of range
eor = 4 # end of range

filenames = ['file' + chr((x-sor) + ord('a')) for x in range(sor, eor)]

for x in range(sor, eor):
 print filenames[x - sor]

If you do not want to create all of the filenames in memory at one time, 
you could generated them during the loop.  However, this will not work 
well when you code is run on a system not using ASCII character encoding.

for x in range(sor, eor):
 print 'file' + chr((x - sor) + ord('a'))

Something using string.ascii_lowercase would work better.  My guess is 
that on the mainframe using EBCDIC character encoding that 
string.ascii_lowercase still contains the LATIN SMALL LETTER characters, 
just as it does on ASCII-based systems.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing pins to the RS232

2005-11-26 Thread Paul Watson
[EMAIL PROTECTED] wrote:
 I want to write to the pins of an RS232 without using the serial
 protocol.  The use would be every pin could act to complete a circuit
 in customized hardware.  I could use python to communicate serially to
 a BASIC stamp or a Javelin stamp and then use the stamp to set however
 many pins as 0's or 1's but should it be that hard to do with python.
 I've looked through how python does serial with the serial module but
 it just uses Java's javax.comm libraries.  Is there anyway to do very
 low level device writing to COM ports?
 
 In summary I'm looking for something like:
 ser = serial.Serial(0)
 ser.pin0 = 1
 ser.pin1 = 1
 ser.pin2 = 1
 
 
 
 or
 ser.write('0xFF')
 which would set 8 pins on the RS232 cable to 1's
 

Accessing hardware at this level is almost always managed by some form 
of device driver in any real operating system.  Even Microsoft Windows 
has device drivers for serial and parallel ports.  This is not your 
father's MS-DOS any more.  It would be a security breach to allow user 
applications direct access at the hardware level.

Also, if you ever hope to run on anything except an IBM-PC clone, then 
the hardware will be different.  Even systems that run x86 processors 
like the NEC PC-98 have 8255 parallel interfaces, but they are located 
on different ports in the machine.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which License Should I Use?

2005-11-25 Thread Paul Watson
mojosam wrote:
 I've been watching the flame war about licenses with some interest.
 There are many motivations for those who participate in this sector, so
 disagreements over licenses reflect those agendas.
 
 I don't have an agenda, at least not right now.  I do plan on writing a
 few programs.
 
 These will be tools I need for firmware testing.  They will be
 relatively simple things like tools for breaking down data by its
 structure for easy viewing, sending commands/macros over serial ports,
 etc.  Similar things exist, but they don't do everything I need.  These
 will also be excellent learning opportunities for me, since I'm still
 pretty shaky on Python.
 
 How do I decide on a license?  Are there any web sites that summarize
 the pros and cons?  I guess I don't care too much about how other
 people use it.  These things won't be comprehensive enough or have
 broad enough appeal that somebody will slap a new coat of paint on them
 and try to sell them.  I guess I don't care if somebody incorporates
 them into something bigger.  If somebody were to add features to them,
 it would be nice to get the code and keep the derivative work as open
 source, but I don't think that matters all that much to me.  If
 somebody can add value and find a way of making money at it, I don't
 think I'd be too upset.
 
 I will be doing the bulk of the coding on my own time, because I need
 to be able to take these tools with me when I change employers.
 However, I'm sure that in the course of using these tools, I will need
 to spend time on the job debugging or tweaking them.  I do not want my
 current employer to have any claim on my code in any way.  Usually if
 you program on company time, that makes what you do a work for hire.
 I can't contaminate my code like that.  Does that mean the GPL is the
 strongest defense in this situation?
 
 I'm open to suggestions as to which licenses to consider.  However,
 please try to keep the conversation to the decision process or what
 sounds like it is best for this purpose.  Let's keep the broader issue
 of which license will bring about the fall of Western Civilization on
 the other thread.
 
 Ron Britton
 
 (The gibberish on the next line really is my email address.)
 nk67v8o02
 at
 sneakemail.com

As mentioned earlier, your employer may lay some claim to the result if 
it substantially relates to your work.

Using your employer's equipment to develop or test the code might also 
be an indication that it is a work for hire.  Either that, or you 
misused the company's assets for personal gain.  Neither sounds very 
attractive.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2.4.2 on AIX fails compiling _codecs_cn.c

2005-11-24 Thread Paul Watson
Martin v. Löwis wrote:
 Paul Watson wrote:
 
 It appears that _ALL_SOURCE gets defined in the 
 /usr/include/standards.h file.  If we could #define _ANSI_C_SOURCE or 
 _POSIX_SOURCE, it appears that it would eleminate _ALL_SOURCE.
 
 
 Ah, ok - this should be easy enough. Python would normally define
 _POSIX_SOURCE (through _XOPEN_SOURCE), but configure(.in) has this
 block:
 
   # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 
 500 but
   # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not 
 defined
   # or has another value. By not (re)defining it, the defaults come in 
 place.
   AIX/4)
 define_xopen_source=no;;
   AIX/5)
 if test `uname -r` -eq 1; then
   define_xopen_source=no
 fi
 ;;
 
 which causes _XOPEN_SOURCE (and subsequently probably _POSIX_SOURCE) not 
 to be defined. What AIX version are you using? Can you try removing
 the fragment from configure(.in), rerun configure, verify that 
 _XOPEN_SOURCE is defined in pyconfig.h, and then try building again?
 
 If this works, this might be a solution. Otherwise, we need to put 
 something like this into _codecs_cn.c:
 
 #ifdef hz
 /* On AIX version such-and-such, hz is defined because _ALL_SOURCE is
defined, this in turn is defined because _XOPEN_SOURCE is not.
As _XOPEN_SOURCE cannot be enabled (see configure.in), we just
work around by removing the hz definition again. */
 #undef hz
 #endif
 
 Regards,
 Martin

Commenting out the section in configure(.in) did not cause it to work. 
It still ended up with '100_encode' complaint.

Using '#undef hz' in ./Modules/cjkcodecs/_codecs_cn.c does cause it to 
compile.  However, it will not pass ./Lib/test/test_codecsencoding_cn.py 
or ./Lib/test/test_codecmaps_cn.py.  The others (_hk, _jp, _kr, and _tw) 
do pass the test.

I also note that compiles occurring after the complaint about not 
finding Tcl/Tk do not appear to get the OPT= setting I specified on the 
'make' command line.  It starts with compilation of structmodule.c and 
includes the _codecs_??.c files.  Does this have any significance?  Is 
it possible that there are other settings not being used?

$ python test_codecencodings_cn.py
test_chunkcoding (__main__.Test_GB2312) ... ERROR
test_customreplace (__main__.Test_GB2312) ... ERROR
test_errorhandle (__main__.Test_GB2312) ... ERROR
test_streamreader (__main__.Test_GB2312) ... ERROR
test_streamwriter (__main__.Test_GB2312) ... ERROR
test_xmlcharrefreplace (__main__.Test_GB2312) ... ERROR
test_chunkcoding (__main__.Test_GBK) ... ERROR
test_customreplace (__main__.Test_GBK) ... ERROR
test_errorhandle (__main__.Test_GBK) ... ERROR
test_streamreader (__main__.Test_GBK) ... ERROR
test_streamwriter (__main__.Test_GBK) ... ERROR
test_xmlcharrefreplace (__main__.Test_GBK) ... ERROR
test_chunkcoding (__main__.Test_GB18030) ... ERROR
test_customreplace (__main__.Test_GB18030) ... ERROR
test_errorhandle (__main__.Test_GB18030) ... ERROR
test_streamreader (__main__.Test_GB18030) ... ERROR
test_streamwriter (__main__.Test_GB18030) ... ERROR
test_xmlcharrefreplace (__main__.Test_GB18030) ... ERROR

==
ERROR: test_chunkcoding (__main__.Test_GB2312)
--
Traceback (most recent call last):
   File 
/home/pwatson/usr/lib/python2.4/test/test_multibytecodec_support.py, 
line 27, in setUp
 self.codec = codecs.lookup(self.encoding)
LookupError: unknown encoding: gb2312

==
ERROR: test_customreplace (__main__.Test_GB2312)
--
Traceback (most recent call last):
   File 
/home/pwatson/usr/lib/python2.4/test/test_multibytecodec_support.py, 
line 27, in setUp
 self.codec = codecs.lookup(self.encoding)
LookupError: unknown encoding: gb2312

==
ERROR: test_errorhandle (__main__.Test_GB2312)
--
Traceback (most recent call last):
   File 
/home/pwatson/usr/lib/python2.4/test/test_multibytecodec_support.py, 
line 27, in setUp
 self.codec = codecs.lookup(self.encoding)
LookupError: unknown encoding: gb2312

==
ERROR: test_streamreader (__main__.Test_GB2312)
--
Traceback (most recent call last):
   File 
/home/pwatson/usr/lib/python2.4/test/test_multibytecodec_support.py, 
line 27, in setUp
 self.codec = codecs.lookup(self.encoding)
LookupError: unknown encoding: gb2312

==
ERROR: test_streamwriter (__main__.Test_GB2312)
--
Traceback (most recent call last):
   File 
/home/pwatson

Re: 2.4.2 on AIX 4.3 make fails on threading

2005-11-23 Thread Paul Watson
Neal Norwitz wrote:
 Paul Watson wrote:
 
When I try to build 2.4.2 on AIX 4.3, it fails on missing thread
objects.  I ran ./configure --without-threads --without-gcc.

Before using --without-threads I had several .pthread* symbols missing.
 
 
 Perhaps you need to add -lpthread to the link line.  This should be
 able to work.  What is the link line output from make?
 
 
Can anyone
suggest a configuration or some change that I can make to cause this to
build correctly?  Thanks.

ld: 0711-317 ERROR: Undefined symbol: ._PyGILState_NoteThreadState
 
 
 I think that problem has been fixed.  Try downloading this file and
 replace the one in your build directory:
 
 
 http://svn.python.org/projects/python/branches/release24-maint/Python/pystate.c

Thanks for your help.  I think it worked better after I read the 
Misc/AIX-NOTES document.  Apparently one -must- use --with-threads.

I grabbed a bzlib.h from the net and created ./Modules/bzlib.h since I 
do not have root access.  I had to change bz2module.c #include to use 
quotes rather than  symbols so that it would find the header file.

Another problem with building _codecs_cn.c I will put in another 
subject.  Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


2.4.2 on AIX fails compiling _codecs_cn.c

2005-11-23 Thread Paul Watson
Any ideas why ./Modules/cjkcodecs/_codecs_cn.c fails to compile?  It 
appears that the CODEC_STATELESS macro is concatenating 'hz' with a 
number and text.


building '_codecs_cn' extension
cc -DNDEBUG -O -I. -I/home/pwatson/src/python/Python-2.4.2/./Include 
-I/home/pwatson/src/python/Python-2.4.2/Include 
-I/home/pwatson/src/python/Python-2.4.2 -c 
/home/pwatson/src/python/Python-2.4.2/Modules/cjkcodecs/_codecs_cn.c -o 
build/temp.aix-4.3-2.4/_codecs_cn.o
/home/pwatson/src/python/Python-2.4.2/Modules/cjkcodecs/_codecs_cn.c, 
line 431.3: 1506-206 (S) Suffix of integer constant 100_encode is not valid.
/home/pwatson/src/python/Python-2.4.2/Modules/cjkcodecs/_codecs_cn.c, 
line 431.3: 1506-196 (W) Initialization between types int(*)(union 
{...}*,const void*,const unsigned short**,unsigned long,unsigned 
char**,unsigned long,int) and int is not allowed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2.4.2 on AIX fails compiling _codecs_cn.c

2005-11-23 Thread Paul Watson
Martin v. Löwis wrote:
 Paul Watson wrote:
 
 Any ideas why ./Modules/cjkcodecs/_codecs_cn.c fails to compile?  It 
 appears that the CODEC_STATELESS macro is concatenating 'hz' with a 
 number and text.
 
 
 More likely, hz is already defined to be 100, then forming 100_encode.
 
 It would be best if you could find out what AIX header file defines
 hz to be 100, and whether there is any way to supress that definition.
 
 Regards,
 Martin

This is on AIX 4.3.3

$ grep -i _hz $(find . -name m_param.h)
#define _HZ 100/* ticks per second of the clock*/
#define __hzHZ /* Berkeley uses lower case hz  */
#define HZ  _HZ
#define hz  __hz

$ cc_r 21|head -1
   VisualAge C++ Professional / C for AIX Compiler, Version 5
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: 2.4.2 on AIX fails compiling _codecs_cn.c

2005-11-23 Thread Paul Watson
Martin v. Löwis wrote:
 Paul Watson wrote:
 
 Any ideas why ./Modules/cjkcodecs/_codecs_cn.c fails to compile?  It 
 appears that the CODEC_STATELESS macro is concatenating 'hz' with a 
 number and text.
 
 
 More likely, hz is already defined to be 100, then forming 100_encode.
 
 It would be best if you could find out what AIX header file defines
 hz to be 100, and whether there is any way to supress that definition.
 
 Regards,
 Martin

Here are the /usr/include/*.h files that include sys/m_param.h

$ grep sys/m_param $(find . -name *.h)
./sys/pthdebug.h:#include sys/m_param.h   /* _NGPRS, _NFPRS */
./sys/context.h:#include sys/m_param.h
./sys/mstsave.h:#include sys/m_param.h/* for machine dependent 
defines*/
./sys/param.h:#include sys/m_param.h
./sys/proc.h:#include sys/m_param.h
./sys/sched.h:#include sys/m_param.h

Can we #undef _ALL_SOURCE for _codecs_cn.c compilation?

There is a description in sys/context.h that seems to suggest that it is 
an internal vs. external definition issue.

+44  /*
+45   * XPG4.2 requires structures and structure elements to be 
defined such
+46   * that they do not pollute the namespace.  _ALL_SOURCE 
contains the
+47   * kernel version, while not _ALL_SOURCE contains the sanitized 
versions.
+48   */
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: 2.4.2 on AIX fails compiling _codecs_cn.c

2005-11-23 Thread Paul Watson
Martin v. Löwis wrote:
 Paul Watson wrote:
 
 Can we #undef _ALL_SOURCE for _codecs_cn.c compilation?
 
 
 Where does _ALL_SOURCE come from? Why is it defined?
 What is its effect on hz?
 
 Regards,
 Martin

Martin v. Löwis wrote:
  Paul Watson wrote:
 
  Can we #undef _ALL_SOURCE for _codecs_cn.c compilation?
 
 
  Where does _ALL_SOURCE come from? Why is it defined?
  What is its effect on hz?
 
  Regards,
  Martin

It appears that _ALL_SOURCE gets defined in the /usr/include/standards.h 
file.  If we could #define _ANSI_C_SOURCE or _POSIX_SOURCE, it appears 
that it would eleminate _ALL_SOURCE.

$ cat t.c
#include stdio.h
#include stdlib.h

int main()
{
 printf(hello, world\n);

#ifdef _ALL_SOURCE
 printf(hello, again\n);
#endif

 exit(0);
}

$ cc_r t.c

$ ./a.out
hello, world
hello, again
-- 
http://mail.python.org/mailman/listinfo/python-list

2.4.2 on AIX 4.3 make fails on threading

2005-11-22 Thread Paul Watson
When I try to build 2.4.2 on AIX 4.3, it fails on missing thread 
objects.  I ran ./configure --without-threads --without-gcc.

Before using --without-threads I had several .pthread* symbols missing. 
  I do not have to have threading on this build, but it would be helpful 
if it is possible.  The machine has the IBM C compiler.  Can anyone 
suggest a configuration or some change that I can make to cause this to 
build correctly?  Thanks.

$ xlc 21|head -1
   VisualAge C++ Professional / C for AIX Compiler, Version 5

 ./Modules/makexp_aix Modules/python.exp . libpython2.4.a;  c++ 
  -Wl,-bE:Modules/python.exp -lld -o python  Modules/python.o 
libpython2.4.a -ldl-lm
collect2: ld returned 8 exit status
ld: 0711-317 ERROR: Undefined symbol: ._PyGILState_NoteThreadState
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more 
information.
make: 1254-004 The error code from the last command is 1.


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


Re: Web-based client code execution

2005-11-21 Thread Paul Watson
Robin Becker wrote:
 Paul Watson wrote:
 ..
 
 -- David



 This looks interesting, but looks even more fragile than CrackAJAX.

 http://www.aminus.org/blogs/index.php/phunt/2005/10/06/subway_s_new_ajax_framework
  


 All of this comes down to Javascript which will still not allow me to 
 read local, client files.  Right?
 
 
 I think reading files is easy; just get the client browser to submit a 
 form with the file as an upload. Hard part is getting the path(s) right.

I need to walk the directory tree to find which files are of interest. 
It sounds like a client application (not browser) will be required.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web-based client code execution

2005-11-20 Thread Paul Watson
Kent Johnson wrote:
 Stephen Kellett wrote:
 
 In message [EMAIL PROTECTED], 
 Steve [EMAIL PROTECTED] writes

 AJAX works because browsers can execute javascript.  I don't know of a
 browser that can execute python.  Basically your stuck with java or
 javascript because everything else really isn't cross platform.



 ActiveState do a version of Python that can run in a script tag like 
 JavaScript and VBScript. This requires Windows Scripting Host. They 
 also do a similar thing for Perl, not sure about TCL.
 
 
 See
 http://groups.google.com/group/comp.lang.python/msg/2d34acee66b40830
 
 Kent

Please correct my misunderstanding if I am wrong, but I thought that 
this runs server-side only and requires Microsoft IIS as the httpd 
server.  Is that correct?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web-based client code execution

2005-11-20 Thread Paul Watson
David Wahler wrote:
 Steve wrote:
 
AJAX works because browsers can execute javascript.  I don't know of a
browser that can execute python.  Basically your stuck with java or
javascript because everything else really isn't cross platform
 
 
 Don't jump to conclusions...
 http://dwahler.ky/python/
 
 If you really, really want Python in a browser, it's certainly
 possible. :)
 
 -- David

This looks interesting, but looks even more fragile than CrackAJAX.

http://www.aminus.org/blogs/index.php/phunt/2005/10/06/subway_s_new_ajax_framework

All of this comes down to Javascript which will still not allow me to 
read local, client files.  Right?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web-based client code execution

2005-11-20 Thread Paul Watson
John J. Lee wrote:
 Paul Watson [EMAIL PROTECTED] writes:
 
 
What are the options?

The user to hits a web page, downloads code (Python I hope), execute it, 
and be able to return the results.  It needs to be able to go through 
standard HTTP so that it could be run from behind a corporate firewall 
without any other ports being opened.

Am I stuck doing an ActiveX control?
 
 [...]
 
 If you just need to talk on port 80, just go ahead and do that (module
 socket, module httplib, module urllib2, urllib.getproxies, etc), and
 write a normal desktop application.
 
 
 If it must run in a browser, here is some food for thought:
 
 
 Compile Python to JavaScript -- very cool
 
 http://www.aminus.org/blogs/index.php/phunt/2005/10/06/subway_s_new_ajax_framework
 
 http://www.aminus.org/blogs/index.php/phunt/2005/10/09/psst_crackajax_is_in_svn
 
 
 Plain old AJAX with Python on server side
 
 https://sourceforge.net/projects/json-py/
 
 http://www.google.co.uk/search?q=ajax+pythonbtnG=Search (um, ignore the 1st 
 result)
 
 
 Write Java applets in Python
 
 http://www.jython.org/
 
 
 Flash 'local storage'
 
 http://www.macromedia.com/support/documentation/en/flashplayer/help/help02.html
 
 Sort-of AJAX-for-Flash stuff
 
 http://www.cs.unc.edu/~parente/tech/tr04.shtml
 http://www.simonf.com/flap/
 
 Flash itself (boo;-)
 
 http://www.macromedia.com/
 
 
 XUL and PyXPCOM (Firefox only)
 
 http://www.xulplanet.com/
 
 http://trac.nunatak.com.au/projects/nufox
 
 
 Firefox future capabilities in this direction (probably most of this
 is relevant)
 
 http://www.mozilla.org/roadmap/gecko-1.9-roadmap.html
 
 http://weblogs.mozillazine.org/roadmap/archives/2005_09.html
 
 
 John

I appreciate your long list of references.  For this task, I think the 
first answer may have to be the one with which to go.  A standard 
application that talks through port 80 and perhaps can use proxies.

My desire to have the code distributed through a web page is just to 
ensure that the user is running the correct version and has not hacked 
it in any way.  I suppose I can checksum the local client application 
and compare it with what is on the server.  Then, make a way to 
update... ARGH!

Even when future browsers embed Python interpreters, the security 
considerations may be such that no one will want to accept code which 
can do much locally anyway.  Probably the right thing for the public 
Internet,  Makes it harder to develop internal system management tools.
-- 
http://mail.python.org/mailman/listinfo/python-list


Web-based client code execution

2005-11-18 Thread Paul Watson
What are the options?

The user to hits a web page, downloads code (Python I hope), execute it, 
and be able to return the results.  It needs to be able to go through 
standard HTTP so that it could be run from behind a corporate firewall 
without any other ports being opened.

Am I stuck doing an ActiveX control?

Yes, I know that downloading code and executing on the client machine is 
a security risk.  This will be for the employee's computers to connect. 
  This will not be a publicly available web page.

I have read some about AJAX.  Is there an APAX coming for Python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web-based client code execution

2005-11-18 Thread Paul Watson
Steve wrote:
 AJAX works because browsers can execute javascript.  I don't know of a
 browser that can execute python.  Basically your stuck with java or
 javascript because everything else really isn't cross platform.

Well, I guess the Grail browser could run Python, but I do not think I 
can go there.

I need READ access to the users local disk storage.  Can I do this in 
Javascript, or should I bite the bullet and turn to ActiveX?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python worth it??

2005-11-15 Thread Paul Watson
Simon Brunning wrote:
 On 14/11/05, john boy [EMAIL PROTECTED] wrote:
 
I have started out trying to learn Python for my first programming language.
 I am starting off with the book how to think like a computer scientist.
I spend about 4-5 hrs a day trying to learn this stuff.  It is certainly no
easy task.  I've been at it for about 1-2 weeks now and have a very
elementary picture of how Python works.  I am teaching myself from home and
only recieve help from this forum.  Can anybody give me a timeframe as to
how long it usually takes to pick something like this up, so I can maybe
figure out a way to pace myself?  I can dedicate a good amount of time to it
everyday.  Any advice on what is the best way to learn Python?  I am a
fairly educated individual with a natural sciences degree (forestry), so I
also have a decent math background.  Are there any constraints
mathematically or logic wise that would prevent me from building a firm
grasp of this language?
 
 
 Keep at it.
 
 Everyone is different, so don't worry about how long it takes you vs.
 how long others might take. If you have no programming background,
 there's a lot to learn. Using Python is a good choice, I think, 'cos
 it gets a lot of extranious crud that many other languages insist on
 out of your way, but there's still a lot to learn.
 
 The best way to learn? Go through the tutorials - but if you get an
 idea for a mini-project of your own, don't be afraid to dive off and
 give it a go. Try to solve you own problems for a while, 'cos that's a
 valuable skill, but don't get to the point of frustration. Ask for
 help here or on the tutor mailing list[1].
 
 And have fun.
 
 [1] http://mail.python.org/mailman/listinfo/tutor
 
 --
 Cheers,
 Simon B,
 [EMAIL PROTECTED],
 http://www.brunningonline.net/simon/blog/

Python is a great choice for a first language.  I agree with the 
tutorial recommendations of others.

I would suggest that you focus on getting out of it what you want out of 
it.  Get some data about rainfall and correlate it with regional fires, 
economic output, or religious practices.  That will get you reading 
data, calculating, and writing output.

Read more code than you write.  Download the Python sources and 
unpackage them on your machine.  You do not have to build the 
executable.  Lot's of the Python library functions are written in 
Python.  Try to explain what the code is doing.  If you do not yet 
understand (after applying due diligence and using Google), then ask 
questions.  Questions are good.  Questions are our friend.

Write as much code as you can.  Get comfortable with a debugger where 
you can watch the action happen.

There are many fundamental computer concepts such as memory, storage, 
persistence, threading, and all that.  Do not worry about understanding 
these in the first few weeks.  Focus on getting out of it something that 
you want.  Understanding the concepts will come to you as you are a 
practitioner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newb ?

2005-11-15 Thread Paul Watson
Chad Everett wrote:
 Hello all,
 
 Have a problem here with a challenge from a book I am reading.
 Any help is much appreciated.
 
 I am trying to run a program that asks the user for a statement and then 
 prints it out backwards.
 this is what I have.
 It does not print anything out.  I assume that I have something out of whack 
 with my high and low statements.
 
 Thanks for you help.
 
 
 print \n\nWelcome to the Backwards Message Display.
 print
 message = raw_input(\nPlease Enter a Message.)
 
 high = len(message)
 low = -len(message)
 print
 print message[high:low]
 print
 print raw_input(Please Press Enter to Exit) 

Are you sure that this is not a class assignment?  You can search the 
messages here for the answer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing tkinter with Python 2.4.2 on FC4

2005-11-14 Thread Paul Watson
Paul Watson wrote:
 I cannot yet get tkinter working on 2.4.2.  I have installed the tk rpms 
  from FC4.  I have checked to see that TKPATH is available in 
 Modules/Setup.
 
 How can I verify that I have tcl/tk installed correctly and it is the 
 correct version (8+)?

Surely, there must be a better way to do this than what I ended up 
doing.  Please respond so that someone will do better than I did.

To get this to work, I whacked the ./Modules/Setup file references to tk 
things.  Two lines were changed from /usr/local/* to /usr/*.  The X11 
lines were simply uncommented.

I had to install a few more RPMs from the FC4 CDs for tk and tcl.  That 
led to installing some more xorg-x11 RPMs.

After that, ./configure; make clean; make; make test;

# *** Always uncomment this (leave the leading underscore in!):
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \
# *** Uncomment and edit to reflect where your Tcl/Tk libraries are:
#   -L/usr/local/lib \
 -L/usr/lib \
# *** Uncomment and edit to reflect where your Tcl/Tk headers are:
#   -I/usr/local/include \
 -I/usr/include \
# *** Uncomment and edit to reflect where your X11 header files are:
 -I/usr/X11R6/include \
# *** Or uncomment this for Solaris:
#   -I/usr/openwin/include \
# *** Uncomment and edit for Tix extension only:
#   -DWITH_TIX -ltix8.1.8.2 \
# *** Uncomment and edit for BLT extension only:
#   -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \
# *** Uncomment and edit for PIL (TkImaging) extension only:
# (See http://www.pythonware.com/products/pil/ for more info)
#   -DWITH_PIL -I../Extensions/Imaging/libImaging  tkImaging.c \
# *** Uncomment and edit for TOGL extension only:
#   -DWITH_TOGL togl.c \
# *** Uncomment and edit to reflect your Tcl/Tk versions:
#   -ltk8.2 -ltcl8.2 \
 -ltk8.4 -ltcl8.4 \
# *** Uncomment and edit to reflect where your X11 libraries are:
 -L/usr/X11R6/lib \
# *** Or uncomment this for Solaris:
#   -L/usr/openwin/lib \
# *** Uncomment these for TOGL extension only:
#   -lGL -lGLU -lXext -lXmu \
# *** Uncomment for AIX:
#   -lld \
# *** Always uncomment this; X11 libraries to link with:
 -lX11
-- 
http://mail.python.org/mailman/listinfo/python-list


Installing tkinter with Python 2.4.2 on FC4

2005-11-12 Thread Paul Watson
I cannot yet get tkinter working on 2.4.2.  I have installed the tk rpms 
  from FC4.  I have checked to see that TKPATH is available in 
Modules/Setup.

How can I verify that I have tcl/tk installed correctly and it is the 
correct version (8+)?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scanning a file

2005-11-01 Thread Paul Watson
Paul Rubin wrote:
 [EMAIL PROTECTED] (John J. Lee) writes:
 
Closing off this particular one would make it harder to get benefit of
non-C implementations of Python, so it has been judged not worth it.
I think I agree with that judgement.
 
 
 The right fix is PEP 343.

I am sure you are right.  However, PEP 343 will not change the existing 
body of Python source code.  Nor will it, alone, change the existing 
body of Python programmers who are writing code which does not close files.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scanning a file

2005-11-01 Thread Paul Watson
Alex Martelli wrote:
 Steve Holden [EMAIL PROTECTED] wrote:
...
 
The runtime knows it is doing it.  Please allow the runtime to tell me
what it knows it is doing.  Thanks.

In point oif fact I don't believe the runtime does any such thing 
(though I must admit I haven't checked the source, so you may prove me
wrong).

As far as I know, Python simply relies on the opreating system to close
files left open at the end of the program.
 
 
 Nope, see
 http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Objects/fi
 leobject.c?rev=2.164.2.3view=markup :
 
 
 static void
 file_dealloc(PyFileObject *f)
 {
 int sts = 0;
 if (f-weakreflist != NULL)
 PyObject_ClearWeakRefs((PyObject *) f);
 if (f-f_fp != NULL  f-f_close != NULL) {
 Py_BEGIN_ALLOW_THREADS
 sts = (*f-f_close)(f-f_fp);
 
 etc.
 
 Exactly how the OP wants to allow the runtime to tell [him] what it
 knows it is doing, that is not equivalent to reading the freely
 available sources of that runtime, is totally opaque to me, though.
 
 The runtime (implementation of built-in object type `file`) could be
 doing or not doing a bazillion things (in its ..._dealloc function as
 well as many other functions), up to and including emailing the OP's
 cousin if it detects the OP is up later than his or her bedtime -- the
 language specs neither mandate nor forbid such behavior.  How, exactly,
 does the OP believe the language specs should allow (presumably,
 REQUIRE) ``the runtime'' to communicate the sum total of all that it's
 doing or not doing (beyond whatever the language specs themselves may
 require or forbid it to do) on any particular occasion...?!
 
 
 Alex

The OP wants to know which files the runtime is closing automatically. 
This may or may not occur on other or future Python implementations. 
Identifying this condition will accelerate remediation efforts to avoid 
the deleterious impact of failure to close().


The mechanism to implement such a capability might be similar to the -v 
switch which traces imports, reporting to stdout.  It might be a 
callback function.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scanning a file

2005-10-31 Thread Paul Watson
Alex Martelli wrote:
...
gc.garbage
 
 [__main__.a object at 0x64cf0, __main__.b object at 0x58510]
 
 So, no big deal -- run a gc.collect() and parse through gc.garbage for
 any instances of your wrapper of file class, and you'll find ones that
 were forgotten as part of a cyclic garbage loop and you can check
 whether they were explicitly closed or not.
 
 
 Alex

Since everyone needs this, how about building it in such that files 
which are closed by the runtime, and not user code, are reported or 
queryable?  Perhaps a command line switch to either invoke or suppress 
reporting them on exit.

Is there any facility for another program to peer into the state of a 
Python program?  Would this be a security problem?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scanning a file

2005-10-31 Thread Paul Watson
Steve Holden wrote:
 Since everyone needs this, how about building it in such that files 
 which are closed by the runtime, and not user code, are reported or 
 queryable?  Perhaps a command line switch to either invoke or suppress 
 reporting them on exit.

 This is a rather poor substitute from correct program design and 
 implementation. It also begs the question of exactly what constitutes a 
 file. What about a network socket that the user has run makefile() on? 
 What about a pipe to another process? This suggestion is rather 
 ill-defined.
 
 Is there any facility for another program to peer into the state of a 
 Python program?  Would this be a security problem?
 
 It would indeed be a security problem, and there are enough of those 
 already without adding more.
 
 regards
  Steve

All I am looking for is the runtime to tell me when it is doing things 
that are outside the language specification and that the developer 
should have coded.

How ill will things be when large bodies of code cannot run 
successfully on a future version of Python or a non-CPython 
implementation which does not close files.  Might as well put file 
closing on exit into the specification.

The runtime knows it is doing it.  Please allow the runtime to tell me 
what it knows it is doing.  Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Controlling output using print with format string

2005-10-30 Thread Paul Watson
It is clear that just using 'print' with variable names is relatively 
uncontrollable.  However, I thought that using a format string would 
reign the problem in and give the desired output.

Must I resort to sys.stdout.write() to control output?

$ python
Python 2.4.1 (#1, Jul 19 2005, 14:16:43)
[GCC 4.0.0 20050519 (Red Hat 4.0.0-8)] on linux2
Type help, copyright, credits or license for more information.
  s = 'now is the time'
  for c in s:
... print c,
...
n o w   i s   t h e   t i m e
  for c in s:
... print %c % (c),
...
n o w   i s   t h e   t i m e
  for c in s:
... print %1c % (c),
...
n o w   i s   t h e   t i m e
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scanning a file

2005-10-30 Thread Paul Watson
Fredrik Lundh wrote:
 Paul Watson wrote:
 
This is Cyngwin on Windows XP.
 
 using cygwin to analyze performance characteristics of portable API:s
 is a really lousy idea.

Ok.  So, I agree.  That is just what I had at hand.  Here are some other 
numbers to which due diligence has also not been applied.  Source code 
is at the bottom for both file and mmap process.  I would be willing for 
someone to tell me what I could improve.

$ python -V
Python 2.4.1

$ uname -a
Linux ruth 2.6.13-1.1532_FC4 #1 Thu Oct 20 01:30:08 EDT 2005 i686

$ cat /proc/meminfo|head -2
MemTotal:   514232 kB
MemFree: 47080 kB

$ time ./scanfile.py
16384

real0m0.06s
user0m0.03s
sys 0m0.01s

$ time ./scanfilemmap.py
16384

real0m0.10s
user0m0.06s
sys 0m0.00s

Using a ~ 250 MB file, not even half of physical memory.

$ time ./scanfile.py
16777216

real0m11.19s
user0m10.98s
sys 0m0.17s

$ time ./scanfilemmap.py
16777216

real0m55.09s
user0m43.12s
sys 0m11.92s

==

$ cat scanfile.py
#!/usr/bin/env python

import sys

fn = 't.dat'
ss = '\x00\x00\x01\x00'
ss = 'time'

be = len(ss) - 1# length of overlap to check
blocksize = 64 * 1024# need to ensure that blocksize  overlap

fp = open(fn, 'rb')
b = fp.read(blocksize)
count = 0
while len(b)  be:
 count += b.count(ss)
 b = b[-be:] + fp.read(blocksize)
fp.close()

print count
sys.exit(0)

===

$ cat scanfilemmap.py
#!/usr/bin/env python

import sys
import os
import mmap

fn = 't.dat'
ss = '\x00\x00\x01\x00'
ss='time'

fp = open(fn, 'rb')
b = mmap.mmap(fp.fileno(), os.stat(fp.name).st_size, 
access=mmap.ACCESS_READ)

count = 0
foundpoint = b.find(ss, 0)
while foundpoint != -1 and (foundpoint + 1)  b.size():
 #print foundpoint
 count = count + 1
 foundpoint = b.find(ss, foundpoint + 1)
b.close()

print count

fp.close()
sys.exit(0)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scanning a file

2005-10-29 Thread Paul Watson
Mike Meyer [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Paul Watson [EMAIL PROTECTED] writes:
...
 Did you do timings on it vs. mmap? Having to copy the data multiple
 times to deal with the overlap - thanks to strings being immutable -
 would seem to be a lose, and makes me wonder how it could be faster
 than mmap in general.

The only thing copied is a string one byte less than the search string for 
each block.

I did not do due dilligence with respect to timings.  Here is a small 
dataset read sequentially and using mmap.

$ ls -lgG t.dat
-rw-r--r--  1 16777216 Oct 28 16:32 t.dat
$ time  ./scanfile.py
1048576
0.80s real 0.64s user 0.15s system
$ time  ./scanfilemmap.py
1048576
   20.33s real 6.09s user14.24s system

With a larger file, the system time skyrockets. I assume that to be the 
paging mechanism in the OS.  This is Cyngwin on Windows XP.

$ ls -lgG t2.dat
-rw-r--r--  1 268435456 Oct 28 16:33 t2.dat
$ time  ./scanfile.py
16777216
   28.85s real16.37s user 0.93s system
$ time  ./scanfilemmap.py
16777216
  323.45s real94.45s user   227.74s system


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


Re: Scanning a file

2005-10-29 Thread Paul Watson
Alex Martelli [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 In today's implementations of Classic Python, yes.  In other equally
 valid implementations of the language, such as Jython, IronPython, or,
 for all we know, some future implementation of Classic, that may well
 not be the case.  Many, quite reasonably, dislike relying on a specific
 implementation's peculiarities, and prefer to write code that relies
 only on what the _language_ specs guarantee.

How could I identify when Python code does not close files and depends on 
the runtime to take care of this?  I want to know that the code will work 
well under other Python implementations and future implementations which may 
not have this provided. 


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


Re: Scanning a file

2005-10-28 Thread Paul Watson
[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I want to scan a file byte for byte for occurences of the the four byte
 pattern 0x0100. I've tried with this:

 # start
 import sys

 numChars = 0
 startCode = 0
 count = 0

 inputFile = sys.stdin

 while True:
ch = inputFile.read(1)
numChars += 1

if len(ch)  1: break

startCode = ((startCode  8)  0x) | (ord(ch))
if numChars  4: continue

if startCode == 0x0100:
count = count + 1

 print count
 # end

 But it is very slow. What is the fastest way to do this? Using some
 native call? Using a buffer? Using whatever?

 /David

How about something like:

#!/usr/bin/env python

import sys

fn = 't.dat'
ss = '\x00\x00\x01\x00'

be = len(ss) - 1# length of overlap to check
blocksize = 4 * 1024# need to ensure that blocksize  overlap

fp = open(fn, 'rb')
b = fp.read(blocksize)
found = 0
while len(b)  be:
if b.find(ss) != -1:
found = 1
break
b = b[-be:] + fp.read(blocksize)
fp.close()
sys.exit(found) 


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


Re: Scanning a file

2005-10-28 Thread Paul Watson
[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I want to scan a file byte for byte for occurences of the the four byte
 pattern 0x0100. I've tried with this:

 # start
 import sys

 numChars = 0
 startCode = 0
 count = 0

 inputFile = sys.stdin

 while True:
ch = inputFile.read(1)
numChars += 1

if len(ch)  1: break

startCode = ((startCode  8)  0x) | (ord(ch))
if numChars  4: continue

if startCode == 0x0100:
count = count + 1

 print count
 # end

 But it is very slow. What is the fastest way to do this? Using some
 native call? Using a buffer? Using whatever?

 /David

Here is an attempt at counting and using the mmap facility.  There appear to 
be some serious backward compatibility issues.  I tried Python 2.1 on 
Windows and AIX and had some odd results.  If you are 2.4.1 or higher that 
should not be a problem.

#!/usr/bin/env python
import sys
import os
import mmap

fn = 't.dat'
ss = '\x00\x00\x01\x00'

fp = open(fn, 'rb')
b = mmap.mmap(fp.fileno(), os.stat(fp.name).st_size, 
access=mmap.ACCESS_READ)

count = 0
foundpoint = b.find(ss, 0)
while foundpoint != -1 and (foundpoint + 1)  b.size():
count = count + 1
foundpoint = b.find(ss, foundpoint + 1)
b.close()

print count

fp.close()
sys.exit(0) 


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


Re: Scanning a file

2005-10-28 Thread Paul Watson
Paul Watson [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
I want to scan a file byte for byte for occurences of the the four byte
 pattern 0x0100. I've tried with this:

 # start
 import sys

 numChars = 0
 startCode = 0
 count = 0

 inputFile = sys.stdin

 while True:
ch = inputFile.read(1)
numChars += 1

if len(ch)  1: break

startCode = ((startCode  8)  0x) | (ord(ch))
if numChars  4: continue

if startCode == 0x0100:
count = count + 1

 print count
 # end

 But it is very slow. What is the fastest way to do this? Using some
 native call? Using a buffer? Using whatever?

 /David

Here is a better one that counts, and not just detects, the substring.  This 
is -much- faster than using mmap; especially for a large file that may cause 
paging to start.  Using mmap can be -very- slow.

#!/usr/bin/env python
import sys

fn = 't2.dat'
ss = '\x00\x00\x01\x00'

be = len(ss) - 1# length of overlap to check
blocksize = 64 * 1024# need to ensure that blocksize  overlap

fp = open(fn, 'rb')
b = fp.read(blocksize)
count = 0
while len(b)  be:
count += b.count(ss)
b = b[-be:] + fp.read(blocksize)
fp.close()

print count
sys.exit(0) 


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


Re: Installing Python at Work

2005-10-18 Thread Paul Watson
Nikola [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 I'm currently learning Python for my own use.
 I'm considering installing it on a work laptop, knowing that it is
 non-licensed, distributable software.

 However, does it access communication ports?  I know the company checks
 their ports regularly for activity.

 I won't be doing anything very serious; I'm just trying out Python,
 learning the basics from 'Learning Python' by O'Reilly.

Are you asking if it is ok to install Python on your company machine or if 
Python does anything that might cause you to get caught doing something the 
company has already said not to do? 


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


Re: piping out binaries properly

2005-10-12 Thread Paul Watson
Andy Leszczynski leszczynscyATnospam.yahoo.com.nospam wrote in message 
news:[EMAIL PROTECTED]
I have got following program:

 import sys
 import binascii
 from string import *
 sys.stdout.write(binascii.unhexlify(41410A4141))


 when I run under Unix I got:

 $ python u.py  u.bin
 $ od -t x1 u.bin
 000 41 41 0a 41 41

 and under Windows/Cygwin following:

 $ python u.py  u.bin
 $ od -t x1 u.bin
 000 41 41 0d 0a 41 41
 006


 The question is how can I pipe out binary content properly and platform
 independently?


 A.

try:
import msvcrt, os
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
except:
pass


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


  1   2   >