Re: File not read to end

2007-04-26 Thread andrew . jefferies
put "rb" as the mode of the open. > > Regards, > > -- > . Facundo > . > Blog:http://www.taniquetil.com.ar/plog/ > PyAr:http://www.python.org/ar/ I am running Windows (Vista). I tried the "rb" as you suggested but it didn't solve the problem. Thanks

Re: File not read to end

2007-04-26 Thread andrew . jefferies
le: > > lineCount +=1 > > print str(lineCount) + " -- " + line > > > I also stuck this same code bit into a test script and it was able to > > parse the entire log without problem. Very quirky. > > > This is my first foray from Perl to P

Re: File not read to end

2007-04-26 Thread andrew . jefferies
On Apr 26, 9:48 am, Facundo Batista <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I've attached the whole script. Thanks again for your help. > > > --Andrew > > Andrew, tip: > > If you attach the whole script, what you get is that a lot of p

Re: Getting some element from sets.Set

2007-05-07 Thread Andrew McLean
[EMAIL PROTECTED] wrote: > In the particular case, I have to read an attribute from any one of > the elements, which one doesn't matter because this attribute value is > same across all elements in the set. Someone else pointed out that there might be better data structures. If performance was no

Re: software testing articles

2007-05-11 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Have you ever been interested in software testing? Giving you an in > depth analysis/knowledge on software testing!! Looking around the site at random, I saw no "in depth analysis/knowledge" of anything. -- http://mail.python.org/

Extended characters in MATPLOTLIB (newbie)

2007-05-15 Thread Andrew Holme
I'm using MATPLOTLIB on Windows. How can I get extended characters such as the micro symbol (greek letter mu) to appear in my axis labels? I've tried: xlabel('µs', font) and xlabel('\xB5s', font) but it just appears as a box. TIA -- http://mail.python.org/mailman/listinfo/python-list

Re: Extended characters in MATPLOTLIB (newbie)

2007-05-15 Thread Andrew Holme
"Andrew Holme" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm using MATPLOTLIB on Windows. > > How can I get extended characters such as the micro symbol (greek letter > mu) to appear in my axis labels? > > I've tried: > > x

Re: Compiling python extension on amd64 for 32 bit

2007-05-25 Thread Andrew MacIntyre
s the Python your toolchain is referencing 32 or 64 bit? Based on what I can see in pyport.h, I'd guess that you're finding a 64 bit Python (ie SIZEOF_LONG == 8). -- ----- Andrew I MacIntyre "These th

Re: Compiling python extension on amd64 for 32 bit

2007-05-26 Thread Andrew MacIntyre
Mathias Waack wrote: > Andrew MacIntyre wrote: > >> Mathias Waack wrote: >>> After switching my development environment to 64 bit I've got a >>> problem with a python extension for a 32 bit application. >> {...} >> >>> Ok, thats fine. So

Python 2.5 and WXPython demo's

2007-05-30 Thread Andrew P
Hello, I am new (very) to Python and have just down loaded the latest version of Python (2.5) and WXPython (2.8). For some reason I cannot get the WXPython demo to run at all. I run windows XP and it can't find a program to run the demo. Any advice? (apologies if this has been posted before). --

Re: Python 2.5 and WXPython demo's

2007-05-30 Thread Andrew P
On May 30, 12:24 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Andrew P wrote: > > Hello, > > > I am new (very) to Python and have just down loaded the latest version > > of Python (2.5) and WXPython (2.8). > > > For some reason I cannot get the WXPython d

Split a string based on change of character

2007-07-28 Thread Andrew Savige
Python beginner here. For a string 'ABBBCC', I want to produce a list ['A', 'BBB', 'CC']. That is, break the string into pieces based on change of character. What's the best way to do this in Python? Using Python 2.5.1, I tried: import re s = re.split(r'(?<=(.))(?!\1)', 'ABBBCC') for e in s: pri

