[OT] a little about regex

2006-10-18 Thread Fulvio
*** Your mail has been scanned by InterScan MSS. *** Hello, I'm trying to get working an assertion which filter address from some domain but if it's prefixed by '.com'. Even trying to put the result in a negate test I can't get the wanted result. The tou

Re: Flexable Collating (feedback please)

2006-10-18 Thread Ron Adam
Fixed... Changed the collate() function to return None the same as sort() since it is an in place collate. A comment in _test() doctests was reversed. CAPS_FIRST option puts words beginning with capitals before, not after, words beginning with lower case of the same letter. It seems I alw

Re: [OT] a little about regex

2006-10-18 Thread Fredrik Lundh
Fulvio wrote: > ... if deny.search(adr): cnt += 1 > ... if allow.search(adr): cnt += 1 hint: under what circumstances are "cnt" decremented in the above snippet? -- http://mail.python.org/mailman/listinfo/python-list

RE: Where to find pydoc?

2006-10-18 Thread Wijaya Edward
Hi, Can you be specific on which URLs can I find "python-tools". Cause I tried the one under easy_install, I still can't find it. Thanks and hope to hear from you again. -- Edward WIJAYA SINGAPORE From: [EMAIL PROTECTED] on behalf of Fredrik Lundh Sent: Mon 1

How to convert this list to string?

2006-10-18 Thread Jia Lu
Hi all I have a list like: >>> list [1, 2, 3] >>> list[1:] [2, 3] I want to get a string "2 3" >>> str(list[1:]) '[2, 3]' How can I do that ? thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert this list to string?

2006-10-18 Thread Theerasak Photha
On 18 Oct 2006 00:20:50 -0700, Jia Lu <[EMAIL PROTECTED]> wrote: > I want to get a string "2 3" > > >>> str(list[1:]) > '[2, 3]' > > How can I do that ? ' '.join(str(i) for i in list[1:]) -- Theerasak -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert this list to string?

2006-10-18 Thread Travis E. Oliphant
Jia Lu wrote: > Hi all > > I have a list like: > list > [1, 2, 3] list[1:] > [2, 3] > > I want to get a string "2 3" > str(list[1:]) > '[2, 3]' > > How can I do that ? > " ".join(str(x) for x in list) -Travis -- http://mail.python.org/mailman/listinfo/python-list

Re: stdout not flushed before os.execvp()

2006-10-18 Thread Fulvio
On Wednesday 18 October 2006 00:25, Fredrik Lundh wrote: > |feature. the "exec" system call operates on a lower level than the > |stdio buffering system. I did in this manner: for exe in ('imap4', 'pop3'): if exe in cfgfil[optsrv + '.protocol']: exe = exe[:4]; exe = 'cal

Re: creating many similar properties

2006-10-18 Thread Carl Banks
Lee Harr wrote: > I understand how to create a property like this: > > class RC(object): > def _set_pwm(self, v): > self._pwm01 = v % 256 > def _get_pwm(self): > return self._pwm01 > pwm01 = property(_get_pwm, _set_pwm) > > > But what if I have a whole bunch of these pw

Re: Where to find pydoc?

2006-10-18 Thread Fredrik Lundh
Wijaya Edward wrote: > Can you be specific on which URLs can I find "python-tools". > Cause I tried the one under easy_install, I still can't find it. it's an RPM. you should be able to get it from where you get other RedHat packages. -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] a little about regex

2006-10-18 Thread Ron Adam
Fulvio wrote: > *** > Your mail has been scanned by InterScan MSS. > *** > > > Hello, > > I'm trying to get working an assertion which filter address from some domain > but if it's prefixed by '.com'. > Even trying to put the result in a negate test I can

Re: How to convert this list to string?

2006-10-18 Thread Fredrik Lundh
Jia Lu wrote: > Hi all > > I have a list like: > list > [1, 2, 3] list[1:] > [2, 3] > > I want to get a string "2 3" > str(list[1:]) > '[2, 3]' > > How can I do that ? http://effbot.org/zone/python-list.htm#printing -- http://mail.python.org/mailman/listinfo/python-l

Re: Looking for assignement operator

2006-10-18 Thread Tommi
Could the "traits" package be of help? http://code.enthought.com/traits/ Alexander Eisenhuth wrote: > Hello, > > is there a assignement operator, that i can overwrite? > > class MyInt: > def __init__(self, val): > assert(isinstance(val, int)) > self._val = val

