Re: Problem with List of List

2006-08-25 Thread Kirt
Kirt wrote: > Fredrik Lundh wrote: > > Fredrik Lundh wrote: > > > > >> I have a code > > >> ==CODE= > > >> List=[['1', 'a', '6'], ['1', 'b', '6'], ['1', 'c', '6'], > > >> ['1', 'd', '6'],['2', 'a','6'], ['2', 'b', '6'], > > >> ['2', 'c', '6'], ['2', 'd',

Re: Problem with List of List

2006-08-25 Thread Kirt
Fredrik Lundh wrote: > Fredrik Lundh wrote: > > >> I have a code > >> ==CODE= > >> List=[['1', 'a', '6'], ['1', 'b', '6'], ['1', 'c', '6'], > >> ['1', 'd', '6'],['2', 'a','6'], ['2', 'b', '6'], > >> ['2', 'c', '6'], ['2', 'd', '6'], ['3', 'a', '6'], > >>

Re: Problem with List of List

2006-08-25 Thread Kirt
Fredrik Lundh wrote: > Fredrik Lundh wrote: > > >> I have a code > >> ==CODE= > >> List=[['1', 'a', '6'], ['1', 'b', '6'], ['1', 'c', '6'], > >> ['1', 'd', '6'],['2', 'a','6'], ['2', 'b', '6'], > >> ['2', 'c', '6'], ['2', 'd', '6'], ['3', 'a', '6'], > >>

Re: Problem with List of List

2006-08-25 Thread Fredrik Lundh
Fredrik Lundh wrote: >> I have a code >> ==CODE= >> List=[['1', 'a', '6'], ['1', 'b', '6'], ['1', 'c', '6'], >> ['1', 'd', '6'],['2', 'a','6'], ['2', 'b', '6'], >> ['2', 'c', '6'], ['2', 'd', '6'], ['3', 'a', '6'], >> ['3','b', '6'], ['4', 'a', '

Re: Problem with List of List

2006-08-25 Thread Fredrik Lundh
Kirt wrote: > I am a newbie and stuck over this for a week that's unfortunate. > I have a code > ==CODE= > List=[['1', 'a', '6'], ['1', 'b', '6'], ['1', 'c', '6'], > ['1', 'd', '6'],['2', 'a','6'], ['2', 'b', '6'], > ['2', 'c', '6'], ['2', 'd', '6'], [

Problem with List of List

2006-08-25 Thread Kirt
I am a newbie and stuck over this for a week I have a code ==CODE= List=[['1', 'a', '6'], ['1', 'b', '6'], ['1', 'c', '6'], ['1', 'd', '6'],['2', 'a','6'], ['2', 'b', '6'], ['2', 'c', '6'], ['2', 'd', '6'], ['3', 'a', '6'], ['3','b', '6'], ['4', '

Re: Taking data from a text file to parse html page

2006-08-25 Thread DH
Yes I know how to import modules... I think I found the problem, Linux handles upper and lower case differently, so for some reason you can't import SE but if you rename it to se it gives you the error that it can't find SEL which if you rename it will complain that that SEL isn't defined... Are yo

wxGlade and __init__

2006-08-25 Thread crystalattice
I'm making a GUI for a console-based program I just wrote. I figured it would be mostly straight forward to convert it over in wxPython but now I'm confused. In my console program, I have __init__ making the dictionaries et al. and then my methods will populate them. However, when I use wxGlade

Re: Avoiding if..elsif statements

2006-08-25 Thread Carl Banks
unexpected wrote: > Currently, I've implemented a bunch of > if..elsif statements to do this, but it's gotten to be over 30 right > now and has gotten rather tedious. Is there a more efficient way to do > this? Use something other than Perl. :) Carl Banks -- http://mail.python.org/mailman/lis

Re: get a line of text from a socket...

2006-08-25 Thread KraftDiner
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, KraftDiner > wrote: > > > If you don't know how long your input data is going to be how can you > > at least treat it a text line at a time... like looking for new line in > > the data... Right now recv blocks. Yes I could do a select, bu

Re: time.clock() going backwards??

2006-08-25 Thread skip
>> I seem to remember this being mentioned before on the list, perhaps by Tim >> Peters. Perhaps he will chime in. Claudio> If I remember it right, the cause of such a problem is updating Claudio> the clock by accessing a time server over a network. Just any Claudio> such ac

[ANN] PyGooCanvas 0.4.0

2006-08-25 Thread Gian Mario Tagliaretti
I am pleased to announce version 0.4.0 of the Python bindings for Goocanvas. This is the first release and it's available at: https://developer.berlios.de/projects/pygoocanvas/ Contributors for this release: == - Gian Mario Tagliaretti (module creation, coding, doc

Re: Newbie programmer question: How do parsers work?(Python examples?)

2006-08-25 Thread Ramon Diaz-Uriarte
On 25 Aug 2006 12:55:26 -0700, bio_enthusiast <[EMAIL PROTECTED]> wrote: > I was wondering exactly how you create a parser. I'm learning > Python and I recently have come across this material. I'm interested > in the method or art of writing a parser. > > If anyone has some python code to post for

Re: Python and STL efficiency

2006-08-25 Thread Pebblestone
Ruby is also not far away :-) Here's my code: require 'time' def f a = [] 100.times do a.push "What do you know" a.push "so long ..." a.push "chicken crosses road" a.push "fool" end b = a.uniq b.each do |x| puts x end e

Re: Avoiding if..elsif statements

2006-08-25 Thread Daniel Nogradi
> Code: > > value = self.dictionary.get(keyword)[0] > > if value == "something": > somethingClass.func() > elsif value == "somethingElse": > somethingElseClass.func() > elsif value == "anotherthing": > anotherthingClass.func() > elsif value == "yetanotherthing": > yetanotherthingCla

Re: ASN.1 encoder & decoder

2006-08-25 Thread Paul Rubin
Doug Stell <[EMAIL PROTECTED]> writes: > Can anyone provide guidance on building an ASN.1 decoder and encoder > in Python? This does not have to be a general purpose implementation, > drivenf from an ASN.1 template. It can be dedicated hard coded to a > particular template. There might be some use

Re: Avoiding if..elsif statements

2006-08-25 Thread Fredrik Lundh
"unexpected" <[EMAIL PROTECTED]> wrote: > However, I'm passing in a few variables, so I can't just take it > out-though every single function would be passing the same variables. > > so something.func() is actually > something.func(string, list) > > How would I modify it to include them? just add

Re: Drag and Drop with PyQt4

2006-08-25 Thread David Boddie
Harshad wrote: > When I run the program, DragEnterEvent works as expected, but the > DropEvent does not seem to be working. I'm not an experienced Python > hacker, and am unable to trace out any problems with the source code. > Any and all help will be appreciated! I'm making an educated guess fr

Re: Python and STL efficiency

2006-08-25 Thread bearophileHUGS
Pebblestone: > Sorry, I did some miscalculation what a shame. Don't worry. For me using Py 2.4.3 those memory values are 4536 before and 20184 kb after, it means a difference of 15648 kb, that equals to about 16023552 bytes, that equals to about 100 * 4 * 4. That means 4 bytes for each

Re: Avoiding if..elsif statements

2006-08-25 Thread unexpected
the missing () was the trick! However, I'm passing in a few variables, so I can't just take it out-though every single function would be passing the same variables. so something.func() is actually something.func(string, list) How would I modify it to include them? Sorry I didn't include them the

Re: Avoiding if..elsif statements

2006-08-25 Thread Chaz Ginger
unexpected wrote: > I have a program where based on a specific value from a dictionary, I > call a different function. Currently, I've implemented a bunch of > if..elsif statements to do this, but it's gotten to be over 30 right > now and has gotten rather tedious. Is there a more efficient way to

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs.object attributes)

2006-08-25 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I think that the official python documentation has to become more like > wikipedia, where people can fix it more easely, so I can add such > warning into the text. comment away: http://pyref.infogami.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and STL efficiency

2006-08-25 Thread Pebblestone
Sorry, I did some miscalculation what a shame. [EMAIL PROTECTED] wrote: > Pebblestone: > > >I heard that python's list is implemented as adjustable array. > > Correct, an array geometrically adjustable on the right. > > > >Here's my lisp implementation:< > > What's the memory size of a

Re: Avoiding if..elsif statements

2006-08-25 Thread Simon Forman
unexpected wrote: > I have a program where based on a specific value from a dictionary, I > call a different function. Currently, I've implemented a bunch of > if..elsif statements to do this, but it's gotten to be over 30 right > now and has gotten rather tedious. Is there a more efficient way to

Re: When is a subclass not right?

2006-08-25 Thread Carl Banks
David Ells wrote: > Carl Banks wrote: > > The classical advice in choosing whether to subclass or or use > > attribute is whether its more an an "is a" or "has a" relationship. If > > it's more natural to say B is an A, then subclass. If it's more > > natural to say B has an A, then use an attr

Re: Avoiding if..elsif statements

2006-08-25 Thread Fredrik Lundh
"unexpected" <[EMAIL PROTECTED]> wrote: > I have a program where based on a specific value from a dictionary, I > call a different function. Currently, I've implemented a bunch of > if..elsif statements to do this, but it's gotten to be over 30 right > now and has gotten rather tedious. Is there a

Re: prevent unauthorized call to script

2006-08-25 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I have copy-paste a script called "form.py" from somewhere else. sounds a bit dangerous. > This script is called from " form.html". Both are running in my Apache > server. How do I prevent other html files from other server to call my > "form.py" script ? usual ap

Re: ASN.1 encoder & decoder

2006-08-25 Thread Doug Stell
I looked at pyasn1. Unfortunately, it is not useful and provides a C interface. Thanks, anyhow. I figure that I will have to write my own, but am unsure of the best approach. Nested lists and distionaries might be useful and I am looking to the feasibility of those mechanisms. On Fri, 25 Aug 2006

Re: Consistency in Python

2006-08-25 Thread Fredrik Lundh
Brendon Towle wrote: >> b) http://pyfaq.infogami.com/why-doesn-t-list-sort-return-the-sorted-list >>(this also explains how to handle your specific use case) > > Well, I posted working code, so I thought it should have been obvious > that I knew how to handle my use case, and was (am) lookin

Re: Python and STL efficiency

2006-08-25 Thread Pebblestone
> What's the memory size of a before computing b? You can compare it with > Python, that may need less memory (because the array contains > pointers). Here's the memory usage: 1) before the loop ( fully garbage collected) 29,052,560 bytes, 757,774 objects. 2) after the loop 103,631,952 bytes,

Avoiding if..elsif statements

2006-08-25 Thread unexpected
I have a program where based on a specific value from a dictionary, I call a different function. Currently, I've implemented a bunch of if..elsif statements to do this, but it's gotten to be over 30 right now and has gotten rather tedious. Is there a more efficient way to do this? Code: value = s

Re: Consistency in Python

2006-08-25 Thread Fredrik Lundh
Brendon Towle wrote: > My third response is that it's *always* possible to shoot yourself in > the foot. Protecting a naive user from one particular metatarsal > projectile insertion at the expense of letting the power-user write more > concise code seems a bad tradeoff to me -- but, I'm not in

Interrupting a running python thread

2006-08-25 Thread johan2sson
I have embedded a python console in a plugin to a Windows application. I do not control the application, but the plugin is mine. Since the application is not thread-safe, I am push()-ing each line onto a code.InteractiveConsole on the GUI thread. This has the downside that a silly mistake that crea

Re: ASN.1 encoder & decoder

2006-08-25 Thread Bruce Stephens
Doug Stell <[EMAIL PROTECTED]> writes: > Can anyone provide guidance on building an ASN.1 decoder and encoder > in Python? ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and STL efficiency

2006-08-25 Thread bearophileHUGS
Pebblestone: >I heard that python's list is implemented as adjustable array. Correct, an array geometrically adjustable on the right. >Here's my lisp implementation:< What's the memory size of a before computing b? You can compare it with Python, that may need less memory (because the array co

Re: sum and strings

2006-08-25 Thread Fredrik Lundh
Hendrik van Rooyen wrote: > | (I still think a "join" built-in would be nice, though. but anyone who > | argues that "join" should support numbers too will be whacked with a > | great big halibut.) > > Strange this - you don't *LOOK* like a Gaulish Blacksmith... no, but I have a nice safari o

Re: random writing access to a file in Python

2006-08-25 Thread Fredrik Lundh
Claudio Grondi wrote: > I was smart enough to try it first on a very small file wondering what > was happening. Python documentation and even Google search after 'random > file access in Python' were not helpful as there was no example and no > hint available. one would think that the repeated

Re: Duck typing alows true polymorfisim

2006-08-25 Thread The Ghost In The Machine
In comp.lang.java.advocacy, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote on 25 Aug 2006 12:05:21 -0700 <[EMAIL PROTECTED]>: > lets say you want a generic numerical algorithom like sum > > Ruby > > def sum lst > lst.inject(0){|total,current| total*current} > end > > Java // i dont know if there is

Re: RE Module

2006-08-25 Thread Tim Chase
> ## > import re > > s = 'xxx0' > > m = re.search("x*", s) > print "First way", m.group(0) > > m = re.search("x*?", s) > print "Second way", m.group(0) > # > First way xxx > Second way > > So now I'm really confused

Re: Python and STL efficiency

2006-08-25 Thread Pebblestone
Here's the result: What do you know fool chicken crosses road f elapsed: 1.26 seconds f2 elapsed 2.11 seconds [EMAIL PROTECTED] wrote: > Pebblestone: > > (defun test4 () > > (let ((a (make-array 400 :element-type 'string > >:adjustable nil))