Re: Split a string based on change of character

2007-07-28 Thread Andrew Savige
--- "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Using itertools: > > import itertools > > s = 'ABBBCC' > print [''.join(grp) for key, grp in itertools.groupby(s)] Nice. > Using re: > > import re > > pat = re.compile(r'((\w)\2*)') > print [t[0] for t in re.findall(pat, s)] Also nice. Esp

Subprocess & ffmpeg

2007-08-16 Thread Andrew Bloomgarden
7;t work with ffmpeg. Does anyone know why this is happening? -- Andrew Bloomgarden -- http://mail.python.org/mailman/listinfo/python-list

Submit Your Python Scripts

2007-08-21 Thread andrew . sain
Hi, just wanted to invite any Python script authors to submit their Python script to our popular software site at http://www.myzips.com We have just today added a "Scripts" directory which includes a Python subdirectory http://www.myzips.com/category/Scripts/ The first submissions usually maintai

Re: question on python syntax

2007-09-10 Thread Andrew Robert
a.m. wrote: > If I type this in shell > > $ ./yourfile.py 12:34 PM & > > What does '$', '.', '/' and '& means in this succession? Note: 12:34 > PM is a argument to the yourfile.py. > This not python syntax but Unix shell. $ = shell prompt ./= look for the program in my

Error in random module, bad installation?

2007-09-12 Thread Andrew F
;, line 1, in File "random.py", line 10, in x = random.random() TypeError: 'module' object is not callable >>> $ find /usr/local/ -name random.py ./lib/python2.5/random.py ./lib/python2.3/random.py Do I need to clobber 2.3? ( If so, why???) TIA -- Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Error in random module, bad installation?

2007-09-13 Thread Andrew F
On Sep 13, 12:57 am, Tim Roberts <[EMAIL PROTECTED]> wrote: > Andrew F <[EMAIL PROTECTED]> wrote: > >I'm a linux user and I just upgraded from 2.1 to 2.5 and changed the > >location of a number of libraries and tools. > > >So far I've tracked most err

Re: class attrdict

2007-03-03 Thread Andrew Coffman
eError, message If you have a dict item with the same name as a method in the class, you won't be able to get to it using syntax sugar, though. It doesn't seem that the syntax sugar saves you much typing anyway (a.foo vs. a['foo']), but perhaps it seems nicer in some aesthe

Re: how to convert an integer to a float?

2007-03-05 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, I have the following functions, but ' dx = abs(i2 - i1)/min(i2, > i1)' always return 0, can you please tell me how can i convert it from > an integer to float? I don't think that's what you really want to do. What you really want

Measureing memory used by a subprocess

2007-04-01 Thread Andrew McLean
don't see any obvious way to get the process id of the spawned subprocess. - Andrew -- http://mail.python.org/mailman/listinfo/python-list

How to copy a file on Windows while preserving permissions

2007-04-12 Thread Andrew Koenig
The answer to this question probably involves pywin32 or a similar library. I would like to copy a file from one place to another on a Windows machine while preserving as much of the file permissions as it is possible to preserve with whatever my program's privileges happen to be. If the file i

Re: Free trips around the globe!!!!!!!!!!

2007-09-17 Thread Andrew Thompson
On Sep 18, 4:59 am, lilly <[EMAIL PROTECTED]> wrote: > On Sep 17, 2:33 pm, [EMAIL PROTECTED] wrote: > > >http://world-traveling-destinations.SPAMpot.com/ > > this is .. ..widely cross-posted *spam*. [ F'Ups set to c.l.j.p. only. ] -- http://mail.python.org/mailman/listinfo/python-list

Re: sorteddict PEP proposal [started off as orderedict]

2007-09-25 Thread Andrew Durdin
t({1:'a', 3:'b': 5:'c', 99:'d'})[3] should return 'b', not 'd'. Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused about 'positive lookbehind assertion'

