Re: Scanning a file

2005-10-28 Thread Fredrik Lundh
Mike Meyer wrote: > Did you do timings on it vs. mmap? Having to copy the data multiple > times to deal with the overlap - thanks to strings being immutable - > would seem to be a lose, and makes me wonder how it could be faster > than mmap in general. if you use "mmap" to read large files sequen

Understanding the arguments for SubElement factory in ElementTree

2005-10-28 Thread mirandacascade
Can the **extra argument in the SubElement() factory in ElementTree be used to set the text property? Example: Want the text associated with the tag to be xyz. xyz rather than: root = Element('root') subroot = SubElement(root, 'subroot') subroot.text = 'xyz' Was wondering whether this code

Debugging with SciTE

2005-10-28 Thread jim . eggleston
I just figured out a reasonably decent way to use pdb in SciTE for debugging Python scripts. Debugging takes place in the SciTE output window. I have only tested this with SciTE on Windows. Here are the pieces you need: 1. Create a debug.py script file (I save this in c:\usr\python\scripts): impo

Re: Scanning a file

2005-10-28 Thread Mike Meyer
"Paul Watson" <[EMAIL PROTECTED]> writes: > Here is a better one that counts, and not just detects, the substring. This > is -much- faster than using mmap; especially for a large file that may cause > paging to start. Using mmap can be -very- slow. > > #!/usr/bin/env python > import sys > > fn

Re: Microsoft Hatred FAQ

2005-10-28 Thread Mike Meyer
"David Schwartz" <[EMAIL PROTECTED]> writes: > "Mike Meyer" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> "David Schwartz" <[EMAIL PROTECTED]> writes: >>> "Mike Meyer" <[EMAIL PROTECTED]> wrote in message >>> news:[EMAIL PROTECTED] >> Maybe true, maybe not - but it doesn't matte

Re: Generic utility class for passing data

2005-10-28 Thread [EMAIL PROTECTED]
ok, so that is simply a wrapper of a dict and has nothing to do with parameter passing and it can be used anyway within the receiving function(or basically anyway I want to say x.key rather than x[key]). def f(**kwargs): x = Bunch(kwargs) x.some_key_as_attribute = something Robert Kern wro

Re: Generic utility class for passing data

2005-10-28 Thread Robert Kern
[EMAIL PROTECTED] wrote: > just curious, since python don't care what object is being passing > around and the receiving function has to 'decode' it(be it tuple or > dict or whatever). What is the advantage of dummy class ? The convenience of the attribute notation. For the record, my favorite va

Re: Generic utility class for passing data

2005-10-28 Thread [EMAIL PROTECTED]
just curious, since python don't care what object is being passing around and the receiving function has to 'decode' it(be it tuple or dict or whatever). What is the advantage of dummy class ? Alex Martelli wrote: > Gordon Airporte <[EMAIL PROTECTED]> wrote: > > > I'm wondering if this is might be

Re: pickling class instances with __slots__

2005-10-28 Thread Alex Martelli
Alex <[EMAIL PROTECTED]> wrote: ... > I have a series of new classes with child-parent relationship and each > has unique __slots__. They don't have __dict__ . I need to be able to > pickle and unpickle them. As far as I could understand, I need to > provide __getstate__ and __setstate__ metho

Re: tkinter blues (greens, reds, ...)

2005-10-28 Thread Sean McIlroy
hi ron changing from english words to hexadecimal numerals did the trick for me, so everything's cool now. thanks for looking at it. peace -- http://mail.python.org/mailman/listinfo/python-list

pickling class instances with __slots__

2005-10-28 Thread Alex
I would greatly appreciate an advice on the following matter that was very much discussed circa 2002 but in all this discussion I could not find the final answer with a code example. Neither I can find it in Python documentation. I have a series of new classes with child-parent relationship and e

Re: suggestions between these two books

2005-10-28 Thread Alex Martelli
Micah Elliott <[EMAIL PROTECTED]> wrote: > On Oct 26, John Salerno wrote: > > Hi all. I'm fairly new to programming and I thought I'd like to try > > Python. I'm trying to decide between these two books: > > > > Learning Python (O'Reilly) > > Beginning Python: From Novice to Professional (APress)

