Re: count files in a directory

2005-05-20 Thread Heiko Wundram
Am Samstag, 21. Mai 2005 06:25 schrieb James Stroud: > This will work for your purposes (and seems pretty fast compared to the > alternative): > > file_count = len(os.walk(valid_path).next()[2]) But will only work when you're just scanning a single directory with no subdirectories...! The altern

Re: first release of PyPy

2005-05-20 Thread Paul Rubin
Torsten Bronger <[EMAIL PROTECTED]> writes: > Please could somebody explain to us non-CS people why PyPy could > have speed features CPython can't have? Does the one-word answer "compiler" explain enough? -- http://mail.python.org/mailman/listinfo/python-list

Re: first release of PyPy

2005-05-20 Thread Torsten Bronger
Hallöchen! "Kay Schluehr" <[EMAIL PROTECTED]> writes: > [...] > > [...] Once You get enough speed out of the PyPy-runtime and the > community shifts to it the PEP-process degenerates in the view of > a PyPythonista to discussions about aspects of the std-objectspace > and language design patterns

Re: first release of PyPy

2005-05-20 Thread Kay Schluehr
Christian Tismer wrote: > [EMAIL PROTECTED] wrote: > > > Kay Schluehr wrote: > > > >>holger krekel wrote: > >> > >>>Welcome to PyPy 0.6 > >>> > >>> > >>>*The PyPy Development Team is happy to announce the first > >>>public release of PyPy after two years of spare-time and > >>>

Re: Running a python program during idle time only

2005-05-20 Thread Donn Cave
Quoth Mike Meyer <[EMAIL PROTECTED]>: | "los" <[EMAIL PROTECTED]> writes: | > I'm trying to create a program similar to that of Google's desktop that | > will crawl through the hard drive and index files. I have written the | > program and as of now I just put the thread to sleep for 1 second afte

Re: Running a python program during idle time only

2005-05-20 Thread Mike Meyer
"los" <[EMAIL PROTECTED]> writes: > I'm trying to create a program similar to that of Google's desktop that > will crawl through the hard drive and index files. I have written the > program and as of now I just put the thread to sleep for 1 second after > indexing a couple of files. > > I'm wonder

Re: performance of Nested for loops

2005-05-20 Thread Andrew Dalke
querypk wrote: > Is there a better way to code nested for loops as far as performance is > concerned. > > what better way can we write to improve the speed. > for example: > N=1 > for i in range(N): >for j in range(N): >do_job1 >for j in range(N): >do_job2 For this cas

Re: SQL Query via python

2005-05-20 Thread Sakesun Roykiattisak
Try cursor.execute ( """ SELECT name, month, day ,category, city FROM bday WHERE %s = %s """ %(arg1,arg2)) Jeff Elkins wrote: >I'm attempting to pass an SQL query via the console: > >$ ./getbd month 05 > >The arguments get seem to passed correctly (via print statements) and then: > >cu

Re: Memory errors with large zip files

2005-05-20 Thread Do Re Mi chel La Si Do
Hi I had make this test (try) : - create 12 txt's files of 100 MB (exactly 102 400 000 bytes) - create the file "tst.zip" who contains this 12 files (but the file result is only 1 095 965 bytes size...) - delete the 12 txt's files - try your code And... it's OK for me. But : the compress

Re: first release of PyPy

2005-05-20 Thread Paul Rubin
Christian Tismer <[EMAIL PROTECTED]> writes: > PyPy is just a completely new approach to interpreted languages, > almost based upon known compiler technology, but applying this in a > consequent manner, that has no comparable prior example. Is there a web page describing what's new? Compile-and-g

Re: count files in a directory