2007-09-25 Thread Andrew Durdin
capture. OTOH, I often find the negative lookbehind (?!...) very useful indeed. Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: [Zope] how do I test for the current item in an iteration

2007-09-28 Thread Andrew Milton
+---[ kamal hamzat ]-- | Dear All, | | I have this error after i added the if statement Time for you to do some reading of your own. That's three in less than an hour... -- Andrew Milton [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Override 'and' and 'or'

2007-10-08 Thread Andrew Durdin
On 10/7/07, Dekker <[EMAIL PROTECTED]> wrote: > > Well I think it is not possible what I wanted to achieve. By > overriding the "and" and "or" keyword I wanted to return a new object: > > SqlValueInt(4) and SqlValueInt(5) --> SqlOpAnd(SqlValueInt(4), > SqlValueInt(5)) PEP 335 is a proposal to allo

Re: pytz has so many timezones!

2007-10-08 Thread andrew clarke
] [Melbourne ] ('Continent' is probably not the right word.) Regards Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected behaviour with HTMLParser...

2007-10-10 Thread Andrew Durdin
On 10/9/07, Just Another Victim of the Ambient Morality <[EMAIL PROTECTED]> wrote: > > "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > Without code, that's hard to determine. But you are aware of e.g. > > > > handle_entityref(name) > > handle_charref(ref) >

Re: EasyMock for python ?

2007-10-15 Thread Andrew Durdin
output from each mock will be interleaved; there should really be some way to use minimock so that you can output a call log from each mock individually after calling the function to test. Of course, that might need to be a feature in still_small_but_slightly_large_than_minimock.py ;-) Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Automatically organize module imports

2007-10-17 Thread Andrew Durdin
on of the environment to run, the fact that Pyflakes reads the source without trying to execute any of it helps a great deal. Andrew. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheriting automatic attributes initializer considered harmful?

2007-10-17 Thread Andrew Durdin
def __init__(self, **kwargs): valid_attrs = set(get_column_names_from_sqlalchemy()) # Only set valid attributes, ignoring any other kwargs for k in set(kwargs.keys()) & valid_attrs: setattr(self, k, kwargs[k]) Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheriting automatic attributes initializer considered harmful?

2007-10-18 Thread Andrew Durdin
posting it on c.l.p :-| Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: ConfigParser preserving file ordering

2007-10-19 Thread Andrew Durdin
As for updating ConfigParser -- like most other changes, it probably needs a champion. Andrew -- http://mail.python.org/mailman/listinfo/python-list

Finding decorators in a file

2007-10-26 Thread Andrew West
Probably a bit of weird question. I realise decorators shouldn't be executed until the function they are defined with are called, but is there anyway for me to find all the decorates declared in a file when I import it? Or perhaps anyway to find the decorators by loading the file by other methods

Re: Python Threads and C Semaphores

2007-01-16 Thread Andrew MacIntyre
_END_ALLOW_THREADS macros and the PyGILState*() API functions (these API functions appeared in Python 2.3). -- ----- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: [EMAIL PROTECTED] (pref)

cannot import libxml2 python module on windoze using activePerl or Python IDLE

2007-01-17 Thread Andrew Marlow
Python etc so I cannot even begin an install. I presume python's libxml builds on the C libs libxml2.dll and iconv.dll so I have installed those into the python DLL directory. I think this will be needed at some point. Please can anyone help? Regards, Andrew Marlow -- There is an emerald her

Re: cannot import libxml2 python module on windoze using activePerl or Python IDLE

2007-01-18 Thread Andrew Marlow
xml-python/ Thanks very much! -Andrew Marlow -- There is an emerald here the size of a plover's egg! Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html Plain text mails only, please http://www.expita.com/nomime.html -- http://mail.python.org/mailman/listinfo/python-list

Re: c++ for python programmers

2007-02-12 Thread andrew clarke
o your mailbox being full. Short answer: Subscribe to the [email protected] mailing list and ask your C/C++ questions there. Regards Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: try...except...finally problem in Python 2.5