Re: Scanning a file

2005-10-28 Thread Paul Watson
"Paul Watson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >>I want to scan a file byte for byte for occurences of the the four byte >> pattern 0x0100. I've tried with this: >> >> # start >> import sys >> >> numCha

Re: Why doesn't this work? :)

2005-10-28 Thread Alex Martelli
Jeremy Moles <[EMAIL PROTECTED]> wrote: > Am I misunderstanding something fundamental about the builtin __* > functions? Can they not be "static?" They can and must be static when their specification say they are (e.g., __new__) and they cannot and must not be static when their specification says

Re: Opaque documentation

2005-10-28 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote: > "Ben Sizer" <[EMAIL PROTECTED]> writes: > > Documentation is often a problem with Python and its libraries, sadly. > > The same almost certainly goes for most open source projects. > > You over-specified the last clause. It should say "most software > proj

Re: Scanning a file

2005-10-28 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote: ... > Except if you can't read the file into memory because it's to large, > there's a pretty good chance you won't be able to mmap it either. To > deal with huge files, the only option is to read the file in in > chunks, count the occurences in each chunk,

pickling classes with __slots__

2005-10-28 Thread Alex Neyfakh
I would greatly appreciate an advice on the following matter that was very much discussed circa 2002 but in all this discussion I could not find the final answer with a code example. I have a series of new classes with child-parent relationship and each has unique __slots__. They don't have __d

Re: Newbie question: string replace

2005-10-28 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 28 Oct 2005 12:27:36 -0700, [EMAIL PROTECTED] wrote: > > > hm...Is there a way to get rid of the newline in "print"? > > Yes, by using another language *wink* Ending the print statement with a comma also works;-) > Or, instead of using pri

Re: Newbie question: string replace

2005-10-28 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > > So how to overwrite the config file directly in script.py instead of > > running script.py with two params? > > Don't overwrite the file directly. Save a copy, then rename it. That See module fileinput

Re: How do I sort these?

2005-10-28 Thread Alex Martelli
Paul Rubin wrote: > "KraftDiner" <[EMAIL PROTECTED]> writes: > > In C++ you can specify a comparision method, how can I do this with > > python... > > Yes, see the docs. Just pass a comparison func to the sort method. Or, better, pass a key-extraction function, that's

Re: Generic utility class for passing data

2005-10-28 Thread Alex Martelli
Gordon Airporte <[EMAIL PROTECTED]> wrote: > I'm wondering if this is might be bad practice. Sometimes when I need to I hope not, 'cuz I suggested that years ago on the Cookbook (under the name of Bunch) with several successive refinements. > class Dummy: > pass > > Then when I need to pa

Generic utility class for passing data

2005-10-28 Thread Gordon Airporte
I'm wondering if this is might be bad practice. Sometimes when I need to pass around several pieces of datum I will put them in a tuple, then when I need to use them in a receiving function I get them out with subscripts. The problem is that the subscript number is completely meaningless and I

Re: Python-list Digest, Vol 25, Issue 522

2005-10-28 Thread Jay Parlar
On Oct 28, 2005, at 9:20 AM, pywrote: From what I have seen Python does not come with an snmp module built in, can anyone suggest some other SNMP module (preferably one you have used/experienced)..I have googled and seen yapsnmp and pysnmp (which seem to be the two most active SNMP modules). W

Re: Print to printer

2005-10-28 Thread SPE - Stani's Python Editor
You should be more specific. What do you want to print? Text, images, ... If you want a cross platform solution you could use wxPython: http://wiki.wxwidgets.org/docbrowse.cgi/wxwin_printingoverview.html#printingoverview For text you could use wxHtmlEasyPrinting: http://wiki.wxpython.org/index.cgi

Re: Expanding Python as a macro language

