Python Win32 Silent Install

2004-12-01 Thread Matt Gerrans
Looks like the installer for the Win32 extensions has changed from Wise to 
distutils, so now my automated silent installations don't work anymore. 
Anyone know if the distutils binary installer can be run silently?I 
haven't been able find a command line reference for distutils binaries (I'm 
still sifting through http://www.python.org/doc/current/dist/, though...).

Maybe there is a better way to do an unattended install of the Win32 
extensions (that is, perhaps without using the binary)?

Anyway, I'm looking into this on the python.org and starship pages, but I 
just thought I'd see if anyone can point me in the right direction...

- Matt 


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


Re: Python 3000 and "Python Regrets"

2004-12-01 Thread Matt Gerrans
Anyway, what's to worry about?When the time comes just whip out a little 
script that converts Python 1.6 (or whatever you like) to Python3K; it will 
only take seven lines of P3K code. 


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


Re: Converting String to Class

2004-12-01 Thread Matt Gerrans
You didn't specify exactly how the string is parsed, so this is a guess:

class Thingy(object):
   def __init__(self,rawinfo):
  self.StructId, vq,self.ProcessName = rawinfo.split()
  self.Version,self.QName = vq.split('.')
   def __str__(self):
  return '' % (self.StructId, self.Version, self.QName, self.ProcessName)

t = Thingy( "TMC2TEST.QUEUE LV1871.MQPROCESS" )
str(t) -> ''

- mfg 


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


Re: Python Win32 Silent Install

2004-12-01 Thread Matt Gerrans
That sounds easy enough, but I imagine the Acive State package requires some 
kind of licensing.I'm pre-installing on millions of consumer PCs. 


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


Re: Python Win32 Silent Install

2004-12-01 Thread Matt Gerrans
You guessed correctly.   Python is on HP (and Compaq now) PCs because I put 
it there.

And yes, I did get the "I've found Python on my computer, what does it do 
and can I remove it" from the support group.   How to answer that?You 
have a computer with Windows Script Host (JScript & VBScript) built in and 
you want to remove Python?I think the best answer is "it does all kinds 
of wonderful things!   You can remove it, of course (easy enough, it is in 
the "Add / Remove Programs" list, after all), but why don't you learn how to 
use it instead?(I even unhooked the file association to prevent Python 
file attachments in emails from giving a black eye to Python, so out of the 
box, it was relatively safe).

I've use Python and the Win32 extensions for much of the automation of the 
process that pre-installs all the software on the PCs.   Of course, Python 
is very versatile and is ideal for the wide range of tasks, large and small 
that are involved.Being that it is both powerful and easy to learn (and 
also because of no lack of evangelism (I hate that term, but don't have a 
better synonym) on my part), it has been adopted as the main language used 
by the whole division for build-automation related tasks.   Before Python, I 
wrote the tools in C++ and did scripting with JScript.   I don't think I 
have to tell anyone on this list how dramatic an increase in productivity 
Python can give over these in many areas (there are a still a few areas 
where the C++ tools reign, but Python also works well with those).

I was contacted by Kevin Altis and later Stephan Deibel about doing a Python 
success story about this and I was game.I did start it, but didn't get 
it finished in time for the Python Success Story book before OSCON 2004 in 
July and have since put it on the back burner.I need to take a little 
vacation from work, so I can finish that.

- Matt 


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


Re: installing 2.4

2004-12-03 Thread Matt Gerrans
"Peter Hansen" <[EMAIL PROTECTED]> wrote:
> Only pure Python code can run without change on a newer interpreter.

Is the interpreter smart enough to rebuild a pyc (if the corresponding py 
file is there of course) file that was built by a previous version?



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


Re: Calling a C program from a Python Script

2004-12-09 Thread Matt Gerrans
"Brad Tilley" <[EMAIL PROTECTED]> wrote:
>>>I'm dealing with a terabyte of files. Perhaps I should have mentioned 
>>>that.

I wouldn't automatically assume that recursing the directories with a Python 
script that calls a C program for each file is faster than doing the 
processing in Python.   For example, I found that using zlib.crc32() 
directly in Python was no slower than calling a C program that calculates 
CRCs of files.   (for huge files, it was important to find the right size 
buffer to use and not try to read the whole thing at once, of course -- but 
the C program had to do the same thing).However, if all the processing 
is done in Python code (instead of a C extension), there probably would be a 
big performance difference.It is just a question of whether the overhead 
of starting a separate process for each file is more time consuming than the 
difference between the Python and C implementations.

The pure Python implementation is probably easier to write, so you can do it 
that way and you're have something that works.  *Then* if the performance is 
not acceptable, try the other route.

Additionally, depending on how much directory crawling you are doing, you 
can just do the whole darned thing in C and save another minute or so.

Anyway, I didn't see the simple answer to your question in this thread (that 
doesn't mean it wasn't there).   I think you could do something like this:

for root, files, dirs in os.walk(path)
 for f in files:
 try:
 os.system( "cprog %s" % (os.path.join(root,f) )

I prefer naming like this, though:

for directory, filenames, subdirs in os.walk(startpath):
   for filename in filenames:
  ...

(particularly, since "root" will not be the root directory, except maybe 
once).

- Matt



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


Re: How can I change the timestamps of directories? (os.utime(), WinXP)

2004-12-09 Thread Matt Gerrans
Are you able change this directories attributes in a command shell or with 
explorer?If so, have you tried win32file.SetFileAttributes()? 


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


Zip with a list comprehension

2004-12-10 Thread Matt Gerrans
This is probably so easy that I'll be embarrassed by the answer.   While 
enhancing and refactoring some old code, I was just changing some map()s to 
list comprehensions, but I couldn't see any easy way to change a zip() to a 
list comprehension.Should I just let those sleeping dogs lie?   (list 
comprehensions seem more readable than map(), but if the list comprehension 
that does the equivalent of zip() is less expressive than zip(), I'll stick 
with zip()).

 


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


Re: Newbie question - default values of a function

2004-12-22 Thread Matt Gerrans
Actually i was not mutable.   Try this:

i = 1
id(i)
i += 1
id(i)

Change both of your sample functions to also print the id of the default 
variable and that might shed a little more light on the matter.

"i = i + 1" is only changing the local reference called i to refer to an 
instance of a different integer object.If you change the original 
function to something similar, it will behave similarly:

def f( a, L=[]):
   L = L + [a]
   return L

Because you are assigning the local reference variable L to a new list, 
instead of modifying that original default list that was created.

Is that more clear, or is it now more unclear?   ;) 


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