2007-02-14 Thread Andrew Koenig
"redawgts" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I keep getting this error "local variable 'f' referenced before > assignment" in the finally block when I run the following code. > >try: >f = file(self.filename, 'rb') >f.seek(DATA_OFFSET) >

Re: Does Python have equivalent to MATLAB "varargin", "varargout", "nargin", "nargout"?

2007-02-18 Thread Andrew McLean
Where you would use varargin and nargin in Matlab, you would use the *args mechanism in Python. Try calling def t1(*args): print args print len(args) with different argument lists Where you would use varargout and nargout in Matlab you would use tuple unpacking in Python. Pla

Re: BDFL in wikipedia

2007-02-21 Thread Andrew McNamara
o page called BDFL, and the Guido_van_Rossum is the next closest match. If you care and you have enough to say on the subject, maybe you could start a BDFL page. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible to set cpython heap size?

2007-02-23 Thread Andrew MacIntyre
indicated. Some platform allocators are notorious for poor behaviour in certain circumstances, and coalescing blocks while deallocating is one particularly nasty problem for code that creates and destroys lots of small variably sized objects. -- - Andrew I MacIntyre

Re: Sub-sort after sort

2007-11-02 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I would want to sort by name first, then sub sort by location. Any > ideas? Thanks! In Python 2.3 and later, sorting is stable -- so you can sort successively in reverse order. In other words, sort the list by location, then sort th

Re: the annoying, verbose self

2007-11-25 Thread Andrew Koenig
"Colin J. Williams" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Alternatively, as someone else suggested, an analogue of the Pascal "with" > could be used: > > def abs(self): > with self: > return math.sqrt(x**2 + y**2 + z**2) How does your suggested "with" statement know

RE: the annoying, verbose self

2007-11-25 Thread Andrew Koenig
> I am not advocating this, but this could be: > def abs(self): >with self: > with math: >return sqrt(x**2 + y**2 + z**2) > The idea being that "with self" use > creates a new namespace: >newGlobal= oldGlobal + oldLocal >newLocal= names from self You don't know what thos

Re: How to Teach Python "Variables"

2007-11-25 Thread Andrew Koenig
"Aurélien Campéas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I mean : aren't C variables also bindings from names to objects ? Or what > ? No, they're not. In C, when you execute x = y; you cause x to become a copy of y. In Python, when you execute x = y you ca

AIX Subversion Python Swig Bindings fix for core dump

2007-12-05 Thread Reedick, Andrew
If you're on AIX and Python immediately dumps core when trying to import any SVN module, then adding "-Wl,-brtl" to LINKFORSHARED in the Makefile seems to fix the problem. Bad: > LINKFORSHARED=-Wl,-bE:Modules/python.exp -lld Good: < LINKFORSHARED=-Wl,-bE:Modules/python.exp -lld

Re: Pure Python GUI lib?

2007-12-22 Thread Andrew MacIntyre
de (available from SourceForge) could still prove a useful reference. Cheers, Andrew. -- ----- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: [EMAIL PROTECTED] (pref) | Snail: PO Box 370

Re: convert pdf to png

2007-12-24 Thread Andrew MacIntyre
s about > like trimming an elephants toenails to save weight. Using ctypes to call Ghostscript's API also works well. I've only done this on Windows, but it should also work on other systems with ctypes support. -- - An

Re: convert pdf to png

2007-12-25 Thread Andrew MacIntyre
Carl K wrote: > Andrew MacIntyre wrote: >> Grant Edwards wrote: >>> On 2007-12-24, Carl K <[EMAIL PROTECTED]> wrote: >>> >>>>> If it is a multi page pdf Imagemagick will do: >>>>> >>>>> convert file.pdf page-%03d.pn

Re: CPython and a C extension using Boehm GC

2007-12-25 Thread Andrew MacIntyre
tension's import routine (init()) for a C extension, and immediately after loading the library if using ctypes. -- ----- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: [EMAIL

