Re: prime number

2005-05-29 Thread lostinpython
It is a homework assignment from a book but not for a class. I'm trying to teach my self some basic programming before I have to take it in college. If I show enough understanding of the subject, my advisor will let me forgo Intro. to Programming and go into Intro. to C++. What civil engineers ne

Re: finding indices in a sequence of parentheses

2005-05-29 Thread Peter Otten
tiissa wrote: > Steven Bethard wrote: >> (2) Does anyone see an easier/clearer/simpler[1] way of doing this? > > I'd personnally extract the parenthesis then zip the lists of indices. > In short: > > >>> def indices(mylist): > ... lopen=reduce(list.__add__, [[i]*s.count('(') for i,s in >

Re: network ping

2005-05-29 Thread garabik-news-2005-05
Sam the Cat <[EMAIL PROTECTED]> wrote: > Besides calling the external ping utility -- is there a way native to python > to execute a similar utility ? > > yes http://www.python.org/~jeremy/python.html -- --- | Radovan Garabík http://kas

Re: cpu usage limit

2005-05-29 Thread garabik-news-2005-05
[EMAIL PROTECTED] wrote: > I understand, that what I suggest does not solve the problem you want, > but.. > > Why do you want to restrict CPU usage to 30%? In Windows I run CPU there might be three reasons: 1) less power consumed (notebooks, PDA's) 2) less heat from CPU 3) (cross platform) schedu

test from hanaro sorry

2005-05-29 Thread Çϳª·Î
-- http://mail.python.org/mailman/listinfo/python-list

test sorrry

2005-05-29 Thread ´º½º66
aaa -- http://mail.python.org/mailman/listinfo/python-list

use of AttributesNSImpl in writing ?

2005-05-29 Thread spinach
I just can't find a good example for the use of AttributesNSImpl in the context of writing XML through XMLGenerator. I need to generate XML that uses several namespaces. The documentation is brief ("understands attribute names as two-tuples of namespaceURI and localname"), it appears you have to se

Re: prime number

2005-05-29 Thread Mike Meyer
"lostinpython" <[EMAIL PROTECTED]> writes: > I'm having trouble writing a program that figures out a prime number. > Does anyone have an idea on how to write it? All I know is that n > 2 > is prim if no number between 2 and sqrt of n (inclusivly) evenly > divides n. How about this (untested): im

Re: finding indices in a sequence of parentheses

2005-05-29 Thread Raymond Hettinger
[Steven Bethard] >> I have a list of strings that looks something like: >> lst = ['0', '0', '(*)', 'O', '(*', '*', '(*', '*))', '((*', '*)', '*)'] . . . >> I want the indices: >> (2, 2), (4, 7), (6, 7), (8, 9) and (8, 10) opener_stack = [] for i, elem in enumerate(lst): for c in elem:

Re: prime number

2005-05-29 Thread Tim Leslie
On 29 May 2005 19:55:32 -0700, lostinpython <[EMAIL PROTECTED]> wrote: > I'm having trouble writing a program that figures out a prime number. > Does anyone have an idea on how to write it? All I know is that n > 2 > is prim if no number between 2 and sqrt of n (inclusivly) evenly > divides n. Th

prime number

2005-05-29 Thread lostinpython
I'm having trouble writing a program that figures out a prime number. Does anyone have an idea on how to write it? All I know is that n > 2 is prim if no number between 2 and sqrt of n (inclusivly) evenly divides n. -- http://mail.python.org/mailman/listinfo/python-list

Monitoring Outgoing Connections?

2005-05-29 Thread Joseph Chase
Is it possible to write a client within Python that would trigger some sort of callback interface when the user is attempting to make an outgoing TCP/IP connection? I'd like to accomplish this on a Windows XP box. Is this something that could be accomplished with the Twisted framework, or am I

Re: Case Sensitive, Multiline Comments

2005-05-29 Thread Roy Smith
In article <[EMAIL PROTECTED]>, D H <[EMAIL PROTECTED]> wrote: > Elliot Temple wrote: > > Hi I have two questions. Could someone explain to me why Python is > > case sensitive? I find that annoying. > > I do too. As you've found, the only reason is because it is, and it is > too late to cha

Re: Case Sensitive, Multiline Comments

2005-05-29 Thread D H
Elliot Temple wrote: > Hi I have two questions. Could someone explain to me why Python is > case sensitive? I find that annoying. I do too. As you've found, the only reason is because it is, and it is too late to change (it was even too late back in 1999 when it was considered by Guido). I

Re: finding indices in a sequence of parentheses

2005-05-29 Thread Steven Bethard
tiissa wrote: > I'd personnally extract the parenthesis then zip the lists of indices. > In short: > > >>> def indices(mylist): > ... lopen=reduce(list.__add__, [[i]*s.count('(') for i,s in > enumerate(mylist)],[]) > ... lclose=reduce(list.__add__, [[i]*s.count(')') for i,s in > enume

Re: __getattribute__ and __getattr__

2005-05-29 Thread Terry Reedy
"Gigi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > In the Python documentation regarding __getattribute__ (more attribute > access for new style classes) it is mentioned that if __getattribute__ > is defined __getattr__ will never be called (unless called explicitely). > H

Re: stdout and stderr showing output only after script is done

2005-05-29 Thread MKoool
sorry i meant i installed python version 2.4.1, thanks MKoool wrote: > I just installed python 2.4 for windows. I was using the cygwin > version previously, but wanted to use the official python 2.4 release > to install a module that reads off some registry entries. > > After installing, I did wh

Re: stdout and stderr showing output only after script is done

2005-05-29 Thread MKoool
sorry, i'm an idoit who just found that i should use the -u option, my bad -- http://mail.python.org/mailman/listinfo/python-list

stdout and stderr showing output only after script is done

2005-05-29 Thread MKoool
I just installed python 2.4 for windows. I was using the cygwin version previously, but wanted to use the official python 2.4 release to install a module that reads off some registry entries. After installing, I did what I normally do, ssh to my local windows machine, and run the python script I

Re: cgi.py?

2005-05-29 Thread Skip Montanaro
david> I've looked into cgi.py from 2.4's distribution, and its contents david> puzzle me. In parse_header, the first line splits on ';': david> plist = map(lambda x: x.strip(), line.split(';')) david> but header parameters may contain semicolon in quoted strings: david>

network ping

2005-05-29 Thread Sam the Cat
Besides calling the external ping utility -- is there a way native to python to execute a similar utility ? -- http://mail.python.org/mailman/listinfo/python-list

__getattribute__ and __getattr__

2005-05-29 Thread Gigi
Hi, In the Python documentation regarding __getattribute__ (more attribute access for new style classes) it is mentioned that if __getattribute__ is defined __getattr__ will never be called (unless called explicitely). Here is the exact citation: """ The following methods only apply to new-styl

Re: Software licenses and releasing Python programs for review

2005-05-29 Thread John J. Lee
"poisondart" <[EMAIL PROTECTED]> writes: [...] > Ultimately I desire two things from the license (but not limited to): > - being able to distribute it freely, anybody can modify it > - nobody is allowed to make profit from my code (other than myself) [...] If you believe it's feasible to get contr

Re: Help with choice of suitable Architecture

2005-05-29 Thread John J. Lee
"Rob Cowie" <[EMAIL PROTECTED]> writes: > Thanks for the comments. > > I kind of get the impression that CGI is the way to go for this > application, and that I should forget about adding client-side > scripting based functionality for the sake of accessibility - which I > understand and kind of

Re: finding indices in a sequence of parentheses

2005-05-29 Thread tiissa
Steven Bethard wrote: > (2) Does anyone see an easier/clearer/simpler[1] way of doing this? I'd personnally extract the parenthesis then zip the lists of indices. In short: >>> def indices(mylist): ... lopen=reduce(list.__add__, [[i]*s.count('(') for i,s in enumerate(mylist)],[]) ...

2005 ICFP Programming Contest

2005-05-29 Thread Robby Findler
Think your favorite programming language is the best one out there? Put it to the test in this year's International Conference on Functional Programming's annual Programming Contest. The contest is coming up in a little under 4 weeks and we have just released more information (including a live cd,

Re: Process monitoring

2005-05-29 Thread gsteff
Thanks- subprocess was exactly what I needed. For anyone else that reads this, I just launched a new subprocess via subprocess.Popen, did what I needed to do in a while look, while calling the poll method of the Popen object to check whether it was finished, and if so, what its error code was. Pr

cgi.py?

2005-05-29 Thread david . tolpin
Hi, I've looked into cgi.py from 2.4's distribution, and its contents puzzle me. In parse_header, the first line splits on ';': plist = map(lambda x: x.strip(), line.split(';')) but header parameters may contain semicolon in quoted strings: Content-Type: image/jpeg; filename="home:lib;im

finding indices in a sequence of parentheses

2005-05-29 Thread Steven Bethard
I have a list of strings that looks something like: lst = ['0', '0', '(*)', 'O', '(*', '*', '(*', '*))', '((*', '*)', '*)'] The parentheses in the labels indicate where an "annotation" starts and ends. So for example, the label '(*)' at index 2 of the list means that I have an annotation at (2

Re: Newbie learning OOP

2005-05-29 Thread John Machin
LenS wrote: > Trying to learn OOP concepts and decided to use Python for this > purpose. I have coded the following CLASS and it seems to work fine. > Any comments on the code or suggestions would be appreciated. > > The class let you take a person's name and split it up into first last > and mid

Re: how to convert string to list or tuple

2005-05-29 Thread Steven Bethard
Duncan Booth wrote: > Dan Bishop wrote: >> Or if you do use eval, don't give it access to any names. [snip] >> os.system("rm -rf *") >> Traceback (most recent call last): >> File "", line 1, in ? >> File "", line 0, in ? >> NameError: name 'os' is not defined > > Have you tried giving it the s

How to restrict lenght of entry widget to certain number of character

2005-05-29 Thread Michael Onfrek
Hi! I'm playing with entry again and trying to restrict length of entry widget to certain number of character, so users cannot enter more character into it. Any ideas? Reg. Michael Onfrek -- http://mail.python.org/mailman/listinfo/python-list

Re: How to learn OO of python?

2005-05-29 Thread Harlin Seritt
? -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter weirdness item count

2005-05-29 Thread pavel.kosina
I think the answer you should find under Subject: Tkinter slowes down --- geon Exception is rule. phil napsal(a): > Using Tkinter Canvas to teach High School Geometry > with A LOT of success. > > My drawing gets very slow after a lot of actions. > > For instance I have created code to rotate a

Re: Case Sensitive, Multiline Comments

2005-05-29 Thread Elliot Temple
On May 29, 2005, at 11:44 AM, Arthur wrote: > On 26 May 2005 17:33:33 -0700, "Elliot Temple" <[EMAIL PROTECTED]> > wrote: > > >> Thanks for the link on case sensitivity. I'm curious about the >> person >> who found case sensitivity useful though: what is it useful for? >> > > I am curious abou

Re: double w pythonie?

2005-05-29 Thread turbos10
w turbos10 napisał(a): > Witam! > Z jaka precyzja python dokonuje obliczen zmiennoprzecinkowych. Czy > jest w pythonie typ podwojnej precyzji (double z c). sorry! -- Uwagi o błędach ortograficznych czy interpunkcyjnych, oraz wszelkie słowne utarczki załatwiaj listami p

double w pythonie?

2005-05-29 Thread turbos10
Witam! Z jaka precyzja python dokonuje obliczen zmiennoprzecinkowych. Czy jest w pythonie typ podwojnej precyzji (double z c). Pozdrawiam -- Uwagi o błędach ortograficznych czy interpunkcyjnych, oraz wszelkie słowne utarczki załatwiaj listami prywatnymi. -- http://mail.python.org/mailman/listin

Re: Software licenses and releasing Python programs for review

2005-05-29 Thread poisondart
With the exception of the example with neighbour Bobby (which directly utilizes my code for profit, in which case is a definite no), I don't see why your other examples should make me reconsider releasing my software for free--in all the cases you've described, the answer should be no. You publish

Re: Case Sensitive, Multiline Comments

2005-05-29 Thread Arthur
On 26 May 2005 17:33:33 -0700, "Elliot Temple" <[EMAIL PROTECTED]> wrote: >Thanks for the link on case sensitivity. I'm curious about the person >who found case sensitivity useful though: what is it useful for? I am curious about why you find case sensitivity annoying. But just mildly curious.

Re: 2D vector graphics Problem

2005-05-29 Thread Scott David Daniels
Karl Max wrote: > "Scott David Daniels" <[EMAIL PROTECTED]> ha scritto nel messaggio >>... Your equation for y uses the new x, not the old x > De hi hi ho. I must sleep some more hours at night... ;-) >>Be more free with names. > > Well, I often report book formulas, and forget renaming varia

Re: 2D vector graphics Problem

2005-05-29 Thread Karl Max
"Scott David Daniels" <[EMAIL PROTECTED]> ha scritto nel messaggio news:[EMAIL PROTECTED] >> x = x * cos - y * sin - xRel * cos + yRel * sin + xRel >> y = x * sin + y * cos - xRel * sin - yRel * cos + yRel >> self.coords = (x,y) > > Your equation for y uses the new x, not the old x. De hi hi

Re: how to convert string to list or tuple

2005-05-29 Thread John Roth
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dan Bishop wrote: > >> Simon Brunning wrote: >>> [...] >> >> Or if you do use eval, don't give it access to any names. >> >>> [...] >> os.system("rm -rf *") >> Traceback (most recent call last): >> File "", line 1, in

tracing crash

2005-05-29 Thread Nir Aides
Hi, I am facing a strange problem. I will appreciate an explanation and a work around for the problem. Look in the following code paste. It seems that taking a reference to the frame object crashes python in some scripts: # # trace_hell.py # # crashes with spe (stani's python editor) v0.7.3.a #

Re: how to convert string to list or tuple

2005-05-29 Thread Duncan Booth
Dan Bishop wrote: > Simon Brunning wrote: >> [...] > > Or if you do use eval, don't give it access to any names. > >> [...] > os.system("rm -rf *") > Traceback (most recent call last): > File "", line 1, in ? > File "", line 0, in ? > NameError: name 'os' is not defined > Have you tried giv

Re: 2D vector graphics Problem

2005-05-29 Thread Scott David Daniels
Karl Max wrote: > def rotate(self, w): > # This method belongs to the class Vertex > # w = angle expressed in radiants > x, y = self.coords > xRel, yRel = self.relPoint # The rotation should be relative to this > sin, cos = math.sin(w), math.cos(w) > x = x * cos - y * sin - xRel * cos + yRel

Re: Help with choice of suitable Architecture

2005-05-29 Thread Rob Cowie
Thanks for the comments. I kind of get the impression that CGI is the way to go for this application, and that I should forget about adding client-side scripting based functionality for the sake of accessibility - which I understand and kind of agree with. I'll look into the problem of concurrent

Re: how to convert string to list or tuple

2005-05-29 Thread Dan Bishop
Simon Brunning wrote: > On 5/26/05, flyaflya <[EMAIL PROTECTED]> wrote: > > a = "(1,2,3)" > > I want convert a to tuple:(1,2,3),but tuple(a) return ('(', '1', ',', > > '2', ',', '3', ')') not (1,2,3) > > Short answer - use eval(). > > Long answer - *don't* use eval unless you are in control of the

Re: Intellisense and the psychology of typing

2005-05-29 Thread Vincent Foley
I have rapidly skimmed over the few responses here. Auto completion is definitly possible in dynamic languages: Common Lisp has it with its Emacs mode, SLIME. If you're in a slime buffer, you type (get-un then press C-c Tab and Emacs will auto-complete with (get-universal-time), if there are many

Re: Newbie learning OOP

2005-05-29 Thread Steven Bethard
LenS wrote: > class names: > def __init__(self, format = "F"): > self.format = format > > def namesplit(self, name): > if self.format == "F": > self.namelist = name.split() > self.first = self.namelist[0] > self.init = self.namelist[1] >

Re: How do i read just the last line of a text file?

2005-05-29 Thread Terry Reedy
"Andy Leszczynski" > What if a file is long enough? I believe you meant "What if a file is too long to read all into memory at once?" If the file is randomly accessible (with file.seek() backwards from the end) then you can read a chunk at the end that you expect to be large enough to contain

Re: How do i read just the last line of a text file?

2005-05-29 Thread nephish
cool. thanks for the help guys ! -- http://mail.python.org/mailman/listinfo/python-list

Re: How do i read just the last line of a text file?

2005-05-29 Thread Steven Bethard
Andy Leszczynski wrote: > Chris F.A. Johnson wrote: >>And to answer the question in the subject line: >> >> last_line = file(argv[1]).readlines()[-1] >> >>Both of which assume "from sys import argv". > > What if a file is long enough? Huh? You mean what if it's too big to fit in memory?

Re: need help of RE

2005-05-29 Thread Steven Bethard
John Machin wrote: > >>> import re > >>> text = "(word1 & (Word2|woRd3))".lower() > # you seem to want downshifting ... > >>> re.split(r"\W+", text) > ['', 'word1', 'word2', 'word3', ''] > >>> > > Hmmm ... near, but not exactly what you want. We need to throw away > those empty strings, which

Re: 2D vector graphics Problem

2005-05-29 Thread F. GEIGER
> xRel, yRel = self.relPoint # The rotation should be relative to this Shouldn't it be x -= xRel y -= yRel xR = x * cos(phi) - y * sin(phi) yR = x * sin(phi) + y * cos(phi) then? Regards Franz GEIGER "Karl Max" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > Hi all, > > I

Re: SWIG std::string& passing

2005-05-29 Thread jchiang
Add the line %include stl.i to your .i file. This will make other stl containers available, in addition to string. Make sure you put this line before any include directives for classes that use std::string. SWIG requires classes to be declared before they are used in order for the interfaces to

Re: Entry scroll doesn't work

2005-05-29 Thread VK
VK wrote: > Hi! > Can entry widget be scrolled? > VK > > TypeError: xview() takes exactly 2 arguments (4 given) > > Code: > > > > from Tkinter import * > class ScrollEntry: > def __init__(self): > self.root = Tk() > self.scrollbar = Scrollbar(self.root,orient=HO

Re: How do i read just the last line of a text file?

2005-05-29 Thread Andy Leszczynski
Chris F.A. Johnson wrote: > On Sun, 29 May 2005 at 05:57 GMT, John Machin wrote: > >>Chris F.A. Johnson wrote: >> >> >>>file = open(argv[1]) ## Open the file given on the command line >>>all_lines = file.readlines() ## Read all the lines >> >>I see your shadowing and raise you one obfusc

Entry scroll doesn't work

2005-05-29 Thread VK
Hi! Can entry widget be scrolled? VK TypeError: xview() takes exactly 2 arguments (4 given) Code: from Tkinter import * class ScrollEntry: def __init__(self): self.root = Tk() self.scrollbar = Scrollbar(self.root,orient=HORIZONTAL,) self.entry =

Re: Trying to understand pickle.loads withou class declaration

2005-05-29 Thread Philippe C. Martin
Thanks, Philippe Sébastien Boisgérault wrote: > Even > > class A: > pass > > should do the trick. Only the instance attributes are saved by a > pickle, > not the methods or the class itself. The unpickler tries to merge the > saved data and the class/method info that is not saved

Re: Copy paste in entry widget

2005-05-29 Thread VK
Michael Onfrek wrote: > Hi, > is copy, paste, cut of selection possible in entry widget? Docs say > selection must be copied by default, in my programm it doesn't work. > Regards, M.O. > Hear it is def paste(self): self.entry.event_generate('') def cut(self):

Re: Is there a better way of doing this?

2005-05-29 Thread Duncan Booth
Michael wrote: > I'm fairly new at Python, and have the following code that works but > isn't very concise, is there a better way of writing it?? It seems > much more lengthy than python code i have read. :-) > (takes a C++ block and extracts the namespaces from it) Yes, there is a better way

Newbie learning OOP

2005-05-29 Thread LenS
Trying to learn OOP concepts and decided to use Python for this purpose. I have coded the following CLASS and it seems to work fine. Any comments on the code or suggestions would be appreciated. The class let you take a person's name and split it up into first last and middle. The class defaults

2D vector graphics Problem

2005-05-29 Thread Karl Max
Hi all, I'm new here. Name's Max from tuscany, and I don't speak english very well :-) I am not veteran at coding, I am most like an "artisan coder" since commodore 64 times. Now the problem: I would like to have a little 2d engine to calculate and trace segments and poly's and their collision

Re: how to convert string to list or tuple

2005-05-29 Thread Steven D'Aprano
On Thu, 26 May 2005 19:53:38 +0800, flyaflya wrote: > a = "(1,2,3)" > I want convert a to tuple:(1,2,3),but tuple(a) return ('(', '1', ',', > '2', ',', '3', ')') not (1,2,3) Others have already given some suggestions. Here are some others. You didn't say where the input string a came from. Do y

nice OOP training problem

2005-05-29 Thread Anton Vredegoor
I found this on the web: http://www.setgame.com/set/puzzle_frame.htm and I'm currently trying to develop a script that models this space and that gives a nice graphic display. Also developing a solver for this or larger spaces looks interesting. I'm not asking for assistance, it just looks like s

Re: first release of PyPy

2005-05-29 Thread Anton Vredegoor
Kay Schluehr wrote: > Anton Vredegoor wrote: > > > I'm not involved in PyPy myself but this would seem a logical > > possibility. To go a step further, if the compiler somehow would know > > about the shortest machine code sequence which would produce the > > desired effect then there would be no r

Re: Is there a better way of doing this?

2005-05-29 Thread Roman Yakovenko
On 5/29/05, Cyril BAZIN <[EMAIL PROTECTED]> wrote: > Hi, > > I don't know very well what you want to do, but if you want to parse c++, > take a look at "GCC-XML python" (http://www.gccxml.org) and the python > binding (http://pygccxml.sourceforge.net/). These tools > translate c++ code to XML. T

Re: the problem with cgi

2005-05-29 Thread Ivan Van Laningham
Hi All-- EP wrote: > > > Has anyone seen that problem with running a python cgi script in a > > server? > > It takes you to myspace.com/redmartian or something. Anyway, does > > anyone know when this problem will be fixed? > > Xah Lee is working on it. > Oh, that's reassuring. Does he have hi

Re: Trying to understand pickle.loads withou class declaration

2005-05-29 Thread Sébastien Boisgérault
Even class A: pass should do the trick. Only the instance attributes are saved by a pickle, not the methods or the class itself. The unpickler tries to merge the saved data and the class/method info that is not saved to recreate the fully functional instance... but of course this info

Re: Is there a better way of doing this?

2005-05-29 Thread Cyril BAZIN
Hi, I don't know very well what you want to do, but if you want to parse c++, take a look at "GCC-XML python" (http://www.gccxml.org) and the python binding (http://pygccxml.sourceforge.net/). These tools translate c++ code to XML. Then, you can parse xml with your favorite tools and find the name

Re: Help with choice of suitable Architecture

2005-05-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Paul Rubin wrote: . . . >good reason" exception. I dunno about "suggest". I do see that . . .

Re: ControlDesk Automation in dSpace

2005-05-29 Thread Sébastien Boisgérault
Crispen a écrit : > I am having trouble using the ControlDesk automation libraries in > python. In particluiar running the automation in a thread. My code is > as follows, is keeps coming up with this strange error. Any help would > be great. > > Crispen > > import cdacon > from time import sleep >

Re: Is there a better way of doing this?

2005-05-29 Thread Fredrik Lundh
Steven D'Aprano wrote: > Guido (our Benevolent Dictator For Life and creator of Python) hates > seeing whitespace next to parentheses. I agree with him. while(newNS) > good, while( newNS ) bad. while is a statement, so while(newNS) is bad in more than one way. -- http://mail.python.org/mail

Re: Is there a better way of doing this?

2005-05-29 Thread Steven D'Aprano
On Sat, 28 May 2005 13:24:19 +, Michael wrote: > Hi, > I'm fairly new at Python, and have the following code that works but isn't > very concise, is there a better way of writing it?? It seems much more > lengthy than python code i have read. :-) > (takes a C++ block and extracts the names

Re: Getting value of radiobutton trouble

2005-05-29 Thread VK
Philippe C. Martin wrote: > PS: Since your starting with TKinter, and although I do not know what your > goal is, I suggest you take a look at wxPython: it is _wonderfull_ ! (no > offence to TCL/TK) > > Regards, > > Philippe > > > > > > > VK wrote: > > >>Philippe C. Martin wrote: >> >>>Hi

Re: Copy paste in entry widget

2005-05-29 Thread Michael Onfrek
I need it for Linux, so far only TkInter used. -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating dict from keys and values

2005-05-29 Thread Just
In article <[EMAIL PROTECTED]>, Dirkjan Ochtman <[EMAIL PROTECTED]> wrote: > Hi there, > > I'm looking for an intuitive way of creating a dict from what the > dict.keys() and dict.values() will return (two lists). > > Currently, I'm using this code: > > > d = {} > > for i in range(len(data)):

ControlDesk Automation in dSpace

2005-05-29 Thread Crispen
I am having trouble using the ControlDesk automation libraries in python. In particluiar running the automation in a thread. My code is as follows, is keeps coming up with this strange error. Any help would be great. Crispen import cdacon from time import sleep from cdautomationlib import * def

Creating dict from keys and values

2005-05-29 Thread Dirkjan Ochtman
Hi there, I'm looking for an intuitive way of creating a dict from what the dict.keys() and dict.values() will return (two lists). Currently, I'm using this code: > d = {} > for i in range(len(data)): > d[header[i]] = data[i] But this feels kind of inelegant. So: is there a better way?

Re: Xml writing in Python and verifying using XSD

2005-05-29 Thread Prashanth Ellina
Diez B. Roggisch wrote: > Use StringIO to capture the output of your writings, and use a > xsd-validating parser (not sure which one, but google should help) to > reread that. Or a temporary file. Thank you very much. I'll try that. -- http://mail.python.org/mailman/listinfo/python-list

Re: need help of RE

2005-05-29 Thread John Machin
cheng wrote: > hi all > a string like > > "(word1 & (Word2|woRd3))" > > how can i use the re to split it to > > ['word1', 'word2', 'word3'] > OK, so you know about the re module. Look in the manual: there's a module-level function called "split", with an example similar to yours. Did you try

Re: need help of RE

2005-05-29 Thread vincent wehren
"cheng" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] | hi all | a string like | | "(word1 & (Word2|woRd3))" | | how can i use the re to split it to | | ['word1', 'word2', 'word3'] | import re s = "(word1 & (Word2|woRd3)" parts = re.split('\W+', s) print [p for p in parts if

Re: need help of RE

2005-05-29 Thread cheng
thx for help..i got it now :) -- http://mail.python.org/mailman/listinfo/python-list

Re: need help of RE

2005-05-29 Thread Chris F.A. Johnson
On Sun, 29 May 2005 at 07:39 GMT, cheng wrote: > hi all > a string like > > "(word1 & (Word2|woRd3))" > > how can i use the re to split it to > > ['word1', 'word2', 'word3'] This splits the string on one or more occurrences of any character that is not alphanumeric: import re str = "(

Re: need help of RE

2005-05-29 Thread tiissa
cheng wrote: > im sorry, my engilsh is not vell well, That's alright, you could have been french. ;) > the string not only contain '&' and '|' and it can be anyting > > i just want to split out the "whole word" inside the string Look at the example for split function of re module in the doc [1]

Re: need help of RE

2005-05-29 Thread Elliot Temple
On May 29, 2005, at 12:57 AM, cheng wrote: > im sorry, my engilsh is not vell well, > > the string not only contain '&' and '|' and it can be anyting > > i just want to split out the "whole word" inside the string If the string could be anything, how do you know where the words are? If it's whi

Re: need help of RE

2005-05-29 Thread cheng
i try theString= theString.lower() print re.split(r'\W+',theString) the reslut is : ['', 'word1', 'word2', 'word3', ''] how can i fix the statment to get ['word1', 'word2', 'word3'] -- http://mail.python.org/mailman/listinfo/python-list

Re: need help of RE

2005-05-29 Thread cheng
i try query = query.lower() print re.split(r'\W+',theString) the reslut is : ['', 'word1', 'word2', 'word3', ''] how can i fix the statment to get ['word1', 'word2', 'word3'] -- http://mail.python.org/mailman/listinfo/python-list

Re: need help of RE

2005-05-29 Thread cheng
im sorry, my engilsh is not vell well, the string not only contain '&' and '|' and it can be anyting i just want to split out the "whole word" inside the string -- http://mail.python.org/mailman/listinfo/python-list

Re: need help of RE

2005-05-29 Thread Elliot Temple
On May 29, 2005, at 12:39 AM, cheng wrote: > hi all > a string like > > "(word1 & (Word2|woRd3))" > > how can i use the re to split it to > > ['word1', 'word2', 'word3'] Could you be more exact about what the string is like? Does it literally contain the characters '&' and '|' ? If so, just

Re: How do i read just the last line of a text file?

2005-05-29 Thread Chris F.A. Johnson
On Sun, 29 May 2005 at 05:57 GMT, John Machin wrote: > Chris F.A. Johnson wrote: > >> file = open(argv[1]) ## Open the file given on the command line >> all_lines = file.readlines() ## Read all the lines > > I see your shadowing and raise you one obfuscation: ;) > open = file(argv[

Re: the problem with cgi

2005-05-29 Thread EP
> Has anyone seen that problem with running a python cgi script in a > server? > It takes you to myspace.com/redmartian or something. Anyway, does > anyone know when this problem will be fixed? Xah Lee is working on it. -- http://mail.python.org/mailman/listinfo/python-list

need help of RE

2005-05-29 Thread cheng
hi all a string like "(word1 & (Word2|woRd3))" how can i use the re to split it to ['word1', 'word2', 'word3'] -- http://mail.python.org/mailman/listinfo/python-list