Re: RotatingFileHandler in Python 2.3.5

2005-05-17 Thread Vinay Sajip
new pip newpip at gmail.com writes:

 
 Is the RotatingFileHandler (from the logging module) available in
 Python 2.3.5? I'm getting a AttributeError: 'module' object has no
 attribute 'RotatingFileHandler' error message when trying to use it.

The handler is in the logging.handlers module, not in the logging module 
itself. If you are using a configuration file, 
use handlers.RotatingFileHandler rather than just RotatingFileHandler.

Vinay Sajip

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


Re: query progress bar

2005-05-17 Thread Timothy Smith
Harald Massa wrote:

it's for wx, the problem isn't making the progress bar itself, it's 
knowing how long the query is going to run for.
i'm using pypgsql



It is quite easy:

from timemachine import oracle

guesser=oracle(guess=SQL)
guesser.set_hint(driver=pypgsql)
guesser.set_hint(gui=wx)

expected_runtime=guesser.estimate(put your query text here)

Only problem is that the timemachine module is currently only installed 
on Guidos and Tims Python.

Harald
  

man thats exactly what i'm looking for. it won't install on standard 2.3 ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Like Christ PBBUH Prayed

2005-05-17 Thread George Sakkis
flamesrock wrote:

 I don't understand.. why is everyone talking about christ on
 comp.lang.python? Isn't this not the place?
 

Maybe they know something we don't.

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


Re: Anyway to designating the encoding of the source for compile?

2005-05-17 Thread janeaustine50
John Machin wrote:
 On 16 May 2005 16:44:30 -0700, [EMAIL PROTECTED] wrote:
[snip]


 Like I said, *ALL* you have to do (like in any other Unicode-aware
 app) is decode your user input into Unicode (you *don't* need to
parse
 bits and pieces of it) and feed it in ... like this:

  user_input_kr = inside=u'\xc7\xd1\xb1\xdb'
  user_input_uc = user_input_kr.decode('euc-kr')
  user_input_uc
 uinside=u'\ud55c\uae00'
  s = compile(user_input_uc, '', 'single')
  exec s
  inside
 u'\ud55c\uae00'
  # right

 HTH,
 John

Thank you but there is still a problem.

| s='euckr=\xc7\xd1;uni=u\xc7\xd1'
| su=s.decode('euc-kr')
| su
|u'euckr=\ud55c;uni=u\ud55c'
| c=compile(su,'','single')
| exec c
| euckr,uni
|('\xed\x95\x9c', u'\ud55c')
|

As you see the single's result is turned into UTF-8 encoding.

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


Windows distribution suggestions?

2005-05-17 Thread Paul Rubin
As what must be penance for something or other, I'm needing to release
a Python app for use under Windows XP.  Please be gentle with me since
I'm a Un*x weenie and the only thing I've had much practice with under
Windows is rebooting it.

My app contains three different programs (say alice.py, bob.py, and
carol.py) that need to be independently launchable, and a dozen or so
other .py files that get imported into those first three.  What I'd
really really like is to make a single installer called (say)
app.exe.  Launching app.exe should completely install Python, unpack
all the necessary modules, and make three icons (alice, bob, carol) on
the desktop.

I know there's various ways of building Windows distros like that, but
am not sure what's currently preferred.  Gordon McMillan's site
www.mcmillan-inc.com has had its domain expire (he really should renew
it before some squatter grabs it!) and the mirror that I've found
indicates that it was last updated for Python 2.3.  I wrote my app
under 2.4 and while I don't think I depend heavily on any 2.4
features, I'd rather not have to downgrade just to make this exe
installer.  There's also py2exe--is that as good?  

Also, what's the preferred way of releasing updates?  That is, let's
say I want to update my .py files and release a new version fairly
frequently--should I just make a new .exe every time?  Would launching
the new one cleanly overwrite or uninstall the old one?  Total
coolness would be a way to ship an update.py along with the app,
that syncs the app up to a Subversion repository, but that may be
asking a bit much.

I do have Visual C++ installed on the development machine, if that helps.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ElemenTree and namespaces

2005-05-17 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 In theory, namespace prefixes are entirely arbitrary and only serve as
 a temporary link to the namespace URI. In practice, people tend to get
 emotionally attached to their favorite prefixes. XPath also breaks this
 theory because it refers to prefixes rather than URIs.

if your XPath processor requires you to use the same namespace
prefixes in the XPath expression as you're using in the document,
that processor is broken.

(XPath processors that can only work on expressions embedded
in XML documents may be an exception to that rule; they can get
the prefix/URI mapping from the execution context)

/F



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


Re: Anyway to designating the encoding of the source for compile?

2005-05-17 Thread Serge . Orlov
[EMAIL PROTECTED] wrote:
  Okay, I'll use one of the CJK codecs as the example. EUC-KR is the
  default encoding.
 
   import sys;sys.getdefaultencoding()
  'euc-kr'
   ''
  '\xc7\xd1\xb1\xdb'

That is the problem. Non-ascii characters in byte strings are
deprecated. Here is what I get when I run a deprecated hello
world program in Russian:
--- hello.py -
print , !
--
C:\pyc:\Python24\python.exe hello.py
sys:1: DeprecationWarning: Non-ASCII character '\xc7' in file
text.py on line 1,  but no encoding declared; see
http://www.python.org/peps/pep-0263.html for details
, !
--
Oops, not only there is a warning, but it doesn't even work
on Windows in Russian locale. To correct the program I need
to switch to unicode strings:
--- hello.py -
# -*- coding: windows-1251 -*-
print u, !
--
C:\pyc:\Python24\python.exe hello.py
, !
--

Since non-ascii characters are deprecated in byte strings,
any non-ascii encoding for sys.getdefaultencoding() is
deprecated as well. Don't set it to 'euc-kr'.


 Any suggestions or any plans in future python versions?

In python 3.0 byte strings will be gone. So you won't be
able to put non-ascii characters into them.


  Serge.

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

Embed Python

2005-05-17 Thread Tommy Ryding
Hi,

Background:
Im currently working on my own Python port for VxWorks this is part of
my master thesis. What I want to do is to only to embed the
interpreter and not the compiler. Both to save memory on the target
device and to be get some security in the device. It is a mission
critical device im applying it to.


Question:
Is there any obvious way to see what files that are needed for the
interpreter and which files that are needed by the compiler?

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


Re: tree functions daily exercise

2005-05-17 Thread Joachim Durchholz
[EMAIL PROTECTED] wrote:
  K!
  http://en.wikipedia.org/wiki/K_programming_language
 
  Interesting.
  Looking at your program, they are so short. I don't know if they are
  full implementation or what...

That's no surprise: list and tree processing are often built right into 
more expressive languages, and K seems to be one of these.

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


Re: Windows distribution suggestions?

2005-05-17 Thread Timothy Smith
Paul Rubin wrote:

As what must be penance for something or other, I'm needing to release
a Python app for use under Windows XP.  Please be gentle with me since
I'm a Un*x weenie and the only thing I've had much practice with under
Windows is rebooting it.

My app contains three different programs (say alice.py, bob.py, and
carol.py) that need to be independently launchable, and a dozen or so
other .py files that get imported into those first three.  What I'd
really really like is to make a single installer called (say)
app.exe.  Launching app.exe should completely install Python, unpack
all the necessary modules, and make three icons (alice, bob, carol) on
the desktop.

I know there's various ways of building Windows distros like that, but
am not sure what's currently preferred.  Gordon McMillan's site
www.mcmillan-inc.com has had its domain expire (he really should renew
it before some squatter grabs it!) and the mirror that I've found
indicates that it was last updated for Python 2.3.  I wrote my app
under 2.4 and while I don't think I depend heavily on any 2.4
features, I'd rather not have to downgrade just to make this exe
installer.  There's also py2exe--is that as good?  

Also, what's the preferred way of releasing updates?  That is, let's
say I want to update my .py files and release a new version fairly
frequently--should I just make a new .exe every time?  Would launching
the new one cleanly overwrite or uninstall the old one?  Total
coolness would be a way to ship an update.py along with the app,
that syncs the app up to a Subversion repository, but that may be
asking a bit much.

I do have Visual C++ installed on the development machine, if that helps
  


i have just gone through this process myself. if your sure your only 
distributing the app to windows xp system, then it's perfectly possible 
to update from an svn by using pysvn. pysvn doesn't currently work on 
win9x clients.
py2exe - use it, it's damn good. it puts all your library's in a 
library.zip file which can then use to update your app.
make a nice neat installer using NSIS, you can even use it to send 
manual patches if you need to.
if you need any help making the pysvn or other parts work give me an 
email i can help.

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


Re: Anyway to designating the encoding of the source for compile?

2005-05-17 Thread Serge . Orlov
[EMAIL PROTECTED] wrote:
 Thank you but there is still a problem.

 | s='euckr=\xc7\xd1;uni=u\xc7\xd1'
 | su=s.decode('euc-kr')
 | su
 |u'euckr=\ud55c;uni=u\ud55c'

su[7] is a non-ascii character inside the byte string euckr

 | c=compile(su,'','single')
 | exec c
 | euckr,uni
 |('\xed\x95\x9c', u'\ud55c')
 |

 As you see the single's result is turned into UTF-8 encoding.

See my previous message. Non-ascii characters in byte strings
are deprecated.

  Serge.

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


[no subject]

2005-05-17 Thread Shariar Dehmand
To whom it may concern,

I am looking to start a python organization in Iran
from scrtch,
Please help me with it, or give me the mailing address
of a reson which is advanced/experienced in what I try
to achieve.
best regards
Mesean Dehmand

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Like Christ PBBUH Prayed

2005-05-17 Thread Ville Vainio
 George == George Sakkis [EMAIL PROTECTED] writes:

George flamesrock wrote:

 I don't understand.. why is everyone talking about christ on
 comp.lang.python? Isn't this not the place?
 

George Maybe they know something we don't.

The information is generally reserved for 34DEG pythonistas. All will
be cleared for lower degree aspirants in due time.

-- 
Ville Vainio   http://tinyurl.com/2prnb
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python 2.3.4, cx_Oracle 4.1 and utf-8 - trouble

2005-05-17 Thread Serge . Orlov
Maxim Kuleshov wrote:
 Hello!

 Trying to fetch long varchar2 column and get the following error:

 cx_Oracle.DatabaseError: column at array pos 0 fetched with error:
1406

 i.e. string buffer is not much enough to fetch the string.

 # fragment of code...
 myCon = cx_Oracle.connect(user, psw, dsn)
 myCur = myCon.cursor()
 myCur.execute(
 select COLUMN from TABLE where ID=1
 )
 for record in myCur.fetchall():
 # ...

 Error is reproduced only if actual string value longer than half of
 declared column size. For short strings all is ok.

 If I print myCur.description, I get:

 [('COLUMN', type 'cx_Oracle.STRING', 250, 250, 0, 0, 1)]

 250 - declared column max size, but I guess cx_Oracle allocates only
250
 bytes(!), so if my string longer than 125 chars (utf-8 national char
 occupies  1 byte) - I get the error.

 Is it bug or what? Any suggestions?

Googling for varchar2 utf-8 suggests that it's an Oracle's
feature (or issue). varchar2 is allocated in bytes. Finding
out the largest number of bytes per character is left as
an exercise :)

  Sergey.

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


Re: Windows distribution suggestions?

2005-05-17 Thread Bernhard Holzmayer
Paul Rubin wrote:

 As what must be penance for something or other, I'm needing to release
 a Python app for use under Windows XP.  Please be gentle with me since
 I'm a Un*x weenie and the only thing I've had much practice with under
 Windows is rebooting it.

I can feel your unhappiness, and I share it. Hi Paul!
Here are some hints...

 My app contains three different programs (say alice.py, bob.py, and
 carol.py) that need to be independently launchable, and a dozen or so
 other .py files that get imported into those first three.  What I'd
 really really like is to make a single installer called (say)
 app.exe.  Launching app.exe should completely install Python, unpack
 all the necessary modules, and make three icons (alice, bob, carol) on
 the desktop.

Since your installer needs to run before Python is installed, you need
something else. Go to http://www.wisesolutions.com
You'll find a Windows installer program, with a demo-version (30days
license). Try this, it would be my best recommendation.
 
 I know there's various ways of building Windows distros like that, but
 am not sure what's currently preferred.  Gordon McMillan's site
 www.mcmillan-inc.com has had its domain expire (he really should renew
 it before some squatter grabs it!) and the mirror that I've found
 indicates that it was last updated for Python 2.3.  I wrote my app
 under 2.4 and while I don't think I depend heavily on any 2.4
 features, I'd rather not have to downgrade just to make this exe
 installer.  

You'll have to test your application on Windows, in any case. 
I've built lots of applications which run in both worlds (Linux/Windows).
Usually this works, but occasionally you'll have to deal with strange
things. One is, if you use ODBC. There's good chance that you'll have to
deal with access restrictions in the %SYSTEM% directory, unless you require
an administrator's account for your application.

If you test your app on a Windows machine, you can easily install Python 2.3
and Python 2.4 on the same machine without conflicts. Just try out, if your
app works with either. If it works with both, why not use 2.3?


 There's also py2exe--is that as good? 
Depends on your application, if that is acceptable. 
I have no experiences with that.
 
 Also, what's the preferred way of releasing updates?  That is, let's
 say I want to update my .py files and release a new version fairly
 frequently--should I just make a new .exe every time?   

Providing an installation program called Setup.exe or Install.exe which does
everything (guided by a sequence of dialog boxes where the user presses
only the return key to get through the successful installation), is
state-of-the-art. Usually, one of the Wise or InstallShield installers, are
used. Or simple WinZip-Packages.

 Would launching the new one cleanly overwrite or uninstall the old one? 

If you've done it in the proper way with the proper tool, yes.

 Total coolness would be a way to ship an update.py along with the app,
 that syncs the app up to a Subversion repository, but that may be
 asking a bit much.