Re: MS VC++ Toolkit 2003, where?

2006-04-24 Thread Andrew Trevorrow
r cache. I'm in Australia, so maybe it depends on where the request is coming from? Any clues on this would be much appreciated. Or maybe someone is willing to make their VCToolkitSetup.exe available temporarily... Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: MS VC++ Toolkit 2003, where?

2006-04-24 Thread Andrew Trevorrow
[EMAIL PROTECTED] (Alex Martelli) wrote: > Andrew Trevorrow <[EMAIL PROTECTED]> wrote: > > Or maybe someone is willing to make their VCToolkitSetup.exe available > > temporarily... > > I suggest any such offers be made privately, since I'm pretty sure > th

Plotting package?

2006-04-25 Thread Andrew Koenig
This may be a foolish question, but what's the most straightforward way to plot a bunch of data in Python? That is, I want to write a program that does some number crunching, and then I want to change some parameters and watch how the changes affect the results. I could produce a file to hand

Re: list example

2006-04-25 Thread Andrew Koenig
"PAolo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > for i in range(1,10): >if i%2: >odd.append(i) >else: >even.append(i) In 2.5 you'll be able to say for i in range(1,10): (odd if i%2 else even).append(i) Whether you

Re: Building a Dynamic Library (libpython.so) for Python 2.4.3 Final

2006-04-26 Thread Andrew MacIntyre
get any other responses, send me a copy of the full make log (ie "make >make.log 2>&1") and I'll compare it to the log from my test build. - Andrew I MacIntyre "These tho

Re: bug in modulus?

2006-05-02 Thread Andrew Koenig
"Christophe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [EMAIL PROTECTED] a écrit : > Floating point numbers just don't have the required precision to represent > 2.0 - 1e-050. For your specific problem, if you really want the result to > be < 2.0, the the best you can do is

Re: bug in modulus?

2006-05-02 Thread Andrew Koenig
"Andrew Koenig" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I disagree. For any two floating-point numbers a and b, with b != 0, it > is always possible to represent the exact value of a mod b as a > floating-point number--at least on every floating

Re: Python for Perl programmers

2006-05-04 Thread Andrew Gwozdziewycz
eintopython.org since you know how to program already. It's free! --- Andrew Gwozdziewycz [EMAIL PROTECTED] http://ihadagreatview.org http://and.rovir.us -- http://mail.python.org/mailman/listinfo/python-list

Re: Method acting on arguements passed

2006-05-05 Thread Andrew Gwozdziewycz
guments: def getBook(id=None, name=None): if id: # do whatever for id elif name: # do whatever for name here They are nearly identical. --- Andrew Gwozdziewycz [EMAIL PROTECTED] http://www.23excuses.com http://ihadagreatview.org http://and.rovir.us -- http://mail.python

MQSeries based file transfers using the pymqi module

2006-05-05 Thread Andrew Robert
Hi everyone, Has anyone developed a pymqi module based file transfer method for use with WebSphere MQSeries v5.3? If so, would it be possible to point me towards examples of how this was done? Any help that can be provided would be greatly appreciated. Thanks -- http://mail.python.org/mailma

Re: how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Andrew Gwozdziewycz
10) >>>> b=range(5) >>>> for x in b: > ... a.remove(x) > ... > it will very slowly. Shall I change to another data structure and > choos > a better arithmetic? > any suggestion is welcome. > thanks a lot! > > -- > http://mail.python.

Re: clear memory? how?

2006-05-09 Thread Andrew Gwozdziewycz
n toplevel. On May 9, 2006, at 4:27 AM, N/A wrote: > Hi all, > I am learning Python. Just wondering how to clear saved memory in > Python? Like in Matlab I can simply use "clear all" to clear all saved > memory. > > Thank u! > -- > http://mail.python.

Re: releasing interpreter lock in custom code?