2005-05-20 Thread James Stroud
Sorry, I've never used os.walk and didn't realize that it is a generator. This will work for your purposes (and seems pretty fast compared to the alternative): file_count = len(os.walk(valid_path).next()[2]) The alternative is: import os import os.path file_count = len([f for f in os.listdi

Re: first release of PyPy

2005-05-20 Thread Christian Tismer
[EMAIL PROTECTED] wrote: > Kay Schluehr wrote: > >>holger krekel wrote: >> >>>Welcome to PyPy 0.6 >>> >>> >>>*The PyPy Development Team is happy to announce the first >>>public release of PyPy after two years of spare-time and >>>half a year of EU funded development. The 0.6

Re: Parsing bash_history and inputting into mysql (Intrusion Detection)

2005-05-20 Thread William Park
[EMAIL PROTECTED] wrote: > I have a seemingly tough assignment for my Senior Project. I need to > develop an Intrusion Detection System. > > My approach is to parse the bash_history file of each user into a mysql > database, assign a threshold for commands or sequences of commands and > then alert

Re: count files in a directory

2005-05-20 Thread James Stroud
Come to think of it file_count = len(os.walk(valid_path)[2]) -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: count files in a directory

2005-05-20 Thread James Stroud
On Friday 20 May 2005 07:12 pm, rbt wrote: > I assume that there's a better way than this to count the files in a > directory recursively. Is there??? > > def count_em(valid_path): > x = 0 > for root, dirs, files in os.walk(valid_path): > for f in files: > x = x+1 >

Re: how to config a comserver in a customize dll?

2005-05-20 Thread Roger Upole
If you have a custom COM dll, you should just register it as normal. I'm not sure why you would want to register it as a python COM server. Unless you've duplicated the whole framework that allows com servers to be written in python ? Roger "ÒÊÃÉɽÈË" <[EMAIL PROTECTED]> wrote in mess

Re: appending key-value pairs to a dict

2005-05-20 Thread rbt
Peter Hansen wrote: > rbt wrote: > >> I know how to setup an empty list and loop thru something... appending >> to the list on each loop... how does this work with dicts? >> >> I'm looping thru a list of files and I want to put the file's name and >> its sha hash into a dict on each loop. > >

count files in a directory

2005-05-20 Thread rbt
I assume that there's a better way than this to count the files in a directory recursively. Is there??? def count_em(valid_path): x = 0 for root, dirs, files in os.walk(valid_path): for f in files: x = x+1 print "There are", x, "files in this directory."

Re: Is Python suitable for a huge, enterprise size app?

2005-05-20 Thread Paul Rubin
Dave Brueck <[EMAIL PROTECTED]> writes: > > What do you use for HTTPS? > > m2crypto (plus some patches to make asynchronous SSL do what we needed). That seems to be a nice piece of code, but it's still at version 0.13; if something goes wrong, are you sure you want to explain that you were using

Re: passing arguments

2005-05-20 Thread Steven Bethard
James Stroud wrote: > import sys > > try: > arg1 = sys.argv[1] > except IndexError: > print "This script takes an argument, you boob!" > sys.exit(1) Also possible, to guarantee that exactly one argument was given: try: arg1, = sys.argv except ValueError: print "This script takes an a

Can you introduce some book about python?

2005-05-20 Thread fdsl ysnh
--- [EMAIL PROTECTED]: > Send Python-list mailing list submissions to > python-list@python.org > > To subscribe or unsubscribe via the World Wide Web, > visit > http://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body > 'help' to >

Running a python program during idle time only

2005-05-20 Thread los
Hi, I'm trying to create a program similar to that of Google's desktop that will crawl through the hard drive and index files. I have written the program and as of now I just put the thread to sleep for 1 second after indexing a couple of files. I'm wondering if anyone knows of a way that I coul

Re: Memory errors with large zip files

2005-05-20 Thread Lorn
Ok, I'm not sure if this helps any, but in debugging it a bit I see the script stalls on: newFile.write (zf.read (zfilename)) The memory error generated references line 357 of the zipfile.py program at the point of decompression: elif zinfo.compress_type == ZIP_DEFLATED: if not zlib: r

[ANN] pysqlite 2.0.2 released

2005-05-20 Thread Gerhard Haering
This is a minor bugfix release. Wiki, bugtracker, downloads at http://pysqlite.org/ If you missed 2.0.1, it fixed a bug that could happen if user-defined functions/aggregates were getting out of scope. It's a fatal bug that will crash your application if you encounter it. - Code changes to allow

Re: How to receive events (eg. user mouse clicks) from IE

2005-05-20 Thread J Correia
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Thanks for the response again. The solution is pretty close but not yet > complete > This is what I observed. > a) I tried to use the delay mechanism as suggested below > ie. > ie.Navigate('www.google.com') > while ie.ReadyState !- 4 >

Re: performance of Nested for loops

2005-05-20 Thread Larry Bates
You can use xrange(N) that way Python doesn't have to build the 1 item lists 2 times. Other than that one would need to know why you would call do_job1 and do_job2 1 times each inside a 1 iteration loop. Most VERY large performance gains are due to better algorithms not code optim

Parsing bash_history and inputting into mysql (Intrusion Detection)

2005-05-20 Thread sreekanth . hari
I have a seemingly tough assignment for my Senior Project. I need to develop an Intrusion Detection System. My approach is to parse the bash_history file of each user into a mysql database, assign a threshold for commands or sequences of commands and then alert the admin of nethin fishy is found.

Re: passing arguments

2005-05-20 Thread Daniel Bickett
An even better way would be to use the optparse module.-- Daniel Bickettdbickett at gmail.comhttp://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: processing a large utf-8 file

2005-05-20 Thread "Martin v. Löwis"
Ivan Voras wrote: > Since the .encoding attribute of file objects are read-only, what is the > proper way to process large utf-8 text files? You should use codecs.open, or codecs.getreader to get a StreamReader for UTF-8. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

processing a large utf-8 file

2005-05-20 Thread Ivan Voras
Since the .encoding attribute of file objects are read-only, what is the proper way to process large utf-8 text files? I need "bulk" processing (i.e. in blocks - the file is ~ 1GB), but reading it in fixed blocks is bound to result in partially-read utf-8 characters at block boundaries. -- ht

Re: passing arguments

2005-05-20 Thread Jeff Elkins
On Friday 20 May 2005 06:46 pm, James Stroud wrote: > import sys > > try: > arg1 = sys.argv[1] > except IndexError: > print "This script takes an argument, you boob!" > sys.exit(1) > > OR, way better: See the optparse module. > > On Friday 20 May 2005 03:26 pm, Jeff Elkins wrote: > > I'm sure

Re: performance of Nested for loops

2005-05-20 Thread Charles Krug
On 20 May 2005 15:35:10 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Is there a better way to code nested for loops as far as performance is > concerned. > > what better way can we write to improve the speed. > for example: > N=1 > for i in range(N): >for j in range(N): >d

Re: first release of PyPy

2005-05-20 Thread Kay Schluehr
holger krekel wrote: > Welcome to PyPy 0.6 > > > *The PyPy Development Team is happy to announce the first > public release of PyPy after two years of spare-time and > half a year of EU funded development. The 0.6 release > is eminently a preview release.* Congratulation to

Re: passing arguments

2005-05-20 Thread James Stroud
import sys try: arg1 = sys.argv[1] except IndexError: print "This script takes an argument, you boob!" sys.exit(1) OR, way better: See the optparse module. On Friday 20 May 2005 03:26 pm, Jeff Elkins wrote: > I'm sure this is obvious, but how the heck do pass an argument(s) to a > python

[ann] first release of PyPy

2005-05-20 Thread holger krekel
Welcome to PyPy 0.6 *The PyPy Development Team is happy to announce the first public release of PyPy after two years of spare-time and half a year of EU funded development. The 0.6 release is eminently a preview release.* What it is and where to start ---

Re: Is Python suitable for a huge, enterprise size app?

2005-05-20 Thread elbertlev
C programs also can be disassembled. Serious people do not consider braking the machine code harder byte-code. -- http://mail.python.org/mailman/listinfo/python-list

Re: Process monitoring

2005-05-20 Thread John Abel
gsteff wrote: >Hey, I'm working on a Python program that will launch some other >non-Python process using os.spawn (in the os.P_NOWAIT mode) and then >basically wait for it to finish (while doing some other stuff in the >interim). Normally, the new process will signal that it's done by >writing t

Re: Is Python suitable for a huge, enterprise size app?

2005-05-20 Thread Dave Brueck
Paul Rubin wrote: > Dave Brueck <[EMAIL PROTECTED]> writes: > >>One thing from your experience that did resonate with me is that, >>except for ftplib and occasionally urllib (for basic, one-shot GETs), >>we don't use any of the standard library's "protocol" modules - partly >>because we had to imp

Re: appending key-value pairs to a dict

2005-05-20 Thread Roy Smith
rbt <[EMAIL PROTECTED]> wrote: >I know how to setup an empty list and loop thru something... appending >to the list on each loop... how does this work with dicts? > >I'm looping thru a list of files and I want to put the file's name and >its sha hash into a dict on each loop. You just assign va

Re: buffer_info error

2005-05-20 Thread Jp Calderone
On 20 May 2005 13:18:33 -0700, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >i am filling in a packet with source and destination address and using >the buffer_info call to pass on the address to an underlying low level >call. > >The src and dest are strings, but buffer_info expects an array. How

Re: PyGame and Rotozoom (Sorry if OT)

2005-05-20 Thread Lee Harr
On 2005-05-20, J. W. McCall <[EMAIL PROTECTED]> wrote: > I'm not sure if this is off-topic, since it doesn't deal with Python > itself, but here goes: > > I'm messing around with writing a simple "game" where the player (a > crudely drawn smiley face) moves by rotating and moving back or forward

From the call hook, how do I know more precisely what is called?

2005-05-20 Thread Vijay Kumar
Hi, I wrote a trace function using the profiling and tracing hooks provided by the python interpreter. The Python interpreter reports the calls occuring in the source program to my trace function. How can I know whether the call happened is a function call or method call and if it is a method ca

Re: appending key-value pairs to a dict

2005-05-20 Thread James Stroud
On Friday 20 May 2005 01:04 pm, rbt wrote: > I know how to setup an empty list and loop thru something... appending > to the list on each loop... how does this work with dicts? > > I'm looping thru a list of files and I want to put the file's name and > its sha hash into a dict on each loop. > > Ma

Re: buffer_info error

2005-05-20 Thread [EMAIL PROTECTED]
i am filling in a packet with source and destination address and using the buffer_info call to pass on the address to an underlying low level call. The src and dest are strings, but buffer_info expects an array. How do i deal with this? -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python suitable for a huge, enterprise size app?

2005-05-20 Thread Paul Rubin
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > this has been reported before, and it won't get fixed (unless you're > volunteering to add Python-compatible garbage collection to Tk, that is). Yeah, I think I understand what the issue is. I can think of some kludgy possible fixes but I assume they'