Who are your customer's (the recipients of your program releases)?
Usually, you cannot rely that they have online access to your repository.
Then, they are potentionally interested in security issues and/or stability
of the program. I'd not like a program which is said to require frequent
updates - I'd guess that there's not much quality inside...

If your application has a GUI, a menu entry might fetch your update files
and place them wherever they must reside. your update.py might feed that
menu entry. Quite easy. 
If you have command line apps, why not provide an additional update.py 
and then, if you provide updates, just install them using your installed
update.py. The only thing: How do you keep track of path/desktop/file
information and how do you deal with user rights etc.?
Are you aware of how this is done under WindowsXP? It's quite different from
older Windows platforms! Therefore it might be easier, to leave this to
professional installation tools.

 
 I do have Visual C++ installed on the development machine, if that helps.

Isn't Visual C++ still coming with a restricted version of InstallShield?
If so, check if you can use that. It might give your release a sort of
professional shine...

You'll certainly find out, that managing the registry/desktop file system
will cost most energy, if you want to release your apps to WindowsXP.
Once Python is running your apps, the rest is peanuts.

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


Re: Windows distribution suggestions?

2005-05-17 Thread Paul Rubin
Bernhard Holzmayer [EMAIL PROTECTED] writes:
 I can feel your unhappiness, and I share it. Hi Paul!
 Here are some hints...

Thanks!  ;-)

 Since your installer needs to run before Python is installed, you need
 something else. Go to http://www.wisesolutions.com
 You'll find a Windows installer program, with a demo-version (30days
 license). Try this, it would be my best recommendation.

Hmm, ok, it looks like the paid version is around 500 USD.  Since this
is a Windows thing I'm ok in principle with using a payware packaging
app, but that's a bit on the expensive side.  I'll see what the
customer says but I think they might resist.

 You'll have to test your application on Windows, in any case. 
 I've built lots of applications which run in both worlds (Linux/Windows).
 Usually this works, but occasionally you'll have to deal with strange
 things. One is, if you use ODBC. There's good chance that you'll have to
 deal with access restrictions in the %SYSTEM% directory, unless you require
 an administrator's account for your application.

The app works ok under Windows now.  I don't use ODBC.  I might need
some database connectivity later and will probably use MySQL.  I don't
want to need an admin account.  Right now the app just has a Tkinter
gui, reads and writes a few files and talks to some sockets.  I might
need to add some C extensions later but those should be pretty portable.

 If you test your app on a Windows machine, you can easily install
 Python 2.3 and Python 2.4 on the same machine without
 conflicts. Just try out, if your app works with either. If it works
 with both, why not use 2.3?

I guess I could do that.  I believe I make some minor use of 2.4 features
but I can probably retrofit those things.

  There's also py2exe--is that as good? 
 Depends on your application, if that is acceptable. 
 I have no experiences with that.

Me neither.  I was hoping to find out its good and bad points as compared
with alternatives.

 Who are your customer's (the recipients of your program releases)?
 Usually, you cannot rely that they have online access to your repository.
 Then, they are potentionally interested in security issues and/or stability
 of the program. I'd not like a program which is said to require frequent
 updates - I'd guess that there's not much quality inside...

The program is under active development and sprouting new features 
every few minutes.  The idea is to release a new development build once
a week or so, for internal use by the customer.

 If your application has a GUI, a menu entry might fetch your update files
 and place them wherever they must reside. your update.py might feed that
 menu entry. Quite easy. 

Hmm, that's another thing I'd have to code--maybe it's feasible.  I'll
think about it.

 If you have command line apps, why not provide an additional update.py 
 and then, if you provide updates, just install them using your installed
 update.py. The only thing: How do you keep track of path/desktop/file
 information and how do you deal with user rights etc.?
 Are you aware of how this is done under WindowsXP? It's quite different from
 older Windows platforms! Therefore it might be easier, to leave this to
 professional installation tools.

No I'm really ignorant about Windows.  I just put the app's files in
C:/Program Files/appname because that's what one of the other developers
said to do.

  I do have Visual C++ installed on the development machine, if that helps.
 
 Isn't Visual C++ still coming with a restricted version of InstallShield?
 If so, check if you can use that. It might give your release a sort of
 professional shine...

Hmm, that's really really interesting.  How would I find out?  

 You'll certainly find out, that managing the registry/desktop file system
 will cost most energy, if you want to release your apps to WindowsXP.
 Once Python is running your apps, the rest is peanuts.

Oh man, I was hoping to avoid that level of hassle.  My app doesn't
use any registry keys of its own, but I guess the Python executable
does, and that stuff presumably has to be updated with every
reinstall, and something is sure to eventually go wrong and corrupt
the registry, if this is anything like the Windows that I'm used to
hearing about.  Sigh.  Just how bad is that under Windows XP?  
I'm used to Windows 95 completely falling apart at the slightest
error but I have the impression that XP is a bit more solid.

Maybe I'll have to just tell them to install Python 2.4 from its
distro MSI and then I can put together a distutils setup.py thingie
which they'd run separately.  That might be acceptable to the customer
if it saves a lot of development effort and prevents user hassles when
things go wrong.  It would sure be nice to have one of those slick
one-click installers though.
-- 
http://mail.python.org/mailman/listinfo/python-list


printing arrays in shell, and .py association with idle

2005-05-17 Thread Paris Miles-Brenden



I have been using python for the last 3 years and 
feel it to be an excellent programming language. However, I have run into 
a few snags or annoyances. I am currently 
creating a computational physics simulation which requires large arrays and am 
using numeric, although this is not a list for numeric, I think that my question 
falls under python in general.


1. My first 
problem is with printing these large arrays for debugging purposes. Is 
there any way to prevent the python shell from word wrapping single array print 
statements? I'm simply using:

print hamiltonian

where hamiltonian is an array of complex 
numbers. Changing window size (default or otherwise) does not change this, 
and I have found the option no-where.


2. Is there a foolproof way to associate .py 
files to open with IDLE, and when ending my program, not causing IDLE to 
quit? I have tried various methods to do this but none have worked so 
far.


Thank you and please accept my apology if this is 
the wrong location for these questions.

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

RE: Problem listing services with wmi

2005-05-17 Thread Tim Golden
[Jean-Sébastien Guay]
| 
| I installed Tim Golden's wmi module 
| (http://tgolden.sc.sabren.com/python/wmi.html), in the hopes it would 
| help me list and work with services on my Win32 machine. Now, 
| everything seems fine except for one thing : Listing services!
| 
| import wmi
| 
| c = wmi.WMI ()
| for s in c.Win32_Service ():
|   if s.State == 'Stopped':
| print s.Caption, s.State
| 
| and I get :
| 
| Traceback (most recent call last):
|   File stdin, line 1, in ?
|   File G:\Python-2.4\Lib\site-packages\wmi.py, line 404, in __call__
| return self.wmi.query (wql)
|   File G:\Python-2.4\Lib\site-packages\wmi.py, line 583, in query
| raise WMI_EXCEPTIONS.get (hresult, x_wmi (hresult))
| wmi.x_wmi: -2147217398

Nothing obvious, I'm afraid. I cut-and-pasted the code directly
from your email and it worked fine on my Win2K machine. For your
information, what the code is doing behind the scenes is the following:

code

import win32com.client

c = win32com.client.GetObject (
  
winmgmts:{impersonationLevel=Impersonate,authenticationLevel=Default}/root/cimv2
)
for service in c.ExecQuery (SELECT * FROM Win32_Service):
  if service.Properties_ (State).Value == Stopped:
print service.Properties_ (Caption).Value
print service.Properties_ (State).Value

/code

You might try cutting-and-pasting that code into an interpreter window
to see what happens. Likewise, the following code snippet does something
similar for vbs. Save it as something.vbs, and then run it from the
command prompt with cscript something.vbs (or however you want to
do it). I'd be interested to know if it gives the same error as the
Python version.

code

set wmi = GetObject (winmgmts:{impersonationLevel=impersonate})
set ServiceSet = wmi.InstancesOf (Win32_Service)
for each Service in ServiceSet
   WScript.Echo Service.Description
Next

/code

TJG

PS I realise that by now you've probably moved on from
this approach, but if you did manage to pin down a problem
we could address, I'd be very glad to address it.


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

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


trouble with copy/deepcopy

2005-05-17 Thread Alexander Zatvornitskiy
 Marc!

16  2005  22:18, Marc 'BlackJack' Rintsch All :

 MR That clears only one dictionary at class level.  Which is visible on
 MR both instances.

 MR class Distribution:
 MR def __init__(self):
 MR self.__gr_on_transp = dict()
 MR self.__ostatok_m = dict()
 MR ...

 MR This creates *instance variables* which should be deepcopied
 MR without problems.
Hmm. I don't find definition of class variable in manual. I try to test it on
such a simple test and find that such variable is NOT shared between copies:

class C:
  q=int()

c1=C()
c2=C()
c1.q=5
c2.q=10
print c1.q
#5
print c2.q
#10

After deepcopy of c1 or c2, all classes have own copy of q. After replacing
integer q on dictionary, results are the same. There is an error?

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

RE: Problem listing services with wmi

2005-05-17 Thread Tim Golden
[Jean-Sébastien Guay]

[... snip Larry Bates' suggestion of removing whitespace ...]

| Out of curiosity, is there any reason why whitespace between 
| the method 
| name and parameter list parentheses isn't good? Because the code I 
| posted before was copy-pasted from Tim Golden's site 
| (http://tgolden.sc.sabren.com/python/wmi.html) and the spaces 
| were there.

It's just a matter of style. Whitespace isn't *that*
significance in Python! I personally -- in whatever
language -- put spaces between function names and
their first parameter. Guido vR, as someone else
has pointed out, prefers not to.

TJG


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

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


Re: Importing and namespace visibility

2005-05-17 Thread bruno modulix
jean-marc wrote:
 Merci Bruno, ( and also to Fredrik )
 
 So I think I understand correctly, if I say that:
 each modulkes requires its own set of reference to whatever objects it
 needs to speak. The interpreter wil see not to create extra copies of
 the compiled code if many modules import the same modules but will make
 them all point to the one already existing (in this program's
 execution).

Seems right.

 Practically, it means every module import whatever it needs - be
 careful with recursive imports - keep things tidy by using the 'import
 suchModule' (and use dotted name chains to reach whatever is needed).

hint
There's a way to shortcut long.fully.dotted.Name without using the 'from
xxx import' syntax:

import long.fully.dotted
Name = long.fully.dotted.Name
/hint

OT
 PS Nice weather in Bordeaux ? 

Well... varying, as usual !-)
/OT


-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows distribution suggestions?

2005-05-17 Thread Timothy Smith
Paul Rubin wrote:

Bernhard Holzmayer [EMAIL PROTECTED] writes:
  

I can feel your unhappiness, and I share it. Hi Paul!
Here are some hints...



Thanks!  ;-)

  

Since your installer needs to run before Python is installed, you need
something else. Go to http://www.wisesolutions.com
You'll find a Windows installer program, with a demo-version (30days
license). Try this, it would be my best recommendation.



Hmm, ok, it looks like the paid version is around 500 USD.  Since this
is a Windows thing I'm ok in principle with using a payware packaging
app, but that's a bit on the expensive side.  I'll see what the
customer says but I think they might resist.

  

You'll have to test your application on Windows, in any case. 
I've built lots of applications which run in both worlds (Linux/Windows).
Usually this works, but occasionally you'll have to deal with strange
things. One is, if you use ODBC. There's good chance that you'll have to
deal with access restrictions in the %SYSTEM% directory, unless you require
an administrator's account for your application.



The app works ok under Windows now.  I don't use ODBC.  I might need
some database connectivity later and will probably use MySQL.  I don't
want to need an admin account.  Right now the app just has a Tkinter
gui, reads and writes a few files and talks to some sockets.  I might
need to add some C extensions later but those should be pretty portable.

  

If you test your app on a Windows machine, you can easily install
Python 2.3 and Python 2.4 on the same machine without
conflicts. Just try out, if your app works with either. If it works
with both, why not use 2.3?



I guess I could do that.  I believe I make some minor use of 2.4 features
but I can probably retrofit those things.

  

There's also py2exe--is that as good? 
  

Depends on your application, if that is acceptable. 
I have no experiences with that.



Me neither.  I was hoping to find out its good and bad points as compared
with alternatives.

  

Who are your customer's (the recipients of your program releases)?
Usually, you cannot rely that they have online access to your repository.
Then, they are potentionally interested in security issues and/or stability
of the program. I'd not like a program which is said to require frequent
updates - I'd guess that there's not much quality inside...



The program is under active development and sprouting new features 
every few minutes.  The idea is to release a new development build once
a week or so, for internal use by the customer.

  

If your application has a GUI, a menu entry might fetch your update files
and place them wherever they must reside. your update.py might feed that
menu entry. Quite easy. 



Hmm, that's another thing I'd have to code--maybe it's feasible.  I'll
think about it.

  

If you have command line apps, why not provide an additional update.py 
and then, if you provide updates, just install them using your installed
update.py. The only thing: How do you keep track of path/desktop/file
information and how do you deal with user rights etc.?
Are you aware of how this is done under WindowsXP? It's quite different from
older Windows platforms! Therefore it might be easier, to leave this to
professional installation tools.



No I'm really ignorant about Windows.  I just put the app's files in
C:/Program Files/appname because that's what one of the other developers
said to do.

  

I do have Visual C++ installed on the development machine, if that helps.
  

Isn't Visual C++ still coming with a restricted version of InstallShield?
If so, check if you can use that. It might give your release a sort of
professional shine...



Hmm, that's really really interesting.  How would I find out?  

  

You'll certainly find out, that managing the registry/desktop file system
will cost most energy, if you want to release your apps to WindowsXP.
Once Python is running your apps, the rest is peanuts.