2005-10-28 Thread SPE - Stani's Python Editor
Well on Windows I used some time ago for similar tasks the wmi module. It is able to analyse running programs, press buttons and activate menu items. As you didn't mention it, you might have a look at it. It works pretty well. http://tgolden.sc.sabren.com/python/wmi.html For linux I don't know.

Re: tkinter blues (greens, reds, ...)

2005-10-28 Thread Ron Adam
Sean McIlroy wrote: > i'm using the canned colors ("pink", "orange", etc). should i try > changing to explicit color specifications to see if that makes a > difference? i'm not sure what the other guy meant by a "soft toy", but > i take it the idea is to try and construct a correctness proof for

Automatically creating a HOME environ variable on Windows?

2005-10-28 Thread jim . eggleston
Windows doesn't have a HOME environment variable, but it does have HOMEDRIVE and HOMEPATH. Could Windows versions of Python automatically populate os.environ with HOME, where HOME = os.path.join(os.environ['HOMEDRIVE'], os.environ['HOMEPATH'])? If this was done, then modules such as pdb, which loa

Re: Microsoft Hatred FAQ

2005-10-28 Thread David Schwartz
"Mike Meyer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "David Schwartz" <[EMAIL PROTECTED]> writes: >> "Mike Meyer" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> The quote about the mafia doesn't compare MS's actions to "actual use >>> of force". >>

Oh what a twisted thread we weave....

2005-10-28 Thread GregM
Hi First off I'm not using anything from Twisted. I just liked the subject line :) The folks of this list have been most helpful before and I'm hoping that you'll take pity on a the dazed and confused. I've read stuff on this group and various website and book until my head is spinning... Here i

Expanding Python as a macro language

2005-10-28 Thread qwweeeit
Hi all, when I moved from Windows to Linux I choosed Python as my language of reference and as GUI, Qt (not much investigated up to now). Till now I didn't regret but one thing: Python can't act as a macro language and so you are obliged to revert to Windows to use programs like AutoIt, Macro

Re: ? Pythoncard

2005-10-28 Thread Lee Harr
On 2005-10-28, LenS <[EMAIL PROTECTED]> wrote: > Never mind I figured out my on stupid mistake > How about posting a very simple explanation of what you did wrong and how you fixed it, instead of leaving the next person who has this problem with a dead end? Thanks. -- http://mail.python.org/ma

Re: Automatic binding of **kwargs to variables

2005-10-28 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > I have a very long list of parameters coming from a web form to my > method foo(self, **kwargs) > > I would like to avoid manually binding the variables to the values > coming through the **kwargs dictionary, just to keep the code cleaner, > I'd lik

Re: How do I sort these?