2006-05-11 Thread Andrew MacIntyre
educational (eg Modules/posixmodule.c). -- ----- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: [EMAIL PROTECTED] (pref) | Snail: PO Box 370 [EMAIL PROTECTED] (alt) |

Re: Slow network reading?

2006-05-11 Thread Andrew MacIntyre
ividends when the repetition counts are large enough; whether this is the case for your tests I can't say. -- - Andrew I MacIntyre "These thoughts are mine alone..." E-mail: [EMAIL PROTECTED] (pref) | Snail: PO Box 370 [EMAIL PROTECTED] (alt)

Re: Slow network reading?

2006-05-13 Thread Andrew MacIntyre
Ivan Voras wrote: > Andrew MacIntyre wrote: > >> Comparative CPU & memory utilisation statistics, not to mention platform >> and version of Python, would be useful hints... > > During benchmarking, all versions cause all CPU to be used, but Python > version has ~

Question regarding checksuming of a file

2006-05-13 Thread Andrew Robert
Good evening, I need to generate checksums of a file, store the value in a variable, and pass it along for later comparison. The MD5 module would seem to do the trick but I'm sketchy on implementation. The nearest I can see would be import md5 m=md5.new() contents = open(self.file_name,"rb").

Re: Question regarding checksuming of a file

2006-05-13 Thread Andrew Robert
Actually, I think I got it but would like to confirm this looks right. import md5 checksum = md5.new() mfn = open(self.file_name, 'r') for line in mfn.readlines(): checksum.update(line) mfn.close() cs = checksum.hexdigest() print

Re: Question regarding checksuming of a file

2006-05-13 Thread Andrew Robert
Roy Smith wrote: >> >> However this does not appear to be actually returning the checksum. >> >> Does anyone have insight into where I am going wrong? > > After calling update(), you need to call digest(). Update() only updates > the internal state of the md5 state machine; digest() returns the

Re: Question regarding checksuming of a file

2006-05-14 Thread Andrew Robert
When I run the script, I get an error that the file object does not have the attribute getblocks. Did you mean this instead? def getblocks(f, blocksize=1024): while True: s = f.read(blocksize) if not s: return yield s def getsum(self):

Option parser question - reading options from file as well as command line

2006-05-16 Thread Andrew Robert
Hi Everyone. I tried the following to get input into optionparser from either a file or command line. The code below detects the passed file argument and prints the file contents but the individual swithces do not get passed to option parser. Doing a test print of options.qmanager shows it una

Re: Option parser question - reading options from file as well as command line

2006-05-16 Thread Andrew Robert
Max Erickson wrote: > Andrew Robert <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > <\snip> > Check parser.usage, it is likely to look a lot like your infile. > > I'm not sure, but I think you need to pass your alternative arguments > to par

Re: Option parser question - reading options from file as well as command line

2006-05-16 Thread Andrew Robert
Max Erickson wrote: > I don't know much about optparse, but since I was bored: > help(o.parse_args) > Help on method parse_args in module optparse: > > parse_args(self, args=None, values=None) method of > optparse.OptionParser instance > parse_args(args : [string] = sys.argv[1:], >

Re: Option parser question - reading options from file as well as command line

2006-05-17 Thread Andrew Robert
Tim N. van der Leeuw wrote: > Andrew Robert wrote: >> Hi Everyone. >> >> >> I tried the following to get input into optionparser from either a file >> or command line. >> >> >> The code below detects the passed file argument and prints the file

Process forking on Windows

2006-05-17 Thread Andrew Robert
Hi everyone, I have a python program that will need to interact with an MQSeries trigger monitor. It does this fine but it hogs the trigger monitor while it executes. I'd like to fork the program off and terminate the parent process so that the trigger monitor frees up. Does anyone how this c

Re: Process forking on Windows