Oh man, I was hoping to avoid that level of hassle.  My app doesn't
use any registry keys of its own, but I guess the Python executable
does, and that stuff presumably has to be updated with every
reinstall, and something is sure to eventually go wrong and corrupt
the registry, if this is anything like the Windows that I'm used to
hearing about.  Sigh.  Just how bad is that under Windows XP?  
I'm used to Windows 95 completely falling apart at the slightest
error but I have the impression that XP is a bit more solid.

Maybe I'll have to just tell them to install Python 2.4 from its
distro MSI and then I can put together a distutils setup.py thingie
which they'd run separately.  That might be acceptable to the customer
if it saves a lot of development effort and prevents user hassles when
things go wrong.  It would sure be nice to have one of those slick
one-click installers though.
  

mate dont bugger around with all that. py2exe will make you a windows 
native exe to run. and for 

Re: printing arrays in shell, and .py association with idle

2005-05-17 Thread Robert Kern
Paris Miles-Brenden wrote:
 I have been using python for the last 3 years and feel it to be an 
 excellent programming language.  However, I have run into a few snags or 
 annoyances.  I am currently creating a computational physics simulation 
 which requires large arrays and am using numeric, although this is not a 
 list for numeric, I think that my question falls under python in general.
  
  
 1.  My first problem is with printing these large arrays for debugging 
 purposes.  Is there any way to prevent the python shell from word 
 wrapping single array print statements?  I'm simply using:
  
 print hamiltonian
  
 where hamiltonian is an array of complex numbers.  Changing window size 
 (default or otherwise) does not change this, and I have found the option 
 no-where.

Well this at least is a Numeric-specific question, not a general Python one.

Anyways, the string representation can be controlled by supplying the 
appropriate callback. From Numeric.py (pardon any unfortunate linewraps):

#Use Konrad's printing function (modified for both str and repr now)
from ArrayPrinter import array2string
def array_repr(a, max_line_width = None, precision = None, 
suppress_small = None):
 return array2string(a, max_line_width, precision, suppress_small,
', ', 1)

def array_str(a, max_line_width = None, precision = None, suppress_small 
= None):
 return array2string(a, max_line_width, precision, suppress_small,
' ', 0)

multiarray.set_string_function(array_str, 0)
multiarray.set_string_function(array_repr, 1)

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Lex Python

2005-05-17 Thread s
I am using bumblebee software PARSER GENERATOR to make a C file from LEX 
regular definitions.
I want to compile that C file with VS .NET but I have problems.
I am working this for Python regular definitions.
Does somebody know how to configure a project to work? Or maybe somone havde 
done all this and can hel me in that way.I need this help soon as possible.
Thanks


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


Python forum

2005-05-17 Thread Jonas Melian
Hi,

I'm going to say a suggestion, why don't you create a forum like the one
of Ruby (http://www.rubyforums.com/)? for the novices this is a great
help, better than a mail list

It's also worth noting that rubyforums.com has nearly no posts (six
total) because it takes very just a short time working.

I know that you have python-list, it's both an email and a usenet list.
But I think that a forum is great for the learning. The test is in
gentoo's forums. They are a lot of experienced people answering
questions without any problem and it goes very well

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


Re: Quick Reference from module doc strings.

2005-05-17 Thread Michele Simionato
 Do you have any feature suggestions, additional information that
could
 go in, something that would extend the content in some way and make
it
 more useful?

I have written something similar which I use all the time. It generates
ReST
output which I can browse with less from the command line, as well as
HTML
output and PDF output that I can print. The hard work is done by
docutils, of course.
I have options to specify if I want to least private names or not, and
to specify
if I want an analytical index to be generated or not. Also, the HTML
output
contains hyperlinks to the original source code, so I can see  it with
a click.
I can feed to minidoc whole packages (it works recursively on
subpackages, so everything is documented).

It was unvaluable in my struggle with Zope.

Michele Simionato

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


Re: trouble with copy/deepcopy

2005-05-17 Thread Peter Otten
Alexander Zatvornitskiy wrote:

 Hmm. I don't find definition of class variable in manual. I try to test
 it on such a simple test and find that such variable is NOT shared between
 copies:
 
 class C:
 q=int()
 
 c1=C()
 c2=C()
 c1.q=5
 c2.q=10
 print c1.q
 #5
 print c2.q
 #10
 

Your test is flawed:

 class C:
... q = 0 # class variable
...
 c = C()
 C.__dict__
{'q': 0, '__module__': '__main__', '__doc__': None}
 c.__dict__
{}
 c.q
0
 c.q = 42 # this is stored in the instance, not the class
 c.__dict__
{'q': 42}
 C.__dict__
{'q': 0, '__module__': '__main__', '__doc__': None}
 c.q
42
 del c.q
 c.q # because C.q is looked up as a fallback, 0 magically reappears
0

Peter

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


Re: Newbie : checking semantics

2005-05-17 Thread Stefan Nobis
[EMAIL PROTECTED] (Bengt Richter) writes:

[block end statements]
 Training wheels do no belong as a permanent part of a bicycle,

Yes, but they would be useful for example in web programming
(embedding Python into HTML), too. So they are not only training
wheels.

But that's not so important. What Python got really wrong is
mixing binding and assignment (because this way you have little
chance to catch typos in identifiers).

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


Function parameter passing problem

2005-05-17 Thread Eduardo Biano
Hi,

I am new to python and tried to pass parameters
between one function to another. I tried two
approaches in doing this but failed. 

The first is, I tried to assign a variable in foo1()
inside an HTML INPUT hidden tag so that I can
retreive it in foo2() using (get_form_var()). But
failed using my limited python knowledge. The sample
code. 

def foo1(request, result)
...
... 
Id_No, FirstName, LastName = result
   
HTML
..
..  
INPUT NAME=id  TYPE=hidden VALUE=Id No
   # I would like to assign Id_No variable to id.

INPUT NAME=submit TYPE=submit VALUE=SUBMIT

   ...
   ..
   /HTML
   
 
The second is, I tried using return Id_No statement 
 foo2() function using a return statement below the
/HTML tag. I tried this option but unfortunately
when I hit the SUBMIT button it only displayed the
variable and got stucked and didn't continue to the
called FORM action=foo2 foo2().

I also have a problem with my user defined function
foo2() which I created at first with one parameter to
accept the variable of foo1(). But when I added
another parameter to accomodate some more and executed
the code, an error message TypeError: foo2() takes
exactly 2 arguments (1 given). I thought I can put as
many parameters I could since this is user defined
function, am I correct in this? 

I have no more options to this problem, hope you will
help me . Thank you in advance.

Cheers!
Ed




 



Discover Yahoo! 
Have fun online with music videos, cool games, IM and more. Check it out! 
http://discover.yahoo.com/online.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python forum

2005-05-17 Thread Robert Kern
Jonas Melian wrote:
 Hi,
 
 I'm going to say a suggestion, why don't you create a forum like the one
 of Ruby (http://www.rubyforums.com/)? for the novices this is a great
 help, better than a mail list
 
 It's also worth noting that rubyforums.com has nearly no posts (six
 total) because it takes very just a short time working.
 
 I know that you have python-list, it's both an email and a usenet list.
 But I think that a forum is great for the learning. The test is in
 gentoo's forums. They are a lot of experienced people answering
 questions without any problem and it goes very well

Various Python web fora have sprung up now and again. None of them ever 
grab much of an audience.

OTOH, if you're volunteering your own time and effort to set one up, I'm 
not going to stop you.

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: Windows distribution suggestions?

2005-05-17 Thread Bernhard Holzmayer
Paul Rubin wrote:

 Since your installer needs to run before Python is installed, you need
 something else. Go to http://www.wisesolutions.com
 You'll find a Windows installer program, with a demo-version (30days
 license). Try this, it would be my best recommendation.
 
 Hmm, ok, it looks like the paid version is around 500 USD.  Since this
 is a Windows thing I'm ok in principle with using a payware packaging
 app, but that's a bit on the expensive side.  I'll see what the
 customer says but I think they might resist.

1) Maybe you can start with the 30days demo license to find out.
2) The high price is paid for the benefit, that you won't get lost inside
the terrific installation jungle like registry, access restrictions, dlls
etc. In the end, it's your benefit, not your customer's.
If I were the customer, I'd demand a fluent installation process at no cost
and without any risk and/or conflict with other installed software. 
If I were the developer (you), I'd compare all costs/times with that price.
If you calculate one hour for let's say 25 USD, the question is: will it
save you 20 hrs. I guess so. If you have spare time, it doesn't get paid.

 The app works ok under Windows now.  
Congratulations.
 I don't use ODBC.  I might need some database connectivity later and will
probably use MySQL.  
Then you'll probably use ODBC, since the MySQL server will probably not be
run under Windows and on the same machine. 
 I don't want to need an admin account.  
Nobody wants that. It just happens...
 Right now the app just has a Tkinter gui, 
That's safe in general, and probably a good choice.
 reads and writes a few files and talks to some sockets.  
Not that trivial! Plan enough time for testing.
And, if you install without sophisticated tool, reserve enough time for
troubleshooting and modifications...
 
 The program is under active development and sprouting new features
 every few minutes.  The idea is to release a new development build once
 a week or so, for internal use by the customer.
If the customer runs it on different machines, make sure that you always
have one installation around where you work, which is exactly as the one at
the customer's site. If the customer is able to run different versions at
the same time, keep one living copy of every possible version.
Hunting bugs while you have lost the overview of the versions, will haunt
you in the end...
 
 If your application has a GUI, a menu entry might fetch your update files
 and place them wherever they must reside. your update.py might feed that
 menu entry. Quite easy.
 
 Hmm, that's another thing I'd have to code--maybe it's feasible.  I'll
 think about it.
Have a look at one of the Adobe Acrobat Reader's newest versions. They do
this. Indeed, it doesn't work on my computer, but that's the idea...

 No I'm really ignorant about Windows.  I just put the app's files in
 C:/Program Files/appname because that's what one of the other developers
 said to do.

Don't do that, despite what the others say. You may propose that, but in any
case give the installer the choice to change it.
Lots of people use different partitions which separate Windows / Programs /
Data. In other countries even Windows uses different path names (e.g. here
in Germany C:/Programme). According to Microsoft's Technical Reference,
you'd better ask the registry to find out where applications usually
reside. (That's what professional installation software does.)

I guess that neither your apps nor Python requires special folders or paths,
so don't impress this disadvantage artificially.
Vice versa: don't ask for another drive/partition, because some users have
only C:/... 

 
  I do have Visual C++ installed on the development machine, if that
  helps.
 
 Isn't Visual C++ still coming with a restricted version of InstallShield?
 If so, check if you can use that. It might give your release a sort of
 professional shine...
 
 Hmm, that's really really interesting.  How would I find out?
Check the installation. Your StartMenu should show the appropriate entry
under VisualStudio/...tools... If not, maybe you forgot to install it.
Or, it's gone away like some other precious tools...
 
 You'll certainly find out, that managing the registry/desktop file system
 will cost most energy, if you want to release your apps to WindowsXP.
 Once Python is running your apps, the rest is peanuts.
 
 Oh man, I was hoping to avoid that level of hassle.  
In contrary, that's what really makes fun. The registry is like a bomb in
your hand - it provides mighty power over the user!!!

 My app doesn't use any registry keys of its own, but I guess the 
 Python executable does, and that stuff presumably has to be updated 
 with every reinstall, 
Probably no. Since your update will certainly only affect py-files, there's
no reason to worry about the Python's registry activities.
The other thing is, that your update must know where to put the updated
files, and that information is usually kept in the registry.

Re: Windows distribution suggestions?

2005-05-17 Thread Toby Dickenson
On Tuesday 17 May 2005 09:35, Timothy Smith wrote:
 mate dont bugger around with all that. py2exe will make you a windows 
 native exe to run. and for updates you just need to update it's 
 library.zip.

py2exe is working great for me too. 

 My app contains three different programs (say alice.py, bob.py, and
 carol.py) that need to be independently launchable, and a dozen or
 so other .py files that get imported into those first three

One tip: make sure your three top-level scripts are as empty as possible: just 
import some other module and call a function. All your active code is then in 
some library.zip shared between the three, and you need never change 
alice.exe, bob.exe, and carol.exe

 use NSIS for the installer, it can do anything you want an  
 it's free. it couldn't be more simple, shoot me an email if you
 need more 

Ive not used NSIS, but I have had good results from the free WiX tools, at 
http://sourceforge.net/projects/wix/. Documentation is poor, but examples are 
plenty.

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


Re: Windows distribution suggestions?

2005-05-17 Thread Timothy Smith
Toby Dickenson wrote:

On Tuesday 17 May 2005 09:35, Timothy Smith wrote:
  

mate dont bugger around with all that. py2exe will make you a windows 
native exe to run. and for updates you just need to update it's 
library.zip.



py2exe is working great for me too. 

  

My app contains three different programs (say alice.py, bob.py, and
carol.py) that need to be independently launchable, and a dozen or
so other .py files that get imported into those first three
  


One tip: make sure your three top-level scripts are as empty as possible: just 
import some other module and call a function. All your active code is then in 
some library.zip shared between the three, and you need never change 
alice.exe, bob.exe, and carol.exe

  

use NSIS for the installer, it can do anything you want an  
it's free. it couldn't be more simple, shoot me an email if you
need more 



Ive not used NSIS, but I have had good results from the free WiX tools, at 
http://sourceforge.net/projects/wix/. Documentation is poor, but examples are 
plenty.

  

another good one is Inno, although it's not as easy to use as NSIS. Inno 
and NSIS can do anything a commercial installer can do, Inno especially.

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


Help wanted

2005-05-17 Thread Jacob van Iwaarden
Hello NG,
I'm a 59 year old Networker who was pushed to go to school for 2 years. I 
think I did it fine 'till now. But now I have to make a small project in 
Python with Y-Pages and Snakeletts. My Problem is that Python is like 
Arabian to me, and I have Time till Sunday.
My Question: is here anyone who is willing to help me by PM on this projekt? 
The teacher told us it will be approx. 50 Lines of Code.
I have to make a Webapplication wich will take Number and Title and number 
of minutes of CD's. It should be done with strings, no saving into an 
SQL-Database or so. I have to add , edit, search and show and delete Items.


Thanks in advance

Jacob 


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


Re: query progress bar

2005-05-17 Thread f
Timothy Smith wrote:
 is it possible to mke a progress bar for queries? say i have a query 
 that will take 20 seconds, i'd like to give some feed back to users on 
 how long this will take.

it is strictly impossible to predict that cause of network load, server 
load, query complexity 

i recommend you put an activity widget, something moving (ie throbber in 
wxPython) while waiting for the result (like the rotating circle in 
firefox).

once query is finished stop your moving stuff, so the user knows it's 
completed.

So you don't need a progress bar, but an activity widget. in gtk, i saw 
that progress bar could be put in activity mode.

And don't forget to add a timeout ...

François
-- 
http://mail.python.org/mailman/listinfo/python-list


\r functionality

2005-05-17 Thread Jake
in c and c++ there is a useful way to refresh an output line in printf
and cout using \r meta command. So for example in the wget application
the progress of the download is updated on the same output line of the
screen. From an intital investigation python seems to lack this. Is
this correct?

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


Re: Newbie : checking semantics

2005-05-17 Thread Antoon Pardon
Op 2005-05-16, Bengt Richter schreef [EMAIL PROTECTED]:
 On Mon, 16 May 2005 18:40:43 +0200, Stefan Nobis [EMAIL PROTECTED] wrote:

rbt [EMAIL PROTECTED] writes:

 True beginners (no programming experience whatsoever) don't have
 to deal with unlearning stuff such as the bracket plague.

That's true. But they also not very used to give nothing (-
whitespace) a meaning. I teached quite some beginners and most of
them had problems to get the indentation right.