Re: Python and STL efficiency

2006-08-25 Thread Pebblestone
Oh, I forgot. Your python's example (use direct index array index) of my corresponding lisp code works slower than the version which use 'append'. This let me think how python's list is implemented. Anyway, python's list is surprisingly efficient. [EMAIL PROTECTED] wrote: > Pebblestone: > > (

Re: Open Office and Python

2006-08-25 Thread tobiah
I should have pointed out that the delimiter is a tab right now. That's what I use in general, but I still call the files .csv files. Also this doesn't check for, or handle quoted fields. > I put together a little utility that you may find helpful > if I understand you correctly. It converts a

Re: RE Module

2006-08-25 Thread Fredrik Lundh
tobiah wrote: > Also, how does the engine decide whether I am adjusting > the greed of the previous operator, or just asking > for another possible character? "?" always modifies the *preceeding* RE element. if the preceeding element is a pattern (e.g. a character or group), it means that the p

Re: Python and STL efficiency

2006-08-25 Thread Pebblestone
> But note this a list (that is an array, a list is a different data > structure) of python becomes filled with pointers. I don't know what > your CL does exactly. I heard that python's list is implemented as adjustable array. Here's my lisp implementation: ++ (defun test-list ()

Re: random writing access to a file in Python

2006-08-25 Thread Tim Chase
> Is there a ready to use (free, best Open Source) tool able to sort lines > (each line appr. 20 bytes long) of a XXX GByte large text file (i.e. in > place) taking full advantage of available memory to speed up the process > as much as possible? Sounds like an occasion to use a merge-sort. Th

