Re: Building Python (2.4.x) with Visual C++ 2005 Express Edition?

2006-05-06 Thread Vincent Wehren
Heikki Toivonen [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
|I did some searches but did not find any definitive answers as to
| whether or not it should be possible to build Python 2.4+ with Microsoft
| Visual C++ 2005 Express Edition.
|
| I tried it myself (have VC++ project files that work with Visual Studio
| 2003 .NET commercial version, just opened and closed them in vcexpress
| to convert the projects) and the compilation finished without errors
| (although with a bunch of deprecation warnings). But when I try to run,
| python crashes on startup.
|
| Has anyone gotten this to work?
|
| -- 
|  Heikki Toivonen

Looking at your post, I tried building 2.4.3 using Visual Studio 2005 
Professional - but ran into trouble with the way signals are treated by the 
new CRT (which may be the error you are talking about).
I saw there was a patch on 
http://sourceforge.net/tracker/index.php?func=detailaid=1350409group_id=5470atid=305470
 
which apparently has been applied to 2.5a2 - which started fine after 
building debug.

Maybe this helps?

Regards,

Vincent Wehren




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


Re: Getting .NET SDK to work with Python 2.4.2

2006-03-19 Thread Vincent Wehren

Dave [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
| Well i don't have the whole visual studio. I don't have 7 either, I
| have 8. I have VB and VC++ Express. If there is no way to download VS7,
| could someone point me to directions on how to build the extensions
| with mingw32?
|

I used the free MS Visual C++ Toolkit 2003 successfully to compile 
extenstions before I had access to VS.
There's a how to here: http://www.vrplumber.com/programming/mstoolkit/

Regards,

Vincent Wehren 


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


Re: How to check if a directory is exist in python?

2006-03-19 Thread Vincent Wehren
[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
|I check the documentation here, but it does not say how to check if a
| directory is exist in python?
| http://docs.python.org/lib/os-file-dir.html

Look at the exist or isdir  methods of the os.path module 
(http://docs.python.org/lib/module-os.path.html}

|
| And why mkdir fails if the directory already exists?

If you prefer a more friendly approach you may wanna take a look at Trent 
Mick's _mkdir which is located at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82465
|

Regards,
Vincent Wehren

| Thank you.
| 


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


Re: How to check if a directory is exist in python?

2006-03-19 Thread Vincent Wehren
Vincent Wehren [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
| [EMAIL PROTECTED] wrote in message
| news:[EMAIL PROTECTED]
||I check the documentation here, but it does not say how to check if a
|| directory is exist in python?
|| http://docs.python.org/lib/os-file-dir.html
|
| Look at the exist or isdir  methods of the os.path module

Ofcourse I mean exists...

| (http://docs.python.org/lib/module-os.path.html}
|
||
|| And why mkdir fails if the directory already exists?
|
| If you prefer a more friendly approach you may wanna take a look at 
Trent
| Mick's _mkdir which is located at
| http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82465
||
|
| Regards,
| Vincent Wehren
|
|| Thank you.
||
|
| 


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


Re: Getting .NET SDK to work with Python 2.4.2

2006-03-19 Thread Vincent Wehren

Dave [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
| So this means that I have to download .NET 1.1 SDK. Visual Studio 8
| comes with msvcrt.lib, but im assuming it's the wrong version.
|

Yes, I'd say so.
--
Vincent Wehren 


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


Re: How do I tell if I'm running in the PyWin interpreter?

2006-01-28 Thread vincent wehren
Charles Krug [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| On 2006-01-28, Steven D'Aprano [EMAIL PROTECTED] wrote:
| 
|  As the comment says, when I run this under Python Win, I get an (pretty
|  sure) Tkinter interface, not a command line, and I don't get my
|  EOFError when I expect to.
| 
|  When do you expect to get an EOFError? The only way I get an EOFError is
|  if I explicitly hit Ctrl-D while raw_input is running. When do you 
expect
|  to get it? Have you tried Ctrl-Z under Windows?
| 
|
| That's exactly how I use it everywhere else.  Type until you're done
| then hit Ctrl-D
|
| The problem is only when running under the PyWin IDE . . I'd been using
| this for months under Idle and every place else I needed it.
|
| The problem is that PyWin doesn't give you a raw command line with in
| response to raw_input, but gives you a text entry box and a nice
| OK-Cancel yada yada interface that silently eats my EOF.
|
| I'd like to have a single tool I can use everywhere.  So far as I can
| tell, that means I have to detect the PyWin IDE and handle it
| separately on initialization so I get a real raw input and not the
| redefined Tkinter version.
|

import sys
import os
if os.path.basename(sys.executable) == 'Pythonwin.exe':
#Pythonwin specific  initialization
else:
#Other

HTH,

Vincent Wehren



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


Re: python encoding bug?

2005-12-31 Thread Vincent Wehren
[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
|
| I was playing with python encodings and noticed this:
|
| [EMAIL PROTECTED]:~$ python2.4
| Python 2.4 (#2, Dec  3 2004, 17:59:05)
| [GCC 3.3.5 (Debian 1:3.3.5-2)] on linux2
| Type help, copyright, credits or license for more information.
|  unicode('\x9d', 'iso8859_1')
| u'\x9d'
| 
|
| U+009D is NOT a valid unicode character (it is not even a iso8859_1
| valid character)

That statement is not entirely true. If you check the current 
UnicodeData.txt (on http://www.unicode.org/Public/UNIDATA/)  you'll find:

009D;control;Cc;0;BN;N;OPERATING SYSTEM COMMAND

Regards,

Vincent Wehren

|
| The same happens if I use 'latin-1' instead of 'iso8859_1'.
|
| This caught me by surprise, since I was doing some heuristics guessing
| string encodings, and 'iso8859_1' gave no errors even if the input
| encoding was different.
|
| Is this a known behaviour, or I discovered a terrible unknown bug in 
python encoding
| implementation that should be immediately reported and fixed? :-)
|
|
| happy new year,
|
| -- 
| ---
|| Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ |
|| __..--^^^--..__garabik @ kassiopeia.juls.savba.sk |
| ---
| Antivirus alert: file .signature infected by signature virus.
| Hi! I'm a signature virus! Copy me into your signature file to help me 
spread! 


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

Re: Guido working on Pypy?

2005-12-30 Thread Vincent Wehren


Andrew Durdin [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
On 29 Dec 2005 04:12:53 -0800, Luis M. González [EMAIL PROTECTED] wrote:
|
| According to this blog entry, it says that Guido has been hired by
| Google to work on Pypy:
| http://zephyrfalcon.org/weblog2/arch_e10_00870.html
|
| Is there anyone who can confirm this information?
| Luis

|Or deny it:
|
|http://zephyrfalcon.org/weblog2/arch_e10_00870.html#e872
|
|Andrew

Well, apparently Guido himself did take the time to deny the claims 
regarding PyPy made in this article.
http://www.computable.nl/nieuws.htm?id=1039941WT.mc_id=rss#reacties (see 
the section lower on the page).

For those unfamiliar with Dutch, his reaction translates into English as 
follows:

This is largely nonsense -- I indeed work for Google but I am not involved 
in PyPy, and the same applies to Google. In addition, PyPy is not being 
developed on behalf of the EU but is subsidized by the EU. See 
http://codespeak.net/pypy/dist/pypy/doc/news.html for more info on PyPy.



Regards,



Vincent Wehren






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

Re: what does 0 mean in MyApp(0)

2005-10-01 Thread vincent wehren
Alex [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Thanks for the replies. It seems that I have three options
| 1. app=MyApp()
| 2. app=MyApp(0)
| 3. app=MyApp('myfile.txt')
|
| 1. In the first case the output stream will be set to stdout/stderr,
| which means that errors will be sent to a window which will be closed
| when the app crashes.
| 2. In the second case the output will be set to the command prompt
| window, which means that I will be able to catch the errors when my app
| crashes.
| 3. There is also a third alternative which is to set the output to  a
| file.
|
| Alterbnative 2 is simple and useful, so that's why everybody use that
| alternative.
|
| Is that correct?

Not entirely:

1. app=MyApp(): stdout/stderr is redirected to its own window, so you're
right here
2. app=MyApp(0): stdout/stderr is not redirected to a window.
Tracebacks will show up at  the console. So you're right here to...

But:
3(a). app=MyApp(1, 'some/file/name.txt'):
   stdout/stderr is redirected to to the file 'some/file/name.txt').

The arguments you pass to MyApp are named parameters, so for improved
readability you may want to use:

3(b). app=MyApp(redirect=1, filename='some/file/name'): will redirect stdout
  to 'filespec'

and instead of 2:

2(b). app=MyApp(redirect=0) # stdout/stderr will stay at the console...

Anyway, if you omit the parameter names, make sure you you position them 
correctly, i.e., a filename should only be positioned as /second/ argument.

HTH,
--

Vincent Wehren



| Alex
| 


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


Re: what does 0 mean in MyApp(0)

2005-09-30 Thread vincent wehren
Alex [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| I'm looking at a tutorial with the code below
|
| from wxPython.wx import *
|
| class MyApp(wxApp):
|def OnInit(self):
|frame = wxFrame(NULL, -1, winApp, size = (800,640))
|frame.Show(true)
|self.SetTopWindow(frame)
|return true
|
| app = MyApp(0)
| app.MainLoop()
|
| Everything is explained nicely except the zero parameter in MyApp(0).
| Anybody knows what that zero refers to?

See:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334620
|

--
Vincent Wehren
| Alex
| 


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


Re: PyEphem on winXP

2005-09-22 Thread vincent wehren
[EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Hi,
|
| I'm a (sort of) newbie to python and would like to install the PyEphem
| extension to Python.  I'm using Python 2.4
| I obtained PyEphem from:
|  http://rhodesmill.org/brandon/projects/pyephem.html
|
| When i ran python setup.py install my error was:
|  error: Python was built with version 7.1 of Visual Studio, and
| extensions need to be built with the same version of the compiler, but
| it isn't installed
|
| Browsing this group led me to the following URL where I could get (for
| free) the Visual C++ Toolkit 2003:
| 
http://www.microsoft.com/downloads/details.aspx?FamilyId=272BE09D-40BB-49FD-9CB0-4BFA122FA91Bdisplaylang=en
|
| However I still see the same error when running
|  python setup.py install.
| I know that Visual C++ Toolkit 2003 is the same as version 7.1, but is
| this the same as Visual Studio 7.1?

It should work.

Did you follow the instructions as per
http://www.vrplumber.com/programming/mstoolkit/ ?

I've had success using that approach...


HTH,
--

Vincent Wehren


|
| If so, can Visual Studio 7.1 be obtained for free?
| If not, is there a workaround?
|
| I've seen suggestions in the group that you can recompile Python 2.4
| using MinGW or some other c compiler.  I'd be willing to do that, but
| do not know how to go about recompiling python.  Advice on this would
| also be helpful.
|
| Thanks,
| James
| 


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


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread vincent wehren

vj [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| When I run the setup.py script , it throws an error
|
| Traceback (most recent call last):
|  File C:\vijay\db2\utils\PyDB2-1.1.0-2.tar\PyDB2-1.1.0\setup.py,
| line 57, in -toplevel-
|libraries=[ db2lib ],
|  File C:\Python24\lib\distutils\core.py, line 137, in setup
|raise SystemExit, gen_usage(dist.script_name) + \nerror: %s % msg
| SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2
| [cmd2_opts] ...]
|   or: setup.py --help [cmd1 cmd2 ...]
|   or: setup.py --help-commands
|   or: setup.py cmd --help
|
| error: no commands supplied
| 
|
| Please let me know , what should have been the issue.

You need to say setup.py install instead of just setup.py

HTH,
--

Vincent Wehren

|
| Thanks in advance.
|
| Vj
| 


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


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread vincent wehren
vj [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|I am new to Python . Please let me where should I issue the command
| setup.py install.
|
| I have been using the IDLE to run Python scripts.

You need to open the command prompt (e.g. by entering cmd in the Run 
input box). Now enter cd C:\vijay\db2\utils\PyDB2-1.1.0-2.tar\PyDB2-1.1.0 
to get into the right directory. Now enter setup.py install and you should 
be all set..

--
Vincent




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


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread vincent wehren
vj [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Unfortunately I get another error
|
| Your DB2 root is: C:\Program Files\IBM\SQLLIB\
| running install
| running build
| running build_py
| creating build
| creating build\lib.win32-2.4
| copying DB2.py - build\lib.win32-2.4
| running build_ext
| error: The .NET Framework SDK needs to be installed before building
| extensions f
| or Python.

You need the same compiler Python 2.4 was compiled with to compile CPython 
extensions from source. Alternatively, you might look into getting some 
precompiled Windows Binaries for pydb2 (try Googling for them or the pyDB2 
mailing list).

HTH,
--

Vincent Wehren


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


Re: Problems with Python for Windows extensions

2005-09-04 Thread vincent wehren
KK [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| the code below is taken from M$ technet as an example on using vb
| script to do a replace all in word:
|
| Const wdReplaceAll  = 2
|
| Set objWord = CreateObject(Word.Application)
| objWord.Visible = True
|
| Set objDoc =
| objWord.Documents.Open(K:\Development\Fabricbase\prod\Test.doc)
| Set objSelection = objWord.Selection
|
| objSelection.Find.Text = Contoso
| objSelection.Find.Forward = True
| objSelection.Find.MatchWholeWord = True
|
| objSelection.Find.Replacement.Text = Fabrikam
| objSelection.Find.Execute ,,wdReplaceAll
|
|
|
|
| I did a rewrite and made it pythonic:
|
| from win32com.client import *
|
| wdReplaceAll  = 2
|
| objWord = Dispatch(Word.Application)
| objWord.Visible = True
|
| objDoc =
| objWord.Documents.Open(K:\Development\Fabricbase\prod\Test.doc)
| objSelection = objWord.Selection
|
| objSelection.Find.Text = Contoso
| objSelection.Find.Forward = True
| objSelection.Find.MatchWholeWord = True
|
| objSelection.Find.Replacement.Text = Fabrikam
| objSelection.Find.Execute (Replace = wdReplaceAll)
|
|
| However, the document juz loaded up in word but no action was taken. I
| am using Word 2003. Any ideas?

KK,

Your example seemed to work fine for me (Python2.4, Pythonwin build 204, 
Word 2003)

One thing: since you say your document loads up fine I don't know if it is 
just a typo, but make sure you follow the rules of backslash literals in 
path names. In other words:
K:\Development\Fabricbase\prod\Test.doc should read either

rK:\Development\Fabricbase\prod\Test.doc (note the leading r for raw 
string
or

K:\\Development\\Fabricbase\\prod\\Test.doc
or

K:/Development/Fabricbase/prod/Test.doc

--

Vincent Wehren





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


Re: zlib + Windows 32 service problem (ImportError)

2005-08-16 Thread vincent wehren

Laszlo Zsolt Nagy [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| vincent wehren wrote:
|
| Laszlo Zsolt Nagy [EMAIL PROTECTED] schrieb im Newsbeitrag
| news:[EMAIL PROTECTED]
| | Sorry, I realized that the import zlib was not executed from my
| | (working) service.
| | So here is the question: why can't I use zlib from a win32 service? Is
| | there any way to make it working?
| |
| | -
| | Python could not import the service's module
| |   File T:\Python\Projects\NamedConnector\Service.py, line 17, in ?
| | from Processor import *
| |   File c:\Python\Projects\NamedConnector\Processor.py, line 35, in ?
| | from mess import MessageSocket
| |   File T:\Python\Lib\mess\MessageSocket.py, line 31, in ?
| | import zlib
| | exceptions.ImportError: dynamic module does not define init function
| | (initzlib)
| | -
| |
| |
| |
| I had a similar problem where a zlib.dll that is *not a Python extension* 
is
| in sys.path *before* zlib.pyd. Python will try to import this zlib.dll 
and
| find the  dll doesn't export a initzlib:
| for more info see
| 
 http://mail.python.org/pipermail/python-list/2004-October/thread.html#248107
| 
| 
| Thanks. I set my system environment variable 'PATH' to this:
|
| 
C:\Python24;C:\Python24\DLLs;c:\Python24\Lib\site-packages\win32;c:\oracle\product\10.1.0\db_1\bin;c:\oracle\product\10.1.0\db_1\jre\1.4.2\bin\client;c:\oracle\product\10.1.0\db_1\jre\1.4.2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program
| Files\Common Files\GTK\2.0\bin
|
| Then I restarted my computer. It is still missing initzlib. :-(
| Please note that I can run the same program as an application, logged in
| as the same user.
|
|  Les

Changing the Windows dll search path doesn't make any difference. It is 
sys.path (Python's search path) that's causing you the headache. Please see 
the mentioned thread for proposed solutions.


Regards,
--

Vincent Wehren 


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


Re: zlib + Windows 32 service problem (ImportError)

2005-08-15 Thread vincent wehren
Laszlo Zsolt Nagy [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Sorry, I realized that the import zlib was not executed from my
| (working) service.
| So here is the question: why can't I use zlib from a win32 service? Is
| there any way to make it working?
|
| -
| Python could not import the service's module
|   File T:\Python\Projects\NamedConnector\Service.py, line 17, in ?
| from Processor import *
|   File c:\Python\Projects\NamedConnector\Processor.py, line 35, in ?
| from mess import MessageSocket
|   File T:\Python\Lib\mess\MessageSocket.py, line 31, in ?
| import zlib
| exceptions.ImportError: dynamic module does not define init function
| (initzlib)
| -
|
|
|
I had a similar problem where a zlib.dll that is *not a Python extension* is 
in sys.path *before* zlib.pyd. Python will try to import this zlib.dll and 
find the  dll doesn't export a initzlib:
for more info see 
http://mail.python.org/pipermail/python-list/2004-October/thread.html#248107

HTH,

Vincent Wehren




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


Re: py2exe windows apps path question

2005-08-02 Thread vincent wehren

Grant Edwards [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|I have several python apps (some wxPython, some plain text-mode
| stuff) that I distribute internally for installation on Win32
| machines.  They're bundled/installed using py2exe and inno
| setup.
|
| I followed what I think is the normal procedure of installing
| each app in its own directory under /Program
| Files/vendor/app.
|
| The problem is that the apps only run if they're started with
| the install directory as the current working directory.
| Otherwise they can't find the .dll's they use from the install
| directory.

AFAIK, Windows normally *does* search the directory where the executable 
module for the current process lives in for dlls. What sort of dlls are 
given you trouble?

--

Vincent Wehren




|
| Is there some way to temporarily add the app's install
| directory to the search path for .dll's?
|
| -- 
| Grant Edwards   grante Yow!  .. I think I'd
|  at   better go back to my 
DESK
|   visi.comand toy with a few 
common
|   MISAPPREHENSIONS... 


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


Re: py2exe windows apps path question

2005-08-02 Thread vincent wehren
Gregory Piñero [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]

|And here is how I make sure I'm always using the right directory in my 
scripts:
|
|Put this code at the top:
|import sys
|curdir=os.path.dirname(sys.argv[0])
|#print curdir
|Then I use curdir to build all of the paths in my app:
|For example let's get a list of files in a folder:
|lstresumes=os.listdir(os.path.join(curdir,resume_folder_path)) #get
|list of resumes

snipped

Greg,

If you need something that works both on a frozen app as well as an 
(unfrozen) python
script, you'd be better off using something like:

def getAppPrefix():
Return the location the app is running from

isFrozen = False
try:
isFrozen = sys.frozen
except AttributeError:
pass
if isFrozen:
appPrefix = os.path.split(sys.executable)[0]
else:
appPrefix = os.path.split(os.path.abspath(sys.argv[0]))[0]
return appPrefix

Now you can use the return value of getAppPrefix() everywhere you need to 
calculate paths relative to your app, regardless if it involves a regular 
script or py2exe'ified one.

Regards,

--

Vincent Wehren


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

Re: py2exe windows apps path question

2005-08-02 Thread vincent wehren
Grant Edwards [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| On 2005-08-02, vincent wehren [EMAIL PROTECTED] wrote:
| 
|  Grant Edwards [EMAIL PROTECTED] schrieb im Newsbeitrag
|  news:[EMAIL PROTECTED]
| |I have several python apps (some wxPython, some plain text-mode
| | stuff) that I distribute internally for installation on Win32
| | machines.  They're bundled/installed using py2exe and inno
| | setup.
| |
| | I followed what I think is the normal procedure of installing
| | each app in its own directory under /Program
| | Files/vendor/app.
| |
| | The problem is that the apps only run if they're started with
| | the install directory as the current working directory.
| | Otherwise they can't find the .dll's they use from the install
| | directory.
| 
|  AFAIK, Windows normally *does* search the directory where the executable
|  module for the current process lives in for dlls. What sort of dlls are
|  given you trouble?
|
| One's a driver for a CAN bus USB widget.  The other failure
| that springs to mind is that gnuplot-py couldn't find something
| (could have been an .exe) that was in the app directory.

Grant,

If you are building paths in you code that are relative to your app, please 
see my reply to Greg's post. If not, you may as a workaround want to try to 
add the frozen application's directory to the system path environment 
variable. Windows will look for dlls there, too.

To get the app's actual location, you will need something like the 
getAppPrefix() function as per my reply to Greg's reply. The getAppPrefix() 
function will also hold when the user adds your frozen app to his/her system 
path and call the app from any location from the command line - sys.argv[0] 
just won't do the trick in such a setting.


HTH,

--

Vincent Wehren










|
| -- 
| Grant Edwards   grante Yow!  HUGH BEAUMONT 
died
|  at   in 1982!!
|   visi.com 


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


Re: py2exe windows apps path question

2005-08-02 Thread vincent wehren

Gregory Piñero [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
 If you need something that works both on a frozen app as well as an
 (unfrozen) python
 script, you'd be better off using something like:

 def getAppPrefix():
 Return the location the app is running from
 
 isFrozen = False
 try:
 isFrozen = sys.frozen
 except AttributeError:
 pass
 if isFrozen:
 appPrefix = os.path.split(sys.executable)[0]
 else:
 appPrefix = os.path.split(os.path.abspath(sys.argv[0]))[0]
 return appPrefix


Vincent,

This sounds interesting.  A few questions for you:
Why don't I see sys.frozen in interpreter?
Does it only appear when it is frozen?

Yes. The sys.frozen attribute is added by py2exe.

What do you mean by frozen, how does python know?

Python doesn't know - it is just told so ;)

What does sys.executable do?

sys.executable gives you the path of the executing binary. Normally, this 
will be something like
c:\\python24\\python.exe - since the interpreter is the executing binary.
Once you have frozen your python application, it will return the path to 
your app.


--

Vincent


Thanks,

Greg 


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

Re: Running Python scripts under W2K with I/O redirection

2005-06-25 Thread vincent wehren

[EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|I apologise if this is a well known problem. I've searched and can't
| find a clear description or fix. Hope someone can help.
|
| I am running my Python scripts under Windows 2000 using Python 2.4
| Build 243 from Activestate.
|
| If I want to specify a file as standard input to my script I can just
| enter a command like:
|
|  H:\ pyscript.py file.inp
|
| and that's what I get. All ok so far.
|
| However if I enter commands like:
|
|  H:\ type file.inp | pyscript.py
|
| or
|
|  H:\ pyscript.py  file.inp
|
| It doesn't work. I've also tried the variant of parsing for a command
| line argument of '-' or 'filename' and then specifically either copying
| the sys.stdin file object or opening the file specified, then using
| that file object. Same problem.
|
| Interestingly enough, if I specify my commands as:
|
|  H:\ type file.inp | python pyscript.py
|
| or
|
|  H:\ python pyscript.py  file.inp
|
| It all works the (unix-like) way I wanted it to. This leads me to
| suspect there is something wrong in the way that Python is being
| invoked by Windows in my problem situation rather than an inherent
| fault within Python itself.

Your suspicion is correct

see:

http://support.microsoft.com/default.aspx?kbid=321788

--

Vincent Wehren



|
| Does anyone have any idea what the problem could be and how to fix it?
| I know its a really minor niggle but it'd make this poor deprived
| unix-guy-forced-into-windows-servitude very happy.
|
| Thanks,  sub1ime_uk
|
| sub1ime_uk (at) yahoo (dot) com
| 


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


Re: tab 2 into tab 4 ?

2005-06-19 Thread vincent wehren

[EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Hello,
|
| I have python code which use tab=2. Recently I would like to change it
| into tab=4.
|
| Anyone has suggestion to convert easily and safely ?

Look at reindent.py in Tools\Scripts.

--

Vincent Wehren


|
| pujo
| 


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


Re: How to get/set class attributes in Python

2005-06-12 Thread vincent wehren

Peter Dembinski [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Kalle Anke [EMAIL PROTECTED] writes:
|
| [snap]
|
|  sys.maxint = -12345
| 
|  I don't really understand what you're meaning.
|
| He meant None = 1 :

I'm sure you know that has become a no-no in Python 2.4+ ;)

 None = 1
SyntaxError: assignment to None



--
Vincent Wehren







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


Re: DB API 2.0 and transactions

2005-06-07 Thread vincent wehren
Christopher J. Bottaro [EMAIL PROTECTED] schrieb im
Newsbeitrag news:[EMAIL PROTECTED]
| Hi,
| Why is there no support for explicit transactions in the DB API?  I mean
| like transaction() to start the trans and commit() and rollback() would
end
| the trans or something.
|
| The reason why I ask is because I wrote a daemon that interacts with a
| Postgres DB.  The value of CURRENT_TIMESTAMP according to Postgres is NOT
| the actual walltime, but the walltime when the current transaction
started.
|
| This gets weird when using the Python DB API to interact with Postgres
| because a transaction gets started in 3 places:  connection, commit,
| rollback.
|
| So consider the daemon:
|
| [pseudo code]
| connect # begin trans at 12:00
| sleep waiting # lets say 15 mins
| wake up
| put entry in db using CURRENT_TIMESTAMP # oops
| [/code]
|
| Oops, the CURRENT_TIMESTAMP evaluates to 12:00, not 12:15.
|
| Now I know there are ways around this...
| 1)  In Postgres, you can get the walltime and cast it to a timestamp.
| 2)  In Python, you can just do an empty commit in order to manually
start
| a new transaction.
|
| I just think its a bit weird because this bit me in the butt for quite a
| while and this didn't happen when doing the same thing in other langs.
|
| Anyone have any opinions on this?

The described behavior seems to be totally in synch with expectations

(both in accordance with PostgreSQL docs and the DB-API.)

These other languages *must* be doing something wrong! ;)

( Auto-commit set to on perhaps? )



Regards,

-

Vincent Wehren


|



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


Re: Python Exercises for Newbee

2005-05-30 Thread vincent wehren
Kanthi Kiran Narisetti [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Hi ALL,

Hi to you too!

|
| I am Windows Administrator, moving little ahead from batch files and
| scripts I started learning Python. I found that Python is very easy and
| is very well documented. Still I am looking more than examples. As a
| beginner i want to do lot of excersice from simple addition to complex
| ...which help me to understand the concepets more clearly.

have you already perused the Python Cookbook?

http://aspn.activestate.com/ASPN/Python/Cookbook/



As a Windows admin, you may also be interested in looking at
Tim Golden's Python Stuff:

http://tgolden.sc.sabren.com/python/index.html


Enjoy!

--
Vincent Wehren


|
| I appreciate if any one can give me such exersices or any link for the
| same.
|
|
| Thank You ,
| Kanthi Kiran
| 


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


Re: need help of RE

2005-05-29 Thread vincent wehren

cheng [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| hi all
| a string like
|
| (word1  (Word2|woRd3))
|
| how can i use the re to split it to
|
| ['word1', 'word2', 'word3']
|

import re
s = (word1  (Word2|woRd3)
parts = re.split('\W+', s)
print [p for p in parts if p]

--

Vincent Wehren 


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


Re: Problem redirecting stdin on Windows

2005-05-26 Thread vincent wehren
aurora [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| On Windows (XP) with win32 extension installed, a Python script can be
| launched from the command line directly since the .py extension is
| associated with python. However it fails if the stdin is piped or
| redirected.
|
| Assume there is an echo.py that read from stdin and echo the input.
|
|
|
| Launching from command line directly, this echos input from keyboard:
|
|   echo.py
|
|
|
| But it causes an error if the stdin is redirected
|
|   echo.py textfile
|
|
|   ...
|   for line in fp:
|   IOError: [Errno 9] Bad file descriptor
|
|
|
| However it works as expected if launched via Python.exe
|
|   c:\Python24\python.exe echo.py textfile
|
|
|
| Why is the second option fails? It makes many script lot less functional.

See:
http://mail.python.org/pipermail/python-bugs-list/2004-August/024920.html

--
Vincent Wehren


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


Re: install python 2.4.1

2005-05-22 Thread vincent wehren

[EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| hi,
|
| I use python 2.4 and
| I would like to install python 2.4.1. Is it necessary to uninstall the
| first version or just install 2.4.1?

What platform? If you're on Windows and are using the msi-Installer, 
uninstalling is recommended.
It will also work without uninstalling, but IIRC, Windows Installer will 
zealously inspect the file version
of each individual file down the Python24 tree to detect necessary disk 
space and so forth, which can take quite some time.


|
| Does it effect pydef (eclipse editor) or komodo ide ?

Don't know..

--
Vincent Wehren

|
|
| pujo
| 


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


Re: iso_8859_1 mystery/tkinter

2005-05-18 Thread vincent wehren

Martin v. Löwis [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| phil wrote:
|  These work fine on Linux
|  s.const = {}
|  s.const['DEG'] = '%c' % (0xb0)
|  s.const['DIV'] = '%c' % (0xf7)
|  s.const['ANG'] = '%c' % (0xd8)
| 
|  On WinXP the symbols for division and angle work fine.
|  But the symbol for degrees, a little circle, produces
|  a vertical bar in Tkinter Text box or Canvas.
|
| I don't understand what you mean by that. Do you have
| the symbol for degrees in your source code (so that
| the editor for the source code displays it as a little
| circle)? Or do you use the numeric code?
|
| Can you show a small program that demonstrates this
| effect?

OP probably means something like:

import Tkinter
root = Tkinter.Tk()
t = Tkinter.Text()
t.pack()
t.insert(0.0, '%c' % 0xb0)
root.mainloop()

which shows a vertical bar in the Text widget.

Changing:

t.insert(0.0, '%c' % 0xb0)

to

t.insert(0.0, u'%c' % 0xb0)


should do the trick though.

--

Regards,

Vincent Wehren

|
| Regards,
| Martin
| 


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

Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread vincent wehren

john67 [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| The company I work for is about to embark on developing a commercial
| application that will cost us tens-of-millions to develop.  When all is
| said and done it will have thousands of  business objects/classes, some
| of which will have hundreds-of-thousands of instances stored in a DB.
| Our clients will probably have somewhere between 50-200 users working
| on the app during the day, possibly in mutiple offices, and then a
| large number of batch processes will have to run each night.  It will
| also need to have a web interface for certain users.  It needs to be
| robust, easy to maintain, and able to be customized for each client.
|
| Right now it looks like Java is the language of choice that the app
| will be developed in. However, I have been looking and reading a lot
| about Python recently and it seems to me that Python could handle it.

If the application is really huge, you should consider using
a set of programming languages that do the particular job best.
That is, go for a complementary, concurrent approach in your choice
of programming  languages. I wouldn't want to religiously stick to any
one language just for the sake of being religious.

I am sure that from a best-for-the-job perspective, Python is a serious
candidate for most of them. The aspects robust, easy to maintain, and
suitable for customization that you envision as properties
for your application are properties that need to be matched the
language(s) of choice, as well. Again, here Python is a more than serious
contender.


Regards,
--

Vincent Wehren





| The big attraction to me is the developer productivity.  It seems that
| if Python can handle it, then we could gain a huge savings by using
| Python instead of Java from a productivity standpoint alone.
|
| So, given the very general requirements in the first paragraph, do you
| think that Python could handle it?  If anyone has direct experience
| developing large apps in Python, I would appreciate your insight.
| Based on the responses I get, I am planning on writing a proposal to my
| management to consider Python instead of Java.
|
| Thanks,
| John
| 


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


Re: Multiple cmps chained one after another

2005-05-14 Thread vincent wehren

Volker Grabsch [EMAIL PROTECTED] schrieb im 
Newsbeitrag news:[EMAIL PROTECTED]
| Hello!
|
| Ich just found a very nice 'pythonic' solution for an often appearing
| problem. I didn't find it documented anywhere, so I'm posting it here.
| If this isn't new in any way, I'd really like to get to know it.
|
| Example problem:
| I have some datetime objects and want to sort them, as here:
|
| birthdays = [d1,d2,d3,d4]
| birthdays.sort()
|
| However, I don't want to sort them the default way. These are birthdays,
| so only the month and day do matter, not the year. E.g.:
|
| 2003-01-01  should be smaller than  1984-05-01
|
| So I have to write the comparison on my own, e.g.
|
| def cmp_birthdays(d1,d2):
| if d1.month  d2.month: return 1
| if d1.month  d2.month: return -1
| if d1.day  d2.day: return 1
| if d1.day  d2.day: return -1
| return 0
|
| ...
| birthdays.sort(cmp_birthdays)


If you don't care about the year, why not just normalize the year
to all be the same using the replace method of the date instance?
Something like:

d1 = datetime.date(2004, 12, 2)
d2 = datetime.date(2001, 12, 3)
d3 = datetime.date(2002, 12, 6)
d4 = datetime.date(1977, 12, 7)
dates =[d1,d2,d3,d4]
datesNorm = [obj.replace(year=1900) for obj in (dates)]
datesNorm.sort()
print datesNorm # etcetera


HTH,

---
Vincent




|
| This implementation of cmp_birthdays is very ugly. Image you want to
| chain more than 2 values in that cmp_birthdays. I also want to use the
| builtin cmp function, not  and .
|
| After thinking some minutes about it, I found a very nice solution:
| I have some cmps one aftter another. If one if them return 1 oder -1,
| it sould be returned. If it returns 0, the next cmp is used. In other
| words: I have a sequence of numbers, and want to get the first one that
| is not 0. (or return 0, if all numbers were 0)
|
| But this is exactly what the or operator does, due to short-circuit
| evaluation. In this example, that means:
|
| def cmp_bithdays(d1,d2):
| return cmp(d1.month,d2.month) or cmp(d1.day,d2.day)
|
| The generic pattern is:
|
| return cmp(...) or cmp (...) or cmp(...) or ...
|
| I'm not sure whether this pattern is already a common recipe, but
| I found it to be a very nice idea. :-)
|
| Any opinions?
|
|
| Greets,
|
| Volker
|
| -- 
| Volker Grabsch
| ---(())---
| \frac{\left|\vartheta_0\times\{\ell,\kappa\in\Re\}\right|}{\sqrt
| [G]{-\Gamma(\alpha)\cdot\mathcal{B}^{\left[\oint\!c_\hbar\right]}}} 


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


Re: Proxy Design Advice Needed

2005-05-11 Thread vincent wehren

[EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
 Hello,

 I need a way to get a notification whenever a variable of an object
 changes. The approach should be non-intrusive so that I can use
 existing objects without modifying them.
 I want to be notified no matter who or what did change the wrapped
 object - even whenever an object internal methods changes the
 variables.
 So I coded the piece of code shown below (just copy and paste it, it's
 ready-to-run).
 It's basically a Proxy class that takes an object and whenever somebody
 tries to access the proxy, the proxy forwards this to the real object.
 Whenever a method of the obj gets called the proxy detects this and the
 operation is performed on the the proxy object so that variable change
 notifications can be send.
 Since I am quite new to Python and the code does not 100% what I want,
 I have the feeling, it's not optimal and that there might be a better
 way to achieve what I want. For example I am not sure if really all
 changes will be catched this way and if the method call re-routed to
 proxy object is not a bit hackish. Second, type(Proxy()) doesn't return
 the same as type(WrappedObj()). The proxy should behave identical to
 the wrapped object. Should I do this with metaclasses to get the type
 right or are there better ways? I am not sure if they could fit here or
 not.
 So, what do you think of this code and how should I improve it?

 Thanks a lot for your help!

 -Matthias

This may be help:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/366254

--
Vincent Wehren



 Code (just copy and pasts and it should run):

 import inspect, new, sys

 class Proxy(object):
def __init__(self, wrappedObj):
# need to call object here to save objs to our own dict
object.__setattr__(self,'_wrappedObj',wrappedObj)
object.__setattr__(self,'_observers',{})

def __getattribute__(self, name):
# if attribute of proxy obj itself was queried return that
 value
if name in ['_wrappedObj','_observers','Subscribe','Notify']:
return object.__getattribute__(self, name)
# otherwise get var from the wrapped object
attr = getattr( object.__getattribute__(self, '_wrappedObj'),
 name )
# make method use this proxy object instead of wrapped one to
 catch updates
if inspect.ismethod( attr ):
return new.instancemethod( attr.im_func, self,
 attr.im_class )
else:
return attr

def __setattr__(self, name, value):
# sets attribute of the wrapped value
setattr(object.__getattribute__(self,'_wrappedObj'), name,
 value)
# notify me of change
object.__getattribute__(self,'Notify')('Changed',name, value)

# Adds an observer
def Subscribe(self, function, event = ''):
self._observers.setdefault(event,[]).append(function)

# Notifies all observers
def Notify(self, event = '', *args):
for observer in self._observers.get(event, []):
observer(*args)


 class TestObj(object):
classVar = 'cv'
def __init__(self):
self.spam = '1'

def method(self):
self.spam = '2'

 # create a proxy
 p = Proxy(TestObj())

 # print some info of it
 print 'Proxy: %s ' % p
 print 'Class of proxy: %s' % p.__class__
 print 'Type of proxy: %s  --- this sucks' % type(p)
 print 'Dir of proxy: %s' % dir(p)

 # enable watching changes
 p.Subscribe(lambda name, var: sys.stdout.write('%s was changed and is
 now %s\n' % (name,var) ) ,'Changed')

 # change some stuff
 p.method()
 p.cv = 'new cv'
 p.spam = 1
 p.func = lambda x: x-1
 print p.func(2)
 


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


Re: computer unable to load _pysvn.pyc

2005-05-08 Thread vincent wehren
Timothy Smith [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Timothy Smith wrote:
|
| this is truely maddening
| 
| Traceback (most recent call last):
|   File PubWare.py, line 11, in ?
|   File Main.pyc, line 46, in ?
|   File pysvn\__init__.pyc, line 12, in ?
|   File pysvn\_pysvn.pyc, line 9, in ?
|   File pysvn\_pysvn.pyc, line 7, in __load
| ImportError: DLL load failed: A device attached to the system is not
| functioning.
| 
| any ideas? it works perfectly on another computer
| 
| 
| ok more information - windows 98 computers have this issue, xp computers
| are fine.
| how do i work around this? obviously one of the pysvn dll's won't load
| on win98.

First, you will need to establish which .dll this is. Than check if the .dll 
has any dependencies that are not present on the host system (using 
depends.exe for example) -- i.e. function calls that are not supported.

--

Vincent Wehren


| note this is  py2exe package made on a windows xp system
| 


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


Re: Looking for Example of wxFontEnumerator Use

2005-05-05 Thread vincent wehren
weston [EMAIL PROTECTED] schrieb im 
Newsbeitrag news:[EMAIL PROTECTED]
| Can anyone give an example of proper usage of wxFontEnumerator?


In the wxPython Demo: wxPython Overview  Miscellaneous  FontEnumerator

If you haven't downloaded the demo/docs yet, you should. You can get your 
version
from http://wxpython.org/download.php.


Regards,
--

Vincent Wehren


|
| Thanks,
|
|   Weston
| 


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


Re: a cx_Oracle ORA-01036 problem

2005-05-05 Thread vincent wehren
Damjan [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| I'm using Python 2.4, cx_Oracle-4.1 on Linux with Oracle instant client
| 10.1.0.3. This is the sql string:
|
| SQL = insert into D.D_NOTIFY values (:CARDREF, :BANKKEY, :OK1, :OK2 \
|:DEBTEUR, :DEBTDEN, to_date(:INVOICE_DATE,'DD.MM.YY'),
|to_date(:PAYMENT_DEADLINE,'DD.MM.YY'), :POINTS)
|
| And I'm trying to execute it as:
|c = db.cursor()
|c.execute(SQL, CARDREF=id, BANKKEY=dc_kluc, OK1=okd, OK2=okc,
|  DEBTEUR=iznos_eur, DEBTDEN=iznos_mkd, INVOICE_DATE=datum_g,
|  PAYMENT_DEADLINE=datum_d, POINTS=bodovi)

| And I get an ORA-01036 exception.
|
| I also have tried
|args = dict(CARDREF=id, BANKKEY=dc_kluc, OK1=okd, OK2=okc,
|  DEBTEUR=iznos_eur, DEBTDEN=iznos_mkd, INVOICE_DATE=datum_g,
|  PAYMENT_DEADLINE=datum_d, POINTS=bodovi)
|c = db.cursor()
|c.execute(SQL, **args)


Shouldn't that be c.execute(SQL, args) (no **-unpacking of the dictionary)?

--

Vincent Wehren


| Same thing.
|
| Everything works If I use python string substituion, like this sql:
| SQL = insert into D.D_NOTIFY values (%s,'%s','%s','%s','%s','%s', \
|to_date('%s','DD.MM.YY'),to_date('%s','DD.MM.YY'),'%s') % fields
|
| Any ideas?
|
|
| -- 
| damjan 


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


Re: [Errno 9] Bad File Descriptor on Windows 2003 Server Py 2.4.1

2005-05-03 Thread vincent wehren
rbt [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| The below script produces a '[Errno 9] Bad File Descriptor' when
| executed. If I remove the try: except: statements, the script stops when
| the error occurs.
|
| The purpose of the script is to monitor the size of the three main logs
| on a Windows 2003 server and send and email should any of the logs get
| shorter. It works fine... just don't know *why* it produces the '[Errno
| 9] Bad File Descriptor' error.
|
| I'm running Python 2.4.1 on Windows 2003 SP1 Server with no funky win32
| extensions ;)
|
| logs = ['AppEvent.Evt', 'SecEvent.Evt', 'SysEvent.Evt']
|
| app_size = 0
| sec_size = 0
| sys_size = 0
|
| def send_email(LogName, old_size, new_size):
| f = Somebody[EMAIL PROTECTED]
| t = [EMAIL PROTECTED]
|
| msg = MIMEText(old_size = %d, new_size = %d %(old_size,
| new_size))
|
| msg[Subject] = %s Log Just Got Shorter %LogName
| msg[Message-id] = email.Utils.make_msgid()
| msg[From] = f
| msg[To] = t
|
| h = smtp.vt.edu
| s = smtplib.SMTP(h)
| s.sendmail(f, t, msg.as_string())
| s.quit()
|
| while 1:
|
| for log in logs:
|
| try:
|
| a = os.stat('C:\WINDOWS\System32\config\%s' %log)

Without looking at the rest of script:

Try using either escaped backslashes as in:

a = os.stat('C:\\WINDOWS\\System32\\config\\%s' %log)

or a raw string (as long as it doesn't end with a single backslash) as in:

a = os.stat(r'C:\WINDOWS\System32\config\%s' %log)

or simply use forward slashes as in:

a = os.stat('C:/WINDOWS/System32/config/%s' %log)




--

Vincent Wehren







| cur_size = a[6]
| print log
| print cur_size, cur_size
|
| if log == 'AppEvent.Evt':
| print old_size, app_size, \n
| if cur_size = app_size:
| app_size = cur_size
| time.sleep(6)
| continue
| else:
| send_email(log, app_size, cur_size)
| time.sleep(6)
| continue
|
| elif log == 'SecEvent.Evt':
| print old_size, sec_size, \n
| if cur_size = sec_size:
| sec_size = cur_size
| time.sleep(6)
| continue
| else:
| send_email(log, sec_size, cur_size)
| time.sleep(6)
| continue
|
| else:
| print old_size, sys_size, \n
| if cur_size = sys_size:
| sys_size = cur_size
| time.sleep(6)
| continue
| else:
| send_email(log, sys_size, cur_size)
| time.sleep(6)
| continue
|
| except Exception, e:
| fp7 = file('log_mon_exception.txt', 'a')
| print  fp7, e
| fp7.close() 


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


Re: trouble with lists

2005-05-03 Thread vincent wehren

[EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| I'm new to python. I tried doing this
|
|  x = [[]] * 3
|  print x
| [ [] [] [] ]
|  x[0].append( 2 )
| [ [2] [2] [2] ]
|
| I confused with the last line output. I actually expected something
| like
|
| [ [2] [] [] ]
|
| Can anyone give me an explanation. help!!

The library reference can!
See http://docs.python.org/lib/typesseq.html

Look at the section notes (2):

Values of n less than 0 are treated as 0 (which yields an empty sequence 
of the same type as s). Note also that the copies are shallow; nested 
structures are not copied. This often haunts new Python programmers; 
consider:

 lists = [[]] * 3
 lists
[[], [], []]
 lists[0].append(3)
 lists
[[3], [3], [3]]etc.
--
Vincent Wehren



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


Re: using locales

2005-04-20 Thread vincent wehren

[EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|
| Is there some sort of tutorial on locales or the locale module?
|
| I can't seem to find a list showing all possible locales. I made 'en'
| work alright, but when I tried 'de' or 'de_DE' or 'es_ES', etc. it said
| that those were not valid locaes. Worst of all, when I tried 'es' it
| said that this was estonian?! Obviously, this is not what ISO 639 says.
| 'es' should be Spanish, and Estonian should be 'et.

What makes you think that the underlying C-runtime library cares about
ISO639? If you're on Windows (which from what you've written I assume you 
are), you might want to look at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_language_strings.asp

(Unfortunately, I know for a fact that this list is *not* exhaustive, at 
least not for WIN2K or XP.)

In addition, you might want to keep in mind - and again this applies to the 
Windows platform - that what is returned by locale.getdefaultlocale is not 
suitable as input for the the country/language argument of locale.setlocale 
(which is somewhat of a pitty, cause I sometimes wish I could do something 
like locale.setlocale(locale.LC_ALL, 
..join(locale.getdefaultlocale()) ).

However, if you really need super-deluxe localization/national language 
support independent of the C runtime on Windows you may need to wrap the 
appropriate functions living in winnls.h (or the version of winnls.h 
contained in the platform SDK) - some of which may have already found there 
way into the Python for Win32 Extensions (GetDateFormat for example).


Regards,

--

Vincent Wehren

|
| Anyway, I'd love to have a method called get_available_locales to tell
| me what I can use on my machine, or something like that.
|
| Can anyone tell me how I *do* get these names?
|
| Thanks
| 


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


Re: Encoding Questions

2005-04-19 Thread vincent wehren

[EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| 1. I download a page in python using urllib and now want to convert and
| keep it as utf-8? I already know the original encoding of the page.
| What calls should I make to convert the encoding of the page to utf8?
| For example, let's say the page is encoded in gb2312 (simple chinese)
| and I want to keep it in utf-8?

Something like:

utf8_s = s.decode('gb2312').encode('utf-8')

- with s being the simplified chinese string - should work.

|
| 2. Is this a good approach? Can I keep any pages in any languages in
| this way and return them when requested using utf-8 encoding?
|
| 3. Does python 2.4 support all encodings?

See http://docs.python.org/lib/standard-encodings.html for an overview.

|
| By the way, I have set my default encoding in Python to utf8.
|

Why would you want to do that?

--

Vincent Wehren

|
| I appreciate any help.
|
| -JF
| 


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


Re: String manipulation

2005-04-13 Thread vincent wehren
Nicholas Graham [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|
| I'm writing a program that requires some string manipulations.  Let's say
| I have a string
|
| s='x'
|
| Now, the ascii code for 'x' is 0x78.  I want to be able to perform
| operations on this number, and print the character corresponding to the
| results of the operation.  For example, the pseudo-code looks like:
|
| -read in string s from external file (for simplicity, we'll keep s='x')
|
| -determine the code for s (should be 0x78 or 120 in base 10), store it in
| variable c
|
| -add a literal to c (let's say c=c+1)
|
| -find out which character corresponds to the new code c=0x79
|
| -store the character in a new string s2
|
| At the end of this, I want s2='y'
|
| Any suggestions?

Take a look at the built-in functions ord() and chr() -- Chapter 2.1 of the 
manual.

 s = 'x'
 c = ord(s)
 c
120
 c+=1
 s2 = chr(c)
 s2
'y'

--

Vincent Wehren

|
| NG
| 


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


Re: How to minimize the window

2005-04-12 Thread vincent wehren
Austin [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|I wrote a GUI program with wxPython.
| In the window, there are 3 attributes on left top.
| _ could let the program to minimize to tool bar.
| I want to let the program minimized to the system tray.

You can take look at Main.py in the wx Demo.

Look for class DemoTaskBarIcon(wx.TaskBarIcon) and how it is
used in the wxPythonDemo class.

| Is there any way to let the window have 4 attributes?
| .  _  O  x

Not that I know of.

HTH,
--

Vincent Wehren



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


Re: help with wxPython and wxGrid

2005-04-10 Thread vincent wehren
Sam the Cat [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| using from wxPython.wx import * under python2.3 I cannot seem to find 
the
| wxGrid class -- it says its undefined -- am I missing something obvious ? 
I
| know the globalspace import is not the best, but that how I got started
| ;) -- any help owuld be appreciated
|
|

Try:

from wxPython.wx import *
from wxPython.grid import *

or

import wx
import wx.grid

--
Vincent Wehren 


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


Re: How to detect windows shutdown

2005-04-07 Thread vincent wehren
Austin [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|I wrote a GUI program with wxPython.
| The error message is:
|
| Unhandled exception
| An unhandled exception occured. Press Abort to terminate the program,
| Retry to exit the program normally and Ignore to try to continue.
|
| Actually, besides the main program, there is another thread running
| background.
|
|
|
|
|  Austin wrote:
|  I wrote a program running on windows.
|  I put the link of the program in Start up folder and let it executed
|  minimized.
|  Every time when I open the computer, my program will be running in 
system
|  tray.
| 
|  But if the user would like to shutdown the computer, the OS will show 
an
|  error about exception.
| 
|  Important missing information:  is this a GUI program or
|  a console program, and if it's a GUI program, what framework
|  did you use to write it (wxPython, PyQt, other...)?  Also,
|  what is the exception that you got?  (Always report the
|  specific error: we can't guess what exception you got,
|  and the answer could well point directly to a cause that
|  is different than you think it is.)
| 
|  -Peter

Does this problem also occur when you manually exit the program (provided
you have a function to do so)?

If so, make sure you do something like self.tbicon.Destroy() -- with
self.tbicon being your instance of wx.TaskBarIcon() -- in your
event handler bound to wx.EVT_CLOSE.

HTH,

--

Vincent Wehren




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


Re: Performance issue

2005-04-02 Thread vincent wehren
Tom Carrick [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Hi,
|
| In my attempted learning of python, I've decided to recode an old
| anagram solving program I made in C++. The C++ version runs in less
| than a second, while the python takes 30 seconds. I'm not willing to
| think it's just python being slow, so I was hoping someone could find
| a faster way of doing this. Also, I was wondering if there was a more
| builtin, or just nicer way of converting a string to a list (or using
| the sort function on a list) than making a function for it.
|
| The words.txt here is just a copy of FreeBSD's /usr/share/dict/words
|
| Anyway, the code:
|
| import string

You're importing string, but never use it, so you can omit that line.

|
| # Need a function to convert a string to a list to be
| # able to use the sort() function
| def string2list(s):
|l = []
|for i in range(0, len(s)):
|l.append(s[i])
|return l

No need to write your own function. list(s) already does the trick.

|
| words = []
| found = []
|
| anagram = raw_input(Find anagrams of word: )
|
| f = open('words.txt', 'r')
| file = f.read()
| f.close()


I don't have a copy of words.txt, but here's what I would try
(untested):

anagram = raw_input(Find anagrams of word: )
sorted_anagram = list(sorted(anagram.lower()))
# If you're Python is pre 2.4 ise
# sorted_anagram = list(anagram.lower())
# sorted_anagram.sort() #--sort list in place


found = []
# assuming words.txt contains a word per line
# iterate over the lines of the file

for line in open(/path/to/words.txt):
word = line[:-1]# Get rid of trailing newline
sorted_word = list(sorted(word.lower()))
if sorted_word == sorted_anagram:
found.append(word)
if found:
print Anagrams of %s: % anagram
for w in found:
print w
else:
print No anagrams for %s % anagram


--

Vincent Wehren




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


Re: AttributeError: ClassA instance has no attribute '__len__'

2005-03-30 Thread vincent wehren
MackS [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| I'm new to Python. In general I manage to understand what is happening
| when things go wrong. However, the small program I am writing now fails
| with the following message:
|
| AttributeError: ClassA instance has no attribute '__len__'
|
| Following the traceback,I see that the offending line is
|
| self.x = arg1 + len(self.y) + 1
|
| Why should this call to the built-in len() fail? In a small test
| program it works with no problems:
|
| class foo:
|  def __init__(self):
|self.x = 0
|self.y = 'y'
|
|  def fun(self, arg1):
|  self.x = arg1 + len(self.y) + 1
|
|  a = foo()
|  a.fun(2)
| 
|
| No problems; can you help me make some sense of what is happening?

In your program, self.y is an instance of ClassA. The traceback tells you 
that ClassA has no __len__ attribute (i.e.
it is an object that has no no special method called __len__, which is 
what gets called
when you do len(obj).

In your test program, self.y is y, a string, which has a __len__ method by 
design:
(see dir(y), which gives you:

['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', 
'__ge__', '__getattribute__', '__getitem__', '__getnewargs__', 
'__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', 
'__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', 
'__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', 
'__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 
'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 
'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 
'replace', 'rfind', 'rindex', 'rjust', 'rsplit', 'rstrip', 'split', 
'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 
'upper', 'zfill']

If you want len(self.y) to work, self.y must be an object that implements a 
__len__ method. In other words, your ClassA needs a __len__ method.

A trivial example:

class ClassA:
def __init__(self, text):
   self.text = text
def __len__(self):
   #return something useful
   return len(self.text)

y = ClassA(Hello)
print len(y) # prints 5


Regards,

--
Vincent Wehren


|
| Thanks in advance
|
| Mack
| 


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


Re: [Python-Dev] RELEASED Python 2.4.1, release candidate 1

2005-03-13 Thread Vincent Wehren
Martin v. Löwis wrote:
Vincent Wehren wrote:
is there a reason why msiexec iterates through what looks like all (?) 
files and directories in/under the destination directory? There is 
massive file I/O going on there (OK, by now you know I didn't 
de-install 2.4 before trying ;-)) which explains the 100% CPU usage 
and the time it takes for the Next button to respond.

I think it is trying to estimate disk usage. To compute the disk usage
correctly, you need to find out
- what files are new files
- what files are going to be deleted
- what files are goging to be replaced
- what files are going to stay

Ah! Thanks for explaining. So this also explains why the indicated 
required disk space on the Customize dialog with the Python item 
selected was a mere 673kb (or was it 637kb - don't recall exactly) - 
this must the size difference between 2.4.0 and 2.4.1 then...

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


Re: [Python-Dev] RELEASED Python 2.4.1, release candidate 1

2005-03-11 Thread Vincent Wehren
Martin v. Löwis wrote:
Anthony Baxter wrote:
On behalf of the Python development team and the Python community, I'm
happy to announce the release of Python 2.4.1 (release candidate 1).
Python 2.4.1 is a bug-fix release. See the release notes at the website
(also available as Misc/NEWS in the source distribution) for details of
the bugs squished in this release.

I'd like to encourage feedback on whether the Windows installer works
for people. It replaces the VBScript part in the MSI package with native
code, which ought to drop the dependency on VBScript, but might
introduce new incompatibilities.
Regards,
Martin
Hi Martin,
is there a reason why msiexec iterates through what looks like all (?) 
files and directories in/under the destination directory? There is 
massive file I/O going on there (OK, by now you know I didn't de-install 
2.4 before trying ;-)) which explains the 100% CPU usage and the time it 
takes for the Next button to respond.

--
Vincent Wehren

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


Re: Tkinter WEIRDNESS or Python WEIRDNESS?

2005-03-11 Thread Vincent Wehren
steve wrote:
In a nutshell, my problem is that I am getting this runtime error, and
I have no clue why.  Please bear in mind its my first python program:
localvariable 'currentAbility' referenced before asignment
If you're assigning an object to a name, it will be assigned to that 
name in local namespace. So, in your case, you are doing augmented 
assignment on a local name that does not yet exist (hence the error 
message). You need to tell the interpreter that what you want is assign 
to that name in global namespace. You can do this by using the 'global' 
statement, as in:

 my_global = 1
 def some_func():
...global my_global
...my_global += 1
 some_func()
 my_global
2
--
Vincent Wehren
--
http://mail.python.org/mailman/listinfo/python-list


Re: determine directories with wildcard

2005-03-08 Thread Vincent Wehren
Thomas Rademacher wrote:
Hello,
I want to collect with the wildcard '*' all existing directories.
For example:  /dir/dir/*/dir/*/dir/* or C:\dir\dir\*\dir\*\dir\*
How can I resolve this problem?
Thanks for your hints, Thomas.

You may want to check out the glob module. E.g. something like:
 import glob, os
 p = c:/*/*/site-packages/*
 dirs = [d for d in glob.glob(p) if os.path.isdir(d)]
 print dirs
['c:/Python23\\Lib\\site-packages\\atox', 
'c:/Python23\\Lib\\site-packages\\BDBStorage', 
'c:/Python23\\Lib\\site-packages\\BitTorrent', 
'c:/Python23\\Lib\\site-packages\\BTrees', 
'c:/Python23\\Lib\\site-packages\\ChartDirector', 
'c:/Python23\\Lib\\site-packages\\cjkcodecs', 
'c:/Python23\\Lib\\site-packages\\ctypes', 
'c:/Python23\\Lib\\site-packages\\CVS', 
'c:/Python23\\Lib\\site-packages\\elementtree', 
'c:/Python23\\Lib\\site-packages\\enchant', 
'c:/Python23\\Lib\\site-packages\\Ft', 
'c:/Python23\\Lib\\site-packages\\imdb', 
'c:/Python23\\Lib\\site-packages\\isapi', 
'c:/Python23\\Lib\\site-packages\\logilab', 
'c:/Python23\\Lib\\site-packages\\mx', 
'c:/Python23\\Lib\\site-packages\\MySQLdb', 
'c:/Python23\\Lib\\site-packages\\numarray', 
'c:/Python23\\Lib\\site-packages\\OpenGL', 
'c:/Python23\\Lib\\site-packages\\OpenGLContext', 
'c:/Python23\\Lib\\site-packages\\parallel', 
'c:/Python23\\Lib\\site-packages\\Persistence', 
'c:/Python23\\Lib\\site-packages\\PIL', 
'c:/Python23\\Lib\\site-packages\\psyco', 
'c:/Python23\\Lib\\site-packages\\py2exe', 
'c:/Python23\\Lib\\site-packages\\pychecker', 
'c:/Python23\\Lib\\site-packages\\pynsource', 
'c:/Python23\\Lib\\site-packages\\Pyrex', 
'c:/Python23\\Lib\\site-packages\\Pyro', 
'c:/Python23\\Lib\\site-packages\\pythonwin', 
'c:/Python23\\Lib\\site-packages\\pywin32_system32', 
'c:/Python23\\Lib\\site-packages\\pyXLWriter', 
'c:/Python23\\Lib\\site-packages\\reportlab', 
'c:/Python23\\Lib\\site-packages\\serial', 
'c:/Python23\\Lib\\site-packages\\spambayes', 
'c:/Python23\\Lib\\site-packages\\ThreadedAsync', 
'c:/Python23\\Lib\\site-packages\\vrml', 
'c:/Python23\\Lib\\site-packages\\win32', 
'c:/Python23\\Lib\\site-packages\\win32com', 
'c:/Python23\\Lib\\site-packages\\win32comext', 
'c:/Python23\\Lib\\site-packages\\wx', 
'c:/Python23\\Lib\\site-packages\\wxPython', 
'c:/Python23\\Lib\\site-packages\\ZConfig', 
'c:/Python23\\Lib\\site-packages\\zdaemon', 
'c:/Python23\\Lib\\site-packages\\ZEO', 
'c:/Python23\\Lib\\site-packages\\zLOG', 
'c:/Python23\\Lib\\site-packages\\ZODB', 
'c:/Python23\\Lib\\site-packages\\ZopeUndo', 
'c:/Python23\\Lib\\site-packages\\_xmlplus', 
'c:/Python24\\Lib\\site-packages\\ChartDirector', 
'c:/Python24\\Lib\\site-packages\\elementtidy', 
'c:/Python24\\Lib\\site-packages\\elementtree', 
'c:/Python24\\Lib\\site-packages\\isapi', 
'c:/Python24\\Lib\\site-packages\\py2exe', 
'c:/Python24\\Lib\\site-packages\\pythonwin', 
'c:/Python24\\Lib\\site-packages\\pywin32_system32', 
'c:/Python24\\Lib\\site-packages\\win32', 
'c:/Python24\\Lib\\site-packages\\win32com', 
'c:/Python24\\Lib\\site-packages\\win32comext', 
'c:/Python24\\Lib\\site-packages\\wx-2.5.3-msw-unicode']

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


Re: basic tkinter/Windows question

2005-02-22 Thread Vincent Wehren
Paul Rubin wrote:
I find myself having to write some code on Windows :-(.  To alleviate
the pain, at least I get to use Python for some of it.
I'm trying to write a simple application, say eggs.py.  It pops a
tkinter gui and lets the user do some stuff.  The system has Python
installed so I don't care about wrapping it in a .exe file or anything
like that.  But I'd like to make a desktop icon for eggs.py and let the
user double-click it and run the app without also getting a DOS box on
the screen.
Rename the file eggs.py to eggs.pyw and create a shortcut to that 
file. The file will be opened using pythonw.exe instead of python.exe.

--
Vincent Wehren

Is there a simple way to do that?  I didn't see anything in the Python
docs about it.  I suspect that this is really a dumb Windows question,
but I avoid Windows whenever I can, so most anything I can ask about it
is probably dumb.
Thanks much.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Chart Director?

2005-02-18 Thread Vincent Wehren
[EMAIL PROTECTED] wrote:
Does anyone here have experience with Chart Director
(http://www.advsofteng.com/index.html)?   I'm thinking about purchasing
it and looking for any feedback from the Python community.  Thanks
Since ChartDirector is not exactly open source nor found its origin in a 
Python setting, my uneducated guess is that it will mostly be companies 
that use ChartDirector.

However, from that vantage-point, ChartDirector is well-documented, has 
lots of examples, and is great value for the money; it's pretty straight 
forward, it covers all Python versions from 1.52 - 2.4, and the license 
generally encompasses all other language bindings, too (all being at 
version 4.0 except for the C++ version which is currently still at 3.04).

Still, you should just try it for what you are planning to use it /for/ 
and see if it meets /your/ specific needs.

--
Vincent Wehren


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


Re: Commerical graphing packages?

2005-02-12 Thread Vincent Wehren
Erik Johnson wrote:
I am aware of ChartDirector (http://www.advsofteng.com/ ) which
explicitly supports python and seems to be about the right level of
sophistication. I don't really know of any other packages in this space, do
you? I am seeking feedback and reccomendations from people who have used
this package or similar ones. I am particularly interested to hear about any
limitations or problems you ran into with whatever package you are using.
We use both the Python and C++ bindings of ChartDirector (although their 
license always spans /all/ supported bindings. It's all pretty 
straight-forward, well-documented, and the license fee is a bargain 
compared to other packages we've used in the past. What it is not 
suitable for is maybe allowing for 3d-views of data cubes - changeable 
on the fly.

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


Re: connecting to Sybase/MsSQL from python

2005-02-12 Thread vincent wehren

John Fabiani [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
 Hi,
 I'm hoping someone on the list has connected to sybase/MsSQL with 
 something
 that works with DBAPI 2.0 from a linux box (SUSE 9.2) because I can't seem
 to get it done.  I found Object Craft's python code that uses FreeTDS. 
 But
 I can't get it compiled.  The code is looking for sybdb.h (first 
 error) -
 of course I don't have sybdb.h.  It is not in Object Crafts code nor in
 the FreeTDS source.  I'm guessing that I need sybase develop lib's but I
 don't know where they are to be found.

 So is there a kind sole out there that can help with instructions on what 
 is
 needed to get python talking to MsSQL.

 jOHN

Use mxODBC?

--

Vincent Wehren


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


Re: Trouble with the encoding of os.getcwd() in Korean Windows

2005-02-09 Thread Vincent Wehren
Erik Bethke wrote:
Hello All,
I have found much help in the google archives but I am still stuck...
here is my code snippet:
path = os.getcwd()
path = path.decode('UTF8')
Now the trouble is I am getting that darn UnicodeDecodeError, where it
is tripping up on the Korean hangul for My Desktop.  Now I have tried
utf8 and utf16 and neither of these works.

So is this my question?:  What encoding does windows use for Korean
Windows?  
Try mbcs. This is a built-in encoding avalaible only on Windows and 
that equals the system's default ANSI codepage. Using mbcs, which is 
short for multi-byte character set, the conversions to and from 
Unicode (decode/encode) are internally handled by the corresponding 
win32 api functions.

--
Vincent Wehren
I thought it might be and so I surfed around
(http://foundationstone.com.au/HtmlSupport/OnlineHelp/Localisation/SupportedEncodings.html)
and there appears to be an encoding called: windows-949 labeled to be
Korean Windows, which of couse is *not* one of the encodings to be
found in the encodings package... which would suck.
But then I thought about it some more, how could you make software to
do things like read the current directory work on different language
machines???  It would be madness to have a try statement for each and
every encoding under the sun...
Why isn't there a get system encoding method?
Or am I on the entirely wrong track?
Thanks,
-Erik
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple constructors

2005-02-06 Thread vincent wehren
Philip Smith wrote:
Call this a C++ programmers hang-up if you like.
I don't seem to be able to define multiple versions of __init__ in my matrix 
class (ie to initialise either from a list of values or from 2 dimensions 
(rows/columns)).

Even if Python couldn't resolve the __init__ to use on the basis of argument 
types surely it could do so on the basis of argument numbers???

At any rate - any suggestions how I code this
Checking the number of arguments ain't all that hard:
class Klass:
   def __init__(*args):
   self.args = args
   if len(self.args) == 1:
   # etc.
This feels rather unpythonic, though. Maybe you could use factory 
functions, forgetting about  __init__ all together (2.2 or higher):

class Klass(object):
def fromList(seq):
result = Klass()
# populate attributes here
# and return the requested object
return result
fromList = staticmethod(fromList)
def fromDimensions(cols, rows):
result = Klass()
# populate attributes here
# and return the requested object
return result
   fromDimensions = staticmethod(fromDimensions)
   #more methods  here
k = Klass.fromList(seq)
etc..
Regards
--
Vincent Wehren



Thanks
Phil 


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


Re: Word for a non-iterator iterable?

2005-02-06 Thread vincent wehren
Leif K-Brooks wrote:
Is there a word for an iterable object which isn't also an iterator, and 
therefor can be iterated over multiple times without being exhausted? 
Sequence is close, but a non-iterator iterable could technically 
provide an __iter__ method without implementing the sequence protocol, 
so it's not quite right.
How about 'reiterable'?
--
Vincent Wehren
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple constructors

2005-02-06 Thread vincent wehren
Reinhold Birkenfeld wrote:
vincent wehren wrote:
Philip Smith wrote:
Call this a C++ programmers hang-up if you like.
I don't seem to be able to define multiple versions of __init__ in my matrix 
class (ie to initialise either from a list of values or from 2 dimensions 
(rows/columns)).

Even if Python couldn't resolve the __init__ to use on the basis of argument 
types surely it could do so on the basis of argument numbers???

At any rate - any suggestions how I code this
Checking the number of arguments ain't all that hard:
class Klass:
   def __init__(*args):
   self.args = args
   if len(self.args) == 1:
   # etc.
This feels rather unpythonic, though. 

And it won't work, as `self' is not defined. ;)
You're right of course!
Note to self: Must stop shooting from the hip ;)
--
Vincent


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


Re: Printing Filenames with non-Ascii-Characters

2005-02-02 Thread vincent wehren
Marian Aldenhövel wrote:
But wouldn't that be correct in my case?
This is what I get inside Eclipse using pydev when I run:
code
import os
dirname = c:/test
print dirname
for fname in os.listdir(dirname):
print fname
if os.path.isfile(fname):
print fname
/code:
c:/test
straßenschild.png
test.py
Übersetzung.rtf
This is what I get passing a unicode argument to os.listdir:
code
import os
dirname = uc:/test
print dirname # will print fine, all ascii subset compatible
for fname in os.listdir(dirname):
print fname
if os.path.isfile(fname):
print fname
/code
c:/test
Traceback (most recent call last):
  File C:\Programme\eclipse\workspace\myFirstProject\pythonFile.py, 
line 5, in ?
print fname
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in 
position 4: ordinal not in range(128)

which is probably what you are getting, right?
You are trying to write *Unicode* objects containing characters outside 
of the 0-128 to a multi byte-oriented output without telling Python the 
appropriate encoding to use. Inside eclipse, Python will always use 
ascii and never guess.

import os
dirname = uc:/test
print dirname
for fname in os.listdir(dirname):
print type(fname)
c:/test
type 'unicode'
type 'unicode'
type 'unicode'

so finally:
code
import os
dirname = uc:/test
print dirname
for fname in os.listdir(dirname):
print fname.encode(mbcs)
/code
gives:
c:/test
straßenschild.png
test.py
Übersetzung.rtf
Instead of mbcs, which should be available on all Windows systems, you 
could have used cp1252 when working on a German locale; inside Eclipse 
even utf-16-le would work, underscoring that the way the 'output 
device' handles encodings is decisive. I know this all seems awkward at 
first, but Python's drive towards uncompromising explicitness pays off 
big time when you're dealing with multilingual data.

--
Vincent Wehren

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


Re: Generating .pyc/.pyo from a make file

2005-02-02 Thread vincent wehren
Tim Daneliuk wrote:
Steve Holden wrote:
Roland Heiber wrote:
Tim Daneliuk wrote:
Aha!  Exactly ... and that makes perfect sense too.  D'oh!  I guess a 
better
distribution strategy would be to have the installation program generate 
the pyo
file at installation time...

Thanks -
Also, the *.py? files contain the full pathname of the *.py they have 
been compiled from. Copying them to other path locations will give you 
the wrong __file___ information in tracebacks.

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


Re: Printing Filenames with non-Ascii-Characters

2005-02-01 Thread vincent wehren
Marian Aldenhövel wrote:
Hi,
I am very new to Python and have run into the following problem. If I do
something like
  dir = os.listdir(somepath)
  for d in dir:
 print d

The program fails for filenames that contain non-ascii characters.

  'ascii' codec can't encode characters in position 33-34:
If you read this carefully, you'll notice that Python has tried and 
failed to *encode* a decoded ( = unicode) string using the 'ascii' 
codec. IOW, d seems to be bound to a unicode string. Which is unexpected 
unless maybe the argument passed to os.listdir (somepath) is a Unicode 
string, too. (If given a Unicode string as argument, os.listdir will 
return the list as a list of unicode names).

If you're printing to the console, modern Pythons will try to guess the 
console's encoding (e.g. cp850). I would expect a UnicodeEncodeError if 
the print fails because the characters do not map to the console's 
encoding, not the error you're seeing.

How *are* you running the program. In the console (cmd.exe)? Or from 
some IDE?

I have noticed that this seems to be a very common problem. I have read 
a lot
of postings regarding it but not really found a solution. Is there a simple
one?

What I specifically do not understand is why Python wants to interpret the
string as ASCII at all. Where is this setting hidden?
Don't be tempted to ever change sys.defaultencoding in site.py, this is 
site specific, meaning that if you ever distribute them, programs 
relying on this setting may fail on other people's Python installations.

--
Vincent Wehren
I am running Python 2.3.4 on Windows XP and I want to run the program on
Debian sarge later.
Ciao, MM
--
http://mail.python.org/mailman/listinfo/python-list


Re: tk global bindings

2005-01-29 Thread vincent wehren
Gabriel B. wrote:
I'm starting to write a POS application UI's module.
There's no mouse, just a bunch of global shortcuts.
the problem is that TK doesn't have global shortcuts! Is there a
work-around or i will have to attach 80 or so bindings for every input
element?
In Tk here are three levels of binding: instance binding, class binding, 
 and application binding represented by the bind, bind_class, and 
bind_all methods. You're probably looking for the the bind_all method, 
as in self.bind_all(SomeKey, self.onSomeKey)

HTH,
--
Vincent Wehren

Thanks,
Gabriel
--
http://mail.python.org/mailman/listinfo/python-list


Re: tk global bindings

2005-01-29 Thread vincent wehren
vincent wehren wrote:
Gabriel B. wrote:
I'm starting to write a POS application UI's module.
In Tk here are three levels of binding: instance binding, class binding, 
 and application binding represented by the bind, bind_class, and 
bind_all methods. You're probably looking for the the bind_all method, 
as in self.bind_all(SomeKey, self.onSomeKey)

HTH,
--
Vincent Wehren
Oh and you of course __must__ look at the (recently updated!) New Mexico 
Tech tkinter document at:
http://infohost.nmt.edu/tcc/help/pubs/tkinter.pdf

See page 75 and follwing for more info on keyboard bindings...
--
Vincent Wehren

Thanks,
Gabriel
--
http://mail.python.org/mailman/listinfo/python-list


Re: module for 'po' files

2005-01-25 Thread vincent wehren
Sara Fwd wrote:
 Hi all
Is there a module for processing  handling  '.po'
files in python?
Don't know exactly what you mean by processing  handling. What do you 
want to do?

--
Vincent Wehren



		
__ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 
--
http://mail.python.org/mailman/listinfo/python-list


Re:snakespell and myspell

2005-01-25 Thread vincent wehren
Fuzzyman wrote:
I'm looking to implement a plugin spell checker.
I'm probably going to go with PyEnchant, as it looks to be the most
promising currently maintained spell checker.
What I would like to know about PyEnchant is how to handle non-ascii 
input. Through trial  error I've noticed that let's say German Umlauts
are stored in the dictionary as using dead accents (is that the term?) 
(as in 'Mutter'), however French accented characters appear to be 
stored differently (as in '\xc3\xa9levage'. Anybody know what the 
system is?


I just wondered if anyone knew what happened to snakespell and myspell.
Don't know about that. But than there also is a pyrex-driven aspell 
binding at http://sourceforge.net/projects/uncpythontools

Regards,
--
Vincent Wehren

Both seem to have dissapeared from the net. People have reported good
results from both - and it seems a shame to lose them.

Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml
--
http://mail.python.org/mailman/listinfo/python-list


Re: snakespell and myspell

2005-01-25 Thread vincent wehren
vincent wehren wrote:
Fuzzyman wrote:
I'm looking to implement a plugin spell checker.
I'm probably going to go with PyEnchant, as it looks to be the most
promising currently maintained spell checker.

What I would like to know about PyEnchant is how to handle non-ascii 
input. Through trial  error I've noticed that let's say German Umlauts
are stored in the dictionary as using dead accents (is that the term?) 
(as in 'Mutter'), however French accented characters appear to be 
stored differently (as in '\xc3\xa9levage')
The latter of course being utf-8...
--
Vincent
--
http://mail.python.org/mailman/listinfo/python-list


Re: Open Folder in Desktop

2005-01-25 Thread vincent wehren
Jimmy Retzlaff wrote:
Kamilche wrote:
sipped
Folders like My Documents, My Pictures, etc. are special and you need to
determine their actual path before you can open them. The pywin32
extensions
(https://sourceforge.net/project/showfiles.php?group_id=78018) include a
way to get at this:
from win32com.shell import shellcon, shell
path = shell.SHGetFolderPath(0, shellcon.CSIDL_MYPICTURES, 0, 0)
os.startfile(path)
Google for CSIDL to find the constants to use for other special folders.
Here's the exact link you'll need (warning, long url ahead ;)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp
--
Vincent Wehren


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


Re: how to find site-packages path (Michael Hoffman) - use distutils

2005-01-18 Thread vincent wehren
Philippe C. Martin wrote:
Why would you want to copy any *.pyc instead of compiling them on
site?

I know that sounds terrible to the open source community, 

but I do not
intend to release the source code for my product 
That's not why I asked. I'll leave the politics up to you. The thing is, 
that the path info gets cached in the *.pyc file. This may lead to 
confusing tracebacks - might they occur - when the user does not install 
to the exact same drive/path as you did.

Additionally: if you *do* want to distribute *.pyc only, I personally 
wouldn't find it terribly neat if you stuck those into the site-packages 
directory of my Python installation. I - for one - would want to know 
what kind of source code you place along *my* sys.path.

Maybe you should consider using py2exe to distribute - keeping your 
*.pyc out of the user's Python directory tree, if any, entirely. Also, 
you may want to consider using Inno Setup as deployment tool (if Windows 
is your target platform). Using distutils for a *.py-less installer 
seems pretty pointless.


Regards,
--
Vincent Wehren
- pls go to
philippecmartin.com/applications.html for my _small_ contributions :-))

Regards,
Philippe

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


Re: how to find site-packages path

2005-01-17 Thread vincent wehren
Philippe C. Martin wrote:
Hi,
I am using my own install script for my software and am looking for a
flawless way to figure out where python, and more specifically
site-packages is installed.
You can take a look at how this is done in Lib/site.py.
Look for the bit of code that starts with
prefixes = [sys.prefix]
sitedir = None # make sure sitedir is initialized because of later 'del'
...
etc.
--
Vincent Wehren

Any clue ?
Regards,
Philippe

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


Re: how to find site-packages path (Michael Hoffman) - use distutils

2005-01-17 Thread vincent wehren
Philippe C. Martin wrote:
The flawless way would be to use distutils. In fact you shouldn't even
need your own install script--it should do most of the work for you.

The reason I have not so far is I have not found a way to get what I
want done:
1) create directories in site-packages (I gather this shoudl be easy
enough)
2) copy already compiled (.pyc) and source (.py) files to those
directories
Why would you want to copy any *.pyc instead of compiling them on site?
--
Vincent Wehren

3) create directories and copy files in a directory kept in an
environment variable
Can distutils do this for me?


Regards,
Philippe


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


Re: py2exe Excludes

2005-01-12 Thread vincent wehren
Ed Leafe wrote:
I'm trying to make a Windows runtime for Dabo, and I want to exclude 
the framework code itself from the exe file, so that people can update 
with new releases as they are made. The relevant section of setup.py has:

setup(
# The first three parameters are not required, if at least a
# 'version' is given, then a versioninfo resource is built from
# them and added to the executables.
version = 0.3.0,
description = Dabo Runtime Engine,
name = daborun,
# targets to build
console = [daborun.py],
#exclude the actual framework
options = { py2exe: {excludes : [dabo]} },
)
Yet the generated library.zip still contains all of the Dabo module 
code. Why is this? What am I doing wrong?
Just a guess: What happens if you remove everything that's in the 
build directory before running setup.py? There may still be files 
around from an earlier build that *did* include the Dabo modules.

--
Vincent Wehren

 ___/
/
   __/
  /
 /
 Ed Leafe
 http://leafe.com/
 http://dabodev.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: exceptions and items in a list

2005-01-10 Thread vincent wehren
Steve Holden wrote:
vincent wehren wrote:
rbt wrote:
If I have a Python list that I'm iterating over and one of the 
objects in the list raises an exception and I have code like this:

try:
do something to object in list
except Exception:
pass
Does the code just skip the bad object and continue with the other 
objects in the list, or does it stop?

Thanks

Fire up a shell and try:
  seq = [1, 2, a, 4, 5, 6.0]
  for elem in seq:
 try:
print int(elem)
 except ValueError:
pass
and see what happens...
--
Vincent Wehren

I suspect the more recent versions of Python allow a much more elegant 
solution. I can't remember precisely when we were allowed to use 
continue in an except suite, but I know we couldn't in Python 2.1.

Nowadays you can write:
Python 2.4 (#1, Dec  4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type help, copyright, credits or license for more information.
  for i in [1, 2, 3]:
 ...   try:
 ... print i
 ... if i == 2: raise AttributeError, Bugger!
 ...   except AttributeError:
 ... print Caught exception
 ... continue
 ...
1
2
Caught exception
3
 
To terminate the loop on the exception you would use break instead of 
continue.
What do you mean by a more elegant solution to the problem? I thought 
the question was if a well-handled exception would allow the iteration 
to continue with the next object or that it would stop. Why would you 
want to use the continue statement when in the above case that is 
obviously unnecessary?:

$ python
Python 2.4 (#1, Dec  4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type help, copyright, credits or license for more information.
 for i in [1,2,3]:
... try:
... if i == 2: raise AttributeError, Darn!
... except AttributeError:
... print Caught Exception
...
1
2
Caught Exception
3

Or do you mean that using continue is more elegant than using pass 
if there are no other statements in the except block?

Regards,
--
Vincent Wehren
regards
 Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: exceptions and items in a list

2005-01-10 Thread vincent wehren
rbt wrote:
If I have a Python list that I'm iterating over and one of the objects 
in the list raises an exception and I have code like this:

try:
do something to object in list
except Exception:
pass
Does the code just skip the bad object and continue with the other 
objects in the list, or does it stop?

Thanks
Fire up a shell and try:
 seq = [1, 2, a, 4, 5, 6.0]
 for elem in seq:
... try:
...print int(elem)
... except ValueError:
...pass
and see what happens...
--
Vincent Wehren
--
http://mail.python.org/mailman/listinfo/python-list


Re: Developing Commercial Applications in Python

2005-01-03 Thread vincent wehren
[EMAIL PROTECTED] wrote:
Hello All,
I am trying to convince my client to use Python in his new product. He
is worried about the license issues. Can somebody there to point me any
good commercial applications developed using python ?. The licence
clearly says Python can be used for commercial applications. Is there
any other implications like that of GPL to make the source open ?
Thanks for any help.
eeykay
At CSB-System AG, we use Python extensively as embedded scripting 
language throughout the ERP system we develop (fields of application: 
system automation, GUI scripting, programmable user exits, reporting, 
data access/replication, autotests, and apart from that, everywhere we 
need something done fast ;-).

I'm sure that its liberal license was among the main drivers to use it 
in the first place!

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


Re: Unicode entries on sys.path

2004-12-30 Thread vincent wehren
Thomas Heller wrote:
Martin v. Löwis [EMAIL PROTECTED] writes:

Thomas Heller wrote:
How should these patches be approached?
Please have a look as to how posixmodule.c and fileobject.c deal with
this issue.

On windows, it would probably
be easiest to use the MS generic text routines: _tcslen instead of
strlen, for example, and to rely on the _UNICODE preprocessor symbol to
map this function to strlen or wcslen.
No. This fails for two reasons:
1. We don't compile Python with _UNICODE, and never will do so. This
   macro is only a mechanism to simplify porting code from ANSI APIs
   to Unicode APIs, so you don't have to reformulate all the API calls.
   For new code, it is better to use the Unicode APIs directly if you
   plan to use them.
2. On Win9x, the Unicode APIs don't work (*). So you need to chose at
   run-time whether you want to use wide or narrow API. Unless
   a) we ship two binaries in the future, one for W9x, one for NT+
  (I hope this won't happen), or
   b) we drop support for W9x. I'm in favour of doing so sooner or
  later, but perhaps not for Python 2.5.

I wasn't asking about the *W functions, I'm asking about string/unicode
handling in Python source files. Looking into Python/import.c, wouldn't
it be required to change the signature of a lot of functions to receive
PyObject* arguments, instead of char* ?
For example, find_module should change from
  static struct filedescr *find_module(char *, char *, PyObject *,
   char *, size_t, FILE **, PyObject **);
to 

  static struct filedescr *find_module(char *, char *, PyObject *,
   PyObject **, FILE **, PyObject **);
where the fourth argument would now be either a PyString or PyUnicode
object pointer?

(*) Can somebody please report whether the *W file APIs fail on W9x
because the entry points are not there (so you can't even run the
binary), or because they fail with an error when called?

I always thought that the *W apis would not be there in win98, but it
seems that is wrong.  Fortunately, how could Python, which links to the
FindFirstFileW exported function for example, run on win98 otherwise...
Normally I would have thought this would require using the Microsoft 
Layer for Unicode (unicows.dll).

According to MSDN 9x already does have a handful of unicode APIs.
FindFirstFile does not seem to be one of them - unless the list on
htpp://msdn.microsoft.com/library/default.asp?url=/library/en-us/mslu/winprog/other_existing_unicode_support.asp)
is bogus (?).
--
Vincent Wehren

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


Re: Unicode entries on sys.path

2004-12-24 Thread vincent wehren
Just wrote:
In article [EMAIL PROTECTED],
 Martin v. Lowis [EMAIL PROTECTED] wrote:

Hm, maybe more a windows question than a python question...
The real question here is: why does Python not support arbitrary
Unicode strings on sys.path? It could, in principle, atleast on
Windows NT+ (and also on OSX). Patches are welcome.

Works for me on OSX 10.3.6, as it should: prior to using the sys.path 
entry, a unicode string is encoded with Py_FileSystemDefaultEncoding. 
For this conversion mbcs will be used on Windows machines, implying 
that such conversions are made using the current system Ansi codepage.
(As a matter of interest: What is this on OSX?). This conversion is 
likely to be useless for unicode directory names containing characters 
that do not have a mapping to a character in this particular codepage.

The technique described by Martin may solve the problem for what in this 
case are Japanese characters, but what if I have directory names from 
another language group, such as simpliefied Chinese, as well?

The only way to get around this is to allow - as Martin suggests - 
arbitrary unicode strings in sys.path on those platforms that may have 
unicode file names.

--
Vincen Wehren
I'm not sure how well it works together with zipimport, though.

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


Re: sql server support from linux

2004-12-20 Thread vincent wehren
Simon Wittber wrote:
I am currently tasked with connecting Python CGI programs, under
Apache2 / Linux, to SQL Server on Windows 2000.
The latest MSSQL module from
http://www.object-craft.com.au/projects/mssql/ (0.09) will not (for
me, at least) compile on Debian.
The next version of the module (0.08) will compile, but raises a
MemoryException whenever I return varchar fields. Hopeless. It also
segfaults (!) whenever I use datetime fields.
The sybase library (also from object-craft) appears to work, but
raises an exception whenever an empty query result is returned. This
is bizzare, and not DB-API 2.0 compiant.
Does anyone in this list ever connect to SQL Server from Linux, using
Python? If so, what is your solution?
Using mx.ODBC?
--
Vincent Wehren
I'm going nuts over here!
Sw.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Easy here documents ??

2004-12-18 Thread vincent wehren
Peter Hansen wrote:
Jim Hill wrote:
I've done some Googling around on this and it seems like creating a here
document is a bit tricky with Python.  Trivial via triple-quoted strings
if there's no need for variable interpolation but requiring a long, long
formatted arglist via (%s,%s,%s,ad infinitum) if there is.  So my
question is:
Is there a way to produce a very long multiline string of output with
variables' values inserted without having to resort to this wacky
v = %s%(variable)
business?

I have no idea what a here document is, but there are several
alternatives to the wacky basic substitution with a tuple of
values.
OP is looking for heredoc syntax; in, let's say, PHP
this lets you do something like:
$foo = new foo();
$name = 'MyName';
echo EOT
My name is $name. I am printing some $foo-foo.
Now, I am printing some {$foo-bar[1]}.
This should print a capital 'A': \x41
EOT;
AFAIK, there is no direct Python equivalent for this kind of syntax. 
Using a mapping like you suggested or the string.Template class in 
Python 2.4 still maybe improvements over what OP calls that wacky 
business.

--
Vincent Wehren
The simplest uses a mapping type:
mydict = {'namedVal': 666}
'''v = %(namedVal)s''' % mydict
Does that let you build whatever a here document is?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Distutils vs. Extension header files

2004-12-09 Thread vincent wehren
Mike Meyer wrote:
I've got a package that includes an extension that has a number of
header files in the directory with the extension. They are specified
as depends = [...] in the Extension class. However, Distutils
doesn't seem to do anything with them.
If I do an sdist, the include files aren't added to the tarball.
IIRC you need to add a MANIFEST.IN file to get non-Python files 
(including those already referenced in your setup.py) in the mix. You'll 
propably need a MANIFEST.IN looking something like the following:

include *.txt
include MANIFEST.in
include setup.py
include setup.cfg
recursive-include src *.c *.h
recursive-include docs *.html *.css *.gif *.jpg *.txt
prune someolddir
HTH,
--
Vincent Wehren

If I do a bdist_rpm, the source files get copied into the build
directory and the build starts, but the header files aren't copied
with the source file, so the build fails with a missing header file.
I find it hard to believe that this is a bug in distutils, so I'd
appreciate it if someone could tell me what I'm doing wrong.
   Thanks,
   mike
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem while trying to extract a directory from a zipfile.

2004-12-08 Thread vincent wehren
ralobao wrote:
I have this code:
try:
file = zipfile.ZipFile(nome_arquivo)
Gauge.start() #inicia o Gauge
for element in file.namelist():
try:
newFile = open(diretorio + element,wb)
except:
newFile = open(diretorio + element + '/',w)
# Gauge
percent = percent + 10
Gauge.update(percent)
Gauge.set_text(Extraindo + element)
# Extrai
newFile.write(file.read(element))
newFile.close()
But when i try to extract an zipfile with a directory in it the code
returns me an IOErro exception: It is a directory
Please how can i solve it ?
You need to create any directories yourself. Maybe
the recipe at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252508
gives you some ideas on how.
HTH
--
Vincent Wehren


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


Re: simple GUI question

2004-12-07 Thread vincent wehren
Roose wrote:
I have been writing only command line programs in python, and I need a way
to simply pop up a GUI dialog box, with an OK box.  Simple huh?
I have used tkMessageBox.showwarning.  This works OK but it also pops up an
empty frame -- i.e. it pops up 2 things.  Is there a way to disable this, or
is there an alternate way of doing things?  OK call me anal, but it bothers
me.
You want somthing like:
root = Tkinter.Tk()
root.withdraw()
msg = tkMessageBox.showwarning(Ooops, Some warning)
--
Vincent Wehren
Another thing I would *like* but is not strictly necessary would be to
change the font size and color of the text within the box.  Is there a good
way of doing that?  
I have googled around but can't find any decent example
code for some reason.
I can use Python 2.3 only, and only stuff that is included in the standard
install.  For something so trivial I can't roll out a new version of Python
or any additional software.
So I assume Tkinter is pretty much my only option, or is that not the case?
Thanks for any help.
Roose

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