At least in the very beginning IMHO it would be useful to
explicitly end a block with some kind of an end statement.

Meaningful whitespache is not a big problem (as many people seems
to think) but it's also not very obvious and sometimes it causes
at least a little bit trouble.

 Training wheels do no belong as a permanent part of a bicycle, IMO.

But what is a training wheel depends on your point of view.

IMO the required indentation is more like permanent training wheels
than end block-markers would be. A structure in general has a begin
marker and an end marker. Even python has them in some cases like
lists and tuples. 

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


Re: Python forum

2005-05-17 Thread Markus Weihs
Hi!

 I'm going to say a suggestion, why don't you create a forum like the one
 of Ruby (http://www.rubyforums.com/)? for the novices this is a great
 help, better than a mail list
 
 It's also worth noting that rubyforums.com has nearly no posts (six
 total) because it takes very just a short time working.
 
 I know that you have python-list, it's both an email and a usenet list.
 But I think that a forum is great for the learning. The test is in
 gentoo's forums. They are a lot of experienced people answering
 questions without any problem and it goes very well

If you speak German, there is a forum at www.python-forum.de .
There is also an english one at http://python-forum.org/py/index.php,
but as you can see, there's not much traffic :-/


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


Re: \r functionality

2005-05-17 Thread Daniel Schüle
Jake wrote:
 in c and c++ there is a useful way to refresh an output line in printf
 and cout using \r meta command. So for example in the wget application
 the progress of the download is updated on the same output line of the
 screen. From an intital investigation python seems to lack this. Is
 this correct?
 

  print a\rb
b
 

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


Re: Windows distribution suggestions?

2005-05-17 Thread Paul Rubin
Bernhard Holzmayer [EMAIL PROTECTED] writes:
  Hmm, ok, it looks like the paid version is around 500 USD
  I'll see what the
  customer says but I think they might resist.
 
 1) Maybe you can start with the 30days demo license to find out.

Yes, I'd certainly do that first.

 2) The high price is paid for the benefit, that you won't get lost inside
 the terrific installation jungle like registry, access restrictions, dlls
 etc. In the end, it's your benefit, not your customer's.

Well, both would benefit, I think.

 If I were the customer, I'd demand a fluent installation process at no cost
 and without any risk and/or conflict with other installed software. 

Of course the customer wants this, but in reality it's going to have
to cost them, so I have to explain that and let them decide.  

 If I were the developer (you), I'd compare all costs/times with that price.
 If you calculate one hour for let's say 25 USD, the question is: will it
 save you 20 hrs. I guess so. If you have spare time, it doesn't get paid.

I wonder if I'd be trading off 20 hours messing with py2exe or
whatever, against 20 hours of learning curve with Wise.  Is Wise
really easy and fast to get started with?  Well, I guess that's what
the evaluation version is to help find out ;-).  

I'm concerned that it's going to be the same 20 hours either way (as
compared with just having them install python.msi separately), and 20
hours of development probably means a full week on the calendar
because of meetings, phone calls and all that usual stuff.  This app
is a small component of a big project and spending an extra week on it
means the whole project takes longer, which is never a good thing.

  The app works ok under Windows now.  
 Congratulations.

Ehh, no big deal, there's not much system dependency so far, and it
was developed under Windows (with IDLE even) from the beginning.  It
may get more system dependent later.

 Then you'll probably use ODBC, since the MySQL server will probably not be
 run under Windows and on the same machine. 

Hmm, at least at first I'd run MySQL on the same machine under Windows
(I know MySQL can run under Windows) but maybe that still needs ODBC.
Eventually it may have to talk to another DB like Oracle.

  I don't want to need an admin account.  
 Nobody wants that. It just happens...

Sigh.  I guess it figures.

  reads and writes a few files and talks to some sockets.  
 Not that trivial! Plan enough time for testing.
 And, if you install without sophisticated tool, reserve enough time for
 troubleshooting and modifications...

Yeah, I really want to keep the installation stuff simple.  

 If the customer runs it on different machines, make sure that you always
 have one installation around where you work, which is exactly as the one at
 the customer's site.

Hmm, maybe not so easy, the customer may be using several different
Windows configurations in different places.

 If the customer is able to run different versions at
 the same time, keep one living copy of every possible version.

For now, I think I can say they have to track the current version.
It may be an issue in the future.

 [self-updating feature built into the app]
 Have a look at one of the Adobe Acrobat Reader's newest versions. They do
 this. Indeed, it doesn't work on my computer, but that's the idea...

Well, it's something to keep in mind, but I'm hoping this stays simple.

  I just put the app's files in C:/Program Files/appname...
 
 Don't do that,... In other countries even Windows uses different
 path names (e.g. here in Germany C:/Programme). 

Good point!!!  Yes, the customer will be running some non-English
Windows installations.  Thanks for mentioning this, I'm sure I would
have otherwise found out the hard way.  

 According to Microsoft's Technical Reference, you'd better ask the
 registry to find out where applications usually reside. (That's what
 professional installation software does.)

Hmm, I think there's a Python function to read registry entries.  I
better check the docs.  Can I just use C:/Appname like the Python
installer does?  If I have a way to launch the gui at all, I guess I
can have a configuration screen that lets the user change that
location.

  Isn't Visual C++ still coming with a restricted version of InstallShield?
  ...
 Check the installation. Your StartMenu should show the appropriate entry
 under VisualStudio/...tools... If not, maybe you forgot to install it.
 Or, it's gone away like some other precious tools...

I didn't see anything like that in the tools menu, but it's possible I
didn't install it.  I think it's a 2-CD installation and I only
installed one of them (the guy at the office said that's the usual
way).  It's Visual Studio 6 (the customer is on MSDN and supplied me
with the machine).

 In contrary, that's what really makes fun. The registry is like a bomb in
 your hand - it provides mighty power over the user!!!

Arrgghhh!  ;-)

  and something is sure to eventually go wrong 

Re: Windows distribution suggestions?

2005-05-17 Thread Paul Rubin
Toby Dickenson [EMAIL PROTECTED] writes:
 py2exe is working great for me too. 

I should give it a try.

 One tip: make sure your three top-level scripts are as empty as
 possible: just import some other module and call a function. All
 your active code is then in some library.zip shared between the
 three, and you need never change alice.exe, bob.exe, and carol.exe

I think I understand what you're saying and it sounds like a very
good idea.  Thanks.

  use NSIS for the installer, it can do anything you want an  
  it's free. it couldn't be more simple, shoot me an email if you
  need more 
 
 Ive not used NSIS, but I have had good results from the free WiX
 tools, at http://sourceforge.net/projects/wix/. Documentation is
 poor, but examples are plenty.

I'll look at these and at INNO (mentioned in another post).  Thanks
again to everyone.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows distribution suggestions?

2005-05-17 Thread Ivan Voras
Paul Rubin wrote:

your active code is then in some library.zip shared between the
three, and you need never change alice.exe, bob.exe, and carol.exe
 
 I think I understand what you're saying and it sounds like a very
 good idea.  Thanks.

One thing about updating files - sorry if I'm stating general and 
universal knowledge, but beware that on Windows you can't delete and/or 
replace a file if it's opened by any process.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Like Christ PBBUH Prayed

2005-05-17 Thread I Know
oh, just 
shut
the
fuck
up
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows distribution suggestions?

2005-05-17 Thread Timothy Smith
Ivan Voras wrote:

Paul Rubin wrote:

  

your active code is then in some library.zip shared between the
three, and you need never change alice.exe, bob.exe, and carol.exe
  

I think I understand what you're saying and it sounds like a very
good idea.  Thanks.



One thing about updating files - sorry if I'm stating general and 
universal knowledge, but beware that on Windows you can't delete and/or 
replace a file if it's opened by any process.
  

hence i found you must do this immediately after updating

sys.path_importer_cache.clear()
zipimport._zip_directory_cache.clear()

then unload your app

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


Re: query progress bar

2005-05-17 Thread Bernhard Holzmayer
Timothy Smith wrote:

 i'm using pypgsql

Assuming you work with PostgreSQL, then:
You know the EXPLAIN command?

