Re: How to use a timer in Python?
Nico Grubert enlightened us with: > How can I use a timer that waits e.g. 10 seconds if 'transfer.lock' > is present and then checks again if 'transfer.lock' is still there? Make a while loop in which you sleep. Or use the threading module if you want to go multi-threading. 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: Mantain IDE colors and paste them in an HTML page
Micah Elliott enlightened us with: > If you're just trying to get copy/paste-able-from-browser html that > has pretty colors, you might start up vim and use the default > colors. You might have to say ":syntax enable". Then just type > ":TOhtml" and you'll have a colorized version of your "IDE" display. Cool, I didn't know that option. Very nice! Thanks! 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: Build spoofed IP packets
billie enlightened us with: > For low level packet building I already used Impacket module but if > I specify a spoofed src address during IP packet creation, module > returns an error. Suggestions? Yes, give us the error. And know that you can't build raw IP packets unless you're root. 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: updating local()
Flavio enlightened us with: > Can anyone tell me why, if the following code works, I should not do > this? > > def fun(a=1,b=2,**args): > > print 'locals:',locals() > locals().update(args) > print locals() Because it's very, very, very insecure. What would happen if someone found a way to call that function? It could replace any name in the locals dictionary, including functions from __builtins__. In other words: probably the whole program could be taken over by other code by just one call to that function. 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: Posix return or exit
M.N.A.Smadi enlightened us with: > my script must return codes which are based on the POSIX spec of > returning a positive value. A work perl version of my code uses > exit(code_num). Use sys.exit(code_num). 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: updating local()
Jp Calderone enlightened us with: > If I can call functions in your process space, I've already taken > over your whole program. That's true for standalone programs, but not for things like web applications, RPC calls etc. 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: Batteries Included?
Alex enlightened us with: > Python's moto is "Batteries Included", but where are the batteries > for making exe files and making an installer file? Those aren't "batteries". Those are things you can do with the program, but are outside the programming language. Writing and distributing software is one thing. Converting them to a platform-specific executable is another. > I had to download, install and use py2exe and Inno Setup in order to > accomplish this. Well done. > I might be wrong expecting that a language whose moto is "Batteries > Included" would be able to produce exe files. Indeed, you're wrong. Why would such an ability be included in Python? It's a cross platform language. What need would Mac, Linux, BSD, Solaris etc. users have for such a feature? And why would it have to be included, when there is an easy solution just around the corner? You prooved that it was easy enough to install and use by someone who just learned Python. I really don't see the problem here. > Are there plans to do this in the future version of Python? I doubt it. 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: Let My Terminal Go
[EMAIL PROTECTED] enlightened us with: > When gVim is launched from a shell terminal, it completely frees the > terminal. [...] How do I implement this in my application written in > python? Using fork() and by catching the HUP signal. 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: Looking for info on Python's memory allocation
Steven D'Aprano enlightened us with: > he says that every time you try to append to a list that is already > full, Python doubles the size of the list. This wastes no more than > 50% of the memory needed for that list, but has various advantages > -- and I'm damned if I can remember exactly what those advantages > were. Allocating extra memory usually requires the following steps: - Allocate more memory - Copy all data from old to new memory - Deallocate old memory That second step requires N actions if there are N data items in the list. If you add one 'block' of memory to the list for each item you add, you waste no memory, but every item added requires N steps to copy all the old items. That means that after you've added N items, N**2 steps have been taken. That's very bad for performance. If, on the other hand, you double the memory every time you run out, you have to copy much less data, and in the end it turns out you need roughly N steps to add N items to the list. That's a lot better, isn't it? 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: TurboGears /.-ed, >new == True< or >new == "True"
Andy Leszczynski enlightened us with: > should not it be: > > 2 def save(self, pagename, data, submit, new): > 3 hub.begin() > 4 if new == True: > 5 page = Page(pagename=pagename, data=data) > 6 else: > 7 page = Page.byPagename(pagename) > 8 page.data = data > > instead of: > > 4 if new == "True": No it should not. The values passed to the function are the strings passed by the GET request, hence all strings. There are methods of dealing with this - read the rest of the documentation. 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: Set an environment variable
Mike Meyer enlightened us with: > It's simpler to use eval and command substitution: > > eval $(python myScript.py) This looks like the best solution to me. 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: p2exe using wine/cxoffice
Jon Perez enlightened us with: > Actually, I think it's many unix/linux users who are ignorant of > just how nice, stable and productive Windows can be as a desktop > environment. I thought the same thing after spending two hours removing some adware I found. > Ever since Win2K got rid of the constant blue screens, the reasons > for switching over to Linux have grown less and less urgent. One thing in Linux (Gnome actually) that I miss in Windows, is that in the latter you need to grab the title bar of a window to move it, and the edge to resize it. In Gnome, I can press the ALT key and drag the window with the left mouse button and resize it by dragging with the right mouse button. When moving, it doesn't matter where your cursor is, as long as it's inside the window. For resizing, it grabs the closest corner and moves that. It's like having a scrollwheel on your mouse. If you've never used such a thing you don't miss it, but if you're used to it, it's a major annoyance when it's gone. > The 'Nix desktop environments are growing visibly more mature with > each passing year, but device support in Linux is still decidedly > inferior and it still takes far too much time to do some things you > take for granted under Windoze. When I replaced my CPU, motherboard and RAM, I had to reinstall Windows and all applications. Linux just booted. When I upgrade my video card, Linux just accepts it without even a single message. On Windows I have to do a reinstall of the video drivers. I think that everybody is influenced by their own experience. Here are a few of my reasons to run Linux, besides the ones already mentioned: - Window management in Linux is separate from the application. That means that a non-responsive (crashed or just very busy) application can still be minimized or moved. - If I log in and my desktop is shown, I can start working immediately. No need to wait for all sorts of things in the system tray to start up first. - Software installation on Linux usually works via the distribution's package manager, so it's one application for almost every software install. It also automatically downloads and installs all required libraries etc. - No need to defragment my harddisk. - No viruses/spyware. There are only two downsides I notice: - There are some games I want to play which aren't available on Linux. That's the only reason I run Windows, btw. - I have to be a little more picky about the hardware I buy. 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: p2exe using wine/cxoffice
Tim Golden enlightened us with: > Well, I'm with you. I'm sure a lot of people will chime in to point > out just how flexible and useful and productive Linux is as a > workstation, but every time I try to use it -- and I make an honest > effort -- I end up back in Windows I'm curious, what do you mean with "it" in the part "every time I try to use it"? There are different distributions of Linux, and putting them all on one big pile is like saying "I've tried Windows, and I really don't like it's user interface" and referring to the interface of Windows 3.1. Many people use Fedora (from RedHat) and don't like it. I agree with them - I don't like it either. For those people: give Ubuntu Linux a go. It's my favourite - and my girlfriend's too btw. 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: assignment to reference
Loris Caren enlightened us with: > If > > a = 'apple' > b = 'banana' > c = 'cabbage' > > How can I get something like:- > > for i in 'abc': > r = eval(i) > if r == 'cabbage': r = 'coconut' > > actually change the object referenced by r rather > than creating a new object temporarily referenced by it? Use: x = { 'a': 'apple', 'b': 'banana', 'c': 'cabbage' } for key, value in x.iteritems(): if value == 'cabbage': x[key] = 'coconut' NOTE: I haven't tested this code > I've tried playing with eval and exec without the desired effect. If you notice yourself using such functions, it's ususally a lot better to simply stash your data in a dictionary, and use that instead. 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: Windows vs Linux [was: p2exe using wine/cxoffice]
Tim Golden enlightened us with: > Not quite fair. Not only would I avoid saying something with a > redundant apostrophe ;) but the Windows user interface, at least for > my purposes, didn't change such a huge amount between Win9x and > Win2K, Hence my reference to windows 3.1. > It's obvious that everyone has a different way of working, and that > I'm more comfortable in Windows because all sorts of small > familiarities So what I read in your post is that you simply don't want to leave your familiar environment. Fair enough. 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: Windows vs Linux [was: p2exe using wine/cxoffice]
Tim Golden enlightened us with: > But as far as I can tell from my experience and from the docs -- and > I'm not near a Linux box at the mo -- having used ctrl-r to recall > line x in the history, you can't just down-arrow to recall x+1, x+2 > etc. Or can you? With bash as well as the Python interactive shell: - ^R followed by a partial string to search - Hit ^R again to get the previous match, repeat as required - Hit ^A/^E to move the cursor to the beginning/end of the line, stopping the "search mode". This allows you to use arrow up/down from that point in the readline history. 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: How do I access the property info in this example ?
David Poundall enlightened us with: > class C(object): > def getx(self): return self.__x > def setx(self, value): self.__x = value > def delx(self): del self.__x > x = property(getx, setx, delx, "I'm the 'x' property.") > > I would like to get at ... > > "I'm the 'x' property." As usual: C.x.__doc__ 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: Windows vs Linux [was: p2exe using wine/cxoffice]
Tim Golden enlightened us with: > Well yes. I think the (only slightly) wider point I was making was > that -- despite goodwill and several attempts on my part -- Linux > still has not overpowered me with its usefulness. I have yet to see any OS that overpowers me with its usefulness. > Extending from this, where I am someone who's a competent computer > user (indeed, a professional software developer of some years' > standing) and who has honestly tried, it seems that switching to > Linux is not quite such a no-brainer as people sometimes make out. I think it's harder to switch for professional computer users than it is for relative laymen. After all, you have to give up a lot of things you've accumulated over the years. A newbie can just sit behind the computer and click some icons, and will be happy when things work properly. > Just occasionally you read posts from people who say (synthesised) > "The Windows command line is rubbish", It is. Let me give an example. I have the following files: SomeFileA.txt SomeFileB.txt SomeFileC.txt .SomeFileA.txt.swp That last one is a swap file created by VIM, because I'm editing SomeFileA.txt. Now, if I want to use the TAB key to get filename completion, and I type "Som", the first "match" it finds is ".SomeFileA.txt.swp". What is that? I don't want a file starting with ".Som", I want a file starting with "Som". There is also no proper terminal support in the "DOS" box, you can't resize it horizontally, and the TAB key can only do dubm filename completion (no smart option completion like only completing with directory names after a "cd" command) > "Windows crashes all the time" Fortunately, no longer true. It is true that a problem in one program has a bigger influence on your desktop as a whole in Windows that it has in Linux, though, so the effect of a badly behaving program is "felt" stronger. > "All Windows machines are overrun with adware and generate spam > willy-nilly". Not all, indeed. There are _lots_ of Windows zombie machines, though. Then again, when I was moving, I didn't pay enough attention to my Linux box, was too late in patching a leak, and it started spamming too. > And you just wonder whether such people have actually *used* a > properly set up Windows machine recently. I have. 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: Windows vs Linux [was: p2exe using wine/cxoffice]
Tim Golden enlightened us with: > Well, fair enough. Although I don't think that on its own this > constitutes "rubbish". True - it's just one of the reasons that shift its status toward rubishness ;-) > Not quite sure what this means. As in ANSI support? (Perfectly true > - definitely lacking there). Or something else? ANSI, or even better VT220 or xterm support. > Well, peculiarly, you can do this (as you're probably aware) from > the Properties menu and it'll work immediately Didn't know it would work immediately. Still awkward that you have to type numbers just to resize a window. > albeit without advising the running programs that it's resized, so > only new lines will take advantage of the new width. Now, why they > didn't let you do the same thing by grabbing the border and pulling, > I don't know! My point exactly! Especially since they do allow you to vertically resize it that way. > Ummm. Not quite true, at least not on my XP machine Hmmm... maybe the 'cd' example was a bad one. Other commands don't have smart completion. You can't complete "ipconfig /rel" to "ipconfig /release" for instance. > I'm sure you're right: given moderately naive users, a Windows box > is *extremely* likely to be zombified. It's just that it doesn't > have to be that way with the proper care and attention. Which is another reason why I don't like Windows and do like Linux: the latter will be fine with just some security updates every now and then. Windows needs spyware sweepers, virus scanners and firewalls. 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: Windows vs Linux
Tim G enlightened us with: > Sadly, this seems not to be the case on my Ubuntu Breezy: bash > 3.00.16, libreadline 4.3/5.0 (not sure which one bash is using). > ctrl-r is fine; but you can't down-arrow from there; it just beeps > at you. Is there some setting I'm missing? See my other post in this thread. What I wrote was tested on Ubuntu Breezy. 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: assignment to reference
Bruno Desthuilliers enlightened us with: > for obj in (a, b, c): >if obj == 'cabbage': > obj = 'coconut' Doesn't work on my Python: Python 2.4.2 (#2, Sep 30 2005, 21:19:01) [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = 'apple' >>> b = 'banana' >>> c = 'cabbage' >>> for obj in (a, b, c): ...if obj == 'cabbage': ... obj = 'coconut' ... >>> c 'cabbage' >>> 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: OpenSSL in Python
dcrespo enlightened us with: > I've been looking for OpenSSL for python. I found pyOpenSSL, but it > requires the OpenSSL library, which I only found on > http://www.openssl.org/, but don't know how to install. Ehm... wouldn't your question then not be more appropriate on the OpenSSL newsgroup/mailinglist/forum/whatever? 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: Why the nonsense number appears?
Johnny Lee enlightened us with: > Why are there so many nonsense tails? thanks for your help. Because if the same reason you can't write 1/3 in decimal: http://docs.python.org/tut/node16.html 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: Why the nonsense number appears?
Ben O'Steen enlightened us with: > I think that the previous poster was asking something different. It all boils down to floating point inprecision. > If > t1 = 0.500 t2 = 0.461 print t1-t2 > 0.039 > > Then why: > t1 += 12345678910 t2 += 12345678910 # Note, both t1 and t2 have been incremented by the same amount. print t1-t2 > 0.0389995574951 It's easier to explain in decimals. Just assume you only have memory to keep three decimals. 12345678910.500 is internally stored as something like 1.23456789105e10. Strip that to three decimals, and you have 1.234e10. In that case, t1 - t2 = 1.234e10 - 1.234e10 = 0. > Using decimal as opposed to float sorts out this error as floats are > not built to handle the size of number used here. They can handle the size just fine. What they can't handle is 1/1000th precision when using numbers in the order of 1e10. 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: Windows - Need to process quotes in string...
Ernesto enlightened us with: > I'm trying to use a $ delimeter Why? > I want to send the string parameter: > > enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&" launchWithoutConsole("devcon.exe" 'enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&"') Or, if you should also be able to send single quotes: launchWithoutConsole("devcon.exe" '''enable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&"''') > The argument itself is a string, but has quotes inside too. Then use other quotes as string delimiters. Why would you use something else? 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: Expanding Python as a macro language
[EMAIL PROTECTED] enlightened us with: > I know, but nowadays almost any relevant application has a GUI. I can't think of any relevant server application running on Linux that has a GUI. My text processor, email client, Usenet client, IRC client, address book and agenda are all without GUI too. 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: OpenSSL in Python
dcrespo enlightened us with: > First, is the PYTHON OpenSSL C wrapper what I need to get running. I think that first you have to get OpenSSL running. Only then can you think about wrapping it. > Second, if you don't know how to answer, then limit your opinion to > yourself. We all enjoy the freedom of speech. Nobody is forcing you to read my posts. If you don't like them, you're very free to ignore them. It's not smart to fend of the only person who bothered to answer your cry for help. Chances are people don't like the way you treat the one person that replied, hence won't offer help. If you need help, the smart thing is to stay polite. 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: OpenSSL in Python
dcrespo enlightened us with: > Excuse me all of you for the way I answered. Sybren, and all of you, > accept my apology. I saw the Sybren's message yersterday late night > in a bad moment. Next time, don't visit Usenet in a bad moment. 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
python.org offline
Hi all, In the past weeks, I often got this message from the python.org webserver: -- Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. -- Does anyone know what's going on? 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: python.org offline
dcrespo enlightened us with: > "The server is temporarily unable to service your request due to > maintenance downtime or capacity problems." Yes, I can read. My question is: does anyone know why this happens so often lately? 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: python.org offline
Steve Holden enlightened us with: > Possibly real maintenance occasioned by a recent move to a new > server, in preparation for the new-look web site. Makes sense. Thanks for the info! 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: python.org offline
[EMAIL PROTECTED] enlightened us with: > Works fine for me, and I check it pretty frequently. Perhaps it's a > problem with your ISP's communication with the Python.org ISP? I doubt it, since they are one and the same ;-) 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: Python's website does a great disservice to the language
[EMAIL PROTECTED] enlightened us with: > I strongly agree with you, the web is full of web sites that are > nice "looking" but have microscopic fixed fonts (against the very > spirit of Html), are full of useless flash, have lots of html > structures nested inside other ones (PHP sites are often like this, > with dirty sourcecode), are difficult/slow to render on differnt/old > browsers (best viewed with its webmaster browser only), are two > times bigger than necessary, etc. Python web site can be improved, > but there are lot of ways to make it worse. I agree to the fullest! I'd rather have a website that I can read and can click through in seconds. 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: python.org offline
A.M. Kuchling enlightened us with: > I suspect this is teething problems related to the move to a new > server. I've bumped up the number of Apache processes, so we'll see > if that alleviates the problem. Thanks! I hope it helps! 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: how to write a blog system with Python
ice enlightened us with: > I am a fresh here , and I have no idea of it. Do you have any > comments? Look up "turbogears" and watch the "20 minute Wiki" video tutorial. 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: Class Variable Access and Assignment
Antoon Pardon enlightened us with: > I would expect a result consistent with the fact that both times b.a > would refer to the same object. "b.a" is just a name, not a pointer to a spot in memory. Getting the value associated with that name is something different from assigning a new value to that name. 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: Cheapest pocket device to code python on
Devan L enlightened us with: > I would not recommend trying to code on a handheld device. Small > screen size and [usually] small keyboards make it > less-than-practical. Stick with a laptop, or write it in a notebook, > if you must. Although it isn't the pinnacle of usability, I can program just fine on my Sharp Zaurus C3000. Having said that, a real PC is a lot nicer to work on. But then, if you want to have a really portable programming thiny, the Zaurus is great. Not too cheap 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: I Need Motivation Part 2
blahman ([EMAIL PROTECTED]) enlightened us with: > i m losing my motivation with python because there are sooo many > modules, that i cant just learn them all, this deters from c or c++ > in which there are only a limited number of header files. There are over 2800 header files on my system in /usr/include. What do you mean "a limited number of header files"? 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: help converting some perl code to python
[EMAIL PROTECTED] enlightened us with: > the problem is the '..' operator in perl. Is there any equivalent in > python? any suggestions ? I have a suggestion: stop assuming we know perl, and explain what this '..' operator does. 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: I Need Motivation Part 2
Dennis Lee Bieber enlightened us with: > I show 185 .py files in the top level Python library. That's a close > match for the base VC include directory -- and I be willing to bet > that site-packages and other add-ins don't add up to another 700 .py > files Sorry, bet lost. I have 1891 .py files in my site-packages. 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: starting an X11 session from Python
Philippe C. Martin enlightened us with: > Have there been any attempt to do so, and is there any source out > there that could help me get started ? What's stopping you from using system(), exec() or the likes to start "startx", "xinit" or simply "X"? 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: Python gui
Gian Mario Tagliaretti enlightened us with: > No, and *I hope* that if another toolkit has to replace Tkinter > (will never happen?) will be PyGTK... :) Why do you hope for PyGTK? I think one of the strengths of wxWidgets is that it uses the native platform's look. GTK looks very nice on my Gnome desktop, but to be honest it's rather ugly on Windows or Mac. 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: How to use generators?
Ian Vincent enlightened us with: > I have never used generators before but I might have now found a use > for them. I have written a recursive function to solve a 640x640 > maze but it crashes, due to exceeding the stack. The only way > around this I can think of is to use Generator but I have no idea > how to. A better way is to use a queue. I had the same problem with a similar piece of code. The only thing why you're using a stack is to move to the "next" point, without going back to a visited point. The non-recursive solution is to mark all visited points as such, only consider non-visited points, and then append the coordinates to a list of points yet to visit. Then keep looping over your code until either you found the solution to the maze or there are no points left to visit. 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: creating single-instance executables using python/py2exe
Satchidanand Haridas enlightened us with: > a new instance is created when I double click on two different > files. Is there a way in which I can make sure only one instance is > created? You could open a listening socket to listen for "open file" commands. If opening that socket fails (address already in use), connect a client socket to it, send the appropriate "open file" command, and exit. That way, you even have a cross-platform solution. 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: about try statement
Shi Mu enlightened us with: > very hard for me to understand the difference between try...except > and try...finally Within a 'try' block, if an exception is called and a matching 'except' block is found, that block will be used to handle the expression. >From the documentation of the "return" keyword: "When return passes control out of a try statement with a finally clause, that finally clause is executed before really leaving the function." Note that there is no talk about exceptions in this. 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: help make it faster please
Bengt Richter enlightened us with: > I suspect it's not possible to get '' in the list from > somestring.split() Time to adjust your suspicions: >>> ';abc;'.split(';') ['', 'abc', ''] >>countDict[w] += 1 >>else: >>countDict[w] = 1 > does that beat the try and get versions? I.e., (untested) > try: countDict[w] += 1 > except KeyError: countDict[w] = 1 OPs way is faster. A 'try' block is very fast, but trowing & handling an exception is slow. > countDict[w] = countDict.get(w, 0) + 1 I think this has the potential of being faster than OPs method, because it's likely to be fully implemented in C. 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: help make it faster please
Bengt Richter enlightened us with: > I meant somestring.split() just like that -- without a splitter > argument. My suspicion remains ;-) Mine too ;-) 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: Python gui
batfree enlightened us with: > Now GTK can use the local theme.You can choose the local theme to > make your application windows style on Winodws and Mac likely on mac > os. But why do that yourself, when you can use a GUI toolkit that does it for you? 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: sqlite utf8 encoding error
Greg Miller enlightened us with: > 'Keinen Text für Übereinstimmungsfehler gefunden' You posted it as "Keinen Text fr ...", which is Latin-1, not UTF-8. > I thought that all strings were stored in unicode in sqlite. Only if you put them into the DB as such. Make sure you're inserting UTF-8 text, since the DB won't do character conversion for you. 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: Python on linux
John Abel enlightened us with: > Here's one I used a while back. Returns a dict containing details per > partition This only gives information about actually mounted partitions. It could be improved by checking /proc/partitions as well. 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: about try and exception
Bruno Desthuilliers enlightened us with: > (Carl's top-post corrrected. Carl, please do not top-post) If you correct people and ask them to alter their posting style, at least make sure you post in a proper way. Snip what you're not directly referring to, so people don't have to scroll in order to start reading your post. 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: Underscores in Python numbers
[EMAIL PROTECTED] enlightened us with: > Of course, also support the locale variant where the meaning of "," > and "." is swapped in most European countries. This is exactly why I wouldn't use that notation. What happens if it is hardcoded into the source? I mean, that's what we're talking about. Then the program would have to have an indication of which locale is used for which source file. Without that, a program would be interpreted in a different way on different computers. I think that would be rather messy. I'm in favour of using spaces or underscores. 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: How to get started in GUI Programming?
[EMAIL PROTECTED] enlightened us with: > Googling around it seems the best GUI is either Tkinter or PyGtk. I'd go for wxPython ;-) 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: Persist a class (not an instance)
Kent Johnson enlightened us with: > Is there a way to persist a class definition (not a class instance, > the actual class) so it can be restored later? >From the docs: "Similarly, classes are pickled by named reference, so the same restrictions in the unpickling environment apply. Note that none of the class's code or data is pickled [...]" 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: Persist a class (not an instance)
Kent Johnson enlightened us with: > OK that confirms that pickle won't work. Is there another approach > that will? Well, since the classes are created at runtime as well, you could compile them using the appropriate API and call exec() on them. 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: Death to tuples!
Mike Meyer enlightened us with: > Is there any place in the language that still requires tuples > instead of sequences, except for use as dictionary keys? Anything that's an immutable sequence of numbers. For instance, a pair of coordinates. Or a value and a weight for that value. > If not, then it's not clear that tuples as a distinct data type > still serves a purpose in the language. In which case, I think it's > appropriate to consider doing away with tuples. I really disagree. There are countless examples where adding or removing elements from a list just wouldn't be right. > The new intended use is as an immutable sequence type, not a > "lightweight C struct". It's the same, really. A lightweight list of elements, where each element has its own meaning, is both an immutable sequence as well as a lightweight C struct. 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: return in loop for ?
Duncan Booth enlightened us with: > I would have thought that no matter how elaborate the checking it is > guaranteed there exist programs which are correct but your verifier > cannot prove that they are. Yep, that's correct. I thought the argument was similar to the proof that no program (read: Turing machine) can determine whether a program will terminate or not. 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: ANN: Dao Language v.0.9.6-beta is release!
D H enlightened us with: > How is that a problem that some editors use 8 columns for tabs and > others use less? So what? I don't care either. I always use tabs, and my code is always readable. Some people suggest one indents with four spaces, and replaces eight spaces of indenting with a tab. Now _that_ is irritating, since my editor's tab size is set to 4. > Tabs are easier to type (one keystroke each) That depends on your editor. Mine (vim) can be instructed to insert the appropriate amount of spaces on a tab, and remove them on a backspace. 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: Tabs bad (Was: ANN: Dao Language v.0.9.6-beta is release!)
Björn Lindström enlightened us with: > This article should explain it: > > http://www.jwz.org/doc/tabs-vs-spaces.html To me it doesn't. I use a single tab character for a single indent levell. That is unambiguous, and also ensures the file is indented as the reader likes it. People who have their tab size set to 'n' will see n-space sized indents, No matter what setting, the order of the indents is kept. This is not the case if tabs and spaces are intermixed, as some style guides suggest. 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: ANN: Dao Language v.0.9.6-beta is release!
Ed Leafe enlightened us with: > See, I can make up bizarre scenarios where spaces cause problems, > too. You make me glad I'm always using tabs :) 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: Tabs bad (Was: ANN: Dao Language v.0.9.6-beta is release!)
Steven D'Aprano enlightened us with: > It seems to me that "one tab per indent level" is far more logical > than "some arbitrary number, N, of spaces, often a multiple of > eight, or four, or two, per indent level, and hope that the number > of spaces is a multiple of that arbitrary N". But maybe that's just > me. It's me too. One tab per indent makes perfect sense. > went back to tabs, got frustrated with people complaining that > indentation was being mangled by various webmail and News clients This is about the only place where I use four spaces (typed as one tab, expanded by Vim): email and Usenet. The reason? I don't want my post to become too wide. If my stuff is read by someone with tab sizes larger than four, it might become too wide, so to prevent that I use spaces. For all other things (like real source code instead of a pasted snippet) I use tabs. > I'm almost fired up enough about this to start the Society For The > Treatment Of Tabs As First Class Characters. *wink* LOL count me in ;-) 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: ANN: Dao Language v.0.9.6-beta is release!
Richard Brodie enlightened us with: > I'm sure some folk can remember local coding styles that suggested > using BEGIN and END as macros for curly brackets in C because { and > } aren't intuitive. I think that if you sink that low, you shouldn't be programming anyway. Come on, if someone can't even grasp the concept of having symbols and understand their meaning, how is such a person going to write a proper program? 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: what's wrong with "lambda x : print x/60,x%60"
[EMAIL PROTECTED] enlightened us with: > No, it is not merely a shortcut. It often allows one to avoid > polluting the namespace with a completely superfluous function name, > thus reducing code smell. Which can also be done by using inner functions. > It can also avoid a multi-line function defintion which often pushes > other relevant code off the current page and out of view, and thus > lambda can increase program readability. def somefunc(x): return x*5 How is that a multi-line function definition? 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: what's wrong with "lambda x : print x/60,x%60"
Fredrik Lundh enlightened us with: >> def somefunc(x): return x*5 >> >> How is that a multi-line function definition? > > but that's namespace pollution! if you do this, nobody will never ever be > able to use the name somefunc again! won't somebody please think about > the children! If you use that as an inner function, it only "pollutes" the local namespace of that function. How's that influencing the rest of the world? 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: what's wrong with "lambda x : print x/60,x%60"
Steve Holden enlightened us with: > I think you need to turn your irony detector up a little - it looks > like hte gain is currently way too low :o) Consider my detector tweaked ;-) 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: what's wrong with "lambda x : print x/60,x%60"
Steven D'Aprano enlightened us with: > All joking aside, when I have names (temporary variables or > scaffolding functions) that I need to initialise a module or data > structure, but then outlive their usefulness, I del the name > afterwards. Am I the only one? I don't do that. I tend to split up my code into pretty small functions, so the temporary names I use have a small scope as is. I don't see the need to add extra 'del' commands when the 'return' five lines further down is going to do the same. 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: ANN: Dao Language v.0.9.6-beta is release!
[EMAIL PROTECTED] enlightened us with: > Some people (a lot of the ones that don't give Python a chance) want > one more choice, braces. Is that so much to ask for? I say: use #{ and #} instead. If you want to have braces, what's wrong with if condition: #{ some statement other statement #} I'm sure you can even teach editors to match on those braces. 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: How to ping in Python?
Nico Grubert enlightened us with: > I just need to "ping" a machine to see if its answering. What's the > best way to do it? To do a real ICMP ping, you need raw sockets, which are turned off on Windows and reserved for root on other systems. You could try to connect to an unused port, and see how fast a RST packet is returned. 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: what's wrong with "lambda x : print x/60,x%60"
Steven D'Aprano enlightened us with: > Once the lookup table is created, you shouldn't use that function > again -- at best it is just sitting around like a third wheel, at > worst it might have side-effects you don't want. So I del the > function. I'd prefer to check the lookup table, and raise a descriptive exception if it already exists. That'll be a lot clearer than the error that a function doesn't extst, while it is clearly defined in the source. 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: unittest and non-.py files
Michael Hoffman enlightened us with: > Hi. I am trying to use unittest to run a test suite on some > scripts that do not have a .py extension. I'd move the functionality of the script into a separate file that does end in .py, and only put the invocation into the .py-less script. 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: Dectecting dir changes
chuck enlightened us with: > The doco indicates to read the source for fcntl.py to lookup the > constants representing the different types of events/signals that > are avaiable. However fcntl on some platforms seems to be > implemented as a binary leaving no way to look up the contants for > the platform. 'pydoc fcntl' works fine on my system, even though the module is a binary .so file. 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: heartbeats
Yves Glodt enlightened us with: > In detail I need a daemon on my central server which e.g. which in a > loop pings (not really ping but you know what I mean) each 20 > seconds one of the clients. You probably mean "really a ping, just not an ICMP echo request". > The only thing the client has to do is to accept the connection. > (optionally sending back some bytes). If it refuses it is assumed to > be offline. Ok, fair enough. > My central server, and this is important, should have a short > timeout. If one client does not respond because it's offline, after > max. 10 seconds the central server should continue with the next > client. I'd write a single function that pings a client and waits for a response/timeout. It then should return True if the client is online, and False if it is offline. You can then use a list of clients and the filter() function, to retrieve a list of online clients. 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: ANN: Dao Language v.0.9.6-beta is release!
Zeljko Vrba enlightened us with: > Find me an editor which has folds like in VIM, regexp search/replace > within two keystrokes (ESC,:), marks to easily navigate text in 2 > keystrokes (mx, 'x), can handle indentation-level matching as well > as VIM can handle {}()[], etc. And, unlike emacs, respects all (not > just some) settings that are put in its config file. Something that > works satisfactorily out-of-the box without having to learn a new > programming language/platform (like emacs). Found it! VIM! 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: Unicode drives me crazy...
[EMAIL PROTECTED] enlightened us with: > I want to get the WMI infos from Windows machines. > I use Py from HU (iso-8859-2) charset. Why not use Unicode for everything? 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: importing pyc from memory?
Derek van Vliet enlightened us with: > I'm trying to save compiled python code in a proprietary file format > to cut reduce the overhead of compiling all my scripts when my app > starts up. Why is that faster than having the .pyc files ready on your filesystem? And why do you want it in a proprietary file format? 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: importing pyc from memory?
Derek van Vliet enlightened us with: > Up to now, I've had all my python scripts defined in XML elements, > which were compiled when my program started up using > Py_CompileString. This has worked great, but I'm finding that most > of the time my app uses to start up is spent in that > Py_CompileString It al makes sense now! Thanks for the explanation. 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: Folding in vim
Andrea Griffini enlightened us with: > - never ever use tabs I always use one tab for indents, and set my editor to display it as four spaces. I like being able to unindent a line by deleting a single character. I don't see a reason why _not_ to use tabs, really. As long as the use is consistent - I hate those files with an 8-space tab and 4-space indent, where they replace two indents with a single tab. For me, one indent = one tab. No matter the tab setting, it'll look good. 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: Folding in vim
Benji York enlightened us with: > Your editor probably supports a "backspace unindents" option. Yes, it does. I'm using vim. > If using Vim it would be something like "set softtabstop=4". This gives you a mixture of tabs and spaces, which I don't like. I'd rather use real tabs for indenting. If you then use another tab width, you only see a wider indent, but the rest of the code is okay. When using a tab/space mixture, with eight spaces being one tab, and an indent of four spaces, things go wrong when the tab size is anything but eight spaces. My solution works for all tab sizes, the other solution only works for tabs of eight spaces. This is why in my opinion it's better to just use tabs. 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: Good starterbook for learning Python?
Lennart enlightened us with: > Can someone advice me with the following issue: i want to learn > python in my summer vacation (i try to ...:-) So, a good start is > buying a good book. But wich? There are many ... http://www.diveintopython.org/ - I read it during the weekend, and it's a very good book. Clearly written, good examples and a healthy dose of humor. > I'm living in the Netherlands and I prefer a book from bol.com (see link) > because i've to order more books by them. Dive Into Python can be freely downloaded. > Search here for python (sorry, there's no short link) Yes there is. Check http://tinyurl.com/ 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: map/filter/reduce/lambda opinions and background unscientific mini-survey
Grant Edwards enlightened us with: > It sounds like you ran a computer user training department. I don't > think it could be called computer science. Being a computer science student at the University of Amsterdam, I can tell you that it definitely should not be called "computer science". > I can't believe that anybody with any computer science background > doesn't know it. I agree. 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: is there an equivalent of javascript's this["myMethod"] for the currently running script?
[EMAIL PROTECTED] enlightened us with: > var m = this["MethodName"]; > m(); //this invokes a method in javascript > > How do I do the same in python? getattr. Read the documentation, it's all in there. 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: How do you program in Python?
Jorgen Grahn enlightened us with: > I use no IDE, just emacs for editing my sources, and a terminal > window or two. And CVS for version control. Almost the same here, except that I use VIM and Subversion instead of Emacs and CVS. > If I get stuck or if the problem is non-trivial, or if I'm writing a > standalone module, I use module unittest so I have something easily > runnable at all times. This unittest code doesn't even have to be > true unit tests -- it can be any speculative code I want, driven by > the unittest framework. Same here. I really love unittest! > Between these two (interactive tinkering and unittest-based code) I > feel little need for IDEs or 'environments for experimentation'. I'm usually annoyed by IDEs because, for instance, they don't use VIM as an editor. Since I'm hooked to that, all IDEs I've used so far have failed to impress me. 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: ZipFile and file rigths
perchef enlightened us with: > it works well but i have a small problem : i can't see how i can > deal with file rights. When I unzip files with this script all the > unzipped files haven't the good rights. That's right. Why should they? ZIP doesn't store file permissions. > ZipInfo objects doesn't store informations about rights ? Correct. > How can i fix this ? Don't use ZIP. Use tar instead. 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: Yet Another Python Web Programming Question
Daniel Bickett enlightened us with: > It would be a long while before he would find Python, and since that > time he would have no desire to ever touch PHP again. My thoughts exactly. > He would, however, be compelled to write a web application again, > but in Python now, of course. Same here :) > * They required installation (as opposed to, simply, the placement > of modules), whereas the only pythonic freedom he had on his hosting > was a folder in his /home/ dir that was in the python system path. I can't help you here. For instance, if you want to get a proper performance, you should install something like mod_python to get Python functionality in Apache. > Python using CGI, for example, was enough for him until he started > getting 500 errors that he wasn't sure how to fix. Check the web server's error logs. My solution was to take a look at Cheetah. It's a template engine that's written in Python. I've written a mod_python handler for it so I can easily create & edit my website using Cheetah as a template engine. Check out http://www.unrealtower.org/mycheetah if you want to read more about the handler & other stuff I wrote. Perhaps you can even help me improve it! 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: Should I use "if" or "try" (as a matter of speed)?
Steve Juranich enlightened us with: > Without fail, when I start talking with some of the "old-timers" > (people who have written code in ADA or Fortran), I hear the same > arguments that using "if" is "better" than using "try". Then here is the counter argument: - Starting a 'try' is, as said somewhere else in this thread, a single bytecode, hence simple. - Those old-timers will probably check the data before they pass it to a function. Because their function has to be stable and idiot-proof as well, the function itself performs another check. Maybe the data is passed even further down a function chain, making checks before and after the function calls. After all, we want to be sure to only call a function when we're sure it won't fail, and every function has to gracefully bail when it's being passed bad data. This means that there will be a _lot_ of checks in the code. Now compare this by setting up a single try-block, and catching the exception at the proper place in case it's being thrown. The important part is this: those old-timers' "if" statements are always executed - it doesn't matter whether the data is correct or incorrect. The "heavy" part of exceptions only comes into play when the data is incorrect, which by proper design of the program shouldn't happen often anyway. As far as I see it, try/except blocks are "cheaper" than "if" statements. 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: ZipFile and file rigths
Robert Kern enlightened us with: > Yes, the .zip file format does store file permissions appropriate to > the platform that generates the file. I never knew that! Thanks for correcting me ;-) 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: Environment Variable
Vivek Chaudhary enlightened us with: > Is it possible to set an environment variable in python script whose > value is retained even after the script exits. It is, if you have absolute control over the calling environment. > Is it possible to somehow create this environment variable inside > python script which will be avaibale even after the script exits. In > otherwords, after I run my script, if I do a "echo $name" in my > shell, it should return the value "vivek" Here is an example Python script: import sys name = sys.stdin.readline() print "export name=%s" % name.strip() If you call it like this: bash$ $(python examplescript) It'll change the 'name' variable of your shell. It's not really a generic nor an elegant way of doing this. Heck, it even depends on the type of shell you're using. If it suits your needs, be happy ;-) 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: Environment Variable
tuxlover enlightened us with: > No, the replies from Grant's and Sybren's do answer my question. It would be a lot more polite to actually thank the people helping you. 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: reg php equivalent move_uploaded file function in python
praba kar enlightened us with: > Is there any php equivalent move_uploaded_file($source_path, > "$upload_dir/$name"); function in python to upload a file to server? move_uploaded_file does NOT upload a file to a server. > Kindly give me answer. Kindly ask answerable question. 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: Python Programming Contest
Brian Quinlan enlightened us with: > Also, it is easiest to protect my system against malicious code if > it is being run on an OS without a writeable filesystem. Even easier with User Mode Linux and a COW (copy on write) filesystem. 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: ssh popen stalling on password redirect output?
[EMAIL PROTECTED] enlightened us with: > I have a script that I cycle through nodes connect to them and run > uptime to get some information. I run the script as root so it > doesn't require a password on the rest of the nodes. It does > however barf on the nodes that are having trouble and require a > different password. Is there an easy way to skip these nodes? > Maybe redirect the password prompt to stdout or stderr or even skip > them? Why not set up proper public/private key authentication, and don't bother with passwords at all? 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: What module to use to get a file from a website?
SolaFide enlightened us with: > I'm sure this is builtin, I just don't know what module. Thank you > for any help! urllib, read the excellent free book "dive into python" at http://www.diveintopython.org/ for examples and usage. 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: What is your favorite Python web framework?
Admin enlightened us with: > But I'd like to know your opinion on what you think is best. The > Python framework I'll use will be to build an e-commerce > application looking like Amazon.com I'm greatly in favour of Cheetah. Also see http://www.unrealtower.org/mycheetah. I need to put up way more documentation & examples, but the basics are there. Let me know what you think! 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: What is your favorite Python web framework?
Admin enlightened us with: > "Error 404 while looking up your page AND when looking for a suitable > 404 > page. Sorry! > No such file /var/www/www.unrealtower.org/compiled/error404.py" You must have caught me editing some stuff, try again ;-) I really need to create another virtual host for when I want to experiment with my scripts and stuff :D 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: goto
rbt enlightened us with: > Many of the world's most profitable software companies (MS for > example) have thousands of goto statements in their code... oh the > horror of it all. Why aren't these enlightened-by-the-gods > know-it-alls as profitable as these obviously ignorant companies? They write software with huge security holes. Direct3D still isn't as stable as OpenGL. It takes ages for them to create security patches. The things I mention are *not* caused by their nice and clean way of coding. As a matter of fact, they use goto to jump from one function to another! And to make sure a 'return' doesn't return to the last call, but to some other, they combine this awful use of goto with manual stack manipulation. And they do all of this in C (or some derivative) so if one function changes it's parameters, all the manual stack modifications and gotos need to be checked for correctness. I'd rather use an exception, or better even - write small functions so I can call 'return' instead of doing 'goto EXIT'. 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: goto
Mike Meyer enlightened us with: >> I dislike gotos because it is too easy to inadvertently create >> infinite loops. <10 WINK; 20 GOTO 10> > > And it's impossible without them? I thought the same thing, but then I read it again and thought about the "inadvertently". As soon as you see a "while True", you _know_ it's going to loop forever. As soon as you see a "goto 10", you don't. 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: Reg file uploading
praba kar enlightened us with: > When we upload a file to the remote server we can get file type > through file extentions. No you can't, you can only make a better guess. If I name my PNG file somefile.jpg, you won't be able to get the file type through file extentions. > How we can find out file type if a file doesn't have any > extentions? One method is to look at the Content-type header the client sent along with the file. Another way is through the 'file' command. 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: newbie - mode for directory
wcc enlightened us with: > When using os.mkdir, what are the numeric numbers for different > modes? man chmod 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: wxPythin installation woes
linuxfreak enlightened us with: > Turns out that libstdc++.so.5 is needed but I checked and i see > that libstdc++.so.6 is installed on my system. On my system (Ubuntu, based on Debian), I can have multiple versions of libstdc++ installed at the same time. 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: PyGTK or wxPython (not a flame war) on Windows
TPJ enlightened us with: > I'd like to choose PyGTK (because of its rich documentation), but > I'm not sure if PyGTK is stable on Windows... For now I know that > wxPython runs well on Windows. Don't forget that wxPython looks like Mac on a Mac. That's important too :) 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