Re: time.clock() going backwards??

2006-08-25 Thread Sander Steffann
Hi, >>>I experimented something very strange, a few days ago. I was debugging an >>>application at a customer's site, and the problem turned out to be that >>>time.clock() was going "backwards", that is it was sometimes >>>(randomically) >>>returning a floating point value which was "less than" th

Re: RE Module

2006-08-25 Thread tobiah
> In python's RE module, they're like Perl: > > Greedy: "<.*>" > Nongreedy: "<.*?>" > Oh, I have never seen that. In that case, why did Roman's first example not work well for HTML tags? '<.*?>' Also, how does the engine decide whether I am adjusting the greed of the previous operator, or j

Re: Newbie programmer question: How do parsers work?(Python examples?)

2006-08-25 Thread faulkner
http://pages.cpsc.ucalgary.ca/~aycock/spark/ http://www-128.ibm.com/developerworks/library/l-spark.html bio_enthusiast wrote: > I was wondering exactly how you create a parser. I'm learning > Python and I recently have come across this material. I'm interested > in the method or art of writing a p

Re: RE Module

2006-08-25 Thread Tim Chase
>> Also, what made the expression greedy? > > They usually are, by default. It means that when there > are more than one ways to match the pattern, choose the > one that matches the most text. Often there are flags > available to change that behavior. I'm not sure off hand > how to do it with t

