Set operations for lists: pythonic hints please!
Working with several thousand tagged items on a Tkinter Canvas, I want to change different configurations of objects having a certain group of tags. I've used the sets module, on the tuple returned by Tkinter.Canvas. find_withtag() method. Since this method takes only one tag at time, I use it for each tag that is part of the look-up group, create a set object for each tuple and intersect the resulting sets, that I tuple out again to feed a loop to change the configuration of the items. Anyone have a more pythonic way (or better performing ) way to suggest ? Thanks in advance, Jean-Marc # My test code # the code is not generic here # my question only pertains to the intersection algorithm perse from Tkinter import * import random, sets root=Tk() m1 = Canvas(root,width=410,height=410) m1.pack(fill=BOTH, expand=1) for i in range(10): x=random.randrange(1,400) y=random.randrange(1,400) m1.create_oval(x,y,x+10,y+10,fill="red",tags=("etoile","rouge")) for i in range(10): x=random.randrange(1,400) y=random.randrange(1,400) m1.create_rectangle(x,y,x+10,y+10,fill="red",tags=("artefact","rouge")) for i in range(10): x=random.randrange(1,400) y=random.randrange(1,400) m1.create_rectangle(x,y,x+10,y+10,fill="green",tags=("artefact","green")) # i=m1.find_withtag("artefact") j=m1.find_withtag("rouge") s1=sets.Set(i) s2=sets.Set(j) s3=s1.intersection(s2) myIntersection=tuple(s3._data.keys()) for i in myIntersection: m1.itemconfig(i,fill="black") root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Set operations for lists: pythonic hints please!
Ouppsss! the title should have read:Set operation for tuples... (sigh!) -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple server/client application
Simon Percivall wrote: > You're calling the grid() method on the Entry object you're > instanciating. Are you sure that the grid() method returns the Entry > object so that you're actually binding it to self.myAddress? The widget maker should do it in two steps instead of one. So instead of: self.myAddress=Entry(self.root,relief=SUNKEN).grid(row=1,column=1,sticky=W) Make it thus: self.myAddress = Entry(self.root,relief=SUNKEN) # make it and keep it here self.address.grid(row=1,column=1,sticky=W) # grid it here in the create_widgets method. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question
Geirr wrote: > Hi, ive just started playing around with python and wondered if someone > could poing me in the right way here. > > > I have a xmlrpc server simple script: > > Server script: > import SimpleXMLRPCServer > class tpo: > > def retTPOXML(): > theFile=open('tpo.xml') > try: > self.strXML = theFile.read() > return self.strXML > finally: > theFile.close() > > tpo_object = tpo() > server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost",)) > server.register_instance(tpo_object) > > print "Listening on port " > server.serve_forever() > > and im trying to print the return value with any luck > > Client Code: > import xmlrpclib > server = xmlrpclib.ServerProxy("http://localhost:";) > current = server.retTPOXML > print current > > > Any comment would be appriciated First: in python, class definitions require that you explicitly refer to the instance, such as self.myMethod(). In *self.strXML* the word *self* is a variable, it should be part of the method parameter list such as *def retTPOXML(self):*. The first parameter of methods (functions in classes) refers to the instance that is created. (BTW, it could be anything else than *self*, which is pure convention) Second: In the client, your not using the method you're refering to it (methods are yet another sort of objects), yu need the parenthesis such as *current = server.retTPOXML()* Notice that on calling the method the object is on the left side of the dot, and that is the object instance that will be adequated to the *self* in the class definition. but you should also read the tutorial. (others may propose things otherwise (better versed in the theory at work behind the scene... ;-)) -- http://mail.python.org/mailman/listinfo/python-list
Re: how to associate files with application
Ashok wrote: > hi, > i want to know how to make a specific type of file open in an > application i developed in python when the user clicks on the file.(in > windows) for eg. a .txt file when clicked opens in notepad, a .doc file > when clicked opens in MS-word. In the same way i want to make a .xyz > file open in the application i developed when clicked. > thanks in advance for any advice. Not an expert in this (OS-related) field but in Windows I think that would be a Registry thing... Maybe this article could help you start somewhere... http://antivirus.about.com/od/windowsbasics/l/blfileassoc4.htm Good Luck, and maybe you can reply-post your eventual success recipe! -- http://mail.python.org/mailman/listinfo/python-list
Re: Can Anyone Help me on this
[EMAIL PROTECTED] wrote: > i m trying to reverse the order in which the > strings are stored in list > > then pop it into another list > > what m i doin worng?? > > here's the code: > > list1 = [] > list2 = [] > list1.extend('123456789') > > print list1 > > for a in list1: > list2 = list1.pop() > > print list2 > -- > * Posted with NewsLeecher v3.0 Beta 7 > * http://www.newsleecher.com/?usenet well, mant things are happening, so many it's not clear to me what you're trying to do... BUT, considering your for statement, since you are poping elements out of list you are shortening it, so you are only getting as far as element '5' If what you want is a reversed copy, you could just append list1 elements to list2, and use the reverse function such as >>> ... >>> for i in list1: ... list2.append(i) ... >>> list2.reverse() >>> list1 ['1', '2', '3', '4', '5', '6', '7', '8', '9'] >>> list2 ['9', '8', '7', '6', '5', '4', '3', '2', '1'] -- http://mail.python.org/mailman/listinfo/python-list
Re: Can Anyone Help me on this
... list2=list1[:] ... Yes, naturally, where was my head ?-)) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python doc problem example: gzip module (reprise)
Sorry but I take exception on this subject. I still think Fredrik's Intro to Tkinter is still more usable ... Grayson's book uses PMW extensively, and a lot is about specific widgets of that library. This actually brings us back to the jest of F. previous post, that documentation is question of multiple source reference, and yes that you have to work the field (Google search, newgroups, cookbooks, source-code, et al) a little bit to get some information. In time, one goes from newbie to casual-user, to regular-user and createds his own setof useful references ... Simple ready-to-eat recipes are just that - fast-food for the mind! (Ok some of it is delicious, even nourishing ;-) ) -- http://mail.python.org/mailman/listinfo/python-list
Re: I need Motivation
And you know what? I almost sure most people on this newsgroup wouldn't feel maligned if somebody told them that's what happened to them. I'd put money that most pythonistas here would think 'Hey Great for you! good luck, and make these machines ever more useful and/or enjoyable for the rest of the universe and yourself!' But that's only how I feel about this perticular newsgroup and community! (But I've been knowned to be naïve ...) -- http://mail.python.org/mailman/listinfo/python-list
Re: text widget example?
Well, in the 'give me a free example' type questions, I guess I'm a bit blue tonight, so here goes: ( no personal pun intended, just look up some recent post in this newsgroup...) # Start the example Python code to show some text file in a text widget from Tkinter import * # import Tkinter in __main__ namespace root = Tk() # initialize Tkinter myTextWidget= Text(root) # set up a text widget as a root (window) child myFile=file("myTextFile.txt") # get a file handle myText= myFile.read() # read the file to variable myFile.close() # close file handle myTextWidget.insert(0.0,myText) # insert the file's text into the text widget myTextWidget.pack(expand=1, fill=BOTH) # show the widget root.mainloop() #run the events mainloop # End the example here You need a text file *myTextFile.txt* in your current working directory for this to work. Read-up on the different objects and properties for detail. Good luck! BTW, now that this is posted, I guess one could say that it's an example on the Internet -- http://mail.python.org/mailman/listinfo/python-list
Re: click event
I guess you mean draw lines from the laast coordinates to the new one? then add a few global variables: lastX="" lastY="" # and modify lastX="" lastY="" def click(event): global lastX, lastY if lastX != "": c.create_line(lastX,lastY,event.x,event.y,fill="white") lastX = event.x lastY = event.y -- http://mail.python.org/mailman/listinfo/python-list
Re: how to present Python's OO feature in design?
Do you mean code-generators for Python from UML? If not, please give some hints in what OOP features you're interested in, because I can't see how use-case, class, instance (objects), package, sequence,( ... other ) diagram would differ in Python from Java from an OOP perspective? -- http://mail.python.org/mailman/listinfo/python-list
Re: RAW_INPUT
The raw_input('Who Goes there?') function writes out the arg and then waits for *user input* , and that is considered terminated when you hit return. Since you only hit return without typing 'Josh' first you get an empty string "" which is then printed to screen... ('You may pass,'+"") Type something and it will appear NOTE: the string variable (print "you may pass, %s" % s ) is uncalled for... Good luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python doc problem example: gzip module (reprise)
(gulp! red-in-the-face) yes Steve, I meant "gist", sorry if I offended anyone, specially Fredrik since I was referring to the 'substance' of his post...certainly not as if it were a 'joke' . Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter- Building a message box
Maybe this can help: http://effbot.org/zone/tkinter-dialog-windows.htm Good luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: XML GUI
Brendan wrote: > py wrote: > > how about wxPython? I am interested in something that will look native > > on various operating systems (win, mac, *nix). > > > > any good tutorial on using wxPython with XML? > > The wxPython distribution comes with XRCed, which is a graphical > gui-builder that serializes to XRC (wxWidgets XML syntax). > > (I'm assuming you just want to use XML to describe the gui. If you > want to define your own xml syntax, then you'll have to wait for > someone more experienced than me for help. There are several packages > for using cusom XML. You can start here: > http://effbot.org/zone/element-index.htm) > > Brendan And you can check this effbot page, for a XML to GUI example.! See "more stupid element tricks: generating tkinter user interfaces from xml, part 1 " at http://online.effbot.org/2003_08_01_archive.htm Good luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: which feature of python do you like most?
James wrote: > Most of the responses are of the "Why Python is more pleasant than C++" > variety, but the original poster specifically said he had experience > with Perl. As such, arguments like "automatic memory management" don't > carry any weight. > > >From my experience as both a Perl and Python user--and I do prefer Perl > for many tasks--the big win for Python is when you have complex data > structures: dictionaries containing arrays, arrays of arrays, array of > dictionaries, and so on. This kind of thing is awkward in Perl (you > need to use references), but perfectly natural and obvious in Python. Well, I didn't know Perl when I was asked to teach a Web development class. I had heard that Perl was CGI standard... So I started to do some Perl and was aghast at what I needed to learn (I don't like special caracters that make code look like martian poetry). Then I read some articles pertaining to Python and CGI and look up that language (I had read a comment by a Java-C++ Guru, favorable to Python). Wow, I understood everything I was reading, and I could think of how other things might work, and by god, they did very often. Like some others have said elsewhere: Python fitted my brain! That's what made it special for me! and it still feel like this to this day! I hope it works for you, if not maybe some other one will (Ruby, Lua, Haskell, O'Caml, C# ;-) ) Never looked back since... -- http://mail.python.org/mailman/listinfo/python-list
Re: Goto XY
WConio does this for Windows. See... getkey() and gotoxy() http://newcenturycomputers.net/projects/wconio.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Goto XY
Like David said below, you need to import WConio but then repemeber when you *import someLib* you have to use qualified names such as WConio.getkey() Example: import WConio s=WConio.getkey() if s == "right": WConio.gotoxy(10,10) WConio.putch("W") s=WConio.getch() -- http://mail.python.org/mailman/listinfo/python-list
Re: Goto XY
Like David said above... ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Newb ??
[EMAIL PROTECTED] wrote: > Chad Everett wrote: > > Hi all, I am new to the group. Trying to learn Python programming on my > > own. I am working through Michael Dawson's Book Python Programming for the > > absolute beginner. > > > > I am tring to write a program that is a number guessing game. I want to be > > able to give the user 5 tries to guess the number before the program ends. > > > > I get the result that I want when the user misses after the 5th try. But it > > does not go down to my closing statement to end. Rather is askes for > > another guess. > > Because even after 5 tries, guess != the_number. You won't get past > the while loop until it does. When there have been 5 misses, try > setting > guess=the_number. > > > > > I appreciate any help you can give. If this is not the correct group for > > these types of questions, I apologize and hope that you can direct me to > > another NG. > > > > Thanks, > > Chad > > > > import random > > > > print "\tWelcome to 'Guess my Number'!" > > print "\nI'm Thinking of a Number between 1 and 100." > > print "\nTry to Guess it in as few attempts as possible.\n" > > > > #Set the initial values > > the_number = random.randrange(100) + 1 > > guess = int(raw_input("Take a guess:")) > > tries = 1 > > > > #Guessing Loop > > > > while (guess != the_number): > > if (guess >the_number): > > print "Lower..." > > else: > > print "Higher..." > > guess = int(raw_input("Take another Guess:")) > > tries +=1 > > if tries == 5: > > print "Sorry you lose." > > print "The Correct Number was ", the_number > > > > > > print "You guess correctly!!" > > print "The number was:", the_number > > print "You got it correct in", tries, "tries" > > > > raw_input("Press Enter to exit the program") here is your corrected version: ##FROM here it's good import random print "\tWelcome to 'Guess my Number'!" print "\nI'm Thinking of a Number between 1 and 100." print "\nTry to Guess it in as few attempts as possible.\n" #Set the initial values ## Here you always get 100, randrange is from start to end+1 the_number = random.randrange(0,101) ##This is OK guess = int(raw_input("Take a guess:")) tries = 1 #Guessing Loop while (guess != the_number): if (guess >the_number): print "Lower..." else: print "Higher..." guess = int(raw_input("Take another Guess:")) tries +=1 if tries == 5: ## Missing break to explicitly leave loop after 5 break ## Then test to see if last guess equals the_number if guess != the_number: print "Sorry you lose." print "The Correct Number was ", the_number else: print "You guess correctly!!" print "The number was:", the_number print "You got it correct in", tries, "tries" raw_input("Press Enter to exit the program") -- http://mail.python.org/mailman/listinfo/python-list
Re: Newb ??
## Here you always get 100... This is false , sorry for the wrong comment on this part, it should rather be: ## randrange is from start to end-1 the_number = random.randrange(1,101) JM (But the rest of my comment seems OK) -- http://mail.python.org/mailman/listinfo/python-list
Recommendation please: forming an XML toolkit
I'm asking help on this topic of building a tools foundation for future XML projects because of the sheer volume of possibilities I will not have the time to check/try/test in detail. This question is a bit like the ones pertaining to 'Which web framework to use?', there is a lot of good stuff out there, and often it boils down to personnal preference, mind-fitting interface and such BUT... to make it more precise I will give more context on the future projects involved... I've done some homework trying out a few packages based on published tutorial: Boddie's Python and XML: An Introduction (for minidom), Lundh's elementTree examples, I read a bit about Amara, pyXML, others. I've read a bit on ease-of-use, benchmarks, pythonesque versus job-protection perspectives, I've even tried building my own xml2PythonObjects2xml tools Finally, I've read-up a few threads pertaining to the question 'which XML packages to use' ! Some considerations I have using XML : 1- representing inter-connected academic articles in text-based files whitout a sopecific BD package 2- being 'easily' able to modify the structure of these documents as search tools evolve 3- searching through these articles often, and with evolving algortihmic complexity (from word base search to RDF-type meta data, to OWL-type semantic information, etc) 4- In a context where I'm (in a practical form) evangelizing the use of Python as a great tool from going from 'this could be a new approach' to 'this piece of code realizes that approach' (managers need to be confident that they could choose to make this set of articles evolve using other languages (other developpers not caring for Python for example, but Java instead) and the infobase would be directly accessible and algorithms understandable from a 'popular' xml-manipulation point-of-view (Using DOM, I guess a regular DOM-SAX Java developper would understand Python code, but would they if the code relied heavily on elementTree (for example) 5- relying as less as possible on complex third-party libs (to use A, first get B from elsewhere, which itself requires C from still another place...) I DON'T mind the simple package (PIL comes to mind here) 6- VERY IMPORTANT CONSIDERATION - That I can keep my focus on developing algorithms, MINIMIZING XML clutter I don't want to become a XML guru - I like the simple principle of XML as a tree of tagged elements that have attributes and text data... Thanks for any and all who read this, and those who have experience ressembling what I'm about to embark on for your help ! Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: How to set program name in Python? ($0 in Perl)
This is not directly what the OP wanted in regards to Perl, but to see what one could do if one needed to change the name of the running program, I wrote this: ## START PROGRAM import sys import os.path import shutil import os def testChangingName(appname): hopedfornameis = appname mylongnameis = sys.argv[0] mynameis = os.path.basename(mylongnameis) basenameis = os.path.dirname(mylongnameis) if mynameis != hopedfornameis: shutil.copyfile(mynameis, basenameis+"/"+hopedfornameis) os.spawnv(os.P_NOWAIT,"c:/python23/python.exe",('c:/python23/python.exe',hopedfornameis)) sys.exit() if __name__ == "__main__": print sys.argv[0] testChangingName("testNameIsChanged.py") s=raw_input("All's well!") s=raw_input("Now do something useful") ## END PROGRAM Since I don't know the circumstance in which the OP wanted to change the name, I really don't know what caveats one should look out for here. I would be curious to know when such a function could come in handy. Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Recommendation please: forming an XML toolkit
I guess you're right... I think its just cold feet from the possibility of getting involved and discovering specific gotchas later. What I'm hearing you tell me is *go and play it*. Thanks for replying... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python worth it??
Simon Brunning wrote: > On 14/11/05, john boy <[EMAIL PROTECTED]> wrote: > > I have started out trying to learn Python for my first programming language. > > I am starting off with the book "how to think like a computer scientist." > > I spend about 4-5 hrs a day trying to learn this stuff. It is certainly no > > easy task. I've been at it for about 1-2 weeks now and have a very > > elementary picture of how Python works. I am teaching myself from home and > > only recieve help from this forum. Can anybody give me a timeframe as to > > how long it usually takes to pick something like this up, so I can maybe > > figure out a way to pace myself? I can dedicate a good amount of time to it > > everyday. Any advice on what is the best way to learn Python? I am a > > fairly educated individual with a natural sciences degree (forestry), so I > > also have a decent math background. Are there any constraints > > mathematically or logic "wise" that would prevent me from building a firm > > grasp of this language? > > Keep at it. > > Everyone is different, so don't worry about how long it takes you vs. > how long others might take. If you have no programming background, > there's a lot to learn. Using Python is a good choice, I think, 'cos > it gets a lot of extranious crud that many other languages insist on > out of your way, but there's still a lot to learn. > > The best way to learn? Go through the tutorials - but if you get an > idea for a mini-project of your own, don't be afraid to dive off and > give it a go. Try to solve you own problems for a while, 'cos that's a > valuable skill, but don't get to the point of frustration. Ask for > help here or on the tutor mailing list[1]. > > And have fun. > > [1] http://mail.python.org/mailman/listinfo/tutor > > -- > Cheers, > Simon B, > [EMAIL PROTECTED], > http://www.brunningonline.net/simon/blog/ Here's another reference: http://www.awaretek.com/tutorials.html Tutorials are sorted by type, and the first type is 'beginners' but it really depends on the level of hand-holding you wish. Your background suggest that you should look at something like Richard Baldwin's Learn to Program Using Python (no programming experience required)... Good luck. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to write an API for a Python application?
While not sure of the behavior you are trying to achieve, XML-RPC comes to mind. But it's based on HTTP protocol in which the client puts request to the server which has to respond. The server cannot initiate interactions. XML-RPC is both widely avalaible, and very easy to implement. NOTE: in order for the server to raise events in the client, the client needs only raise periodically a *need-anything-from-me* type of request which permits the server to return its request in response to the client. Naturally this solution makes superfluous calls takes some bandwidth, so it might not be appropriate in every circumstance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Hot to split string literals that will across two or more lines ?
Xiao Jianfeng wrote: > Hi, > > I need to print a long sting, which is two long so it must expand two > lines. > I know that we can use backslash(\) to explicitly join two lines into a > logical line, > but this doesn't work for string literals :( > > my code: > - > if sth.: > print "a string whcih is very very looo\ > ng." > - > > If I don't break the line, it will be very ugly, if I break the > line,but how ? > > Thanks in advance! in python there are triple quoted strings: strVar = """this the beginning and this is the end """ > > xiaojf -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter from Vis. BASIC
Terrance N. Phillip wrote: > In VB, an easy way I indicate progress is something like > do while > lblNotify.foreground = randomcolor > lblNotify.refresh <--- > > loop > > I want to do the same thing in Python/Tkinter: > > # Wait for network to recognize the workstation: > while os.system("slist") != 0: > self.notify["fg"] = randcolor() > # how do I refresh label l3 at this point? > time.sleep(3) > > I've tried self.notify.grid() (I'm using the grid geometry manager > throughout), but that didn't work, and there is no redraw() or refresh() > method that I can see. I know of an update_idletask() method, look it up in the tkinter doc to see if that's what you need! -- http://mail.python.org/mailman/listinfo/python-list
Re: moving mouse?
dado wrote: > dado wrote: > > I'm implementing a "self-tutorial" into my app, > > and wondering if there's a way of moving a mouse > > cursor on command? probably using sys,os modules? > > I also figured this would be useful for making > 'remote desktop' kinda thing... Naturally, you can always implement a simulation of this yourself in most GUI tools you would be using. I guess the complexity, thoroughness of your tutorial may mean that its unfeasable, business wise, but technologically it doesn't seem like rocket science... -- http://mail.python.org/mailman/listinfo/python-list
Re: Draw a triangle...
JustSomeGuy wrote: > Hi I'm writing a python application on my windows box and I want to draw > a simple triangle on the screen... How can I do this. > Am I going to have to use tcl/tk? Take a look at Tkinter, Python's wrapper around Tk - you'll find many things if you Google this! It's hard to tell yu more not knowing what you really want, since you're *not telling* ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get started in GUI Programming?
It all really depends on what you wish to achieve. Results are generally in proportion to the effort involved. I don't think a "Python for Nulls" exists ! the following thread deals with documentation for beginners (and others as well) http://groups.google.ca/group/comp.lang.python/browse_frm/thread/4b7a01e1feb128fa/2b6b186a96c4fa73?hl=en#2b6b186a96c4fa73 For Tkinter the basic document is Fredrik Lundh's 'Introduction to Tkinter' (you can google to easily find this) and also one from New Mexico Tech at http://infohost.nmt.edu/tcc/help/lang/python/tkinter.html If you're intent on doing image manipulation, I would advise that you consider the Python Imaging Library (known as PIL). Pain is a very personal concept - what can be a painful endeavor for some might be a enticing challenge for another ;-) Good luck. -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI and long running job
[EMAIL PROTECTED] wrote: > Hello, > I am using python and CGI to initiate a long running simulation (up to > 5h long) on a remote machine. The main idea is that I use a form, enter > the parameters and a CGI scripts start the simulation using these > parameters. The structure of the script is: > > 1. Read paremeters > 2. Display some information > 3. Start the simulation > > For step 3 I use either os.system or os.popen(2). The problem is that > the web server does not send the information of step 2 back to the > browser, unless step 3 is completed. The browser simply waits for a > response, without displaying anything. How can I just read the params, > display the info I want, start the simulation and then terminate either > the script or at least the connection to the browser without having to > wait for the simulation to finish? > > I am using activestate python 2.4, Apache and WinXP. > > Thanks a lot for your help. Maybe you could use 'os.spawn' variants with the P_NOWAIT parameter... (not sure of the syntax here, it's in the doc) Good luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: Eclipse best/good or bad IDE for Python?
malv wrote: > This is probably a fair answer. > My experience: Two years ago I started with Boa till I discovered eric. > I have been with eric ever since. Eric uses Qt as GUI. I think both Qt > and wx enable you to do pretty much the same thing. I like the work > F.Lundh did on Tkinter, but every time I try, I get bogged down in the > tcl mess that it builds on. Take the example of the indispensible > datagrid: a piece of cake in both Qt and wxWidgets, a nightmare > otherwise. > > Since a couple of weeks I made the tour of wing-ide, komodo and PyDev. > PyDev appears really to be a top heavy kludge. Perhaps OK for java > lovers but very laborious to set up and work with, this in spite of the > abundant hype & spam on this board. Wing-ide's debugger stops on > imagined errors where eric and komodo do allright. I could not get the > designer to run on komodo. So I'm back at eric. On eric you use the > superb Qt designer. If you run linux, you get Qt and PyQt with KDE. You > can keep on running gnome if you want. For windows, Qt4 is supposed to > be free. Further, very extensive and attractive extensions exist: qwt > and qwt3d for graphics. > > This is my experience. If I find better, I'll change. > malv Eclipse with Pydev is great with Tkinter apps. I try to stick with Tkinter so Boa, Eric are not my cup of tea. Some mainstream free IDE have problems with Tkinter's mainloop: PythonWin IDLE, that I know of, may be others. Eclipse with Pydev has been behaving excellently with Tkinter apps, never freezing up, giving me the debugger, etc. Great stuff! PS Yes, a Tkinter datagrid would be nice (sigh) -- http://mail.python.org/mailman/listinfo/python-list
Re: calculate system disk space
PyPK wrote: > how can we compute the current system disk space using a python > script.? > any ideas or have anyone tried this.. Google, on "Python disk size", returned this link: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66455 Thanks for the reply recipe, Steve ;-) Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
cx_Oracle failed to load DLL BUT versions correct
Hello Having cx_Oracle (an Oracle database connector for Python) used it here where I teach for the last couple of years, and finding it so easy to use (and install) I was taken aback when I got an error message telling me it could not load the DLL (complete message below) Third, I've read (on activeState site) about someone else having this problem which seemed to be resolved by correctly installing the appropriate versions of different software piece. BUT no 1 : I works on my portable (that has the same configuration for OS, Python and cx) BUT no 2: The same configuration gets the error message from our classroom workstations - after multiple testing, (uninstalling everything, python, Oracle, cx_Oracle,etc) , cleaning the registry, re-installing from fresh binaries ( Oracle works (SQL+) ) , the error stays... HELP - Any hints, helps, things to look for, whatnot, Many thanks in advance, Jean-Marc [EMAIL PROTECTED] Cegep du Vieux-Montreal CONFIGURATION windows XP professionnal, sp2 (firewall stopped) installation in administrator mode Oracle 10g Python 2.3.4 pywin32-203.win32-py2.3.exe cx_Oracle-4.1-win32-10g-py23.exe NOTE: all files seem in the right places (cx_Oracle.pyd in site-packages) ERROR (taken from PythonWin interactive window) PythonWin 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32. Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) - see 'Help/About PythonWin' for further copyright information. >>> import cx_Oracle Traceback (most recent call last): File "", line 1, in ? ImportError: DLL load failed: La procédure spécifiée est introuvable. >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: Why and how "there is only one way to do something"?
Tolga wrote: > As far as I know, Perl is known as "there are many ways to do > something" and Python is known as "there is only one way". Could you > please explain this? How is this possible and is it *really* a good > concept? if you 'import this', you get a bit of Python Zen... from which I have taken this line: *... There should be one-- and preferably only one --obvious way to do it. ...* If this is what you are referring to then here is an explanation. So there is not 'only one way', but rather there should be a way to do something that is obvious, re easy to find, evident, 'given'... The quality(ies) looked for here that makes this *really* good is 1- that you don't spend an inordinate amount of time looking for it - you just go along and use it so your mind can be focussed of what you need to achieve instead of how you can achieve it. 2- If it's 'obvious', then chances are others will see it and use it also, so that their code is more understandable by others. For anyone who has taken care of code of others this can be *really really good* ;-) Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Why and how "there is only one way to do something"?
Yes, a shared preferred way. And the same is true of many... Think Haskell, OCaml, Lua, Ruby, Lisp, Smalltalk, Java, C... They all have qualities of some sort, that appeal to some of us. Not all the same, nor to all of us. It's really a question of perspective. In this Python community, one shared preferred way is obviousness, that we agree or disagree upon, that we argue or ignore as best suits us. It is not 'the law', it is a wish. For clarity, for communication, for exchange and for certainly many more reasons. As a personal experience, I've often been able to use the language structures, and functions for that matter, out of thin air, because it seemed *obvious* in the context. But the Help files remain close-by... Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Bad people management (Was Herds of cats)
Alex Martelli wrote: > Mike Meyer <[EMAIL PROTECTED]> wrote: > > > Steve Holden <[EMAIL PROTECTED]> writes: > > > Alex Martelli wrote: > > >> Not a bad point at all, although perhaps not entirely congruent to > > >> open > > >> source: hiring key developers has always been a possibility (net of > > >> non-compete agreements, but I'm told California doesn't like those). > > > > California places pretty strict limits on non-compete agreements. I > > Yep, this is roughly what I'd heard, and what I meant above. > > > was at Ingres when their parent company - ASK - got bought by CA. CA > > required people choosing to leave the company to sign an agreement > > that included *their* standard non-compete clause before getting the > > separation cash. Enough people left that found this clause irritating > > that it got take to multiple lawyers. Every last one of them declared > > it unenforceable in CA. > > Tx for the anecdote, which does appear to reinforce the point. I assume > CA's non-compete clause was fine in NY (I'm guessing that's where their > lawyers would be) and they didn't consider the state differences... > > > > > The essential difference, it seems to me, is that buying the company > > > gets you control over the company's proprietary technologies, whereas > > > hiring the developer only gets you access to the development skills of > > > the people who've been involved open source developments. > > > > But it's not at all clear which of these is the more desirable > > outcome. > > Good point. I guess the only real answer is, "it depends". But because > of this SH's point should be rephrased as, "buying the company ONLY gets > you control", etc, to emphasize the paralellism. Even where non-compete > agreements ARE enforced, by buying a company you're still not assured of > getting *access to the development skills* -- even if those developers > are forced to keep working for you, if they feel they're doing it under > duress because you're legally twisting their arm, it seems very unlikely > that you'll get much of anything USEFUL out of them (and I would be > astonished if strict non-compete agreements still applied if you FIRED a > developer, rather than the developer choosing to leave...). > > > CA bought ASK to get control of Ingres, which their Unicenter > > product used as a database. The *entire* server software development > > group left, meaning CA had all the sources and technologies, but none > > of the talent that created them. We called this the $300 million > > source license. > > > > CA pretty clearly got screwed on this deal. They have since > > open-sourced the Ingres product. > > I'm not sure the two sentences in your last paragraphs are really as > causally connected as one might think;-). After all, didn't SAP also > opensource their own DB (I believe they now have a partnership with > MySQL to try to commercialize it), although in different circumstances? > > IOW, it seems to me that, apart from Oracle, nobody's making money on > databases any more (I believe Microsoft is now giving away SQL Server > for free, although maybe not the largest "enterprise" edition and surely > not in open-source form -- of course, MS can afford a *lot* of money > losing ventures, because Windows and Office bankroll the entire company > to a highly "ca-ching" degree;-); so, companies whose money making > depends on applications sitting on top of the DB (true to some extent of > CA, to an even larger one of SAP) may opensource it both to (they hope) > get some free support for it AND to minimally undermine Oracle (who uses > its DB revenues to bankroll multipronged attacks and acquisitions into > the field of enterprise applications). > > Still, I'm not disputing that CA "got screwed"... though it looks like > they did it to themselves -- they didn't stop to consider the need to > WOO developers to actually get them onboard as a part of the overall > deal, just sort of assumed they "came with the package"!-) Bad people > management must be close to the #1 cause of failure of promising mergers > and acquisitions (and I'm not sure the qualifying part of this sentence, > after "failure", is needed;)... > > > Alex Not really in the same vein but " Bad people management must be close to the #1 cause of failure of promising ..." software projects. Mind you, sometimes that just mean, minding one's self. -- http://mail.python.org/mailman/listinfo/python-list
Re: oop in python
Larry Bates wrote: > novice wrote: > > hello over there! > > I have the following question: > > Suppose I created a class: class Point: > > pass > > then instanciated an instance: new = Point() > > So now how to get the instance new as a string: like ' new ' ; Is > > there any built in function or method > > for eg: > > > > class Point: > >def _func_that_we_want_(self): > > return ... > > new._func_that_we_want_() ---> ' new ' > > > > Just a wild guess, but I think he wants to refer to it by a > name. The best way to do this is to put the class instance > in a dictionary and make the key 'new' > > instancedict={} > instancedict['new']=Point() > > then you can call methods by: > > instancedict['new'].somemethod() > > -Larry Bates Maybe it's more in the way of the builtin function *eval*... example (you decide if this is what you mean ;-) ) >>> class toto(object): ... def max(self): ... return 12 ... >>> t=toto() >>> eval("t.max") > >>> eval("t.max()") 12 -- http://mail.python.org/mailman/listinfo/python-list
Re: oop in python
(addendum) ... And even ... >>> eval("t").max() 12 >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Scrollbar not working
Dustan a écrit : > I'm trying to get a scrollbar bound with a Frame, and I keep on getting > a scrollbar, but it doesn't actually scroll. Some help, please? Frames are NOT scrollable objects for scrollbars in Tkinter: Listbox, Canvas and Text widget are. I f you want/need to scroll something else, I think you are going to have to do it yourself, meaning you can use the scrollbars to get user input by binding an event to it, and then moving things around your Frame to give the scrolling appearance. OR you can take a look at a third-party such as PythonMegaWidgets (PMW) who have them I believe... Happy New Year anyhow... Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Quickest way to make py script Web accessible
[EMAIL PROTECTED] wrote: > What is the quickiest and easiest way to make a py script run on a Web > server? I have access to an Apache Web server running on Linux. > > I'm often asked to run some of my scripts on behalf of others. My hope > is to make a simple Web-based interface where people could run the > scripts themselves whenever they like... instead of asking me. > > I'd rather not rewrite the scripts with PHP. Any tips on a fast, easy > way of doing this? > > Thanks! If it's just using the web to *run* a python script on the server, then a simple cgi-script which will spawn a process for other scripts. You need a web form that permit the user to choose the script he/she wants executed. That form will point (action='your_cgi_script.py') to the script who's job will be to spawn the other script, submitting the user choice. One HTML page for the script choices and one extra python script to receive the cgi call, seems easy! If it doesn't look that way to you, don't hesitate to let it be known, and on which part... Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Quickest way to make py script Web accessible
[EMAIL PROTECTED] wrote: > I apologize for my inital ambiguity. > > Say I have a .py script that gets email addresses from a database and > then sends messages to customers (this is not spam, these guys _want_ > to get the emails). Historically, IT has executed the script when > someone in Marketing makes a request. I want to make it so that > Marketing can run the script themselves by executing the script through > a Web-based interface. I don't want to have to alter the script a great > deal in order to do this. I think my previous suggestion was just on the nose - none of your scripts need be modified EXCEPT if they entail user input, for which you would have to a web form to get such info from your user. and have your cgi call your mail program with the parameters submitted from the web form (such group of customers, such message, etc). An alternative to spawning a process, is importing the mail script within the cgi script itself (conditionnaly if need be). -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin: logging module not showing messages from imported modules
[EMAIL PROTECTED] wrote: > Having the following code: > > Module1.py > import logging > def X(): > logging.error('test') > > If I import it into PythonWin console and call X(), the error message > is not printed. If I do the same in Python console the message is > printed. Do I need to configure the logging module or it's a problem > with PythonWin? > > If I call logging.error() in the PythonWin console it works like a > charm. The problem is just regarding imported modules. > > > Rodrigo Strauss Do you *run* module1 before attempting to call X() from the interactive window? -- http://mail.python.org/mailman/listinfo/python-list
Re: An app without GUI
Daniel Crespo wrote: > Hello to all, > > I have to build a server app without GUI. This app must be an xml-rpc > server, so it has to be up all the time. I would control it through the > xml-rpc port from a web interface using php, sending parameters to > defined xml-rpc functions for running certain processes, like viewing > current connections, restart it or shutting it down, for example. > > Actually, I have it implemented with wxPython. The GUI controls when > the xml-rpc server is running, so when I close the GUI, so does the > server and all the dependent threads. > > I want to do something like the MainLoop(), but without GUI. I can sit > down and build all this stuff, but I would like to know if someone had > passed through this. Any tips? > > Thanks > > Daniel here is complete example - some words in french note: this will open a dos box for std IO #* # -*- encoding: iso-8859-1 -*- import os import SimpleXMLRPCServer import xmlrpclib class mainServeur(object): """ going to be the servicing object""" def __init__(self): pass def testServeur(self): return "i am a server" monPort = 4089 # whatever server = SimpleXMLRPCServer.SimpleXMLRPCServer(("127.0.0.1", monPort)) def kill(): global quit quit = 1 return "i am a dying server" # Globales quit = 0 activeController= mainServeur() server.register_instance(activeController) server.register_function(kill) #Go into the main listener loop print "llistening on port ",monPort while not quit : server.handle_request() #** -- http://mail.python.org/mailman/listinfo/python-list
tkinter cursors name&display reference
I made a document on Tkinter cursors (mouse pointers?), pairing the cursor image with its name... Not a great deal of magic here since anyone can program something to see the different cursors on screen rather easily... BUT to have a printable reference can be nice :-) Would this be useful to anyone else? Could it be an addendum to Tkinter documentation? Should I propose it to someone or post it somewhere? Is pdf better than html ? etc,etc. Thanks for your advice, Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Trouble displaying image with tkinter
sj wrote: > I am just learning to use Tkinter and am having problems displaying image > files. I am able to display an image using tutorials (such as > http://www.daniweb.com/code/snippet296.html) But when I try my own code all > I get is an empty widget. What is wrong with the following program? > > > > from Tkinter import * > > class Foo(Frame): > > def __init__(self,master=None): > Frame.__init__(self,master) > self.pack() > self.createWidgets() > > > def createWidgets(self): > > self.qbutton = Button(self) > self.qbutton["text"] = "Quit" > self.qbutton["command"] = self.quit > self.qbutton.pack(side = "top") > > idata = > PhotoImage(file="/home/sj/documents/projects/xaed/images/cat_001.gif") > > canvas = Canvas(width=300,height=200) > canvas.pack(side="top",fill=BOTH,expand=YES) > canvas.create_image(50,10,image=idata,anchor=NW) > > ## lab = Label(self,image=idata) > ## lab.pack(side=TOP) > > > root = Tk() > app = Foo(root) > app.mainloop() > #app.destroy() If you keep a reference of the photoImage object then it will work! ... self.idata= PhotoImage(file="/home/sj/documents/projects/xaed/images/cat_001.gif") ... canvas.create_image(50,10,image=iself.data,anchor=NW) ... By making the PhotoImage an attribute of your object, you keep a reference that the garbage collector will NOT collect, So you're image will continue to exist and thus be rendered by the canvas. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie doing lengthy initialization with Tkinter gui
Maric Michaud wrote: > Le dimanche 13 août 2006 12:39, Pasi Oja-Nisula a écrit : > > > The question is how (or where) can I call my loadImages function right > > after the mainloop starts? Or is there a better way to do this? > > > Seems a good use case for multi-thread, try something like this : > > In [28]: import Tix > > In [29]: main=Tix.Tk() > > In [30]: p=Tix.Meter(main) > > In [31]: p.pack() > > In [32]: def process(progress) : >: from time import sleep >: for i in range(10) : >: sleep(1) >: p.configure(value=float(p.cget('value'))+0.1) >: >: > > > In [33]: import thread > > In [34]: thread.start_new_thread(process, (p,)) and main.mainloop() > > Of course the last line is tricky, the thread should be started by the > App(Tix.Tk) mainloop. > > > > Pasi > > -- > _ > > Maric Michaud > _ > > Aristote - www.aristote.info > 3 place des tapis > 69004 Lyon > Tel: +33 426 880 097 Tkinter also has a timer-type function called *after*. Use this to call your init function just befrore the mainloop call. You gui wil show up and you can then update it to show progress as you wish No neep for thread or Tix modules...! Here's a working example: # from Tkinter import * # Your progress showing function def showProgress(i): # Tell the gui to show some progress here obj=c.find_withtag("job")[0] c.itemconfig(obj,text="Ok from job is up to "+str(i)) c.update() # Your app init function def doInitOne(): #Do some init work here for i in range(100): for j in range(100): for k in range(100): for m in range(100): a=1 # Once in a while update the gui showProgress(i) # your main app root=Tk() c=Canvas(root,bg="yellow",width=300,height=300) monobj=c.create_text(100,200,text="Some ",tags="job") c.pack() # this will *sleep* one millisec before calling # your doInitOne function and continue # with the rest of the code during that sleep time # in this case just the mainloop root.after(1, doInitOne) root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
tkinter btn visual state with tkMessageBox
why is the button sunken when called through a bind method, and not with the command attribute? Thank you! ## Cut'nPaste example from Tkinter import * import tkMessageBox class Vue(object): def __init__(self): self.root=Tk() self.root.title("test button visual state") self.b1=Button(self.root,text="tkMessageBox.showinfo with bind :-(") #,command=self.showMsg) self.b1.bind("",self.showMsg) self.b2=Button(self.root,text="tkMessageBox.showinfo with command :-)",command=self.showMsg) self.b1.pack() self.b2.pack() self.root.mainloop() def showMsg(self,evt=1): if evt==1: txt="From button with command" else: txt="From button with bind" tkMessageBox.showinfo("Test of button", txt) if __name__=="__main__": v=Vue() -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter btn visual state with tkMessageBox
Hendrik van Rooyen wrote: > <[EMAIL PROTECTED]> wrote: > > To: > > > | why is the button sunken when called through a bind method, and not > | with the command attribute? > | Thank you! > | > | > | ## Cut'nPaste example > | from Tkinter import * > | import tkMessageBox > | > | class Vue(object): > | def __init__(self): > | self.root=Tk() > | self.root.title("test button visual state") > | self.b1=Button(self.root,text="tkMessageBox.showinfo with bind > | :-(") #,command=self.showMsg) > | self.b1.bind("",self.showMsg) > > 8<--- > > change this to : > >self.b1.bind("",self.showMsg) > > Problem is that a button "sinks in" when you press it and "springs back" when > you release it... > > and the "Button" leaves it sunken - because when you release, the control > is > no longer there > > - Hendrik Thanks Hendrik - is the command attribute connected to the bindable events? jm -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter btn visual state with tkMessageBox
Hendrik van Rooyen wrote: > <[EMAIL PROTECTED]> Wrote: > | > | Hendrik van Rooyen wrote: > | > <[EMAIL PROTECTED]> wrote: > | > > | > To: > | > > | > > | > | why is the button sunken when called through a bind method, and not > | > | with the command attribute? > | > | Thank you! > | > | > | > | > | > | ## Cut'nPaste example > | > | from Tkinter import * ... > | > and the "Button" leaves it sunken - because when you release, the > control is > | > no longer there > | > > | > - Hendrik > | Thanks Hendrik - is the command attribute connected to the bindable > | events? > | jm > > I don't have a clue - you are either asking about advanced magic here, > or I don't understand your question - I believe the lower level routines > are common, but I don't *Know* this - so its a pity that some people > who shall be nameless have beaten their brains out in a thread about > a directory name here.. > > You may have noticed that there is another subtle bug with what I have > suggested to you - when you press the offending button, then move the > mouse to move the cursor off the screen button, - the button > "springs back" as expected - but then when you release the mouse > button, off the screen button, the call back is done anyway, instead of > being cancelled when the cursor moves off the screen button. > > - for the command case, the sequence is different, and the call back is done > only if the release is done on the screen button... > > - But this may just be my setup - does yours do the same? > > I don't know how to fix that - you could look at sequences of events - button > push followed by release - But I doubt whether this will help, as its doing > something like that anyway (haven't tried it) > > - Hendrik Same behavior here - Also, I added a bind to Button event and another to ButtonRelease, and also had the command attribute. All three *events* are processed, in similar fashion that you describe above. Finally, the command attribute seems to works like a ButtonRelease BUT still permits a binding to another function on a ButtonRelease event (and only one) so if the lower level functions might be the same the path to them seem different. I found this article that pertains to the question: http://www.ferg.org/thinking_in_tkinter/tt075.py but I'll postpone my own investigation at this time to return to my program ;-) Thanks again, Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Tk: filling a frame with a widget
Paolo Pantaleo wrote: > I have this code > > from Tkinter import * > > root=Tk() > Button(root).pack(fill=BOTH) > root.mainloop() > > I would expect the button filling all the client draw area of the > Frame, but when I resize the root window the button becomes wider, but > not higher ( I get some empty space under the button). How could set > the button to fill always all the space available? > > Well maybe some other solution exists, since my problem is this: > > I have a resizable window and i want to keep it filled with a Canvas > displaying an image (PhotoImage). Can I get the in some way the size > of the clien draw area of the window containig the canvas? > > Thnx > PAolo > > -- > if you have a minute to spend please visit my photogrphy site: > http://mypic.co.nr you also need to expand it as in from Tkinter import * root=Tk() Button(root).pack(expand=1,fill=BOTH) #HERE use expand=1 as extra option root.mainloop() jean-marc -- http://mail.python.org/mailman/listinfo/python-list
Re: filling a frame with a widget
Fredrik Lundh wrote: > Paolo Pantaleo wrote: > > >I have this code > > > > from Tkinter import * > > > > root=Tk() > > Button(root).pack(fill=BOTH) > > root.mainloop() > > > > I would expect the button filling all the client draw area of the > > Frame, but when I resize the root window the button becomes wider, but > > not higher ( I get some empty space under the button). > > pack(fill=BOTH, expand=1) should do the trick. > > the pack geometry manager works by slicing off vertical or horizontal areas > from > the parent, one area per widget. the "fill" option controls how to place the > widget > inside that area, the "expand" option controls how to handle any extra space > left > in the parent. if "expand" isn't set for any child widget, the extra space > is left un- > used. > > I'm not the OP, and I even replied about expand but *now* I know how it works... Thanks, Fredrik! jean-marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Dive Into Java?
erikcw wrote: > DiveIntoPython.org was the first book I read on python, and I really > got a lot out of it. I need to start learning Java (to maintain a > project I've inherited), and was wondering if anyone knew of any > similar books for Java? > > Maybe once I know my way around the language, I can sneak Jython in... > :-) > > Thanks! > Erik Not exactly Dive into Java, but one amongst very great book on programming (and the one that pointed me to Python :-)) , really! ) - *Just Java* by Peter van der Linden, really great book! and fun to read, and bright, and this (apocryphical) citation (i don't have the book under hand just now, being on vacation ;-)): *...to the question 'Should I learn Java, C++, Perl?' (the answer is) 'Yes!' ...* and Python was included among several other OpenSource stuff on the CD. Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Raw beginner....
Fabio Zadrozny wrote: > On 10/8/06, Colin Lehmann <[EMAIL PROTECTED]> wrote: > > I am new to Python although I have been using Delphi since version one, > > I have been employed as a C and C++ programmer so when I went to Linux > > (Ubuntu 5.10) I thought Python looked pretty good. > > I downloaded and installed 'Eric Python IDE' which seems OK, any > > alternatives suggested will be looked at > > Suggestions: http://wiki.python.org/moin/IntegratedDevelopmentEnvironments > > Cheers, > > Fabio Fabio, your reply is SO cool ! Pydev rocks (for those of us who accept Java-Eclipse gigantism) Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE
Jan Bakuwel wrote: > John Purser wrote: > > On Fri, 2006-10-13 at 15:48 +, giuseppe wrote: > >> What is the better IDE software for python programming? > >> > >> many thanks > >> > >> joe > > > > Joe, > > > > Find the best Python programmer and ask him/her. > > > > John Purser > > I may be the worst Python programmer (since Python is new for me)... but > I have a lot of experience with IDEs and just looked into Python IDEs. > > My opinion: Eclipse is free but rather complex; WingIDE is commercial > software but well worth the few $ - at least for someone like myself. > > cheers, > Jan Actually, Eclipse is easy enough, if you don't want to use the whole complexity available and Pydev (the python plugin) is really good - but this is NOT a flame because wingware as a good reputation also SPE (but I haven't tried it necause i don't have wxPython), also PythonScript or Pyscripter as it is sometimes found, but that is windows only (I think). And then, there is Komodo, from our friends at ActiveState... Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python
Bruno Desthuilliers wrote: > Kay Schluehr wrote: > > Bruno Desthuilliers wrote: > > > >> Just for the record : Ruby's code-blocks (closures, really) come from > >> Smalltalk, which is still the OneTrueObjectLanguage(tm). > > > > IsTheOneTrueObjectLanguage(tm)ReallyCamelCased? > > > ThatsAGoodQuestion. > > DoYouMeanIsTheIdentifierTheOneTrueObjectLanguage(tm)CamelCasedOrIsTheObjectObjectBoundToIdentifierTheOneTrueObjectLanguage(tm)CamelCasedOrYetSomethingElse? > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" youGuysAreAllCrazyOrSomethingNicer(CrazyBeingANiceAttributeHere)(ButIDon'tKnowAboutSyncategoremasLikeParenthesisOrApostrophe)InCamelBackNotationWhichAsNothingToDoWithPolishReverseNotation)ThankYou Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Any idea how to do this in Python?
Lad wrote: > Dennis, > Thank you for your reply > You say: > >Pretend you are the computer/application/etc. How would YOU > > perform such a ranking? > That is what I do not know , how to perform such ranking. > Do you have any idea? > > Regards, > Lad. take a piece of paper to *play* the use-case you wrote about. Do things one step at a time, and figure what is needed, Example: 1- a user is on a web page # ok I need a web page 2- a user sends info to the server # ok the web page needs a input widget of sorts AND I need a server app 3- analyse (or decide ) what type of info the user may send (selected choices, free text, etc) 4- the user must be identified in some way (so to discriminate him from others), so the also must be that type of input... etc, etc At the end you will have a better picture of things required - then you build them ;-) Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter--does anyone use it for sophisticated GUI development?
Kevin Walzer wrote: > I'm a Tcl/Tk developer who has been working, slowly, at learning Python, > in part because Python has better support for certain kinds of > applications that I want to develop than Tcl/Tk does. Naturally, I > thought that I would use Tkinter as the GUI for these programs. However, > in doing research into GUI development techniques, sample code, and > showcase applications, what has struck me is how little sophisticated > GUI development seems to be done in Tkinter as compared to, say, > wxPython. I've found plenty of tutorials on how to do basic GUI stuff > with Tkinter, but that stuff pretty much ends with the core Tk widgets > (buttons, entry fields, scrollbars, and menu items). > > Coming from Tcl/Tk, where there are a huge number of extension packages > to enhance the Tk widgets and which allow you to make really polished > GUI's, I'm struck mainly by how little of this stuff has made it over > into Tkinter/Python. For instance, I've developed several Tcl > applications that use the core Tk widgets, the Tile theming package, the > Bwidget set (great tree widget and listbox, which allows you to embed > images), and tablelist (an extremely flexible muti-column listbox > display). I've found Python wrappers for some of this stuff, but almost > no documentation on how to use them, and very little in the way of > actual applications making use of them--which is itself a red flag. And > most of the pure-Python extension stuff that I've found, such as Python > megawidgets, is pretty dated/ugly and lags far behind the comparable > stuff on the Tcl side. > > Am I better off biting the bullet and learning wxPython--a different GUI > paradigm to go with the new language I'm trying to learn? I had hoped to > reduce my learning curve, but I'm very concerned that I simply can't do > what I want to do with Tkinter. What do other Tkinter developers think? Tkinter is certainly dated (?), worst than PMW which is built upon it. But what do you what/need? I use , and am making my students use Tkinter for a web multiu-user client-server game. The Canvas is a great object, but you have to write the code yourself, if you want a special look. Eye-candy, Tkinter ain't, and it doesn't have a lot of sophisticated widgets (again ?) . I wanted a tabbed pane last year and made myself one (not the exact look of others, but functional if what you want is multiple frames of widgets for each tab; the table widget took quite a bit of doing, also and it's not an Excel spreadsheet) I do know that people are impressed by glitz and glamour (And I don't have a nice tree (with picture) widget) But all of this does forget that Tkinter is still in the standard library, while all others are third-party add-ons... so there is a extra hassle with them... So, what do You want? (widgets, criterias etc) Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem getting a file pathname with tkFileDialog
Tim Daneliuk wrote: > Sefyroth wrote: > > Thanks, > > > > but I get this error when I try this. > > > > UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in > > position 12: ordinal not in range(128) > > > > I had encountered it with the askdirectory method as well. Is there an > > easy way to bypass this? > > > > Thanks again > > I believe you are running into a directory or file name that has > non-ascii characters in it. Python as shipped is set up to > deal with ascii as its native encoding format. You can change > this by editing the "site.py" file - look in the Lib directory > in your python installation. Look for this code: > > --- > def setencoding(): > """Set the string encoding used by the Unicode implementation. The > default is 'ascii', but if you're willing to experiment, you can > change this.""" > encoding = "ascii" # Default value set by _PyUnicode_Init() > if 0: > # Enable to support locale aware default string encodings. > import locale > loc = locale.getdefaultlocale() > if loc[1]: > encoding = loc[1] > --- > > > > Change the "if 0:" to "if 1:" and see if that doesn't fix the problem. > > > > -- > > Tim Daneliuk [EMAIL PROTECTED] > PGP Key: http://www.tundraware.com/PGP/ you could also use encode("iso-8859-1") to nterpret just the printed name such as: print myfilename.encode("iso-8859-1") and by the way if you wanted the file NAME you could have used openfilename() instead of openfile();-) jean-marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Best Python Editor
bruno at modulix wrote: > Manoj Kumar P wrote: > > Hi, > > > > Can anyone tell me a good python editor/IDE? > > It would be great if you can provide the download link also. > > I hate to be the one answering this, but this is *really* a FAQ - as you > would have known if you had google'd this group for this. > ... and/or consider this page from python.org http://wiki.python.org/moin/PythonEditors since there are many possibilities of *good editors*, and advocacy generally stems from personal preferences ;-) jm -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI Program Error
Byte wrote: > Thanks, this works. Now, since the tutorial I was using is clearly > rubbish, any better ones? For a (relative) newbie please. Also, how do > I code a GUI Hello World program? > > -- /usr/bin/byte How does John Salerno previous code NOT fit the bill? >> John Salerno wrote: >> ... >> import Tkinter as tk >> >> root = tk.Tk() >> label = tk.Label(root, text='Hello world!') >> label.pack() >> root.mainloop() >> ... I think you should get a copy of "an-introduction-to-tkinter" from Fredrik Lundh and try out the different usage examples and experiment, then post more specific questions (after searching this newsgroup since many questions lie here already answered). -- http://mail.python.org/mailman/listinfo/python-list
found a swftools for 2.4 - Docs anyone?
New to swf - interesting technology for dynamic web graphic effects stemming from user input. I found a working windows pre-compiled binary (0.6.2) for Python 2.4 of rfxswf library from swftools to generate swf files. (flash compiled files(?)). No source of documentation of that api. There are a few python examples that I managed to make work, from swftools site but only covers partly the api. help(SWF) only tells of the main classes - nothings on arguments I tried reading the C source, but I'm not very fluent in C so that didn't amount to much. Any help appreciated in finding help on this API. Thanks in advance Jean-Marc Ref: http://www.swftools.org/ python binary : http://lists.gnu.org/archive/html/swftools-common/2005-01/msg00066.html (Thanks to Daichi .) -- http://mail.python.org/mailman/listinfo/python-list
billionlaughs, on me :-(( - on winXP help!
Looking up different blogs etc on xml parsers I wind up on the site of Computer stuff, www.razorvine.net. And in the browser torture section, the billionlaughs.xml link (that you shouldn't use if you don't know what your doing, as was my case (mea culpa)) Thinking I was about to crash the browser, I look up the web for assorted advice and find nothing except a post about the *killer xml file*... So hereb goes nothing... click, hang, reboot, hangs, (mouse pointer moves, that's it folks) the disk spins occasionally, the vents go up mad, I guess the CPU is working - have know idea on what. I'm able to boot in safe mode but don't know what to do next? Any ideas ? Further details? Thanks in advance (I know this is not directly related to python, but regulars here are my only source of knowledge to this point, on this "Billion Laughs" DoS attack) Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: billionlaughs, on me :-(( - on winXP help!
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > Looking up different blogs etc on xml parsers I wind up on the site of > > Computer stuff, www.razorvine.net. > > And in the browser torture section, the billionlaughs.xml link (that > > you shouldn't use if you don't know what your doing, as was my case > > (mea culpa)) ... > > reboot as usual, and the next time you see a link that says "do NOT > click if you don't know what you're doing", don't click on it. > > Right ;-) and thanks for your very fast reply ! -- http://mail.python.org/mailman/listinfo/python-list
Re: Active Python versions
Trent Mick wrote: > Tom Del Rosso wrote: > > Can I ask you about alternative environments? How do Active Python and IDLE > > from python.org compare? > > Both ActivePython and the Python installers from python.org install > IDLE. They should not differ at all (AFAIK). > > Trent > > -- > Trent Mick > [EMAIL PROTECTED] Maybe the OP is refering to PythonWin editor (as compared to IDLE) which is in ActiveState's release but not in the Python.org release... makes for a very different subject, and hopefully for very different answer direction. jean-marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Question
placid wrote: > BartlebyScrivener wrote: > > Saint Malo wrote: > > > If the program searches for blue, i just want it to print blue > > > > Huh? Tell it to print whatever you want. > > > > for line in file: > > if 'blue' in line: > > print 'blue' > > > > for line in file: > > if 'brown' in line: > > print 'brown' > > > > for line in file: > > if 'red' in line: > > print 'weasels rip my flesh' > A little rewrite of the precedent code to make it just a bit closer to a program (since the OP is a so-called newbie) myWords=['blue','red','brown'] # you might use a list myFile=open('mytextfile.txt').readlines() for line in myFile: for word in myWords: if word in line: if word != "red": print 'weasels rip my flesh' else: print "i found",word > wow Dude, this is not efficient at all! You only need to read the file > once not as many times as there are words in your looking for in the > lines of the file FWIW, I'm pretty sure the example of BartleByScrivener didn't entail a new read each time but that it was written for readabilityt purposes only of the "print what you want" idea... ;-) Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Active Python versions
Tom Del Rosso wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> typed > in news://[EMAIL PROTECTED], > > > Maybe the OP is refering to PythonWin editor (as compared to IDLE) > > which is in ActiveState's release but not in the Python.org release... > > makes for a very different subject, and hopefully for very different > > answer direction. > > Yes. I just wanted to know which programming environment is prefered by > regular users, maybe even one that I haven't heard of yet. > ... try reading this very recent (still active) thread: http://groups.google.com/group/comp.lang.python/browse_frm/thread/9577320064fa33eb/7ad49f0d44ecbc47?hl=en#7ad49f0d44ecbc47 My two-grain of salt: PythonWin is simple and nice BUT breaks if you do Tkinter Gui (and try to run a program while the previous run isn't finished) Python Scripter - light, nice, some nice features but missing code folding, if you like that... Pydev + Eclipse (Eclipse is Java based plugin type environment) lots of stuff (to much for some) and heavy [t's Java after all ;-) ] But nowadays with RAM, and processor speed - it's nice to do almost every task in the same basic environment (plugins for almost anything) BTW Kudos to all the people behind these apps (mark hammond of pywin fame, kiriakos vlahos for python scripter , and fabio zadrozny for pydev) jean-marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Question
Saint Malo wrote: > BTW my program isn't about red blue yellow etc. I'm just using it as > an example. I guess i didn't asked the question correctly or am not > expressing myself correctly. Let me try one more. > > Ok. > > Contents of text file follow: > > red blue purble > yellow blue green > > > > Now lets imagine i wrote some code to look for the word red. Once the > program has found red i want it to print something like the following > line. > > > If you add red and blue you obtain the color purple... > > > How do i turn each color in the line into a separate string? Now is > that possible? > ... Ok myself! Let's start at the beginning 1- a text string is text, not colors, right? 2- how does a computer know that you are looking for a color? Because you give it a label say 'red' (which is a text string) and it looks for that pattern of caracters in the string you are giving it as a target. 3- so you already HAVE the string you want, no? So, what I guess you question really is might look like the following: if I find colors words in a line, find what color is produced by the combination of all those I found in the line IF this is the case then what you may want is something like this: mycolors=["red", "green"] for line in file: listofwords = line.split(" ") # is a space is seperating the words in the actual line activecolors=[] # an empty list to use as local container for word in listofwords: if word in mycolors: activecolor.append(word) # keep a note of what color was found in this line dosomething(activecolors) Before I continue with that line of answer, does this seem closer to what you care to do? jm -- http://mail.python.org/mailman/listinfo/python-list
Re: USB
Gabriel wrote: > ¿Alguien conoce algún módulo para python con el que se pueda tener > acceso a los puertos USB y que sea multiplataforma? > > -- > Gabriel Hola Gabriel, Voy... http://sourceforge.net/projects/pyusb (multiplataforma sin Windows) mas http://web.media.mit.edu/~dmerrill/sensor_network_applications/plug_howto.html otros http://libusb-win32.sourceforge.net/(windows) Esperando ;-)) Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: AN Intorduction to Tkinter
... > > If anybody has some really good sites with examples of Tkinter programs > and stuff, please share :) ... You should really pay attention to people's reply to your questions if you want help ;-) In this case meaning, that you should show what type of problem you are getting. Since the examples out of An Introduction to Tkinter work, what else could be useful to you is hard to guess. jean-marc -- http://mail.python.org/mailman/listinfo/python-list
Re: windev vs python SOS
MC wrote: > Bonjour ! > > Comme tu es français, tu me coprendras. > > Alors : > - windev est fermé, et protégé par des dongles. Résultat : dongle > perdu, en panne, ou volé, il faut racheter une licence (c'est arrivé à > un ami) > - le langage de windev est beaucoup moins évolué que Python. Et, > quand je dis beaucoup, c'est faible... Python a des possibilités > énormes en programmation procédurale, en Orienté Objet, et, même, en > programmation fonctionnelle. > - la structure interne de Python est extraordinaire. Vraiment. > - Python est très facile à apprendre. Il existe beaucoup de > ressources, même en français, sur Internet, dans des livres, etc. > - Python est un langage stable, avec très très peu de bugs/problèmes. > Sur ce point, windev marque sérieusement le pas. Sur certains forums > consacrés à windev, le nombre de bugs signalés était effarant. > - les librairies disponibles pour Python couvrent un spectre beaucoup > plus large que celles disponibles pour windev > - les bases de données intégrées à windev sont issues du vieux moteur > "hyperfile", beaucoup trop limité. Avec Python, on peut choisir le SGBD > que l'on veut, sans trop de soucis. Depuis SQL-lite, jusqu'à Oracle (XE > ou autre), on peut assumer tous les niveaux de puissance nécessaire. > - avec Python, on peut faire du multi-threading, du réparti, des > applications web, consoles, invisibles (services), des serveurs COM, > développer des interfaces, ou en utiliser de toutes prêtes, travailler > sur du réseau, piloter des équipements industriels, etc. etc. > - je n'utilise pas le "libre" comme argument, sauf pour un point : si > pc-soft (éditeur de windev) a, un jour de grosses difficultés, le > produit pourrait bien disparaitre soudainement, ce qui n'est pas le cas > de Python, maintenu par une communauté. Or, il y a peu d'années, cette > boîte a eu, justement, d'importants problèmes financiers. > > Le gros point fort de windev, c'est un marketing très agressif. > D'ailleurs, si tu veux manger et boire à l'oeil, va suivre les > présentations. > > Avant dernier point : tu aurais pu mettre ton message dans le newsgroup > français sur Python. > > Dernier point : si quelqu'un veut traduire ce message, il a mon accord > tout entier. > > > > -- > @-salutations > > Michel Claveau OK, I'll try a very literal translation (if it seems to makes any sense at all) Since you're french, you'll understand this. So, - windev is closed, and protected by dongles. Result: lost dongle, or broke, or stolen, you have to get another licence (It happened to a friend) - the windev language isn't close to have evolved like Python has. And by isn't close, I'm putting it weakly Python has great possibilities for procedural programming, Object-Oriented Programming, and even funxctional programming - The internal structure of Python is extraordinary. Really. - Python is very easy to learn. There are a lot of ressources, even in french, on Internet, in books, etc. - Python is a stable language, with very, very few bugs/problems - On that point, windev really hits the mark. On some fora pertaining to windev, the number of bugs brough up is appalling. - The available librairies for Python cover a much wider range than that available for windev. - the integrated database of windev comes from the very old "hyperfile" engine, much too limited. With Python, you can choose the DB you want, without a lot of worry. From SQL-Lite to Oracle (XE or other), you can assume any level of capacity required. - With Python, you can do multi-threading, RPCs, web apps, console apps, invisible (services), COM servers, build interfaces or use pre-existing ones, work on networking, drive industrial equipment, etc, etc - I'm not using that it's "open" as an argument, except for one point: if pc-soft (producer of windev) has , one day, some sort of big problem, the product might suddenly disappear, which is not the case of Python, maintained by a community. And a few years ago, it just happened to have some important financial problems The strong suit of windev lies in its agressive marketing. And so speaking, if you want free food and drink, attend the demonstrations Before last point: you could have posted your message to the french python newsgroup. And last, if someone wishes to translate this message, he has might entire agreement And I hope I did an okay job , michel. Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: windev vs python SOS
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] wrote: > > Hi, > > > > Bruno Desthuilliers a écrit : > >> I've never met a programmer that "loved" Windev. > > > > I have met some here (I'm the guy with a mustache-just kidding but > > actually I was there). > > > > http://www.pcsoft.fr/pcsoft/tdftech/2006/images/Paris/07-IMG_5853.jpg > > > > WinDev is widely used in France > > "widely used" ? Widely marketed, for sure, but last time I had to find a > job, there where not that much Windev positions (3 in one year in the > fifth french city) - much less than Java or .NET or (whatever your > mainstream language here) - or even PHP/Javascript FWIW. And it was not > better in other major french locations... > > (and please avoid us the usual marketing crap - been here, done that) > > > and that's a thing because a lot of > > french programmers think that english tools "have to be better". > > I think that's one of the dumbiest thing I've ever read. > > Thread's over for me - keeping on polluting this group with anything > related to this crap is a total waste of resources. > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" Two things (Well three things) : 1- thanks Tim Golden for translating the financial thingy! 2- I'm just back from the pc-soft site, and what do you know, I saw a download menu (for upgrades), went there and was told (Cut'nPaste here) CAUTION: To download these modules, you must own a registered copy of WinDev 10 "English" or "International" version. Otherwise, you are not authorized to download the modules below. - Now I don't own a copy so it wouldn't be usaful since it's an upgrade, but you know what? I hate this tone of voice ("you are not authorized to ...") but that's ok, it just my feelings. So I go to read testimonials, and wow playmobil, cool stuff - lots of prfetty playmobil pics too, even 2 screen shots, excepts that even at 300%, you can't make out what they are about. OK, so I'm a kid at heart - let's go see the John Deere testi - Nice pics of tractors and such, another unreadable screen shot... Eh!, think I, this is promotional stuff, so its *normal* promotional stuff, lets that a look at the beast since there is a big red "Download TRIAL VERSION" button by the windev 10 paragraph -so I click and get a "To download the WinDev trial version, please fill the form below: " message, hummm but there is a download button at the top of the form and then line annoncing optional infromation, so I click again without filling the info, thank you, so now I'm downloading windev 8 - that's before I cancel the job... hummm again, with all the nice people here and elsewhere, at Microsoft, and Oracle, and Sun ;-) that give out so much to to try and get there technology known - and I'm NOT talking about the OpenSource region of the world - It just makes me wonder, why can't you have an opinion and disagree with your boss ... But then again, maybe your boss wrote those testimonials on another life! 3-Re-reading some posts of this thread I'll permit myself an ultimate, if third point: "...What is cool about WinDev is that the language is closely embedded with the GUI. " makes for great MVC apps I'm sure. Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: storing variable names in a list before they are used?
John Salerno wrote: > If I want to have a list like this: > > [(first_name, 'First Name:'), (last_name, 'Last Name:').] > > where the first part of each tuple is a variable name and the second > part is a label for the user to see, such as a form like this: > > First Name: > Last Name: > > (the variables would store whatever information is entered in the text > boxes to the right of each label. I'm doing it this way so I can write a > loop to construct my GUI components). > > how would I go about putting these variable names in a list? I know I > can't leave them as above, but if I put them in as a string, then how do > I later "transform" them into an actual variable for assign, such as: > > first_name = widget.get_text() > > Is there some kind of idiom that does this sort of work? > > Thanks. Not sure but mmaybe this older post might help: http://mail.python.org/pipermail/tutor/2005-January/035232.html JM -- http://mail.python.org/mailman/listinfo/python-list
Re: does anybody earn a living programming in python?
Alex Martelli wrote: > Magnus Lycka <[EMAIL PROTECTED]> wrote: >... > > stuff in the world, so my standard extrapolation technique would yield > > 3 python programmers globally. > > I think this estimate is low, based on three piece of data I know (but, > sorry, are all confidential;-) and thus one I can infer: > -- I know how many copies of "Python in a Nutshell" Google buys; > -- I know how many Python programmers work at Google; > -- I know how many copies the Nutshell sells worldwide; > > Assuming the willingness to buy "Python in a Nutshell" is constant > across the population of Python programmers (and I don't believe my > working there influences anything -- Google had the Nutshell in the > standard set of books engineers use, well before I got hired there), I > can project a worldwide number of Python programmers that's several > times higher than that. > > Or perhaps not, depending on the definition of "Python programmer". > Most of Google's software developers who know Python also know one or > more (generally several) of C, C++, Java, SQL, HTML, Javascript, &c, > though they may or may not use any one or more of them often on the job; > many Googlers who program only in Python do not _just_ program -- they > are also working on other jobs besides software development (hardware > design, testing, management, administrative assistance, system > administration, network operations, whatever...). Hey, by a > sufficiently strict definition _I_ don't count as a "Python programmer", > since I also do substantial amounts of management, not to mention a > little bit of C++, some C, SQL, HTML, and so forth...;-) > > > Alex A few points: Personnally, I've never heard_of a Python_only programmer... When I chose Python for web dev programming class, no one knew why I was using a (second_rate) handy-crafty language, instead of ASP-PHP_whateverP language that was in the mainstream. Because of academic freedom, I was allowed to show it as a *different* type of language. Most mainstream job boards here in Montreal had never posted ANY (not that I could find) jobs (5 years ago) NONE so it went that it Python would just be a *educational* add-on for the students. Since then, feedback from students in industry is that it is being used more and more, day in and day out by top world class shops (games, effects, etc). BUT It's still Java, C++, PHP, SQL that have the marketing demands... Finally, also (personnal interpretation) because of the BUG2000 Scare, shops had boosted the staff with just about anyone they could get there hands on prior to this event, with the son, mom and great-grand uncle who could do a database of contacts in MSAccess (and this is NOT demeaning MSAccess), so now companies are NOT posting for the jobs in this *language* oriented fashion outside the mainstream (Java, C++,etc). Finally, most programmers and programmers-wannabe-students just don't hope to be top-tier in their trade - They just want a job, so they can marry, play, pay rent, go home - Sorry, most are not interested in technology, and since most managers I have seen, in a 15 year career in dev before taking a teaching job, don't CARE about technology, you have a perfect match for Java, PHP advertisement... My two cents, rooting for Python (and Ruby and Lua and OCaml, and ... you get the point!) Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Find directory name of file?
veracon wrote: > I'm pretty new at Python, so I have no idea how to do this: How do I > find the name of the directory that contains the application currently > being executed (e.g. if the file is /home/user/file.py, I want to get > the /home/user part)? > > Thanks! look into os.path module for help -- http://mail.python.org/mailman/listinfo/python-list
Re: Find directory name of file?
also the function os.cwd() ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Help!
Alex Martelli wrote: > Stephen <[EMAIL PROTECTED]> wrote: > > > Hi All, > > im new to python i just have a few questions and was wondering if > > you could help me?? > > > > 1. what programming langaugue does python use? or which is most popular? > > Python _is_ a programming language, so your question is not clear. If > you're asking what languages are used to implement Python, that's C (for > the mainstream version), Java (for Jython), C# (for IronPython), and > Python itself (for PyPy). > > > 2. Does anyone know where i could get hold of practice code > > http://aspn.activestate.com/ASPN/Python/Cookbook/ -- but much of it may > be a bit advanced for a beginner. > > > 3. Any good ebooks or links to start with. (according to the web this is the > > best place to start.) > > http://wiki.python.org/moin/BeginnersGuide lists many. > > > i know you probally get asked these questions all the time! but im trying to > > mirgrate for windows to linux. > > Python runs on Windows, Linux, Mac (where it comes with the OS, but then > that's also true of many Linux distros), and elsewhere. > > > Alex Just so you can grasp what this means (because C++ also has Windows, Linux and Mac implementation...), the SAME Python source code, including GUI parts (Tkinter*, in my case) run directly in all of them. *it's plain jane GUI, it doesn't do Aqua! jean-marc -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing modules
CONTEXT: Trying to modularize (is this english?) application development : MVC style, team distributed so that a visual component can be in one module imported and used by the __main__, and connected (read packed) at runtime to other components coming from the main or other modules. PROBLEM: After reading the above reference (and the Nutshell chapter) and trying different importing variations I still have a very difficult time understanding this situation. 1-importing Tkinter in main, 2-importing module that uses Tkinter, without importing Tkinter in that module (DOES NOT WORK) KLUDGED SOLUTION: import Tkinter in module (but don't understand why it has to be this way) MODEL (I taught would work): ## importTestMain module from Tkinter import * import testModule tata = testModule.toto() ## this works myWidget = tata.createNewFrame() ## this gets the exception (see below) ... ## testModule class toto(object): def __init__(self): self.someAttribute= 2 def createNewFrame(self): self.myFrame = Frame()## culprit line in exception return f if __main__=='__name__': ## team member tests is work here (does work!) from Tkinter import * myInstance = otherModule.toto() myWidget = myInstance.createNewFrame() root=Tk() myWidget.pack(in_=root) root.mainloop() The exception says : Traceback (most recent call last): File "C:\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\jean_marc\exemples_code_source\modules_packages\import_test\importTestMain.py", line 18, in ? tata=toto() File "C:\jean_marc\exemples_code_source\modules_packages\import_test\importTestMain.py", line 10, in __init__ self.myNewFrame = self.myTestModuleObject.createNewFrame(self.myInterModuleTestCommand) File "C:\jean_marc\exemples_code_source\modules_packages\import_test\testModule.py", line 8, in createNewFrame self.myFrame = Frame() NameError: global name 'Frame' is not defined >>> VARIATION Imported testModule AFTER using Tkinter in main... same error :( -- http://mail.python.org/mailman/listinfo/python-list
still don't get unicode and xml - help!
I have to work with XML data containing accented characters (ISO-8859-1 encoding) Using ElementTree, the only way i found to get the text attribute of a node was to encode it individually, if you want. It doubles the amount of time to process :-( i surely doing this wrong... What is the good way to do it? I didn't see an obvious way to do it this time... Thanks ## My XML Encoding Program #! c:/python24/python -u # -*- coding: iso-8859-1 -*- import elementtree.ElementTree as ET import time def getMyXML(accentedTest): filename="pagemembre.xml" tree = ET.parse(filename) elem = tree.getroot() if accentedTest: for i in elem: f= i.text.encode("iso-8859-1") #encode pour lire les accents else: for i in elem: f= i.text print f def writeMyXML(myrange,accentedTest): root = ET.Element("mondoc") if accentedTest: for i in range(myrange): ch=ET.SubElement(root, "monchapitre") ch.text="bel été et je serai la prêmière de la classe" else: for i in range(myrange): ch=ET.SubElement(root, "monchapitre") ch.text="bel ete et je serai la premiere de la classe" tree = ET.ElementTree(root) tree.write("pageMembre.xml","iso-8859-1") if __name__ =="__main__": accentedTest=int(raw_input("set 1 for accented test, 0 for ascii")) print "First, writing" t1=time.clock() writeMyXML(2,accentedTest) t2=time.clock() print "Now, reading" t3=time.clock() getMyXML(accentedTest) t4=time.clock() print "accents are",accentedTest,"writing=",str(t2-t1),"reading=",str(t4-t3) s=raw_input("END XML TEST") # End XML Encoding Program -- http://mail.python.org/mailman/listinfo/python-list
Re: dynamic drawing in web page
barbaros wrote: > Hello everybody, > > I need to put some dynamic drawings on my web page. More precisely, I > need to draw a number of geometric figures (circles, rectangles) which > evolve into a graphics windows according to some law (a little bit like > the solar system). I need also to have several fields aside the window, > where the visitor can change values for several significant parameters > (like the mass of each body). > > Could you please suggest a solution (preferably not involving hundreds > of lines of code) ? The computations should be performed on the client > machine. > > Thank you. Cristian Barbarosie http://cmaf.fc.ul.pt/~barbaros with this you can. http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm It's javascript and it's not the fastest thing on earth, but it works and its client-side... JM -- http://mail.python.org/mailman/listinfo/python-list
Play AVI files as cut-scene... in BGE - HOW?
Blender Game Engine does not seem able to just play an AVI clip file... I want to play these files as cut-scenes in a game - subprocess it to the OS, and continue on return seems a good solution - but so sorry, it's been a while since I've delved in such places... I need a refresher. Must be platform independent (or platform *adjustable* ;-) ) Continue script execution only after it's over (in due time or passed over by user) Must be configurable to adjust ourput screen and stuff like that... Any hints out there :-) Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list