2005-10-28 Thread Steven D'Aprano
On Fri, 28 Oct 2005 13:42:49 -0700, KraftDiner wrote: > unzip doesn't seem to work for me... Nor for me: >>> unzip Traceback (most recent call last): File "", line 1, in ? NameError: name 'unzip' is not defined I don't think it exists. But it is easy enough to create: def unzip(L): """

Re: Newbie question: string replace

2005-10-28 Thread Steven D'Aprano
On Fri, 28 Oct 2005 12:27:36 -0700, [EMAIL PROTECTED] wrote: > hm...Is there a way to get rid of the newline in "print"? Yes, by using another language *wink* Or, instead of using print, use sys.stdout.write(). -- Steven. -- http://mail.python.org/mailman/listinfo/python-list

Re: Scanning a file

2005-10-28 Thread Steven D'Aprano
On Fri, 28 Oct 2005 06:22:11 -0700, [EMAIL PROTECTED] wrote: > Which is quite fast. The only problems is that the file might be huge. What *you* call huge and what *Python* calls huge may be very different indeed. What are you calling huge? > I really have no need for reading the entire file int

Re: Scanning a file

2005-10-28 Thread Steven D'Aprano
On Fri, 28 Oct 2005 15:29:46 +0200, Björn Lindström wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > >> f = open("filename", "rb") >> s = f.read() >> sub = "\x00\x00\x01\x00" >> count = s.count(sub) >> print count > > That's a lot of lines. This is a bit off topic, but I just can't sta

Re: How to replace all None values with the string "Null" in a dictionary

2005-10-28 Thread Steven D'Aprano
On Fri, 28 Oct 2005 05:23:00 -0700, dcrespo wrote: >> I think it would be time for you to read the Fine Manual... > > hi, thanks for your answer... I really did it the same way you > suggested, but I forgot to tell you that I wanted to get a better way > for doing it. What was wrong with the way

Re: Scanning a file

2005-10-28 Thread Paul Watson
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I want to scan a file byte for byte for occurences of the the four byte > pattern 0x0100. I've tried with this: > > # start > import sys > > numChars = 0 > startCode = 0 > count = 0 > > inputFile = sys.stdin > > while True: >ch =

Automatic binding of **kwargs to variables

2005-10-28 Thread [EMAIL PROTECTED]
Hi all, I have a very long list of parameters coming from a web form to my method foo(self, **kwargs) I would like to avoid manually binding the variables to the values coming through the **kwargs dictionary, just to keep the code cleaner, I'd like to bind them automatically I was adviced agains

Re: newstyle classes and __getattribute__

2005-10-28 Thread Stefan Sonnenberg-Carstens
Stefan Sonnenberg-Carstens schrieb: > James Stroud schrieb: > >> On Friday 28 October 2005 14:26, Stefan Sonnenberg-Carstens wrote: >> >>> Hi there, >> >> >> [..clip..] >> >>> Now, I do this: >>> >>> class T(object): >>> def __init__(self,name='',port=80): >>> self.name=name >>>

Re: How do I sort these?

2005-10-28 Thread Amaury
Sam Pointon a écrit : >>unzip doesn't seem to work for me... > > > It's not a part of the standard Python distribution, but this is a > naive implementation (it doesn't react well to the list's contents > having different lengths). > > def unzip(seq): > result = [[] for i in range(len(seq[0]

Re: newstyle classes and __getattribute__

2005-10-28 Thread Stefan Sonnenberg-Carstens
James Stroud schrieb: > On Friday 28 October 2005 14:26, Stefan Sonnenberg-Carstens wrote: > >>Hi there, > > [..clip..] > >>Now, I do this: >> >>class T(object): >> def __init__(self,name='',port=80): >> self.name=name >> self.port=port >> def __getattribute__

Re: newstyle classes and __getattribute__

2005-10-28 Thread James Stroud
On Friday 28 October 2005 14:26, Stefan Sonnenberg-Carstens wrote: > Hi there, [..clip..] > Now, I do this: > > class T(object): > def __init__(self,name='',port=80): > self.name=name > self.port=port > def __getattribute__(self,key): > if key==

Re: newstyle classes and __getattribute__

2005-10-28 Thread Stefan Sonnenberg-Carstens
Stefan Sonnenberg-Carstens schrieb: > Hi there, > I'm facing some strange things - but maybe only me is strange - anyway... > > i wrote the following code: > > > +++ > class T(object): > def __init__(self,name='',port=80): > self.name=name > self.port=port > +++ > > looks fi

Re: tkinter blues (greens, reds, ...)

2005-10-28 Thread Sean McIlroy
i'm using the canned colors ("pink", "orange", etc). should i try changing to explicit color specifications to see if that makes a difference? i'm not sure what the other guy meant by a "soft toy", but i take it the idea is to try and construct a correctness proof for the script, and see what keeps

newstyle classes and __getattribute__

2005-10-28 Thread Stefan Sonnenberg-Carstens
Hi there, I'm facing some strange things - but maybe only me is strange - anyway... i wrote the following code: +++ class T(object): def __init__(self,name='',port=80): self.name=name self.port=port +++ looks fine - to me. Now I can do: >>> t = T(name

Re: ? Pythoncard

2005-10-28 Thread LenS
Never mind I figured out my on stupid mistake Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I sort these?

2005-10-28 Thread Sam Pointon
> unzip doesn't seem to work for me... It's not a part of the standard Python distribution, but this is a naive implementation (it doesn't react well to the list's contents having different lengths). def unzip(seq): result = [[] for i in range(len(seq[0]))] for item in seq: for in

Re: Microsoft Hatred FAQ

2005-10-28 Thread Mike Meyer
"David Schwartz" <[EMAIL PROTECTED]> writes: > "Mike Meyer" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> The quote about the mafia doesn't compare MS's actions to "actual use >> of force". > I'm sorry, that's just absurd. I won't speculate on what motivates you > to engage

Re: How do I sort these?

2005-10-28 Thread Paul Rubin
"KraftDiner" <[EMAIL PROTECTED]> writes: > In C++ you can specify a comparision method, how can I do this with > python... Yes, see the docs. Just pass a comparison func to the sort method. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter Frame Size

2005-10-28 Thread James Stroud
On Friday 28 October 2005 11:00, Tuvas wrote: > Okay. I have alot of items that are put on the basic frame already, > using a grid method. Will this change anything? It shouldn't. For example from Tkinter import * app = Tk() app.geometry("%dx%d%+d%+d" % (600, 400, 0, 0)) f = Frame(app) f.pack() L

Re: How do I sort these?

2005-10-28 Thread KraftDiner
unzip doesn't seem to work for me... -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I sort these?

2005-10-28 Thread KraftDiner
In C++ you can specify a comparision method, how can I do this with python... Say for instance the first list was a dictionary and I wanted to sort on one of the keys in the dictionary? -- http://mail.python.org/mailman/listinfo/python-list

Re: XML Tree Discovery (script, tool, __?)

2005-10-28 Thread uche . ogbuji
""" I was looking for something similar (XML to DTD inference) but I didn't find anything related in python. Trang (http://www.thaiopensource.com/relaxng/trang-manual.html#introduction), on the other hand seems impressive after a few non-trivial tests. It would be neat to have it ported in python,