2006-05-17 Thread Andrew Robert
bruno at modulix wrote: > Andrew Robert wrote: >> Hi everyone, >> >> >> I have a python program that will need to interact with an MQSeries >> trigger monitor. >> >> It does this fine but it hogs the trigger monitor while it executes. >> >>

Re: Process forking on Windows - or what is MQSeries

2006-05-17 Thread Andrew Robert
Gary Herron wrote: > Andrew Robert wrote: > > > The windows CreateProcess call has many of the same semantics as the > Unix fork, i.e., a new process is created sharing all the resources of > the original process. The "subprocess" modules uses CreateProcess, but

Conversion of perl unpack code to python - something odd

2006-05-18 Thread Andrew Robert
Hey everyone, Maybe you can see something I don't. I need to convert a working piece of perl code to python. The perl code is: sub ParseTrig { # unpack the ibm struct that triggers messages. my $struct = shift; my %data; @data{qw/StructID Version QName ProcessName TriggerData ApplType

Re: Conversion of perl unpack code to python - something odd

2006-05-18 Thread Andrew Robert
Peter Otten wrote: > Andrew Robert wrote: > >> format='4s 4s 48s 48s 64s 4s 256s 128s 128s 48s' > > You are trying to squeeze 10 items into just > >> d1,d2=struct.unpack(format,data) > > two variables (d1 and d2) > >> ValueError: too man

Re: number of different lines in a file

2006-05-18 Thread Andrew Robert
r.e.s. wrote: > I have a million-line text file with 100 characters per line, > and simply need to determine how many of the lines are distinct. > > On my PC, this little program just goes to never-never land: > > def number_distinct(fn): > f = file(fn) > x = f.readline().strip() > L

File encoding strategy question

2006-05-20 Thread Andrew Robert
Hi everyone, I am in the process of creating a file transmit/receiver program using MQSeries. The way it works is through creation of an XML message. Elements within the XML message contain things such as file name, size, and the file contents. The file contents are encoded, currently using Bas

Re: 'error reading datastream' -- loading file only when transfer is complete?

2006-05-20 Thread Andrew Robert
[EMAIL PROTECTED] wrote: > hello -- > > i'm running python/pygame on maemo (nokia 770). my situation is that > i'm continually scouring this one directory for incoming files. if i > see if there's a new file (coming in via wireless scp), i proceed to > load it and process it. > > however, i think

Re: Problem with odbc and Sql Server

2006-05-21 Thread Andrew MacIntyre
e the control of the odbc module. I've not had much to do with SQL Server, but I wonder whether there is some configuration setting that might be affecting this behaviour. - Andrew I MacIntyre

Testing for file type

2006-05-22 Thread Andrew Robert
Hi Everyone, Is there a way to test if a file is binary or ascii within Python? I'd prefer not to text against file extension. Any help you can provide would be greatly appreciated. Thanks, Andy -- http://mail.python.org/mailman/listinfo/python-list

Class probkem - getting msg that self not defined

2006-05-22 Thread Andrew Robert
Hi Everyone, I am having a problem with a class and hope you can help. When I try to use the class listed below, I get the statement that self is not defined. test=TriggerMessage(data) var = test.decode(self.qname) I would have thought that self would have carried forward when I

Re: Class probkem - getting msg that self not defined

2006-05-22 Thread Andrew Robert
wes weston wrote: > Andrew Robert wrote: >> Hi Everyone, >> >> I am having a problem with a class and hope you can help. >> >> When I try to use the class listed below, I get the statement that self >> is not defined. >> >> test=TriggerMes

Re: Class probkem - getting msg that self not defined

