Self-identifying functions and macro-ish behavior
Hi, I was wondering how I may get a python function to know what its name is without me having to write it manually? For example: def func1(): print 'func1' return True def func2(): print 'func2' return True should be more like def func1(): print return True def func2(): print return True I imagine this means things like closures which I'm not familiar with (I'm not a CS person). In this case, each function is part of a class, so I imagine I can take a dir() of the class if necessary. This leads into my next related question, which is How do I get some sort of macro behavior so I don't have to write the same thing over and over again, but which is also not neatly rolled up into a function, such as combining the return statements with a printing of ? My application has a bunch of functions that must do different things, then print out their names, and then each call another function before returning. I'd like to have the last function call and the return in one statement, because if I forget to manually type it in, things get messed up. (ok, I'm writing a parser and I keep track of the call level with a tab count, which gets printed before any text messages. So each text message has a tab count in accordance with how far down the parser is. Each time a grammar rule is entered or returned from, the tab count goes up or down. If I mess up and forget to call tabsup() or tabsdn(), the printing gets messed up. There are a lot of simple cheesy production rules, [I'm doing this largely as an exercise for myself, which is why I'm doing this parsing manually], so it's error-prone and tedious to type tabsup() each time I enter a function, and tabsdn() each time I return from a function, which may be from several different flow branches.) Thanks for any help :) Michael -- http://mail.python.org/mailman/listinfo/python-list
Excel and TrackChanges
I have a problem with pycom automation with excel. If i use the following in my excel_wrapper: """ self.Workbook.Save() self.Workbook.HighlightChangesOptions(When=1) self.Workbook.ListChangesOnNewSheet = True """ I don't get any history worksheet. If i use 2 (xlAllChanges) or 3 (xlNotYetReviewed), i get the history worksheet but with all results. I use Office 2k sp1. thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: Which is faster? (if not b in m) or (if m.count(b) > 0)
In <[EMAIL PROTECTED]>, Farel wrote: > Which is Faster in Python and Why? ``if not b in m`` looks at each element of `m` until it finds `b` in it and stops then. Assuming `b` is in `m`, otherwise all elements of `m` are "touched". ``if m.count(b) > 0`` will always goes through all elements of `m` in the `count()` method. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write a C-style for loop?
John Salerno wrote: > for (int i = 0; i < 50; i += 5) > > How would that go in Python, in the simplest and most efficient way? for i in xrange(0,50,5): print i -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write a C-style for loop?
John Salerno wrote: > I assume this is the way for loops are written in C, but if it helps to > be specific, I'm referring to C# for loops. The Python for loop seems to > be the same (or similar) to C#'s foreach loop: > > foreach int i in X > > But how would you write a C# for loop in Python? Do you rework a while > loop, or use the range() function? > > Here's an example: > > for (int i = 0; i < 50; i += 5) > > How would that go in Python, in the simplest and most efficient way? > > Thanks. Take a look at the range() builtin. That should give you what you need. -- http://mail.python.org/mailman/listinfo/python-list
how to write a C-style for loop?
I assume this is the way for loops are written in C, but if it helps to be specific, I'm referring to C# for loops. The Python for loop seems to be the same (or similar) to C#'s foreach loop: foreach int i in X But how would you write a C# for loop in Python? Do you rework a while loop, or use the range() function? Here's an example: for (int i = 0; i < 50; i += 5) How would that go in Python, in the simplest and most efficient way? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Do you want your own free virtual mall?? Come here...
http://www.telebay.com/esolutions/mall.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: accountability & lying thru the teeth
Al Balmer wrote: > On Tue, 14 Feb 2006 23:59:19 GMT, Kenny Tilton > <[EMAIL PROTECTED]> wrote: > > >>Ulrich Hobelmann wrote: >> >>>Xah Lee wrote: >>> >>> here's a site: http://www.longbets.org/bets that takes socially important predictions. I might have to enter one or two. i longed for such a accountable predictions for a long time. Usually, some fucking fart will do predictions, but the problem is that it's not >>> >>>[...] >>> >>>OMG, he's back. >>> >>>I predict, Xah will haunt us for years to come. >>> >> >>WTF is wrong with Xah? He posts an occasional article in good faith and >>leaves it at that. ignoring the insults that follow. > > > Apparently you've never actually read one of his articles. Have you read his web page? Like I did? Get back to me after you come up to speed on Xah. > >>In the end we have one good-faith article and a bunch of personal >>attacks from a Usenet chorus of self-appointed finger-shakers creating >>more pollution than he ever did. >> >>If only some of the people castigating Xah for daring to use Usenet >>would post as rarely as he, and show as much restraint. >> > > Restraint? Now I know you haven't read it. > Note that I was not endorsing the content. The restraint I was talking about was in ignoring you. If you and everyone else ignored his articles there would not be this thread. Which is not being dragged out by Xah. You all dis Xah, yet he is larger than you: you cannot resist heaping abuse on him. If you could, his articles would appear and disappear without leaving a trace. Instead we get people with half his wit making lame attempts at witty put-downs, embarrassing only themselves. Xah acknowledges his problem, you clowns do not even know you have one. kenny -- http://mail.python.org/mailman/listinfo/python-list
Re: How to *Search* with google from inside my programme and get the search result?
Frank Potter <[EMAIL PROTECTED]> wrote: ... > Does google supply some webservice to programmers? I did see Yep, see http://www.google.com/apis/index.html . Alex -- http://mail.python.org/mailman/listinfo/python-list
Which is faster? (if not b in m) or (if m.count(b) > 0)
Which is Faster in Python and Why? jc = {}; m = [] x = [ [1,2,3,4,5,6,7,8,9],[..],...] # upwards of 1 entries def mcountb(): for item in x: b = item[:]; b.sort(); bc = 0 for bitem in b: bc += int(bitem) try: m = jc[bc] except: m = [] if m.count(b) == 0: m.append(b); jc[bc]=m def binm() for item in x: b = item[:]; b.sort(); bc = 0 for bitem in b: bc += int(bitem) try: m = jc[bc] except: m = [] if not b in m: m.append(b); jc[bc]=m -- http://mail.python.org/mailman/listinfo/python-list
Re: How to *Search* with google from inside my programme and get the search result?
Frank Potter wrote: > Does google supply some webservice to programmers? I did see Googling for "google api" gets you to: http://www.google.com/apis/ It appears to be a SOAP API, which you can access with python, but I think you'll need a third-party library. Googling for "python soap" gets you: http://www-128.ibm.com/developerworks/library/ws-pyth5/ which might be a place to start. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to cat None
Seems that what you want to do is to create a string in the form of : "55Init=Init\n55First=first\n55Last=Last\n55Alias=None" for each dictionary. If that is the case, may be you can try this : "\n".join("%s=%s" % x for x in user1.iteritems()) Note that you cannot control the ordering of the keys when iterating a dict which may or may not be a concern for you. LittlePython wrote: > I found out the hard way that I can not cat None. I get an error. Is there a > simple way to cat None without doing some kind of equation ( if this then > that). Is there a isNone() somewhere. I am not too sure I know what None > really means. > > I include an example to show what I am talking about in case I am alittle > confused. > > > > > from easygui import * > import string > > msgbox('Starting Program') > > thisfile = fileopenbox(msg='Choose the correct File', title='Matrix Input > File') > input = file(thisfile,'r') > > header = string.split(string.strip(input.readline()),',') > header.extend(['55FirstName', > '55Intial','55LastName','55Alias',]) > > all = input.readlines() > input.close > input = None > matrix = {} > for user in all: > user1 = string.split(string.strip(user),',') > user1.extend(['None']*4)<-I would like to > None or better NULL this instead of string it > user1 = dict(zip(header,user1)) > matrix[user1['OldNTLogon']] = user1 > > mychoice = choicebox(choices=matrix.keys()) > user1 = matrix[mychoice] > > alltogether = '' > > for KeyName in user1.keys(): > if alltogether == '': > alltogether = KeyName + '=' + ' ' + user1.get(KeyName) + '\n' > else: > alltogether = alltogether + KeyName + '=' + user1.get(KeyName) + > '\n' <--- error 'can not cat None with a str' or something like that > > msgbox(alltogether,'User Matrix for '+ mychoice ) > > msgbox('The End') -- http://mail.python.org/mailman/listinfo/python-list
Re: processing limitation in Python
[EMAIL PROTECTED] wrote: > But running it in IDLE just locks up the > computer. Bad Windows. yeah, right - blame it all on Microsoft! try ctrl-F6 (or Shell / Restart Shell from the menu) in IDLE, which stops programs from infinite looping - nas -- http://mail.python.org/mailman/listinfo/python-list
Re: How to cat None
LittlePython wrote: I am not too sure I know what None really means. It means null, void or lack of value. It is not an empty string. You can't add None to stings. >>> r = None >>> print r None >>> print type(r) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to cat None
You can just surround the offending value with str(...). You should probably be doing that anyway, because the value might be a number or something else not stringish. -- http://mail.python.org/mailman/listinfo/python-list
Re: Soduku
you dont measure single run, you measure multiple runs using the "timeit" module (for me 1000 repeats was about right). here are some results which i recorded when i was implementing Sudoku solver (on AMD Athlon 1.25GHz, using the sample shown on www.sudoku.com front page): brute: 1000 for 83 sec smart: 1000 for 21 sec brute, bitset: 1000 for 29 sec smart, bitset: 1000 for 7.0 sec smart, bit+que: 1000 for 5.3 sec so you see the algorithm makes big difference... and so does the data structure used. i got 15x speed-up that way. i guess i can claim that my solver runs the sample for 5.3s/1000 = 5.3 ms! a friend was also implementing sudoku - this time in C - and his program solves the sample 1 times for 3.4sec (i.e. for 0.34ms) on slightly faster machine - so let's say his **highly optimized** C code is about 10x faster than mine. - Nas -- http://mail.python.org/mailman/listinfo/python-list
Re: Soduku
27ms == 0.027s How do you have a 16x16 grid for soduku? Are you using 16 digits? 0-F? The one I am using has 9 digits, 9 squares of 9 cells each, or 9x9 cells. The least efficient part of the algorithm is that part to calculate what to put in a hole (as anyone might've guessed.) My algorithm calculates this by using a set of possible values. Then I visit each cell in the same row, column, and square, removing values from the set. What's left is the possible values. If there is only one possible value, then I've found what belongs there. The soduku puzzle I was using for a test can be solved without making any guesses in this way. The guy's algorithm was visiting each empty square and then trying out numbers from 1-9. If they didn't violate the rules (by examining each cell in the row, column, and square for each guess), then he would move to the next empty cell and try again, until he got the solution. There was a lot of backtracking and it would even try to find all possible answers. -- http://mail.python.org/mailman/listinfo/python-list
How to cat None
I found out the hard way that I can not cat None. I get an error. Is there a simple way to cat None without doing some kind of equation ( if this then that). Is there a isNone() somewhere. I am not too sure I know what None really means. I include an example to show what I am talking about in case I am alittle confused. from easygui import * import string msgbox('Starting Program') thisfile = fileopenbox(msg='Choose the correct File', title='Matrix Input File') input = file(thisfile,'r') header = string.split(string.strip(input.readline()),',') header.extend(['55FirstName', '55Intial','55LastName','55Alias',]) all = input.readlines() input.close input = None matrix = {} for user in all: user1 = string.split(string.strip(user),',') user1.extend(['None']*4)<-I would like to None or better NULL this instead of string it user1 = dict(zip(header,user1)) matrix[user1['OldNTLogon']] = user1 mychoice = choicebox(choices=matrix.keys()) user1 = matrix[mychoice] alltogether = '' for KeyName in user1.keys(): if alltogether == '': alltogether = KeyName + '=' + ' ' + user1.get(KeyName) + '\n' else: alltogether = alltogether + KeyName + '=' + user1.get(KeyName) + '\n' <--- error 'can not cat None with a str' or something like that msgbox(alltogether,'User Matrix for '+ mychoice ) msgbox('The End') -- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected behaviour of getattr(obj, __dict__)
"Carl Banks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > But wait, it gets weirder. Not weird at all. Just an artifact of CPython's storage recycling algorithm. id(Parrot.f) == id(Parrot.f) > True id(Parrot.__dict__) == id(Parrot.__dict__) > True A wrapper is created and passed to id() which returns an int object while releasing the wrapper back to the free list. Then another wrapper is created in the same chunk of memory and passed to id, which returns an int of the same value for comparison. The language ref only guarantees uniqueness of ids at any particular instant and allows reuse of ids of deallocated objects. I half seriously think the lib ref entry for id() should have a warning that naive use can mislead. > But that's not all. Redefine Parrot as: > > class Parrot(object): >def f(self): pass >def g(self): pass > > Then, > id(Parrot.f) == id(Parrot.g) > True Same thing. The wrapper content is not relevant as long as it uses the same memory block. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
This is top posting, i.e. my post is above yours. For this particular response, it seems to be a bit more appropriate to do bottom posting, see below. However, don't take that as a rule or convention that you need to do one or another exclusively, it depends and I believe mature and sincere posters would know when to do which. LittlePython wrote: > I have no idea what top-posting or bottom-posting is? This is bottom posting, where people can refer to what I am answering to, right above this line/paragraph. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
I have no idea what top-posting or bottom-posting is? "Felipe Almeida Lessa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Em Qua, 2006-02-15 às 00:30 +, LittlePython escreveu: > > I really do not wish to limit myself to MS. My bread and butter is MS but I > > am a BSD fan at heart. I wanted to learn something I can use in both. > > Please start by not top-posting ;-). Also, see > http://www.mono-project.com/VisualBasic.NET_support . > > -- > "Quem excele em empregar a força militar subjulga os exércitos dos > outros povos sem travar batalha, toma cidades fortificadas dos outros > povos sem as atacar e destrói os estados dos outros povos sem lutas > prolongadas. Deve lutar sob o Céu com o propósito primordial da > 'preservação'. Desse modo suas armas não se embotarão, e os ganhos > poderão ser preservados. Essa é a estratégia para planejar ofensivas." > > -- Sun Tzu, em "A arte da guerra" > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python equivilant to msgbox()
I am glad you did remind me of WScript.Shell ... I have to keep in mind that most if not all of what I have been using in VBS is avail to me. Thx "Claudio Grondi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython wrote: > > I am no VB programmer just dabble in vbscripting abit. The only one I am > > aware of is the popup as self closing. I never thought of using com. > Ok, so my remarks about COM were not for you. > > > > Do you know of any thing for a busy box in the same vain as easygui > No, I don't, but it doesn't mean, that there is none considering myriads > of various available COM components. My idea was to make you aware, that > you can use your VB compiler for creating any ActiveX/COM components for > usage with Python the way I have described, but as you write it seems > not to be an option for you. > > So I have to admit, that EasyGUI is in your case apparently > >>> exactly what you was looking for ... > > :-) > > Claudio > > > > > > "Claudio Grondi" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>LittlePython wrote: > >> > >>>That is exactly what I was look for .. thx > >> > >>Surprised to hear that. > >> > >>As VisualBasic programmer I would expect you to have experience with > >>ActiveX on Windows, where the best way to go with Python is to reuse all > >>the ActiveX components and their known user interfaces (i.e. constants > >>to use as parameter and constants for interpretation of return values) > >>directly from within Python. > >> > >>A message box goes e.g. this way: > >> > >> >>> import win32com.client > >> >>> axWshShell = win32com.client.Dispatch("WScript.Shell") > >> >>> axWshShell.Popup(u"(MsgText)This axWshShell.Popup closes itself > >>after 45 seconds", 45, u"(MsgTitle)Testing WScript.Shell object:", 1) > >> > >>By the way: is there a ready for direct use timed self closing Ok/Cancel > >>message box in any of the proposed GUI packages? > >> > >>Claudio > >> > >>> > >>>"Kent Johnson" <[EMAIL PROTECTED]> wrote in message > >>>news:[EMAIL PROTECTED] > >>> > >>> > LittlePython wrote: > > > >Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I > >would like to call this instead of print (to the screen) . I would like > >to write a simple script that is not an event drive gui but calls input > >boxes, message boxes, or maybe even a file open browser box as well? > > Take a look at EasyGUI: > http://www.ferg.org/easygui/ > > Kent > >>> > >>> > >>> > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding an Application in a Web browser
bruno at modulix wrote: > rodmc wrote: >> Is it possible to embed a Python application within Internet explorer? > > No. Nor in any other browser (except from Grail, but I think this > doesn't count). You can if you use IronPython. Of course it will only work with Internet Explorer on windows. Java and JVM languages are of course much better for applets: jython, groovy, jruby, etc. I don't know if jython or jruby applets are actually possible however since it is interpreted. >> However if someone clicks >> on a shape it should open up another application, such as Word. > > Lol. This would be a really big bad security issue. Look up Microsoft's smart client api. It is their answer to java web start. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic gui format?
bruno at modulix wrote: > DH wrote: >> bruno at modulix wrote: >> >>> DH wrote: >>> Bruno Desthuilliers wrote: >> I am currently seeking for pythonic alternative for XML. > > A pretty obvious one is dicts and lists. What about (Q&D): That's like JSON: http://www.json.org/example.html >>> >>> No, it's pure Python. It happens that JSON looks pretty close to Python, >>> but that's another point. >> >> Python dict and lists ARE JSON. The only difference that python can't >> handle is multiline comments. > > And what about true vs True and false vs False ?-) The syntax is the same, except for, as I said, JSON's multiline comments. The semantics do differ, but that has nothing to do with the user's question, about an alternative to XML for data representation. You can use "true" or True or "null" or None or whatever semantic values you want. You can use the JSON library if you want. But there really is no need in this case. Just import the file containing the dicts and lists. > No, Python's dicts and lists are not JSON. Which are syntactically identical to JSON's. > They are Python's dicts and > lists. JSON stands for JavaScript Object Notation, and AFAIK, Python and > javascript are two different languages No shit. -- http://mail.python.org/mailman/listinfo/python-list
Re: processing limitation in Python
Big help guys, thanks. There does seem to be a problem with Pythons IDLE. If I run my oridgional program from a dos shell I can hit Ctrl-C and free up the procesor, But running it in IDLE just locks up the computer. Bad Windows. Thanks for the help with a more efficent algorythm. David KG2LI -- http://mail.python.org/mailman/listinfo/python-list
How to *Search* with google from inside my programme and get the search result?
I want to search something by a key word from inside my py script. The using google idea comes to my mind first because write a search programme from scratch is not so easy. I want to take advantage of goolge results, but I don't know how. To extract the result from html of google can get the result, but it's not reliable and stable because the html structure my be changed any time. Does google supply some webservice to programmers? I did see some a tool use google to search and use it's result from the programme very well. Its name is "Email catcher&sender 2.10", which can be download at http://www.worldminer.com/download.htm. Windows users can take a look at it. It supports more than google, but yahoo and some other search engines. How does it do it? I really need some hints. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and ASP
What do you mean? I can't just upload the file to the server that is going to host my site? -- http://mail.python.org/mailman/listinfo/python-list
Re: html source
Hi Steve (Young), Here is my take. It is possible that the web page you are accessing dynamically generates the page using the user-agent. The user-agent when used from urllib2 will be set to Python-urllib/x.x. If the page were generated dynamically, this would go into the "else" part (of the page-generation logic) and yield a page without all the fancy scripts. Why don't you try setting the user-agent to same as the browser you are using and see if you get the same HTML source this time. Refer http://diveintopython.org/http_web_services/user_agent.html on setting the user-agent. Thanks, --Kartic The Great 'Steve Holden' uttered these words on 2/13/2006 4:53 PM: > Steve Young wrote: > >> Hi, I was wondering why when I use urllib2.build_opener().open(url), >> it doesn't give me the same thing as if I would just click on view--> >> source on my web browser. It gives me most of html on the page but >> leaves out lots of scripts and some of the link's urls are truncated. >> Is there something out there in python that gives me EXACTALLY the >> same thing as if you were to just do view-->source on the web browser? >> Thanks for the help. >> > If this observation is truly correct it should qualify as a bug. Can you > give us a URL and some code which demonstrate your assertion? > > regards > Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and ASP
ASP files have to be served up by a web server. Roger "Tempo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It still doesn't work. I fixed that one error that you pointed out > Roger Upole, but it still isn't working. All I did was copy and past > the code above, plus Roger's fix, into Notepad2 and saved it as a > '.asp'. When I opened it in Firefox, all that showed up was the source > code of the file. It seems like it is reading the '.asp' file as a text > file in the web browser. Any further ideas? Thanks. > == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Soduku
On Tue, Feb 14, 2006 at 05:32:48PM -0800, Jonathan Gardner wrote: > Here at my job, Python gets no respect. > > A programmer here wanted to see which language among Python, Perl, and > Java was better. So he wrote a Python, perl, and Java version. Except > the Python version was 20x slower than the perl and Java versions. > > Well, luckily he asked around in our little Python group about what he > did wrong. He simply misindented a block of code, making it run 10x as > often as it needed to. With that one fix, it was running faster than > the Java and perl versions, about 2x as fast. A few other minor tweaks > made it run even faster. > > And we've been playing with different algorithms for soduku solutions. > I had it down to 27 ms to solve the puzzle. > A nice story to hear, did you measure how long each of the solutions took you to write (even if it was just a wrote translation of the same strategy)? Is my math off or does 27ms mean 0.027 seconds? On my laptop (1.3GHz) an empty python program takes 10ms to run (0.010 secs). I ask out of vanity, my own solver takes .15 seconds to run (20 seconds for a 16x16 grid). -jackdied -- http://mail.python.org/mailman/listinfo/python-list
Re: listing attributes
You are right, using __dict__ is what i needed. But I chose the solution explained before because i don't want to list all attributes of the object, only attributes that are instances of the class Property (or a subclass of it). -- http://mail.python.org/mailman/listinfo/python-list
'could not open display' error when import gtk - how fix?
Why can't I import gtk (pygtk) module? It appears gtk module want X perms? >>> import gtk Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.3/site-packages/gtk-2.0/gtk/__init__.py", line 37, in ?from _gtk import * RuntimeError: could not open display -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and ASP
It still doesn't work. I fixed that one error that you pointed out Roger Upole, but it still isn't working. All I did was copy and past the code above, plus Roger's fix, into Notepad2 and saved it as a '.asp'. When I opened it in Firefox, all that showed up was the source code of the file. It seems like it is reading the '.asp' file as a text file in the web browser. Any further ideas? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Soduku
Em Ter, 2006-02-14 às 17:32 -0800, Jonathan Gardner escreveu: > So, one more story on why Python is really good. I think, at least with > 2.4, we should start bragging about Python's speed. I mean, it beats > Java AND perl! Maybe the other implementations also have errors? Well, I'm not saying Python is worse than them, I'm just trying to be fair. Besides, puzzles can't say if one is better than the other, they're completely out of the reality of most programs. Just my two cents, Felipe. -- "Quem excele em empregar a força militar subjulga os exércitos dos outros povos sem travar batalha, toma cidades fortificadas dos outros povos sem as atacar e destrói os estados dos outros povos sem lutas prolongadas. Deve lutar sob o Céu com o propósito primordial da 'preservação'. Desse modo suas armas não se embotarão, e os ganhos poderão ser preservados. Essa é a estratégia para planejar ofensivas." -- Sun Tzu, em "A arte da guerra" -- http://mail.python.org/mailman/listinfo/python-list
Soduku
Here at my job, Python gets no respect. A programmer here wanted to see which language among Python, Perl, and Java was better. So he wrote a Python, perl, and Java version. Except the Python version was 20x slower than the perl and Java versions. Well, luckily he asked around in our little Python group about what he did wrong. He simply misindented a block of code, making it run 10x as often as it needed to. With that one fix, it was running faster than the Java and perl versions, about 2x as fast. A few other minor tweaks made it run even faster. And we've been playing with different algorithms for soduku solutions. I had it down to 27 ms to solve the puzzle. So, one more story on why Python is really good. I think, at least with 2.4, we should start bragging about Python's speed. I mean, it beats Java AND perl! -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
Em Ter, 2006-02-14 às 19:54 -0500, Ken Stevens escreveu: > Some people or group of people decided bottom posting was better and it > MUST be that way. To me that even goes against one of the main > philosophies of Linux which is that of choice. So, to any who think, > otherwise... there is absolutely NOTHING wrong or incorrect about TOP > posting. OK, rant mode off. I feel better now! I got that off my chest! I don't want to start another discussion about this (the ck mailing list had one these days), but this has nothing to do about choice: it's a convention. And I don't think you want even to try to send a patch to Linus with code conventions he doesn't like. -- "Quem excele em empregar a força militar subjulga os exércitos dos outros povos sem travar batalha, toma cidades fortificadas dos outros povos sem as atacar e destrói os estados dos outros povos sem lutas prolongadas. Deve lutar sob o Céu com o propósito primordial da 'preservação'. Desse modo suas armas não se embotarão, e os ganhos poderão ser preservados. Essa é a estratégia para planejar ofensivas." -- Sun Tzu, em "A arte da guerra" -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you pronounce 'tuple'?
On Tue, 14 Feb 2006 09:16:18 -0600 Rocco Moretti <[EMAIL PROTECTED]> wrote: > Erik Max Francis wrote: > > If a 4-tuple is a quadruple, a 3-tuple is a triple, a > > 2-tuple is an pair, then I guess a 1-tuple would be a > > single. Granted that's not nearly as gruesome enough a > > name to go with the special lopsided Pythonic creature > > mentioned above. I suggest we name it a hurgledink. > > +1 QOTW Yeah, +1, definitely. -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
Ken Stevens wrote: > Felipe Almeida Lessa wrote: >> Em Qua, 2006-02-15 às 00:30 +, LittlePython escreveu: >>> >> Please start by not top-posting ;-) > Sigh! This has been bothering me for some time. I tend to bottom post > primarily because people here are so anal about it. > > In any case, I actually prefer top posting The rule here is _neither_ top post _nor_ bottom post. Show _only_the_ _relevant_part_ (including what you are replying to), and then reply to it. This often means interspersed quotes and replies. If a reader wants the whole previous message, we have google groups (or other archives). This is not your email, but a public board that others will later search for answers. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you pronounce 'tuple'?
On Tue, 14 Feb 2006 10:40:09 -0500 Tim Peters <[EMAIL PROTECTED]> wrote: > the-acid-test-is-whether-you-say-"xor"-with-one-syllable- > or-three-ly y'rs - tim -- Oh dear, I say it with two, am I just not cool, or what? ;-) "ex-or" -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python equivilant to msgbox()
LittlePython wrote: > I am no VB programmer just dabble in vbscripting abit. The only one I am > aware of is the popup as self closing. I never thought of using com. Ok, so my remarks about COM were not for you. > > Do you know of any thing for a busy box in the same vain as easygui No, I don't, but it doesn't mean, that there is none considering myriads of various available COM components. My idea was to make you aware, that you can use your VB compiler for creating any ActiveX/COM components for usage with Python the way I have described, but as you write it seems not to be an option for you. So I have to admit, that EasyGUI is in your case apparently >>> exactly what you was looking for ... :-) Claudio > > > "Claudio Grondi" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>LittlePython wrote: >> >>>That is exactly what I was look for .. thx >> >>Surprised to hear that. >> >>As VisualBasic programmer I would expect you to have experience with >>ActiveX on Windows, where the best way to go with Python is to reuse all >>the ActiveX components and their known user interfaces (i.e. constants >>to use as parameter and constants for interpretation of return values) >>directly from within Python. >> >>A message box goes e.g. this way: >> >> >>> import win32com.client >> >>> axWshShell = win32com.client.Dispatch("WScript.Shell") >> >>> axWshShell.Popup(u"(MsgText)This axWshShell.Popup closes itself >>after 45 seconds", 45, u"(MsgTitle)Testing WScript.Shell object:", 1) >> >>By the way: is there a ready for direct use timed self closing Ok/Cancel >>message box in any of the proposed GUI packages? >> >>Claudio >> >>> >>>"Kent Johnson" <[EMAIL PROTECTED]> wrote in message >>>news:[EMAIL PROTECTED] >>> >>> LittlePython wrote: >Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I >would like to call this instead of print (to the screen) . I would like >to write a simple script that is not an event drive gui but calls input >boxes, message boxes, or maybe even a file open browser box as well? Take a look at EasyGUI: http://www.ferg.org/easygui/ Kent >>> >>> >>> > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: accountability & lying thru the teeth
Kenny Tilton <[EMAIL PROTECTED]> wrote: > If only some of the people castigating Xah you misspelled castrated -- John Small Perl scripts: http://johnbokma.com/perl/ Perl programmer available: http://castleamber.com/ I ploink googlegroups.com :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
Felipe Almeida Lessa wrote: >Em Qua, 2006-02-15 às 00:30 +, LittlePython escreveu: > > >>I really do not wish to limit myself to MS. My bread and butter is MS but I >>am a BSD fan at heart. I wanted to learn something I can use in both. >> >> > >Please start by not top-posting ;-). Also, see >http://www.mono-project.com/VisualBasic.NET_support . > > > Sigh! This has been bothering me for some time. I tend to bottom post primarily because people here are so anal about it. In any case, I actually prefer top posting. Reading the New message first is better (because I get lot of mail). If I need to be reminded of context I can always scan down. It makes much more sense to me. Some people or group of people decided bottom posting was better and it MUST be that way. To me that even goes against one of the main philosophies of Linux which is that of choice. So, to any who think, otherwise... there is absolutely NOTHING wrong or incorrect about TOP posting. OK, rant mode off. I feel better now! I got that off my chest! Ken -- http://mail.python.org/mailman/listinfo/python-list
Re: Mac OS X - Deployment
Matt Trivisonno wrote: > Hi Everybody, > > I just spent about an hour googling and still can't find out how to deploy a > Python app to Mac OS X. > > I just finished a simple Hello-World GUI app using wxPython and deployed it > to > a WinXP system using PyInstaller. So I am familiar with the basic tools. > > It would be great if I could build an OS X executable from my XP system. Is > that possible? If so, is it documented anywhere? > > If I can't do it on XP, I suppose I would have to install Python and wxPython > on a Mac, then copy over my HelloWorld.py file, but what then? I know how to > make DMG files, but what woudl go into the DMG? > > I am used to REALbasic where you write your code and then push the "Build" > button and executables for Linux, Windows, and Mac are created in less than a > minute. Maybe the Python world will be as advanced one day... > > Thanks, > Matt > > > py2app works for this. I'm not sure if it works from windows. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
Em Qua, 2006-02-15 às 00:30 +, LittlePython escreveu: > I really do not wish to limit myself to MS. My bread and butter is MS but I > am a BSD fan at heart. I wanted to learn something I can use in both. Please start by not top-posting ;-). Also, see http://www.mono-project.com/VisualBasic.NET_support . -- "Quem excele em empregar a força militar subjulga os exércitos dos outros povos sem travar batalha, toma cidades fortificadas dos outros povos sem as atacar e destrói os estados dos outros povos sem lutas prolongadas. Deve lutar sob o Céu com o propósito primordial da 'preservação'. Desse modo suas armas não se embotarão, e os ganhos poderão ser preservados. Essa é a estratégia para planejar ofensivas." -- Sun Tzu, em "A arte da guerra" -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
I really do not wish to limit myself to MS. My bread and butter is MS but I am a BSD fan at heart. I wanted to learn something I can use in both. I thought about Perl first but I feel the learning curve is to steep (to get it right), it seems easier to make a mistake in Perl and not catch it. Python just feels right and fits me better. ... Well what do I know ... you make you pick and take your chances. <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > LittlePython wrote: > > I am very new to python. I have been studying it for only a month or so. I > > have been using vbscript for about 2-3 yrs and only recently been using it > > rather heavily the past 9 months or so. I am new very new to oop. My main > > use will be administrative scripting into the win3k, XP, AD domain, > > 55exchange and 2003exchange environments. I like to incorp wxpython (GUI) > > into my scripts instead of HTA's that I have been using with VBS. I am also > > finding myself being tasked with jobs that are outside the scope of VBS. > > Well that's a lot to learn and I have a feeling that to many I am just > > another member of "The Ministry of STUPID Questions" > > > Out of curiosity, why python ? The new VB.Net seems to be a very > interesting one language wise and given that you have a VB experience, > it seems to be a natural one to try. > -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: accountability & lying thru the teeth
On Tue, 14 Feb 2006 23:59:19 GMT, Kenny Tilton <[EMAIL PROTECTED]> wrote: >Ulrich Hobelmann wrote: >> Xah Lee wrote: >> >>> here's a site: http://www.longbets.org/bets that takes socially >>> important predictions. I might have to enter one or two. >>> >>> i longed for such a accountable predictions for a long time. Usually, >>> some fucking fart will do predictions, but the problem is that it's not >> >> [...] >> >> OMG, he's back. >> >> I predict, Xah will haunt us for years to come. >> > >WTF is wrong with Xah? He posts an occasional article in good faith and >leaves it at that. ignoring the insults that follow. Apparently you've never actually read one of his articles. > >In the end we have one good-faith article and a bunch of personal >attacks from a Usenet chorus of self-appointed finger-shakers creating >more pollution than he ever did. > >If only some of the people castigating Xah for daring to use Usenet >would post as rarely as he, and show as much restraint. > Restraint? Now I know you haven't read it. -- Al Balmer Sun City, AZ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python equivilant to msgbox()
I am no VB programmer just dabble in vbscripting abit. The only one I am aware of is the popup as self closing. I never thought of using com. Do you know of any thing for a busy box in the same vain as easygui "Claudio Grondi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython wrote: > > That is exactly what I was look for .. thx > Surprised to hear that. > > As VisualBasic programmer I would expect you to have experience with > ActiveX on Windows, where the best way to go with Python is to reuse all > the ActiveX components and their known user interfaces (i.e. constants > to use as parameter and constants for interpretation of return values) > directly from within Python. > > A message box goes e.g. this way: > > >>> import win32com.client > >>> axWshShell = win32com.client.Dispatch("WScript.Shell") > >>> axWshShell.Popup(u"(MsgText)This axWshShell.Popup closes itself > after 45 seconds", 45, u"(MsgTitle)Testing WScript.Shell object:", 1) > > By the way: is there a ready for direct use timed self closing Ok/Cancel > message box in any of the proposed GUI packages? > > Claudio > > > > > > "Kent Johnson" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>LittlePython wrote: > >> > >>>Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I > >>>would like to call this instead of print (to the screen) . I would like > >>>to write a simple script that is not an event drive gui but calls input > >>>boxes, message boxes, or maybe even a file open browser box as well? > >> > >>Take a look at EasyGUI: > >>http://www.ferg.org/easygui/ > >> > >>Kent > > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: accountability & lying thru the teeth
Ulrich Hobelmann wrote: > Xah Lee wrote: > >> here's a site: http://www.longbets.org/bets that takes socially >> important predictions. I might have to enter one or two. >> >> i longed for such a accountable predictions for a long time. Usually, >> some fucking fart will do predictions, but the problem is that it's not > > [...] > > OMG, he's back. > > I predict, Xah will haunt us for years to come. > WTF is wrong with Xah? He posts an occasional article in good faith and leaves it at that. ignoring the insults that follow. In the end we have one good-faith article and a bunch of personal attacks from a Usenet chorus of self-appointed finger-shakers creating more pollution than he ever did. If only some of the people castigating Xah for daring to use Usenet would post as rarely as he, and show as much restraint. ken -- http://mail.python.org/mailman/listinfo/python-list
[ANN] python-openid 1.0.4
This morning there was a message in my inbox from my DNS registrar inviting me to click through for a "special message" from them. An animation loaded with elaborately rendered red roses and candlelight, and wishes for a happy valentines day written out in a flowing font. Well, I guess we could have done that too. But we don't really know that much about this Saint Valentine character. Do we really need to send out cards stamped with symbolic hearts? Or would it in fact be better to publish some bug fixes? For all I know, Saint Valentine's day job is working as a sysadmin. Perhaps he even runs an OpenID server for his company's domain. So today we're releasing version 1.0.4 of our Python OpenID library. This is a maintenance release which includes in openid.consumer: * added logging to more error cases. * fixed to appropriately return SETUP_NEEDED from completeAuth(). * fixed some occurrences of unnecessarily falling back to dumb mode. in openid.server: * corrections to the server's replay attack prevention in dumb mode. * made more careful checking of trust_root. and in openid.store, used by both parties: * removal of several arbitrary field limits in the SQL stores. (This will effect newly created stores only; old ones will continue operating with their existing schema.) Python OpenID is available under the GNU LGPL from http://www.openidenabled.com/openid/libraries/python Download links: http://www.openidenabled.com/resources/downloads/python-openid/python-openid-1.0.4.tar.gz http://www.openidenabled.com/resources/downloads/python-openid/python-openid-1.0.4.zip sha1sums: 1d7548ece4a92d70fe5f8b8abbfbafd30ea57c4b python-openid-1.0.4.tar.gz 423fde12c5030553798381ffa7f8ecda340533da python-openid-1.0.4.zip Share and Enjoy, - Kevin JanRain, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic gui format?
Gregory Petrosyan a écrit : (snip) > Your dicts example is nice, but this approach (and some others) lacks > one important feature: ordering of GUI elements. In XML, the order of > all elements is specified, and with dicts (or with very clean Georg's > model) it is not. (BTW remember topics about ordered dicts...) (rereading this thread...) Err... Wait a minute. Are you actually *sure* that there's a problem with ordering here ? I mean (please stop me if I missed the point): a Window is an object, right ? It has attributes (which are named, and definitively *not* ordered - remember, object attributes are actually stored in a dict). Now *some* of these attributes may well be collections of other objects (ie: widgets...). And these collections *can* be ordered. window = { '__class__' : 'Window', 'id' : 'dummy', 'title' : 'My Dummy Window', 'w' : 640, 'h' : 480 'widgets': [ {'__class__' : 'Widget', 'id : 'dummy1', 'handlers' : { 'on_click' : # damn..., }, }, {'__class__' : 'Widget', 'id : 'dummy2', 'handlers' : { 'on_clock' : # dring..., }, }, ], } Braindead Stupid Simple, Isn't it ? (DH was *somehow* right: this is not JSON, but this is exactly what JSON is to javascript). As you see, what needs to be ordered is ordered. Now what we'd need would be a way to represent callback (handlers) functions. The simplest would probably be to forbid anonymous functions for callbacks, so we could just store the fully.qualified.name.to.callback as string... My 2 cents -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and ASP
It looks like you have a space before the first Response.Write. This works fine for me if that line is left-justified. hth Roger "Tempo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I recently uploaded a sample ASP-Python page to my web server and it > didn't show up correctly. Before I explain what it did, I should > mention that I got the same result when I tried to view the page from > my desktop (winxp user). So when I tried to view the sample ASP with > Python page from my desktop and web server, all that showed up was the > source code. I'm not sure exactly what this means since I know that > python 2.4 is installed on my computer and the ASP page still didn't > show up correctly. Here's the sample ASP-Python code, courtesy of > http://www.4guysfromrolla.com/webtech/082201-1.shtml : > > > > > ASP-Python Test Page > > > <%@ Language=Python %> > <% > Response.Write("Python lives in the ASP delimeters!") > %> > > > > document.write("Python's throwing a party on the client-side!") > > > > > Response.Write("Python gets ready to rumble inside a server-side > scripting block!") > > > > > > > > Any ideas about what I am doing wrong? Thanks. > == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding an Application in a Web browser
Using the Pywin32 extensions ( http://sourceforge.net/projects/pywin32/ ) , you can register Python as an Active Scripting language. Then it can be used anywhere javascript or vbscript are used, in IE, ASP, etc. It should only be used in IE for trusted applications, however. Roger "rodmc" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Thanks for all the comments. > > I will elaborate slightly to give everyone an idea of what is going on. > Basically I need to create a dynamic visualisation which sits in the > active desktop, basically behind the desktop icons and in front of the > windows wallpaper. Windows lets you define a web page which can be > displayed in this way. The application itself can sit on the local > users computer, rather than actually being downloaded via the web. It > will be retrieving data from a variety of sources. If there is another > way to do it then that would be good, for example writing another > active desktop application which people can use. > > The user has to be able to resize, move or get rid of the visualisation > if they wish to do so. > > Best, > > rod > == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and ASP
Did you save it with ".asp" extension? Is the directory enabled to run scripts? Can you run any other server-side script snippet (say VBscript)? -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic gui format?
bruno at modulix schrieb: > And finally, you could write your own ordered mapping type - but then > you loose the builtin syntax... I still don't understand why so many objected there are no "use cases" for ordered dicts when I tried to discuss these in a recent thread... Actually I see them everywhere. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list
Python and ASP
I recently uploaded a sample ASP-Python page to my web server and it didn't show up correctly. Before I explain what it did, I should mention that I got the same result when I tried to view the page from my desktop (winxp user). So when I tried to view the sample ASP with Python page from my desktop and web server, all that showed up was the source code. I'm not sure exactly what this means since I know that python 2.4 is installed on my computer and the ASP page still didn't show up correctly. Here's the sample ASP-Python code, courtesy of http://www.4guysfromrolla.com/webtech/082201-1.shtml : ASP-Python Test Page <%@ Language=Python %> <% Response.Write("Python lives in the ASP delimeters!") %> document.write("Python's throwing a party on the client-side!") Response.Write("Python gets ready to rumble inside a server-side scripting block!") Any ideas about what I am doing wrong? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic gui format?
ever considered doing the mapping this way? window = [ ["item", {'k1': 'v1', 'k2': 'v2'], ["otheritem", {'k1n': 'v1n', 'k2n': 'v2n'}] ] it is as simple as it gets: for 1:1 mapping from XML, list of Attributes becomes py List. the list of Properties of an attribute becomes a py Dictionary ps. you can do tuples instead of lists if immutable is ok. -- http://mail.python.org/mailman/listinfo/python-list
Copying zlib compression objects
I'm writing a program in python that creates tar files of a certain maximum size (to fit onto CD/DVD). One of the problems I'm running into is that when using compression, it's pretty much impossible to determine if a file, once added to an archive, will cause the archive size to exceed the maximum size. I believe that to do this properly, you need to copy the state of tar file (basically the current file offset as well as the state of the compression object), then add the file. If the new size of the archive exceeds the maximum, you need to restore the original state. The critical part is being able to copy the compression object. Without compression it is trivial to determine if a given file will "fit" inside the archive. When using compression, the compression ratio of a file depends partially on all the data that has been compressed prior to it. The current implementation in the standard library does not allow you to copy these compression objects in a useful way, so I've made some minor modifications (patch follows) to the standard 2.4.2 library: - Add copy() method to zlib compression object. This returns a new compression object with the same internal state. I named it copy() to keep it consistent with things like sha.copy(). - Add snapshot() / restore() methods to GzipFile and TarFile. These work only in write mode. snapshot() returns a state object. Passing in this state object to restore() will restore the state of the GzipFile / TarFile to the state represented by the object. Future work: - Decompression objects could use a copy() method too - Add support for copying bzip2 compression objects Does this seem like a good approach? Cheers, Chris diff -ur Python-2.4.2.orig/Lib/gzip.py Python-2.4.2/Lib/gzip.py --- Python-2.4.2.orig/Lib/gzip.py 2005-06-09 10:22:07.0 -0400 +++ Python-2.4.2/Lib/gzip.py2006-02-14 13:12:29.0 -0500 @@ -433,6 +433,17 @@ else: raise StopIteration +def snapshot(self): +if self.mode == READ: +raise IOError("Can't create a snapshot in READ mode") +return (self.size, self.crc, self.fileobj.tell(), self.offset, self.compress.copy()) + +def restore(self, s): +if self.mode == READ: +raise IOError("Can't restore a snapshot in READ mode") +self.size, self.crc, offset, self.offset, self.compress = s +self.fileobj.seek(offset) +self.fileobj.truncate() def _test(): # Act like gzip; with -d, act like gunzip. diff -ur Python-2.4.2.orig/Lib/tarfile.py Python-2.4.2/Lib/tarfile.py --- Python-2.4.2.orig/Lib/tarfile.py2005-08-27 06:08:21.0 -0400 +++ Python-2.4.2/Lib/tarfile.py 2006-02-14 16:50:41.0 -0500 @@ -1825,6 +1825,28 @@ """ if level <= self.debug: print >> sys.stderr, msg + +def snapshot(self): +"""Save the current state of the tarfile +""" +self._check("_aw") +if hasattr(self.fileobj, "snapshot"): +return self.fileobj.snapshot(), self.offset, self.members[:] +else: +return self.fileobj.tell(), self.offset, self.members[:] + +def restore(self, s): +"""Restore the state of the tarfile from a previous snapshot +""" +self._check("_aw") +if hasattr(self.fileobj, "restore"): +snapshot, self.offset, self.members = s +self.fileobj.restore(snapshot) +else: +offset, self.offset, self.members = s +self.fileobj.seek(offset) +self.fileobj.truncate() + # class TarFile class TarIter: diff -ur Python-2.4.2.orig/Modules/zlibmodule.c Python-2.4.2/Modules/zlibmodule.c --- Python-2.4.2.orig/Modules/zlibmodule.c 2004-12-28 15:12:31.0 -0500 +++ Python-2.4.2/Modules/zlibmodule.c 2006-02-14 14:05:35.0 -0500 @@ -653,6 +653,36 @@ return RetVal; } +PyDoc_STRVAR(comp_copy__doc__, +"copy() -- Return a copy of the compression object."); + +static PyObject * +PyZlib_copy(compobject *self, PyObject *args) +{ +compobject *retval; + +retval = newcompobject(&Comptype); + +/* Copy the zstream state */ +/* TODO: Are the ENTER / LEAVE needed? */ +ENTER_ZLIB +deflateCopy(&retval->zst, &self->zst); +LEAVE_ZLIB + +/* Make references to the original unused_data and unconsumed_tail + * They're not used by compression objects so we don't have to do + * anything special here */ +retval->unused_data = self->unused_data; +retval->unconsumed_tail = self->unconsumed_tail; +Py_INCREF(retval->unused_data); +Py_INCREF(retval->unconsumed_tail); + +/* Mark it as being initialized */ +retval->is_initialised = 1; + +return (PyObject*)retval; +} + PyDoc_STRVAR(decomp_flush__doc__, "flush() -- Return a string containing any remaining decompressed data.\n" "\n" @@ -723,6 +753,8 @@ comp_compress__doc__}, {"flush", (binaryfunc)PyZlib_flush, METH_VARARGS,
Re: How can I find a freelance programmer?
On 2/14/06, Charles <[EMAIL PROTECTED]> wrote: > I am looking for a freelance Python programmer to create a cross-platform > application with wxPython. > Any idea where I could find one? You should check out the Dabo project, which is a very impressive framework that uses wxPython for its UI. The authors are both independent programmers, and they sure know their stuff. -- # p.d. -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing the screen
It clears the screen by scrolling all the characters out of sight at the top of the terminal window. So the screen is blank, but not cleared in the sense that I mean it. The behavior I want is for the display to be effectively "erased" and ready to receive the next wave of data -- like you would do in a UI -- which is what I'm used to working with, which is why this is mildly frustrating, and at least 1/3 of why I sound like an idiot with this question. Anyway, I don't want it to scroll, just, in essense "refresh". As a total Python noob, my approach has been os.system("clear") ,then print "something". -- http://mail.python.org/mailman/listinfo/python-list
Mac OS X - Deployment
Hi Everybody, I just spent about an hour googling and still can't find out how to deploy a Python app to Mac OS X. I just finished a simple Hello-World GUI app using wxPython and deployed it to a WinXP system using PyInstaller. So I am familiar with the basic tools. It would be great if I could build an OS X executable from my XP system. Is that possible? If so, is it documented anywhere? If I can't do it on XP, I suppose I would have to install Python and wxPython on a Mac, then copy over my HelloWorld.py file, but what then? I know how to make DMG files, but what woudl go into the DMG? I am used to REALbasic where you write your code and then push the "Build" button and executables for Linux, Windows, and Mac are created in less than a minute. Maybe the Python world will be as advanced one day... Thanks, Matt -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you pronounce 'tuple'?
Paddy wrote: > Hmm, > I've found a term for a large tuple, a muckle: > > > http://www.google.co.uk/search?hl=en&q=define%3Amuckle&btnG=Search&meta= > > Definitions of muckle on the Web: > > * batch: (often followed by `of') a large number or amount or > extent; "a batch of letters"; "a deal of trouble"; "a lot of money"; > "he made a mint on the stock market"; "it must have cost plenty" > wordnet.princeton.edu/perl/webwn > As in that well-known Scottish saying "Mony a mickle make a muckle" meaning many small things add up to something great. Due, I believe, the the great Rabbie Burns. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I find a freelance programmer?
Tim Parkin wrote: > Charles wrote: > > >>Hello, >> >>I am looking for a freelance Python programmer to create a cross-platform >>application with wxPython. >>Any idea where I could find one? >>Thanks, >> >> >> > > You could ask Steve Holden? - that'll be 10% commission Steve! ;-) > Hi, Charles How can I help you? I'm fairly experienced with Python, and I'm giving a wxPython tutorial at PyCon in a week's time, so I know the technologies you need. What's the requirement? [Thanks, Tim: can I pay you in beer? :-)] regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I find a freelance programmer?
That's not Steve Holden. Steve Holden is a folk hero around here, in fact when the Boogeyman goes to sleep every night, he checks his closet for Steve Holden. ... sorry, just want an excuse to use a Chuck Norris fact ;-) http://www.chucknorrisfacts.com/ -Greg On 2/14/06, Charles <[EMAIL PROTECTED]> wrote: > On Tue, 14 Feb 2006 17:46:46 -0300, Tim Parkin <[EMAIL PROTECTED]> wrote: > > > You could ask Steve Holden? - that'll be 10% commission Steve! ;-) > > Him: http://sholden.typepad.com/ ? > > > -- > Charles. > > Desenvolvimento e criação de sites: www.auriance.com > Hospedagem de sites e servidores dedicados: www.auriance.net > -- > http://mail.python.org/mailman/listinfo/python-list > -- Gregory Piñero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com) -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic gui format?
How about this: def mogrify(): print "Mogrifying" gui = window(title = "Hello World!") [ image(text = "nice pics here", pos = (5, 5), src = "img.png"), text(opts = "italic") ["(some text here)"], lst() [ "first element", "second element" ], button(action = mogrify, text = "Click Me!") ] There may be some slight errors above, but the principle works for me. The gui is described with valid Python code, and object order, types, parameter checking etc works in the way you would expect in Python. If you try not to think about how it abuses Pythons items, I find it quite nifty. I have a toy project where I build a gui like this, with two major differences from your wishlist: (1) My code does not contain the actual widget objects, but instead builds a tree that gets traversed to build the gui objects. (2) The only parser I have right now builds html documents with callback dispatching (using Turbogears). I envision generation of gui code for locally executed GUI:s (e g wxPython) as well. However, I see no immediate reason that you should not be able to put the actual widget objects in the tree like illustrated above. I did not in any way invent this method of description. If you are interested, a more mature use can be found in Nevow (http://divmod.org/trac/wiki/DivmodNevow) where they have a document object model called Stan, using a similar method to generate xhtml documents. I'd be happy to hear about other uses. I'll leave it to others to have opinions about whether it is to be considered pythonic. - Patrik -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I find a freelance programmer?
On Tue, 14 Feb 2006 17:46:46 -0300, Tim Parkin <[EMAIL PROTECTED]> wrote: > You could ask Steve Holden? - that'll be 10% commission Steve! ;-) Him: http://sholden.typepad.com/ ? -- Charles. Desenvolvimento e criação de sites: www.auriance.com Hospedagem de sites e servidores dedicados: www.auriance.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding an Application in a Web browser
bruno at modulix wrote: > rodmc wrote: > >>Is it possible to embed a Python application within Internet explorer? > > No. Nor in any other browser (except from Grail, but I think this > doesn't count). I remember there was a project for running CGI-BIN-like programs directly in Mozilla without a web server. But I can't find it anymore. Ciao, Michael. -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I find a freelance programmer?
Charles wrote: >Hello, > >I am looking for a freelance Python programmer to create a cross-platform >application with wxPython. >Any idea where I could find one? >Thanks, > > > You could ask Steve Holden? - that'll be 10% commission Steve! ;-) Tim Parkin -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding an Application in a Web browser
try this: create file named "test.hta" and put inside - import sys document.writeln("Hello from Python", sys.version) - double click to open it, it will work if you have activestate extensions installed. -- http://mail.python.org/mailman/listinfo/python-list
Re: installing python on a server?
John Salerno wrote: > Can anyone tell me how complicated it might be to install Python on my > server so I can use it for web apps? Is it a one-time process, or > something to maintain? > > Thanks. As it turns out, my hosting company supports Python on their servers! I know I didn't see it there before, so either it was hidden or they somehow turned it on for me after I asked about it. Either way, this saves me a ton of trouble. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Rethinking the Python tutorial
Here's my two cents - I started with the official tutorial. It seemed up to date to me. Things that changed from 2.4 to 2.5 changed in the tutorial as well. I still refer to it every few days, because it had been a useful reference for the basic data types. I like that it seemlessly links into the other documents, both online and in the local MS Help format. It took a couple of days to get through, and gave me enough of an introduction to the library that I could get started on the Python Challenge. I don't think it's broken enough to throw away completely. Bug reports filed at sf.net appear to be responded to quickly. I haven't tried "A Byte of Python", so I can't comment. I tried to learn from "Dive into Python", but I found that it went too quickly. I have a lot of C and C++ experience, but I needed the more basic stuff, like dictionaries, tuples, etc. explained in more detail. It was a very useful guide once I had the basics, but after my initial experience with it I put Python away for a few months. "Dive into Python" is not being kept up to date. The last revision was May 2004, and several things have changed since then. For instance, chapter 4, on introspection, creates a program called apihelper.py, which uses introspection and doc strings to print the usage of an object. This is all great stuff, which would be part of my toolkit, except that there is a built-in, help(), that does the same thing. I had to go to the downloaded source to find that out. In other cases, the tutorial still teaches to older versions of Python, sometimes with notes for the newer styles, sometimes without. Another downside is the use of internet sources for examples. For instance, his example for a web feed is http://diveintomark.org/xml/atom.xml, which replies with a "410 Gone". As you might guess, this was the author's server, and might have been removed because of all the people taking the tutorial. This would have to be fixed, to make chapters 11 and 12 make much sense. As for a wiki version of the tutorial, I think the MoinMoin docs are a good example. MoinMoin is a wiki engine running Python, and the documents are distributed with each engine. These documents can be seen on the project website, http://moinmoin.wikiwikiweb.de/HelpContents. There is a second wiki at http://moinmaster.wikiwikiweb.de/HelpContents , which contains the "master" documents. Those that want to help improve, correct, or translate documents do their work on this wiki. It lowers the number of pages that maintainers have to review, so that a consistant quality can be maintained. It also is a (slight) barrier to entry, so that casual users don't make random changes. I think the most important thing for a tutorial is a consistant style and a consistant idea of the user's capabilities. This is easiest with a single maintainer, but requires constant dilligence and a subdued ego for a collaborative document. -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I find a freelance programmer?
Try this site I use them. You will make many freelancer contacts...some good some bad...don't pay without escrow but good jobs get done. Hope you will find it worthwhile. Best regards & good luck. Sanjay. On 2/15/06, Jorge Godoy <[EMAIL PROTECTED]> wrote: Charles <[EMAIL PROTECTED]> writes:> I am looking for a freelance Python programmer to create a cross-platform> application with wxPython.> Any idea where I could find one? Here? At Python-jobs? :-) At the wxPython mailing list?--Jorge Godoy <[EMAIL PROTECTED]>"Quidquid latine dictum sit, altum sonatur." - Qualquer coisa dita em latim soa profundo.- Anything said in Latin sounds smart.--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: using an existing DLL file without having access to the source code?
On Tue, 2006-02-14 at 13:50, Dieter Vanderelst wrote: > Dear all, > > Could anybody tell me whether there are ways to use an existing DLL file > in Python without having access to the source code? That sounds like a job for ctypes: http://starship.python.net/crew/theller/ctypes/ HTH, Carsten. -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: accountability & lying thru the teeth
Xah Lee wrote: > here's a site: http://www.longbets.org/bets that takes socially > important predictions. I might have to enter one or two. > I predict Xah Lee will remain as clueless as he currently is. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list
windows security descriptors
Hope this isn't too inappropriate: Thanks to tips from comp.lang.python and the Python win32 mailing list, I've been able to begin using Python to work with Windows security descriptors with some small success. http://opensource.w2k.vt.edu/brad_scripts.php I've just started, not a whole lot there yet, but it's all pure Python. It's been my experience that this stuff isn't well documented on the Web (hence my post here to share what I've learned so far). So, anyone interested in this topic may download the scripts. Feedback from Windows security descriptor gurus would be great! Thanks, Brad -- http://mail.python.org/mailman/listinfo/python-list
Re: using an existing DLL file without having access to the source code?
Dieter Vanderelst wrote: > Could anybody tell me whether there are ways to use an existing DLL file > in Python without having access to the source code? Try ctypes. http://starship.python.net/crew/theller/ctypes/ > I'm trying to find a way to use the image filters available in the > Filters-project (http://filters.sourceforge.net/) without having to > compile or build the DLL myself, which is according to the authors very > hard. I don't have any experience with this specific library but I've used ctypes in the past and it worked great. HTH. ... jay graves -- http://mail.python.org/mailman/listinfo/python-list
using an existing DLL file without having access to the source code?
Dear all, Could anybody tell me whether there are ways to use an existing DLL file in Python without having access to the source code? I'm trying to find a way to use the image filters available in the Filters-project (http://filters.sourceforge.net/) without having to compile or build the DLL myself, which is according to the authors very hard. I have quite some experience with Python itself, but I'm not really familiar with extending/embedding Python, please bare that in mind when responding :). With kind regards, Dieter -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding an Application in a Web browser
Thanks for all the comments. I will elaborate slightly to give everyone an idea of what is going on. Basically I need to create a dynamic visualisation which sits in the active desktop, basically behind the desktop icons and in front of the windows wallpaper. Windows lets you define a web page which can be displayed in this way. The application itself can sit on the local users computer, rather than actually being downloaded via the web. It will be retrieving data from a variety of sources. If there is another way to do it then that would be good, for example writing another active desktop application which people can use. The user has to be able to resize, move or get rid of the visualisation if they wish to do so. Best, rod -- http://mail.python.org/mailman/listinfo/python-list
Re: Location of Python modules
Byte wrote: > >if it is in the sys.path > > sys.path, what is this? a variable in the sys module. quoting from a reply that you might have missed: $ python -c "import sys; print sys.path" ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages', ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advocacy in scientific computation
In article <[EMAIL PROTECTED]>, Michael Tobis <[EMAIL PROTECTED]> wrote: . . . >Among the Python components and Python bindings of special interest to >scientists are the elegant and powerful matplotlib plotting package, >which began by emulating and now surpasses the plotting features of >Matlab, SWIG, which allows for runtime interoperability with various >languages, f2py which specifically interoperates with Fortran, NetCDF >libraries (which cope with NetCDF files with dramatically less fuss >than the standard C or Fortran bindings), statistics packages including >bindings to the R language, linear algebra packages, various >platform-specific and portable GUI libraries, genetic algorithms, >optimization libraries, and bindings for high performance differential >equation solvers (notably, using the Argonne National Laboratory >package PetSC). An especially interesting Python trick for runtime >visualization in models that were not designed to support it, pioneered >by David Beazley's SWILL, embeds a web server in your model code. > >See especially http://starship.python.net/~hinsen/ScientificPython/ and >http://scipy.org as good starting points to learn about scientific uses >of Python. > >mt > Lovely; putting a copy here is a great service to others. I want a few subtle changes. I applaud the slogan about how Python encompasses the best of Matlab and Java (among others); I like to think that'll get through. In that vicinity would be a good place, if practical, to work in mention that: A. Python is *excellent* for long-lasting and/or group work; B. Python's licensing is friendly; C. It's a real language, and therefore generalizes far better than Matlab; and D. Has an unrivaled span of practicality, so that learning it enables a researcher to tackle a wide variety of software taskes. You touch on these matters, but I think that section might be pro- pitious for promoting them, perhaps along with E. Python's ease-of-learning and successful record in the hands of children, scientists, and other casual practitioners. Also, my instinct is to underline that this stuff is REAL. David Beazley was winning awards with his scientific Python-Fortran marriage back in the '90s. Perhaps your audience doesn't need so much convincing on that point ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Python / Apache / MySQL
Sybren Stuvel wrote: > Dennis Lee Bieber enlightened us with: > > I believe that since 4.1, the "default table format" is InnoDB, and > > that DOES have some support foreign keys and transactions. > > Finally they are starting to make more sense. I'd still rather use a > database that has had those features for a longer time, though. My experience with MySQL on the abomination that is Fedora Core (so I imagine it was 4.x as opposed to 5.x), was that the default table type appeared to be the ridiculously incapable MyISAM, and that by choosing InnoDB you got transactions along with a bunch of limitations and a serving of odd behaviour, where "odd" means "would raise a laugh amongst users of other database systems". I think you only really need to compare the manuals for MySQL [1] and PostgreSQL [2] to see that PostgreSQL offers straightforward but seemingly well-tested functionality for populating databases and then having them just work properly, whereas MySQL offloads an array of "features" and a mangled SQL syntax onto the developer/administrator in a way that would suggest, if one were to be uncharitable in this matter, that the developers of MySQL aren't confident that everything works and would rather "empower" users to make their own choices and then to apologise for themselves when something they thought might work (and probably would on some other system) actually doesn't. Anyway, various comparisons have been made, and here are a few good/recent ones: http://www.wlug.org.nz/PostgresVsMysql http://sql-info.de/mysql/gotchas.html http://sql-info.de/postgresql/postgres-gotchas.html And here's one with a Pythonic slant: http://bob.pythonmac.org/archives/2005/08/12/mysql-hate/ Paul [1] http://dev.mysql.com/doc/refman/5.0/en/ [2] http://www.postgresql.org/docs/7.4/static/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I find a freelance programmer?
Charles <[EMAIL PROTECTED]> writes: > I am looking for a freelance Python programmer to create a cross-platform > application with wxPython. > Any idea where I could find one? Here? At Python-jobs? :-) At the wxPython mailing list? -- Jorge Godoy <[EMAIL PROTECTED]> "Quidquid latine dictum sit, altum sonatur." - Qualquer coisa dita em latim soa profundo. - Anything said in Latin sounds smart. -- http://mail.python.org/mailman/listinfo/python-list
How can I find a freelance programmer?
Hello, I am looking for a freelance Python programmer to create a cross-platform application with wxPython. Any idea where I could find one? Thanks, -- Charles. landemaine[at]gmail[dot]com -- http://mail.python.org/mailman/listinfo/python-list
Re: Location of Python modules
>if it is in the sys.path sys.path, what is this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advocacy in scientific computation
Nicely done. But now for a couple of small nits: > other language is that they are suddenly dramatically several times > more productive 'suddenly dramatically several times' seems a bit redundantly repeditively excessive, don't you think? > Among the Python components and Python bindings of special interest to > scientists are the elegant and powerful matplotlib plotting package, > which began by emulating and now surpasses the plotting features of > Matlab, SWIG, which allows for runtime interoperability with various > languages, f2py which specifically interoperates with Fortran, NetCDF > libraries (which cope with NetCDF files with dramatically less fuss > than the standard C or Fortran bindings), statistics packages including > bindings to the R language, linear algebra packages, various > platform-specific and portable GUI libraries, genetic algorithms, > optimization libraries, and bindings for high performance differential > equation solvers (notably, using the Argonne National Laboratory > package PetSC). As the length of the sentence built up, and the inumerable commas passed by, my brain exploded. I'd suggest turning this into a bullet list. -- http://mail.python.org/mailman/listinfo/python-list
Re: processing limitation in Python
On Tue, 14 Feb 2006 08:42:38 -0800, [EMAIL PROTECTED] wrote: > If I un-comment any line in this program below the line where I > commented " all OK up to this point " This program locks up my > computer. It locks up the operating system as well? Shame on Windows. What happens if you type ctrl-C to interrupt the processing? > I'm just wondering if any one else has noticed any problems with > working with large numbers in Python ind if there is anything that can > work around this issue. Yes, you need a better algorithm. You can prove to yourself that it isn't a problem with Python handling big numbers by running this simple test: factor(10) and watch how quickly it completes -- a fraction of a second. The problem is that your test data have few factors, and so your function spends a LONG time increasing d by one each iteration. Worst case, if your number is a prime, it has to try to divide against *every* number, 2, 3, 4, ... all the way up to the prime itself. This takes a LONG time if the number is very large. Some improvements you might like to try: You have to check for factors of two. But after you have done that, you are just wasting time to check for factors of 4, 6, 8, ... because they can't possibly be factors. Pull the factor of two test out of the loop, then start the test with d = 3 and increase by two instead of one. You can stop looking for factors once you have reached the square root of the original number. The square root is the biggest possible factor. There are other improvements you can make, but they make the code more complicated. Just these few things will give you a HUGE performance boost: def factor(n): factors = [] while n % 2 == 0: factors.append(2) n = n/2 d = 3 mx = int(n**0.5) while (n > 1) and (d <= mx): if n % d: d = d+2 else: factors.append(d) n = n/d if n != 1: factors.append(n) return factors Using this new improved version, I get this calculation in about two seconds: >>> factor(12345678987654) [2, 3, 2057613164609L] and this in less than a second: >>> factor(12345678987654321) [3, 3, 3, 3, 37, 37, 333667, 333667] -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3000 deat !? Is true division ever coming ?
I knew about that approach. I just wanted less typing :-( On 2/14/06, Rocco Moretti <[EMAIL PROTECTED]> wrote: > Gregory Piñero wrote: > > On 14 Feb 2006 06:44:02 -0800, [EMAIL PROTECTED] > > > > > >>5./2.=2.5 is floating point math, with all the round off errors that > >>incorporates. > > > > Thanks Curtis, I never knew that trick. I guess for variables do have > > true division you have to make them floats? e.g. > > float(var1)/float(var2)? Or do you know a less typing approach for > > that? > > Google "python true division" -> I'm feeling lucky: > > http://www.python.org/doc/2.2.3/whatsnew/node7.html > > From the web page: > > """ > * By including a from __future__ import division in a module(*), the / > operator will be changed to return the result of true division, so 1/2 > is 0.5. Without the __future__ statement, / still means classic > division. The default meaning of / will not change until Python 3.0. > """ > > *As the first non-docstring/non-comment line. > > Note that that's for a module -- the interactive interpreter won't > respond the same way to the "from __future__ import" statement. > -- > http://mail.python.org/mailman/listinfo/python-list > -- Gregory Piñero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com) -- http://mail.python.org/mailman/listinfo/python-list
Re: processing limitation in Python
On 14 Feb 2006 08:42:38 -0800 in comp.lang.python, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >If I un-comment any line in this program below the line where I >commented " all OK up to this point " This program locks up my >computer. Hmm. Ctrl-C gets me out just fine. In Idle, at least. > >Windows task manager will show "Not Responding" for Python in the >Applications tab and in the Performance tabe the CPU usage will be >locked at %100. Well sure. It's pretty busy code. > >I've experienced the same problem on 2 different computers, one running >2000 pro. the other running XP home eddition. both computers run >Python 2.4.2 > >I'm just wondering if any one else has noticed any problems with >working with large numbers in Python ind if there is anything that can >work around this issue. Try running with the changes I've made below, and see if that tells you anything. def factor(n): d = 2 pctr = 0 factors = [ ] while n > 1: if n % d == 0: factors.append(d) n = n/d else: d = d + 1 pctr += 1 if pctr >= 100: print "So Far: " + str(factors) pctr = 0 print factors factor (12) factor (123) factor (1234) factor (12345) factor (123456) factor (1234567) factor (12345678) factor (123456789) factor (1234567898) factor (12345678987) factor (123456789876) factor (1234567898765) # all OK up to this point factor (12345678987654)# locks up computer if I run this line #factor (123456789876543) #factor (1234567898765432) #factor (12345678987654321) Hint: 2057613164609L is a Really Big Number (tm). If it's prime (I don't know if it is or not), it will take more than 46 days on my computer to figure that out. Did you wait that long? Regards, -=Dave -- Change is inevitable, progress is not. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python / Apache / MySQL
Dennis Lee Bieber enlightened us with: > I believe that since 4.1, the "default table format" is InnoDB, and > that DOES have some support foreign keys and transactions. Finally they are starting to make more sense. I'd still rather use a database that has had those features for a longer time, though. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: processing limitation in Python
Using CPython or GMPY with a smarter algorithm in acceptable time you can find that: 12345678987654 == 2 * 3 * 2057613164609 It's a very big number to factorize with that naive algorithm, so the program hangs... (I have used an online factoring service). Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3000 deat !? Is true division ever coming ?
Gregory Piñero wrote: > On 14 Feb 2006 06:44:02 -0800, [EMAIL PROTECTED] > > >>5./2.=2.5 is floating point math, with all the round off errors that >>incorporates. > > Thanks Curtis, I never knew that trick. I guess for variables do have > true division you have to make them floats? e.g. > float(var1)/float(var2)? Or do you know a less typing approach for > that? Google "python true division" -> I'm feeling lucky: http://www.python.org/doc/2.2.3/whatsnew/node7.html From the web page: """ * By including a from __future__ import division in a module(*), the / operator will be changed to return the result of true division, so 1/2 is 0.5. Without the __future__ statement, / still means classic division. The default meaning of / will not change until Python 3.0. """ *As the first non-docstring/non-comment line. Note that that's for a module -- the interactive interpreter won't respond the same way to the "from __future__ import" statement. -- http://mail.python.org/mailman/listinfo/python-list
Re: processing limitation in Python
[EMAIL PROTECTED] > If I un-comment any line in this program below the line where I > commented " all OK up to this point " This program locks up my > computer. > > Windows task manager will show "Not Responding" for Python in the > Applications tab and in the Performance tabe the CPU usage will be > locked at %100. > > I've experienced the same problem on 2 different computers, one running > 2000 pro. the other running XP home eddition. both computers run > Python 2.4.2 > > I'm just wondering if any one else has noticed any problems with > working with large numbers in Python ind if there is anything that can > work around this issue. > > Thankd for reading > David > > def factor(n): > d = 2 > factors = [ ] > while n > 1: > if n % d == 0: > factors.append(d) > n = n/d > else: > d = d + 1 > print factors You primary problem is that this is a horridly inefficient way to factor, taking time propotional to n's largest prime divisor (which may be n). > factor (12) > factor (123) > factor (1234) > factor (12345) > factor (123456) > factor (1234567) > factor (12345678) > factor (123456789) > factor (1234567898) > factor (12345678987) > factor (123456789876) > factor (1234567898765) # all OK up to this point > #factor (12345678987654)# locks up computer if I run this line It doesn't lock up for me, using Python 2.3.5 or 2.4.2 on Windows (XP Pro SP2, but the specific flavor of Windows shouldn't matter). I ran it from a DOS box, and while it was plugging away on 12345678987654, hitting Ctrl+C stopped it. If you let it continue running, and you & your computer were immortal (something worth shooting for :-)), it would eventually print the factorization. Since 12345678987654 = 2 * 3 * 2057613164609 the loop would have to go around over 2 trillion times to find the final 2057613164609 prime factor. A simple enormous improvement is to get out of the loop when d*d > n. Then n must be prime or 1. That would slash the worst-care runtime from being proportional to n to being proportional to sqrt(n). > ... -- http://mail.python.org/mailman/listinfo/python-list
Python advocacy in scientific computation
Someone asked me to write a brief essay regarding the value-add proposition for Python in the Fortran community. Slightly modified to remove a few climatology-related specifics, here it is. I would welcome comments and corrections, and would be happy to contribute some version of this to the Python website if it is of interest. === The established use of Fortran in continuum models such as climate models has some benefits, including very high performance and flexibility in dealing with regular arrays, backward compatibility with the existing code base, and the familiarity with the language among the modeling community. Fortran 90 and later versions have taken many of the lessons of object oriented programming and adapted them so that logical separation of modules is supported, allowing for more effective development of large systems. However, there are many purposes to which Fortran is ill-suited which are increasingly part of the modeling environment. These include: source and version control and audit trails for runs, build system management, test specification, deployment testing (across multiple platforms), post-processing analysis, run-time and asynchronous visualization, distributed control and ensemble management. To achieve these goals, a combination of shell scripts, specialized build tools, specialized applications written in several object-oriented languages, and various web and network deployment strategies have been deployed in an ad hoc manner. Not only has much duplication of effort occurred, a great deal of struggling up the learning curves of various technologies has been required as one need or another has been addressed in various ad hoc ways. A new need arises as the ambitions of physical modeling increase; this is the rapid prototyping and testing of new model components. As the number of possible configurations of a model increases, the expense and difficulty of both unit testing and integration testing becomes more demanding. Fortunately, there is Python. Python is a very flexible language that has captured the enthusiasm of commercial and scientific programmers alike. The perception of Python programmers coming from almost any other language is that they are suddenly dramatically several times more productive than previously, in terms of functionality delivered per unit of programmer time. One slogan of the Python community is that the language "fits your brain". Why this might be the case is an interesting question. There are no startling computer science breakthroughs original to the language, Rather, Python afficionados will claim that the language combines the best features of such various languages as Lisp, Perl, Java, and Matlab. Eschewing allegiance to a specific theory of how to program, Python's design instead offers the best practices from many other software cultures. The synergies among these programming modes is in some ways harder to explain than to experience. The Python novice may nevertheless observe that a single language can take the place of shell scripts, makefiles, desktop computation environments, compiled languages to build GUIs, and scripting languages to build web interfaces. In addition, Python is useful as a wrapper for Fortran modules, facilitating the implementation of true test-driven design processes in Fortran models. Another Python advocacy slogan is "batteries included". The point here is that (in part because Python is dramatically easier to write than other languages) there is a very broad range of very powerful standard libraries that make many tasks which are difficult in other languages astonishingly easy in Python. For instance, drawing upon the standard libraries (no additional download required) a portable webserver (runnable on both Microsoft and Unix-based platforms) can be implemented in seven lines of code. (See http://effbot.org/librarybook/simplehttpserver.htm ) Installation of pure python packages is also very easy, and installation of mixed language products with a Python component is generally not significantly harder than a comparable product with no Python component. Among the Python components and Python bindings of special interest to scientists are the elegant and powerful matplotlib plotting package, which began by emulating and now surpasses the plotting features of Matlab, SWIG, which allows for runtime interoperability with various languages, f2py which specifically interoperates with Fortran, NetCDF libraries (which cope with NetCDF files with dramatically less fuss than the standard C or Fortran bindings), statistics packages including bindings to the R language, linear algebra packages, various platform-specific and portable GUI libraries, genetic algorithms, optimization libraries, and bindings for high performance differential equation solvers (notably, using the Argonne National Laboratory package PetSC). An especially interesting Python trick for runtime visualization in models that were not designed
RE: Win32_Process.Create -- not starting process
[abcd] | I am using Python to create a process on another computer. Both | computers are on the same domain with admin privileges. | | On computer B I have a batch script which starts a python | script. From computer A I am doing the following: | | import wmi | w = wmi.WMI("1.2.3.4") | p = w.new("Win32_Process") | pid, retVal = p.Create(CommandLine="C:\\a_script.bat") | print pid, retVal | | The output I get is, 1218 0 0 = "Successful Completion" | however the python script that is called from the batch script | never seems to run or at least only for a split second. Sometimes I | see python.exe appear in the task manager on computer B for a split | second then it goes away. So I went to computer B and double clicked | on the batch script, and sure enough a command opened up and | the python script was running...and stayed running...no problem. | I should mention, that sometimes it will execute the batch script and | the Python script will run and stay running. That has only happened | after trying to do "p.Create(CommandLine)" more than once, but not | every time I try. | | Any ideas why its not working for me remotelyor why its random? | These are win xp machines with no firewalls running. OK, let me say up front: there's nothing terribly obvious. Just in case you haven't, it's probably worth your running the latest wmi module -- 1.0rc6 at time of writing -- which makes slightly cleaner the interface to WMI classes. However, that's not the problem here, as the syntax you're using above works in 0.6b and in 1.0rc6 (I just tried both). I *think* that what you're seeing is that the script isn't running in the environment you're expecting, and is then swallowing the problem. Can you confirm whether or not the simplest possible Python script does indeed run and produce the expected result? You may well have to specify an explicit path for Python, give explicit paths for output files and so on. My test case, for example, which ran consistently, was: ## on the remote machine c:\python23\python c:\temp\wmi-test\test.py import os f = open ("c:\\temp\\wmi-test\\test.txt", "w") f.write ("%s\n" % os.getcwd ()) for k, v in os.environ.items (): f.write ("%s => %s\n" % (k, v)) f.close () ## on my machine import wmi c = wmi.WMI ("vogbp364") # obviously your remote machine name # # Slightly cleaner syntax new to wmi 1.0 # c.Win32_Process.Create (CommandLine=r"c:\temp\wmi-test\test.cmd") Obviously the extent to which you'll need to specify things will be affected by the system-level as opposed to user-level info on each machine. Hope that helps. Feel free to get back if it doesn't. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Pythonic gui format?
bruno at modulix schrieb: > Christoph Zwerschke wrote: >> Bruno Desthuilliers schrieb: >> >>> Gregory Petrosyan a écrit : >>> I am currently seeking for pythonic alternative for XML. >> Bruno, before writing another simple GUI, > > > Sorry, Christoph, wrong attribution !-) > I'm sorry, I still get easily confused by usenet multilevel quoting ;-) I meant Gregory and I meant "GUI library", not "GUI". -- Christoph -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you pronounce 'tuple'?
On Tue, Feb 14, 2006 at 10:40:09AM -0500, Tim Peters wrote: > > the-acid-test-is-whether-you-say-"xor"-with-one-syllable-or-three-ly y'rs - > tim "Zorr!" of course. Saying "All hail the mighty Exclusive Or!" would just sound silly. -jackdied -- http://mail.python.org/mailman/listinfo/python-list
processing limitation in Python
If I un-comment any line in this program below the line where I commented " all OK up to this point " This program locks up my computer. Windows task manager will show "Not Responding" for Python in the Applications tab and in the Performance tabe the CPU usage will be locked at %100. I've experienced the same problem on 2 different computers, one running 2000 pro. the other running XP home eddition. both computers run Python 2.4.2 I'm just wondering if any one else has noticed any problems with working with large numbers in Python ind if there is anything that can work around this issue. Thankd for reading David def factor(n): d = 2 factors = [ ] while n > 1: if n % d == 0: factors.append(d) n = n/d else: d = d + 1 print factors factor (12) factor (123) factor (1234) factor (12345) factor (123456) factor (1234567) factor (12345678) factor (123456789) factor (1234567898) factor (12345678987) factor (123456789876) factor (1234567898765) # all OK up to this point #factor (12345678987654)# locks up computer if I run this line #factor (123456789876543) #factor (1234567898765432) #factor (12345678987654321) -- http://mail.python.org/mailman/listinfo/python-list
Re: Cygwin IDLE has no menu bar
Thorsten Kampe wrote: > * Steve Holden (2006-02-14 04:14 +0100) > >>I just wondered whether anyone has seen this problem and fixed it. An >>IDLE with no menu bar isn't much use ... > > > It's not fixed but the workaround is "idle -n" So it is! Thanks. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list
Win32_Process.Create -- not starting process
I am using Python to create a process on another computer. Both computers are on the same domain with admin privileges. On computer B I have a batch script which starts a python script. From computer A I am doing the following: import wmi w = wmi.WMI("1.2.3.4") p = w.new("Win32_Process") pid, retVal = p.Create(CommandLine="C:\\a_script.bat") print pid, retVal The output I get is, 1218 0 0 = "Successful Completion" however the python script that is called from the batch script never seems to run or at least only for a split second. Sometimes I see python.exe appear in the task manager on computer B for a split second then it goes away. So I went to computer B and double clicked on the batch script, and sure enough a command opened up and the python script was running...and stayed running...no problem. I should mention, that sometimes it will execute the batch script and the Python script will run and stay running. That has only happened after trying to do "p.Create(CommandLine)" more than once, but not every time I try. Any ideas why its not working for me remotelyor why its random? These are win xp machines with no firewalls running. -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you pronounce 'tuple'?
::snip a thousand responses:: Well, I'm certainly glad I brought it up. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you pronounce 'tuple'?
Tim Peters wrote: > "tuhple" is a girly-man affectation. That's why Guido and I both say > the manly "toople". Heh heh. Actually, 'toople' sounds like a noun to me, and 'tuple' sounds like a verb, so I prefer 'toople' anyway. -- http://mail.python.org/mailman/listinfo/python-list