ASN.1 encoder & decoder

2006-08-25 Thread Doug Stell
Can anyone provide guidance on building an ASN.1 decoder and encoder in Python? This does not have to be a general purpose implementation, drivenf from an ASN.1 template. It can be dedicated hard coded to a particular template. Doug Stell, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listi

Re: Python and STL efficiency

2006-08-25 Thread bearophileHUGS
Pebblestone: > (defun test4 () > (let ((a (make-array 400 :element-type 'string > :adjustable nil)) > (b nil)) > (dotimes (i 100) > (progn > (let ((j (1- (* 4 i > (setf (aref a (incf j))

Re: time.clock() going backwards??

2006-08-25 Thread Tim Peters
[Giovanni Bajo[ >> I experimented something very strange, a few days ago. I was debugging an >> application at a customer's site, and the problem turned out to be that >> time.clock() was going "backwards", that is it was sometimes >> (randomically) returning a floating point value which was "less

Re: RE Module

2006-08-25 Thread tobiah
Roman wrote: > This is excellent. Thanks a lot. > > Also, what made the expression greedy? They usually are, by default. It means that when there are more than one ways to match the pattern, choose the one that matches the most text. Often there are flags available to change that behavior. I'

Re: Duck typing alows true polymorfisim

2006-08-25 Thread Terry Reedy
"David Ells" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > def increment(x): >return x += 1 'return x+1' works better ;-) tjr -- http://mail.python.org/mailman/listinfo/python-list

Re: RE Module

2006-08-25 Thread Anthra Norell
Roman, I don't quite understand what you mean. Line separators gone? That would be the '\n', right? What of it if you process line by line, as your variable name 'row' suggests? As to the maximum size re can handle, I have no idea. I vaguely remember the topic being discussed. You should b

Re: random writing access to a file in Python

2006-08-25 Thread tobiah
> === > if I want to write, I don't open for reading (plus or not plus) > === I was thinking the same thing. I know python is only following C, which is good, but the flags

Re: time.clock() going backwards??

2006-08-25 Thread Claudio Grondi
Terry Reedy wrote: > "Giovanni Bajo" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Hello, >> >>I experimented something very strange, a few days ago. I was debugging an >>application at a customer's site, and the problem turned out to be that >>time.clock() was going "backward

Re: random writing access to a file in Python

2006-08-25 Thread Claudio Grondi
Dennis Lee Bieber wrote: > On Fri, 25 Aug 2006 16:39:14 +0200, Claudio Grondi > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > >>The core of my problem was ... trying to use 'wb' or 'w+b' ... (stupid >>me ...) > > > Ouch... How many times did you have to restore tha

Re: RE Module

2006-08-25 Thread Roman
This is excellent. Thanks a lot. Also, what made the expression greedy? tobiah wrote: > Roman wrote: > > I am trying to filter a column in a list of all html tags. > > > > To do that, I have setup the following statement. > > > > row[0] = re.sub(r'<.*?>', '', row[0]) > > The regex will be 'greedy

Re: Newbie programmer question: How do parsers work?(Python examples?)

2006-08-25 Thread Terry Reedy
"bio_enthusiast" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I was wondering exactly how you create a parser. I'm learning > Python and I recently have come across this material. I'm interested > in the method or art of writing a parser. > > If anyone has some python code to post

Re: Newbie programmer question: How do parsers work?(Python examples?)

2006-08-25 Thread Brian Mills
You have a lot of choices with this sort of thing. What you'd use depends largely on what sorts of files/input you'll be parsing. For example, a common machine-friendly data format is the comma-separated file. These, or really any file which uses a character-based field seperator (including newl

Re: Newbie programmer question: How do parsers work?(Python examples?)

2006-08-25 Thread Neil Cerutti
On 2006-08-25, bio_enthusiast <[EMAIL PROTECTED]> wrote: > I was wondering exactly how you create a parser. I'm learning > Python and I recently have come across this material. I'm > interested in the method or art of writing a parser. > > If anyone has some python code to post for an abstract pars

Re: namespace problems

2006-08-25 Thread Terry Reedy
"Kiran" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, I am trying to get the following to work, but cant seem to do > it the way i want to. > > ok, so I come into python and do the following: > x = 1 > > then, i have a file called test.py in which i say: > print x > >

Re: wxPython and Py2exe crashes in "window" mode but not in "console" mode

2006-08-25 Thread jean-michel bain-cornu
Hi Jerry, > I have created an application using wxPython and compiled it using > py2exe. When I put > > setup(console=['myscript.py']) > > in my setup.py file, the resulting application runs just fine. But > when I change it to > > setup(windows=['myscript.py']) > > The application crashes wi

Re: SE 2.2 install

2006-08-25 Thread Anthra Norell
Dylan,     It seems there is an installation routine that doesn't work. I just has a similar complaint. Fact is, I am not familiar with the routine. It sounds like it automates complicated downloads. This is as simple a download as can be. So just forget about install. Download the zip f

Re: time.clock() going backwards??

2006-08-25 Thread Terry Reedy
"Giovanni Bajo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > I experimented something very strange, a few days ago. I was debugging an > application at a customer's site, and the problem turned out to be that > time.clock() was going "backwards", that is it was sometim

Re: Duck typing alows true polymorfisim

2006-08-25 Thread Simon Forman
[EMAIL PROTECTED] wrote: > What was i thinkinng repace * with + i was'nt thinking i origanaly > thaught of sum of squares so i put a * insted of a + But again, what's your question? -- http://mail.python.org/mailman/listinfo/python-list

Newbie programmer question: How do parsers work?(Python examples?)

2006-08-25 Thread bio_enthusiast
I was wondering exactly how you create a parser. I'm learning Python and I recently have come across this material. I'm interested in the method or art of writing a parser. If anyone has some python code to post for an abstract parser, or links to some informative tutorials, that would be great.

Re: Taking data from a text file to parse html page

2006-08-25 Thread Anthra Norell
Surely you write your own programs. (program_name.py). You import and run them. You may put SE.PY and SEL.PY into the same directory. That's all. Or if you prefer to keep other people's stuff in a different directory, just make sure that directory is in "sys.path", because that is where imp

Re: Fw: Is this a good idea or a waste of time?

2006-08-25 Thread Simon Forman
Hendrik van Rooyen wrote: > "Simon Forman" <[EMAIL PROTECTED]> wrote: > > 8<- > > | BTW, speaking of "strictness", "more stricter" is invalid English, > | just "stricter" is the "correct" form. ;-) > > or alternatively the construct "

Re: Open Office and Python

2006-08-25 Thread tobiah
F wrote: > Hello there! > > I'd like to load a .csv file to the Open Office spreadsheet from the command > line using an arbitrary delimiter through Python. I put together a little utility that you may find helpful if I understand you correctly. It converts a .csv file to a .xls file without t

Re: Duck typing alows true polymorfisim

2006-08-25 Thread atbusbook
What was i thinkinng repace * with + i was'nt thinking i origanaly thaught of sum of squares so i put a * insted of a + -- http://mail.python.org/mailman/listinfo/python-list

Re: Disable close button in management window.(KDE- pyQT)

2006-08-25 Thread Gabriel - BR
Thank -- http://mail.python.org/mailman/listinfo/python-list

Re: Duck typing alows true polymorfisim

2006-08-25 Thread David Ells
[EMAIL PROTECTED] wrote: > lets say you want a generic numerical algorithom like sum > > Ruby > > def sum lst > lst.inject(0){|total,current| total*current} > end > > Java // i dont know if there is a numeric super class for numbers > > class Sum{ > public static int sum(int[] lst){ > int

Re: Duck typing alows true polymorfisim

2006-08-25 Thread John Bokma
[EMAIL PROTECTED] wrote: > lets say you want a generic numerical algorithom like sum Hmmm, I thought you were going to announce that you were the first born son of Xah Lee. Actually you did! -- John MexIT: http://johnbokma.com/mexit/ per

Re: List comparison help please

2006-08-25 Thread Simon Forman
Bucco wrote: > Simon Forman wrote: > > > 1) Don't use "dir", "file", and "list" as variable names, those are > > already python built in objects (the dir() function, list type, and > > file type, respectively.) > > Thanks. My own stupidity on this one. > > > > 2) 'r' is the default for open(), omi

Re: Duck typing alows true polymorfisim

2006-08-25 Thread Simon Forman
[EMAIL PROTECTED] wrote: > lets say you want a generic numerical algorithom like sum > > Ruby > > def sum lst > lst.inject(0){|total,current| total*current} > end > > Java // i dont know if there is a numeric super class for numbers > > class Sum{ > public static int sum(int[] lst){ > int t

Re: Python and STL efficiency

2006-08-25 Thread Pebblestone
I tested in Common Lisp and compared the result with python. My PC is: 3.6GH Pentium4 My OS is: Ubuntu 6.06 i386 My lisp implementation is SBCL 0.9.8 for i386 My python's version is: V2.4.3 Both implementations were installed via apt-get install. Here's my Lisp program: +

Re: RE Module

2006-08-25 Thread tobiah
Roman wrote: > I am trying to filter a column in a list of all html tags. > > To do that, I have setup the following statement. > > row[0] = re.sub(r'<.*?>', '', row[0]) The regex will be 'greedy' and match through one tag all the way to the end of another on the same line. There are more comple

Drag and Drop with PyQt4

2006-08-25 Thread Harshad
Hi, I'm writing a program using Python 2.4 and PyQt4. The aim is to implement drag and drop from filesystem and display a list of files dragged on to the listWidget. This function will later become part of a software for workflow management. When I run the program, DragEnterEvent works as expecte

Re: When is a subclass not right?

2006-08-25 Thread David Ells
Carl Banks wrote: > > I think it's kind of a fine point. In my own code I've had cases where > I've switched from subclass to attribute and back over the development, > and vice versa. I think there are many cases where it's preferable to > use an attribute, but not really wrong to subclass (and

Duck typing alows true polymorfisim

2006-08-25 Thread atbusbook
lets say you want a generic numerical algorithom like sum Ruby def sum lst lst.inject(0){|total,current| total*current} end Java // i dont know if there is a numeric super class for numbers class Sum{ public static int sum(int[] lst){ int total = 0; for(int current : lst){ tot

Re: When is a subclass not right?

2006-08-25 Thread David Ells
Chaz Ginger wrote: > I was writing some code that used someone else class as a subclass. He > wrote me to tell me that using his class as a subclass was incorrect. I > am wondering under what conditions, if ever, does a class using a > subclass not work. > > Here is an example. For instance the ori

wxPython and Py2exe crashes in "window" mode but not in "console" mode

2006-08-25 Thread Jerry
I have created an application using wxPython and compiled it using py2exe. When I put setup(console=['myscript.py']) in my setup.py file, the resulting application runs just fine. But when I change it to setup(windows=['myscript.py']) The application crashes without any indication of what hap

Re: django's view.py as class not just methods

2006-08-25 Thread Rob Wolfe
Skink <[EMAIL PROTECTED]> writes: > Hi, > > I'm relatively new to django and maybe my question is stupid, but... > > Is it possible to map in urls.py some url not to function in views.py > (which has first argument with HttpRequest) but to some class method? > In that case each instance of such cl

Re: [Q] About an Installer Script for PyWin

2006-08-25 Thread Larry Bates
Mr. Roboto wrote: > I need PyWin under the covers, that is, to install it as part of an > application, but in such a way that it isn't visible to users. I'm > concerned about a so-called "power-user", seeing the Python directory > and/or the corresponding entry in the 'Add/Remove Programs' list, >

Re: telnetlib thread-safe?

2006-08-25 Thread Jerry
Great, thanks for the info. -- http://mail.python.org/mailman/listinfo/python-list

[Q] About an Installer Script for PyWin

2006-08-25 Thread Mr. Roboto
I need PyWin under the covers, that is, to install it as part of an application, but in such a way that it isn't visible to users. I'm concerned about a so-called "power-user", seeing the Python directory and/or the corresponding entry in the 'Add/Remove Programs' list, breaking my app by uninstal

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Larry Bates wrote: > lazaridis_com wrote: > > I would like to change the construct: > > > > if __name__ == '__main__': > > > > to something like: > > > > if exec.isMain(): > > > > My (OO thought) is to place a class in an separate code module and to > > instantiate an singleton instance which would

Re: couple more questions about sqlite

2006-08-25 Thread Preston Hagar
It looks like most of your questions have been answered, but I might also suggest the APress book on SQLite: http://www.amazon.com/gp/product/1590596730/sr=8-2/qid=1142277203/ref=pd_bbs_2/002-3764084-7189633?%5Fencoding=UTF8***MAJOR DISCLAIMER: I was the technical reviewer on this book.***The book

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-25 Thread bearophileHUGS
Aahz wrote: > Taking a look at __slots__ is fine as long as you don't actually use them. I remember the recent discussion about such matters... but I don't understand its dangers fully still. I assume __slots__ may be removed in Python 3.0, but maybe "experts" need it now an then. Or maybe a "expe

Re: Best Editor

2006-08-25 Thread crystalattice
JAG CHAN wrote: > Friends, I am trying to learn Python. > It will be of great help to me if you let me know which one would be best > editor for learning Python. > Plese note that I would like to have multiplatform editor which will be > useful for both LInux and Windows XP. > Thanks. My choice i

Re: get a line of text from a socket...

2006-08-25 Thread Jean-Paul Calderone
On 25 Aug 2006 09:37:09 -0700, KraftDiner <[EMAIL PROTECTED]> wrote: >If you don't know how long your input data is going to be how can you >at least treat it a text line at a time... like looking for new line in >the data... Right now recv blocks. Yes I could do a select, but the >examples seem

ANN: DMetaph.py An implementation of the Double Metaphone algorithm

2006-08-25 Thread Timothy Grant
Hello everyone, I recently had a need to do some work with fuzzy matches, so I ported Lawrence Philips DMetaph class from C++ to Python. This is currently pretty much a line for line port of his his C++ code. It is not very pythonic at all. Because it is SO ugly, I'm not yet making it available

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Duncan Booth wrote: > lazaridis_com wrote: > > > Are ther alternative constructs/mechanism available, which could be > > used to add this functionality possiby directly to a code-module? > > How about something along these lines: > > -- auto.py - > import sys, atexit > > de

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Fuzzyman wrote: > lazaridis_com wrote: > > I would like to change the construct: > > > > if __name__ == '__main__': > > > > to something like: > > > > if exec.isMain(): > > > > My (OO thought) is to place a class in an separate code module and to > > instantiate an singleton instance which would ke

namespace problems

2006-08-25 Thread Kiran
Hi all, I am trying to get the following to work, but cant seem to do it the way i want to. ok, so I come into python and do the following: >>> x = 1 then, i have a file called test.py in which i say: print x Now, after having defined x =1 in the python interpreter, i come in and say: import te

Re: get a line of text from a socket...

2006-08-25 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, KraftDiner wrote: > If you don't know how long your input data is going to be how can you > at least treat it a text line at a time... like looking for new line in > the data... Right now recv blocks. Yes I could do a select, but the > examples seem a bit complicated for

Re: time.clock() going backwards??

2006-08-25 Thread K.S.Sreeram
Giovanni Bajo wrote: > Hello, > > I experimented something very strange, a few days ago. I was debugging an > application at a customer's site, and the problem turned out to be that > time.clock() was going "backwards", that is it was sometimes (randomically) > returning a floating point value whi

get a line of text from a socket...

2006-08-25 Thread KraftDiner
If you don't know how long your input data is going to be how can you at least treat it a text line at a time... like looking for new line in the data... Right now recv blocks. Yes I could do a select, but the examples seem a bit complicated for a simple line oriented input... -- http://mail.py

  1   2   >