ANN: Wavy Navy 1.00 (Pygame shoot 'em up)
Wavy Navy 1.00 is now available at http://sizer99.com/wavy/ under BSD License. This is a Pygame shoot-em-up based on the 1983 Sirius Software game by Rodney McAuley. Created from scratch in about 3 weeks of my spare time using Python and Pygame as a test project for Pygame (which was easily up to the task). My art and sound skills are weak, so if you'd like to create better art and sound effects the game is nearly fully skinnable and I welcome contributions! I still enjoy playing the game, even after spending three weeks of my life making it, I hope you will enjoy it! [EMAIL PROTECTED] http://sizer99.com/wavy/>Wavy Navy 1.00 - Pygame shoot 'em up. (09-Apr-05) -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming Language for Systems Administrator
"Kanthi Kiran Narisetti" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > I am Windows Systems Administrator(planning to migrate to Linux > administration in near future), I have occassionally written few batch > files and Vbscripts to automate my tasks. > > Now I have strong interest to learn a programming language that would > help me to write Scripts or Application ( In Systems Administrative > point of view) . > [...] > I am confused to chose between C++,Python,Perl. I admin both Windows and Linux (Slackware, Debian) boxes, and I think your best choice is either Python or learning bash scripting. C++ is just no good - I use it for some large applications, but for sysadmin and utility stuff it just takes 10 times as much work to get anything done as Python does. bash scripting is still the way most people seem to do these things on linux (it's equivalent to batch files under Windows/DOS but far more powerful), which is the reason I suggest you take a look at it - it's still useful for writing small things that you want to send to other people where you don't know if they have python installed. Of course this is made less useful for you because you need to install a bash interpreter on Windows so it's no longer cross platform. I suggest you learn Python instead of Perl. Perl and Python are close enough in terms of functionality (with a little give and take, please no holy wars), so I wouldn't say one is Better than the other if you already know it. But for someone starting from scratch I think you will find that while the perl program may be smaller the python program will be far more readable, maintainable, and easier to write. I use bash scripting for small stuff (just simple command lines in sequence), C++ and Java for a few things that require it (though I really hate them both after using Python) and Python whenever I can. Python on Linux/Windows is amazingly cross platform as long as you use functions like os.path.join('dir','file') instead of hardcoding 'dir\\file' into your code. And use the glob, shutil, and os libraries to do all your hard work for you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming Language for Systems Administrator
Looking at my followup, I really didn't make it clear that you'll have to learn some bash scripting to be an effective *nix administrator, just because so many parts of the system use bash scripting. But python is much nicer to write anything non-trivial in. -- http://mail.python.org/mailman/listinfo/python-list
Looking for a very specific type of embedded GUI kit
We make embedded devices that are basically wimpy linux boxes with small custom display/touchscreen heads on them. They're not running X or any other windowing system. All development is done with C++ and PEG (Portable Embedded GUI) driving the display. PEG lets you install your own hardware driver to talk any custom hardware, which is what we've done. Currently we have an upgrade/installer application that boots from CD, reads an XML manifest, does what it takes to reformat the drive, partition it, install the correct packages, etc. etc. All the while displaying on the little screen what it's doing so there's some obvious progress going on. Doing this kind of thing in C++ is very painful, so I've suggested that perhaps the installer could be done in Python - at which point we have the issue of which non-X graphics toolkit we can use. If this works out, we'd probably like to replace other C++ tools with Python as well. So the question is: what non-X gui toolkit can we use that has Python bindings and will let us use a custom display driver at the lowest level? Qt/Embedded looks nice, but I don't see anything about Python binding (though as I write this I've found PyQt). I've also looked at nano-x and picogui from doing google searches on the newsgroup. Can wxPython run without X? I don't think so, but could be wrong. Should we just write our own python wrapper for PEG? I'm still researching, but figured I'd ask here in case anyone had any relevant experience and could point me somewhere. -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a very specific type of embedded GUI kit
Thanks for your suggestions - after digging into SDL it looks pretty darn easy to add your own primitive devices at the low level (in src/video/), so that seems like the way to go. Once SDL is working, plenty of kits run on top of it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Apache mod_python
Dan <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > My question is, how mature/stable is mod_python? Is it suitable for a > production environment? The documentation is a bit lacking, and I've I use mod_python for all my web stuff, including several live production sites - no problems so far. Admittedly, I don't use anything too complicated - usually just the handler and publisher syntax and a little bit of authentication. Plus MySQL on the back end. >From what I've been told, the one gotcha is that you want to make sure that different on-server users aren't sharing the same copy of mod_python, since they'll have a shared context. Which would only a problem where you're running a server open for lots of people to set up their own pages. I own all the servers being used so it's not an issue. -- http://mail.python.org/mailman/listinfo/python-list
Re: Extending base class methods
[EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: > Any ideas why this does not work? I get the error "TypeError: unbound > method printer() must be called with Field_Collection instance as > first argument (got MSD instance instead)"): > > > #== > === class Field_Collection: > fieldList = [] > > def add(self, name, size, compression, responseValue, value, > description): > self.fieldList.append( Field(name, size, compression, > responseValue, value, description) ) > > def update(self): > print "updating field" > > def get(self): > print "getting field" > > def printer(self): > for x in self.fieldList: > x.printer() > > > #== > === > > > class MSD(Field_Collection): > standard = "" > decField = "" > > def printer(self): > print "Standard: " + self.standard > print "decField: " + self.decField > Field_Collection.printer(self) > > #== > === > > w2k, python 2.3 > I added these lines to your code: foo = MSD() foo.printer() And it worked perfectly (python 2.3.3). You would get that error if you accidentally did something like: foo = MSD() MSD.printer() # oops, should be foo.printer() -- http://mail.python.org/mailman/listinfo/python-list
Re: [pygame] Very simple program fails. Why?
"Brent W. Hughes" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > I'm just starting to learn pygame. I write what I think is just about > the simplest program that should display a window and then quit. > #--- > import sys > import time > import pygame > > pygame.init() > screen = pygame.display.set_mode((640,480)) > pygame.display.set_caption("A Bug's Life") > time.sleep(4) > #--- Two problems here - first is that you should always call pygame.display.quit() when done. The second is that if you sleep(4) you've effectively blocked off the event loop for that process, which makes Windows unhappy. Even clicking 'close' to close the window won't work. Your very dumbest pygame program should have a loop like: while pygame.event.poll().type != KEYDOWN: pygame.time.delay(10) Which just does nothing (but pumps the event loop) until a key is pressed, then exits. Or you could add up the spent time and bail when it hits four seconds, or whatever you want, but you should be doing something with the pygame.event loop. And then call the pygame.display.quit() when done of course. -- http://mail.python.org/mailman/listinfo/python-list
Can't drag and drop onto .py in Windows XP?
I have several python utils that look at sys.argv to get a list of filenames to process and mangle the files in various ways. If I have a bar.bat file in Windows XP then I can just drag foo.avi onto bar.bat and bar.bat gets called with foo.avi as an argument, everyone's happy. But if I have a bar.py (or .pyw) and try to drag and drop foo.avi to it, I get a big NO cursor and nothing happens. Now I can work around this by creating a _bar.bat and having the _bar.bat call bar.pyw with the filenames it was passed (this is obviously ridiculous). Or I can create a shortcut which has the target of c:\python25\pythonw.exe c:\mybar\bar.pyw and that works, but makes telling people how to install my utilities on their computer a pain in the rear. It's just a little weird that I can't just drag and drop file names onto .pyw or .py files. Am I missing something here? Thanks for any help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't drag and drop onto .py in Windows XP?
"Roger Upole" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Sizer wrote: >> It's just a little weird that I >> can't just drag and drop file names onto .pyw or .py files. Am I >> missing something here? >> >> Thanks for any help. > > You can register a DropHandler for the Python file class. > Put this in a .reg file and merge it into the registry: > > REGEDIT4 > > [HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler] > @="{86C86720-42A0-1069-A2E8-08002B30309D}" Sir, you rock! I found that it actually worked a little better if I used a generic wsh drop handler instead of the .exe handler, but I would never have known where to start looking without your suggestion. I ended up with the following .reg file, and now I can drag and drop files onto my .py, .pyw, and .pyc files and off they go as you'd expect. It kind of seems like this should be the default installer behavior unless there's a good reason not to do it. Thanks again for your help. REGEDIT4 [HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler] @="{60254CA5-953B-11CF-8C96-00AA00B8708C}" [HKEY_CLASSES_ROOT\Python.NoConFile\shellex\DropHandler] @="{60254CA5-953B-11CF-8C96-00AA00B8708C}" [HKEY_CLASSES_ROOT\Python.CompiledFile\shellex\DropHandler] @="{60254CA5-953B-11CF-8C96-00AA00B8708C}" -- http://mail.python.org/mailman/listinfo/python-list
Installing PyPy alongside Python 2.7 on Windows?
I'd like to evaluate the recent build of PyPy on the project I'm currently working on, but am not sure how best to go about it. So my question is simply - how would I go about installing PyPy alongside Python 2.7 on Windows? In particular, unzipping PyPy and adding it to the PATH is easy enough, but what about getting setuptools and easy_setup working to install various packages for it? Is there a virtualenv-based method I can use here? (And is pip a decent replacement for setuptools on Windows yet?) -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PyPy alongside Python 2.7 on Windows?
On Jul 13, 7:29 am, cjrh wrote: > You can just extract the windows pypy 1.5 distribution to any folder and run > "pypy.exe" from there as if it was called "python.exe". This is how I have > been using it. In fact, pypy has been the default python for my portable > eclipse for a good while now. That doesn't give access to existing site-packages, or allow me to install binary packages that it can access. Hence me asking about that specifically. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pygame: Filling the screen with tile images
I don't think PyGame will handle tiling for you, or any concept of a 'background image'. If you want something to appear multiple times on the screen, you need to draw it multiple times. If you do that onto a surface that is the same size as your screen, you can then consider that the background image and blit that to the screen at the start of every frame you draw. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: bug or feature?
Fredrik Lundh wrote: > it's also mentioned in chapter 4 of the tutorial: > > http://docs.python.org/tut/node6.html#SECTION00671 > > "*Important warning*: The default value is evaluated only once. This > makes a difference when the default is a mutable object such as a list, > dictionary, or instances of most classes. " Perhaps it would be a good idea if Python actually raised a warning (SyntaxWarning?) if you use an unnamed list or dict as a default argument. This would doubtless help quite a few beginners. And for people who really do want that behaviour, working around the warning should involve minimal extra code, with extra clarity thrown in for free. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: "no variable or argument declarations are necessary."
Paul Rubin wrote: > Let's see if I understand what you're saying: > > C and Java: you get useful type checking except when you declare > a reference as type ANY. This is a shortcoming compared to: > > Python: where you get no useful type checking at all. > > That is not very convincing logic. It's started to get very misleading - Python gives you plenty of type-checking, as we all know, just not at compile-time. Also comparing Python to C/Java as you have done is not very appropriate unless you want Python to have the same sort of compile times as C and Java do. I think you're doing a small disservice to respond to Steve when not acknowledging the context of the thread, where Diez was explaining that the system used in ML would not work in Python, then Antoon made a suggestion that would fix that particular problem but make others worse. I'm not convinced that the Java route - where you type out lengthy type declarations to get some compile-time typechecking which you usually end up having to bypass later anyway - is at all beneficial, at least not in the context of Python. I can't ever remember a time when I thought "type checking really saved me from a bug there" when using C/C++/Java, but I _can_ remember many times where I've had to consider which cast or conversion to use, or had to write another overloaded function to accommodate a similar-but-different type, or debug a complex template message, or add a superfluous base class or interface, all just to get the kind of genericity that Python gives for free. And it's no good saying that variable declarations will be optional, because as soon as these statically-typed variables enter the standard library, every Python programmer will have to take these considerations on board when writing their code, whether we want to use them or not. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Sequence and/or pattern matching
Séb wrote: > 1) I have a list of connexion between some computers. This list has > this format : It looks like you want graph theory. > Ip A Date Ip B > ...... ... > 192.168.0.119.10.2005 192.168.0.2 > 192.168.0.319.10.2005 192.168.0.1 > 192.168.0.419.10.2005 192.168.0.6 That looks like a list of edges between graph nodes, you see. Each node corresponds to an address and each edge is a connection between two nodes - ip addresses, in your case. > 2) I want to find if there are unknown sequences of connexions in my > data and if these sequences are repeated along the file : > > For example : > > Computer A connects to Computer B then > Computer B connects to Computer C then > Computer C connects to Computer A That looks like finding a path between Node A and Node C. This is a common application of graph theory, and especially when finding routes (eg. for train journeys, or for AI characters in computer games). > 3) Then, the software gives the sequences it has found and how many > times they appear... You can find all the routes between 1 node and others by using depth-first search (or indeed, any other simple graph search algorithm). Basically, this says that, for any node, examine all the nodes it leads to. Then examine those nodes... repeat until you run out of nodes or find where you're looking for. The only complication is remembering the route you took. > I hope this is clear, point 2) is where I have my main problem. Has > someone an idea where to start and if there's already something coded ? I found a couple of Python graph libraries on Google but I can't vouch for their quality. However, writing your own simple graph traversal algorithm should be quite trivial. I would start by populating a dictionary where the keys are instances of address A and the values are lists of address B values for address A. Add each link again with address B as the key and address A as the value if you need to represent bidirectional connections. Then you can perform search on that as required. The only slight complication is avoiding infinite loops - I might use a dictionary of address->boolean values here and check off each address as the algorithm progresses. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Upgrading 2.4.1 to 2.4.2
[EMAIL PROTECTED] wrote: > Not sure that is a good idea on a linux system. MS should be fine, but > I actually tried that on linux. Didn't realize how much on a linux > system depends on Python. I had that problem once, although to be fair it really does depend on which distribution you use as to how many problems you're going to have. Perhaps the way to do it is to install the new Python version in /usr/local/ (alongside the distro's version is in /usr/ ), then when you're sure your new version is installed and working, change the references over - perhaps it's possible to do this with just 1 symbolic link somewhere. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Minimizing Connection reset by peer exceptions
[EMAIL PROTECTED] wrote: > Occasionally (perhaps 5% of the time) the following exception gets > raised: > > (10054, 'Connection reset by peer') Generally this just means the connection has closed through some unusual means, perhaps by being turned off, or a network cable being unplugged, or a timeout along the way, etc. 5% is a high figure, but perhaps you connect to hosts that are unreliable for some reason. You don't have control over this really; just make sure you handle the exception. Such is life, when dealing with networking. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Minimizing Connection reset by peer exceptions
Steve Holden wrote: > Do note, though, that if you aren't using some means (threading, > forking, etc) of handling the connections asynchronously then your > server will normally only queue a very limited number of connections > (usually 5 at most). The example given by the original poster seemed to be a client (using connect_ex) rather than a server, so I think this would only be an issue if the code was connecting to the same host repeatedly in quick succession. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: select.select() on windows
jas wrote: > I am currently using subprocess to execute a command. Then I read from > it's stdout...however, this is hanging on a read..waiting for more > bytes. So what I would like is to timeout...and select.selec() seems > to be what I need. Except I don't have a socket, i have stdout. > > Any suggestions on how to do a timeout like select.select with stdout? I am not too familiar with any asynchronous I/O facilities in Python beyond select, so in your situation I would use the threading module, with the blocking read in one thread and your time-out in the main thread. You could perhaps use an Event object here, which has the time-out functionality for you. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: loop help
What do you mean by 'it starts accumulating' in this context? Are you talking about the fact that numbers gain decimal places? Or the fact that using a number between 0 and 1 will make your values diverge to infinity? Either way, it's just mathematics for you, I'm afraid, and there's little Python can do about it. ;) Which part of the code issues the overflow error? I'm guessing it's the draw.point() call since that's the only bit I can't test. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Opaque documentation
egbert wrote: > Once in a while you come acros aline of documentation > that you have to, or that invites you to, read it again. > This is what I found in PyGTK: > > The set_screen method sets the 'screen" property to > the gtk.gdk.Screen specified by screen. The "screen" property > contains the screen that the window is displayed on. Clearly this is a violation of "once and only once". I'd reword it as: The set_screen method sets the property to the gtk.gdk specified by. The property contains the that the window is displayed on. ;) Maybe if I was being less facetious, someone could reword it as: The set_screen method sets the 'screen" property to the supplied gtk.gdk.Screen object. This property contains the screen that the window is displayed on. Documentation is often a problem with Python and its libraries, sadly. The same almost certainly goes for most open source projects. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatically creating a HOME environ variable on Windows?
> [EMAIL PROTECTED] napisa³(a): > > MS recommends using %USERPROFILE%, as the above in many cases returns > "C:\", which is wrong. I'm guessing this is why IDLE creates a directory in the root of my Win98 system whenever I use it. It would be great if this could be fixed for the next version. -- Ben Sizer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's website does a great disservice to the language
CppNewB wrote: > But the logos look like they were done in Paint and maybe a > readable default font is in order. I can't believe you think the font there is unreadable. It's left to the browser default, which is usually set to a simple serif font, which in turn is presumably the default because the majority of all books, magazines, and newspapers in existence use it, and have found it perfectly readable up to now. With the ability of the user to customise their font size, surely this is by definition more readable than any arbitrarily chosen typeface and size which cannot possibly suit everybody? You can append "body { font-family: sans-serif; font-size: 10pt; }" to the CSS and make it look 'professional' but it doesn't make it more readable. Really this just comes down to preconceptions over how a site 'should' look based on other sites, not on any tangible difference. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's website does a great disservice to the language
Björn Lindström wrote: > Actually it does set some fonts ("avantgarde" and > "lucidasomethignorother") as first choices. I guess you, like me, and > probably most people in here, doesn't have those installed. As far as I can tell, those fonts are only set for 'pre' and 'h' tags. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: help converting some perl code to python
[EMAIL PROTECTED] wrote: > the problem is the '..' operator in perl. Is there any equivalent in > python? I can't think of anything with a similar operation, to be honest. I'd try using while loops which look out for the next section delimiter. -- Ben Sizer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Most efficient way of storing 1024*1024 bits
Tom Anderson wrote: > On Wed, 2 Nov 2005, Dan Bishop wrote: > > > Tor Erik Sønvisen wrote: > > > >> I need a time and space efficient way of storing up to 6 million bits. > > > > The most space-efficient way of storing bits is to use the bitwise > > operators on an array of bytes: > > Actually, no, it's to xor all the bits together and store them in a single > boolean. I'd use 'or' rather than 'xor'. The or operator is more likely to yield a '1' at the end of it, and a 1 is narrower than a 0, obviously making it more efficient to store. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: how to present Python's OO feature in design?
Kay Schluehr wrote: > pcmanlin wrote: > > because i have a problem that python's oo feature is so great, but > > maybe when the project become larger, python's no-declaration cannot > > mapping the design to practice? > > > > I am not sure about it. I don't know if there are any tools that convert UML to Python code, but that doesn't stop you working with UML diagrams if you choose, and then hand-coding the classes later. Just remember that one of the major purposes of using UML for big up-front design is to save you from having to do a lot of refactoring later, but in Python this is rarely a difficult task. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Is mod_python 3.1 good for commercial blogging/CMS?
Anthony L. wrote: > 1. I want to use CGI through Publisher handler, instead of CGI handler > or PSP. Despite the speed increase mod_python gives me, there is a > problem of persistence that can be a problem when dealing with a site > that will hosts potentially hundreds of simultaneous users. What problem? Could you elaborate further? > 3. I am not very attracted to PSP because I want to separate the logic > from the presentation as completely as possible, and PHP and other > template languages including PSP seem difficult to do that in. In theory, people use these templates to /improve/ the separation between logic and presentation. When you just use req.write() you're inevitably mixing logic and presentation. At least with the template systems, you do the presentation once and the logic fills in the gaps. It's even possible to edit the presentation in many WYSIWYG web editors without affecting the code. > Why can't I just use req.write() to > output my markup, relying completely on external CSS after the fact? You can, and in fact this is largely what I do. But the HTML/CSS divide is not exactly in the same place as the template/CGI-style divide. You can still delegate most of the presentation work to CSS no matter how you emit your HTML. It as not easy to work with the CGI-style code in a WYSIWYG web editor as it is to edit a template, which is probably the main reason for their use. Also, coding everything with req.write() means that each page is very idiosyncratic, making for poor code-reuse. In theory. > My > thought is that HTML templates provide a minimum set of static code that > doesn't require extra processing, thus keeping performance up. However, > if I minimize my use of req.write() will it make a difference? I don't think performance is a factor, really. HTML templates tend to exist so that you can structure the page without worrying about the Python code. They work well for fairly uniform pages that largely require the same sort of data on each page. I am more of a programmer than a designer so I prefer to think in terms of code and emit HTML as it suits me. > I'd appreciate some practical advise on this. I am funding this myself > on a small budget with no hard deadline, so it is critical to me that I > choose a language that will minimize my costs. Are my assumptions > correct, or am I falling prey to FUD? Python is a good language for rapid development and hence testing. So you could probably create a quick mock-up of your system and then write some scripts to place it under heavy stress to see how well it holds up. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Alex Martelli wrote: > If you have valuable code, and > distribute it, people WILL crack it -- just check the warez sites for > experimental proof... EVERYTHING that people are really interested in > DOES get cracked, no matter what tricky machine-code the "protections" > are coded in. That is very black and white thinking. It may be true that everything gets cracked, but there are different degrees to which it might harm your business model. On top of that, some users may be reluctant to install binary cracks from obviously disreputable sources. Who knows what spyware or viruses you could catch? Compare that to the simplicity and safety of someone posting instructions to "open secure.py in notepad, and change the 'if license_found:' line to 'if 1:'", for example. No risk and even less effort than applying a patch. If someone wants to break into your house, they will get in. But it's still worth taking some precautions (locks, alarms, whatever) to reduce the probability. > There's ONE way to have uncrackable code -- don't distribute it, but > rather put it up on the net on a well-secured machine under your > control, available as (say) a webservice (subscription-only, pay per > use, or whatever business model you want). This is all well and good when: - web access is free (it's not if you're on dialup, or on a portable device/phone) - web access is fast enough (it's not if you're working with certain types of real-time games or multimedia) - web access is convenient (it's not if you're behind a restrictive firewall, or your country/area is poorly connected) For example, I'd like to write a game in Python. I'd like to give the game away free and charge for extra content. In C++ I can make it difficult for users to share content with others who haven't paid for it, with cryptographic hashes and the like. No, not impossible, but difficult enough to deter most people. In Python it's much harder, when the end user can open up the relevant file and quickly remove the license check. No doubt this is another of the reasons why Python isn't catching on quickly for game development, sadly. (I'm not saying this is a deficiency of Python as such. It's just a comment on the situation.) > This is (a minor) one of the many reasons that make webservices the way > of the future (hey, even *MSFT* noticed that recently, it seems...). But they are not suitable for all applications, and probably never will be. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Mike Meyer wrote: > Yu-Xi Lim <[EMAIL PROTECTED]> writes: > > Ben's analogy of the house is not a perfect example, but it's still a > > fair one. You know that if some one really wants to break into your > > house, he will get in, regardless of your sophisticated laser trip > > wire system, ex-SAS guards, and genetically-engineered guard dogs. But > > as long as the cost of protection is less than the cost of the item > > you're protecting (multiplied by the relevant probabilities, factoring > > recurring costs, etc), it's worthwhile to spend money on > > protection. If that fails, then you will of course fall back on the > > law, but you still try to prevent it from happening in the first place. > > Sounds like you just said that manufacturers should improve their > protection until they aren't making any profit on the product. That's > silly. The goal isn't to maximize protection, it's to maximize > profit. That means it only makes sense to spend money on better > protection if the cost of the protection is less than the expected > profit from adding it. I agree with what you're saying, but it seems like you're arguing against what was said rather than what was intended. Without wishing to put words into anybody's mouths, I'm pretty sure what Yu-Xi Lim meant was just that even imperfect protection is worthwhile if you estimate that it will benefit you more than it will cost you. This is in contrast to the opinion that any protection is useless because someone will break it if they want to. > A recent, heavily > publicized case where Sony added copy protection to a product cost > them sales, and from what I've heard, even legal fees. I think that's a poor example - the cost hasn't come from the mere act of adding protection, but the method in which that protection operates. I don't think anybody here - certainly not me - is talking about infecting a user's system to protect our property, or taking any other intrusive steps. I'd just like to make it non-trivial to make or use additional copies. -- Ben Sizer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Mike Meyer wrote: > There are ways to distribute > Python modules so that the user can't just open them in a text > editor. There are also ways to get cryptographic security for > distributed modules. I know distributing as bytecode helps, but I was under the impression that the disassembers worked pretty well. With the dynamic nature of the language I expect that all the variable names are largely left intact. You win some, you lose some, I guess. As for cryptographic security, could you provide a link or reference for this? I am quite interested for obvious reasons. I'd be concerned that there's a weak link in there at the decoding stage, however. I have considered distributing my program as open source but with encrypted data. Unfortunately anyone can just read the source to determine the decryption method and password. Maybe I could put that into an extension module, but that just moves the weak link along the chain. > Yes, if you use the same methods you use in C++, > it's "much harder". But by the same token, if you tried to use the > methods you'd use in a Python program in C++, you'd find that the C++ > version was "much harder". Well, I'm not sure what you mean here. A compiled C++ program is much harder to extract information from than a compiled Python program. That's without applying any special 'methods' on top of the normal distribution process. > Of course, as Alex pointed out, all of these are just keeping honest > people honest. The crooks have all the advantages in this game, so you > really can't expect to win. No, certainly not. But if you can mitigate your losses easily enough - without infringing upon anyone else's rights, I must add - then why not do so. -- Ben Sizer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Mike Meyer wrote: > > I have considered distributing my program as open source but with > > encrypted data. Unfortunately anyone can just read the source to > > determine the decryption method and password. Maybe I could put that > > into an extension module, but that just moves the weak link along the > > chain. > > This isn't a Python problem, it's a problem with what you're doing. Try > Alex's solution, and put the data on a network server that goes > through whatever authentication you want it to. To be fair, I don't think I have accused Python of having a problem, just mentioned that this is an area where Python is less appropriate than other languages which have a significant degree of obfuscation as a side-effect of their use. I already explained elsewhere that putting the data on the network is not always appropriate. I know people love web services and the like these days, but they are not the answer to everything. Even in situations where it is practical to keep all the data server-side, it still just moves the problem rather than solving it, in that instead of people copying the data they now copy the authentication for the data. Anecdotal evidence from experiences with online registration for Half-Life 2 and Windows XP would suggest that this method ends up annoying more legitimate customers than the usual copy-protection does. > It is? Is the Python disassembler so much advanced over the state of > the art of binary disassemblers, then? Or maybe it's the Python > decompilers that are so advanced? Decompyle (http://www.crazy-compilers.com/decompyle/ ) claims to be pretty advanced. I don't know if you can download it any more to test this claim though. > As far as I can tell, the only real > difference between Python bytecodes and x86 (for instance) binaries is > that Python bytecodes keep the variable names around so it can do > run-timme lookups. That's not that big a difference. It makes a lot of difference when you're hunting around for something or trying to understand a bit of code. Python bytecode (or at least, the output from dis) is also a lot more straightforward than x86 or 68K assembly to decipher. > > No, certainly not. But if you can mitigate your losses easily enough - > > without infringing upon anyone else's rights, I must add - then why not > > do so. > > Elsewhere in the thread, you said: > > > I'd just like to make it non-trivial to make or use additional copies. > > How do you do that without infringing my fair use rights? Yes, I suppose my terminology there was wrong. The term I should probably have used was 'distribute usable additional copies'. Generally speaking I believe in the "like a book" interpretation of rights... you should have the right to give it away, sell it to someone, lend it, excerpt parts for review or criticism, but not to distribute additional copies that essentially duplicate the original. On the other hand though, what you term a 'fair use right' is not necessarily viewed that way under law. The relevant part of the law (at least in the US) says "it is not an infringement for the owner of a copy of a computer program to make or authorize the making of another copy or adaptation of that computer program provided [...] that such new copy or adaptation is for archival purposes only", which is quite distinct, legally speaking, from saying "you have the right to make a copy or adaptation for archival purposes". However, this is drifting more into the legal area which I am less interested in. Really I'd just like to be able to use Python for my work and am interested in finding the best way of doing so. -- Ben Sizer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary of tuples from query question
David Pratt wrote: > With the tip, I > simplified my code to: > > vlist_dict = {} > record_count = 0 > for record in cursor.fetchall(): > record_count += 1 > vlist_dict[record_count] = tuple(record) > print vlist_dict I missed your original post, so forgive me if I'm missing the point here. But if you're indexing the dictionary with integers, I expect you could just use a list instead, which I think could make your code look like this: vlist = [tuple(record) for record in cursor.fetchall() ] print vlist In Python there is rarely any need to manually increment index values within a loop. If you do need the record count here, len(vlist) would be equivalent. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for adding symbols within Python
Grant Edwards wrote: > In the situations described, I always use strings > and have never felt the need for something else: ... > I don't think I even understand what the objection is. What is > needed is a code fragment that shows how the use of strings is > untenable. myObject.value = 'value1' #... 100 lines of code elided... if myObject.value = 'Value1': do_right_thing() else: do_wrong_thing() I don't actually think string use is 'untenable', but it is definitely more error-prone. With some sort of named object on the right hand side you will at least get a helpful NameError. -- Ben Sizer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Mike Meyer wrote: > "Ben Sizer" <[EMAIL PROTECTED]> writes: > > Decompyle (http://www.crazy-compilers.com/decompyle/ ) claims to be > > pretty advanced. I don't know if you can download it any more to test > > this claim though. > > No, it doesn't claim to be advanced. It claims to be good at what it > does. There's no comparison with other decompilers at all. In > particular, this doesn't give you any idea whether or not similar > products exist for x86 or 68k binaries. That's irrelevant. We don't require a citable source to prove the simple fact that x86 binaries do not by default contain symbol names whereas Python .pyc and .pyo files do contain them. So any decompilation of (for example) C++ code is going to lose all the readable qualities, as well as missing any symbolic constants, enumerations, templated classes and functions, macros, #includes, inlined functions, typedefs, some distinctions between array indexing and pointer arithmetic, which inner scope a simple data variable is declared in, distinctions between functions/member functions declared as not 'thiscall'/static member functions, const declarations, etc. > I've dealt with some very powerfull disassemblers and > decompilers, but none of them worked on modern architectures. You can definitely extract something useful from them, but without symbol names you're going to have to be working with a good debugger and a decent knowledge of how to use it if you want to find anything specific. Whereas Python could give you something pretty obvious such as: 6 LOAD_FAST0 (licensed) 9 JUMP_IF_FALSE9 (to 21) > > It makes a lot of difference when you're hunting around for something > > or trying to understand a bit of code. Python bytecode (or at least, > > the output from dis) is also a lot more straightforward than x86 or 68K > > assembly to decipher. > > I'm not convinced of the former. I'll grant you half of the > latter. 68K machine language is fairly straightforward. On the other > hand, it's also seems to be irrelevant. What platform are you > developing for that's still based on the 68K? There are several embedded/portable devices based on 68K derivatives. That's not really the point though. I chose 68K assembly as an example as it's considered to be simpler than x86 assembly, yet it's still significantly more complex and less readable than the output from dis.dis() > > The term I should > > probably have used was 'distribute usable additional copies'. > > My question still stands, though - and unanswered. I'm not really sure where we're going here. I have made the point that I am not obliged to make my software copyable to facilitate your right to copy it any more than any given newspaper is obliged to publish you to facilitate your right to free speech. Therefore I find it hard to see how anything is infringing upon a right here. My interest lies in being able to use encrypted data (where 'data' can also include parts of the code) so that the data can only be read by my Python program, and specifically by a single instance of that program. You would be able to make a backup copy (or 20), you could give the whole lot to someone else, etc etc. I would just like to make it so that you can't stick the data file on Bittorrent and have the entire world playing with data that was only purchased once. > But we can be > explicit if you want: How do you do that without requiring that your > software be given special consideration in the distaster recovery and > preparedness planning? I should state that I am not at all claiming a "one size fits all" policy for software development. Firstly, from a personal point of view I am talking about simple consumer entertainment software which is not mission critical or anything like it. For more important software, there will surely be different expectations and requirements. In my case, providing a free download of any lost executables or data upon presentation of a legitimate license key should be adequate. -- Ben Sizer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Mike Meyer wrote: > "Ben Sizer" <[EMAIL PROTECTED]> writes: > > In my > > case, providing a free download of any lost executables or data upon > > presentation of a legitimate license key should be adequate. > > My special handling for such > things - and *especially* for entertainment software, where the media > gets handled by children - is "Return that POS." That's funny, I could have sworn that a few messages above you suggested I "Try Alex's solution, and put the data on a network server that goes through whatever authentication you want it to." Are you claiming therefore that it's more acceptable to you to have to access the data remotely every time you use the software than once per install? > Worse yet, you play > semantic games so you can claim not to be violating fair use rights in > the process. No, I am just pointing out that you are mixing up the concept of an actual 'right' such as one embodied in a state's constitution, with an implied 'right' that is just an exemption from committing an offence. The term 'right' does not even appear in the relevant part of US copyright law, except to state that it is a limitation on the copyright holder's rights. -- Ben Sizer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposal for adding symbols within Python
Grant Edwards wrote: > On 2005-11-15, Ben Sizer <[EMAIL PROTECTED]> wrote: > > > > myObject.value = 'value1' > > > > #... 100 lines of code elided... > > > > if myObject.value == 'Value1': > > do_right_thing() > > else: > > do_wrong_thing() > > > > I don't actually think string use is 'untenable', but it is > > definitely more error-prone. With some sort of named object on > > the right hand side you will at least get a helpful NameError. > > I don't see how that's an argument in favor of the proposal > being discussed. Aren't $Value1 and $value1 both legal and > distinct symbols in the proposed syntax? Won't you have the > exact same issue that you do with mis-typing strings? I think the idea is that if the symbol hasn't been instantiated locally in an assignment operation, then it will not exist, and "if foo == $symbolName" will either raise a NameError or flag some error during compilation. It cannot do this with string comparisons. I expect this would require a 2-pass compilation process, the first pass spotting all references to symbols and instantiating them appropriately, the second pass resolving these references and noting any that did not match up. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Mike Meyer wrote: > > Are you claiming therefore that it's more acceptable to you to have to > > access the data remotely every time you use the software than once per > > install? > > Alex's solution doesn't require special treatment for disaster > recovery and/or planning, and as such is a valid answer to the > question. It may be unacceptable for *other* reasons, but it beats > dictating a disaster recovery plan for your software to the end user > hands down on that basis. Sorry, I just don't see this as being a significant difference that makes 'access-always' acceptable and 'access rarely' unacceptable. > > No, I am just pointing out that you are mixing up the concept of an > > actual 'right' such as one embodied in a state's constitution, with an > > implied 'right' that is just an exemption from committing an offence. > > The term 'right' does not even appear in the relevant part of US > > copyright law, except to state that it is a limitation on the copyright > > holder's rights. > > You're still just playing semantic games. The common usage is "fair > use rights." If you mean "... without infringing on the end users > rights, except for fair use rights", then you should say that. Call it what you like; still, I cannot be infringing on your right when such a right does not exist to be infringed. If you want to term it a 'right', feel free, but that's not what you're granted under US law or the Berne Convention. The 'common usage' here leads to a misinterpretation of what you're entitled to. What is actually stated is a limitation on the copyright holder's exclusive rights, which is a very different matter. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are there no ordered dictionaries?
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > Using the same logic, we don't need types other than string in a DBMS > > as we can always convert a string field into some other types when it > > is needed. > > No, that's not the same logic. The dict() in my example doesn't convert be- > tween data types; it provides a new way to view an existing data structure. This is interesting; I would have thought that the tuple is read and a dictionary created by inserting each pair sequentially. Is this not the case? -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are there no ordered dictionaries?
Fredrik Lundh wrote: > Ben Sizer wrote: > > This is interesting; I would have thought that the tuple is read and a > > dictionary created by inserting each pair sequentially. Is this not the > > case? > > pointers to the members of each pair, yes. but a pointer copy is a > cheap operation (for the given use case, we're only talking about a > few dozen pairs anyway, at the most). I was really thinking more about the other work, such as the hashing and whatever, but I guess that is very efficient anyway. > this is a common fallacy; Python programmers underestimate the > cost of adding extra layers to their code (e.g. by using an ordered > dict data structure that has to incrementally update both a list and > a dictionary), and overestimate the cost of letting the C layer do > bulk operations. If it was me I would probably have just used a list and searched it linearly: premature optimisation is the root of all evil, etc. But then I've never found a need for an ordered dictionary anyway; I always felt they were more an artifact of the language implementation than a reflection of something inherently useful. However, you have to forgive people for falling prey to the 'fallacy' you describe - for years there's been an attempt to teach people to use proper data structures and algorithms instead of relying on micro-optimisations (ie. "it's too slow: redo it in assembly"). So often, the first port of call for a good programmer will be to try and find a structure that maps directly to the problem. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: a new design pattern for Python Library?
The Eternal Squire wrote: > I tend to use this design pattern a lot in order to aid in > compartmentalizing interchangeable features in a central class that > depend on the central class's data. I'm afraid I've read this paragraph and the code 3 times and I still have no idea what you're trying to convey. Perhaps it's just because your example is too abstract to me. It does look like it obscures the role of the classes involved however, which doesn't seem like a good thing to me. What do you consider a 'friendship dependency'? Is this just the Strategy pattern? -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: a new design pattern for Python Library?
bruno at modulix wrote: > Ben Sizer wrote: > > I'm afraid I've read this paragraph and the code 3 times and I still > > have no idea what you're trying to convey. > > Got anything more constructive to add? -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as Guido Intended
[EMAIL PROTECTED] wrote: > Steve Holden wrote: > > > I agree that sometimes those who shoot such proposals down in flames > > might be more considerate of the feelings of the proposers, but life is > > short and we are all imperfect. > > Well, no one is obliged to be considerate about other's feeling, that > is a personal choice. But doing it the high handed way is usually > counter-productive and never get the message across, which to me is a > failure. I agree with you that sometimes, the responses here can come across as a bit condescending. I don't think this is intentional, as everybody seems friendly enough, but I do see a pattern of people replying to a query and implying that the original poster should know better than to ask for whatever they asked, despite the Pythonic solutions suggested often differing algorithmically from the best solution in other languages. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: a new design pattern for Python Library?
The Eternal Squire wrote: > Suppose I have a central class with complex behavior that I want to > simply write as a bare skeleton upon which to hang the auxillary > classes that help provide the complex behavior. So, it's akin to the GoF's Template Method or Strategy patterns, then. > What I will typically do is create the auxillary class as a friend so > that I can have tighter integration between the Skeleton instance and > an Auxillary member instance, where the Auxillary instance isolates > behavior that I might want to modify later through inheritance. > >class Auxillary (Friend): > def __str__ (self): >return "%s %d" % (self.__class__.__name__, self.friend.core_data) > >class Skeleton: > def __init__ (self): >self.auxillary = Auxillary (self) > >skeleton = Skeleton () > >print skeleton.auxillary This looks just like the Strategy pattern except that instead of storing the skeleton as a value within Auxiliary, you use a 'Friend' base class. I would argue that this obscures the code rather than makes it clearer. I would do this sort of thing in C++ where you need that base class to enforce the interface, but not in Python. I don't care what type I assign to self.auxillary as long as it supports the methods/properties I require, and it shouldn't care whether it's being assigned to a Skeleton or something else, as long as that object provides the data it requires. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing big XML files where beginning depends on end.
output = [] def write_tree(node): output.append("") sum = 0 for child in reversed(node.children): if child.type = leaf: output.extend(["", "%d" % node.value, ""]) sum += node.value else: sum += write_tree(node) output.append("" % sum) return sum write_tree(rootNode) output.reverse() print output :) (There is probably a cleaner way to do this than the quick hack above.) -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing big XML files where beginning depends on end.
Magnus Lycka wrote: > This won't help if we have problems keeping the whole > structure / call graph in memory at one time. Ah, I had assumed that the main problem was just that the resulting DOM was too big. Still, I don't think there would be a problem if you just constructed a very small tree and then wrote out XML based upon that, instead of using an external library for this. For example, if your only elements are node and leaf, you can store that distinction in 1 bit, as opposed to a library's naive implementation using the strings "node" and "leaf", probably 40 bits in each case. Similarly you can calculate the aggregate attributes on the fly when it comes to outputting the tree instead of storing them. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as Guido Intended
Delaney, Timothy (Tim) wrote: > It is without a doubt though incumbent on anyone proposing new > *features* to have a solid understanding of what they are proposing, > what it would affect, any backwards incompatibilities, and whether it > fits into the python philosophy (import this). Sure. However, I wasn't just thinking about feature suggestions, but about times when people are asking about the best algorithm to use or why Python doesn't have something they used to rely upon in another language. > And this is the crux of it - the majority of such proposals come from > people who apparently haven't actually used python that much, and are > trying to impose things from other languages onto it. The problem you get, is that the only people who are ever likely to need to ask questions, are those who don't fully understand Python, by definition. Often the answer they get is unintuitive to anyone not familiar with Python, but occasionally you are additionally treated as if you should have known and that thinking otherwise is a bit stupid, which is a bit unfair. In some cases, the question is quite valid, but the Python community has ossified around their own particular approach, which is not necessarily optimal but seems to be enough for all concerned. (eg. the proliferation of web frameworks that holds Python back as a platform in that area.) -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao Language v.0.9.6-beta is release!
Tom Anderson wrote: > Which is not to say that it's a bad idea - if it really is scaring off > potential converts, then a dumbed-down dialect of python which uses curly > brackets and semicolons might be a useful evangelical tool. If we're going to be creating evangelical tools, I think a decent description or tutorial explaining why scoping through indentation is a better idea, rather than capitulating to the ignorance of those who won't try something different. If you repeat a piece of functionality, you factor it out into a single function. If you repeat a piece of data, you normalise it into a separate table or object. If you consistently find yourself having to enter a new scope and indent at the same time, and close scopes and unindenting at the same time, the sensible approach is to combine these concepts into one. Surely any programmer worthy of the term can see benefits to the approach when it is not just mentioned as a bizarre and arbitrary limitation of the language. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao Language v.0.9.6-beta is release!
[EMAIL PROTECTED] wrote: > > a decent description or tutorial... is better > > Sound good but... we're programmers, not documentation specialist or > motivational speakers. Why, when I suggest fixing a design defect with > code, do so many programmers want to respond with... documentation and > arguments instead of code? You haven't suggested fixing a design defect. You've suggested changing part of the design. Just because a few people dislike something, doesn't make it a defect. I dislike child-proof medicine bottles, as they're a slight inconvenience to me, but they serve an important purpose. > From "The Design of Everyday Things", docs are a sign of poor design. Firstly, it's somewhat ironic that you have to cite a documented source to back up your point. Some things simply require being put into words. You make your point by referring to a book; I would make the case for scope-indentation by referring to a paragraph in the docs. Secondly, how is this at all relevant? Do you think that adding braces to Python will mean we can remove part of the existing documentation? That is the only logical conclusion to draw from what you're saying. Thirdly, is a programming language an "Everyday Thing"? Computer programs are, yes, but languages are not. They're targeted at a very specific audience and are geared towards a very complex task. There is only so much simplification that can be done before a tool becomes useless. The context of your quote is that that things should be self-documenting and obvious.You simply can't do that with programming languages. All you can do is try to make it as consistent as possible, so that there are few surprises and as little documentation as possible. Merging scope with indentation is one good example of doing this. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
A.M. Kuchling wrote: > The tutorial seems to be in pretty good shape because Raymond > Hettinger has been keeping it up to date. It doesn't cover > everything, but it's a solid introduction, and if people don't find it > works for them, they have lots of alternative books. No suggestions > here. The last time I looked at it, I thought the tutorial was the weakest part of the documentation, because it assumed you were coming at Python from another language, and often assumed that language was C. I mean, the very first line says, "If you ever wrote a large shell script"... which most people never have. The second page assumes you're using Unix and throws in Windows as an afterthought. The third page demonstrates string literals using the term "just as you would do in C". This is a bit pointless because anyone familiar with C is probably bright enough to make the connection for themselves, and anyone who isn't will not appreciate what is being explained. This sort of theme continues throughout. Once upon a time I expect nearly all Python programmers came from C, but today, I doubt that is true, especially since most universities seem to prefer teaching Java over C++. In short, the tutorial is quite outdated for today's prospective Python programmers. Admission: I once offered to help clean it up, but by the time I got a reply from [EMAIL PROTECTED], I had started a new job and no longer had time. Sorry. As for the alternative books comment, I think this is very wrong... people are surely far more likely to buy a comprehensive reference to a language they're already hooked on by a good tutorial, than they are to buy an entry-level text for a language they don't quite understand but which seems to boast good reference material! > There are endless minor bugs in the library reference, but that seems > unavoidable. It documents many different and shifting modules, and > what to document is itself a contentious issue, so I don't think the > stream of small problems will ever cease. Make the docs like PHP's docs. Users can post addendums and corrections to the documentation, then all one of the official maintainers has to do is fold in those corrections later. > There's another struggle within the LibRef: is it a reference or a > tutorial? Does it list methods in alphabetical order so you can look > them up, or does it list them in a pedagogically useful order? I > think it has to be a reference; if each section were to be a tutorial, > the manual would be huge. I agree: reference foremost. However, all but the most trivial libraries should have a short example, preferably on the first page of their docs, so that you can quickly get an idea of whether this does what you want it to do, and how the code is going to look. Some libraries don't (ConfigParser comes to mind, Threading is another) which make using them a bit of a chore to begin with. Again, if web users could contribute examples as comments on the docs as with PHP, they can be added in later. > The library reference has so many modules that the table of contents > is very large. Again, not really a problem that we can fix; splitting > it up into separate manuals doesn't seem like it would help. Personally I'd be happy to see a lot of those modules removed from the distribution, but I expect few will agree with me. ;) -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao Language v.0.9.6-beta is release!
[EMAIL PROTECTED] wrote: > > Just because a few people dislike something, > > doesn't make it a defect. > > Actually, it does. Whose definition of defect are we using? And how small a sample population are we going to require in order to find a 'something' which less than 'a few' people dislike? > Where it will cut down is the > otherwise unending debate over the issue. Documentation is not just > what you find on a single web page. It will cut down debate but it would make the language more complex and less consistent. I don't think that's a price worth paying. > And it might help bring Python into the mainstream. I'd much rather educate the mainstream to be able to see the benefits of this method, than drag Python down to meet them. > > ...things should be self-documenting and obvious. > > You simply can't do that with programming languages. > > Maybe not completely. Trust me though, we can do better. Of course. However I would argue that indented scope is one way of doing so. Scope is instantly visible, and no longer a game of 'hunt the punctuation character, which is in a different place depending on the coder's style'. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao Language v.0.9.6-beta is release!
Antoon Pardon wrote: > Op 2005-12-06, Ben Sizer schreef <[EMAIL PROTECTED]>: > > Of course. However I would argue that indented scope is one way of > > doing so. Scope is instantly visible, and no longer a game of 'hunt the > > punctuation character, which is in a different place depending on the > > coder's style'. > > There are situations in which indentation is not that visible. > > The problem is that situations arise where your code can't be > read continuously. e.g. it can be spread over pages in a book. Write shorter functions ;) > Other situations arise where indentation alone isn't a clear > indication of how many scopes are left. No, but I find it's only a tiny bit worse than in C++/Java, where I usually find myself adding a comment at the end of a block anyway, just so that I remember what exactly is coming to an end at that point. (Although again, this might be telling me that my function is too big.) That transfers to Python where necessary. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > I suspect I'd have a harder time living without the sys module than with > > many of the builtins. Then there's os, re, math, ... Some modules, like > > thread and sys, have to be linked into the interpreter. Are they "core" or > > "add on"? Once you start migrating stuff from the "add on" manual (Library > > Reference) to the "core" manual (Language Reference), where do you stop? > > I think a natural dividing line is "import". If you import it, it > is in the Library refrence. Exactly. I'm surprised this is even open to debate. Any built-in which will work without an import statement - no matter how it's implemented - should be documented as if it was part of the core language. And anything you have to explicitly ask for using import, should be in the library reference under the name of the module or package you're importing. In terms of knowing where to look for information on a feature, this is the most sensible approach. In no other language would I look to the library reference for something which does not appear on the surface to come from a library. As an aside, personally I rarely touch the sys module. I use re, random, threading, and even xml.dom.minidom more than sys. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Integrating Python into a C++ app
I know the conventional wisdom is to write the whole app in Python and only extend with C++ where speed is an issue, but I already have a large C++ app that I'd like to add Python to. Ideally I'd rewrite the whole app in Python but I don't have time to do that and maintain the old system at the same time. So my next thought was to perhaps integrate the two and slowly migrate modules and classes across from C++ to Python. If it matters, the main reason I'm interested in doing this is because I appreciate the productivity of Python and would like to take advantage of that as I add features to the current code, to reduce bugs and cut development time. I've read a few good things in this group about Elmer (http://elmer.sourceforge.net), but I'm not sure how simply that accommodates calls in the reverse direction (from Python code back into C++). Are there any other options that would require a minimum of rewriting of code? Does anybody have any experience of such a project? -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: PyChecker messages
But you could use a dict of return values, or even just assigning a different return value in each if clause. The end result is that you have a single well-defined exit point from the function, which is generally considered to be preferable. -- http://mail.python.org/mailman/listinfo/python-list
Re: Doubt C and Python
Grant Edwards wrote: > On 2005-08-23, praba kar <[EMAIL PROTECTED]> wrote: > > What why it is more efficient. Kindly let me > > know with some details. > > Have you read _any_ of the thread? A number of people have > already explained in detail why programming in Pything is more > efficient. Please read the responses you've already gotten. Grant, Going by the Google Groups timestamps that I see, there's a good chance that none of the other responses were visible to the OP when the above followup was posted. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing a parser the right way?
beza1e1 wrote: > I'm writing a parser for english language. This is a simple function to > identify, what kind of sentence we have. Do you think, this class > wrapping is right to represent the result of the function? Further > parsing then checks isinstance(text, Declarative). > > --- > class Sentence(str): pass > class Declarative(Sentence): pass > class Question(Sentence): pass > class Command(Sentence): pass As far as the parser is concerned, making these separate classes is unnecessary when you could just store the sentence type as a normal data member of Sentence. So the answer to your question is no, in my opinion. However, when you come to actually use the resulting Sentence objects, perhaps the behaviour is different? If you're looking to use a standard interface to Sentences but are going to be doing substantially different processing depending on which sentence type you have, then yes, this class hierarchy may be useful to you. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Sound and music libraries?
Are there any decent sound and music libraries for Python that are suitable for game use? Pygame is too closely tied to SDL, PyFMOD seems to no longer be maintained, and ALPY 1.0 has disappeared and is GPL anyway (not suitable for my purposes). I'd settle for DirectSound bindings but DirectX use in Python doesn't seem to be done for some reason. -- Ben Sizer. -- http://mail.python.org/mailman/listinfo/python-list
ImportError with pickle (Python 2.7.9), possibly platform dependent
I'm saving some data via pickle, and loading it in is proving tricky. Traceback (most recent call last): [...some lines removed...] File "/home/kylotan/OMDBSetup.py", line 44, in get_omdb_map __omdb_map = OMDBMap.OMDBMap.load_from_binary(full_path) File "/home/kylotan/OMDBMap.py", line 87, in load_from_binary d = pickle.load(binary_file) File "/usr/local/lib/python2.7/pickle.py", line 1378, in load return Unpickler(file).load() File "/usr/local/lib/python2.7/pickle.py", line 858, in load dispatch[key](self) File "/usr/local/lib/python2.7/pickle.py", line 1090, in load_global klass = self.find_class(module, name) File "/usr/local/lib/python2.7/pickle.py", line 1124, in find_class __import__(module) ImportError: No module named OMDBMap Here are the 2 weird things: 1) There clearly is a module named OMDBMap, and it's importable - it's there in the 2nd line of the traceback. 2) This error only arises on Linux. Exactly the same file loads in properly on MacOSX, and on Windows 8. What I've done to try and debug this: a) I've run an MD5 on the file to make sure the file is identical on all platforms, and that nothing is changing the line endings, and I'm also making sure to both open and save the pickle with 'rb'/'wb'. b) I tried both pickle and cPickle - they seem to produce slightly different output but the error is exactly the same in each case. c) I pickle and unpickle from exactly the same file (a file called OMDBSetup.py does 'import OMDBMap' and then calls methods in there to save and load the data (including the OMDBMap.OMDBMap.load_from_binary which contains the above callstack). The intention here was to avoid both the common "No module named __main__" error, and to hopefully have exactly the same modules imported into the namespace at both save and load time. So my hypothesis is that I've either found some edge case which only acts weird on Linux (or only succeeds on the other platforms, whichever way you look at it), or there's something wrong with the Linux configuration that means it somehow cannot find this module (despite it already having found it to get this far). Does anybody have any suggestions on how I can go about debugging this? Or refactoring it to avoid whatever is happening here? -- Ben Sizer -- https://mail.python.org/mailman/listinfo/python-list
Re: ImportError with pickle (Python 2.7.9), possibly platform dependent
On Thursday, 30 April 2015 01:45:05 UTC+1, Chris Angelico wrote: > On Thu, Apr 30, 2015 at 2:01 AM, Ben Sizer wrote: > > 1) There clearly is a module named OMDBMap, and it's importable - it's > > there in the 2nd line of the traceback. > > > > Does anybody have any suggestions on how I can go about debugging this? Or > > refactoring it to avoid whatever is happening here? > > Are you half way through importing it when this load() call happens? > That might cause some issues. No, we already imported OMDBMap at the top of OMDBSetup. > Has your current directory been changed anywhere in there? Good question. It turns out that the current directory seems to be $HOME when loading, but is the script directory during saving. This will be because the Linux server is running under mod_wsgi, whereas we run the save script in-place. Our Windows and Mac tests run via Flask's built-in server so the working directory is likely to be the same whether we're running the script that does pickle.dump or the whole app that does pickle.load. > What happens if you catch this exception and print out sys.modules at > that point? Another good question, and this gives us the answer. The module lists are quite different, as I'd expect because the load happens in the context of the full application whereas the dump happens as a standalone script. But literally every module that is in the 'before dump' list is in the 'before load' list - except OMDBMap. Like the error says! What /is/ in the 'before load' list however is "my_wsgi_app.OMDBMap". The module has been imported, but the pickle algorithm is unable to reconcile the module in the WSGI app's namespace with the module referenced in the pickle file. So... I don't know how to fix this, but I do now know why it fails, and I have a satisfactory answer for why it is acting differently on the Linux server (and that is just because that is the only one running under WSGI). Two out of three isn't bad! Thanks, -- Ben Sizer -- https://mail.python.org/mailman/listinfo/python-list
Re: ImportError with pickle (Python 2.7.9), possibly platform dependent
On Friday, 1 May 2015 13:09:48 UTC+1, Chris Angelico wrote: > > Cool! That's part way. So, can you simply stuff OMDBMap into > sys.modules prior to loading? It might be a bit of a hack, but it > should work for testing, at least. Conversely, you could change the > dump script to import via the name my_wsgi_app to make it consistent. > > ChrisA Sorry for not coming back to this sooner. In our case we are probably just going to work with a different file format because this was something like the 3rd time that the way pickle works caused our loading to fail for some reason or other. I think the hoops we need to jump through to ensure that the dumping and loading environments match up are too high relative to the cost of switching to JSON or similar, especially if we might need to load the data from something other than Python in future (god forbid). -- Ben Sizer -- https://mail.python.org/mailman/listinfo/python-list
Re: ImportError with pickle (Python 2.7.9), possibly platform dependent
On Friday, 1 May 2015 13:34:41 UTC+1, Peter Otten wrote: > Ben Sizer wrote: > > > So... I don't know how to fix this, but I do now know why it fails, and I > > have a satisfactory answer for why it is acting differently on the Linux > > server (and that is just because that is the only one running under WSGI). > > Two out of three isn't bad! > > How about moving OMDBMap.py into the parent folder of my_wsgi_app.__file__ > or any other folder in sys.path? That might work, but wouldn't be practical for us because in some configurations my_wsgi_app doesn't exist at all (as it is an artifact of running under mod_wsgi environment) and when it does, it it at the top of the hierarchy - so the rest of the app wouldn't be access modules there. It could be put into sys.path somewhere else... but that is starting to break the project structure just to satisfy pickle. Instead, we'll just use a different format in future. -- Ben Sizer -- https://mail.python.org/mailman/listinfo/python-list
Creating an object that can track when its attributes are modified
I am trying to make an object that can track when its attributes have been assigned new values, and which can rollback to previous values where necessary. I have the following code which I believe works, but would like to know if there are simpler ways to achieve this goal, or if there are any bugs I haven't seen yet. class ChangeTrackingObject(object): def __init__(self): self.clean() def clean(self): """Mark all attributes as unmodified.""" object.__setattr__(self, '_dirty_attributes', dict()) def dirty_vals(self): """Returns all dirty values.""" return dict( [ (k,v) for k,v in self.__dict__.iteritems() if k in self._dirty_attributes] ) def get_changes_and_clean(self): """Helper that collects all the changes and returns them, cleaning the dirty flags at the same time.""" changes = self.dirty_vals() self.clean() return changes def rollback(self): """Reset attributes to their previous values.""" for k,v in self._dirty_attributes.iteritems(): object.__setattr__(self, k, v) self.clean() def __setattr__(self, key, value): # If the first modification to this attribute, store the old value if key not in self._dirty_attributes: if key in self.__dict__: self._dirty_attributes[key] = object.__getattribute__(self, key) else: self._dirty_attributes[key] = None # Set the new value object.__setattr__(self, key, value) I am aware that adding a new attribute and then calling rollback() leaves the new attribute in place with a None value - maybe I can use a special DeleteMe marker object in the _dirty_attributes dict along with a loop that calls delattr on any attribute that has that value after a rollback. I also believe that this won't catch modification to existing attributes as opposed to assignments: eg. if one of the attributes is a list and I append to it, this system won't notice. Is that something I can rectify easily? Any other comments or suggestions? Thanks, -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating an object that can track when its attributes are modified
On Wednesday, 6 March 2013 16:22:56 UTC, Chris Angelico wrote: > > Effectively, you would need to have a > subclass of list/dict/tuple/whatever that can respond to the change. This is certainly something I'd be interested in having, but I guess that would be fragile since the user would have the burden of having to remember to use those types. > What's the goal of this class? Can you achieve the same thing by > using, perhaps, a before-and-after snapshot of a JSON-encoded form of > the object? > I need to be able to perform complex operations on the object that may modify several properties, and then gather the properties at the end as an efficient way to see what has changed and to store those changes. Any comparison of before-and-after snapshots could work in theory, but in practice it could be expensive to produce the snapshots on larger objects and probably expensive to calculate the differences that way too. Performance is important so I would probably just go for an explicit function call to mark an attribute as having been modified rather than trying to do a diff like that. (It wouldn't work for rollbacks, but I can accept that.) -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating an object that can track when its attributes are modified
On Thursday, 7 March 2013 00:07:02 UTC, Steven D'Aprano wrote: > On Wed, 06 Mar 2013 08:56:09 -0800, Ben Sizer wrote: > > > I need to be able to perform complex operations on the object that may > > modify several properties, and then gather the properties at the end as > > an efficient way to see what has changed and to store those changes. Any > > comparison of before-and-after snapshots could work in theory, but in > > practice it could be expensive to produce the snapshots on larger > > objects and probably expensive to calculate the differences that way > > too. Performance is important so I would probably just go for an > > explicit function call to mark an attribute as having been modified > > rather than trying to do a diff like that. (It wouldn't work for > > rollbacks, but I can accept that.) > > Premature optimization. > > Unless you have been eating and breathing Python code for 15+ years, your > intuition of what is expensive and what isn't will probably be *way* off. > I've been using Python for ~15 years, and I wouldn't want to try to guess > what the most efficient way to do this will be. I admit, I've only been using Python for 10 years, but I've learned a lot about optimisation and what needs optimising from my time as a game developer. This code needs to be fairly high-performing due to the role it plays in my server and the frequency with which the behaviour gets called. > Actually I lie. I would guess that the simple, most obvious way is > faster: don't worry about storing what changed, just store *everything*. > But I could be wrong. The use case I have is not one where that is suitable. It's not the snapshots that are important, but the changes between them. > Fortunately, Python development is rapid enough that you can afford to > develop this object the straightforward way, profile your application to > see where the bottlenecks are, and if it turns out that the simple > approach is too expensive, then try something more complicated. I don't see a more straightforward solution to the problem I have than the one I have posted. I said that a system that took snapshots of the whole object and attempted to diff them would probably perform worse, but it would probably be more complex too, given the traversal and copying requirements. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: How do (not) I distribute my Python progz?
Tolga wrote: > Let's suppose that I have written a Python program and, of course, want > to show it to the world ;-) > > So, do I have to distrubute my source code? Or is there a way to hide > my code? Suggested solutions to this in the past have including using Py2exe (or something like it) to create single-file distributables (viewable with a zip program, however), writing custom import hooks to decode encrypted modules, and storing valuable data online. It might even be possible to do some sort of RMI and store useful parts of your code online, although this requires a network connection and a latency-insensitive application, which are by no means universal. You could also consider moving your sensitive code to a compiled C module, perhaps using something like Pyrex to make it fairly easy. Obviously you will want to decide whether it's worth the effort to do all this, because most of the time it won't be. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: IsString
Steven D'Aprano wrote: > def modify_in_place(obj): > """Modify an arbitrary object in place.""" > obj = None > > x = [1, 2, 3] # mutable object > modify_in_place(x) > assert x is None > > > Doesn't work either. To be fair, this isn't because the function is not pass by reference, but because the assignment operator reassigns the reference rather than altering the referent, and thus modify_in_place doesn't actually contain any modifying operations. With a good understanding of what Python's assignment operator actually does, (I believe) you can view Python as pass-by-reference without any semantic problems. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: definition of 'polymorphism' and python
Gabriel Zachmann wrote: > I understand the Wikipedia article on Polymorphism > ( http://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29 ) > that it doesn't make sense to talk about polymorphism in a fully dynamically > typed language -- does the Python community agree? "In computer science, polymorphism means allowing a single definition to be used with different types of data (specifically, different classes of objects)." >>> len("abcd") 4 >>> len([1,2,3,4,5,6]) 6 Looks pretty polymorphic to me. In fact, Python's polymorphism support is so good that it makes inheritance much less important than it is in other languages. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: OO in Python? ^^
Antoon Pardon wrote: > Op 2005-12-14, Christopher Subich schreef > > Doesn't work; duck typing is emphatically not subclass-typing. > > I don't see how that is relevant. > > > For this > > system to still work and be as general as Python is now (without having > > to make all variables 'object's), > > But the way Guido wants python to evolve would make all variables > objects. This is what PEP 3000 states. > > Support only new-style classes; classic classes will be gone. > > As far as I understand this would imply that all classes are subclasses > of object and thus that isinstance(var, object) would be true for all > variables. But that's still useless for your purposes. Everything will be derived from object but it doesn't mean everything file-like will be derived from file or everything dictionary-like will be derived from dictionary. Duck-typing means that code told to 'expect' certain types will break unnecessarily when a different-yet-equivalent type is later passed to it. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Python web framework is most like Ruby on Rails?
Mike Meyer wrote: > [Not sure if this attribution is correct.] > > Alex Martelli wrote: > > Because of course if other languages have 1 or two frameworks, python > > needs a dozen. > > People keep talking about Python's wealth of web frameworks as if it > were a bad thing. I just don't see it. Just like I like to have more > than 1 or 2 languages available for programming, I like to have more > than 1 or 2 web frameworks available for building web sites. That I > can get the flexibility I want in this area *without* having to > abandon Python is a plus for Python. Flexibility is good, but personally I think the problem is that instead of useful variety, we have redundant overlap. How many different templating systems, sql<-->object mappings, and URL dispatch schemes do we need? And what exactly is the difference between them all, except for slightly different syntax? One major benefit of reducing the number of such frameworks is that a larger community would form around each product, meaning better documentation and examples. Also, it would be easier to know which one to recommend for a given task, when there are fewer available and they are more distinct. In particular, it would be helpful to have something simple in the standard library, as currently there's a large barrier to entry for the Python newbie who wants to get into web programming, compared to ASP or PHP, or even Java servlets. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: OO in Python? ^^
Antoon Pardon wrote: > Op 2005-12-15, Ben Sizer schreef <[EMAIL PROTECTED]>: > So? I answered a question. That my answer is not usefull for > a specific purpose is very well prosible but is AFAIC irrelevant. The point being made was that your declarations such as these: int: a object: b would break the original idea (a module containing a sum() function that can take any object that has an addition operator). Inheritance isn't good enough in this situation. I apologise if that isn't what you were answering, but that seems to have been the thread context. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Why and how "there is only one way to do something"?
Steve Holden wrote: > Would you, say, remove "for" loops because they could be written as > "while" loops. Don't forget the word "obvious" that appears in that > catchphrase ... Interestingly - and somewhat related to this - the other day I was looking for a do..while or do..until loop in the Python language reference, thinking that there must be a statement for it, since semantically they're distinct from while loops. I had a use case that could have been slightly simplified by such a construct. The fact that I didn't find one seemed slightly strange at first, coming from a C/Pascal background, although it did occur to me that I've used Python for years now and not noticed this lack before. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Enumeration idioms: Values from different enumerations
Ben Finney wrote: > The problem with "is the same value" as an explanation for '==' is > that it doesn't help in cases such as:: > > >>> ShirtSize = Enum('small', 'medium', 'large') > >>> AppleSize = Enum('small', 'large') > > What should be the result of this comparison:: > > >>> ShirtSize.small == AppleSize.small > > Are they "the same value"? They're both "small" (and they both coerce > to the same string value, and in this case the same integer value). Is it possible to make it have the following sort of behaviour? : >>> ShirtSize.small == AppleSize.small True >>> ShirtSize.small is AppleSize.small False It works for comparing a boolean (True) vs. an integer (1), so it has some sort of precedent. (Especially if you make the tenuous assumption that True,False are language-supported 'enums' for 0 and 1.) -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Enumeration idioms: Values from different enumerations
Antoon Pardon wrote: > Op 2005-12-16, Ben Sizer schreef <[EMAIL PROTECTED]>: > > Is it possible to make it have the following sort of behaviour? : > > > >>>> ShirtSize.small == AppleSize.small > > True > >>>> ShirtSize.small is AppleSize.small > > False > > > > It works for comparing a boolean (True) vs. an integer (1), so it has > > some sort of precedent. (Especially if you make the tenuous assumption > > that True,False are language-supported 'enums' for 0 and 1.) > > I'm against it. I don't like the following returning True: > > ShirtSize.small in [ShirtSize.Medium, AppleSize.small] I agree to an extent. I can see that being unwanted behaviour, although not really a big one, and no worse than in C++. I think that when you have a list of alternatives like that, they're either hard-coded by selectively picking from the enumeration's initialisation list, or by being generated according to some other criteria. Either way, it would be hard to end up with the wrong type of value into that list, I think. > I also think it may cause problems with other comparisons. > > Supose the following: > > col = Enum('red', 'green', 'blue') > paint = Enum('violet' , 'blue', 'red') > > Then we get the following situation: > > col.red == paint.red and col.blue == paint.blue > > but > > col.red < col.blue and paint.blue < paint.red I don't think that's a problem - does any other language make any guarantees on ordering across multiple enumerations? Transitivity within any single enumeration plus transivity of equivalence across multiple enumerations, should be enough for most needs, no? -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Python web framework is most like Ruby on Rails?
Mike Meyer wrote: > "Ben Sizer" <[EMAIL PROTECTED]> writes: > > Flexibility is good, but personally I think the problem is that instead > > of useful variety, we have redundant overlap. How many different > > templating systems, sql<-->object mappings, and URL dispatch schemes do > > we need? And what exactly is the difference between them all, except > > for slightly different syntax? > > Well, they come in at least three major variants: complete publishing > system (ake zope), templating system (aka psp), and modules (aka > cgi). Each of these is focused on a different level of the problem, > and hence is suitable for different things. I see what you mean, but unfortunately I think there is a lot more fuzziness than that. If the separate parts were clearly delineated things would be a lot better. I look to the Database API Specification as a great example of how this could (should?) be done, allowing for easy interchangeability while still providing a well-documented standard, and the opportunity to bundle a basic module with the standard library without raising the difficulty level for those who wish to use other frameworks. A PyWebForm API and a PyWebSession API would be fairly easy to create, for example. Templating maybe less so, but not much. > Syntax can be very important, especially for templating > systems. Typically, those are used in situations where you have a lot > of X/HTML and want a bit of dynamic content. Ideally, you want to be > able to treat this just like a static HTML page. If the syntax of a > templating system makes your standard web tools puke, you probably > want to avoid it. I think templating syntax is very important, but with something like Python I think the future is in modules like HTMLTemplate rather than the ASP/PHP model. When you're working with a valid XML page in the first place, all your tools should work adequately. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Enumeration idioms: Values from different enumerations
Steven D'Aprano wrote: > On Fri, 16 Dec 2005 02:43:35 -0800, Ben Sizer wrote: > > Is it possible to make it have the following sort of behaviour? : > > > >>>> ShirtSize.small == AppleSize.small > > True > > Okay, so I was wrong to say that nobody was seriously suggesting that sort > of behaviour. I was working under what looks to have been an incorrect assumption that someone was looking for a way to do the above. After all, it was mentioned in what seemed like seriousness. I can't think of a use case for it, myself. > > It works for comparing a boolean (True) vs. an integer (1), so it has > > some sort of precedent. (Especially if you make the tenuous assumption > > that True,False are language-supported 'enums' for 0 and 1.) > > Enums are not conceptually subclasses of integers. Integers just happen to > be a useful method to implement enumerations. Aren't they? They have discrete values, can be ordered and compared for equality, etc. I think the 'numerate' part of 'enumeration' is a hint here. They certainly don't look much further from being integers than booleans do. But, if nobody actually needs the behaviour I described before, this point is irrelevant. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Python web framework is most like Ruby on Rails?
Paul Rubin wrote: > "Russell E. Owen" <[EMAIL PROTECTED]> writes: > > I disagree. Once you've picked a database (not trivial in itself, of > > course), you typically only have a few options for talking to in in > > Python. Also, typically either: > > - One stands out (because others have been abandoned or whatever), so > > there's an easy answer, or > > But none of them stand out, the way the ones in PHP stand out, by > being included in the standard library. I think that's a very good reason to include them in the standard library. > With Python's web template systems, there's a real set of distinct > ones and it's maybe still too early to say there's an easy answer. > Hopefully there will eventually be one. I think we're talking very small values of 'distinct' here. Arguably the biggest difference between ASP and PHP is the language, then the libraries and objects you use. Python already has a separate language and libraries - does it really need a multitude of syntaxes for embedding it in HTML? Obviously some people think so, but I wonder if this isn't just because of the ease with which an enterprising web developer can roll their own and release it, rather than there being any significant benefits to any individual package over the others. > With db modules, if there's an easy answer, then I can't understand > why that easy answer isn't incorporated into the stdlib so people can > stop having to research it. I think there's an easy answer in most cases. Who is responsible for making the decision though? -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Python web framework is most like Ruby on Rails?
Paul Rubin wrote: > "Pierre Quentel" <[EMAIL PROTECTED]> writes: > > I am Karrigell's author. I have chosen the GPL licence almost at random > > (I saw that the Python licence was GPL-compatible), so I don't mind > > switching to another Open Source licence if the GPL is liable to cause > > problems. Which one would you advice : BSD ? Python licence ? another ? > > My own hope (not shared by everyone obviously) is that you will stay > with the GPL, but make clear that applications that simply run under > Karrigell but don't modify the Karrigell code aren't subjected to the > GPL. That should satisfy Kent's concerns. Unfortunately, that doesn't really satisfy the GPL's concerns. The work arguably "contains or is derived from" Karrigell, which is explicitly covered in section 2b of the GPL. If you start excluding key clauses from the GPL, then there's little point using it. To cut a long story short, and to avoid quibbling over the details of how a license designed with the low-level mechanics of C-style programs and libraries in mind actually applies to a language like Python with very loose coupling, I'll just say that this sort of situation is exactly what the LGPL exists for. I would suggest the author adopts the LGPL as a good compromise between the community benefits of GPL and the user benefits of, say, BSD or zlib licenses. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Python web framework is most like Ruby on Rails?
Paul Rubin wrote: > "Ben Sizer" <[EMAIL PROTECTED]> writes: > > Unfortunately, that doesn't really satisfy the GPL's concerns. The work > > arguably "contains or is derived from" Karrigell, > > I don't see that. The web app gets run by Karrigell like a CGI script > is run by Apache, like a Linux app is run by the Linux kernel. The web app uses parts of Karrigell though - things like the QUERY variable or or Session object. That is analogous to linking with Karrigell as a library. > The LGPL has fallen into some disfavor at the FSF, and I don't see > Karrigell as a library. The LGPL ultimate subverts the intent of the GPL in that it lets people use open source code without having to give much back. Still, it is 'better' in that regard than BSD or zlib. The only practical difference in this case would be that the LGPL makes it clear that there's a separation between your code and Karrigell code. > The application is not an integrated blob > combining Karrigell and user code, from what I can tell. Rather, the > user code is run under Karrigell's control, like Karrigell itself > is run under the Python interpreter. I see your point, but I think 95% of Karrigell apps will end up making calls back into the framework. The intent of the GPL is arguably that if you rely directly upon some GPL code for your application, your app falls under the license. From: http://www.gnu.org/licenses/gpl-faq.html#MereAggregation : "What constitutes combining two parts into one program? This is a legal question, which ultimately judges will decide.[...] If modules are designed to run linked together in a shared address space, that almost surely means combining them into one program. By contrast, pipes, sockets and command-line arguments are communication mechanisms normally used between two separate programs. So when they are used for communication, the modules normally are separate programs. But if the semantics of the communication are intimate enough, exchanging complex internal data structures, that too could be a basis to consider the two parts as combined into a larger program. " This is largely academic since the author seems willing to reconsider the license; but it's an interesting point for applications like this generally, especially in Python where 'linking' is a little less stringently defined than in C/C++. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Python web framework is most like Ruby on Rails?
Martin Christensen wrote: > >>>>> "Ben" == Ben Sizer <[EMAIL PROTECTED]> writes: > Ben> Unfortunately, that doesn't really satisfy the GPL's concerns. > Ben> The work arguably "contains or is derived from" Karrigell, which > Ben> is explicitly covered in section 2b of the GPL. If you start > Ben> excluding key clauses from the GPL, then there's little point > Ben> using it. > > You will also notice that section 2b of the GPL only applies to works > that are published or distributed, and if a company bases its web site > on Karrigell or any other GPL'ed web framework but does not share the > code with anyone, it cannot be considered to be published nor > distributed. Hence the GPL is a perfectly fine license for this kind > of use. You're right, but, Kent said earlier in the thread that "Most of my projects at least have the potential of being distributed to customers and GPL is not an option." I was addressing this concern specifically. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: sorting with expensive compares?
Dan Stromberg wrote: > Python appears to have a good sort method, but when sorting array elements > that are very large, and hence have very expensive compares, is there some > sort of already-available sort function that will merge like elements into > a chain, so that they won't have to be recompared as many times? It's not really practical - if the list is unsorted, it's non-trivial to determine how many times a given element is duplicated until you've compared it with everything else. That is roughly an O(N*N/2) operation whereas sorting typically is O(NlogN). This is why C++'s 'std::unique' function only operates on sorted lists. So instead, one alternative would be to use a comparison function that takes the 2 objects and looks for the pair in a dictionary: if that pair is not found, perform the normal comparison and store it in the dictionary for next time, and if it is found, just return it. This way the actual comparison is only done once for each pair. Alternatively you might be able to produce a cheap comparison from the expensive one if you can summarise the information in a simpler form. Perhaps each sorting criterion can be represented as an integer, and you can instead sort a list of lists containing integers. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Apology Re: Is 'everything' a refrence or isn't it?
Steven D'Aprano wrote: > > On reading back over my post, I realise that it might > sound like I was mad at KraftDiner. My apologies -- I'm > not, I feel (s)he is the victim of incorrect > information here, not the culprit. > > After all, as a Python newbie, how is KraftDiner > supposed to know that when people say "Python is call > by reference", what they actually mean is "Um, except > that it doesn't behave like any call by reference > language you're likely to have used before, and > sometimes it behaves more like call by value"? But, if you separate the calling mechanism from the assignment mechanism, then Python does behave like every other call by reference language. The problem is that people expect to then be able to change the value of the referred object with the assignment operator. It's the assignment semantics that differ from languages such as C++ and Java, not the calling mechanism. In C++, assignment means copying a value. In Python, assignment means reassigning a reference. The unfortunate problem is that people think of 'pass by reference' in association with 'assignment is a mutating operation', when really the 2 concepts are orthogonal and Python replaces the second with 'assignment is a reference reseating operation'. The only reason I stress this is because with this in mind, Python is consistent, as opposed to seeming to have 2 different modes of operation. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Apology Re: Is 'everything' a refrence or isn't it?
Alex Martelli wrote: > Ben Sizer <[EMAIL PROTECTED]> wrote: >... > > assignment semantics that differ from languages such as C++ and Java, > > not the calling mechanism. In C++, assignment means copying a value. In > > Python, assignment means reassigning a reference. > > And in Java, it means just the same as in Python (with some unfortunate > exceptions, in Java, for elementary types such as int -- but for all > normal types, the meaning of assignment and parameter passing is just > the same in Java as in Python). > > Considering that Java may have become the language most used for first > courses in programming, it's unfortunate to propagate disinformation > about its assignment semantics differing from Python's -- it will > confuse people who know Java, and there are many of those. Yes, my mistake - I forgot that Java reseats object references rather than copying object values. (I'm a C++ person at heart.) Personally I think this is a reason why Java is a poor language to teach beginners, as it's stuck between low level semantics from C and high level semantics like those of Python. It doesn't provide a very consistent view, meaning you're bound to get confused no matter what second language you start to learn. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: search multiple dictionaries efficiently?
Duncan Booth wrote: > Test with the 'in' operator and then retrieving the value is the fastest > solution when the value isn't in the dictionary (it only does a single > lookup then), and is still fast when it is. [0.36/0.2] > > Using the get method of the dictionary with a default value to be retrieved > if the key is not present is slower than using the 'in' operator in all > cases (it does beat try/except when an exception is thrown) [0.49/0.54] Assuming those statistics are replicatable, it's quite unfortunate that the obvious and concise way to do things works out more slowly than the approach that you'd expect to take twice as long. Thankfully there doesn't seem to be too many of these problems in Python. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Execute Commands on Remote Computers over Network
dylpkls91 wrote: > I have been researching this topic and come up with some code to make > it work. It uses SSL and requires the 3rd party package Paramiko (which > requires PyCrypto). However, at this moment I have no network to test > the code on! Trying to connect to localhost (127.0.0.1) fails. Where is the code that is supposed to receive this connection? There has to be something running on the target PC to accept incoming commands. Paramiko appears to use SSH, which (as far as I know) connects to a computer running an sshd program or equivalent and executes commands via that program. If there's no sshd running on the target, you can't do anything. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Python linker
Simon Brunning wrote: > So, they'll download and install the .NET framework at 23 MB, but they > won't download and install Python at 9 and half? I think the .NET framework gets thrown down via Windows Update - or at least it did for me - so that doesn't count as a 'separate download' for many purposes. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Python linker
Sion Arrowsmith wrote: > Er, what? How are you generating your standalone executables? What > size is "acceptable"? python24.dll is only 1.8M -- surely on any > non-embedded platform these days 1.8M isn't worth bothering about. > And since you mention wx (all of another 4.8M) I'd guess we're > talking about desktop applications. Who's going to notice if your > executable is a couple of M slimmer? I've considered making a few lightweight GUI apps in the past but you just can't do it with wxPython. When you have similar products done in Visual C++ weighing in at kilobytes rather than megabytes, it's hard to convince people that it's worth downloading your product. Say I wanted to develop a simple Notepad clone with 1 or 2 extra features: the MS executable is 68Kb, yet to simulate it in wxPython would be over 5MB; nobody would want it. I suppose you can use the msvcrt library directly and cut out wx from the dependencies, but sadly the Python overhead is still a slight deterrent. Not that I see an easy solution to this, of course. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Detecting socket connection failure
[EMAIL PROTECTED] wrote: > First, the proof that > something is there and rejecting the connection (or is it that this > thing actually accepts the connection and then drops it?)... Yes, it accepts it and then drops it, or perhaps drops it after receiving some data? It's not a failed or rejected connection from a socket point of view, however. > In [4]: remote.recv(200) > Out[4]: '' Assuming I understand the socket module, given how under-documented it is, I assume this means the socket has now been closed. > How do I detect this case? The recv may > really not have any data for a long time, so a recv of no bytes is not > a way to test the connection status. You already received zero bytes the first time, which I believe means the socket is closed, and you shouldn't pass it to select a second time. You should never get zero bytes unless the socket is closed, otherwise it would just sit there and wait until it has some bytes to return to you. Select doesn't tell you that there's data waiting - obviously it can't, as how would it handle the write case? - but in fact tells you that the socket is 'ready', and operations upon it should return immediately. And 'ready' in this case could well just mean it's ready to tell you that it's not connected. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Python linker
Alex Martelli wrote: > What framework (if any) is your Visual C++ code using? If it's using > wxWidgets (the framework underlying wxPython) I very much doubt that it > can be a few kilobytes -- unless the wxWidgets DLL is already installed > on the target machines so that it doesn't need to be packaged together > with the application code. Sure, I meant without wxWidgets. > The easy solution is to compare apples with apples: if, in your > application space, it is crucial to use only DLLs that are already > installed on the target machines, you can do that from Python (with > ctypes, for example) just as you can from C. But even that is sadly not practical, since the Python DLL alone is about 30 times the size of a tiny app like Notepad (for example). > What generally happens in the real world is rather different: > applications get programmed in whatever language and release/version is > handy, and the runtimes are separately offered for download and install > to those users who have not yet installed any previous application using > the same language and release/version. The real world is a big and diverse place, and I assure you that my applications are no less real than your own! :) Sometimes you simply cannot pick a language and version at leisure and expect everybody to install whatever is required. There are some things - casual entertainment products for example, or one-shot system checking tools, etc - where people are reluctant to install anything at all, and will not bother if they see a 6MB download. I wasn't saying this was a problem with Python - though I do expect that .dll could be trimmed down a bit - but it is a bit of a shame that I can't easily distribute something less than 1MB in size using Python. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: random shuffles
Ross Ridge wrote: > David G. Wonnacott wrote: > > Couldn't we easily get an n*log(n) shuffle... > > Why are you trying to get an O(n*log(n)) shuffle when an O(n) shuffle > algorithim is well known and implemented in Python as random.shuffle()? I think David is referring to this: "don't you still need to use O(log(n)) time to find and remove the item from the collection?" The answer for him is no: as far as I know, the Python list is a random-access structure, so looking up 2 items and swapping them runs in constant time. You perform that N times to shuffle the sequence, so it runs in O(N). -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I pass a list to a __init__ value/definition?
[EMAIL PROTECTED] wrote: > I've got: > > class MultipleRegression: > def __init__(self, dbh, regressors, fund): > self.dbh = dbh > self.regressors = regressors > > and I want to be able to enter regressors as a list like > MultipleRegression(dbh, [1,2,3,4], 5). But when I do this only the 1 > gets passed to regressors and thus to self.regressors. Your problem lies elsewhere, as when I do exactly that, I get the correct results: >>> mr = MultipleRegression(10, [1,2,3,4], 5) >>> print mr.regressors [1, 2, 3, 4] So I think the way you are passing your list to MultipleRegression is perhaps wrong. I expect your problem is in creating that list in the first place from an unknown number of items. Basically you need to create the list, repeatedly add the necessary items to it until you're done, and then pass that to MultipleRegression. How to create and populate that list will depend on where you're getting the data from. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Python audio output switch
Pan Xingzhi wrote: > Guys: > > Hi there. Recently I'll have to write a quite interesting program > in Python on a Linux box. What I need is a function which allows the > user to 'switch' the audio output from file>//. They are audio inputs, not audio outputs! I don't know of any Python modules for this, though maybe one exists. Most documentation is for C coders, and depends a lot upon what sound system your distribution of Linux is running. If you are using OSS (Open Sound System), you may be able to access /dev/mixer to choose which device is the default input. (Although I am more used to systems where you can read each input independently.) If so, you may find this page gives you a few pointers: http://www.oreilly.de/catalog/multilinux/excerpt/ch14-07.htm If you are using something else, like ALSA, you may want to look at their documentation. Or perhaps http://jackaudio.org/ will be of use. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Ray wrote: > Just that it's a big, huge, humongous pity to see Python keeps missing > the big thing over and over again. Last time when biotechnology was > hot, which language became The Language? Perl. Now simple web app is > hot? It's Ruby. The problem is that Python is the 2nd best language for everything. ;) As a general purpose language I don't think it can be beaten, but for almost any given project of non-trivial size, there seems to always be one language that has better support for the subject. I frequently find myself wanting to use Python but being unable to, often due to some library being unavailable, as in your case. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Steve Jobless wrote: > Sybren Stuvel wrote: > > > > Steve Jobless enlightened us with: > > > The first case can be just a typo, like: > > > > > > x.valeu = 5 > > > > > > I make typos all the time. Without a spell checker, this message > > > would be unreadable :). > > > > Then learn to read what you type, as you type it. Typing without > > errors can be trained. > > I'd rather let a machine to do that. Wasn't computer created for tasks > like this? (No, not really. But...) One of the benefits of Python is being able to dynamically add attributes like that, or indeed to be able to access attributes that haven't explicitly been created. If it raised an error each time you tried to add something outside of an __init__ function, there are many Python tricks you could no longer achieve. Unfortunately, when you come from a language like C++ or Java where you learned to live without those benefits, often not even knowing such things existed, all you see are the negatives (ie. lack of checking). -- Ben Sizer The > > > > > > The second case can be like: > > > > > > x.next = y > > > y.next = None > > > > > > to create a linked list by piggybacking "next" to the class. It will > > > overwrite the iterater for the class if defined. > > > > You shouldn't simply pick a name and assign something to it without > > checking the current use of that name. It's pretty much true for > > everything in life. > > Well, the choice of "next" was not a good example. Sure, no one with > decent Python knowledge would do that. > But what about adding a method to the class? Am I supposed to ask "Is > anyone using name xxx?" The class may be used by developers I don't > even know and some of them may be on the other side of the planet... > > > > > > If I was working on a large project with many engineers, I'd assume > > > someone will do things like this sooner or later. I've seen many > > > horrendous code in my life and I have no control over who I work > > > with. > > > > Long live a versioning system. With that, you can find the person > > writing the horrible code, and slap them on the back of the head. > > People, like all animals, can be trained into doing the right thing. > > I'd like to. But often those people are long gone for one reason or > another. Sometimes, it happens to be my boss... > > > Maybe I should ask the question in a different way: > > What are the benefits from this? There must be something really good > (and hopefully safe) you can do with it only from the outside. I don't > have much problem over-riding functions from the inside of the class. > But from the outside, I fail to see why anyone needs to add attributes > or over-ride functions. > > SJ -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Roman Susi wrote: > Ben Sizer wrote: > > The problem is that Python is the 2nd best language for everything. ;) > > Is it a bad thing? I don't know. I suppose that depends on how you define 'bad'! For me, it is often inconvenient, because I'd prefer to use Python but generally find that I have to choose something else if I want to do the best possible for any particular project. In my case, multimedia and game support is patchy, and web development support is still oriented towards the Java/enterprise user - if CGI doesn't suffice, that is. In the original poster's case, it's seemingly because specific database support seems to be lacking. Improving the libraries in these areas would hopefully increase the diversity of Python's potential applications rather than diminish it. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Ray wrote: > Actually Bruno, don't you think that the notion of flexibility in > Python comes at the expense of "security" is simply due to the fact > that the syntax of "screw up" is exactly the same as the syntax of "I > mean it this way and I do want it"? > > Perhaps if we use a different syntax when we want to say "I really want > this", it'll be better (so Python can differentiate between a typo and > a conscious decision). Surely the very nature of a typo is that you don't know at the time of typing that you've done the wrong thing. Therefore it's impossible to signal to Python that you don't want what you've actually typed! The only way statically-typed languages prevent these errors is typically by prohibiting the operation entirely. Since Python doesn't want to do that, you can't effectively prevent this type of error. Luckily, I find that they don't actually arise in practice, and I've spent orders of magnitude more time in C++ having to coerce objects from one type to another to comply with the static typing than I probably ever will spend debugging Python programs where a typo caused an error of this type. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Steve Jobless wrote: > Unfortunately, I don't see a way > to separate interface from implementation in Python. So, it may not make > much difference whether you subclass it or hack it from the outside. Documentation. (And name-mangling, underscore prepending, all the stuff the others said.) Whenever I use a 3rd party library, I consult the docs to see how it works and which functions do what. The interface is what is published and the implementation is what you find if you dig around in the module. Yes, there's little in the way of run-time enforcement of this divide. But that's because Python gives you other benefits that come from run-time assignment and re-assignment of attributes. It's a common and powerful idiom that you find in several languages, especially that are wholly or partially prototype-based, such as Javascript. > Unfortunately, it seems to be taking unnecessary risk. I was > hoping someone shows me a compelling reason to sacrifice the safety, but > I don't hear much. I think the main issue is that tracking whether an attribute is public or private and whether an accessing scope is allowed to access it would impose a burden on the language developers, extra typing for users, and a run-time performance penalty, in the pursuit of some degree of 'safety' that isn't universally agreed to be useful. With this in mind, the name-mangling approach is a very reasonable middle ground. Every language has a philosophy and Python's differs from that of (for example) Java. It may not be suitable for large teams of mediocre programmers who require the compiler to keep them in line, but might produce better results than Java in other circumstances. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Fastest Way To Loop Through Every Pixel
Chaos wrote: > As my first attempt to loop through every pixel of an image, I used > > for thisY in range(0, thisHeight): > for thisX in range(0, thisWidth): > #Actions here for Pixel thisX, thisY > > But it takes 450-1000 milliseconds > > I want speeds less than 10 milliseconds The main question is: why do you want to do this? I ask because with performance requirements like that, you almost certainly need another approach, one which I may be able to suggest. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Paul Boddie wrote: > Ben Sizer wrote: > > > > In my case, multimedia and game support is patchy, > > There are lots of multimedia and game frameworks for Python. Which ones > have you tried and why are they insufficient? PyGame was barely maintained for a year, and is based on SDL which was also barely maintained for a year, and which hasn't kept up with hardware advances at all. On the graphical side you can opt for OpenGL, the Python library for which is also barely maintained (though I hear work is underway behind the scenes) and doesn't provide much more than a minimal layer over the C interface anyway. DirectX support only appeared this year unless you used IronPython, and it doesn't seem very popular. Which other frameworks are you thinking of? I know of a variety of wrappers around individual libraries, and of wrappers around 3D engines such as Irrlicht and Ogre, but not much else. > Certainly, some Web frameworks have some element of Java flavouring, > but there's also considerable diversity at least at certain levels. Pretty much every Python web offering revolves around you having your own server with the luxury of running your own long-running processes on it. Great for business apps, not much use for the hobbyist or independent site. There are probably some hosts that will provide shared hosting for your Django or Turbogears app, but they are not exactly numerous. The barrier to entry here is much higher than with PHP or ASP, for example. And even with the full framework approach, the field has been so fragmented until recently that in terms of community support, you'd be better off opting for another language. I appreciate there's a diversity vs. standardisation argument there which may never be settled, so I accept this is just a personal opinion, but I do think a critical mass of users is important with any technology. I'm in a similar situation to the original poster; I'd like to use Turbogears for an app I want to write, but will probably end up doing it in PHP instead, because I can't get dedicated hardware or a local host for Turbogears. (Never mind the lack of documentation.) > Otherwise, no amount of complaining will put the > two technologies together. It's a fair point, but on the other hand, saying "if you want it doing, do it yourself" doesn't objectively improve the status quo. If something doesn't exist, it doesn't exist, and it's valid to comment upon that fact. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list