Re: Comparing 2 similar strings?

2005-05-20 Thread Skip Montanaro
Steve> (is this the same as 'Conchobar'?) No, that's a trendy pub in Key West... Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: appending key-value pairs to a dict

2005-05-20 Thread Brian Beck
rbt wrote: > I know how to setup an empty list and loop thru something... appending > to the list on each loop... how does this work with dicts? > > I'm looping thru a list of files and I want to put the file's name and > its sha hash into a dict on each loop. Like so: d = {} for filename in f

Re: Is Python suitable for a huge, enterprise size app?

2005-05-20 Thread Paul Rubin
Dave Brueck <[EMAIL PROTECTED]> writes: > One thing from your experience that did resonate with me is that, > except for ftplib and occasionally urllib (for basic, one-shot GETs), > we don't use any of the standard library's "protocol" modules - partly > because we had to implement our own HTTP lib

Re: appending key-value pairs to a dict

2005-05-20 Thread Peter Hansen
rbt wrote: > I know how to setup an empty list and loop thru something... appending > to the list on each loop... how does this work with dicts? > > I'm looping thru a list of files and I want to put the file's name and > its sha hash into a dict on each loop. Whereas with a list you would call

Re: buffer_info error

2005-05-20 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > data = array('B', '\0' * 256) > data1 = ''.join([dest, src] > > print data.buffer_info()[0]... works > print data1.buffer_info()[0]error > > This output is a string and hence i believe i get the above error. Any > ideas? Yes, you are entirely correct. (Integers do

Difficulty installing PyXml.

2005-05-20 Thread Amitpython5
Hello,     I have python installed under a different directory (/images/QA/QATools12/lib/python2.1), and I'm now trying to install PyXml. It gives me the following error: -> python setup.py buildTraceback (most recent call last):  File "setup.py", line 127, in ?    config_h_vars = parse_conf

appending key-value pairs to a dict

2005-05-20 Thread rbt
I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put the file's name and its sha hash into a dict on each loop. Many thanks, rbt -- http://mail.python.org/mailman/li

Re: circular imports

2005-05-20 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > I'm working with a large code base that I'm slowly trying to fix > "unpythonic" features of. [...] > Insead I'd rather have PYTHONPATH already include '/general/path/' > and then just use: One option you might not have considered, which I find more "pythonic" than envir

buffer_info error

2005-05-20 Thread [EMAIL PROTECTED]
Hello, buffer_info is giving the following error: AttributeError: 'str' object has not attribute 'buffer_info' Here's the code snippet... dest = '' src = '0123' data = array('B', '\0' * 256) data1 = ''.join([dest, src] print data1 >>0123 print data.buff

Re: Comparing 2 similar strings?

2005-05-20 Thread Steve Holden
Chris Croughton wrote: > On Thu, 19 May 2005 06:38:59 +1000, John Machin ><[EMAIL PROTECTED]> wrote: > > >>On Wed, 18 May 2005 15:06:53 -0500, Ed Morton <[EMAIL PROTECTED]> >>wrote: >> >> >>>William Park wrote: >>> >>> How do you compare 2 strings, and determine how much they are "close"

Re: circular imports

2005-05-20 Thread "Martin v. Löwis"
[EMAIL PROTECTED] wrote: > All of the __init__.py files are empty and I don't know of any > overlapping of names. Like I said this is code that works fine, I'm > just trying to clean up some things as I go. I see. The problem is that a module in a package is entered into the parent package only

Re: Comparing 2 similar strings?

2005-05-20 Thread Steve Holden
Dennis Lee Bieber wrote: > On Wed, 18 May 2005 20:03:53 -0500, Ed Morton <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > >>Fantastic test data set. I know how to pronounce McPherson but I'd never >>have guessed that Mousaferiadis sounds like it. I suppose non-Celts >>p

Re: Bug in Elementtree/Expat

2005-05-20 Thread uche . ogbuji
""" > Most examples in the book do not include such a declaration and yet are > properly rendered by Internet Explorer. > Is it mandatory and why is it that Expat crashes on it? It's not mandatory but it's probably good practice to make the document self-contained. The xlink prefix is defined in

Re: Is Python suitable for a huge, enterprise size app?

2005-05-20 Thread elbertlev
Sure it does not. As well as C, unless you instaead of malloc use low level os-dependant APIs. -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert from numbers to letters

2005-05-20 Thread Bill Mill
On 20 May 2005 10:07:55 -0700, Jason Drew <[EMAIL PROTECTED]> wrote: > Hey, that's good. Thanks Steve. Hadn't seen it before. One to use. > > Funny that Pythonwin's argument-prompter (or whatever that feature is > called) doesn't seem to like it. > > E.g. if I have > def f(tupl): > print tupl

Re: OO design question / Transform object in place?

2005-05-20 Thread Dave Benjamin
[EMAIL PROTECTED] wrote: > Dave Benjamin wrote: > >>I think it's much better for simplify() to return a new object >>and leave the original object unmodified. You can still write: >>expression2 = expression2.simplify() > > A belated thank-you message for your reply to my posting. I took your > ad

Memory errors with large zip files

2005-05-20 Thread Lorn
Is there a limitation with python's zipfile utility that limits the size of a file that can be extracted? I'm currently trying to extract 125MB zip files with files that are uncompressed to > 1GB and am receiving memory errors. Indeed my ram gets maxed during extraction and then the script quits. I

Re: circular imports

2005-05-20 Thread qhfgva
All of the __init__.py files are empty and I don't know of any overlapping of names. Like I said this is code that works fine, I'm just trying to clean up some things as I go. Here are my working examples: x1.py == # how things work in our code now: # called with home/dlee/test/module python

Re: Convert from numbers to letters

2005-05-20 Thread Jason Drew
Hey, that's good. Thanks Steve. Hadn't seen it before. One to use. Funny that Pythonwin's argument-prompter (or whatever that feature is called) doesn't seem to like it. E.g. if I have def f(tupl): print tupl Then at the Pythonwin prompt when I type f( I correctly get "(tupl)" in the argumen

embedded function body

2005-05-20 Thread Marco Colombo
Hi, I need to embed an user-supplied python function body in a C program. That is, the user has no control over the function definition: def afunction(): Now, the problem is that I can't just append the supplied string, because I need to properly indent it which isn't trivial - just adding a

Re: How come print cannot be assigned to a variable?

2005-05-20 Thread [EMAIL PROTECTED]
Thank You Adriano. You were a huge help. Vaibhav -- http://mail.python.org/mailman/listinfo/python-list

Re: dealing with MAC address

2005-05-20 Thread Grant Edwards
On 2005-05-20, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > How do i fill in a command line passed mac address for source mac > address. The first six bytes of data[i] should contain destination mac > and the next six bytes of data[i] should contain the source mac > address. Use the struct modu

Re: circular imports

2005-05-20 Thread "Martin v. Löwis"
[EMAIL PROTECTED] wrote: > So I thought I'd just add the necessary __init__.py files and then > things would just work. Unfortunately trying this exposed a large > number of circular imports which now cause the files to fail to load. You didn't describe you you created the necessary __init__.py f

Re: python24.zip

2005-05-20 Thread "Martin v. Löwis"
Robin Becker wrote: > Firstly should python start up with non-existent entries on the path? Yes, this is by design. > Secondly is this entry be the default for some other kind of python > installation? Yes. People can package everything they want in python24.zip (including site.py). This can onl

Re: PIL and line drawing

2005-05-20 Thread rzed
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Leonard J. Reder wrote: > >> I am using PIL to annotate some images with lines. I could not >> find anyway to make the line that is drawn from the ImageDraw >> object thicker. Does anyone have a suggestion or solution for >

Re: How to receive events (eg. user mouse clicks) from IE

2005-05-20 Thread cal_2pac
Thanks for the response again. The solution is pretty close but not yet complete This is what I observed. a) I tried to use the delay mechanism as suggested below ie. ie.Navigate('www.google.com') while ie.ReadyState !- 4 time.sleep(0.5) d=win32com.client.DispatchWithEvents(ie.Document, Doc

Re: Twisted an several CPUs

2005-05-20 Thread Michael Sparks
Paul Rubin wrote: > Jp Calderone <[EMAIL PROTECTED]> writes: >> Distributing load across multiple machines scales better than >> distributing it over multiple CPUs in a single machine. If you have >> serious scalability requirements, SMP is a minor step in the wrong >> direction (unless you're

Re: Cascading menus with Tk

2005-05-20 Thread michelle
Martin Franklin wrote: > michelle wrote: > >> Hi all, >> >> I am new to Tk, or Python GUI programming and I seem to be stuck. I >> have looked about for help with Tk GUIs, but everything seems so terse >> or incomplete?? I have been mostly using the "Introduction to Tkinter" >> by Fredrik Lundh >

Re: ANN: new release of RUR-PLE available

2005-05-20 Thread André Roberge
Michael Hoffman wrote: > André Roberge wrote: > >>Version 0.8.6a is now available. > > > You might see a bit more interest if you briefly explain what RUR-PLE > is, and where to find it. Oops.. sorry about that. RUR - a Python Learning Environment. Its purpose is to provide an environment wher

Re: Convert from numbers to letters

2005-05-20 Thread Steven Bethard
Jason Drew wrote: > ##def tuple2coord(tupl): [snip] > ##rowfromzero, colfromzero = tupl Just a side note here that if you want a better function signature, you might consider writing this as: tuple2coord((rowfromzero, colfromzero)): ... Note that the docstrings are nicer this way: py>

dealing with MAC address

2005-05-20 Thread [EMAIL PROTECTED]
Hello, I am trying to fill a packet with source and destination mac address. The first 6 bytes hold the destination mac address and the next six bytes hold the source mac address. In the code i am filling in the first six bytes to broadcast address for the destination. # fill in the destination ad

Re: How come print cannot be assigned to a variable?

2005-05-20 Thread Adriano Ferreira
print is a statement, not a function. Read Guido's words on that: http://www.python.org/search/hypermail/python-1992/0112.html Regards. Adriano. -- http://mail.python.org/mailman/listinfo/python-list

How come print cannot be assigned to a variable?

2005-05-20 Thread [EMAIL PROTECTED]
Hi all, In Python, some functions can be assigned to variables like this: length=len Why is it that print cannot be assigned to a variable like this? (A syntax error is declared.) Thanks, Vaibhav -- http://mail.python.org/mailman/listinfo/python-list

circular imports

2005-05-20 Thread qhfgva
I'm working with a large code base that I'm slowly trying to fix "unpythonic" features of. One feature I'm trying to fix is the use of: # how things are now sys.path.append('/general/path/aaa/bbb') # lots of lines like this to specific dirs import foo Insead I'd rather have PYTHONPATH already in

Re: a re problem

2005-05-20 Thread cheng
thx for help :) -- http://mail.python.org/mailman/listinfo/python-list

Re: a re problem

2005-05-20 Thread Fredrik Lundh
"cheng" <[EMAIL PROTECTED]> wrote: > >>> p.sub('','a\nbc') > 'abc' > >>> p.sub('','%s') % "a\nbc" > 'a\nbc' > > is it anyone got some idea why it happen? >>> p.sub('', 'a\nbc') Traceback (most recent call last): File "", line 1, in ? NameError: name 'p' is not defined >>> import re >>> p = re.

Re: a re problem

2005-05-20 Thread Mikael Olofsson
cheng wrote: >>>p.sub('','%s') % "a\nbc" >>> >>> >'a\nbc' > >is it anyone got some idea why it happen? > Make that p.sub('','%s' % "a\nbc") Regards /Mikael Olofsson Universitetslektor (Senior Lecturer [BrE], Associate Professor [AmE]) Linköpings universitet --

a re problem

2005-05-20 Thread cheng
>>> p.sub('','a\nbc') 'abc' >>> p.sub('','%s') % "a\nbc" 'a\nbc' is it anyone got some idea why it happen? -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert from numbers to letters

2005-05-20 Thread Jason Drew
Sorry, scratch that "P.S."! The act of hitting Send seems to be a great way of realising one's mistakes. Of course you need colnr - m for those times when m is set to 26. Remembered that when I wrote it, forgot it 2 paragraphs later! -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert from numbers to letters

2005-05-20 Thread Jason Drew
Er, yes! It's REALLY ugly! I was joking (though it works)! I retract it from the code universe. (But patent pending nr. 4040404.) Here's how I really would convert your (row_from_zero, col_from_zero) tuple to spreadsheet "A1" coords, in very simple and easy to read code. ##def tuple2coord(tupl):

python24.zip

2005-05-20 Thread Robin Becker
Investigating a query about the python path I see that my win32 installation has c:/windows/system32/python24.zip (which is non existent) second on sys.path before the actual python24/lib etc etc. Firstly should python start up with non-existent entries on the path? Secondly is this entry be th

Re: Cascading menus with Tk

2005-05-20 Thread Martin Franklin
michelle wrote: > Hi all, > > I am new to Tk, or Python GUI programming and I seem to be stuck. I > have looked about for help with Tk GUIs, but everything seems so terse > or incomplete?? I have been mostly using the "Introduction to Tkinter" > by Fredrik Lundh > (http://www.pythonware.com/libra

Re: ANN: new release of RUR-PLE available

2005-05-20 Thread Michael Hoffman
André Roberge wrote: > Version 0.8.6a is now available. You might see a bit more interest if you briefly explain what RUR-PLE is, and where to find it. -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list

Re: Python on a public library computer

2005-05-20 Thread Anton Vredegoor
alex23 wrote: > You know, there _are_ valid reasons for libraries et.al. 'locking down' > public terminals other than fascism... Maybe, but in this case I can run only IE, word, excel and powerpoint. Do you think there is a rational reason for that? Like Tim Peters showing up, explaining that it

Re: string formatting quirk?

2005-05-20 Thread Peter Otten
[EMAIL PROTECTED] wrote: > ''%([]) doesn't raise exception > but > ''%('') does > > Can anyone explain me why?? That is a side-effect of duck-typing. The duck-type of an empty list is indistinguishable from that of an empty dictionary. Not testing the exact type here achieves consistency with th

Re: Cascading menus with Tk

2005-05-20 Thread Peter Otten
michelle wrote: > What I am trying to do is add cascading menus to a Tk menu widget like: > > File > New... > ---> Router > ---> Firewall > Open > > Exit Just add the submenu with the "Router" and "Firewall" entries to the filemenu in the same way you added the submenu with the "New", "Open

Re: Comparing 2 similar strings?

2005-05-20 Thread John Machin
On 20 May 2005 04:09:26 GMT, [EMAIL PROTECTED] (Patrick TJ McPhee) wrote: >In article <[EMAIL PROTECTED]>, >John Machin <[EMAIL PROTECTED]> wrote: > >% None of the other approaches make the mistake of preserving the first >% letter -- this alone is almost enough reason for jettisoning soundex. >

Re: pyvm -- faster python

2005-05-20 Thread Susan A. Smith
I have read about parrot. How is that progressing? Stelios Xanthakis wrote: > Hi. > > pyvm is a program which can run python 2.4 bytecode (the .pyc files). > A demo pre-release is available at: > http://students.ceid.upatras.gr/~sxanth/pyvm/ > > > Facts about pyvm: > - It's FAST. According

string formatting quirk?

2005-05-20 Thread [EMAIL PROTECTED]
Hi, ''%([]) doesn't raise exception but ''%('') does Can anyone explain me why?? rgds Anurag -- http://mail.python.org/mailman/listinfo/python-list

Re: OO design question / Transform object in place?

2005-05-20 Thread andy2O
Dave Benjamin wrote: > [EMAIL PROTECTED] wrote: > > Now suppose I set "expression2 = Sum([a,-a])" and Sum.simplify() > > recognises that the two terms cancel and the Sum has value 0. > > > > Can I make "expression2.simplify()" transform expression2 from an > > instance of Sum to an instance of Numb

Re: cddb and mci produce an ImportError

2005-05-20 Thread flupke
flupke wrote: I finally succeeded in making a proper mci.dll that works. I will document what i did in the coming days and place it here. I developed the dll with DevC++. Anyway, it all works :) Benedict -- http://mail.python.org/mailman/listinfo/python-list

Cascading menus with Tk

2005-05-20 Thread michelle
Hi all, I am new to Tk, or Python GUI programming and I seem to be stuck. I have looked about for help with Tk GUIs, but everything seems so terse or incomplete?? I have been mostly using the "Introduction to Tkinter" by Fredrik Lundh (http://www.pythonware.com/library/tkinter/introduction/index.

Re: PyGame and Rotozoom (Sorry if OT)

2005-05-20 Thread Will McGugan
J. W. McCall wrote: > I'm not sure if this is off-topic, since it doesn't deal with Python > itself, but here goes: > > I'm messing around with writing a simple "game" where the player (a > crudely drawn smiley face) moves by rotating and moving back or forward > (think Resident Evil, but from

Re: MySQLdb and Unicode

2005-05-20 Thread deelan
Achim Domma (Procoders) wrote: > Hi, > > I try to write unicode strings to a MySQL database via MySQLdb. > According to the documentation I should pass 'utf-8' as keyword > parameter to the connect method. But then I get the following error: > (...) > > > I'm using version 1.2 of MySQLdb. Any

MySQLdb and Unicode

2005-05-20 Thread Achim Domma (Procoders)
Hi, I try to write unicode strings to a MySQL database via MySQLdb. According to the documentation I should pass 'utf-8' as keyword parameter to the connect method. But then I get the following error: Traceback (most recent call last): File "C:\develop\SyynX\unicode_test.py", line 7, in ?

  1   2   >