Re: OpenSSL in Python

2005-10-28 Thread Sybren Stuvel
dcrespo enlightened us with: > I've been looking for OpenSSL for python. I found pyOpenSSL, but it > requires the OpenSSL library, which I only found on > http://www.openssl.org/, but don't know how to install. Ehm... wouldn't your question then not be more appropriate on the OpenSSL newsgroup/mai

Re: How do I sort these?

2005-10-28 Thread KraftDiner
yes... Thats the idea... -- http://mail.python.org/mailman/listinfo/python-list

Re: Microsoft Hatred FAQ

2005-10-28 Thread Paul Rubin
"David Schwartz" <[EMAIL PROTECTED]> writes: > Is it your position that Micorosoft's monopoly was illegal when they > first acquired it? It's utterly irrelevant whether it was illegal when they acquired it. The law is against acquiring OR MAINTAINING a monopoly by anticompetitive means. Tha

Re: popen2

2005-10-28 Thread g.franzkowiak
David Wahler schrieb: > g.franzkowiak wrote: > >>I start a process in my application with popen2.popen3('MyOtherProcess'). >>That's ok, but what can I do if the other process is running ? >>Can I fetch some information and start with that ? >> >>gerd > > > It's not clear what you're asking for.

? Pythoncard

2005-10-28 Thread LenS
I have created a small gui stub as follows using Pythoncard: c:\myhome lmsgui.py lmsgui.rsrc.py When I try to run I get the following error: (Errno2) no such file or directory lmsqui.rsrc.py I understand why I am getting the error the question is how do I fix this so it looks in the p

Re: Microsoft Hatred FAQ

2005-10-28 Thread David Schwartz
"Lasse Vågsæther Karlsen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ok, let me just make my opinion very clear on this and then I'll just > leave this thread altogether. > > I think you are comparing apples and oranges so whatever conclusion you > manage to draw from that i

drag/move image from staticBitmap control?

2005-10-28 Thread James Hu
Hi, all gurus,   I have an application to show bitmap image on one wx.staticBitmap control area, I can display part of the image, or the whole image(detail is unclear), But I would like to use mouse to drag/move the image inside thewx.staticBitmap control when only part image on the scre

