Re: How to determine if IO redirection is occurring with the output from a Python program?
Check os.isatty(fd). It will return True if fd is a terminal-like device. On Tue, Apr 17, 2012 at 5:21 PM, Edward d'Auvergne wrote: > Hi, > > I was wondering if anyone knows of how to detect when IO redirection > of any form is happening within a Python program? I would like to > emulate the behaviour of the GNU tools (for example the Unix commands > 'ls' or 'grep') whereby ascii escape sequences are printed if the > output is solely to the terminal, and in all other cases (redirection > to file via '>', pipes via '|', or more complex redirections) the > ascii escape characters are suppressed. Any ideas would be > appreciated! > > Cheers, > > Edward > > > -- > Edward d'Auvergne, PhD > Lead developer of the projects relax, minfx, and bmrblib > http://www.nmr-relax.com > http://gna.org/projects/minfx > http://gna.org/projects/bmrblib > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggest design to accomodate non-unix platforms ?
Paramiko provides SSH2 support and is platform-independent (implemented purely in Python). Try it and see if it works for you. Link: http://www.lag.net/paramiko/.. On 04/18/2012 04:35 PM, Richard Shea wrote: On a *nix box this is a reasonable bit of Python : cmd = "ssh -o StrictHostKeyChecking=no -i %s %s@%s '%s'> %s" % (key, user, dns, "echo CONNECTION READY", tmp_file) result = os.system(cmd) ... on a Windows box it will fail because 'ssh' isn't part of Windows. There *are* ways of achieving the equivalent functionality in Windows, eg putty.exe -ssh user@host ... and that's only one of them. So I'm interested in suggestions/examples where a user can update a config file to specify by which means they want (in this case) the ssh functionality to be supplied. I'm thinking of something in a config file like this ... ssh_dropin = {exec: 'putty.exe -ssh %s@%s', args:['auser','somehost']} ... which I think would work and be sufficiently flexible to deal with alternatives to putty.exe but is there a more established (... better !) way of doing this stuff ? Thanks Richard. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Louie-1.0b2 - Signal dispatching mechanism
Thomas Heller wrote: > > What is the difference between PyDispatcher and Louie? > (I'm still using a hacked version of the original cookbook recipe...) Not too much at this point, but the general differences are listed on this page: http://louie.berlios.de/changes.html Matt and I plan to experiment with other changes for Nufox, PyQt, Schevo and other things that we are working on. -- Patrick K. O'Brien Orbtech http://www.orbtech.com Schevohttp://www.schevo.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Solutions for data storage?
Leif K-Brooks wrote: > I'm writing a relatively simple multi-user public Web application with > Python. It's a rewrite of a similar application which used PHP+MySQL > (not particularly clean code, either). My opinions on various Web > frameworks tends to vary with the phase of the moon, but currently, I'm > planning to use Quixote. > > Needless to say, my application will need some kind of persistent data > storage. The previous PHP+MySQL application uses around 1.1GB of > storage, so something like PyPerSyst where everything is kept in memory > is out. You might want to look at Schevo (http://schevo.org), an ODBMS and application development framework. Schevo builds on some of the concepts introduced in Pypersyst, and can use Pypersyst as its backend storage, but it can also use ZODB and Durus (and it is easy to switch between backends). Schevo provides schema evolution and migration features, enforces referential integrity and field constraints, enforces unique indexes (whether single field or multiple field keys), etc. All you have to do is describe your objects using a simple syntax such as this snippet from a weblog application that we are putting together as an example: class Author: """Authors write posts.""" name = f.string() password = f.hashedValue() email = f.string() _key(name) _icon('.apps.kuser') def __str__(self): return self.name class Post: """Posts contain content posted to the weblog.""" slug = f.string(doc='The short name that appears in the URL.') title = f.string() published = f.datetime() author = f.entity(allow=Author) excerpt = f.memo() content = f.memo() _key(slug) _icon('.filesystems.desktop') def __str__(self): return self.slug Schevo might not be quite ready for your particular needs, but the situation you describe is the target for Schevo. While most of our UI work has been with Qt, our next focus is on Nevow, which we have used in the past on a predecessor to what is now Schevo. I've used Quixote in the past, but I'm not sure how easy it would be to use it as the UI for a Schevo app. Most of our short-term efforts are going to be concentrated on Nevow and Plone for web applications, and Qt for GUI apps (and hopefully wxPython at some point). Matthew Scott and I will be giving a Schevo presentation at PyCon on the subject of "Developing Database Applications With Schevo". You can read our outline at http://schevo.org/doc/pycon2005/proposal. Good luck with your project. -- Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Solutions for data storage?
Posting using Google Groups messed up the formatting of those class definition examples. Assume that they contain the usual indentation of typical class definitions. ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: IDLE history, Python IDE, and Interactive Python with Vim
Ashot wrote: > This is sort of both Python and Vim related (which is why I've posted to > both newsgroups). > > Python related: > -- > I have been frustrated for quite some time with a lack of a history > command in IDLE (in fact with IDLE in general). Often I'll develop new > code at the command line, testing each line as I go. Currently I have to > copy and paste, removing outputs and the ">>>" at each line. > Is it perhaps possible to make some kind of hack to do this (dump a > command history)? > > Idle in general isn't that great IMO, so I was wondering also if there are > better alternatives out there? What do people use mostly? I've tried > something called pyCrust, but this too didn't have history and some other > things I was looking for. PyCrust is only a shell, not a full-blown IDE, so it likely lacks things that you were looking for. But it certainly does have history, multi-line command recall, and cut/paste options with and without the leading prompts. In fact, the default Copy command (Ctrl+C) strips out the prompts, and the Copy Plus command (Shift+Ctrl+C) retains the prompts. If you select the Session tab you'll see the entire command history, without prompts and without the responses from the Python interpreter. Here are some other keybindings: >>> shell.help() * Key bindings: Home Go to the beginning of the command or line. Shift+HomeSelect to the beginning of the command or line. Shift+End Select to the end of the line. End Go to the end of the line. Ctrl+CCopy selected text, removing prompts. Ctrl+Shift+C Copy selected text, retaining prompts. Ctrl+XCut selected text. Ctrl+VPaste from clipboard. Ctrl+Shift+V Paste and run multiple commands from clipboard. Ctrl+Up Arrow Retrieve Previous History item. Alt+P Retrieve Previous History item. Ctrl+Down Arrow Retrieve Next History item. Alt+N Retrieve Next History item. Shift+Up ArrowInsert Previous History item. Shift+Down Arrow Insert Next History item. F8Command-completion of History item. (Type a few characters of a previous command and press F8.) Ctrl+EnterInsert new line into multiline command. Ctrl+]Increase font size. Ctrl+[Decrease font size. Ctrl+=Default font size. >>> Hope that helps. Pat -- Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Wow! I must say, I'm less than impressed with the responses so far. I know Ilias can give the impression that he is just trolling, but I can assure you he is not. At least, not in this case. ;-) So in an effort to make some headway, I'm going to try to summarize the current state of affairs. The bottom line is that compiling C extension modules on the Windows platform for Python 2.4 is, today, a royal pain in the ass. Period. Here's why. The main challenge is that extensions must be compiled using the same runtime dll as that used by the Python interpreter itself. The official Windows binary installation of Python 2.3.5 and its predecessors was compiled with one MS product, which was fairly easy to support with minGW, but Python 2.4 was compiled with the newer .NET compiler. Unfortunately, compiling extensions for Python 2.4 with the free MS tools is not trivial, as evidenced by Mike Fletcher's very thorough document on the subject: Python 2.4 Extensions w/ the MS Toolkit Compiler http://www.vrplumber.com/programming/mstoolkit/ In addition, there are some unresolved licensing questions concerning the .NET runtime file for extensions (msvcr71.dll): http://mail.python.org/pipermail/python-dev/2005-February/051393.html There have been extensive discussions about these issues on the Python-Dev mailing list over the past couple of months (mostly in December, but continuing to the present - see http://mail.python.org/pipermail/python-dev/2004-December/thread.html as a starting point), which seem to have fizzled out or at least haven't resolved much. The discussions made reference to work that has already been done to allow Python to be compiled with minGW: pyMinGW is a patch to Python source that aims to get Python to compile under MinGW http://jove.prohosting.com/iwave/ipython/pyMinGW.html I've not seen any commentary on the quality of this patch, so that doesn't appear to be the reason it hasn't been officially adopted. Reading all the threads from Python-Dev has not enlightened me at all as to what the underlying reason is for not adopting these changes. Maybe there are good reasons, I just couldn't find them, and I'm usually pretty good with Google. A few of you have mentioned that minGW is not an optimizing compiler on the Windows platform, whereas the MS .NET one is. If anyone has information on the performance differences, I'd really appreciate being able to see it, particularly as it applies to Python 2.4. Now, we get to the essence of my particular situation. I've got a project that includes some Python extensions written in C. My users (who are Python developers, but not necessarily hard-core types) need to be able to work out of their local Subversion checkouts. This includes locally compiling these extensions as necessary. I'd like this to work with Python 2.4, and be as painless as possible on my users. I can't expect them to purchase a .NET compiler or go through a bunch of configuration changes. So far, I haven't figured out a good way to support this. I'm open to suggestions. I suspect that my needs are very similar to those of the original poster. Perhaps the issue is in part a matter of minGW catching up with the new MS compilers. My understanding of and experience with Python 2.3.5 and its predecessors has been that Python itself didn't need to be recompiled with minGW, since extensions compiled with minGW linked to the same C runtime dll. So if minGW had support for msvcr71.dll then maybe this problem goes away with Python 2.4 as well. If anyone can shed any light on this situation, it would really help me out. Thanks. -- Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
So what if someone appears to be a troll? Suck it up and rise above it. This thread started with legitimate questions. Unfortunately, almost every response has been dismissive, petty, and a complete waste of time and effort. Please respond to the issue or simply ignore it. The issue is real and I'd like to find a solution to it as well. Right now it feels like I'm in the company of a bunch of hell-bent school bullies. I'm ashamed of the behavior I'm witnessing on this list. -- Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
I thought I was being as clear and specific as I needed to be. Apparently not. I'm talking about compiling the original source code, per the recommendations made by Mike Fletcher and documented here: Python 2.4 Extensions w/ the MS Toolkit Compiler http://www.vrplumber.com/programming/mstoolkit/ Now, if you know something I don't, I'm all ears. But I don't see how your suggestion solves my problem. But I'll be thrilled if that is the case. Care to enlighten me? -- Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Actually, no. We ran into some issues with Python 2.4 that caused us to return to Python 2.3.5. But I would really like to upgrade to Python 2.4. So I started researching the subject before I did anything. If you are telling me that minGW can compile extensions that are compatible with the Python 2.4 that uses msvcr71.dll, then that is good news indeed. Is there anything that needs to be configured or patched to make this happen? And how does minGW know which dll to link? What if I have both versions of Python installed - 2.3.5 and 2.4? Is there an easy way to detect this and switch between the two dlls? If I'm asking questions already answered elsewhere, I'd love a link to that resource, if you have it. Thanks, Pat Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
Stephen, I appreciate your responses. Maybe "school bullies" was an exaggeration on my part. At the same time, I'm not sure it is good for the Python community to expect everyone to roll up their sleeves and hack at something to make it work. (And I don't mean to imply that you hold that opinion. But far too many others *have* expressed that.) It's a marketing issue as much as anything. Why is Apple doing so well? They make everything simple. Now the techies will argue that they make some things too simple (like the iPod), but it's hard to deny that simple things that work consistently without any fuss have a broader appeal with the public at large. I think the same applies to developers. Not every programmer is willing to go through a lot of pain and effort just to get something simple to work. I, for one, am willing to go through that pain to save users of my product (who happen to be developers) from having to do the same. But I don't think any less of my users. I'm as lazy as they are. I like simple things that work consistently without any fuss too. :-) Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
>>users. I can't expect them to purchase a .NET compiler or go through a >See above. That answers the cost question (assuming that your interpretation of the licensing is correct, since I'm not a lawyer nor qualified to render much of an opinion on that). But there is still the issue of going through a bunch of configuration hassle that scares me away from expecting my users to make use of the MS tools. Unless things have gotten easier since Mike Fletcher wrote about the situation. But thanks for the licensing info. Much appreciated. :-) Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Stephen Kellet said: Pat, could you include some context in your replies? I have no idea if you are replying to my comments about Visual Studio Express or someone else? The only text I see in your replies is what you write, no text from the posting you are replying to. As it is I've ignored all your replies so far as I'm not sure I'm the person you are addressing (until I saw the above, now I'm confused). Sorry about that. I'm replying using Google Groups and making a total mess of things. :-( David Fraser asked if I had tried to compile a Python extension for Python 2.4 using minGW. I said that I had not (but I have for Python 2.3.5). Here is the rest of my reply, for future reference: We ran into some issues with Python 2.4 that caused us to return to Python 2.3.5. But I would really like to upgrade to Python 2.4. So I started researching the subject before I did anything. If you are telling me that minGW can compile extensions that are compatible with the Python 2.4 that uses msvcr71.dll, then that is good news indeed. Is there anything that needs to be configured or patched to make this happen? And how does minGW know which dll to link? What if I have both versions of Python installed - 2.3.5 and 2.4? Is there an easy way to detect this and switch between the two dlls? If I'm asking questions already answered elsewhere, I'd love a link to that resource, if you have it. Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Fredrik Lundh wrote: > "Pat"wrote: > > > I thought I was being as clear and specific as I needed to be. > > Apparently not. I'm talking about compiling the original source code > > the python source or the extension source? > > > The bottom line is that compiling C extension modules > > would indicate the latter. setup.py handles that just fine, if you have the > right tools. no pain at all. > > > Now, if you know something I don't, I'm all ears. But I don't see how > > your suggestion solves my problem. > > if your problem is compiling C extension modules, I suggest getting a > good compiler. I've done that, and compiling C extension modules is > no problem at all. > > if your problem is that you don't want to use a good compiler, or that > your company cannot afford to buy you a compiler, or you have other > reasons to chose the "pain in the ass" way over the "it just works" way, > I'm afraid I cannot help you. my time's too precious to waste on inferior > tools. Okay, I think we are pretty much talking about the same thing. My problem is not that I'm unable or unwilling to purchase a good compiler. My problem is that I don't want to make it a requirement of my users. The twist is that my users will be working out of a Subversion repository that includes source code for extensions written in C. Those extensions need to be compiled, and the code changes too frequently for me to want to deal with supplying compiled binaries. So I'm looking for options for Windows users who do not have, and are unwilling to get, a Microsoft compiler. For some users, minGW is an attractive option. For those who want to use minGW, I'm trying to establish whether or not minGW is a viable option, particularly for Python 2.4. I was under the impression that there were possible advantages to compiling Python itself using minGW, but that that required some patches that hadn't been applied to Python (for reasons unknown to me). Said patches are available here: http://jove.prohosting.com/iwave/ipython/pyMinGW.html I'm also under the impression that there are possible disadvantages to compiling Python itself with anything other than the Microsoft's optimizing compiler, such as performance. But I haven't seen any numbers on that, so I don't have information one way or the other. It may also be the case that minGW can now correctly compile extension that link to the newer runtime used by Python 2.4, but that wasn't always the case. If that's true, that would eliminate the primary reason for wanting to compile Python itself with minGW, though philosophical differences with MS might motivate some to want to avoid the MS compilers altogether. Perhaps the only thing that's a mess is my understanding of the situation. But even if that's the case, I don't think I'm alone, based on all the threads I've read over the past couple of days. ;-) Thanks in advance for any help anyone can offer to reduce my confusion. Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Stephen Kellett wrote: > In message <[EMAIL PROTECTED]>, Pat > <[EMAIL PROTECTED]> writes > >That answers the cost question (assuming that your interpretation of > >the licensing is correct, since I'm not a lawyer nor qualified to > >render much of an opinion on that). But there is still the issue of > >going through a bunch of configuration hassle that scares me away from > > What configuration hassle? Can't be any harder than specifying a > different CRT surely? I don't want to have to ask users of my code to have to go through this: http://www.vrplumber.com/programming/mstoolkit/ What I want is to provide everything a user would need within my own Subversion repository. Any C code would be compiled behind the scenes using free tools that I'm able to include in my repository (without having to hire a lawyer first). Having to tell users that they need to download, install, and configure all this additional compiler stuff is asking too much from my potential user base, since I'm also targeting novices and developers from other languages for whom C compiler stuff is going to be a barrier to entry. I hope that makes sense. :-) -- Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Fredrik Lundh wrote: > "Pat" wrote: > > > Okay, I think we are pretty much talking about the same thing. My > > problem is not that I'm unable or unwilling to purchase a good > > compiler. My problem is that I don't want to make it a requirement of > > my users. The twist is that my users will be working out of a > > Subversion repository that includes source code for extensions written > > in C. Those extensions need to be compiled, and the code changes too > > frequently for me to want to deal with supplying compiled binaries. > > here's what I do to supply compiled binaries for 2.1 through 2.4: > > > mkall > > upload dist > > > So I'm looking for options for Windows users who do not have, and are > > unwilling to get, a Microsoft compiler. For some users, minGW is an > > attractive option. For those who want to use minGW, I'm trying to > > establish whether or not minGW is a viable option, particularly for > > Python 2.4. > > here's what I just did (time in minutes): > > +00: googled for the mingw home page > +00: found the mingw download page > +02: finally figured out what to download > +03: noticed that my usual SF site only offered 1K/s; aborted download > +07: finished downloading the mingw kit from another SF site > +17: finished installing > +18: added \mingw\bin to the path > +18: typed "python setup.py install --compiler=mingw32" > +18: got a linker error; googled for help > +19: copied python24.dll to \mingw\lib > +20: finished building the sample library (cElementTree); all tests pass > > so what's your excuse for not doing this? ;-) A few things. Primarily the fact that I'm not very experienced in C (the extensions that I need to have compiled are not written by me). Secondarily, the fact that the discussion threads I read made it seem much more complicated than what you just described. Third, the fact that some of the code we've tried to compile didn't compile cleanly, the way your cElementTree did (but I can't remember what exactly the problem was and I didn't do the compiling). And, finally, an aversion to trial-and-error solutions. I prefer to Google and ask questions when I'm out of my element. Thanks for the info. -- Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Fredrik Lundh wrote: > "Pat" wrote: > > > A few things. Primarily the fact that I'm not very experienced in C > > (the extensions that I need to have compiled are not written by me). > > Secondarily, the fact that the discussion threads I read made it seem > > much more complicated than what you just described. > > from two posts at the top of this thread: > > "Writing a setup.py and running > python setup.py build_ext --compiler=mingw32 > works for me *without* any more work. Things can't get much > simpler." > > and > > "The mingw compiler *is* supported through distutils. distutils > can straightforwardly be configured to build extensions with > mingw." In my defense, the threads I was referring to were prior to this thread and did not include the two snippets that you've quoted. Besides, there *was* additional work that needed to be done, specifically adding the python23.dll or python24.dll to the \mingw\lib directory, as you mentioned in one of your previous posts. Now, I'm not saying any of this is rocket science, or isn't fairly easy to overcome. But it is a definite stumbling block for someone like myself who is less fluent with C that you are. > (now go read Ilias replies to those posts) I'm not Ilias. He'll have to fend for himself. I just happen to have a similar need to understand how to simplify the process of compiling extensions for Python in light of the recent changes with Python 2.4. > > Third, the fact that some of the code we've tried to compile didn't compile > > cleanly, the way your cElementTree did (but I can't remember what exactly > > the problem was and I didn't do the compiling). > > was that code tested under gcc? code that compiles under visual C doesn't > necessarily compile silently under gcc, but fixing that is usually pretty trivial > (no worse than porting mostly portable code between platforms). The code was not written by me. Specifically, we are making use of PEAK and the "unofficial" GPL port of Qt for Windows (not the upcoming GPL version from Trolltech). I just want it to work. ;-) > > And, finally, an aversion to trial-and-error solutions. I prefer to Google and > > ask questions when I'm out of my element. > > sure didn't sound that way when you entered this thread: > > "So in an effort to make some headway, I'm going to try to summarize the > current state of affairs. The bottom line is that compiling C extension modules > on the Windows platform for Python 2.4 is, today, a royal pain in the ass. > Period. Here's why. /.../" Okay, I suppose I could have done a better job phrasing that. I should have said something like "in my personal opinion, finding definitive, documented information on the proper way to compile C extensions for Python in light of the recent changes to Python 2.4 is a royal pain in the ass." To that I would now add "But Fredrik Lundh thinks things can't get much simpler, and if you ask him nicely he'll show you the error of your ways." ;-) > now go download MinGW and figure out what's wrong with your C code. It isn't my C code. I'm only including it as a dependency in my project and trying to make the use of it by my users "simpler than could ever be conceived by someone who thinks things can't get much simpler". ;-) > if you get stuck, post the error messages, and I'm sure some c.l.pythoneer > will help you sort it out. Thanks. In all seriousness, you're posts have helped. When we ran into snags we tried to compile cElementTree, got a bunch of errors, figured out we hadn't copied python23.dll into /mingw/lib, and were able to compile everything we needed. We still haven't tried that for Python 2.4 yet, due to other constraints that we haven't worked out. But I think we are getting closer and your help is greatly appreciated. :-) -- Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Diez B. Roggisch wrote: > > >> Just out of curiousity: How many python extensions are you planning to > >> write? > > > > I estimate 10 to 100, depending on abstractional capabilities of the > > extension system. > > > >> And how many lines of pure python code have you written in your life? > > > > 0 (zero). > > Awesome. Without any lines of code written, you have already identified the > areas where python lacks features that have to be overcome with C-written > extensions. As usual, I stand with my mouth agape over your near-psychic > abilities to analyze even the complexest matters without any actual > fiddling with the nitty gritty details. If you put yourself into the shoes of someone who decides to use a Python product that requires compiling, and that product contains C extensions that also need compiling, you'll see that it doesn't matter whether or not that individual has actually written a single line of Python themselves. If the compiling process is not easy, then that user will be forced to fiddle with nitty gritty details about which they'd rather remain ignorant. On Linux, I've installed and used/compiled products in a variety of languages in which I've never written a single line of source code myself. In most cases the process works fairly well. When it doesn't, I'm forced to fiddle with nitty gritty details about which I'd rather remain ignorant. The result is usually a good deal of frustration and anger on my part. On Windows, most users are used to installing precompiled binary packages, rather than compiling from source. When you do have to compile from source, it often requires you to fiddle with nitty gritty details about which you'd rather remain ignorant. The less fiddling required, the happier the user will be, and the easier it will be for that product to get adopted on that platform. No psychic abilities are required. No Python abilities are required, either, for that matter. ;-) -- Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Nick Coghlan wrote: > Pat wrote: > > On Windows, most users are used to installing precompiled binary > > packages, rather than compiling from source. When you do have to > > compile from source, it often requires you to fiddle with nitty gritty > > details about which you'd rather remain ignorant. The less fiddling > > required, the happier the user will be, and the easier it will be for > > that product to get adopted on that platform. No psychic abilities are > > required. No Python abilities are required, either, for that matter. > > ;-) > > And the fact that building *any* Windows native program without commercial > software is a PITA is the py-dev crew's fault, how? I don't recall saying that it was their fault, but if I gave that impression I apologize. I'm mainly reacting to those individuals who keep claiming that things couldn't be any simpler and that there is no problem. Based on the quality of the rest of your reply, you clearly on not one of those individuals. In fact, you have given some great information here. So thank you. It is greatly appreciated. > The python.org releases provide pre-built binaries for Windows, support for > compiling Windows extensions with various compilers (including MinGW), and > autoconf/automake support for POSIX-ish platforms (including Cygwin). True, and I've always been glad that Tim Peters went through all the trouble of creating and supporting the Windows binaries because I was on the Windows platform when I first got introduced to Python. Thank you, Tim! > For native Windows compilation of the interpreter, they support MSVC6 and MSVC7.1. > > If you're a serious commercial Windows shop, you will have one of the Microsoft > compiler suites installed *somewhere*. At that point, building your own version > of Python is trivial. True, but see my reply to your subsequent points. > Which leaves the hobbyists, and those companies which, for whatever reason, > choose not to use Visual Studio to build C/C++ code on Windows. Exactly. And how big is that group, really? It might be quite large. > If it meets your needs, the easiest solution is to build a non-native version > using Cygwin (./configure, make, make altinstall). That's what I currently do, > as the easiest free way to hack Python on a Windows box. Yeah, but Cygwin is a bit scary for Windows folks who aren't familiar with Linux or Unix. > Which means our target group is now only those who want to build a Windows > Python binary, and don't want to use Visual Studio, and don't want to use Cygwin > (hmm, the group under discussion must be getting rather small by now). Actually, I think this group is potentially huge in comparison to the current users of Python. It's just that they aren't currently represented in the Python community. Look at the PythonCard project. I was involved in the early stages of its formation (that was when I wrote PyCrust, which was incorporated into PythonCard). A great deal of the interest in PythonCard was from hobbyists, VBers, old HyperCard developers, etc. These folks were not your typical Python programmers. They just wanted a simple tool that they could use to create simple applications. Now what if PythonCard started using some C source code as part of their project? They would either have to provide binaries, or they would have to make it easy for their developer community, many of whom are on Windows, to be able to compile C extensions for Python. If they couldn't make it easy, they would risk alienating many of their supporters. So my only point is that by making it easier to use C extensions, we have an opportunity to make Python more attractive to a broader audience that includes hobbyists and folks that do not want to pay for commercial C compilers. And I think there may very well be more C code in typical projects with all the cool tools getting used, like Pyrex and such. [snip] The rest of your message provided great information. Thank you very much. -- Patrick K. O'Brien Orbtechhttp://www.orbtech.com Schevo http://www.schevo.org Pypersyst http://www.pypersyst.org -- http://mail.python.org/mailman/listinfo/python-list
Re: pycrust xmlrpclib problem
Timothy Gee wrote: > Have do a lot of lab work making use of xmlrpclib and am quite > dependent on it. I just started working with pycrust under Linux RH9, > and wanted to use it as my standard python environment, however, when I > import xmlrpclib, I get a segmentation fault. Command line still works > fine however. Details for pycrust are: > PyCrust 0.9.5 > > Yet another Python shell, only flakier. > > Half-baked by Patrick K. O'Brien, > the other half is still in the oven. > > Shell Revision: 1.9.2.10 > Interpreter Revision: 1.6.2.1 > > Platform: linux2 > Python Version: 2.4.1 > wxPython Version: 2.6.3.3 > (wxGTK, unicode, gtk2, wx-assertions-on, SWIG-1.3.27) > Linux Info: > Linux rtphostb06 2.4.20-18.9 #1 Thu May 29 07:08:16 EDT 2003 i686 i686 > i386 GNU/Linux > > Anyone had a similar problem? Any workarounds? > -Tim- It works fine for me on Windows XP with wxPython 2.6.2.1, so you may want to report this on the wxPython mailing list and see if anyone else has the same problem. Unless you've already done that. I haven't been actively involved with wxPython in some time. -- Patrick K. O'Brien Orbtech http://www.orbtech.com Schevohttp://www.schevo.org Louie http://www.pylouie.org -- http://mail.python.org/mailman/listinfo/python-list
I need suggests
I have to do a big programm. Could someone give me some suggests about IDE (on Linux) and books to learn. -- http://mail.python.org/mailman/listinfo/python-list
optparse question
Up until today, I never needed to pass any arguments to a Python program. I did all the requisite reading and found that I should use optparse instead of getopt. I read the documentation and since the words "simple" and "easy" often appeared in the examples and documentation, I just knew that it would be a snap to implement. Problem is that all I wanted to do was pass a one flag to the program "-d", for to enable debug mode. Several hours later I gave up after optparse complained about every variation I tried. What does it take to pass single parameter to a program? http://docs.python.org/library/optparse.html stated that programs always have options. Is that so? What about "dir /s"? getopt resolved my immediate need, but I would like to know how one could use optparse to extract out the options from something like "dir /s /b". -- http://mail.python.org/mailman/listinfo/python-list
Re: optparse question
If you mean with "/" as the option designator instead of "-": there doesn't appear to be a documented way of doing it. You would have to do some social engineering on the users to get them used to doing "dir -s -b". In any case I thought the number of Windows users who know how to fire up a Command Prompt window was diminishingly small ... you actually have users who know how to use commands like "dir /s /b"? I used dir /s /b as a trivial Windows example. I use Windows for personal use but Ubuntu for work and programming. Personally, I use dir /s /b all the time on Windows since the /b option finds files *much* faster; maybe 10x or 100x faster but I didn't get out a stopwatch. -- http://mail.python.org/mailman/listinfo/python-list
Re: optparse question
Thorsten Kampe wrote: * Pat (Mon, 26 Jan 2009 20:02:59 -0500) Up until today, I never needed to pass any arguments to a Python program. [...] getopt resolved my immediate need, but I would like to know how one could use optparse to extract out the options from something like "dir /s /b". If you actually read the documentation (it's right at the top) you knew that this is not possible: "There are many different syntaxes for options; the traditional Unix syntax is a hyphen (“-“) followed by a single letter [...] The GNU project introduced "--" [...] These are the only two option syntaxes provided by optparse. Some other option syntaxes that the world has seen include: [...] a slash followed by a letter, or a few letters, or a word, e.g. "/f", "/file" These option syntaxes are not supported by optparse, and they never will be. This is deliberate: [...] the last only makes sense if you’re exclusively targeting VMS, MS-DOS, and/or Windows." Thorsten Sigh. I used dir /s /b as a simple Windows command with a flag (it could have been dir /s) because it was the first thing that popped into my mind. I had no idea people were going to get so upset that I used a Windows example and go off on a tear. -- http://mail.python.org/mailman/listinfo/python-list
Re: optparse question
I had no idea people were going to get so upset that I used a Windows example and go off on a tear. Nobody is upset, and nobody has "gone off on a tear". The point about the "Windows example" is that the docs say in a close-to-screamingly- obvious manner that /options are not supported, no matter what religion uses them. It was not, and still is not, apparent what you really wanted. We're all patiently waiting for you to rephrase the question(s). Sigh. I used an incorrect example (I sincerely apologize to the world for that egregious error on my part). I''m totally cognizant that the documentation states '-'' or '--' need to be used for flags. The question was it possible to add a simple flag like 'd-' to optparse with no other parameters? I'm guessing from the vitriolic diatribes here that the answer is no. To those who wrote that no one uses command line windows and no one uses 'dir /s /b' command is totally irrelevant. I'm writing a proprietary program used solely by my company. Not everyone writes programs for the same target audience as you do. The program is written in Python on Ubuntu. If you don't want to answer the question or don't have any meaningful to add, please don't pollute the forum with further vacuous responses. I didn't ask, or expect, you to write the code for me. christ on a stick, so many of you behave like prima donnas. -- http://mail.python.org/mailman/listinfo/python-list
Re: optparse question
Peter Otten wrote: Pat wrote: The question was it possible to add a simple flag like 'd-' to optparse with no other parameters? Do you mean "d-" or "-d"? If the latter, what's wrong with Robert Kern's answer? Peter I mean "-d" since that's what Unix commands expect for flags. My sole intention for the "-d" was to put my program into debug mode so that while I'm using the Wing IDE, I can debug my program using just one child process (instead of dozens) without having to change a constant within my program. I haven't figured out a way to debug multiple child processes in Wing. But, I confess, I haven't been very vigorous in learning how. My other intention was to learn the optparse module just for the sake of learning. -- http://mail.python.org/mailman/listinfo/python-list
Re: len()
Tobiah wrote: Just out of curiosity, why was len() made to be it's own function? I often find myself typing things like my_list.len before I catch myself. Thanks, Toby I'm surprised that no one responded to that question. I keep making that mistake all the time myself. -- http://mail.python.org/mailman/listinfo/python-list
Re: len()
Andreas Waldenburger wrote: On Sat, 31 Jan 2009 13:27:02 -0500 Pat wrote: Tobiah wrote: Just out of curiosity, why was len() made to be it's own function? I often find myself typing things like my_list.len before I catch myself. Thanks, Toby I'm surprised that no one responded to that question. Huh? Gabriel Genellina replied about 46 minutes after it was posted. Might it be that your newsserver is a bit laggy? regards /W Might be laggy. Who knows. Why didn't you answer the len() question? -- http://mail.python.org/mailman/listinfo/python-list
Re: len()
Gabriel Genellina wrote: En Wed, 04 Feb 2009 12:38:04 -0200, Pat escribió: Andreas Waldenburger wrote: On Sat, 31 Jan 2009 13:27:02 -0500 Pat wrote: Tobiah wrote: Just out of curiosity, why was len() made to be it's own function? I often find myself typing things like my_list.len before I catch myself. I'm surprised that no one responded to that question. Huh? Gabriel Genellina replied about 46 minutes after it was posted. Might it be that your newsserver is a bit laggy? Might be laggy. Who knows. Why didn't you answer the len() question? Why should he? Why didn't you look for the answer yourself, after being told that it existed? Why do you expect *us* to repeat ourselves again and again? Don't be so lazy... Why do *us* feel obligated to respond? Is there a gun pointed at your heads forcing to giving a bellicose responses? Who is this *us*? A secret society? An exclusive club? New rule: If you don't like a question or a post, simply ignore it. We don't enjoy your snarky repartee. -- http://mail.python.org/mailman/listinfo/python-list
Re: len()
Terry Reedy wrote: Pat wrote: Andreas Waldenburger wrote: On Sat, 31 Jan 2009 13:27:02 -0500 Pat wrote: Tobiah wrote: Just out of curiosity, why was len() made to be it's own function? I often find myself typing things like my_list.len before I catch myself. Thanks, Toby I'm surprised that no one responded to that question. Huh? Gabriel Genellina replied about 46 minutes after it was posted. Might it be that your newsserver is a bit laggy? regards /W Might be laggy. Who knows. Why didn't you answer the len() question? I didn't respond because it has been asked and answered before, so the answer can be found in the google archives or even maybe the FAQ. Yes, you did respond. Aren't you the one who wrote "Might be laggy"? If you didn't feel like answering the question, why did you add an utterly worthless post? -- http://mail.python.org/mailman/listinfo/python-list
Re: lint for Python?
Bruno Desthuilliers wrote: Pat a écrit : I've been searching for a good multi-module lint checker for Python and I haven't found one yet. Pylint does a decent job at checking for errors only within a single module. Here's one of my problems. I have two modules. In module one, I have a function: def foo( host, userid, password ): pass In module two, I call that function: foo( userid, password) lint doesn't find that error Nope, but even the most simple manual test should find it pretty quick. and it won't be caught until it's called while the program is running. I don't want that error found at 3AM. Don't you ever test your code ??? I've never used a language that didn't catch that type of error. It does. Just try to run your code, and you'll have a nice traceback. Unless of course 'foo' is rebound in module two to another callable expecting only two parameters... I'm quite surprised that Python is being used by a number of major companies. Perhaps do they rely more on testing and less on the compiler ? FWIW, I've seen my share of bugs in declarativly statically typed languages, and most of them were way nastier (and way less obvious) than the above one. How you catch these types of errors? Just like any other type of errors : testing, testing, and then add some more tests. I haven't gotten into unittesting. I've just started learning Python. It also dawned on me why my original question is a bit lame. Python supports default arguments; something that is new to me. How could lint possibly know the correct number of arguments passed to it? Unless, of course, lint knew which functions had default arguments or not. I'll come back with more intelligent questions after I've actually learned some Python. -- http://mail.python.org/mailman/listinfo/python-list
Array of dict or lists or ....?
I can't figure out how to set up a Python data structure to read in data that looks something like this (albeit somewhat simplified and contrived): States Counties Schools Classes Max Allowed Students Current enrolled Students Nebraska, Wabash, Newville, Math, 20, 0 Nebraska, Wabash, Newville, Gym, 400, 0 Nebraska, Tingo, Newfille, Gym, 400, 0 Ohio, Dinger, OldSchool, English, 10, 0 With each line I read in, I would create a hash entry and increment the number of enrolled students. I wrote a routine in Perl using arrays of hash tables (but the syntax was a bear) that allowed me to read in the data and with those arrays of hash tables to arrays of hash tables almost everything was dynamically assigned. I was able to fill in the hash tables and determine if any school class (e.g. Gym) had exceeded the number of max students or if no students had enrolled. No, this is not a classroom project. I really need this for my job. I'm converting my Perl program to Python and this portion has me stumped. The reason why I'm converting a perfectly working program is because no one else knows Perl or Python either (but I believe that someone new would learn Python quicker than Perl) and the Perl program has become huge and is continuously growing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Array of dict or lists or ....?
Dennis Lee Bieber wrote: On Mon, 06 Oct 2008 19:45:07 -0400, Pat <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: I can't figure out how to set up a Python data structure to read in data that looks something like this (albeit somewhat simplified and contrived): States Counties Schools Classes Max Allowed Students Current enrolled Students Nebraska, Wabash, Newville, Math, 20, 0 Nebraska, Wabash, Newville, Gym, 400, 0 Nebraska, Tingo, Newfille, Gym, 400, 0 Ohio, Dinger, OldSchool, English, 10, 0 The structure looks more suited to a database -- maybe SQLite since the interface is supplied with the newer versions of Python (and available for older versions). I don't understand why I need a database when it should just be a matter of defining the data structure. I used a fictional example to make it easier to (hopefully) convey how the data is laid out. One of the routines in the actual program checks a few thousand computers to verify that certain processes are running. I didn't want to complicate my original question by going through all of the gory details (multiple userids running many processes with some of the processes having the same name). To save time, I fork a process for each computer that I'm checking. It seems to me that banging away at a database would greatly slow down the program and make the program more complicated. The Perl routine works fine and I'd like to emulate that behavior but since I've just starting learning Python I don't know the syntax for designing the data structure. I would really appreciate it if someone could point me in the right direction. -- http://mail.python.org/mailman/listinfo/python-list
Append a new value to dict
I know it's not "fair" to compare language features, but it seems to me (a Python newbie) that appending a new key/value to a dict in Python is awfully cumbersome. In Python, this is the best code I could come up with for adding a new key, value to a dict mytable.setdefault( k, [] ).append( v ) In Perl, the code looks like this: $h{ $key } = $value ; Is there a better/easier way to code this in Python than the obtuse/arcane setdefault code? -- http://mail.python.org/mailman/listinfo/python-list
Re: Append a new value to dict
Pat wrote: I know it's not "fair" to compare language features, but it seems to me (a Python newbie) that appending a new key/value to a dict in Python is awfully cumbersome. In Python, this is the best code I could come up with for adding a new key, value to a dict mytable.setdefault( k, [] ).append( v ) In Perl, the code looks like this: $h{ $key } = $value ; Is there a better/easier way to code this in Python than the obtuse/arcane setdefault code? Naturally, right after writing my post I found that there is an easier way: table[ k ] = v I found that in "Python for Dummies". How apropos. -- http://mail.python.org/mailman/listinfo/python-list
Re: Append a new value to dict
paul wrote: Pat schrieb: I know it's not "fair" to compare language features, but it seems to me (a Python newbie) that appending a new key/value to a dict in Python is awfully cumbersome. In Python, this is the best code I could come up with for adding a new key, value to a dict mytable.setdefault( k, [] ).append( v ) In Perl, the code looks like this: $h{ $key } = $value ; Whats wrong with: mytable[key] = value cheers Paul mytable[key] = value is the code that I wound up using. It's obvious now that I know the answer. Thank you very much to all for your help. In a earlier question (I can't find the thread in my newsreader), I asked about an array of dict to dict and someone supplied me with the answer. [state]={} [state][city]={} ['Florida']['Tampa] = 20 It worked out perfectly and the Python code is a billion times easier to read than the Perl version. Of all the languages I've learned and used professionally, I'm finding Python to be one of the best languages to learn and use. Having Wing IDE Pro has made it a lot easier for me to learn and debug. It does have a few bugs but they always respond by email within several hours. Absolutely superb customer support. And no, I'm in no way affiliated with Wingware except that I'm a satisfied customer. -- http://mail.python.org/mailman/listinfo/python-list
Re: regular expression question (re module)
Faheem Mitha wrote: Hi, I need to match a string of the form capital_letter underscore capital_letter number against a string of the form anything capital_letter underscore capital_letter number some_stuff_not_starting with a number DUKE1_plateD_A12.CEL. Thanks in advance. Please cc me with any reply. Faheem. While I can't provide you with an answer, I can say that I've been using RegExBuddy (for Windows, about $40, 90 day money back guarantee, http://www.regexbuddy.com/) for quite a few months now and it's greatly helped me with creating/learning/debugging regexps. You put in your regexp in the top field and all the possibilities in the bottom field. Whatever matches is instantly highlighted. You keep modifying your RE until only the correct matches are highlighted. Talk about instant gratification! No, I'm in no way affiliated with this company. There's also a free *IX version that's quite similar to RegExBuddy but I don't have the name since I'm writing this while on a Windows platform. -- http://mail.python.org/mailman/listinfo/python-list
Re: python debugger tips?
[EMAIL PROTECTED] wrote: Hi All, I'm switching to python from perl, and like the language a ton, but I find pdb and pydb to be vastly inferior debuggers to the perl version. In particular, I've grown very used to stepping into arbitrary functions interactively. For instance, in perl you can do this: Does anyone have advice on any macros or something that i could use to do this? Additionally, what do people recommend as good "advanced" python debugger guides? Explaining breakpoints and all is useful, but I really want to know how to make sophisticated macros and interact with the debugger from the interactive prompt. Thanks! Y I'd strongly recommend you try Wing Pro IDE (Windows or *IX) http://wingware.com/ Free 30 day trial (10 days at a time). You can download and fully use the program (it's not crippled) without having to use a credit card. $179/user/operating system. Absolutely great for debugging code. You can take chunks of code and put into the integrated Python shell (a Wing pane) and test it out. As I'm writing code, I test out each line then blocks of code. While running the program, the integrated Python shell recognizes your variables and you can modify them on the fly. I found Eclipse to be inscrutable for Python but I was able to understand and use Wing within an hour or so. There's a free showmedo.com video of the Wing IDE (http://showmedo.com/videos/video?name=pythonOzsvaldWingIDEIntro) Wing IDE Pro is missing some features that Eclipse has but I thought that Wing was so much better than Eclipse that I paid for Wing Pro. The license allowed me to put it on my home and work computers. I am in no way affiliated with the company except that I'm a very satisfied customer. -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHON WORKING WITH PERL ??
Sean DiZazzo wrote: On Sep 29, 12:44 pm, "Blubaugh, David A." <[EMAIL PROTECTED]> wrote: Sir, You are absolutely correct. I was praying to G_d I did not have to slaughter my project's source code in this manner. However, like life itself, I was given legacy source code (i.e. someone else errors to fix) in Perl. However, I have just found out that there is a way to import the Perl interpreter within Python!!! I now believe I can utilize python as the main platform to develop the project upon !! Thanks, David -Original Message- From: D'Arcy J.M. Cain [mailto:[EMAIL PROTECTED] Sent: Monday, September 29, 2008 1:32 PM To: Blubaugh, David A. Cc: [EMAIL PROTECTED] Subject: Re: PYTHON WORKING WITH PERL ?? On Mon, 29 Sep 2008 13:16:14 -0400 "Blubaugh, David A." <[EMAIL PROTECTED]> wrote: I was wondering if it was possible to have a situation where a programming project would utilized BOTH python and perl? Such as utilizing python for internet programming and then utilize perl for text processing and systems programming? Is this even feasible??? I don't see why not but I also question if it is a good idea. Once you have all your objects and low level methods written in Python it just makes sense to re-use them rather than trying to duplicate the functionality in another language. Of course, sometimes we don't have control over our entire environment so yes, you can mix them if you have to. Rewrite everything in python. Save yourself now...while you still can. ~Sean Trust me. Sean is absolutely correct. I'm currently in the process of converting a large Perl project to Python (and learning Python at the same time) and the improvement in code is incredible. After you learn Python, you'll come to despise Perl. -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE Question
Steve Phillips wrote: Hi All, I am just wondering what seems to be the most popular IDE. The reason I ask is I am currently at war with myself when it comes to IDE's. It seems like every one I find and try out has something in it that others don't and viceversa. I am in search for the perfect IDE and after many months of searching, I always come back to IDLE to do what I need to do. I want to use Komodo badly but the one issue I have with that is sometimes the auto-complete works and other times it doesn't. Even if I carbon copy a script. Thanks in advance, Steve P I've been using Wing IDE Pro for about a month or two and I'm very satisfied with it. Is it "perfect"? No. However, I've been communicating the developers on some of the minor shortcomings of Wing and they've been extremely responsive. I usually get a return email within a few hours sometimes minutes. The nice thing is that you can download and try a completely non-crippled version for 30 days (10 days at a time). What I particularly like about it is that it's for Python only. I find Wing much easier to use than Eclipse and, thankfully, it's not written in Java which seems to takes Eclipse all day to load. The integrated Python shell recognizes your variables so while you're debugging you can interact with your code. I could go on, but I've got to get back to work. -- http://mail.python.org/mailman/listinfo/python-list
regexp in Python (from Perl)
I have a regexp in Perl that converts the last digit of an ip address to '9'. This is a very particular case so I don't want to go off on a tangent of IP octets. ( my $s = $str ) =~ s/((\d+\.){3})\d+/${1}9/ ; While I can do this in Python which accomplishes the same thing: ip = ip[ :-1 ] ip =+ '9' I'm more interested, for my own edification in non-trivial cases, in how one would convert the Perl RE to a Python RE that use groups. I am somewhat familiar using the group method from the re package but I wanted to know if there was a one-line solution. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
re.search over a list
While I can use a for loop looking for a match on a list, I was wondering if there was a one-liner way. In particular, one of my RE's looks like this '^somestring$' so I can't just do this: re.search( '^somestring$', str( mylist ) ) I'm not smart enough (total newbie) to code up a generator expression and I was wondering if I'm missing something obvious. I love succinct but clearly understandable code. thx! -- http://mail.python.org/mailman/listinfo/python-list
Re: re.search over a list
Bruno Desthuilliers wrote: Pat a écrit : While I can use a for loop looking for a match on a list, I was wondering if there was a one-liner way. In particular, one of my RE's looks like this '^somestring$' so I can't just do this: re.search( '^somestring$', str( mylist ) ) I'm not smart enough (total newbie) to code up a generator expression and I was wondering if I'm missing something obvious. words = ['foo', 'bar', 'somestring', 'baaz'] re.search(r"^somestring$", "\n".join(words), re.MULTILINE) I love succinct but clearly understandable code. separator.join(sequence_of_strings) is a very common python idiom, so you can consider it as readable. That's excellent. Exactly what I was looking for. Thank you VERY much! -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp in Python (from Perl)
Bruno Desthuilliers wrote: Pat a écrit : I have a regexp in Perl that converts the last digit of an ip address to '9'. This is a very particular case so I don't want to go off on a tangent of IP octets. ( my $s = $str ) =~ s/((\d+\.){3})\d+/${1}9/ ; While I can do this in Python which accomplishes the same thing: ip = ip[ :-1 ] ip =+ '9' or: ip = ip[:-1]+"9" Yes! That's exactly what I was looking for. I'm more interested, for my own edification in non-trivial cases, in how one would convert the Perl RE to a Python RE that use groups. I am somewhat familiar using the group method from the re package but I wanted to know if there was a one-line solution. Is that what you want ? >>> re.sub(r'^(((\d+)\.){3})\d+$', "\g<1>9", "192.168.1.1") '192.168.1.9' re.sub(r'^(((\d+)\.){3})\d+$', "\g<1>9", "192.168.1.100") '192.168.1.9' Ah-hah! That's how one uses groups. It's beautiful. I couldn't find that in my books. Thank you very, very much! At first, I thought that using RE's in Python was going to be more difficult than Perl. A lot of my Perl code makes heavy use of RE searching and substitution. I will never, ever write another line of Perl code as long as I live. -- http://mail.python.org/mailman/listinfo/python-list
question regarding list comprehensions
I have written chunks of Python code that look this: new_array = [] for a in array: if not len( a ): continue new_array.append( a ) and... string = "" for r in results: if not r.startswith( '#' ): string =+ r It seems that a list comprehension could clean up the code, but I seem to have a mental block on list comprehensions. I've read up a lot on this subject in my books and on the Internet and for whatever reason, I'm having problems with this idiom (if that's the correct expression). I've made a number of attempts to solve this on my own but I keep getting errors. Could someone please tell me how I could convert the above code to something more elegant but readily understandable? Finally, if someone could point me to a good tutorial or explain list compressions I would be forever in your debt. -- http://mail.python.org/mailman/listinfo/python-list
Re: question regarding list comprehensions
Steven D'Aprano wrote: On Mon, 20 Oct 2008 10:20:03 -0400, Pat wrote: Finally, if someone could point me to a good tutorial or explain list compressions I would be forever in your debt. Think of a for-loop: for x in (1, 2, 3): x Creates x=1, then x=2, then x=3. It doesn't do anything with the x's, but just creates them. Let's turn it into a list comp, and collect the x's: [x for x in (1, 2, 3)] [1, 2, 3] for x in (1, 2, 3): 2*x+1 Creates x=1, then evaluates 2*x+1 = 3. Then it repeats for x=2, then x=3. Here it is as a list comp: [2*x+1 for x in (1, 2, 3)] [3, 5, 7] for x in (1, 2, 3): if x != 2: 2*x+1 Here it is as a list comp: [2*x+1 for x in (1, 2, 3) if x != 2] [3, 7] You can use any sort of sequence inside a list comp, not just a tuple. [c.upper() for c in "abcd"] ['A', 'B', 'C', 'D'] You can nest list comps: [y+1 for y in [2*x+1 for x in (1, 2, 3)]] [4, 6, 8] Advanced: you can use tuple-unpacking: [(y,x) for (x,y) in [(1,2), (3, 4)]] [(2, 1), (4, 3)] and also multiple for-loops: [(x,c) for x in (1, 2) for c in "abc"] [(1, 'a'), (1, 'b'), (1, 'c'), (2, 'a'), (2, 'b'), (2, 'c')] That last one is close to: for x in (1, 2): for c in "abc": (x, c) Thank you. I think that clears up the mystery a bit. I added your note to my snippets file. When I have a situation that I can't resolve, I'll ask with the specifics. I really do try to learn this as much as possible on my own without just flinging a question onto the forum. -- http://mail.python.org/mailman/listinfo/python-list
Re: question regarding list comprehensions
Diez B. Roggisch wrote: Pat wrote: I have written chunks of Python code that look this: new_array = [] for a in array: if not len( a ): continue new_array.append( a ) new_array = [a for a in array if len(a)] and... string = "" for r in results: if not r.startswith( '#' ): string =+ r "".join(r for r in results if not r.startswith("#")) Diez Thank you very much! That's exactly what I was looking for. That's much cleaner than my code. This is a great forum and I really appreciate everyone's help. -- http://mail.python.org/mailman/listinfo/python-list
Question about scope
I have a Globals class. In it, I have a variable defined something like this: remote_device_enabled = bool In one module, I assign True/False to Globals.remote_device_enabled. Once set, this value never changes. In another module, at the top after the imports statements, I tried this: from Globals import * RDE = Globals.remote_device_enabled This way, I thought that I could just use 'if RDE:' Within the functions, however, I get a different value. What am I misunderstanding? I tried this at the top of the module (but it didn't word): global RDE RDE = Globals.remote_device_enabled Of course, within a function, the variable using the same two lines of code assigns the correct value to RDE. Thank you, Total Newbie -- http://mail.python.org/mailman/listinfo/python-list
Re: re.search over a list
Bruno Desthuilliers wrote: Pat a écrit : Bruno Desthuilliers wrote: Pat a écrit : While I can use a for loop looking for a match on a list, I was wondering if there was a one-liner way. In particular, one of my RE's looks like this '^somestring$' so I can't just do this: re.search( '^somestring$', str( mylist ) ) I'm not smart enough (total newbie) to code up a generator expression and I was wondering if I'm missing something obvious. words = ['foo', 'bar', 'somestring', 'baaz'] re.search(r"^somestring$", "\n".join(words), re.MULTILINE) I love succinct but clearly understandable code. separator.join(sequence_of_strings) is a very common python idiom, so you can consider it as readable. That's excellent. Exactly what I was looking for. Thank you VERY much! Note that at least for this exact case, you don't need re at all: >>> 'somestring' in words True But I guess you do have some less trivial use case !-) I used re because I wanted a string that was not a substring, hence the ^$. In my trivial example, I used words but my intent was to search for words within a longer string. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about scope
Bruno Desthuilliers wrote: Pat a écrit : I have a Globals class. Not sure it's such a great idea, but anyway... What's the use case for this class ? There are perhaps better (or at least more idiomatic) solutions... In it, I have a variable defined something like this: remote_device_enabled = bool Could you show actual code ? It would really help. But it seems your 'Globals' class is mostly 1/ a singleton and 2/ used for application wide settings. Is that right ? In one module, I assign True/False to Globals.remote_device_enabled. Directly to the class ? Please, once again, provide real code. Well... not necessarily your whole code, but at least minimal working code that reproduces the problem. Once set, this value never changes. In another module, at the top after the imports statements, I tried this: from Globals import * The convention is to use lower case names for modules (and MixedCase names for classes). This avoids confusion between synonym classes and modules... RDE = Globals.remote_device_enabled This way, I thought that I could just use 'if RDE:' Within the functions, however, I get a different value. What am I misunderstanding? Not enough informations, and my crystal ball is out for repair. Sorry. Perhaps some actual code may help ?-) I tried this at the top of the module (but it didn't word): global RDE Outside a function body, the 'global' statement is a no-op. In Python, 'global' really means 'module-level', so anything defined at the module level is already as global as it can be. RDE = Globals.remote_device_enabled Of course, within a function, the variable using the same two lines of code assigns the correct value to RDE. Sorry Pat, but there's just not enough context for us to guess what's wrong. It's easy enough to get it wrong with real code, so trying to guess is just a waste of time. Stripping out the extra variables and definitions, this is all that there is. Whether or not this technique is *correct* programming is irrelevant. I simply want to know why scoping doesn't work like I thought it would. ---> myGlobals.py file: class myGlobals(): remote_device_enabled = bool ---> my initialize.py file: from myGlobals import * def initialize(): myGlobals.remote_device_enabled = True ---> my main.py file: import from myGlobals import * RDE = myGlobals.remote_device_enabled def main(): if RDE:# this will not give me the correct value process_device() -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp in Python (from Perl)
Bruno Desthuilliers wrote: MRAB a écrit : On Oct 19, 5:47 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: Pat a écrit : (snip) ip = ip[ :-1 ] ip =+ '9' or: ip = ip[:-1]+"9" (snip) >>> re.sub(r'^(((\d+)\.){3})\d+$', "\g<1>9", "192.168.1.1") '192.168.1.9' re.sub(r'^(((\d+)\.){3})\d+$', "\g<1>9", "192.168.1.100") '192.168.1.9' The regular expression changes the last sequence of digits to "9" ("192.168.1.100" => "192.168.1.9") but the other code replaces the last digit ("192.168.1.100" => "192.168.1.109"). Mmm - yes, true. ip = ".".join(ip.split('.')[0:3] + ['9']) As I first stated, in my very particular case, I knew that the last octet was always going to be a single digit. But I did learn a lot from everyone else's posts for the more generic cases. thx! -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about scope
Steven D'Aprano wrote: On Thu, 23 Oct 2008 11:38:35 -0400, Pat wrote: I have a Globals class. Well, that's your first mistake. Using global variables in a class is no better than using bare global variables. They're still global, and that's a problem: http://weblogs.asp.net/wallen/archive/2003/05/08/6750.aspx It depends upon the situation. In my program, I have one routine that loads a bunch of files and initializes a number of variables. After that, the values in the globals class never change. It's a lot easier to maintain this type of code than to passing the same variables from function to function to function. On the other hand, if multiple functions were willy-nilly changing global variables then globals would be a maintenance nightmare. To unilaterally state that globals are always "evil" borders on a subjective religious conviction. -- http://mail.python.org/mailman/listinfo/python-list
lint for Python?
I've been searching for a good multi-module lint checker for Python and I haven't found one yet. Pylint does a decent job at checking for errors only within a single module. Here's one of my problems. I have two modules. In module one, I have a function: def foo( host, userid, password ): pass In module two, I call that function: foo( userid, password) lint doesn't find that error and it won't be caught until it's called while the program is running. I don't want that error found at 3AM. I've never used a language that didn't catch that type of error. I'm quite surprised that Python is being used by a number of major companies. How you catch these types of errors? I've spoken to tech support at Wing and they weren't aware of a multi-module lint but they're considering putting their own lint into their IDE. Thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: lint for Python?
Miki wrote: Hello, In module one, I have a function: def foo( host, userid, password ): pass In module two, I call that function: foo( userid, password) lint doesn't find that error and it won't be caught until it's called while the program is running. pychecker does find these kind of errors. Before posting my original question, I tried pychecker and it didn't catch that error. I've never used a language that didn't catch that type of error. I'm quite surprised that Python is being used by a number of major companies. How you catch these types of errors? By running a large test suite, I highly recommend "nose". That's something I'll look into after I'm more proficient in Python. Currently, I'm learning my way around Python. Thank you. HTH, -- Miki <[EMAIL PROTECTED]> http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Screen placement based on screen resolution
I am trying to place a dialog in the center of the screen based on a users screen resolution. I can get the width and height of the screen, but I can't seem to use the following: root.geometry('WxH+X+Y') It appears the values for X and Y need to be integers and not a variable like width/2-40 S -- http://mail.python.org/mailman/listinfo/python-list
Re: Screen placement based on screen resolution
Thanks. S "Lonnie Princehouse" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Tkinter takes strings as its arguments; it's TCL's legacy. You can use > string formatting for this: > > x = width/2-40 > y = height/2-30 > > root.geometry('%ldx%ld+%ld+%ld' % (width, height, x, y)) > -- http://mail.python.org/mailman/listinfo/python-list
Re: Screen placement based on screen resolution
Thanks a lot for you response. S "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Pat" <[EMAIL PROTECTED]> wrote: > >> I am trying to place a dialog in the center of the screen based on a >> users >> screen resolution. I can get the width and height of the screen, but I >> can't >> seem to use the following: >> >> root.geometry('WxH+X+Y') >> >> It appears the values for X and Y need to be integers and not a variable >> like width/2-40 > > Python doesn't look in string literals for things that might look > like expressions, but if you have the values, *creating* a string > with the right contents is pretty easy. see the tutorial for the > basics: > >http://docs.python.org/tut/node9.html > > if you have all the values in variables, this expression sets the > geometry in one step: > >root.geometry("%dx%d%+d%+d" % (width, height, xoffset, yoffset)) > > also see > >http://effbot.org/tkinterbook/wm.htm#Tkinter.Wm.geometry-method > > which includes code that parses a geometry string. > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI Problem on MS IIS 5.0 - Trying to access files on other machines
Set the site to be Basic Authentication and login as you. I suspect that the .exe is either running as IWAM/IUSER (i.e. GUEST) or you are running into a double hop issue. Pat "paulp" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Greetings, > > I'm working on a CGI program that will run under MS IIS 5.0 and will > browse folders on three other machines, building HTML pages that will > provide links to these folders. > > Essentially, the CGI will connect to each machine in turn, doing the > FindFirst/FindNext process based on the current criteria. It will > select certain files/folders, and build an HTML page as it goes. > > The premise is fine. If I run the program from the command line, it > seems to work fine and I get my HTML code out. I can copy the code > into a separate file, open it in the browser, and all appears right > with the world. > > However, when I try to run the CGI from the browser itself, I get all > kinds of problems. The first one I got was a 1312, "A specified logon > session does not exist. It may have already been terminated." After > doing some searching, I began to investigate impersonation of a logged > on user. This produces a different error: 1314, "A required privilege > is not held by the client." > > The code involved and the output I'm getting follows: > > -BEGIN-- > class Impersonate: >def __init__(self, login, password ): >self.domain = '4Q9ND21' >self.login = login >self.password = password >self.handel = None >def logon(self): >tracelist.append("Impersonate logon step 0") >win32security.RevertToSelf()# terminates impersonation >tracelist.append("Impersonate logon step 1") >self.handel = win32security.LogonUser( self.login, self.domain, > self.password, win32con.LOGON32_LOGON_INTERACTIVE, > win32con.LOGON32_PROVIDER_DEFAULT ) >tracelist.append("Impersonate logon step 2") >win32security.ImpersonateLoggedOnUser(self.handel) >tracelist.append("Impersonate logon step complete") >def logoff(self): >win32security.RevertToSelf()# terminates impersonation >if self.handel != None: >self.handel.Close() # guarantee cleanup > --END--- > > and I execute this code with the following > > -BEGIN-- >impersonate = Impersonate( 'PYTHONTEST', 'PYTHONTEST' ) >try: >tracelist.append("about to attempt the IMPERSONATE") >impersonate.logon() >tracelist.append("impersonate did NOT throw exception") >b=AdjustPrivilege(SE_SYSTEM_PROFILE_NAME) >b=AdjustPrivilege(SE_TCB_NAME) >try: >tracelist.append("win32api.GetUserName = " + > win32api.GetUserName() ) ># print win32api.GetUserName() #show you're someone else >finally: >impersonate.logoff() #return to normal >except: >a = "Impersonate Logon Error: %s %s" % (sys.exc_type, > sys.exc_value) >tracelist.append(a) ># print sys.exc_type, sys.exc_value > --END--- > > When I run this code, my tracelist comes out with > > -BEGIN-- > 2005-09-15 16:43:37 > about to attempt the IMPERSONATE > Impersonate logon step 0 > Impersonate logon step 1 > Impersonate Logon Error: pywintypes.error (1314, 'LogonUser', 'A required > privilege is not held by the client.') > --END--- > > > I'm coding this in Python 2.4 and the Windows extensions. I have a > number of other CGI programs in Python running under IIS that work > correctly, but those only do database accesses. This one I'm trying to > put together is the first one to actually do file searches. > > > I have set the privileges for the logged on account on my IIS box for > SE_TCB_NAME, SE_CHANGE_NOTIFY_NAME and SE_ASSIGNPRIMARYTOKEN_NAME and > rebooted. To no avail. I'm not sure if there are additional > alterations that need to be done to the security policies or not. > Again, I'm not a guru. > > > If anyone can give me more information/guidance I would greatly > appreciate it. If you need more information from me, I will do my best > to provide it. > > TIA, > > Paul > > -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI Problem on MS IIS 5.0 - Trying to access files on other machines
Don't change the account IIS is running under - that is a pretty big security issue waiting to happen. Change the authentication model for the web site to Basic, then logon as you. That will cause any execution to be in the security context you are expecting. Pat "paulp" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Based on your comment, I finally realized that IIS is running under the > IUSR_ account. So I changed the priveleges on this account on my test IIS > server as related elsewhere in this note. So now I'm getting a different > error. > > 1326, "LogonUser", "Logon failure: unknown user name or bad password" > > It's progress of a sort. > > My test box is running IIS, and I set up a local test account (PYTHONTEST) > on my primary box. This is the account I'm trying to hook into at the > moment. > > Any thoughts on this? > > Many thanks for your help. > > Paul > > > "Pat [MSFT]" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Set the site to be Basic Authentication and login as you. I suspect that >> the .exe is either running as IWAM/IUSER (i.e. GUEST) or you are running >> into a double hop issue. >> >> >> Pat >> >> "paulp" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> > Greetings, >> > >> > I'm working on a CGI program that will run under MS IIS 5.0 and will >> > browse folders on three other machines, building HTML pages that will >> > provide links to these folders. >> > >> > Essentially, the CGI will connect to each machine in turn, doing the >> > FindFirst/FindNext process based on the current criteria. It will >> > select certain files/folders, and build an HTML page as it goes. >> > >> > The premise is fine. If I run the program from the command line, it >> > seems to work fine and I get my HTML code out. I can copy the code >> > into a separate file, open it in the browser, and all appears right >> > with the world. >> > >> > However, when I try to run the CGI from the browser itself, I get all >> > kinds of problems. The first one I got was a 1312, "A specified logon >> > session does not exist. It may have already been terminated." After >> > doing some searching, I began to investigate impersonation of a logged >> > on user. This produces a different error: 1314, "A required privilege >> > is not held by the client." >> > >> > The code involved and the output I'm getting follows: >> > >> > -BEGIN-- >> > class Impersonate: >> >def __init__(self, login, password ): >> >self.domain = '4Q9ND21' >> >self.login = login >> >self.password = password >> >self.handel = None >> >def logon(self): >> >tracelist.append("Impersonate logon step 0") >> >win32security.RevertToSelf()# terminates impersonation >> >tracelist.append("Impersonate logon step 1") >> >self.handel = win32security.LogonUser( self.login, self.domain, >> > self.password, win32con.LOGON32_LOGON_INTERACTIVE, >> > win32con.LOGON32_PROVIDER_DEFAULT ) >> >tracelist.append("Impersonate logon step 2") >> >win32security.ImpersonateLoggedOnUser(self.handel) >> >tracelist.append("Impersonate logon step complete") >> >def logoff(self): >> >win32security.RevertToSelf()# terminates impersonation >> >if self.handel != None: >> >self.handel.Close() # guarantee cleanup >> > --END--- >> > >> > and I execute this code with the following >> > >> > -BEGIN-- >> >impersonate = Impersonate( 'PYTHONTEST', 'PYTHONTEST' ) >> >try: >> >tracelist.append("about to attempt the IMPERSONATE") >> >impersonate.logon() >> >tracelist.append("impersonate did NOT throw exception") >> >b=AdjustPrivilege(SE_SYSTEM_PROFILE_NAME) >> >b=AdjustPrivilege(SE_TCB_NAME) >> >try: >> >tracelist.append("win32api.GetUserName = " + >> > win32api.GetUserName() ) >> ># print win32api.GetUserName() #show you're someone else >> >finally: >> >
Re: Can one use Python to learn and even apply Functional Programming?
This made me grin. ;) -- https://mail.python.org/mailman/listinfo/python-list
Basic help
Good Day all. I am new to Python. I need to maintain software written on Python 1.5.2. I will upgrade after learning more. My question is : When compiling, the results of the compile is displayed in the "active window". How can I view this window. Many thanks for your assistance. Kind regards Pat -- This message has been scanned for viruses and dangerous content by Pinpoint, and is believed to be clean. -- https://mail.python.org/mailman/listinfo/python-list
Re: JUST GOT HACKED
I don't think you are allowed to use the word dumbass to describe anyone or anything buddy. On Tuesday, October 1, 2013 9:42:31 AM UTC-4, Ferrous Cranus wrote: > Στις 1/10/2013 4:27 μμ, ο/η Chris “Kwpolska” Warrick έγραψε: > > > On Tue, Oct 1, 2013 at 3:15 PM, Νίκος wrote: > > >> Στις 1/10/2013 4:06 μμ, ο/η Mark Lawrence έγραψε: > > >>> > > >>> On 01/10/2013 10:58, Νίκος wrote: > > > > Just logged in via FTP to my server and i saw an uploade file named > > "Warnign html" > > > > Contents were: > > > > WARNING > > > > I am incompetent. Do not hire me! > > > > Question: > > > > WHO AND MOST IMPORTNTANLY HOW DID HE MANAGED TO UPLOAD THIS FILE ON MY > > ACCOUNT? > > > > PLEASE ANSWER ME, I WONT GET MAD, BUT THIS IS AN IMPORTANT SECURITY RISK. > > > > SOMEONES MUST HAVE ACCESS TO MY ACCOUNT, DOES THE SOURCE CODE OF MY MAIN > > PYTHON SCRIPT APPEARS SOMEPLACE AGAIN?!?! > > >>> > > >>> > > >>> Would you please stop posting, I've almost burst my stomach laughing at > > >>> this. You definetely have a ready made career writing comedy. > > >> > > >> > > >> Okey smartass, > > >> > > >> Try to do it again, if you be successfull again i'll even congratulate you > > >> myself. > > >> > > >> -- > > >> https://mail.python.org/mailman/listinfo/python-list > > > > > > It looks like you are accusing someone of doing something without any > > > proof whatsoever. Would you like help with the fallout of the lawsuit > > > that I hope Mark might (should!) come up with?i'am > > > > > > Speaking of “try again”, I doubt it would be hard… As long as a FTP > > > daemon is running somewhere (and you clearly do not know better); or > > > even you have a SSH daemon and you do not know better, an attacker > > > can: > > > > > > a) wait for you to publish your password yet again; > > > b) get you to download an exploit/keylogger/whatever; > > > c) brute-force. > > > > > > Well, considering it’s unlikely you actually have a long-as-shit > > > password, (c) is the best option. Unless your password is very long, > > > in which case is not. > > > > > > I’m also wondering what language your password is in. If you actually > > > used a Greek phrase, how long will it take you to get locked out due > > > to encoding bullshit? > > > > Like i use grek letter for my passwords or like i'am gonna fall for any > > of your 3 dumbass reasons. > > > > I already foudn the weakness and corrected it. -- https://mail.python.org/mailman/listinfo/python-list
Re: JUST GOT HACKED
>From what I gather he was viewing files uploaded to the ftp folder and found >this warning.html file contained within... So my take on it is, someone just >uploaded it and this guy is freaking out making a buffoon out of himself. -- https://mail.python.org/mailman/listinfo/python-list
pyhon 1.5.2 problem
Good Day all, I have the following problem. This is the python code # Import SER # SER.set_speed('115200','8N1') .. .. .. When I run the above code I get the following error : SER.set_speed('115200','8N1') AttributeError : set_speed Can anyone help as this did work before.I have recompiled everything but the problem still Exists. In anticipation, Many Thanks Pat p...@icon.co.za -- This message has been scanned for viruses and dangerous content by Pinpoint, and is believed to be clean. -- https://mail.python.org/mailman/listinfo/python-list
Boa Constructor error: "No section:editor"
Hi, In case you haven't solved this already, the problem seems to be an empty or corrupt config file - \documents and settings\username\.boa-constructor\Explorer.msw.cfg. (at least under windows - don't know where it'd be in linux/elsewhere) When I deleted it, the next invocation of boa worked fine. Good luck! Pat -- http://mail.python.org/mailman/listinfo/python-list
Relative Imports
Hey guys, I know this is a really stupid question, but I've tried googling and nothing came up. I also tried IRC, but it was too crowded and I didn't get much useful information. I'm using Python 2.5 on WinXP, and I'm trying to do a relative import. Here's the package structure A/ __init__.py aneededmodule.py [some more modules] B/ __init__.py anothermodule.py anothermodule.py needs to use aneededmodule.py; package A's __init__.py looks like this: from aneededmodule import somestuff My problem is that when anothermodule tries to import ..aneededmodule or ..somestuff (because somestuff was imported into __init__), I get a ValueError: Attempted relative import in non-package. What's my problem? This seems like something very trivial, but I've never had to use python for a project of this size before, so I've never dealt with this. Thanks for your help, -Pat -- http://mail.python.org/mailman/listinfo/python-list