EXPLAIN will give you a very accurate estimation for the expense for the
query. 
(You'll have to find out what cost means in terms of your progress.)

I did never try this using pypgsql, but if it works, this might be your
solution...

The precision of EXPLAIN, however, depends on the modifications since the 
last time you ran VACUUM on the DB.
If the size of tables or indices didn't suffer considerable changes since
then, the estimation should be quite accurate.

Bernhard

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


Re: Python Documentation (should be better?)

2005-05-17 Thread Davo
Overall organization is definitely an issue, at least for newer users.
As an occasional python user I remain constantly in a mode of having to
look up basic terminology for examples and exact spelling of terms in
order to knock out a quick script.  I feel very much like Mr. Bottaro
that the docs, while quite good in some ways, can be frustrating and
inconsistent at times.  Here's a link to a concrete and mostly real
stream of consciousness example of using the docs: (rather long)

http://home.pacbell.net/dl_brown/input_something.txt

Many responses from experienced users that show how to find a certain
piece of information really miss the point by a wide margin.  It's nice
that they can find the information easily of course.  It's those who
don't have the experience who can have more trouble.  If the docs,
especially the tutorial, are intended to help those with limited
experience they should try to be a little more fool-proof with regard
to indexing and searching, and also have more basic examples.

Here are a couple specific suggestions for improvements:

-- Please add the basic input methods to the Input/Output section of
the tutorial (see previous link and the original post for this thread)

-- Add a Doc_Feedback button on many of the documentation pages so when
people have problems finding or understanding something they can
immediately and easily send feedback about that specific problem.

-- Consider at least renaming and reordering the main doc page links to
highlight the most important 2 or 3 docs for people who don't know
where to start.  Right now the doc structure is too flat and
disconnected in my opinion.  It needs to act more like a funnel. Today
I have to pick which document might contain the information I need and
if I'm wrong I probably won't find what I'm looking for quickly.  The
present structure seems to work ok for experts, not so well for
novices.

-- If doc maintainers believe the better approach for most people is to
just search (I don't) then move the doc links to the side, put them in
a smaller font, and put a big search box in the middle of the docs
page.  Right now search is in the far corner so the implicit
understanding is that it's not the first thing to try.

-- Find clearer names/descriptions for some documents.  For example
maybe it's just me but what is the _Library_ Reference?  I know about
python modules and python language, etc.  What are python libraries.
Or is it just intended to mean generically a book in a library of
python books?  There was some discussion and debate about which doc was
the Manual  Perhaps one of the docs or a reorganized combination
should be called the Python Online Manual if Manual Implies that it's
the go-to book.

-- And finally, I recall the last time I tried to figure out how to do
something with a date value I looked in the datetime module.  There are
lots of sophisticated tools apparently but I really never grasped how
to go about using them.  A couple basic examples of what can be done
with the tools would be nice.

--  TkInter... (ok I'm done now)

 help(tKinter)
Traceback (most recent call last):
  File stdin, line 1, in ?
NameError: name 'tKinter' is not defined
 help('tkinter')
no Python documentation found for 'tkinter'

 help('tKinter')
no Python documentation found for 'tKinter'

 help('TkIinter')
no Python documentation found for 'TkIinter'

 help('TkInter')
no Python documentation found for 'TkInter'

 help('Tkinter')

Help on module Tkinter:  (don't believe it)


-- David

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


Re: Python on a public library computer

2005-05-17 Thread Anton Vredegoor
John J. Lee wrote:

 Why not Jython?

There's no command prompt! The file menu from IE is also gone. There is
a sun Java console but it looks like this:

quote Sun Java Console

Java(TM) Plug-in: Version 1.4.2_06
Using JRE version 1.4.2_06 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\x

c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
p:   reload proxy configuration
q:   hide console
r:   reload policy configuration
s:   dump system properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to n

/quote Sun Java Console

Thanks for replying anyway!

Anton

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


Re: Python on a public library computer

2005-05-17 Thread Anton Vredegoor
John J. Lee wrote:

 Why not Jython?

There's no command prompt! The file menu from IE is also gone. There is
a sun Java console but it looks like this:

quote Sun Java Console

Java(TM) Plug-in: Version 1.4.2_06
Using JRE version 1.4.2_06 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\x

c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
p:   reload proxy configuration
q:   hide console
r:   reload policy configuration
s:   dump system properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to n

/quote Sun Java Console

Thanks for replying anyway!

Anton

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


Image.putpalette(Colors)?

2005-05-17 Thread Oliver Albrecht
 Has somebody a example-script how i can put a other palette to a image?
(after this the image should have similar outlook)


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


Re: query progress bar

2005-05-17 Thread Timothy Smith
Bernhard Holzmayer wrote:

Timothy Smith wrote:

  

i'm using pypgsql



Assuming you work with PostgreSQL, then:
You know the EXPLAIN command?

EXPLAIN will give you a very accurate estimation for the expense for the
query. 
(You'll have to find out what cost means in terms of your progress.)

I did never try this using pypgsql, but if it works, this might be your
solution...

The precision of EXPLAIN, however, depends on the modifications since the 
last time you ran VACUUM on the DB.
If the size of tables or indices didn't suffer considerable changes since
then, the estimation should be quite accurate.

Bernhard

  


i've never heard of pypgsql supporting andthing like that, but i'll have 
a look

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


Re: Python on a public library computer

2005-05-17 Thread Anton Vredegoor
Timothy Smith wrote:

 how locked down is the computer? there's a few (brave) public access
 unix shell providers out there. if you could run telnet you could use
them

Sorry, no telnet. Every executable that is not listed is blocked. For
example I can download:

http://prdownloads.sourceforge.net/scintilla/Sc1.exe

but if I run it I get two error messages:

a) a 15 seconds appguard message

b} 'access to the specified device, path or file is denied'

Maybe some shell provider is a good idea, however I still think I
should make a cherrypy form of 24 lines or so and run it over there and
simulate a python interpreter on a webpage which I can access from
here. Has this been tried before?

How can I use cookies to identify interpreter sessions?

Anton

'webpython_3000_server_at_xxx.xxx.xxx.xxx_'

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


Re: \r functionality

2005-05-17 Thread Duncan Booth
Jake wrote:

 in c and c++ there is a useful way to refresh an output line in printf
 and cout using \r meta command. So for example in the wget application
 the progress of the download is updated on the same output line of the
 screen. From an intital investigation python seems to lack this. Is
 this correct?
 

 for i in range(1):
...   print '\r',i,'and counting',
...
 and counting

(not obvious from the copy/paste of the output is that it also displayed 
the intervening numbers as it counted). The important thing is to end each 
print statement with a comma (or use sys.stdout.write).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interaction between TclTk editor with Python code

2005-05-17 Thread Jeff Epler
One way to get a handle on some Tcl variables from Python is to create
Tkinter.Variable instances with the names of the existing Tcl variables
(normally, the variable names are chosen arbitrarily).  Once you've done
this, you can do things like add variable traces (the trace_variable
method) on the Python side.  One thing to be aware of is that the Python
object's __del__ will unset the variable on the Tcl side.  Also, this
code sets an initial value for the variable which may or may not be
appropriate in your application.

The code below was ripped from a larger application, so it may or may
not work without modification.

Jeff

# This code is in the public domain
from Tkinter import *
def makevar(master, name, klass, *default):
self = newinstance(klass)
self._master = master
self._tk = master.tk
self._name = name
if default:
self.set(default[0])
else:
self.set(self._default)
return self

def makebool(master, name, *default):
return makevar(master, name, Tkinter.BooleanVar, *default)
def makeint(master, name, *default):
return makevar(master, name, Tkinter.IntVar, *default)
def makefloat(master, name, *default):
return makevar(master, name, Tkinter.DoubleVar, *default)
def makestring(master, name, *default):
return makevar(master, name, Tkinter.StringVar, *default)


pgp8S84d8ZZDq.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Bug in Elementtree/Expat

2005-05-17 Thread alainpoint
Hello,

I use Elementtree to parse an elementary SVG file (in fact, it is one
of the examples in the SVG essentials book). More precisely, it is
the fig0201.svg file in the second chapter.
The contents of the file are as follows (i hope it will be rendered
correctly):
!DOCTYPE svg PUBLIC -//W3C//DTD SVG 1.0//EN
http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd;
svg width=200 height=200
titleDefault User Coordinates/title
descShows a rectangle on a grid in default user coordinates/desc
image xlink:href=default_ruler.svg x=0 y=0 width=200
height=200/
g transform=translate(40,40)
rect x=10 y=10 width=50 height=30style=stroke: black; fill:
none;/
/g
/svg

The parsing fails in the following way:
Traceback (most recent call last):
  File C:\privatedata\myapp.py, line 60, in ?
root = ElementTree(file=infile).getroot()
  File c:\python23\lib\site-packages\elementtree\ElementTree.py, line
554, in __init__
self.parse(file)
  File c:\python23\lib\site-packages\elementtree\ElementTree.py, line
594, in parse
parser.feed(data)
  File c:\python23\lib\site-packages\elementtree\ElementTree.py, line
1171, in feed
self._parser.Parse(data, 0)
xml.parsers.expat.ExpatError: unbound prefix: line 6, column 1


The problem seems to lie with the xlink:href tag. If i remove the xlink
namespace, it then does not produce a traceback.

Thank you for helping
Alain

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


Re: question about the id()

2005-05-17 Thread Peter Dembinski
Giovanni Bajo [EMAIL PROTECTED] writes:

 Peter Dembinski wrote:

 BTW, a typical performance optimization (not done automatically by
 python) is to hoist unchanging-value expressions out of loops, and
 obj.method is often such an expression, so you will this strategy
 when people try
 to squeeze extra performance from their programs.

 Good to know.  Is there any advanced optimizer for Python code,
 which would do such things for me (or suggest them, like pychecker
 does for readability)?


 Prove that a.f() would not change the meaning of a.f after its
 invokation is close to impossible.

Many things in Python programs cannot be proved.  But what about
suggesting optimisations, not doing them automatically?  

The similar case may be found in refactorization -- most things cannot
be proved, so the final decision is left to the programmer (and his
unit tests).

-- 
http://www.peter.dembinski.prv.pl
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python on a public library computer

2005-05-17 Thread Robert Kern
Anton Vredegoor wrote:
 Timothy Smith wrote:
 
 
how locked down is the computer? there's a few (brave) public access
unix shell providers out there. if you could run telnet you could use
 
 them
 
 Sorry, no telnet. Every executable that is not listed is blocked. For
 example I can download:
 
 http://prdownloads.sourceforge.net/scintilla/Sc1.exe
 
 but if I run it I get two error messages:
 
 a) a 15 seconds appguard message
 
 b} 'access to the specified device, path or file is denied'

There is a Java SSH client that runs in the browser.

http://www.oit.duke.edu/sa/security/ssh.html

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: Python forum

2005-05-17 Thread Brett g Porter
Jonas Melian wrote:
 Hi,
 
 I'm going to say a suggestion, why don't you create a forum like the one
 of Ruby (http://www.rubyforums.com/)? for the novices this is a great
 help, better than a mail list
 
 It's also worth noting that rubyforums.com has nearly no posts (six
 total) because it takes very just a short time working.
 
 I know that you have python-list, it's both an email and a usenet list.
 But I think that a forum is great for the learning. The test is in
 gentoo's forums. They are a lot of experienced people answering
 questions without any problem and it goes very well
 
 Thanks

Don't forget that there's also the Tutor list (see 
http://www.python.org/mailman/listinfo/tutor ), targeted to people 
looking to learn the language...


-- 
//  Today's Oblique Strategy (© Brian Eno/Peter Schmidt):
//  Change instrument roles
//  Brett g Porter * [EMAIL PROTECTED]

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


Re: Python on a public library computer

2005-05-17 Thread Anton Vredegoor
Chris Lambacher topposted:

 usb key and moveable python.
 http://www.voidspace.org.uk/python/movpy/

I have a usb card reader and I can use it. That saves me from having to
have remote storage at least. However I can only save files, not open
them, except if I use word, excel or powerpoint.

The moveable python is great indeed. This worked here before, but then
I could even access *other* peoples usb sticks in this whole building
... Crazy. Not anymore though. They could really use someone like me
here for a sensible security policy that doesn't cripple the users. I
can't even set internet options, that means I can't remove my history
or clear my cache :-(

Anton

'security doesn't mean shooting everyone in the foot'

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


Re: logging problems

2005-05-17 Thread [EMAIL PROTECTED]
I tried moving the import traceback to the start of  the file
(logging/__init__.py) but that did not seem to have any effect?
I suppose the fix was in version 1.26 in cvs?

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


Re: Python forum

2005-05-17 Thread Skip Montanaro

Brett Don't forget that there's also the Tutor list (see
Brett http://www.python.org/mailman/listinfo/tutor ), targeted to
Brett people looking to learn the language...

I wonder if there's a way to gateway the tutor list to the
python-forum.org forum, probably to the beginner's forum.

Skip

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


Design Question. Data Acquisition/Display related.

2005-05-17 Thread StepH
Hi,

I'm building a little application, which the goal is to:

1./ Collect data via Serial line and or via a file (for playback).
2./ Display these data as graph, oscilloscope, ...

How manage this ?

1./ Is each display must responsible to acquire/read the data ?
2./ Or an engine collect the data then send them to each display ?

Also, how to anim this ?

1./ Via a timer ?
2./ Via a simple loop (read/update display/pause/read user key)

The app. will be a GUI (tkInter) app. and the user must be able to stop 
the process at any time.

Sure, all this must be maintenable, let's say to acquire data via other 
type of channel or to other type of display...

Yes, it's like a mini labView...

Any idea or link is welcome.

Thanks.

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


a little trouble passing values to Oracle using bind variables

2005-05-17 Thread Michael . Coll-Barth
All,

As the subject line says, I am having some trouble passing bind variables to
Oracle.  When I pass a printable string value, such as 'NM', I get data.
When I try to pass a non-printable character, such as 'return' - chr(13), I
get no data back.  I can't simply make NactionCode = chr(13), as python
would change the value of NactionCode to '\r' and Oracle sees this as a two
byte character, and not chr(13).  I have looked into how Oracle might accept
something like '\x00' for chr(0), but to no avail.  

Any thoughts?

thanks,
Michael



def goGetIt( NactivityDt, NactionCode ):

dataQuery = '''select a, b, c
   from %s 
   where activityDt  = :NactivityDt
 and actionCode  = :NactionCode
   order by %s
''' % ( schema.tableName )

dbm.cursor.execute(dataQuery, NactivityDt = activityDt, NactionCode =
actionCode )
result = dbm.cursor.fetchall()

return result

NactivityDt = '12-apr-2005'
NactionCode = 'NM'
act1 = goGetIt( NactivityDt, NactionCode )

NactivityDt = '12-apr-2005'
NactionCode = 'chr(13)'
act2 = goGetIt( NactivityDt, NactionCode )

NactivityDt = '12-apr-2005'
NactionCode = chr(13)
act3 = goGetIt( NactivityDt, NactionCode )
___
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.

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


PyXML/expat and the empty elements

2005-05-17 Thread Armin Steinhoff


Hi all,

is it possible to get the name of an empty element specified
by element/ ... the expat parser seems only to recognize
the element/element form

Regards

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


Re: PyXML/expat and the empty elements

2005-05-17 Thread Armin Steinhoff
Armin Steinhoff wrote:
 
 
 Hi all,
 
 is it possible to get the name of an empty element specified
 by element/ ... the expat parser seems only to recognize
 the element/element form
 
 Regards
 
   Armin


Ok ... found the root of the problem. The expat parser is OK :)

Regards

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


Re: Python on a public library computer

2005-05-17 Thread TZOTZIOY
On 14 May 2005 04:21:04 -0700, rumours say that
[EMAIL PROTECTED] [EMAIL PROTECTED] might have
written:

I'm typing this in a public library on a computer with OS windows 2000
server. I can run Internet explorer, word, excel and powerpoint, that's
it. Maybe java, but it seems to be flaky.

I want to run python scripts from this computer.

snip

I am not sure I will help you (uncertainty based on the part I snipped),
but the part so far can be easilly solved if you install Python for
single user inside the Documents and settings\username folder (or
whatever it is called).  I did in a similar case.


End of reply here; and now for some completely minor python success
story.


Some months ago, I happened to be for full workdays at a client's site,
with strict security rules enforced (no domain login == no access even
to web proxy) but I needed to access my company's internal mail server
from my laptop (which I do by ssh forwarding usually).  I could plug in
my laptop to their network, get an address, but that was all (local
network access only).

So I asked permission from an employee there (working on a computer
logged on to the domain) if I could run a putty session with forwarding
enabled.  He said he'd ask their BOFH; now, the BOFH was strictly a
windows person (I somehow connect strictly-industry-standard-OS/app
persons with lack of resourcefulness, as if these people have 7 bits
per byte :), and he thought that my case was hopeless, since the
employee's account had only access to a web proxy, and CONNECT requests
were only allowed to port 443, but he said ok anyway (in his place, I
wouldn't; but then again, what do I know? ;).

After a call to a colleague in order to redirect connections to port 443
(from the client's network) of an underused computer at my site to port
22, I set up putty to connect through their web proxy, but that didn't
work (since no authentication was given as requested).

Then it was that I downloaded python, installed it in the employee's
documents folder, and created a 'sniffer' between the web browser and
web proxy to find out the authentication headers.  After testing them by
hand, I wrote a script to pretend it's the web browser requesting a
CONNECT from the web proxy, and putty would connect to my script which
would just pass data back and forth.  It didn't work.

I quickly found out that their web proxy did NOT let anything come and
go, unless its client had sent at least 4 octets (and that was also a
security measure they had taken which I was not told about-- they wanted
only protocols where the client talks first, ie (pun intended) typically
HTTP).  So putty was waiting for the ssh server to announce its version
before announcing itself, but the announcement of the server would not
come through until putty sent something.

So I changed the middle-server [midsrv]: as soon as putty connected to
the listening port of midsrv, it opened the connection to the web proxy,
and instantly sent the putty announcement to the ssh server, consuming
it when putty sent it normally, and happily moving octets around for the
rest of the connection.  From my laptop, I could get my emails with
plain POP3.

That was in 34 minutes time (debugging time included).

When the network guy dropped by a couple of hours later to ask me if I
needed any help, I just thanked him for letting me connect.  He
scratched his head, tried to understand what happened (didn't realise
that the python app was important even though he absent-mindedly passed
over it checking running tasks), so I let him think over it for several
minutes before explaining to him what I did.  He was most impressed with
the python program when I showed it to him, gave a warning to the
employee: ok, run his program, but don't let him touch your computer
again!, and then came to the following conclusion (much similar to a
Python motto):

If Python can do this, it {Python} should be forbidden...


PS Unfortunately, I could not charge security consulting fees.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Design Question. Data Acquisition/Display related.

2005-05-17 Thread Alex Verstraeten
StepH wrote:

1./ Is each display must responsible to acquire/read the data ?
2./ Or an engine collect the data then send them to each display ?

  

I'd keep it simple:

- DataCollector class
asociated with one or more display instances (implemented as a list of 
display subscribers)
it collects data from a source and notifies each subscribed display that 
new data is available.
could something like a 'collect' method which performs:

for display in self.subscribed_displays:
   display.update( data )


- Display class
just a simple display class with an update method
it should be able to receive new data
and display new data
(those 2 actions could be implemented in different methods, you might 
not want to display everytime new data is available... maybe you might 
want to consolidate data in some way and output it at some high interval)

Also, how to anim this ?

1./ Via a timer ?
2./ Via a simple loop (read/update display/pause/read user key)
  


a simple loop could do it
  - handle user events
  - collect data
  - update displays
  - sleep


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


Re: best way to do this ...

2005-05-17 Thread Thomas Guettler
Am Tue, 17 May 2005 05:26:15 -0700 schrieb Tonino:

 Hi ALL,
 
 I am having a issue with a particular storage of data problem and
 wanted to know if I am going about it the wrong way.
 
 I have a list of reference numbers associated with a product and I have
 a socket that listens on a port.  Now what happens is the client app
 connects to the server - sends the product and the associated ref
 numbers (there are a few per product). I need to be able to store these
 in a data  structure so that when the same product is called again  -
 it can display the ref numbers for that product.

The smallest database is the filesystem. Create a directory for every
product. Store the references in a file in this directory.

 
 for a in Detail:
 RuntimeError: dictionary changed size during iteration

I did not see any dict in your code, but this message means, that you
can't change the dictionary in the loop. Maybe this helps:

for a, b in list(mydict.items()):



 Thomas

-- 
Thomas Güttler, http://www.thomas-guettler.de/


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


Re: best way to do this ...

2005-05-17 Thread Tonino
hmm - but I want to store the data in memory eather than a filesystem
... it is not an issue if the program terminates - it is almost needed
while running and does not need to remember where it is ..

the dirctionary is detail = {}

will try the list() function - thanks

Tonino

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


Re: Windows distribution suggestions?

2005-05-17 Thread dave . brueck
 One tip: make sure your three top-level scripts are as empty as
 possible: just import some other module and call a function. All
 your active code is then in some library.zip shared between the
 three, and you need never change alice.exe, bob.exe, and carol.exe

 I think I understand what you're saying and it sounds like a very
 good idea.  Thanks.

To elaborate, this approach has worked well for me when I've needed to
release multiple .exe's together:

First make a dispatching module like this (call it run.py)

if __name__ == '__main__':
  app = sys.argv[0].lower()
  if app.find('alice') != -1:
import alice
alice.main()
  elif app.find('bob') != -1:
import bob
bob.main()
  etc...

Next, use py2exe to create an executable for run.py, and then copy
run.exe to alice.exe, bob.exe, and carol.exe (the resulting .exe's will
be very small). The reasoning behind this is that this way only one
copy of all the DLLs, Python std library, and so forth need to be
included in your release.

And to second everyone else's suggestions: NSIS and InnoSetup are
great, free, and powerful. They have all the features you need to
automatically copy your files to the proper location on disk, create
desktop icons, and create an uninstaller entry - you'll just write a
small installation script telling what features you'd like to take
advantage of, but they figure out all the details and combine your
application files into a standalone installer (your app.exe).

It'll take a little work to get this all straightened out the first
time, but after that you can have a single build/release script so it's
painless from then on.

And for updates: the least problematic approach is to just release the
whole thing each time. IIRC, InnoSetup (and probably NSIS) include a
feature where you can detect if your app is running when the user tries
to install an update and you can prompt the user to shut down first.
You'd need to use ctypes or pywin32 to make your app detectable that
way, but it's only 1 or 2 lines of code. But, lemme know if you want to
go the route of updating only portions of the app - I've gone that
route too but it takes more work and has its own set of problems; I
might be able to save you a few headaches.

-Dave

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


Re: Design Question. Data Acquisition/Display related.

2005-05-17 Thread StepH
Alex Verstraeten a écrit :

 StepH wrote:

 1./ Is each display must responsible to acquire/read the data ?
 2./ Or an engine collect the data then send them to each display ?

  

 I'd keep it simple:

 - DataCollector class
 asociated with one or more display instances (implemented as a list of 
 display subscribers)
 it collects data from a source and notifies each subscribed display 
 that new data is available.
 could something like a 'collect' method which performs:

 for display in self.subscribed_displays:
   display.update( data )


 - Display class
 just a simple display class with an update method
 it should be able to receive new data
 and display new data
 (those 2 actions could be implemented in different methods, you might 
 not want to display everytime new data is available... maybe you might 
 want to consolidate data in some way and output it at some high interval)

Ok, it was my first idea too...


 Also, how to anim this ?

 1./ Via a timer ?
 2./ Via a simple loop (read/update display/pause/read user key)
  


 a simple loop could do it
  - handle user events
  - collect data
  - update displays
  - sleep



Here i've a prob. (due to the fact that I start both with Python  
TkInter).  In TkInter, you run your app by launching a mainloop() 
routine, right ?  So, how, in my forever loop (handle user events / 
Collect data / Update Display / Sleep) handle the user data ?

Sure, i can (i suppose), log user activity (via the event send by the Tk 
underlayer), the poll theses event in my for ever loop ?  But in this 
case, are these event will be correctly generated (by Tk) ?  How to 
give the hand to Tk in such scenario ?

Thanks for your help.

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


Re: Python on a public library computer

2005-05-17 Thread Anton Vredegoor
Christos TZOTZIOY Georgiou wrote:

 I am not sure I will help you (uncertainty based on the part I
snipped),
 but the part so far can be easilly solved if you install Python for
 single user inside the Documents and settings\username folder (or
 whatever it is called).  I did in a similar case.

.msi is blocked by the appguard. I knew that because I tried it a week
ago, but just to be sure I tried again.

 End of reply here; and now for some completely minor python success
 story.

[snip story]


Thanks, that was a nice story! However I still think ... But you know
what I think by now don't you :-)

Anton

'[EMAIL PROTECTED] import NNTP  '

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


Sorting x lists based on one list

2005-05-17 Thread Philippe C. Martin
Hi,

I'm looking for an easy algorithm - maybe Python can help:

I start with X lists which intial sort is based on list #1.

I want to reverse sort list #1 and have all other lists sorted accordingly.

Any idea is welcome.

Regards,

Philippe

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


Re: Image.putpalette(Colors)?

2005-05-17 Thread Fredrik Lundh
Oliver Albrecht wrote:

 Has somebody a example-script how i can put a other palette to a image?

here's one of the first google hits for PIL putpalette:

http://effbot.org/zone/pil-pseudocolor.htm

 (after this the image should have similar outlook)

similar to what?

/F 



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


Re: Sorting x lists based on one list ... maybe an example would make sense:

2005-05-17 Thread Philippe C. Martin
l1 = ['a','b','c']
l2 = ['toto','titi','tata'] # 'toto' refers to 'a', 'titi' to b' 
l3 = ['foo','bar','doe'] # 'foo' refers to 'a' 

I want to reverse sort l1 and have l2 and l3 follow accordingly.

Regards,

Philippe






Philippe C. Martin wrote:

 Hi,
 
 I'm looking for an easy algorithm - maybe Python can help:
 
 I start with X lists which intial sort is based on list #1.
 
 I want to reverse sort list #1 and have all other lists sorted
 accordingly.
 
 Any idea is welcome.
 
 Regards,
 
 Philippe

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


Re: \r functionality

2005-05-17 Thread Fredrik Lundh
Jake [EMAIL PROTECTED] wrote:

 in c and c++ there is a useful way to refresh an output line in printf
 and cout using \r meta command.

that's a control character that's printed to the terminal by printf/cout,
not a C or C++ meta command

to print the same character in Python, use the same character escape:

print \r, count,

(note that if this works or not depends on the terminal you're sending the
output to.  most ordinary terminals handle it just fine, but if you're sending
output to an IDE console window, it may not work as expected)

/F 



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


Re: Python RPM and CentOS

2005-05-17 Thread Ken Godee
The reasonable thing would be to use yum.


 Not really a Python question, but I thought some on this list may be 
 able to answer so here goes:
 
 I have several machines on which I must install CentOS. There are many 
 updates to CentOS and it's very time consuming to do the updates over 
 the network. I have a local copy of all of the updated rpms. Would it be 
 reasonable to do something like this to upgrade them locally and more 
 quickly than over the network???
 
 updated_rpms = [list of updated rpms]
 
 for f in updated_rpms:
 
  try:
  os.popen(/bin/rpm --nodeps -U %s %f)
 
  except Exception, e:
  print e
 
 
 Thanks,
 
 rbt

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


Re: Bug in Elementtree/Expat

2005-05-17 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 I use Elementtree to parse an elementary SVG file (in fact, it is one
 of the examples in the SVG essentials book). More precisely, it is
 the fig0201.svg file in the second chapter.
 The contents of the file are as follows (i hope it will be rendered
 correctly):
 !DOCTYPE svg PUBLIC -//W3C//DTD SVG 1.0//EN
http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd;
 svg width=200 height=200
 titleDefault User Coordinates/title
 descShows a rectangle on a grid in default user coordinates/desc
 image xlink:href=default_ruler.svg x=0 y=0 width=200
 height=200/
 g transform=translate(40,40)
 rect x=10 y=10 width=50 height=30style=stroke: black; fill:
 none;/
 /g
 /svg


 xml.parsers.expat.ExpatError: unbound prefix: line 6, column 1

 The problem seems to lie with the xlink:href tag. If i remove the xlink
 namespace, it then does not produce a traceback.

so where in that file do you see an xlink declaration?

(elementtree doesn't fetch external DTD:s, so putting in the DTD file
doesn't really help).

adding

xmlns:xlink=http://www.w3.org/1999/xlink;

to the svg element should make the problem go away.

/F 



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


Re: Sorting x lists based on one list ... maybe an example would make sense:

2005-05-17 Thread Peter Otten
 Philippe C. Martin wrote:
 
 I'm looking for an easy algorithm - maybe Python can help:
 I start with X lists which intial sort is based on list #1.
 I want to reverse sort list #1 and have all other lists sorted
 accordingly.

One way, using a helper list with indices:

 l1 = ['a','b','c']
 l2 = ['toto','titi','tata'] # 'toto' refers to 'a', 'titi' to b' 
 l3 = ['foo','bar','doe'] # 'foo' refers to 'a' 
 indices = sorted(range(len(l1)), key=l1.__getitem__, reverse=True)
 for items in l1, l2, l3:
... items[:] = [items[i] for i in indices]
...
 l1
['c', 'b', 'a']
 l2
['tata', 'titi', 'toto']
 l3
['doe', 'bar', 'foo']

Another way would be to merge the three lists into one of 3-tuples, sort,
and unmerge, similarly to the DSU pattern -- which raises the question: why
are you using three lists in the first place?

Peter


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


Re: Sorting x lists based on one list ... maybe an example would make sense:

2005-05-17 Thread Philippe C. Martin
 Another way would be to merge the three lists into one of 3-tuples, sort,
 and unmerge, similarly to the DSU pattern -- which raises the question:
 why are you using three lists in the first place?

:-) Thanks, the lists will evolve and are also stored in 'csv' format in
external files at one point. I cannot use dictionaries because I need to
control the sorting (hash).

In this specific case, list 1 represents students with their information,
list 2 represents assignments with information such as weight, term, max
grade ... and list 3 the actual grades.

Regards,

Philippe



Peter Otten wrote:

 Philippe C. Martin wrote:
 
 I'm looking for an easy algorithm - maybe Python can help:
 I start with X lists which intial sort is based on list #1.
 I want to reverse sort list #1 and have all other lists sorted
 accordingly.
 
 One way, using a helper list with indices:
 
 l1 = ['a','b','c']
 l2 = ['toto','titi','tata'] # 'toto' refers to 'a', 'titi' to b' 
 l3 = ['foo','bar','doe'] # 'foo' refers to 'a' 
 indices = sorted(range(len(l1)), key=l1.__getitem__, reverse=True)
 for items in l1, l2, l3:
 ... items[:] = [items[i] for i in indices]
 ...
 l1
 ['c', 'b', 'a']
 l2
 ['tata', 'titi', 'toto']
 l3
 ['doe', 'bar', 'foo']
 
 Another way would be to merge the three lists into one of 3-tuples, sort,
 and unmerge, similarly to the DSU pattern -- which raises the question:
 why are you using three lists in the first place?
 
 Peter

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


Re: Windows distribution suggestions?

2005-05-17 Thread Serge Orlov

Timothy Smith wrote:
 Ivan Voras wrote:

 Paul Rubin wrote:
 
 
 
 your active code is then in some library.zip shared between the
 three, and you need never change alice.exe, bob.exe, and carol.exe
 
 
 I think I understand what you're saying and it sounds like a very
 good idea.  Thanks.
 
 
 
 One thing about updating files - sorry if I'm stating general and
 universal knowledge, but beware that on Windows you can't delete
and/or
 replace a file if it's opened by any process.
 
 
 hence i found you must do this immediately after updating

 sys.path_importer_cache.clear()
 zipimport._zip_directory_cache.clear()

 then unload your app

I don't think it's a good idea to update files of a running
application. It's better to copy the current version into
another directory and after successful update switch over
to the new version.

Dirs during update:
c:\program files\mysoftware\current
c:\program files\mysoftware\latest

post update
c:\program files\mysoftware\previous
c:\program files\mysoftware\current

The advantage of the approach of keeping the previous version
is that your customers can always switch back to the previous
version even if the network is not available or your update
server is down. It's like an undo button. If the users know that
they can easily downgrade, they will more willing to upgrade.

  Serge.

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


Re: Windows distribution suggestions?

2005-05-17 Thread rbt
Bernhard Holzmayer wrote:
 Paul Rubin wrote:
 
 
As what must be penance for something or other, I'm needing to release
a Python app for use under Windows XP.  Please be gentle with me since
I'm a Un*x weenie and the only thing I've had much practice with under
Windows is rebooting it.
 
 
 I can feel your unhappiness, and I share it. Hi Paul!
 Here are some hints...
 
 
My app contains three different programs (say alice.py, bob.py, and
carol.py) that need to be independently launchable, and a dozen or so
other .py files that get imported into those first three.  What I'd
really really like is to make a single installer called (say)
app.exe.  Launching app.exe should completely install Python, unpack
all the necessary modules, and make three icons (alice, bob, carol) on
the desktop.
 
 
 Since your installer needs to run before Python is installed, you need
 something else. Go to http://www.wisesolutions.com

Or, you could use a simple bat script... that's what I do.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows distribution suggestions?

2005-05-17 Thread Grant Edwards
On 2005-05-17, Paul Rubin http wrote:

 As what must be penance for something or other, I'm needing to release
 a Python app for use under Windows XP. 

I'm a Unix guy who occasionally ships a Python app for Win32,
and I always recommend py2exe and inno setup:

  py2exe   http://starship.python.net/crew/theller/py2exe/
  inno setup   http://www.jrsoftware.org/isinfo.php

Inno setup is as good as any other installer, and it's free.
  
-- 
Grant Edwards   grante Yow!  Did I SELL OUT yet??
  at   
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Design Question. Data Acquisition/Display related.

2005-05-17 Thread Alex Verstraeten
StepH wrote:

a simple loop could do it
 - handle user events
 - collect data
 - update displays
 - sleep


Here i've a prob. (due to the fact that I start both with Python  
TkInter).  In TkInter, you run your app by launching a mainloop() 
routine, right ?  So, how, in my forever loop (handle user events / 
Collect data / Update Display / Sleep) handle the user data ?

Sure, i can (i suppose), log user activity (via the event send by the Tk 
underlayer), the poll theses event in my for ever loop ?  But in this 
case, are these event will be correctly generated (by Tk) ?  How to 
give the hand to Tk in such scenario ?

Thanks for your help.

StepH.
  

oops, sorry, I was thinking of a 'pygame' kind of loop, where you have 
control over it.
I dont have experience on Tk, I allways use wxPython or pygame for gui's.

you can forget about the loop I mentioned... it doesn't apply to 
event-driven applications where you have no control over the loop.
you'd be using a timer that triggers a tick method at a certain 
interval, in that tick method you could tell your data collectors to 
collect data... then the data collectors would trigger all its 
subscribed displays's update function, so they draw the new available 
data, just like the for display in self.subscribed_displays: 
display.update(data).

so it comes to something like this:

tk mainloop is set to call tick() every 100ms through a timer.
tick() will iterate through all data collectors and call their collect 
method
each data collector will then collect data  and iterate through all 
asociated displays calling their respective 'update' method on each.

of course there are plenty of ways to design an app, this is just an idea.

hope it helps,
Alex











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


Re: Bug in Elementtree/Expat

2005-05-17 Thread alainpoint

Fredrik Lundh wrote:

 adding

 xmlns:xlink=http://www.w3.org/1999/xlink;

 to the svg element should make the problem go away.


Thanks for the tip. It indeed solves the problem.
Most examples in the book do not include such a declaration and yet are
properly rendered by Internet Explorer.
Is it mandatory and why is it that Expat crashes on it?

Alain

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


Reading image dimensions with PIL

2005-05-17 Thread Will McGugan
Hi,

I'm writing an app that downloads images. It rejects images that are 
under a certain size - whithout downloading them completely. I've 
implemented this using PIL, by downloading the first K and trying to 
create a PIL image with it. PIL raises an exception because the file is 
incomplete, but the image object is initialised with the image 
dimensions, which is what I need. It actualy works well enough, but I'm 
concerened about side-effects - since it seems an unconventional way of 
working with PIL. Can anyone see any problems with doing this? Or a 
better method?


Thanks,

Will McGugan


-- 
http://www.willmcgugan.com
.join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c 
in jvyy*jvyyzpthtna^pbz ] )
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python forum

2005-05-17 Thread Grant Edwards
On 2005-05-17, Jonas Melian [EMAIL PROTECTED] wrote:

 I'm going to say a suggestion, why don't you create a forum
 like the one of Ruby (http://www.rubyforums.com/)? for the
 novices this is a great help, better than a mail list

Says you.  I prever a newsgroup.  Mailing lists are in second
place and web forums a very distant third.  I really don't see
how pointing Mozilla or Thunderbird at a newsgroup isn't any
harder than pointing it at a web forum.

 I know that you have python-list, it's both an email and a usenet list.

And both are far better than web forums.

 But I think that a forum is great for the learning. The test
 is in gentoo's forums. They are a lot of experienced people
 answering questions without any problem and it goes very well

Except for the torture of using a web forum's UI.

[In case you can't tell, I hate web forums.  I've never seen a
single one with a suable UI.]

-- 
Grant Edwards   grante Yow!  .. My vaseline is
  at   RUNNING...
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem listing services with wmi

2005-05-17 Thread Jean-Sébastien Guay
Hello Tim, thanks for replying,

For your
information, what the code is doing behind the scenes is the following:

code

import win32com.client

c = win32com.client.GetObject (
  
 winmgmts:{impersonationLevel=Impersonate,authenticationLevel=Default}/root/cimv2
)
for service in c.ExecQuery (SELECT * FROM Win32_Service):
  if service.Properties_ (State).Value == Stopped:
print service.Properties_ (Caption).Value
print service.Properties_ (State).Value

/code
  


Running this code seems to go through the 87 first services in the list 
returned by ExecQuery, then stops with the following error :

Traceback (most recent call last):
  File stdin, line 1, in ?
  File G:\Python-2.4\Lib\site-packages\win32com\client\util.py, line 
83, in next
return _get_good_object_(self._iter_.next())
pywintypes.com_error: (-2147217398, 'OLE error 0x8004100a', None, None)

Could there be such a thing as a null pointer in the list at position 
88? Or is that not possible in Python? Would the iterator just stop at a 
null value? As I said, I'm pretty new to Python so I'm just throwing 
around ideas here.

code

set wmi = GetObject (winmgmts:{impersonationLevel=impersonate})
set ServiceSet = wmi.InstancesOf (Win32_Service)
for each Service in ServiceSet
   WScript.Echo Service.Description
Next

/code
  


This gives me the first 87 services as well, and then stops with this 
message :

C:\Documents and Settings\guayj\Desktop\bob.vbs(7, 1) (null): 0x8004100A

So it would seem that the 3 methods give the same result. As to which 
service it has gotten to when it gets to position 88 in the list, 
obviously I can't find out with a script, and it seems that the list 
isn't in any order I can see, so I couldn't even venture a guess... I'll 
try looking if there's a service in my list that isn't valid (points to 
an uninstalled program for example) or something like that... But if you 
have other ideas please let me know.

PS I realise that by now you've probably moved on from
this approach, but if you did manage to pin down a problem
we could address, I'd be very glad to address it.
  


Not at all, this is a small project I'm using to try and learn Python... 
I'm currently on summer break before I start my Masters, so I have the 
luxury of keeping this on the back burner until I find a fix... Thanks 
for your help!

J-S

-- 
___
Jean-Sébastien Guay   [EMAIL PROTECTED]
 http://whitestar02.webhop.org/

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


Re: Sorting x lists based on one list ... maybe an example would make sense:

2005-05-17 Thread Philippe C. Martin
I will look at that merge/unmerge thing


Peter Otten wrote:

 Philippe C. Martin wrote:
 
 I'm looking for an easy algorithm - maybe Python can help:
 I start with X lists which intial sort is based on list #1.
 I want to reverse sort list #1 and have all other lists sorted
 accordingly.
 
 One way, using a helper list with indices:
 
 l1 = ['a','b','c']
 l2 = ['toto','titi','tata'] # 'toto' refers to 'a', 'titi' to b' 
 l3 = ['foo','bar','doe'] # 'foo' refers to 'a' 
 indices = sorted(range(len(l1)), key=l1.__getitem__, reverse=True)
 for items in l1, l2, l3:
 ... items[:] = [items[i] for i in indices]
 ...
 l1
 ['c', 'b', 'a']
 l2
 ['tata', 'titi', 'toto']
 l3
 ['doe', 'bar', 'foo']
 
 Another way would be to merge the three lists into one of 3-tuples, sort,
 and unmerge, similarly to the DSU pattern -- which raises the question:
 why are you using three lists in the first place?
 
 Peter

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


Re: Reading image dimensions with PIL

2005-05-17 Thread Dave Brueck
Will McGugan wrote:
 I'm writing an app that downloads images. It rejects images that are 
 under a certain size - whithout downloading them completely. I've 
 implemented this using PIL, by downloading the first K and trying to 
 create a PIL image with it. PIL raises an exception because the file is 
 incomplete, but the image object is initialised with the image 
 dimensions, which is what I need. It actualy works well enough, but I'm 
 concerened about side-effects - since it seems an unconventional way of 
 working with PIL. Can anyone see any problems with doing this? Or a 
 better method?

If you're tossing images that are too _small_, is there any benefit to not 
downloading the whole image, checking it, and then throwing it away?

Checking just the first 1K probably won't save you too much time unless you're 
over a modem. Are you using a byte-range HTTP request to pull down the images 
or 
just a normal GET (via e.g. urllib)? If you're not using a byte-range request, 
then all of the data is already on its way so maybe you could go ahead and get 
it all.

But hey, if your current approach works... :) It _is_ a bit unconventional, so 
to reduce the risk you could test it on a decent mix of image types (normal 
JPEG, progressive JPEG, normal  progressive GIF, png, etc.) - just to make 
sure 
  PIL is able to handle partial data for all different types you might 
encounter.

Also, if PIL can't handle the partial data, can you reliably detect that 
scenario? If so, you could detect that case and use the 
download-it-all-and-check approach as a failsafe.

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


Re: Python forum

2005-05-17 Thread Dave Brueck
Grant Edwards wrote:
 On 2005-05-17, Jonas Melian [EMAIL PROTECTED] wrote:
I'm going to say a suggestion, why don't you create a forum
like the one of Ruby (http://www.rubyforums.com/)? for the
novices this is a great help, better than a mail list
[snip]
But I think that a forum is great for the learning. The test
is in gentoo's forums. They are a lot of experienced people
answering questions without any problem and it goes very well
 
 
 Except for the torture of using a web forum's UI.
 
 [In case you can't tell, I hate web forums.  I've never seen a
 single one with a suable UI.]

Amen! Generally they are an abomination.

To make matters worse, many forums that become popular are saddled with so many 
advertisements that moving from one message to another becomes a... grueling... 
lesson... in... patience.

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


processing a Very Large file

2005-05-17 Thread DJTB
Hi,

I'm trying to manually parse a dataset stored in a file. The data should be
converted into Python objects.

Here is an example of a single line of a (small) dataset:

3 13 17 19 -626177023 -1688330994 -834622062 -409108332 297174549 955187488
589884464 -1547848504 857311165 585616830 -749910209 194940864 -1102778558
-1282985276 -1220931512 792256075 -340699912 1496177106 1760327384
-1068195107 95705193 1286147818 -416474772 745439854 1932457456 -1266423822
-1150051085 1359928308 129778935 1235905400 532121853

The first integer specifies the length of a tuple object. In this case, the
tuple has three element: (13, 17, 19)
The other values (-626177023 to 532121853) are elements of a Set.

I use the following code to process a file:


from time import time
from sets import Set
from string import split
file = 'pathtable_ht.dat'
result = []
start_time = time ()
f=open(file,'r')
for line in f:
splitres = line.split()
tuple_size = int(splitres[0])+1
path_tuple = tuple(splitres[1:tuple_size])
conflicts = Set(map(int,splitres[tuple_size:-1]))
# do something with 'path_tuple' and 'conflicts'
# ... do some processing ...
result.append(( path_tuple, conflicts))

f.close()
print time() - start_time


The elements (integer objects) in these Sets are being shared between the
sets, in fact, there are as many distinct element as there are lines in the
file (eg 1000 lines - 1000 distinct set elements). AFAIK, the elements are
stored only once and each Set contains a pointer to the actual object

This works fine with relatively small datasets, but it doesn't work at all
with large datasets (4500 lines, 45000 chars per line).

After a few seconds of loading, all main memory is consumed by the Python
process and the computer starts swapping. After a few more seconds, CPU
usage drops from 99% to 1% and all swap memory is consumed:

Mem:386540k total,   380848k used, 4692k free,  796k buffers
Swap:   562232k total,   562232k used,0k free,27416k cached

At this point, my computer becomes unusable.

I'd like to know if I should buy some more memory (a few GB?) or if it is
possible to make my code more memory efficient.

Thanks in advance,
Stan.
-- 
http://mail.python.org/mailman/listinfo/python-list


Type question

2005-05-17 Thread nitrogenycs
Hello,

is this call assumed to be True in any case?

result = type(SomeClass) is SomeClass

I've written a proxy class which shadows a real object. If you call
type(proxyobj) it returns the type of the proxyobject and not the type
of the shadowed object. Example:

p = proxy(shadowobj())
result1 = type(p) is shadowobj # will return False
result2 = isinstance(p, shadowobj)   # will return True

So the first call compares the id()s of both types, while the second
calll seems to work different.
I've tried to use a proxy metaclass that creates new objects with the
name 'shadowobj'. So

print type(p)
print type(shadowobj())

will look exactly the same. however their id()s compare different and
that's why the 1st test doesn't work as I'd expect it to work.
Can somebody tell me why the id()s compare different for the same type
names? Here's the metaclass:

class ProxyMeta(type):
def __new__(self, classname, bases, classdict):
return type.__new__(self, 'shadowobj', bases, classdict)

class Proxy(object):
__metaclass__ = ProxyMeta

Why is (type(Proxy) is shadowobj == False)? Shouldn't type.__new__
reuse the existing shadowobj type and increase its refcount instead of
creating a new instance of it? Then the id()s would compare the same.
So, finally, is checking for types with 'is' as shown above just wrong
and one should use isinstance or is my proxy class showing bad
behaviour or is this a bug in type.__new__?

-Matthias

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


Re: Quick Reference from module doc strings.

2005-05-17 Thread Ron Adam
Michele Simionato wrote:
Do you have any feature suggestions, additional information that
 
 could
 
go in, something that would extend the content in some way and make
 
 it
 
more useful?
 
 
 I have written something similar which I use all the time. It generates
 ReST
 output which I can browse with less from the command line, as well as
 HTML
 output and PDF output that I can print. The hard work is done by
 docutils, of course.
 I have options to specify if I want to least private names or not, and
 to specify
 if I want an analytical index to be generated or not. Also, the HTML
 output
 contains hyperlinks to the original source code, so I can see  it with
 a click.
 I can feed to minidoc whole packages (it works recursively on
 subpackages, so everything is documented).
 
 It was unvaluable in my struggle with Zope.
 
 Michele Simionato
 

Hi Michele,

Sound great!  Adding a command line parser, I'm going to add a brief 
command line parser to it today, but nothing as elaborate as you have 
already.  Could you post a part of the output as an example?  How is the 
index built?

The direction I'm going is to build a database/dictionary with each 
individual item as a record. Maybe feed it the whole lib directory, then 
to be able to generate cross module/package lists by subject or keyword. 
  I'm not exactly sure how to connect everything together yet.  This is 
a figure it out as I go project, but I think it's worth trying.

Cheers,
_Ron





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


RE: Problem listing services with wmi

2005-05-17 Thread Tim Golden
[... snip results ...]

| So it would seem that the 3 methods give the same result. As to which 
| service it has gotten to when it gets to position 88 in the list, 
| obviously I can't find out with a script, and it seems that the list 
| isn't in any order I can see, so I couldn't even venture a 
| guess... I'll 
| try looking if there's a service in my list that isn't valid 
| (points to 
| an uninstalled program for example) or something like that... 
| But if you 
| have other ideas please let me know.

Well I honestly don't know if this will go any further,
but the following code uses the win32service module from
pywin32 to collect the service information, on the off-chance
that it *won't* fail where WMI does. I can't easily test it
since the script doesn't raise an error on my machine.

At the end, it tries to print out the differences between
the win32-collected info and the wmi-collected info.

code

#
# Not sure if you're running 2.3/2.4
#
try:
  set
except NameError:
  from sets import Set as set

##
## Taken from a post to c.l.py by William J. Rice
##
import win32service
import win32con

accessSCM = win32con.GENERIC_READ
hscm = win32service.OpenSCManager (None, None, accessSCM)

win32_names = set ()

for service_info in win32service.EnumServicesStatus(hscm):
  win32_names.add (service_info[1])

import win32com.client

c = win32com.client.GetObject (
  
winmgmts:{impersonationLevel=Impersonate,authenticationLevel=Default}/root/cimv2
)

wmi_names = set ()
for service in c.ExecQuery (SELECT * FROM Win32_Service):
  try:
short_name = service.Properties_ (Caption).Value
  except:
pass
  else:
wmi_names.add (short_name)

print only in win32:, , .join (win32_names - wmi_names)
print

print only in wmi:, , .join (wmi_names - win32_names)
print

/code

Let me know if anything shows up.

TJG


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

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


Re: Unique Elements in a List

2005-05-17 Thread Nyet Ya Koshka
 One reasonable solution might be as follows:

   def unique_elts(seq):
 elts = {}
 for pos, elt in enumerate(seq):
   elts.setdefault(elt, []).append(pos)

 return [ (x, p[0]) for (x, p) in elts.iteritems()
  if len(p) == 1 ]


Minor tweak to conserve space:

def bachelor_filter(iter_over_hashables):
   B={}
   for index, elem in enumerate(iter_over_hashables):
  if B.setdefault(elem, index) != index:
 B[elem]=None
   return [pair for pair in B.items() if pair[1] is not None]

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


Re: processing a Very Large file

2005-05-17 Thread Tim Peters
[DJTB]
 I'm trying to manually parse a dataset stored in a file. The data should be
 converted into Python objects.

 Here is an example of a single line of a (small) dataset:
 
 3 13 17 19 -626177023 -1688330994 -834622062 -409108332 297174549 955187488 
 589884464 -1547848504 857311165 585616830 -749910209 194940864 -1102778558 
 -1282985276 -1220931512 792256075 -340699912 1496177106 1760327384 
 -1068195107 95705193 1286147818 -416474772 745439854 1932457456 -1266423822 
 -1150051085 1359928308 129778935 1235905400 532121853
 
 The first integer specifies the length of a tuple object. In this case, the
 tuple has three element: (13, 17, 19)
 The other values (-626177023 to 532121853) are elements of a Set.

 I use the following code to process a file:
 
 from time import time
 from sets import Set
 from string import split

Note that you don't use string.split later.

 file = 'pathtable_ht.dat'
 result = []
 start_time = time ()
 f=open(file,'r')
 for line in f:
splitres = line.split()

Since they're all integers, may as well:

splitres = map(int, line.split())

here and skip repeated int() calls later.

tuple_size = int(splitres[0])+1
path_tuple = tuple(splitres[1:tuple_size])
conflicts = Set(map(int,splitres[tuple_size:-1]))

Do you really mean to throw away the last value on the line?  That is,
why is the slice here [tuple_size:-1] rather than [tuple_size:]?

# do something with 'path_tuple' and 'conflicts'
# ... do some processing ...
result.append(( path_tuple, conflicts))

 f.close()
 print time() - start_time
 
 The elements (integer objects) in these Sets are being shared between the
 sets, in fact, there are as many distinct element as there are lines in the
 file (eg 1000 lines - 1000 distinct set elements). AFAIK, the elements are
 stored only once and each Set contains a pointer to the actual object

Only small integers are stored uniquely; e.g., these aren't:

 100 * 100 is 100 * 100
False
 int(12345) is int(12345)
False

You could manually do something akin to Python's string interning to
store ints uniquely, like:

int_table = {}
def uniqueint(i):
return int_table.setdefault(i, i)

Then, e.g.,

 uniqueint(100 * 100) is uniqueint(100 * 100) 
True
 uniqueint(int(12345)) is uniqueint(int(12345))
True

Doing Set(map(uniqueint, etc)) would then feed truly shared int
(and/or long) objects to the Set constructor.

 This works fine with relatively small datasets, but it doesn't work at all
 with large datasets (4500 lines, 45000 chars per line).

Well, chars/line doesn't mean anything to us.  Knowing # of set
elements/line might help.  Say there are 4500 per line.  Then you've
got about 20 million integers.  That will consume at least several 100
MB if you don't work to share duplicates.  But if you do so work, it
should cut the memory burden by a factor of thousands.

 After a few seconds of loading, all main memory is consumed by the Python
 process and the computer starts swapping. After a few more seconds, CPU
 usage drops from 99% to 1% and all swap memory is consumed:

 Mem:386540k total,   380848k used, 4692k free,  796k buffers
 Swap:   562232k total,   562232k used,0k free,27416k cached

 At this point, my computer becomes unusable.

 I'd like to know if I should buy some more memory (a few GB?) or if it is
 possible to make my code more memory efficient.

See above for the latter.  If you have a 32-bit processor, you won't
be able to _address_ more than a few GB anyway.  Still, 384MB of RAM
is on the light side these days wink.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Type question

2005-05-17 Thread Serge Orlov
[EMAIL PROTECTED] wrote:
 Hello,

 is this call assumed to be True in any case?

 result = type(SomeClass) is SomeClass

 I've written a proxy class which shadows a real object. If you call
 type(proxyobj) it returns the type of the proxyobject and not the
type
 of the shadowed object. Example:

 p = proxy(shadowobj())
 result1 = type(p) is shadowobj # will return False
 result2 = isinstance(p, shadowobj)   # will return True

 So the first call compares the id()s of both types, while the second
 calll seems to work different.
 I've tried to use a proxy metaclass that creates new objects with the
 name 'shadowobj'. So

 print type(p)
 print type(shadowobj())

 will look exactly the same.

isinstance is not a law. It's just a convention. You don't
actually need to implement it. Consider PEP 246, I believe,
it is the right way to do what you want to do.
isinstance and metaclasses are not.

Instead of writing
if not isinstance(obj, class):
report error

ask your users to write
obj = adapt(obj, Interface)

instead of dispatch code like
if isinstance(obj, thisclass):
do this
elif isinstance(obj, thatclass):
do that
else:
report error

ask the users to write:
if kind(obj) is ThisKind:
do this
elif kind(obj) is ThatKind:
do that
else:
report error

where kind can be defined as
def kind(obj):
return getattr(obj, 'kind', None)

  Serge.

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


newbie running IDLE with command line arguments

2005-05-17 Thread crypto
Hi,

I am trying to use IDLE in order to test my program. My program is the
following:

import sys, socket
size = 1024
host, port, message = sys.argv[1], int(sys.argv[2]), sys.argv[3]
print host

How do I run this program on IDLE? I trying Run-Run Module but it
gives me:

Traceback (most recent call last):
  File C:\Python24\userprograms\simpleclient.py, line 5, in
-toplevel-
host, port, message = sys.argv[1], int(sys.argv[2]), sys.argv[3]
IndexError: list index out of range

How do I enter the command arguments?

Thanks,
C29

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


Re: Quick Reference from module doc strings.

2005-05-17 Thread Michele Simionato
Ron Adam:

 Sound great!  Adding a command line parser, I'm going to add a brief
 command line parser to it today, but nothing as elaborate as you have
 already.  Could you post a part of the output as an example?  How is
the
 index built?

For the command line parser, see
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278844

Here is an example of output:

http://www.phyast.pitt.edu/~micheles/python/ms.html

(it is a package called ms (as My Stuff) where I put my utilities).

The system works for module of the standard library too, but since
most of the time they do not have docstrings in reST format, there
are ugly formatting errors. But this is a bug of the standard library,
not of my tool ;)

For the index: minidoc associates a footnote number to every name,
and then
prints the names in alphabetical order. You can reach the documentation
for that name with a click.

   Michele Simionato

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


Re: Problem listing services with wmi

2005-05-17 Thread Jean-Sébastien Guay
Hi again Tim,

Well I honestly don't know if this will go any further,
but the following code uses the win32service module from
pywin32 to collect the service information, on the off-chance
that it *won't* fail where WMI does. I can't easily test it
since the script doesn't raise an error on my machine.
  


Seems like your hunch was right, the first loop completes correctly. 
Adding a counter to both loops shows that getting services from 
win32service.EnumServicesStatus() gets 108 services, and getting them 
through WMI gets to 87 and then halts with the previously mentioned error :

Traceback (most recent call last):
  File stdin, line 1, in ?
  File G:\Python-2.4\Lib\site-packages\win32com\client\util.py, line 
83, in next
return _get_good_object_(self._iter_.next())
pywintypes.com_error: (-2147217398, 'OLE error 0x8004100a', None, None)

 From examining your code I imagine you tried to catch the exception, 
but it didn't work because the exception is thrown on the for line and 
not when getting the service's Caption property... So it stopped at 87 
anyways. And indeed, the only in win32 list shows 21 entries ( 
len(win32_names - wmi_names) = 108-87 = 21 ).

[...snip code...]

# Not sure if you're running 2.3/2.4
  


Python 2.4 on Windows XP SP2 here.

Do you think we're getting anywhere with this? If not, then I'll just 
use the win32 method of getting the service list, even though it isn't 
as pretty. I don't want to waste your time on something that may have 
more to do with my machine than anything else... But if you want to try 
and get to the bottom of this, I have no problem with trying out other 
suggestions.

Thanks a lot, just by your small scripts I've already learned a lot more 
about Python!

J-S

-- 
___
Jean-Sébastien Guay   [EMAIL PROTECTED]
 http://whitestar02.webhop.org/

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


  1   2   >