Re: Microsoft Hatred FAQ

2005-10-28 Thread David Schwartz
"Mike Meyer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The quote about the mafia doesn't compare MS's actions to "actual use > of force". I'm sorry, that's just absurd. I won't speculate on what motivates you to engage in such crazy distortion. Of course the quote about

Print to printer

2005-10-28 Thread avnit
I can't seem to figure out how to print with my printer using python. I'm using Mac OSX 10.4. I was thinking maybe something with applescript. Does anyone know? -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question: string replace

2005-10-28 Thread [EMAIL PROTECTED]
Got it, thanks all! -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question: string replace

2005-10-28 Thread [EMAIL PROTECTED]
hm...Is there a way to get rid of the newline in "print"? -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't this work? :)

2005-10-28 Thread Jeremy Moles
On Fri, 2005-10-28 at 14:50 -0400, Chris Lambacher wrote: > I think what you really want is: > > try: > # this will fail and be caught > # below, w > import foobar > > except ImportError, error: > class foobarclass: > def __getattr__(*args, **kargs): >

Re: Typing tutor help script needed, please

2005-10-28 Thread RedGrittyBrick
> Throw wrote: >> I must be able to extract words which contain only >> certain letters (they need not contain all of those letters, >> but they may not contain any other letters). SPE - Stani's Python Editor wrote: > #---Input data > > #List of words; every word or sentence on one line > #

Re: Typing tutor help script needed, please

2005-10-28 Thread Anno Siegel
Throw <[EMAIL PROTECTED]> wrote in comp.lang.perl.misc: > > G'day everyone! > > I would like to design typing tutor exercises for Afrikaans (and other > languages possibly). This is for a GPL project. For this, I need a > script that can extract words from a long list of words, based on which >

Re: Newbie question: string replace

2005-10-28 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Now it works: > rex = re.compile(r'(^.*username *=[^"]*")([^"]*)(".*$)') > for line in fileinput.input(FILE, inplace=1): > m = rex.match(line) > if m is not None: > line = "%s%s%s\n" % (m.group(1), new_name, m.group(3)) > pr

Re: Opaque documentation

2005-10-28 Thread Mike Meyer
"Ben Sizer" <[EMAIL PROTECTED]> writes: > Documentation is often a problem with Python and its libraries, sadly. > The same almost certainly goes for most open source projects. You over-specified the last clause. It should say "most software projects." http://www.mired.

Re: How do I sort these?

2005-10-28 Thread Diez B. Roggisch
KraftDiner wrote: > I have two lists. > I want to sort by a value in the first list and have the second list > sorted as well... Any suggestions on how I should/could do this? I guess you mean that you have two lists of same size where each index position pointing to corrsponding items - like two

Re: How do I sort these?