2006-05-22 Thread Andrew Robert
Hey Bruno, Although I have not tested it, this appears to be it exactly. Some confusion though. > import struct > > class TriggerMessage(object): > def __init__(self,data): > """ > Unpacks the passed binary data based on the > MQTCM2 format dictated in >

Conversion of perl based regex to python method

2006-05-24 Thread Andrew Robert
I have two Perl expressions If windows: perl -ple "s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge" somefile.txt If posix perl -ple 's/([^\w\s])/sprintf("%%%2X", ord $1)/ge' somefile.txt The [^\w\s] is a negated expression stating that any character a-zA-Z0-9_, space or tab is ignored. The ()

Re: how to change sys.path?

2006-05-24 Thread Andrew Robert
Dennis Lee Bieber wrote: > On Wed, 24 May 2006 14:45:55 GMT, John Salerno > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > >> I just right-clicked on My Computer --> Properties --> Advanced --> >> Environment Variables, and added a new one called PYTHONPATH. I don't >> know i

Re: Conversion of perl based regex to python method

2006-05-24 Thread Andrew Robert
Andrew Robert wrote: > I have two Perl expressions > > > If windows: > > perl -ple "s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge" somefile.txt > > If posix > > perl -ple 's/([^\w\s])/sprintf("%%%2X", ord $1)/ge' somefile.txt >

regex/lambda black magic

2006-05-25 Thread Andrew Robert
Hi everyone, I have two test scripts, an encoder and a decoder. The encoder, listed below, works perfectly. import re,sys output = open(r'e:\pycode\out_test.txt','wb') for line in open(r'e:\pycode\sigh.txt','rb') : output.write( re.sub(r'([^\w\s])', lambda s: '%%%2X' % ord(s.group()), line)

Re: regex/lambda black magic

2006-05-25 Thread Andrew Robert
Max Erickson wrote: > Try getting rid of the lamba, it might make things clearer and it > simplifies debugging. Something like(this is just a sketch): > > > max > Yeah.. trying to keep everything on one line is becoming something of a problem. To make this easier, I followed something from

Re: regex/lambda black magic

2006-05-25 Thread Andrew Robert
Hi Everyone, Thanks for all of your patience on this. I finally got it to work. Here is the completed test code showing what is going on. Not cleaned up yet but it works for proof-of-concept purposes. #!/usr/bin/python import re,base64 # Evaluate captured character as hex def ret_hex(va

dictionary/hash and '1' versus 1

2008-01-03 Thread Reedick, Andrew
As a Perl monkey in the process of learning Python, I just stepped on the "'1' (string) is not the same as 1 (integer) in regards to keys for dictionaries/hashes" landmine. Is there a good way to ensure that numbers represented as strings or ints do not get mixed up as keys? Example of the proble

RE: dictionary/hash and '1' versus 1

2008-01-04 Thread Reedick, Andrew
> From: Stephen Hansen [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 03, 2008 7:39 PM > To: Reedick, Andrew > Cc: [email protected] > Subject: Re: dictionary/hash and '1' versus 1 > > > > Well one important thing to learn while learning Pyt

Re: Memory Leaks and Heapy

2008-01-05 Thread Andrew MacIntyre
possibly get better performance). -- ----- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: [EMAIL PROTECTED] (pref) | Snail: PO Box 370 [EMAIL PROTECTED] (alt) |Belconnen ACT 2616 Web:http://www.and

RE: dictionary/hash and '1' versus 1

2008-01-07 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Steven D'Aprano > Sent: Saturday, January 05, 2008 7:01 PM > To: [email protected] > Subject: Re: dictionary/hash and '1' versus 1 > > The problem with automatic conversions between strin

RE: dictionary/hash and '1' versus 1

2008-01-07 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Paddy > Sent: Monday, January 07, 2008 12:52 PM > To: [email protected] > Subject: Re: dictionary/hash and '1' versus 1 > > Or how using different operators for similar operations on differ

Learning Python via a little word frequency program

2008-01-09 Thread Andrew Savige
names = "freddy fred bill jock kevin andrew kevin kevin jock" produce a frequency table of names, sorted descending by frequency. then ascending by name. For the above data, the output should be: kevin : 3 jock : 2 andrew: 1 bill : 1 fred :

<    7   8   9   10   11   12   13   14   15   16   >