Re: creating many similar properties

2006-10-18 Thread George Sakkis
Michele Simionato wrote: > Lee Harr wrote: > > I understand how to create a property like this: > > > > class RC(object): > > def _set_pwm(self, v): > > self._pwm01 = v % 256 > > def _get_pwm(self): > > return self._pwm01 > > pwm01 = property(_get_pwm, _set_pwm) > > > >

Re: creating many similar properties

2006-10-18 Thread George Sakkis
Carl Banks wrote: > Lee Harr wrote: > > I understand how to create a property like this: > > > > class RC(object): > > def _set_pwm(self, v): > > self._pwm01 = v % 256 > > def _get_pwm(self): > > return self._pwm01 > > pwm01 = property(_get_pwm, _set_pwm) > > > > > > But

Re: How to convert this list to string?

2006-10-18 Thread Ron Adam
Jia Lu wrote: > Hi all > > I have a list like: > list > [1, 2, 3] list[1:] > [2, 3] > > I want to get a string "2 3" > str(list[1:]) > '[2, 3]' > > How can I do that ? > > thanks Just to be different from the other suggestions... >>> a = [1, 2, 3] >>> str(a[1:]).strip('[]'

Re: python's OOP question

2006-10-18 Thread neoedmund
Bruno Desthuilliers wrote: > neoedmund wrote: > (snip) > > So I can reuse a method freely only if it's worth reusing. > > For the word "inheritance", in some aspect, meanings reuse the super > > class, with the condition: must reuse everything from super class. > > Not really. In fact, inheritance

Re: creating many similar properties

2006-10-18 Thread Michele Simionato
George Sakkis wrote: > > Why is this less hidden or magical than a metaclass ? Because it does not use inheritance. It is not going to create properties on subclasses without you noticing it. Also, metaclasses are brittle: try to use them with __slots__, or with non-standard classes (i.e. extensio

Re: python's OOP question

2006-10-18 Thread Fredrik Lundh
neoedmund wrote: > ivestgating the web, i found something similiar with my approch: > http://en.wikipedia.org/wiki/Duck_typing > "Duck-typing avoids tests using type() or isinstance(). Instead, it > typically employs hasattr() tests" that's not entirely correct, though: in Python, duck-typing typ

Re: python's OOP question

2006-10-18 Thread neoedmund
Bruno Desthuilliers wrote: > neoedmund wrote: > (snip) > > So I can reuse a method freely only if it's worth reusing. > > For the word "inheritance", in some aspect, meanings reuse the super > > class, with the condition: must reuse everything from super class. > > Not really. In fact, inheritance

Re: creating many similar properties

2006-10-18 Thread Michele Simionato
George Sakkis wrote: > > from itertools import chain, izip, repeat > > def ByteProperties(*names, **defaulted_names): > def byte_property(name, default): > return property(lambda self: getattr(self, name, default), > lambda self,v: setattr(self, name, v%256)) >

Re: creating many similar properties

2006-10-18 Thread Carl Banks
George Sakkis wrote: > Michele Simionato wrote: > > import sys > > > > def defprop(name, default=127): > > loc = sys._getframe(1).f_locals > > prop = '_%s' % name > > def _set(self, v): > > v_new = v % 256 > > setattr(self, prop, v_new) > > def _get(self): > >

Re: creating many similar properties

2006-10-18 Thread Michele Simionato
Carl Banks wrote: > Devil's Advocate: he did say "hidden magic TO YOUR CLASS". > > If you use a (real) metaclass, then you have the icky feeling of a > class permanently tainted by the unclean metaclass (even though the > metaclass does nothing other than touch the class dict upon creation); > wher

Re: creating many similar properties

2006-10-18 Thread Carl Banks
George Sakkis wrote: > There's a subtle common bug here: all _get and _set closures will refer > to the last property only. You have to remember to write "def > _set(self,v,prop=prop)" and similarly for _get to do the right thing. Sorry. My mistake. > By the way, I can't think of a case where t

Re: Looking for assignement operator

2006-10-18 Thread Bruno Desthuilliers
Tommi wrote: (please don't top-post - corrected) > > > Alexander Eisenhuth wrote: >> Hello, >> >> is there a assignement operator, that i can overwrite? >> >> class MyInt: >> def __init__(self, val): >> assert(isinstance(val, int)) >> self._val = val >> >> a = MyInt

Re: dynamic module loading via __import__, nonetype?

2006-10-18 Thread John Allman
Gabriel Genellina wrote: > At Monday 16/10/2006 13:33, John Allman wrote: > >> If i manually import a module, this method works a treat, however if i >> attempt to dynamically load a module at runtime the create method fails >> with the following error: >> >> TypeError: 'NoneType' object is not ca

Re: a little about regex

2006-10-18 Thread Rob Wolfe
Fulvio wrote: > I'm trying to get working an assertion which filter address from some domain > but if it's prefixed by '.com'. > Even trying to put the result in a negate test I can't get the wanted result. [...] > Seem that I miss some better regex implementation to avoid that both of the > fi

Re: creating many similar properties

2006-10-18 Thread Carl Banks
Michele Simionato wrote: > Carl Banks wrote: > > Devil's Advocate: he did say "hidden magic TO YOUR CLASS". > > > > If you use a (real) metaclass, then you have the icky feeling of a > > class permanently tainted by the unclean metaclass (even though the > > metaclass does nothing other than touch

Wax: problem subclassing TextBox

2006-10-18 Thread alex23
Hey everyone, I've just started looking at Wax and have hit a problem I can't explain. I want an app to respond to every character input into a TextBox. Here's a simple, working example: +++ from wax import * class MainFrame(VerticalFrame): def Body(self): self.search = TextBox(self)

RE: making a valid file name...

2006-10-18 Thread Matthew Warren
> > Hi I'm writing a python script that creates directories from user > input. > Sometimes the user inputs characters that aren't valid > characters for a > file or directory name. > Here are the characters that I consider to be valid characters... > > valid = > ':./,^0123456789abcdefghijklmno

Re: creating many similar properties

2006-10-18 Thread Michele Simionato
Carl Banks wrote: > Come on, I don't think anyone's under the impression we're being > indiscriminate here. Ok, but I don't think that in the case at hand we should recommend a metaclass solution. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Book about database application development?

2006-10-18 Thread Paul Boddie
Dennis Lee Bieber wrote: > > Python has a half dozen GUI toolkits, and multiple adapters for > databases (some don't even follow DB-API2 specs). All independently > written. So no, you are not going to find, say, a grid widget that > automatically links to a database table/view/cursor, with bi-dir

Re: Python Web Site?

2006-10-18 Thread Christophe
*% a écrit : > Is there a problem with the Python and wxPython web sites? I cannot > seem to get them up, and I am trying to find some documentation... > > Thanks, > Mike All the sites hosted on sourceforge that rely on their vhost computer ( ie, site hosted on sourceforge that do n

Re: python's OOP question

2006-10-18 Thread Ben Finney
"neoedmund" <[EMAIL PROTECTED]> writes: > Bruno Desthuilliers wrote: > > neoedmund wrote: > > > in real life, a class is not defined so well that any method is > > > needed by sub-class. > > > > Then perhaps is it time to refactor. A class should be a highly > > cohesive unit. If you find yourself

Re: python's OOP question

2006-10-18 Thread Neil Cerutti
On 2006-10-18, neoedmund <[EMAIL PROTECTED]> wrote: > ivestgating the web, i found something similiar with my approch: > http://en.wikipedia.org/wiki/Duck_typing > "Duck-typing avoids tests using type() or isinstance(). Instead, it > typically employs hasattr() tests" It's pity it didn't get calle

portable extensions options for external libraries

2006-10-18 Thread Alexandre Guimond
Hi. I want to create a portable setup.py file for windows / linux for an extension package that i need to link with external libraries (gsl and boost). on windows i do something like this: imaging = Extension( 'pyag.imaging._imaging', sources = ( glob.glob( 'Source/pyag/imagi

matrix Multiplication

2006-10-18 Thread Sssasss
hi evrybody! I wan't to multiply two square matrixes, and i don't understand why it doesn't work. Could you explain me? def multmat(A,B): "A*B" if len(A)!=len(B): return "error" D=[] C=[] for i in range(len(A)): D.append(0) for i in range(len(A)): C.append(D) for i in

Re: making a valid file name...

2006-10-18 Thread Fredrik Lundh
Matthew Warren wrote: >>> import re >>> badfilename='£"%^"£^"£$^ihgeroighroeig3645^£$^"knovin98u4#346#1461461' >>> valid=':./,^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' >>> goodfilename=re.sub('[^'+valid+']',' ',badfilename) to create arbitrary character sets, it's usually

Re: matrix Multiplication

2006-10-18 Thread Fredrik Lundh
"Sssasss" wrote: > I wan't to multiply two square matrixes, and i don't understand why it > doesn't work. > > def multmat(A,B): >"A*B" >if len(A)!=len(B): return "error" >D=[] >C=[] >for i in range(len(A)): D.append(0) >for i in range(len(A)): C.append(D) append doesn't co

Re: Plotting histograms

2006-10-18 Thread Roberto Bonvallet
[EMAIL PROTECTED] wrote: > hi, I have some values(say from -a to a) stored in a vector and I want > to plot a histogram for those values. How can I get it done in python. > I have installed and imported the Matplotlib package but on executing > the code > [N,x]=hist(eig, 10) # make a histogram > I

Re: Flexable Collating (feedback please)

2006-10-18 Thread georgeryoung
On Oct 18, 2:42 am, Ron Adam <[EMAIL PROTECTED]> wrote: > I put together the following module today and would like some feedback on any > obvious problems. Or even opinions of weather or not it is a good approach. ,,, def __call__(self, a, b): """ This allows the Collate class work

Re: making a valid file name...

2006-10-18 Thread Fabio Chelly
You should use the s.translate() It's 100x faster: #Creates the translation table ValidChars = ":./,^0123456789abcdefghijklmnopqrstuvwxyz" InvalidChars = "".join([chr(i) for i in range(256) if not chr(i).lower() in ValidChars]) TranslationTable = "".join([chr(i) for i in range(256)]) def valid_f

Re: matrix Multiplication

2006-10-18 Thread Sssasss
Fredrik Lundh wrote: > "Sssasss" wrote: > > > I wan't to multiply two square matrixes, and i don't understand why it > > doesn't work. > > > > def multmat(A,B): > >"A*B" > >if len(A)!=len(B): return "error" > >D=[] > >C=[] > >for i in range(len(A)): D.append(0) > >for i in

codecs.EncodedFile

2006-10-18 Thread Neil Cerutti
Perhaps I'm just bad at searching for bugs, but anyhow, I wanted to know what you all thought about the following behavior. A quick search of pydev archives yielded a nice wrapper to apply to streams to perform decoding and encoding behind the scenes. Assuming I get the correct encodings from some

Re: python's OOP question

2006-10-18 Thread Peter Otten
Neil Cerutti wrote: > On 2006-10-18, neoedmund <[EMAIL PROTECTED]> wrote: >> ivestgating the web, i found something similiar with my approch: >> http://en.wikipedia.org/wiki/Duck_typing >> "Duck-typing avoids tests using type() or isinstance(). Instead, it >> typically employs hasattr() tests" >

Re: matrix Multiplication

2006-10-18 Thread Gerrit Holl
On 2006-10-18 14:15:17 +0200, Sssasss wrote: > Fredrik Lundh wrote: > > "Sssasss" wrote: > > > > > I wan't to multiply two square matrixes, and i don't understand why it > > > doesn't work. > > > > > > def multmat(A,B): > > >"A*B" > > >if len(A)!=len(B): return "error" > > >D=[] > > >

MemoryError - IMAP retrieve self._sock.recv(recv_size)

2006-10-18 Thread Stephen G
Hi there. I have been receiving MemoryErrors using the Windows version of Python 2.5. The script I have written times the sending and the reception of emails with various attachments. I get many exceptions when using the IMAP downloads. This happens randomly; sometimes the file downloads OK,

Re: MemoryError - IMAP retrieve self._sock.recv(recv_size)

2006-10-18 Thread Fredrik Lundh
"Stephen G" <[EMAIL PROTECTED]> wrote: > I get many exceptions when using the IMAP downloads. This happens > randomly; sometimes the file downloads OK, and other times no. > File "C:\Python25\lib\socket.py", line 308, in read >data = self._sock.recv(recv_size) > > Is this a know bug or is t

Re: Numpy-f2py troubles

2006-10-18 Thread [EMAIL PROTECTED]
Hi Andrea, you should post this to the numpy list: numpy-discussion@lists.sourceforge.net Cheers! Bernhard Andrea Gavana schrieb: > Hello NG, > > I am using the latest Numpy release 1.0rc2 which includes F2PY. I > have switched to Python 2.5 so this is the only alternative I have > (IIUC).

Re: matrix Multiplication

2006-10-18 Thread David
Il 18 Oct 2006 04:17:29 -0700, Sssasss ha scritto: > hi evrybody! > > I wan't to multiply two square matrixes, and i don't understand why it > doesn't work. Can I suggest a little bit less cumbersome algorithm? def multmat2(A,B): "A*B" if len(A)!=len(B): return "error" # this check is

Re: matrix Multiplication

2006-10-18 Thread Roberto Bonvallet
Sssasss wrote: > hi evrybody! > > I wan't to multiply two square matrixes, and i don't understand why it > doesn't work. > Could you explain me? > > def multmat(A,B): >"A*B" >if len(A)!=len(B): return "error" Wrong validation here: you _can_ multiply two matrices with a different number

Re: How to convert this list to string?

2006-10-18 Thread Jia Lu
Thank you very much. I memoed all you views. :) -- http://mail.python.org/mailman/listinfo/python-list

PIL: Image.draft -- what are the modes that I can use?

2006-10-18 Thread abcd
I have PIL 1.1.5 on python 2.4.1 and I am attempting to get a smaller (file size) of an image. for example: im = ImageGrab.grab() im.save("tmp.gif") about 1.7mb im.save("tmp.jpeg") about 290kb anyways I want to save the image as a GIF, but not have it be so largeso I thought th

Re: Image.draft -- what are the modes that I can use?

2006-10-18 Thread Fredrik Lundh
"abcd" wrote: >I have PIL 1.1.5 on python 2.4.1 and I am attempting to get a smaller > (file size) of an image. > > for example: > im = ImageGrab.grab() > > im.save("tmp.gif") about 1.7mb > im.save("tmp.jpeg") about 290kb > > anyways I want to save the image as a GIF, but not have it

Re: Image.draft -- what are the modes that I can use?

2006-10-18 Thread abcd
Fredrik Lundh wrote: > GIF is horribly unsuitable for screenshots on modern machines. have you > considered using PNG ? > > or even better, Flash? well I am trying to take screenshots and make them into an animated GIF, however, putting them into a Flash movie would be coolany idea how to go

Re: Image.draft -- what are the modes that I can use?

2006-10-18 Thread Fredrik Lundh
"abcd" wrote: >> or even better, Flash? > > well I am trying to take screenshots and make them into an animated > GIF, however, putting them into a Flash movie would be coolany idea > how to go about doing either with python? (windows, possibly linux > later) to repeat myself: here's a

Re: Image.draft -- what are the modes that I can use?

2006-10-18 Thread abcd
oh and vnc2swf would not be an option, i cant be setting up a vnc server, etc. just need to use python (and necessary packages). animated gif would probably be best i am assuming. -- http://mail.python.org/mailman/listinfo/python-list

Re: Restart a Python COM Server

2006-10-18 Thread m . errami
OK, well thank you for your help (merci pour ton aide!) M.E. MC wrote: > Hi! > > It is the normal behavior of COM. > > Note that, Python being dynamic, you can modify Python script, OF THE > INTERIOR, during execution. > > -- > @-salutations > > Michel Claveau -- http://mail.python.org/mailm

Win32 python and excel macros

2006-10-18 Thread michael . pearmain
Hi Experts, Looking for a very quick bit on of advice on how to make some python code run. I'm a newbie to both VBA and Python, so i apologise if this is very easy but i'm about to tear my hair out after googling for the last 3 days. I have written a large python script which inside of it create

Python RPM package arch compatability

2006-10-18 Thread Christopher Taylor
Hello all, A quick question if I may. I'm running RHEL 4 on a x86_64 and I'm curious if any of the packages at http://www.python.org/download/releases/2.4/rpms/ would suite my setup. If they don't can I simply build from source and not overwrite /usr/bin/Python (for the same reasons as listed at

Re: Image.draft -- what are the modes that I can use?

2006-10-18 Thread abcd
Fredrik Lundh wrote: > to repeat myself: > > here's a tool that lets you use VNC to capture the screen, and then > convert > the result to a flash animation: > >http://www.unixuser.org/~euske/vnc2swf/ > > is there a way to make animated GIFs with python? vnc2swf is to much for w

Re: Save/Store whole class (or another object) in a file

2006-10-18 Thread alexLIGO
Hi, thanks for the reply,but unfortunately this does not work with the type of classes I am dealing with. When trying to pickle the class I get the following error: File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex raise TypeError("a class that defines __slots__ without " TypeErr

Re: Python RPM package arch compatability

2006-10-18 Thread Fredrik Lundh
Christopher Taylor wrote: > A quick question if I may. I'm running RHEL 4 on a x86_64 and I'm > curious if any of the packages at > http://www.python.org/download/releases/2.4/rpms/ would suite my > setup. > > If they don't can I simply build from source and not overwrite > /usr/bin/Python (for t

How to execute a linux command by python?

2006-10-18 Thread haishan chang
How to execute a linux command by python? for example: execute "ls"  or "useradd oracle" Who can help me? thank you! -- http://mail.python.org/mailman/listinfo/python-list

Re: Flexable Collating (feedback please)

2006-10-18 Thread Ron Adam
[EMAIL PROTECTED] wrote: > > On Oct 18, 2:42 am, Ron Adam <[EMAIL PROTECTED]> wrote: >> I put together the following module today and would like some feedback on any >> obvious problems. Or even opinions of weather or not it is a good approach. > ,,, > def __call__(self, a, b): > ""

Re: Python RPM package arch compatability

2006-10-18 Thread Christopher Taylor
So just build it from source and use make altinstall instead? That simple huh? Will I need to do anything else to make sure things are put in their correct place? Respectfully, Christopher Taylor On 10/18/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Christopher Taylor wrote: > > > A quick que

Re: Image.draft -- what are the modes that I can use?

2006-10-18 Thread abcd
fredrik, in other posts you have mentioned the use of gifmaker. i have tried that with the following: I am using gifmaker.py from PIL v1.1.5 on python 2.4.1. CODE import ImageGrab, gifmaker seq = [] while keepOnGoing: im =

Re: Save/Store whole class (or another object) in a file

2006-10-18 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > thanks for the reply,but unfortunately this does not work with the type > of classes I am dealing with. When trying to pickle the class I get the > following error: > > File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex > raise TypeError("a class that def

Re: MemoryError - IMAP retrieve self._sock.recv(recv_size)

2006-10-18 Thread Stephen G
Fredrik, Thanks for the response. I did see that, but having been dated 2005 I thought that it might have been patched. I am also sometimes getting the same problem with the urllib.py module. T his may have to do with the interaction between Python and the mobile optimization client that I

Re: Restart a Python COM Server

2006-10-18 Thread olsongt
[EMAIL PROTECTED] wrote: > Hello all. > I am desperately in need for you help guys. Here is the story: > 1- I have created a small simple COM serve with python (along the lines > read in Win32 Programming with python). > 2- If I start the server and call a function from VBE everything works > fine

Re: a little about regex

2006-10-18 Thread Ant
Rob Wolfe wrote: ... > def filter(adr):# note that "filter" is a builtin function also > import re > > allow = re.compile(r'.*(?|$)') # negative lookbehind > deny = re.compile(r'.*\.com\.my(>|$)') > cnt = 0 > if deny.search(adr): cnt += 1 > if allow.search(adr): cnt +=

Re: How to execute a linux command by python?

2006-10-18 Thread Fredrik Lundh
haishan chang wrote: > How to execute a linux command by python? > for example: execute "ls" or "useradd oracle" > Who can help me? start here: http://www.python.org/doc/lib/ -- http://mail.python.org/mailman/listinfo/python-list

Re: MemoryError - IMAP retrieve self._sock.recv(recv_size)

2006-10-18 Thread Fredrik Lundh
Stephen G wrote: > I am hesitant to make any changes to the python libraries as > I need to distribute these scripts with a standard Python install. well, you could at least check if the suggestions in that thread makes the problem go away... (if so, shipping a patched version with your progra

Re: Save/Store whole class (or another object) in a file

2006-10-18 Thread Michele Simionato
[EMAIL PROTECTED] wrote: > Hi, > > thanks for the reply,but unfortunately this does not work with the type > of classes I am dealing with. When trying to pickle the class I get the > following error: > > File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex > raise TypeError("a class t

Dictionaries

2006-10-18 Thread Lad
How can I add two dictionaries into one? E.g. a={'a:1} b={'b':2} I need the result {'a':1,'b':2}. Is it possible? Thank you L. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to execute a linux command by python?

2006-10-18 Thread Fredrik Lundh
Fredrik Lundh wrote: > start here: > > http://www.python.org/doc/lib/ make sure you skim though the *entire* list. when you've done that, see the "process management" section in the "os" module documentation (make sure to read the entire page before you decide which API to use), and als

Re: Dictionaries

2006-10-18 Thread Simon Brunning
On 18 Oct 2006 08:24:27 -0700, Lad <[EMAIL PROTECTED]> wrote: > How can I add two dictionaries into one? > E.g. > a={'a:1} > b={'b':2} > > I need > > the result {'a':1,'b':2}. >>> a={'a':1} >>> b={'b':2} >>> a.update(b) >>> a {'a': 1, 'b': 2} -- Cheers, Simon B [EMAIL PROTECTED] http://www.brunn

Re: doctest quiet again before exit how

2006-10-18 Thread p . lavarre
> ... every run of doctest after the first is verbose ... > *** DocTestRunner.merge: '__main__' in both testers; summing outcomes. Another path to the same bug: import doctest print doctest.testfile(__file__, verbose=False) print doctest.testfile(__file__, verbose=False) Mystifiedly yours, rank

Re: Dictionaries

2006-10-18 Thread Gary Herron
Lad wrote: > How can I add two dictionaries into one? > E.g. > a={'a:1} > b={'b':2} > > I need > > the result {'a':1,'b':2}. > > Is it possible? > > Thank you > L. > > Yes, use update. Beware that this modifies a dictionary in place rather than returning a new dictionary. >>> a={'a':1} >>> b={

Re: Dictionaries

2006-10-18 Thread Tim Chase
> How can I add two dictionaries into one? > E.g. > a={'a:1} > b={'b':2} > > I need > > the result {'a':1,'b':2}. >>> a.update(b) >>> a {'a':1,'b':2} -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: Win32 python and excel macros

2006-10-18 Thread John Coleman
[EMAIL PROTECTED] wrote: > Hi Experts, > > Looking for a very quick bit on of advice on how to make some python > code run. I'm a newbie to both VBA and Python, so i apologise if this > is very easy but i'm about to tear my hair out after googling for the > last 3 days. > > I have written a large

Re: Win32 python and excel macros

2006-10-18 Thread Mike P
Thanks for your advice on this matter, I'm actually using Excel 2003!! so it shows how much i know! i did manage to get the prog to run with the line xl.Application.Run("CTP.xla!sheet1.CTP") but it didn't do anything... i'm guessing it is along the lines of wht you were saying earlier about big

Re: Dictionaries

2006-10-18 Thread Boris Borcic
dict(a.items() + b.items()) Lad wrote: > How can I add two dictionaries into one? > E.g. > a={'a:1} > b={'b':2} > > I need > > the result {'a':1,'b':2}. > > Is it possible? -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionaries

2006-10-18 Thread Steven D'Aprano
On Wed, 18 Oct 2006 08:24:27 -0700, Lad wrote: > How can I add two dictionaries into one? > E.g. > a={'a:1} > b={'b':2} > > I need > > the result {'a':1,'b':2}. > > Is it possible? What should the result be if both dictionaries have the same key? a={'a':1, 'b'=2} b={'b':3} should the result

Re: Win32 python and excel macros

2006-10-18 Thread Mike P
After just running trying that update it hits the macro perfectly but hten i get an error message after i type in a couple of values.. as per below Traceback (most recent call last): File "", line 148, in ? File ">", line 14, in Run File "C:\Python24\Lib\site-packages\win32com\client\dynamic

Re: Image.draft -- what are the modes that I can use?

2006-10-18 Thread Brett Hoerner
abcd wrote: > ... Are you sure you can't use VNC? An animated GIF based on full-screen grabs will be amazingly huge and have very low color quality at the same time. Installing VNC on Windows should take you about 30 seconds, honest. Or is this for some sort of project where you can't use anyth

Install from source on a x86_64 machine

2006-10-18 Thread Christopher Taylor
Hello all, Being relatively new to linux I'm a little confused about what options I need to use to build python from source. Currently, I have python installed as part of the inital RHEL4 load located at /usr/bin/Python and /usr/bin/Python2.3 . Some of the files are located in /usr/lib64/Python2

Re: Image.draft -- what are the modes that I can use?

2006-10-18 Thread abcd
Brett Hoerner wrote: > Are you sure you can't use VNC? An animated GIF based on full-screen > grabs will be amazingly huge and have very low color quality at the > same time. > > Installing VNC on Windows should take you about 30 seconds, honest. > > Or is this for some sort of project where you c

Re: Dictionaries

2006-10-18 Thread Lad
Tim Chase wrote: > > How can I add two dictionaries into one? > > E.g. > > a={'a:1} > > b={'b':2} > > > > I need > > > > the result {'a':1,'b':2}. > > >>> a.update(b) > >>> a > {'a':1,'b':2} > > -tkc Thank you ALL for help. However It does not work as I would need. Let's suppose I have a={'c'

Re: Dictionaries

2006-10-18 Thread Tim Chase
> However It does not work as I would need. > Let's suppose I have > > a={'c':1,'d':2} > b={'c':2} > but > a.update(b) > will make > {'c': 2, 'd': 2} > > and I would need > {'c': 3, 'd': 2} Ah...a previously omitted detail. There are likely a multitude of ways to do it. However, the one th

Re: Dictionaries

2006-10-18 Thread Lad
Steven, Thank you for your reply and question. > > What should the result be if both dictionaries have the same key? The answer: the values should be added together and assigned to the key That is {'a':1, 'b':5} ( from your example below) Is there a solution? Thanks for the reply L. > > a={'a':

Re: Dictionaries

2006-10-18 Thread Rob De Almeida
Lad wrote: > Let's suppose I have > > a={'c':1,'d':2} > b={'c':2} > but > a.update(b) > will make > {'c': 2, 'd': 2} > > and I would need > {'c': 3, 'd': 2} > > (because `c` is 1 in `a` dictionary and `c` is 2 in `b` dictionary, so > 1+2=3) > > How can be done that? dict([(k, a.get(k, 0) + b.ge

Re: Looking for assignement operator

2006-10-18 Thread Robert Kern
Bruno Desthuilliers wrote: > Tommi wrote: > (please don't top-post - corrected) >> >> Alexander Eisenhuth wrote: >>> Hello, >>> >>> is there a assignement operator, that i can overwrite? >>> >>> class MyInt: >>> def __init__(self, val): >>> assert(isinstance(val, int)) >>>

Re: Dictionaries

2006-10-18 Thread Fredrik Lundh
Lad wrote: > The answer: the values should be added together and assigned to the key > That is > {'a':1, 'b':5} > ( from your example below) > > Is there a solution? have you tried coding a solution and failed, or are you just expecting people to code for free? -- http://mail.python.org/mai

Re: portable extensions options for external libraries

2006-10-18 Thread Robert Kern
Alexandre Guimond wrote: > so my question is: what is the right way of specifying extensions > options (include_dirs, libraries, library_dirs) so that they are > portable between windows and linux? i'm thinking environment variables. The user can already use command-line options and CFLAGS if he

Re: matrix Multiplication

2006-10-18 Thread Sssasss
David wrote: > Il 18 Oct 2006 04:17:29 -0700, Sssasss ha scritto: > > > hi evrybody! > > > > I wan't to multiply two square matrixes, and i don't understand why it > > doesn't work. > Can I suggest a little bit less cumbersome algorithm? > > def multmat2(A,B): > "A*B" > if len(A)!=len(B):

Re: matrix Multiplication

2006-10-18 Thread Sssasss
Roberto Bonvallet wrote: > Sssasss wrote: > > hi evrybody! > > > > I wan't to multiply two square matrixes, and i don't understand why it > > doesn't work. > > Could you explain me? > > > > def multmat(A,B): > >"A*B" > >if len(A)!=len(B): return "error" > > Wrong validation here: you _can

Re: Dictionaries

2006-10-18 Thread Steven D'Aprano
On Wed, 18 Oct 2006 09:31:50 -0700, Lad wrote: > > Steven, > Thank you for your reply and question. > >> >> What should the result be if both dictionaries have the same key? > The answer: the values should be added together and assigned to the key > That is > {'a':1, 'b':5} > ( from your example

Re: How to execute a linux command by python?

2006-10-18 Thread Daniel Nogradi
> > How to execute a linux command by python? > > for example: execute "ls" or "useradd oracle" > > Who can help me? > > start here: > > http://www.python.org/doc/lib/ > And continue here: http://www.python.org/doc/lib/os-process.html -- http://mail.python.org/mailman/listinfo/python-list

Help: Python2.3 & Python2.4 on RHEL4 x86_64

2006-10-18 Thread Christopher Taylor
RHEL comes with Python2.3 installed. A program I need to install requires Python2.4 So I got Python2.4 from source and compiled it up. I configured it with --prefix=/usr --exec-prefix=/usr and --enable-unicode=ucs4 . I then make'd it and then make altinstall so that it didn't overwrite the /us

  1   2   3   >