2005-10-28 Thread Steve Holden
KraftDiner wrote: > I have two lists. > I want to sort by a value in the first list and have the second list > sorted as well... Any suggestions on how I should/could do this? > >>> first = [1, 3, 5, 7, 9, 2, 4, 6, 8] >>> second = ['one', 'three', 'five', 'seven', 'nine', 'two', 'four', 'six',

Re: OEM character set issue

2005-10-28 Thread Kent Johnson
Dennis Lee Bieber wrote: > On Fri, 28 Oct 2005 15:55:56 +0200, "Ladvánszky Károly" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > >>On my hungarian Win2k, some of the accented characters of the file names >>appear incorrectly when Python is driven from the command line. Ho

Re: Scanning a file

2005-10-28 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > I want to scan a file byte for byte for occurences of the the four byte > pattern 0x0100. data = sys.stdin.read() print data.count('\x00\x00\x01\x00') Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: tkinter blues (greens, reds, ...)

2005-10-28 Thread Ron Adam
Steve Holden wrote: > Sean McIlroy wrote: > >> hi all >> >> i recently wrote a script that implements a puzzle. the interface >> mostly consists of a bunch of colored disks on a tkinter canvas. the >> problem is that the disks change their colors in ways other than the >> way they're supposed t

Re: Typing tutor help script needed, please

2005-10-28 Thread Mike Meyer
"Throw" <[EMAIL PROTECTED]> writes: > G'day everyone! > > I would like to design typing tutor exercises for Afrikaans (and other > languages possibly). This is for a GPL project. For this, I need a > script that can extract words from a long list of words, based on which > letters those words co

Re: Why doesn't this work? :)

2005-10-28 Thread Chris Lambacher
I think what you really want is: try: # this will fail and be caught # below, w import foobar except ImportError, error: class foobarclass: def __getattr__(*args, **kargs): return None foobar = foobarclass() print fo

Re: urllib2 problem

2005-10-28 Thread John J. Lee
"Jeremy Martin" <[EMAIL PROTECTED]> writes: [...] > website. I originally just used urllib.urlopen and everything worked > fine on my Windows PC at work. I tried the same script at home on my > Fedora COre 3 box using python 2.4, and whenever I try to connect to > the site I get the (110, Connec

How do I sort these?

2005-10-28 Thread KraftDiner
I have two lists. I want to sort by a value in the first list and have the second list sorted as well... Any suggestions on how I should/could do this? -- http://mail.python.org/mailman/listinfo/python-list

Re: Scanning a file

2005-10-28 Thread Mike Meyer
Andrew McCarthy <[EMAIL PROTECTED]> writes: > On 2005-10-28, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> I'm now down to: >> >> f = open("filename", "rb") >> s = f.read() >> sub = "\x00\x00\x01\x00" >> count = s.count(sub) >> print count >> >> Which is quite fast. The only problems is that the

Re: SNMP

2005-10-28 Thread Larry Bates
py wrote: >>From what I have seen Python does not come with an snmp module built > in, can anyone suggest some other SNMP module (preferably one you have > used/experienced)..I have googled and seen yapsnmp and pysnmp (which > seem to be the two most active SNMP modules). > > Thanks > Google tu

Re: popen2

2005-10-28 Thread David Wahler
g.franzkowiak wrote: > I start a process in my application with popen2.popen3('MyOtherProcess'). > That's ok, but what can I do if the other process is running ? > Can I fetch some information and start with that ? > > gerd It's not clear what you're asking for. Could you please clarify? -- David

Re: Typing tutor help script needed, please

2005-10-28 Thread SPE - Stani's Python Editor
#---Input data #List of words; every word or sentence on one line #If from file: WORDS = open(fileName).readlines() WORDS = """\ Afrikaans Anna Bread red word bored python""".split('\n') #---Main program import re PATTERN = ['[^(%s)]+','[%s]+'] FILENAME= ['not_%s.txt','%s.txt']

Re: Newbie question: string replace

2005-10-28 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Now it works: > rex = re.compile(r'(^.*username *=[^"]*")([^"]*)(".*$)') > for line in fileinput.input(FILE, inplace=1): > m = rex.match(line) > if m is not None: > line = "%s%s%s\n" % (m.group(1), new_name, m.group(3)) > print line > > But there

Re: tkinter blues (greens, reds, ...)

2005-10-28 Thread Steve Holden
Sean McIlroy wrote: > hi all > > i recently wrote a script that implements a puzzle. the interface > mostly consists of a bunch of colored disks on a tkinter canvas. the > problem is that the disks change their colors in ways other than the > way they're supposed to. it certainly isn't just a bug

Re: Tkinter Frame Size

2005-10-28 Thread Tuvas
Okay. I have alot of items that are put on the basic frame already, using a grid method. Will this change anything? -- http://mail.python.org/mailman/listinfo/python-list

Why doesn't this work? :)

2005-10-28 Thread Jeremy Moles
Jumping right into the code (which should speak for itself): # --- try: # this will fail and be caught # below, w import foobar except ImportError, error: class foobar: @staticmethod def __getattr

Re: Scanning a file

2005-10-28 Thread James Stroud
On Friday 28 October 2005 06:29, Björn Lindström wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > f = open("filename", "rb") > > s = f.read() > > sub = "\x00\x00\x01\x00" > > count = s.count(sub) > > print count > > That's a lot of lines. This is a bit off topic, but I just can't stand

Re: Tkinter Frame Size

2005-10-28 Thread James Stroud
On Friday 28 October 2005 10:38, Tuvas wrote: > I'm tyring to set the size of the window that is opened when you open a > Tkinter window, without much sucess. I have tried changing the heigth > and width atributes, but it doesn't do anything. I tried using the > grid_propagate command that I saw

Tkinter Frame Size

2005-10-28 Thread Tuvas
I'm tyring to set the size of the window that is opened when you open a Tkinter window, without much sucess. I have tried changing the heigth and width atributes, but it doesn't do anything. I tried using the grid_propagate command that I saw to use, but made the window even smaller... What can I d

Re: Newbie question: string replace

2005-10-28 Thread [EMAIL PROTECTED]
Now it works: rex = re.compile(r'(^.*username *=[^"]*")([^"]*)(".*$)') for line in fileinput.input(FILE, inplace=1): m = rex.match(line) if m is not None: line = "%s%s%s\n" % (m.group(1), new_name, m.group(3)) print line But there is an extra line break after each line in F

Re: How to translate python into C

2005-10-28 Thread Lawrence Oluyede
Il 2005-10-28, Johnny Lee <[EMAIL PROTECTED]> ha scritto: > Thanks, Szabolcs. In fact, I want to reproduce a crush on cygwin. I > used a session of python code to produce the crush, and want to > translate it into C and reproduce it. Is the tools provided by you help > with these issues? Of coz, I'

popen2

2005-10-28 Thread g.franzkowiak
I start a process in my application with popen2.popen3('MyOtherProcess'). That's ok, but what can I do if the other process is running ? Can I fetch some information and start with that ? gerd -- http://mail.python.org/mailman/listinfo/python-list

tkinter blues (greens, reds, ...)

2005-10-28 Thread Sean McIlroy
hi all i recently wrote a script that implements a puzzle. the interface mostly consists of a bunch of colored disks on a tkinter canvas. the problem is that the disks change their colors in ways other than the way they're supposed to. it certainly isn't just a bug in my script, since i can someti

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-28 Thread Christopher Subich
Steve Holden wrote: >> On Thu, 2005-10-27 at 14:00, Gregory Piñero wrote: >> >>> Not quite because if something(3) fails, I still want something(4) to >>> run. > Then the obvious extension: > > for i in range(20): >... > > but I get the idea that Gregory was thinking of different statement

Re: xml-rpc - adodb - None type - DateTime type

2005-10-28 Thread infidel
> I can replace all None values with the string 'Null', there's no > problem, but I can't detect the DateTime type object I retrieve from > the database. > > I have something like this: > def xmlrpc_function(): > conn = adodb.NewADOConnection('postgres') > conn.Connect(host,user,password,da

Re: SNMP

2005-10-28 Thread py
...also I am looking to work with windows, as well as linux. -- http://mail.python.org/mailman/listinfo/python-list

SNMP

2005-10-28 Thread py
>From what I have seen Python does not come with an snmp module built in, can anyone suggest some other SNMP module (preferably one you have used/experienced)..I have googled and seen yapsnmp and pysnmp (which seem to be the two most active SNMP modules). Thanks -- http://mail.python.org/mailman

Re: replace words

2005-10-28 Thread Scott David Daniels
Peter Otten wrote: > [EMAIL PROTECTED] wrote: > > >>What is the way for replacing in a string from . to . the sentence? >>for example: >>"been .taken. it may be .left. there, >>even if the .live coals were not. cleared" >>I want to do this-> replace(\.(.*)\.,\.start (1) end\.) >>result: >>"been

Re: Is bytecode machine (in)dependent?

2005-10-28 Thread Tim Peters
[Robert McLay] > I'm trying to understand bytecodes generated on different machines. > I understand that the bytecodes can change between version. But since > I'm told that .pyc files are version dependent but not machine > dependent, I'm wondering why the bytecodes are machine dependent. They ar

  1   2   >