python library for web discussions
Hi, I'm building something like digg/reddit and would like to allow people to have discussions on various items. Is there a simple lightweight python library that I can use (as opposed to a heavyweight web framework)? Although not necessary, some sort of scoring/moderation mechanism would be good also (e.g., like reddit/slashdot). Amir -- http://mail.python.org/mailman/listinfo/python-list
Re: Have you ever considered of mousing ambidextrously?
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > Scott David Daniels <[EMAIL PROTECTED]> wrote: > >> Roy Smith wrote: >>> I never understood why people switch mouse buttons. I'm left handed, so I >>> put the mouse on the left side of my keyboard. It never occurred to me to >>> flip the buttons around. >> Well, I switch 'em because the "forefinger is primary" is ingrained. > > I do both buttons with my forefinger. It just seems like the normal thing > to do. How do you manage that? Do you keep your finger hovered over the mouse? It seems like quite an effort to move it back and forth between the two buttons, unless you have a smaller mouse. -- http://mail.python.org/mailman/listinfo/python-list
Re: strange math?
[EMAIL PROTECTED] wrote: f(01) > 43 f(02) > 44 f(010) > 50 42+010 > 50 > > The first f(01) was a mistake. I accidentally forgot to delete the > zero, but to my suprise, it yielded the result I expected. So, I tried > it again, and viola, the right answer. So, I decided to really try and > throw it for a loop, f(010), and it produced 50. I expected 52 > (42+10). Why doesn't python ignore the first zero and produce a result > of 52? It ignored the first zero for f(01) and f(02). Hmm. I know, I > know, why am I sending it a 01,02, or a 010 to begin with? Like I > said, it was an accident, but now i'm curious. I'm not a computer > science major so please be kind with any explanations. Number beginning with the digit '0' are octal (base 8), so 010 == 8. 42 + 8 = 50. Numbers beginning with '0x' are base 16. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list
Re: strange math?
Thanks for the great reply, Steve, et al. -j -- http://mail.python.org/mailman/listinfo/python-list
Re: strange math?
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello everyone, I'm experimenting with python and i'm following this > tutorial: > http://docs.python.org/tut/node6.html#SECTION00640 I'm > in section 4.7.5 Lambda Forms. In this section I was working along and > I noticed something strange. It happened because of a typo. Below is > a copy/paste from my idle session: > def make_incrementor(n): > return lambda x: x+n > f=make_incrementor(42) f(0) > 42 f(1) > 43 f(10) > 52 f(0) > 42 f(01) > 43 f(02) > 44 f(010) > 50 42+010 > 50 > > The first f(01) was a mistake. I accidentally forgot to delete the > zero, but to my suprise, it yielded the result I expected. So, I tried > it again, and viola, the right answer. So, I decided to really try and > throw it for a loop, f(010), and it produced 50. I expected 52 > (42+10). Why doesn't python ignore the first zero and produce a result > of 52? That's because python interprets 010 as *octal* 10 which is *decimal* 8. Thus 42+010 = 42+8 = 50 which is quite as it should be... Regards, Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: strange math?
f(01) > 43 f(02) > 44 f(010) > 50 42+010 > 50 Literal ints with lead 0 are interpreted as octal numbers (base 8) instead of decimal numbers (base 10). 01==1 either way, but 010 == 8. >>> 010 8 0x (zero eks) prefix indicate hexadecimal numbers: >>> 0xff 255 Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: strange math?
[EMAIL PROTECTED] wrote: f(01) > 43 f(02) > 44 f(010) > 50 42+010 > 50 > > The first f(01) was a mistake. I accidentally forgot to delete the > zero, but to my suprise, it yielded the result I expected. So, I tried > it again, and viola, the right answer. So, I decided to really try and > throw it for a loop, f(010), and it produced 50. I expected 52 > (42+10). Why doesn't python ignore the first zero and produce a result > of 52? It ignored the first zero for f(01) and f(02). Hmm. I know, I > know, why am I sending it a 01,02, or a 010 to begin with? Like I > said, it was an accident, but now i'm curious. I'm not a computer > science major so please be kind with any explanations. Python isn't ignoring the initial 0. It reads the initial 0 as indicating that the following number is expressed in octal. You can see this if you try any number with a digit higher than 7 in it: >>> 08 Traceback ( File "", line 1 08 ^ SyntaxError: invalid token So you get 8 added to your number when you write 010 because eight is spelled as 10 in octal. The leading-zero notation is unfortunate, and there has been some recent discussion[1][2] on python-dev about trying to change the prefix to ``0o`` or ``0c`` in Python 3.0 but for the moment at least it looks like we're stuck with the confusing leading zero. [1]http://mail.python.org/pipermail/python-dev/2006-January/060262.html [2]http://mail.python.org/pipermail/python-dev/2006-February/060277.html STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I use a conditional in a variable declaration?
[EMAIL PROTECTED] wrote: > I want the equivalent of this: > > if a == "yes": >answer = "go ahead" > else: >answer = "stop" > > in this more compact form: > > a = (if a == "yes": "go ahead": "stop") > > is there such a form in Python? I tried playing around with lambda > expressions, but I couldn't quite get it to work right. Rather than lambda, this merits a named function. You only have to define it once. def mux(s, t, f): if s: return t return f def interpret(a): answer = mux(a == "yes", "go ahead", "stop") print answer interpret("yes")# Prints "go ahead." interpret("no") # Prints "stop." -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
OK, a bad case of RTFM. I saved your file as WildCartesian.hs and then 1) command line: ghci WildCartesian.hs 2) Get some loading messages 3) command line: test and it works! But how do I compile it to get a program with command line arguments? I'm looking through Daume's tutorial right now. -- http://mail.python.org/mailman/listinfo/python-list
strange math?
Hello everyone, I'm experimenting with python and i'm following this tutorial: http://docs.python.org/tut/node6.html#SECTION00640 I'm in section 4.7.5 Lambda Forms. In this section I was working along and I noticed something strange. It happened because of a typo. Below is a copy/paste from my idle session: >>>def make_incrementor(n): return lambda x: x+n >>>f=make_incrementor(42) >>>f(0) 42 >>>f(1) 43 >>>f(10) 52 >>>f(0) 42 >>>f(01) 43 >>>f(02) 44 >>>f(010) 50 >>>42+010 50 The first f(01) was a mistake. I accidentally forgot to delete the zero, but to my suprise, it yielded the result I expected. So, I tried it again, and viola, the right answer. So, I decided to really try and throw it for a loop, f(010), and it produced 50. I expected 52 (42+10). Why doesn't python ignore the first zero and produce a result of 52? It ignored the first zero for f(01) and f(02). Hmm. I know, I know, why am I sending it a 01,02, or a 010 to begin with? Like I said, it was an accident, but now i'm curious. I'm not a computer science major so please be kind with any explanations. -- http://mail.python.org/mailman/listinfo/python-list
Re: Have you ever considered of mousing ambidextrously?
In article <[EMAIL PROTECTED]>, Roy Smith <[EMAIL PROTECTED]> wrote: > >I never understood why people switch mouse buttons. I'm left handed, >so I put the mouse on the left side of my keyboard. It never occurred >to me to flip the buttons around. Heh. When possible, my work situation includes two computers, each with their own keyboard and mouse. To put the keyboards as close together as possible, the mice go on the outside. I generally flip the buttons on the left-hand mouse. That way I'm using the "same" fingers on both mice. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "19. A language that doesn't affect the way you think about programming, is not worth knowing." --Alan Perlis -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I use a conditional in a variable declaration?
On 2006-03-19, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I want the equivalent of this: > > if a == "yes": >answer = "go ahead" > else: >answer = "stop" If that's what you want, then write that. ;) -- [EMAIL PROTECTED] Grant Edwards -- http://mail.python.org/mailman/listinfo/python-list
Re: Need design advice. What's my best approach for storing this data?
Mudcat wrote: > In doing a little research I ran across PyTables, which according to > the documentation does this: "PyTables is a hierarchical database > package designed to efficiently manage very large amounts of data." It > also deals with compression and various other handy things. Zope also > seems to be designed to handle large amounts of data with compression > in mind. > > Does any know which of these two apps would better fit my purpose? I > don't know if either of these has limitations that might not work out > well for what I'm trying to do. I really need to try and compress the > data as much as possible without making the access times really slow. PyTables is exactly suited to storing large amounts of numerical data aranged in tables and arrays. The ZODB is not. -- Robert Kern [EMAIL PROTECTED] "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations
On Sun, 19 Mar 2006 02:08:11 GMT, Tim Roberts <[EMAIL PROTECTED]> wrote, quoted or indirectly quoted someone who said : >Try pressing Ctrl-R when his message is visible. I'm also using Agent, and >that toggles his extended characters from quoted-printable to visible for >me. that swaps fixed and variable pitch fonts. I gather you have one of your fonts configured without many chars in it. -- Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I use a conditional in a variable declaration?
[EMAIL PROTECTED] writes: > a = (if a == "yes": "go ahead": "stop") > > is there such a form in Python? I tried playing around with lambda > expressions, but I couldn't quite get it to work right. This has been the subject of huge debate over the years. The answer is Python doesn't currently have it, but it will be added to a coming version: See http://www.python.org/doc/peps/pep-0308/ To do it in the most general way with lambda expressions, use (untested): a = (lambda: iffalse_expression, lambda: iftrue_expression)[bool(condition)]() That makes sure that only one of the target expressions gets evaluated (they might have side effects). There are various more common idioms like a = (condition and iftrue_expression) or iffalse_expression which can go wrong and evaluate both expressions. It was a bug caused by something like this that led to conditional expressions finally being accepted into Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I use a conditional in a variable declaration?
Kent - Thanks for the quick reply. I tried the and/or trick - it does work. But you're right - more trouble than its worth So for now, I did it "the long way". It looks like (see below), this functionality will be added in soon. Thanks for the quick help. -sam -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I use a conditional in a variable declaration?
[EMAIL PROTECTED] wrote: > I've done this in Scheme, but I'm not sure I can in Python. > > I want the equivalent of this: > > if a == "yes": >answer = "go ahead" > else: >answer = "stop" > > in this more compact form: > > > a = (if a == "yes": "go ahead": "stop") > > > is there such a form in Python? I tried playing around with lambda > expressions, but I couldn't quite get it to work right. There will be, in Python 2.5 (final release scheduled for August 2006): >>> answer = "go ahead" if a=="yes" else "stop" See: http://mail.python.org/pipermail/python-dev/2005-September/056846.html http://www.python.org/doc/peps/pep-0308/ --Ben -- http://mail.python.org/mailman/listinfo/python-list
Re: Need design advice. What's my best approach for storing this data?
In doing a little research I ran across PyTables, which according to the documentation does this: "PyTables is a hierarchical database package designed to efficiently manage very large amounts of data." It also deals with compression and various other handy things. Zope also seems to be designed to handle large amounts of data with compression in mind. Does any know which of these two apps would better fit my purpose? I don't know if either of these has limitations that might not work out well for what I'm trying to do. I really need to try and compress the data as much as possible without making the access times really slow. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I use a conditional in a variable declaration?
[EMAIL PROTECTED] wrote: > I want the equivalent of this: > > if a == "yes": >answer = "go ahead" > else: >answer = "stop" > > in this more compact form: > > > a = (if a == "yes": "go ahead": "stop") If the value for the 'true' case can never have a boolean value of False, you can use this form: a = (a == "yes") and "go ahead" or "stop" The short-circuit evaluation of 'and' and 'or' give the correct result. This will not work correctly because the 'and' will always evaluate to "" which is False so the last term will be evaluated and returned: a = (a == "yes") and "" or "stop" and IMO the extra syntax needed to fix it isn't worth the trouble; just spell out the if / else. Kent -- http://mail.python.org/mailman/listinfo/python-list
Can I use a conditional in a variable declaration?
I've done this in Scheme, but I'm not sure I can in Python. I want the equivalent of this: if a == "yes": answer = "go ahead" else: answer = "stop" in this more compact form: a = (if a == "yes": "go ahead": "stop") is there such a form in Python? I tried playing around with lambda expressions, but I couldn't quite get it to work right. -- http://mail.python.org/mailman/listinfo/python-list
Re: POP3 Mail Download
Bob Piton wrote: > I think what he is hinting at is that you are missing a right parentheses. > > msgNum = int(split(msg, " ")[0] > should be: > msgNum = int(split(msg, " "))[0] Or more likely: msgNum = int(split(msg, " ")[0]) > msgSize = int(split(msg, " ")[1] > should be: > msgSize = int(split(msg, " "))[1] Similarly: msgSize = int(split(msg, " ")[0]) More readably: msgNum, msgSize = [int(text) for text in split(msg, " ")[:2]] > Now if only somebody would tell me, with elementary examples, how you > write to the thing called 'stdout' and how you read from 'stdin'. import sys print 'parrot' # writes to sys.stdout print >>None, 'limburger' # Also writes to sys.stdout print >>sys.stdout, 'roquefort' # Also writes to sys.stdout sys.stdout.write('Shropshire -- the cheese of the gods\n) # Also oneline = raw_input('prompt: ') # reads from sys.stdin for line in sys.stdin: # reads line from sys.stdin print 'The current line is: %r' % line if not line.strip(): break chunk = sys.stdin.read(23) # reads a series of bytes from sys.stdin Warning: idle does not implement line iteration as in the for loop. Also the read in both line iteration and .read(N) may well read the input in "block mode", so you may have to type-ahead or end with an end-of-file (^D for Unix, ^Z for Windows) before it starts processing the lines. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: POP3 Mail Download
Bob Piton wrote: > On Sat, 18 Mar 2006 18:34:56 -0500, Kevin F wrote: >>i have no idea what you are hinting at, can you please just tell me what i >>need to change? > > > I know how you feel; it's brutal trying to get elementary information from > this group. You could try the python-tutor list, it tends to give more focused answers to newbie questions than this group, which is pretty newbie-friendly but does have a tendency to veer widely from the original question. > Now if only somebody would tell me, with elementary examples, how you > write to the thing called 'stdout' and how you read from 'stdin'. raw_input() prompts to stdout and reads from stdin. print outputs to stdout: In [53]: print raw_input('What is your name? ') What is your name? Kent Kent or import sys and use sys.stdin and sys.stdout. Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets
John Machin wrote: > On 19/03/2006 8:31 AM, Kent Johnson wrote: >>How does xlrd compare with pyexcelerator? At a glance they look pretty >>similar. >> > > I have an obvious bias, so I'll just leave you with a not-very-PC > analogy to think about: > > Depending on the ambient light and the quantity of mead drunk in the > hall, Helen of Troy and Grendel's mum might at a glance look pretty > similar, too. Perhaps a more thorough investigation is needed. What > about your requirements: a partner for the graduation ball, or someone > to lift the truck off you when the jack collapses? That didn't shed much light. I'm interested in your biased opinion, certainly you must have had a reason to write a new package. I don't have current requirements for this, I'm curious. Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Python compiler
"Rc" wrote in message news:[EMAIL PROTECTED] > it is a Dos Window > that opened.I think it is not possible on a XP computer? In XP, it is called a Command Prompt (window). You can get one without Python by looking under All Programs / Accessories. It is similar to the Win 9X 'Dos Window'. But has a much bigger scrollback capacity. But I now use IDLE which has a Python Shell window that simulates the Command Prompt window but is much easier to cut from (to paste into postings, for instance). Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Have you ever considered of mousing ambidextrously?
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > Scott David Daniels <[EMAIL PROTECTED]> wrote: > >> Roy Smith wrote: >>> I never understood why people switch mouse buttons. I'm left handed, so I >>> put the mouse on the left side of my keyboard. It never occurred to me to >>> flip the buttons around. >> Well, I switch 'em because the "forefinger is primary" is ingrained. > > I do both buttons with my forefinger. It just seems like the normal thing > to do. A, but if you had been around when "chording" was practiced (a technique that makes no sense with less than 3 buttons), you would have been used to having to have pairs of buttons down at a time. With that style, it does make a difference which button the forefinger is over. -- -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Adding instance attributes to types
I have written a C module which implements a new Python type, and implemented data attributes for the type using PyGetSetDef/tp_getset. However, I want to allow instances of this type to have additional data attributes which also have get() and set() functions. (This might be better suited to use inherited classes or types, but the differences would be very minor). Is this possible? -- http://mail.python.org/mailman/listinfo/python-list
ANN: consensus 0.1.1 - Collaborative filtering library for Python
Last night was the first release of a new (maybe the only?) collaborative filtering library in Python. www: http://exogen.case.edu/projects/consensus/ pypi: http://python.org/pypi/consensus/0.1.1 svn: svn://exogen.case.edu/consensus/tags/0.1.1 consensus currently includes three collaborative filtering models: vector distance, simple similarity, and constrained Pearson correlation. Several additional models are in development, as well as improvements to the current models. # Usage Adapting the rating histories of users to fit into consensus is simple: feed is a dictionary mapping any unique user object (usernames, id numbers, your own hashable user class) to a dictionary mapping items that user has rated to their rating for each item. # Examples In the repository you'll find a real-world example of using consensus: recommending songs based on the listening histories of AudioScrobbler users. A 1,000 user dataset is included and demonstrates how easy it is to make suggestions. The recommendations we've seen so far look pretty good. # Feedback This is the first release, so feedback is welcome and encouraged. We're currently looking into making a better interface to our classes to support models that rely on caching, etc. -- Brian Beck Adventurer of the First Order -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can we find top-notch python developers?
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Alex Martelli) wrote: > Unfortunately, I entirely understand _why_ most software development > firms prefer face-to-face employees: when I found myself, back when I > was a freelance consultant, alternatively working remotely for some > time, and at the client's office for another part of the time, I saw my > productivity soar by 3-4 times when I was working locally, physically > right next to the rest of the team, rather than remotely Actually, it's a quadratic problem. If your productivity goes up N-fold by having face time with your co-workers, consider also that your co-workers' productivity also goes up N-fold by having face time with you. For the most part I find coding to be a solitary activity (unless I'm doing pair programming, but that's another post). Face time is good for design, code review, and solving problems. It's also good for catching snippets of conversations which aren't directly related to what you're doing but keep you in the big-picture loop anyway. Most of the really good design work I've been involved in has happened during random spontaneous hallway discussions. You start with, "Hey, Joe, what do you think about ...?", then you go find an empty room with a whiteboard, and a couple of hours later, you've both earned your salaries for the month. Sometimes, somebody who you didn't even think knew anything about the topic of discussion will notice what you're drawing on the board and contribute what turns out to be the winning idea. That's really hard to do when working remotely (even if you're both in the same time zone, let alone 5, or 8, or 12 hours apart). I find my most productive way of working is to come into the office every day and appear to get nothing useful done. I go to meetings, schmooze, argue, eat lunch with co-workers, try to sell my ideas to anybody who I can get to listen, and deal with bureaucratic stupidity. Then I got home and get in a good 3 or 4 solid hours of coding where there's nobody to bother me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there no end to Python?
"Jeffrey Schwab" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Sorry, that came out a lot ruder than I meant it. There has been much worse here, and even more in other groups... > I've always heard that Python was extremely easy to learn. I'm still > fairly new to the language, though (2.2), and I have not found it any > easier to learn than Perl or Ruby. It's great that all these new > features have been added, but if I want power at the expense of > intuitive language constructs, I'll stick to C++. Guido is not completely oblivious to complexification versus ease of learning. The problem at present is that 2.5 will have most of the additions that have been planned for 3.0 but, for back-compatibility, few of the deletions and simplifications. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: How to run SimpleHTTPServer on IronPython on Mono
Paul Boddie wrote: > Sanghyeon Seo wrote: > > The purpose of this document is twofold: to show how to run > > SimpleHTTPServer on IronPython on Mono, and to debunk some myths like: > > > > * IronPython doesn't run on Mono > > But it does require recent versions, according to the document. > Requiring the latest stuff straight from the revision control > repository is always an inhibiting factor in the adoption of software. Yes, it's unfortunate, as I wrote on the howto myself. Of course, you can use released version of MS.NET for easier install. Also note that current release (1.1.13.4) of Mono runs and compiles IronPython 1.0 Beta 1, 2, 3 just fine. Only the latest release (Beta 4) has problems. > > * IronPython doesn't support Python standard library > > * IronPython is a toy > > I don't think people really believe either of these any more. Maybe *you* don't, but take a look at the following thread for example: http://groups.google.com/group/comp.lang.python/browse_thread/thread/2762f6dfc5f72651 Some quotes: "It seems, that usage of IronPython is currently limited to Windows platform" "However, there isn't e.g. a os-module in IronPython" Which are, false. (They were false even at the time posts were written.) And finally, Ian Bicking said: > I think concrete instructions on exactly how to get > IronPython up and working -- for someone with no .NET experience or > familiarity with that toolset -- would be an excellent way to bring > more attention to IronPython from the existing Python community. So that's exactly what I tried to do. > IronPython developers haven't really done a good job at explaining > the benefits of their work, or clearing up potential misconceptions. > For example, take a look at the previously-promoted Web site: > > http://www.ironpython.com > > It's out-of-date and doesn't mention the current Web site, which is a > mere section of some corporate "community" site for .NET: hardly a good > way of promoting something with (potential for) a fairly decent brand > identity. I am aware of these problems and will discuss this in the mailing list soon. At least, updating the website and having the public bug tracker are important. (gotdotnet.com tracker isn't one IronPython team is using.) > Then, consider the licensing situation: whilst IronPython appears to > have a fairly permissive licence [1], Microsoft have decided to put it > under their "shared source" umbrella [2], confusing things > substantially, (snip) > However, one benefit of Microsoft's desire to simplify their licensing > is that the resulting compatibility with existing licences has had some > tentative recognition [3]. > [1] http://lists.debian.org/debian-legal/2005/08/msg00089.html Do you realize *I* was the person asking for clarification of the license on debian-legal mailing list? > If IronPython users consider themselves to be > part of the wider Python community, is it a good thing that they're > reliant on Microsoft to keep that community from fragmenting? I quite don't get what you are trying to say here. Seo Sanghyeon -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there no end to Python?
"Kamilche" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > arcane code' crowd. Sets - when I played with them, they were slower > than doing the equivalent code with dicts. It's got to be a reliable, > compelling feature, before I'll add it to my arsenal. In 2.3, sets was, I believe, a module written in Python on top of the dict type. In 2.4, set() is a builtin type written in C adapting the C code of dicts but without the overhead of values, and with set rather than dict oriented methods. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting .NET SDK to work with Python 2.4.2
yea i have .net 1.1, but not the sdk. do i need the 1.1 SDK too? -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting to ARGB and writing to a bitmap
[EMAIL PROTECTED] wrote: > >I don't know what type of files they are, but the script allows me to >save to a bitmap just fine. But I do know they need to be in RGBA >format, so I've followed what most of the tutorials for RGBA >conversions said to do...shifting the bytes. It wasn't until I looked at your sample image that I realized you meant the INCOMING image is ARGB , and you're trying to convert it to ARGB . >The major problem is that everything is in green, it's shifted up by x >pixels, and it's..um..flipped from left to right. I've been working on >this for a few weeks now and any insight to the problem is greatly >appreciated. There are a couple of issues here. Depth 32 is not one of the standard formats for DIBs. 24 is (B G R B G R), but not 32. To create 32-bit DIBs, you are supposed to set biCompression to BI_BITFIELDS, and then supply bitmasks in the three dwords that follow the BITMAPINFOHEADER telling exactly where the R, G, and B values can be found. However, NT happens to handle the format as you have it, so we'll leave it alone. DIBs have no concept of an alpha channel. What are you going to use to read this? ># since bitmaps are upside down, gotta flip it over >data = f2.read() > >i = size-21 >while i >= 0: >nm = 0x100 > >f1.seek(i) >temp1 = struct.unpack('B', f1.read(1))[0] This reads one 8 bit value, and then tries to pull 32 bits of information from it. You need to read a 16-bit value and crack it 4 bits at a time, not 8 bits. >peek = temp1 > >a = nm*(peek >> 24) & 0xff >r = nm*(peek >> 16) & 0xff >g = nm*(peek >> 8 ) & 0xff >b = nm*(peek & 0xff) What is the "multiply by 0x100" supposed to be doing? As near as I can tell, since "*" binds more tightly than "&", this will result in a, r, and always being 0. >sh = (a<<24)|(r<<16)|(g<<8)|b > >f2.write(struct.pack('H', sh)) "sh" is a 32-bit value. You almost certainly want 'L' here, not 'H'. Here is one that works, although it creates the DIB upside down, as you note. I'll leave that as an exercise for the reader. import os import struct import array IN = 'testimg' OUT = 'xxx.bmp' fin = file(IN,'rb') width = 100 insize = os.stat(IN)[6] height = insize / width / 2 fout = file(OUT,'wb') # Do the BITMAPFILEHEADER. fout.write('BM') bmfh = struct.pack( 'LLL', insize*2 + 14 + 40, 0, 14+40 ) fout.write(bmfh) # Do the BITMAPINFOHEADER. bmih = struct.pack('LLLHHLL', 40, width, height, 1, 32, 0, 0, 0, 0, 0, 0 ) fout.write(bmih) # Expand the pixels, scan by scan. for i in range(height): words = array.array('H') words.fromfile( fin, width ) rgba = array.array('B') for word in words: a = ((word >> 12) & 0xf) * 0x11 r = ((word >> 8) & 0xf) * 0x11 g = ((word >> 4) & 0xf) * 0x11 b = ((word >> 0) & 0xf) * 0x11 rgba.extend( [b,g,r,a] ) rgba.tofile(fout) print '*', -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations
Roedy Green <[EMAIL PROTECTED]> wrote: >On 17 Mar 2006 00:58:55 -0800, "Fuzzyman" <[EMAIL PROTECTED]> wrote, >quoted or indirectly quoted someone who said : > >>Hmmm... it displays fine via google groups. Maybe it's the reader which >>is 'non-compliant' ? > >I am using Agent. You configure your database with an encoding, >which is by default the platform encoding, not UTF-8. I have just >flipped it over to UTF-8. We'll see if that makes Xah's future UTF-8 >messages more readable. Try pressing Ctrl-R when his message is visible. I'm also using Agent, and that toggles his extended characters from quoted-printable to visible for me. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: POP3 Mail Download
Kevin F <[EMAIL PROTECTED]> wrote: ... > > msgSize = int(split(msg, " ")[1] # line is missing closing paren, ... > thanks, that helped fix the syntax error, however, now when i run it, it > gives me an error for 'split', saying "name 'split' is not defined" > > i'm new to python so bear with me but how do i fix this? you change the above-quoted assignment into: msgSize = int(msg.split()[1]) and similarly for other occurrences of split, which is a string method (and needs to be called as such) and not a builtin function. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: can't rebind magic methods
Michael Tobis <[EMAIL PROTECTED]> wrote: > I'd appreciate an explanation of why this doesn't work and any > workarounds. Special methods are looked up (for their automatic use) on the type, not the instance. The workaround is therefore to set them on the type, too: > class myint(object): > > def __init__(self,val): > self.val = int(val) > def mystr(self): > return self.val.__str__() > self.__str__ = new.instancemethod(mystr,self,mint) #doesn't > work What you need is to have *** as myint.__str__ *** the method you want to get called. If you have a bunch of special methods that you want to ensure delegate to self.val.(samemethod), you don't have to write them out -- you can assign them as attributes of myint, with a simple loop of setattr right after the class statement, or with a custom metaclass, or whatever you find handiest. For example (warning, untested code): def _setdelegate(cls, delegate_cls, name): method = getattr(delegate_cls, name) def f(self, *a, **k): return method(self.val, *a, **k) f.func_name = name setattr(cls, name, f) class myint(object): def __init__(self, val): self.val = int(val) for spec in 'str repr hash hex oct'.split(): _setdelegate(myint, '__%s__' % spec) This may be worth refactoring into a custom metaclass if you need more than one class like this myint, but that's quite a side issue. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets
- xlrd seems to be focused on extracting data. - pyexcelerator can also generate Excel files. -- http://mail.python.org/mailman/listinfo/python-list
Re: pop3 mail download - using python.org example
Kevin F <[EMAIL PROTECTED]> wrote: > i'm trying to this this code to access my pop server but it only prompts > for a password and not a username, how do i get it to ask for my > username as well? getpass.getuser() doesn't prompt, it gets your username from the environment or the OS. If you want a raw input function that prompts, instead of that call rawinput('User: ') ... Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can we find top-notch python developers?
Nicholas Reville <[EMAIL PROTECTED]> wrote: > Hi, I hope this is an OK spot for this question: ... > We're looking to expand our development team, but we haven't been > getting enough top-quality applicants. I was wondering if anyone > here has suggestions for where we can post or list these job > openings. This is the job description: Yes, this is OK, as is http://www.python.org/community/jobs/ as Roy suggested, most mailing lists of local Python interest groups (I'm not sure they ALL welcome Python-related job offers, but I do know that applies to the ones I read, both Italian and US ones), and so on. The real problem, though, is that the job market for really top-notch Python developers is getting really squeezed these days -- around here, for example, "big-name" firms such as Google, BitTorrent, Pixar and Industrial Lights and Magic suddenly find themselves in pretty hot competition for a pool of talent that can't grow fast enough to accomodate the demand. You appear to be ready to hire people anywhere in the world, which puts you in a much stronger competitive position. I know quite a few people I'd just *LOVE* to hire... save for the fact that I just can't convince them to move (in fact, in some cases, thanks to the delightful situation with H1B visas, even if I _could_ convince them, it would still be WAY uphill from there, darn). Unfortunately, I entirely understand _why_ most software development firms prefer face-to-face employees: when I found myself, back when I was a freelance consultant, alternatively working remotely for some time, and at the client's office for another part of the time, I saw my productivity soar by 3-4 times when I was working locally, physically right next to the rest of the team, rather than remotely -- nowadays, open-source projects have discovered the same issue, which is why they have "sprints" with everybody gathering in the same place, where SO much more good work gets done than when everybody's connected to each other only via the net... Alistair Cockburn makes similar observations in his book "Agile Software Development", how it seems projects can be truly agile only if the team is co-located... ah well:-(. It would be SO much more convenient, for workers and firms both, if reality would be so kind to us as to be different!-) Anyway, best of luck! Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: POP3 Mail Download
On Sat, 18 Mar 2006 18:34:56 -0500, Kevin F wrote: > Dennis Lee Bieber wrote: >> On Sat, 18 Mar 2006 17:24:05 -0500, Kevin F <[EMAIL PROTECTED]> >> declaimed the following in comp.lang.python: >> >>> I fixed the indentation to: >>> >>> emails = [] >>> for msg in messagesInfo: >>> msgNum = int(split(msg, " ")[0] >>> msgSize = int(split(msg, " ")[1] >> >> Now look at your parentheses... >>> and it still doesn't work, what's wrong? >> >>> msgNum = int(split(msg, " ")[0] >> HINT: 0 1 21 ? > i have no idea what you are hinting at, can you please just tell me what i > need to change? I know how you feel; it's brutal trying to get elementary information from this group. I think what he is hinting at is that you are missing a right parentheses. msgNum = int(split(msg, " ")[0] should be: msgNum = int(split(msg, " "))[0] msgSize = int(split(msg, " ")[1] should be: msgSize = int(split(msg, " "))[1] Now if only somebody would tell me, with elementary examples, how you write to the thing called 'stdout' and how you read from 'stdin'. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can we find top-notch python developers?
In article <[EMAIL PROTECTED]>, Nicholas Reville <[EMAIL PROTECTED]> wrote: > Hi, I hope this is an OK spot for this question: An even better place would be to post your position on the Python Jobs Board, http://www.python.org/community/jobs/ -- http://mail.python.org/mailman/listinfo/python-list
pop3 mail download - using python.org example
i'm trying to this this code to access my pop server but it only prompts for a password and not a username, how do i get it to ask for my username as well? ##from http://docs.python.org/lib/pop3-example.html import getpass, poplib M = poplib.POP3('localhost') M.user(getpass.getuser()) M.pass_(getpass.getpass()) numMessages = len(M.list()[1]) for i in range(numMessages): for j in M.retr(i+1)[1]: print j -- http://mail.python.org/mailman/listinfo/python-list
Where can we find top-notch python developers?
Hi, I hope this is an OK spot for this question: I'm a co-founder of the Participatory Culture Foundation (pculture.org), we're a non-profit that develops Democracy Player and some related internet TV tools (see getdemocracy.com). Democracy Player has a Python backend with native front-ends for Mac, Windows, and Linux. We're looking to expand our development team, but we haven't been getting enough top-quality applicants. I was wondering if anyone here has suggestions for where we can post or list these job openings. This is the job description: Software Developer - We're looking for a solid programmer who can work independently, communicate well, and occasionally step back from the code to contemplate improvements to program architecture or our development process. Most of our code is in dynamic languages like Python and Ruby, so a clear understanding of language concepts is important. Email: jobs[at]pculture.org Here it is online: http://www.getdemocracy.com/jobs/ Any suggestions would be really appreciated and sorry if this is off- topic! Thanks, nicholas -- http://mail.python.org/mailman/listinfo/python-list
epydoc: links to other methods/classes with reStructuredText
Hi, I try to use epydoc with reStructuredText. It works fine, my only problem is that I couldn't figure out the syntax for links to other methods or classes. Any hints? Max P.S: Where is the correct platform for discussing epydoc? -- http://mail.python.org/mailman/listinfo/python-list
can't rebind magic methods
I'd appreciate an explanation of why this doesn't work and any workarounds. It's not a showstopper, but I'd like to pseudo-inherit a bunch of magic methods from an attribute, and would prefer to abstract the definitions into a loop rather than write them all out. thanks mt ### import new class myint(object): def __init__(self,val): self.val = int(val) def mystr(self): return self.val.__str__() self.__str__ = new.instancemethod(mystr,self,mint) #doesn't work self.str = new.instancemethod(mystr,self,mint) """ # this works def __str__(self): return self.val.__str__() """ if __name__ == "__main__": a = myint(3) b = a a.val = 42 print b # want "42" print b.str() # works -- http://mail.python.org/mailman/listinfo/python-list
Re: POP3 Mail Download
Paul McGuire wrote: > "Kevin F" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Dennis Lee Bieber wrote: >>> On Sat, 18 Mar 2006 16:44:44 -0500, Kevin F <[EMAIL PROTECTED]> >>> declaimed the following in comp.lang.python: >>> >>> However, if I try to actually download the messages themselves, my python editor highlights 'msgSize' and says "invalid syntax" when I run the following subsequent lines of code: emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1] if(msgSize < 2): messages = server.retr(msgNum)[1] messages = join(message, "\n") emails.append(message) >>> Look very closely at your indentation >>> >>> >> I fixed the indentation to: >> >> emails = [] >> for msg in messagesInfo: >> msgNum = int(split(msg, " ")[0] >> msgSize = int(split(msg, " ")[1] >> if(msgSize < 2): >> messages = server.retr(msgNum)[1] >> messages = join(message, "\n") >> emails.append(message) >> >> >> and it still doesn't work, what's wrong? > > See comments. > -- Paul > > > emails = [] > for msg in messagesInfo: > msgNum = int(split(msg, " ")[0] # line is missing closing paren > msgSize = int(split(msg, " ")[1] # line is missing closing paren, > too > if(msgSize < 2): # this line should not be > further indented > messages = server.retr(msgNum)[1] > messages = join(message, "\n") > emails.append(message) > > > thanks, that helped fix the syntax error, however, now when i run it, it gives me an error for 'split', saying "name 'split' is not defined" i'm new to python so bear with me but how do i fix this? -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets
On 19/03/2006 8:31 AM, Kent Johnson wrote: > John Machin wrote: > >> I am pleased to announce a new general release (0.5.2) of xlrd, a Python >> package for extracting data from Microsoft Excel spreadsheets. > > > How does xlrd compare with pyexcelerator? At a glance they look pretty > similar. > I have an obvious bias, so I'll just leave you with a not-very-PC analogy to think about: Depending on the ambient light and the quantity of mead drunk in the hall, Helen of Troy and Grendel's mum might at a glance look pretty similar, too. Perhaps a more thorough investigation is needed. What about your requirements: a partner for the graduation ball, or someone to lift the truck off you when the jack collapses? Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: POP3 Mail Download
"Kevin F" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dennis Lee Bieber wrote: > > On Sat, 18 Mar 2006 16:44:44 -0500, Kevin F <[EMAIL PROTECTED]> > > declaimed the following in comp.lang.python: > > > > > >> However, if I try to actually download the messages themselves, my > >> python editor highlights 'msgSize' and says "invalid syntax" when I run > >> the following subsequent lines of code: > >> > >> > >> > >> emails = [] > >> for msg in messagesInfo: > >> msgNum = int(split(msg, " ")[0] > >> msgSize = int(split(msg, " ")[1] > >> if(msgSize < 2): > >> messages = server.retr(msgNum)[1] > >> messages = join(message, "\n") > >> emails.append(message) > > > > Look very closely at your indentation > > > > > > I fixed the indentation to: > > emails = [] > for msg in messagesInfo: > msgNum = int(split(msg, " ")[0] > msgSize = int(split(msg, " ")[1] > if(msgSize < 2): > messages = server.retr(msgNum)[1] > messages = join(message, "\n") > emails.append(message) > > > and it still doesn't work, what's wrong? See comments. -- Paul emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] # line is missing closing paren msgSize = int(split(msg, " ")[1] # line is missing closing paren, too if(msgSize < 2): # this line should not be further indented messages = server.retr(msgNum)[1] messages = join(message, "\n") emails.append(message) -- http://mail.python.org/mailman/listinfo/python-list
interrupting pythonD with ^C
I'm finding that many times when I inadvertently code an endless loop in pythonD code, on MSDOS, execution cannot be interrupted by ctrl-C and I am forced to reboot and this is rapidly loses its novelty. Do users of pythonD have a coding technique, or a library file to include, to endow a program with keyboard interrupt-ability? Endless loops arise when I forget to increment a loop index, or code incorrectly the end condition test, or indent wrongly, etc. -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
Re: POP3 Mail Download
Dennis Lee Bieber wrote: > On Sat, 18 Mar 2006 17:24:05 -0500, Kevin F <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> I fixed the indentation to: >> >> emails = [] >> for msg in messagesInfo: >> msgNum = int(split(msg, " ")[0] >> msgSize = int(split(msg, " ")[1] > > Now look at your parentheses... >> and it still doesn't work, what's wrong? > >> msgNum = int(split(msg, " ")[0] > HINT: 0 1 21 ? i have no idea what you are hinting at, can you please just tell me what i need to change? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to change echo in python prompt
Hi... Found out (sys.ps1 and sys.ps2 control that).Cheers,FabioOn 3/18/06, Fabio Zadrozny <[EMAIL PROTECTED] > wrote:Hi All,Does someone know if there is some way to supress the '>>>' and '...' in the python prompt (while actually forcing prompts with -i)? -- and all that in a non-platform dependent way ;-) Thanks,Fabio -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting .NET SDK to work with Python 2.4.2
okay, i am new to python and realize that indentation is important. i have tried to put everything in their respective indentations but it still doesn't work, can someone try to fix this? from poplib import * server = POP3("mail.bluebottle.com") print server.getwelcome() print server.user("[EMAIL PROTECTED]") print server.pass_("") messagesInfo = server.list()[1] numMessages = len(messagesInfo) print numMessages emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1] if(msgSize < 2): message = server.retr(msgNum)[1] message = join(message, "\n") emails.append(message) Kevin F wrote: > Dave wrote: >> I searched the usenet and some mail archives and tried various >> techniques, but I can't seem to get the .NET 2.0 SDK to work with >> python. I'm a total newbie when it comes to python installs. I >> downloaded the .NET 2.0 SDK and I have python 2.4.2 and im trying to >> install zope. So i go to the cmd and go to the directory and type >> "python setup.py build" (Will have to install after) and it comes up >> with this(after everything else runs smoothly): >> running build_ext >> error: The .NET SDK needs to be installed before building extensions >> for python. >> >> I set the .net2.0 directory in windows enviromental PATH and added a >> key to registry in: >> HKEY_{LOCAL_MACHINE}\Software\Microsoft\.NETFramework\FrameworkSDKDir >> to the path of it. It still doesn't recongnize it and I don't know why. >> > > okay, i am new to python and realize that indentation is important. i > have tried to put everything in their respective indentations but it > still doesn't work, can someone try to fix this? > > from poplib import * > > server = POP3("mail.bluebottle.com") > print server.getwelcome() > print server.user("[EMAIL PROTECTED]") > print server.pass_("hahaha") > > messagesInfo = server.list()[1] > numMessages = len(messagesInfo) > > print numMessages > > emails = [] > for msg in messagesInfo: > msgNum = int(split(msg, " ")[0] > msgSize = int(split(msg, " ")[1] > if(msgSize < 2): >message = server.retr(msgNum)[1] >message = join(message, "\n") >emails.append(message) -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting .NET SDK to work with Python 2.4.2
Dave wrote: > I searched the usenet and some mail archives and tried various > techniques, but I can't seem to get the .NET 2.0 SDK to work with > python. I'm a total newbie when it comes to python installs. I > downloaded the .NET 2.0 SDK and I have python 2.4.2 and im trying to > install zope. So i go to the cmd and go to the directory and type > "python setup.py build" (Will have to install after) and it comes up > with this(after everything else runs smoothly): > running build_ext > error: The .NET SDK needs to be installed before building extensions > for python. > > I set the .net2.0 directory in windows enviromental PATH and added a > key to registry in: > HKEY_{LOCAL_MACHINE}\Software\Microsoft\.NETFramework\FrameworkSDKDir > to the path of it. It still doesn't recongnize it and I don't know why. > okay, i am new to python and realize that indentation is important. i have tried to put everything in their respective indentations but it still doesn't work, can someone try to fix this? from poplib import * server = POP3("mail.bluebottle.com") print server.getwelcome() print server.user("[EMAIL PROTECTED]") print server.pass_("hahaha") messagesInfo = server.list()[1] numMessages = len(messagesInfo) print numMessages emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1] if(msgSize < 2): message = server.retr(msgNum)[1] message = join(message, "\n") emails.append(message) -- http://mail.python.org/mailman/listinfo/python-list
Re: Have you ever considered of mousing ambidextrously?
Em Sáb, 2006-03-18 às 14:26 -0500, Roy Smith escreveu: > "WangQiang" <[EMAIL PROTECTED]> wrote: > > I'm also a programmer, as working in front of computer day and day, my > > right hand is so tired and ached. So I tried to mouse in both hands. I > > find that it is really an efficient way to release pains. At first I > > switched the mouse buttons in windows control panel, but it taked me > > several steps to finish it > > I never understood why people switch mouse buttons. I'm left handed, so I > put the mouse on the left side of my keyboard. It never occurred to me to > flip the buttons around. I'm also left handed and using the middle finger for left click leave my index finger for middle or right clicking or scrolling with the wheel. I find it much easier to do this way, specially when programming, where I do lots of copy & pastes with middle click, and playing first person shooters. But for me the greatest advantage is that, as my index finger is more precise than the middle one, I leave my best finger to the activity that need most accuracy: scrolling with the wheel. The middle finger just have to click, very easy. -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list
Re: POP3 Python Mail Download
Kevin F wrote: > However, if I try to actually download the messages themselves, my > python editor highlights 'msgSize' and says "invalid syntax" when I run > the following subsequent lines of code: > > > > emails = [] > for msg in messagesInfo: > msgNum = int(split(msg, " ")[0] > msgSize = int(split(msg, " ")[1] You have an inconsistent indent in the two lines above. All the lines in a block must have the same indent (except sub-blocks of course). Kent -- http://mail.python.org/mailman/listinfo/python-list
How to change echo in python prompt
Hi All,Does someone know if there is some way to supress the '>>>' and '...' in the python prompt (while actually forcing prompts with -i)?-- and all that in a non-platform dependent way ;-) Thanks,Fabio -- http://mail.python.org/mailman/listinfo/python-list
Getting .NET SDK to work with Python 2.4.2
I searched the usenet and some mail archives and tried various techniques, but I can't seem to get the .NET 2.0 SDK to work with python. I'm a total newbie when it comes to python installs. I downloaded the .NET 2.0 SDK and I have python 2.4.2 and im trying to install zope. So i go to the cmd and go to the directory and type "python setup.py build" (Will have to install after) and it comes up with this(after everything else runs smoothly): running build_ext error: The .NET SDK needs to be installed before building extensions for python. I set the .net2.0 directory in windows enviromental PATH and added a key to registry in: HKEY_{LOCAL_MACHINE}\Software\Microsoft\.NETFramework\FrameworkSDKDir to the path of it. It still doesn't recongnize it and I don't know why. -- http://mail.python.org/mailman/listinfo/python-list
Re: remove a directory with special chars
Is there a special reason you want to use Python to do this? The Linux command shell would probably do exactly the same job (you can specify backslash-escaped characters at the command-line)... anyway to do it in python: import os os.remove("/path/to/the/file/.\177\177") Note that under Linux, hidden files start with a "." - that's what makes them hidden. By the way, "\177" (decimal 79) is a letter "O"... I suspect you meant "\011" (decimal 9) which is backspace... Hope that helps, -andyj -- http://mail.python.org/mailman/listinfo/python-list
Re: Python equivalent of Perl-ISAPI?
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there an effcient way (more so than cgi) of using Python > with Microsoft IIS? Something equivalent to Perl-ISAPI? > Pywin32 comes with an ISAPI package. See \lib\site-packages\isapi\samples\ for some demos. Roger == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: __dict__ strangeness
Georg Brandl wrote: > Hi, > > can someone please tell me that this is correct and why: > > >>> class C(object): > ... pass > ... > >>> c = C() > >>> c.a = 1 > >>> c.__dict__ > {'a': 1} > >>> c.__dict__ = {} > >>> c.a > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'C' object has no attribute 'a' > >>> > >>> class D(object): > ... __dict__ = {} > ... > >>> d = D() > >>> d.a = 1 > >>> d.__dict__ > {} > >>> d.__dict__ = {} > >>> d.a > 1 > > Thanks, > Georg Here is another example that might help: >>> class E(object): ... __dict__ = {'a': 1} ... >>> e = E() >>> e.__dict__ {'a': 1} >>> E.__dict__ >>> E.__dict__['a'] Traceback (most recent call last): File "", line 1, in ? KeyError: 'a' >>> E.__dict__['__dict__'] {'a': 1} Ziga -- http://mail.python.org/mailman/listinfo/python-list
Re: POP3 Mail Download
Dennis Lee Bieber wrote: > On Sat, 18 Mar 2006 16:44:44 -0500, Kevin F <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > >> However, if I try to actually download the messages themselves, my >> python editor highlights 'msgSize' and says "invalid syntax" when I run >> the following subsequent lines of code: >> >> >> >> emails = [] >> for msg in messagesInfo: >> msgNum = int(split(msg, " ")[0] >> msgSize = int(split(msg, " ")[1] >> if(msgSize < 2): >> messages = server.retr(msgNum)[1] >> messages = join(message, "\n") >> emails.append(message) > > Look very closely at your indentation > > I fixed the indentation to: emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1] if(msgSize < 2): messages = server.retr(msgNum)[1] messages = join(message, "\n") emails.append(message) and it still doesn't work, what's wrong? -- http://mail.python.org/mailman/listinfo/python-list
Re: Have you ever considered of mousing ambidextrously?
In article <[EMAIL PROTECTED]>, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Roy Smith wrote: > > I never understood why people switch mouse buttons. I'm left handed, so I > > put the mouse on the left side of my keyboard. It never occurred to me to > > flip the buttons around. > Well, I switch 'em because the "forefinger is primary" is ingrained. I do both buttons with my forefinger. It just seems like the normal thing to do. -- http://mail.python.org/mailman/listinfo/python-list
Re: Have you ever considered of mousing ambidextrously?
I can't quite understand why right handed people put the mouse in their right hand. I'm not a touch typist, like most of the English engineers I know, and I am left handed but prefer to have the mouse in my right hand. this allows my to mouse and then peck at the keyboard with my left hand for the odd keystroke. I would however prefer the numeric pad on the left. - Paddy. -- http://paddy3118.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: A Frame-space syntax ? - Re: global, globals(), _global ?
In <[EMAIL PROTECTED]>, robert wrote: > The fact is: > * Python has that big problem with unnecessary barriers for nested frame > access - especially painfull with callback functions where you want to > put back data into the calling frame. You mean accessing the locals in the function that invoked the callback!? That sounds ugly. Makes it hard to decouple the caller and the callee here. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: filter list fast
Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert
JuHui wrote: 10/3.0 > > 3.3335 > The above value is a float, not a long ... int(10/3.0) > > 3 > >>> int(1l) 1 >>> 1 1L >>> 1/100 100L >>> int(1/100) 100 >>> regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd www.holdenweb.com Love me, love my blog holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: filter list fast
comparing [x for x in list1 if x not in list2] with set1, set2 = set(list1), set(list2) list(set1-set2) gives something like len(list2) speedup -- 10010 1000 100 11000 the speedup is constant for different len(list1) -- http://mail.python.org/mailman/listinfo/python-list
POP3 Mail Download
Having some troubles downloading messages with POP3... I can connect to the server just fine and list messages without any problem with the following code: from poplib import * server = POP3("mail.bluebottle.com") print server.getwelcome() print server.user("[EMAIL PROTECTED]") print server.pass_("") messagesInfo = server.list()[1] numMessages = len(messagesInfo) print numMessages However, if I try to actually download the messages themselves, my python editor highlights 'msgSize' and says "invalid syntax" when I run the following subsequent lines of code: emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1] if(msgSize < 2): messages = server.retr(msgNum)[1] messages = join(message, "\n") emails.append(message) anyone know what's wrong? thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets
John Machin wrote: > I am pleased to announce a new general release (0.5.2) of xlrd, a Python > package for extracting data from Microsoft Excel spreadsheets. How does xlrd compare with pyexcelerator? At a glance they look pretty similar. Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.5 Schedule
Don Taylor wrote: > [EMAIL PROTECTED] wrote: >> For more details about the plan for Python 2.5, see: >> http://www.python.org/doc/peps/pep-0356/ > I hope that this is not considered too off topic, but what compiler is > going to be used for the MSW version of 2.5? > > If it is going to the MS Visual Studio 2005 compiler then will it be > possible to use the 'free' Visual C++ 2005 Express Edition to build > extensions? I think there will be no compiler switching for a while. The previous switch from VC 6 was in part because there was no longer any legal way to get a VC 6.0 compiler. This round at least is sticking with the same compiler as Python 2.4 (VC 7.0). The new 2005 compiler flags much of the Python source with complaints about perfectly legal ANSI C constructs, and a "clean build" is a strong preference of the PyDev group. -- -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Why won't the sprites in my group show up? (PyGame)
Isis wrote: > Hi all, > I am writing a snake game, but all is not going well... Chances are good that you'll get access to many more potential respondents by posting the question to the Pygame mailing list. -- http://mail.python.org/mailman/listinfo/python-list
Re: Have you ever considered of mousing ambidextrously?
Roy Smith wrote: > I never understood why people switch mouse buttons. I'm left handed, so I > put the mouse on the left side of my keyboard. It never occurred to me to > flip the buttons around. Well, I switch 'em because the "forefinger is primary" is ingrained. > When somebody right handed sits down at my keyboard, I often see them > trying to avoid using the mouse (using arrow keys, control keys, anything > to avoid mousing). I just pick up the mouse and move it over to the right > side for them, and then they often say, "But, the buttons are backwards > now". Apparently most right handers *expect* that I, as a sinister mouse > user, have changed the buttons. Why? > > Of course, I grew up (and still prefer) the Mac, where there *is* only one > button. I grew up on 3-button mice, and later worked with people used to the original optional chord pad, so I find the Apple "users can't count past one" attitude strange. With the chord pad and three-button mouse, you could fill in forms without touching the keyboard. http://www.cedmagic.com/history/first-computer-mouse.html --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Have you ever considered of mousing ambidextrously?
Roy Smith wrote: > "WangQiang" <[EMAIL PROTECTED]> wrote: >>I'm also a programmer, as working in front of computer day and day, my >>right hand is so tired and ached. So I tried to mouse in both hands. I >>find that it is really an efficient way to release pains. At first I >>switched the mouse buttons in windows control panel, but it taked me >>several steps to finish it > > I never understood why people switch mouse buttons. It seems likely it's because the index finger is generally more dextrous than the middle finger, in spite of how often some people use their middle finger during driving or, say, pair programming... ;-) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there no end to Python?
Scott David Daniels wrote: > Kind of like the core developers saying, rather than getting more > users of this language, I'd prefer they submit careful bug reports > with money attached to fix the bugs -- ain't gonna happen. Actually, it does happen: http://www.python.org/psf/donations/ (The actual list doesn't appear to have survived the transition to the new site, but there really are people who have donated, and sometimes simply in the hopes it helps get a problem fix, or out of gratitude that a bug was fixed. And for about N-1 other reasons (where N is how many people have donated so far)...) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Threads modify "global" variable -- asking for trouble?
Thank you. Implementing a results queue was much simpler than I expected, and I think as I add this into the rest of the program it will avoid a lot of potential problems later too. -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing an output from another function
Byte wrote: > "Try this (I think its called "argument expansion", but I really don't > know what its called, so I can't point you to docs):" > > This works, thanks. But how acn I get rid of the ugly surrounding > brackets and commas? > > e.g. If the scripts overall output was (('B', 'C'),), how to change it > to just B C? > You can get rid of the outer parentheses by removing the asterisk from the parameter list. But the other parentheses: ('B', 'C') will remain, because it's a tuple. You can access the values by indexing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there no end to Python?
[EMAIL PROTECTED] a écrit : > John Salerno wrote: > >>But isn't Python sort of known for the opposite, i.e. 'one simple way', >>or something to that effect? > > > The Python language is clear and concise and so I don't think takes > long to learn. To learn the "basics", no. To really grasp all you can do with it - talking about expressivity and black magic -, this takes *much* more time. Think of all you can do with decorators, descriptors, metaclasses, closures, etc... > But there's so many libraries and packages available > that I'll probably never use more than a fraction of them. This is > good thing because I can ignore what I don't need. Well, I found myself reinventing the (square) wheel(tm) so many times - I wrote a csv package before noticing there was a much better one the standard lib - that I don't think it would be wise to ignore too much... Just my 2 cents... -- http://mail.python.org/mailman/listinfo/python-list
Why are so many built-in types inheritable?
Hi folks! For debugging purposes I tried this: --- snip --- def foo(): pass function = type(foo) class PrintingFunction(function): def __init__(self, func): self.func = func def __call__(self, *args, **kwargs): print args, kwargs return function.__call__(self, args, kwargs) class DebugMeta(type): def __new__(self, name, bases, dict): for name in dict: if type(dict[name]) is function: dict[name] = PrintingFunction(dict[name]) --- snap --- Now I tought I were able to let all maethod of classes with DebugMeta as metaclass print out their arguments. But I got the following sad error: TypeError: Error when calling the metaclass bases type 'function' is not an acceptable base type That's awful, isn't it? What could I do to get the above code working? (No, I disliked to re- implement without this unpleasant behaviour in Python.) Greetings, F. Sidler -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.5 Schedule
[EMAIL PROTECTED] wrote: > For more details about the plan for Python 2.5, see: > > http://www.python.org/doc/peps/pep-0356/ > I hope that this is not considered too off topic, but what compiler is going to be used for the MSW version of 2.5? If it is going to the MS Visual Studio 2005 compiler then will it be possible to use the 'free' Visual C++ 2005 Express Edition to build extensions? Thanks, Don. -- http://mail.python.org/mailman/listinfo/python-list
Re: ipv6 validation
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Hello, > is there any common function for validation if string contains valid ip > address(both ipv4 and ipv6)? Or does sb wrote some regular expression > for this? > thanks > J Look at socket.inet_pton(). First check to make sure ipv6 is supported on your platform, then pass your string to inet_pton() inside of a try block to catch socket.error. It would have been nicer is a more specific exception was thrown, but this seems to work. For example: >>> socket.has_ipv6 True >>> socket.inet_pton(socket.AF_INET6, "8001::1244") '\x80\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12D' >>> socket.inet_pton(socket.AF_INET6, "8001:xyz:1244") Traceback (most recent call last): File "", line 1, in ? socket.error: illegal IP address string passed to inet_pton >>> Be aware that IPv6 support is messy on Windows. For example, if you're running Win 2003 (or XP, I would guess), the OS does support IPv6 (and thus socket.has_ipv6 will probably bet set to True) but the IPv6 libraries don't actually get loaded until you configure an IPv6 address on some interface. This means things like inet_pton() will fail, which is truly bletcherous and evil. Writing a regex to recognize valid IPv6 presentation strings is not trivial. Keep in mind that you're allowed exactly 0 or 1 "::" occurrances, and things like "::192.168.11.1" are legal (I don't remember if I got the semantics right there, but the syntax is legal). -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there no end to Python?
>> This is a common (and silly) whine. 1. not a whine 2. if it is really common is it all that silly? >> effort in a free system is not fungible. The odds of your affecting how the people doing the work by complaining about how they do it and their priorities are about zero to one. That is true only if my goals were to actually effect a change. if you read what i wrote it is 1000% clear i don't expect that at all. Just stating an opinion about how Python has evolved. We've seen a lot of gains, in terms of power and speed and have lots of new toys, i am just point out that any new tech comes at a cost, and that this whole "i don't need to know this thing that has fundamentally changed how the program works" idea is a flawed. It don't matter that you don't use it, at some point someone else will and unless you live in a cave, you are gonna be staring at other folks code scratching your head. I am a better programmer than before, but i scratch my head a lot more @ 2.4 that i did at 2.0. oh, well. i knew some one would flame me. -kp8-- my main point is that new language constructs giveth and new language constructs also taketh away. -- http://mail.python.org/mailman/listinfo/python-list
Re: Have you ever considered of mousing ambidextrously?
"WangQiang" <[EMAIL PROTECTED]> wrote: > I'm also a programmer, as working in front of computer day and day, my > right hand is so tired and ached. So I tried to mouse in both hands. I > find that it is really an efficient way to release pains. At first I > switched the mouse buttons in windows control panel, but it taked me > several steps to finish it I never understood why people switch mouse buttons. I'm left handed, so I put the mouse on the left side of my keyboard. It never occurred to me to flip the buttons around. When somebody right handed sits down at my keyboard, I often see them trying to avoid using the mouse (using arrow keys, control keys, anything to avoid mousing). I just pick up the mouse and move it over to the right side for them, and then they often say, "But, the buttons are backwards now". Apparently most right handers *expect* that I, as a sinister mouse user, have changed the buttons. Why? Of course, I grew up (and still prefer) the Mac, where there *is* only one button. -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
[EMAIL PROTECTED] schrieb: > "This is where K starts to set itself from apart from most of the > common programming languages in use today. You rarely write loops in K > (KDB is 100% loop-free), instead you use adverbs. An adverb modifies a > function, returning another function, changing the ways it operates > over its arguments and what it does with it's return values." Doesn't sound too different from what closures do. Or lazy parameter passing. I'm not sure whether the K designer actually fits that description, but there are too many language designers around reinventing the wheel, arguing whether it should have seven, eight or thirteen sides... Regards, Jo -- http://mail.python.org/mailman/listinfo/python-list
Re: Linear regression in NumPy
Matt Crema wrote: > To sum up a wordy post, "What do experienced users find is the most > efficient way to navigate the numpy docs? (assuming one has already > read the FAQs and tutorials)" You're not likely to get much of an answer here, but if you ask on [EMAIL PROTECTED], you'll get plenty of discussion. -- Robert Kern [EMAIL PROTECTED] "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets
I am pleased to announce a new general release (0.5.2) of xlrd, a Python package for extracting data from Microsoft Excel spreadsheets. CHANGES: * Book and sheet objects can now be pickled and unpickled. Instead of reading a large spreadsheet multiple times, consider pickling it once and loading the saved pickle; can be much faster. * Now works with Python 2.1. Backporting to Python 2.1 was partially funded by Journyx - provider of timesheet and project accounting solutions (http://journyx.com/) * open_workbook() can be given the contents of a file instead of its name. * Now more tolerant of files written in unexpected ways by 3rd party software. * Speed improvements. Minor bugfixes. MAIN FEATURES OF xlrd: * Library for developers; not a tool for end-users. * Platform-independent pure Python – you don't need Windows, Excel, COM, ... * Handles all Excel file versions back to 3.0. * Strong support for Excel dates. AVAILABLE FROM: http://cheeseshop.python.org/pypi/xlrd http://www.lexicon.net/sjmachin/xlrd ENQUIRIES: E-mail to sjmachin at lexicon.net with [xlrd] in the subject. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: __dict__ strangeness
Georg Brandl <[EMAIL PROTECTED]> wrote: > [moving to python-dev] > > Alex Martelli wrote: > > Georg Brandl <[EMAIL PROTECTED]> wrote: > > > >> can someone please tell me that this is correct and why: > > > > IMHO, it is not correct: it is a Python bug (and it would be nice to fix > > it in 2.5). > > Fine. Credits go to Michal Kwiatkowski for discovering that in bug #1448042 > which I closed out of ignorance ;) Yep, I remember Michal posting about the bug here, and I suggested that he open it as an actual bug on SF;-)... [[I'm supposed to be finishing up the 2nd edition of the Nutshell, so I can't really do much on Python myself, these days...]] Alex -- http://mail.python.org/mailman/listinfo/python-list
Why won't the sprites in my group show up? (PyGame)
Hi all, I am writing a snake game, but all is not going well... Two problems here. First of all, the little circles I use for my sprite images only show up as quadrants. Second of all, only the Head sprite for my snake shows up at all. Why? Here are the class definitions: ! /usr/bin/python import pygame as PG seg_size = 20 class SnakeSegment(PG.sprite.Sprite): def __init__(self, pos): PG.sprite.Sprite.__init__(self) self.image = PG.Surface([seg_size,seg_size]) self.rect = self.image.get_rect() self.rect.topleft = pos # self.direction = 0 class SnakeHead(SnakeSegment): def __init__(self,pos,spd = 10): PG.sprite.Sprite.__init__(self) SnakeSegment.__init__(self,pos) PG.draw.circle(self.image,(255,0,0),self.rect.center,4) self.speed = spd # governs speed of whole snake def update(self): self.rect.left += self.speed class SnakeBody(SnakeSegment): def __init__(self,pos,prev): PG.sprite.Sprite.__init__(self) SnakeSegment.__init__(self,pos) PG.draw.circle(self.image,(0,255,0),self.rect.center,4) self.previous=prev def update(self): self.rect.center = self.previous.rect.center class SnakeTail(SnakeSegment): def __init__(self,pos,prev): PG.sprite.Sprite.__init__(self) SnakeSegment.__init__(self,pos) PG.draw.circle(self.image,(0,0,255),self.rect.center,4) self.previous=prev def update(self): self.rect.center = self.previous.rect.center class Snake(PG.sprite.OrderedUpdates): def __init__(self, pos, length = 6): PG.sprite.OrderedUpdates.__init__(self) self.head = SnakeHead(pos) self.segs = length - 2 self.position = pos self.add(self.head) prev = self.head posx, posy = pos for x in range(self.segs): posx += seg_size prev = (SnakeBody((posx,posy),prev)) self.add(prev) # print prev.rect.center posx += seg_size self.add(SnakeTail((posx, posy),prev)) self._spritelist.reverse() # we need tail first, head last Whew! And here is my little test program. #!/usr/bin/python from snake import * #import pygame as PG DBUF = PG.DOUBLEBUF FSCR = PG.FULLSCREEN screenx = 640 screeny = 480 def main(): PG.init() screen = PG.display.set_mode((screenx, screeny)) #python likes to make pointers. q = Snake((100,100)) q.draw(screen) q.update() PG.display.flip() while 1: PG.event.pump() keyinput = PG.key.get_pressed() if keyinput[PG.K_ESCAPE] or PG.event.peek(PG.QUIT): break if __name__ == '__main__': main() Whoop, there it is. What have I done wrong? -- http://mail.python.org/mailman/listinfo/python-list
Dr. Dobb's Python-URL! - weekly Python news and links (Mar 17)
QOTW: "Generally, you should always go for whatever is clearest/most easily read (not just in Python, but in all languages)." - Timothy Delaney "You will find as your programming experience increases that the different languages you learn are appropriate for different purposes, and have different advantages and disadvantages. Python excels at expressing algorithms in an unambiguous and easily-readable way." - Steve Holden Is Python a viable extension language for Java? Ravi Teja expertly outlines the possibilities: http://groups.google.com/group/comp.lang.python/msg/54ad155bc138c8d2 "In order to facilitate small groups working on specific Python-in-Education projects, we have launched an edupython list on google groups." This is a hands-on complement to the more "philosophical" edu-sig. http://groups.google.com/group/edupython mailto:edupython@googlegroups.com One interesting use of Python--at least to software workers--is to manage texts written in *other* languages. Fredrik Lundh and Roman Yakovenko present good approaches for the C++ case: http://groups.google.com/group/comp.lang.python/msg/913eb2563b815745 http://groups.google.com/group/comp.lang.python/msg/2b74c8355fc5c25a Pascal and Python? Sure: http://groups.google.com/group/comp.lang.python/browse_thread/thread/9806ed054493d6a6/ Uche Ogbuji details XPath, *XSLT, XQuery, ... capabilities: http://groups.google.com/group/comp.lang.python/browse_thread/thread/51b0fcdc7df8a34e/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous tradition early borne by Andrew Kuchling, Michael Hudson and Brett Cannon of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge re
Re: insert chars into string
[EMAIL PROTECTED] schrieb: > hi > is there a string method to insert characters into a string? > eg > str = "abcdef" > i want to insert "#" into str so that it appears "abc#def" > > currently what i did is convert it to a list, insert the character > using insert() and then join them back as string.. If you are frequently want to modify a string in such a way, that this is the recommended way to do so. It might be that there are mutable-string implementations out there that make that easier for you - but in the end, it boils down to using list, so that the overhead of concatenating strings is encountered only once, on the end when you actually need the result. Diez -- http://mail.python.org/mailman/listinfo/python-list
Socket error: 10053 software caused connection abort
-- http://mail.python.org/mailman/listinfo/python-list
Re: Is there no end to Python?
Heheh, that sounds about right. :-D I personally haven't used the new stuff yet. Maybe I'm not experienced enough in Python yet to have encountered the need for them. I've played with them some, but every time I consider using them, something stops me. What stops me from using 'setattr' (an old feature), is that it doesn't fire when a person changes an element of a list... not very intuitive. What stops me from using properties, is seeing how populating a dict using the update method wipes them out... again, not intuitive to me. List comprehensions - REALLY unnecessary. Only handy if you belong to the 'Likes to impress people with small amounts of arcane code' crowd. Sets - when I played with them, they were slower than doing the equivalent code with dicts. It's got to be a reliable, compelling feature, before I'll add it to my arsenal. -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
Nice! How to put it in a loop? I'm totally a newbie to Lisp myself, just gettng into Graham and Touretzky. Let's create a problem. Suppose after excluding I want to know if the digits sum to 12, say, like maybe they're part of a partition. S={0,..6}, S^5, excluding "*1*5*" and "1*2*3*", say. How would I do that? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python compiler
Rc wrote: > "DaveM" <[EMAIL PROTECTED]> schreef in bericht > news:[EMAIL PROTECTED] > >>On Thu, 16 Mar 2006 13:34:14 +0100, "Méta-MCI" >><[EMAIL PROTECTED]> wrote: >> >> >>>Après, vous pourrez aussi fréquenter le newsgroup : >>> fr.comp.lang.python >>>qui a l'avantage d'être en français. >> >>But perhaps he's a Flemish speaker - are you trying to start a riot? >> >>DaveM > > Yes,I'm a Flemish speaker, I have been to school in the evening > to study Englisch and also now for the last year I'm study French. > To improve my English it's maybe good to work with English > newsgroupes.I'm not looking for a riot,because I don't understand > the word.By the way, in case to learn Python,they told me it's > the most esay language to start. > But ,my question is when I start Python it is a Dos Window > that opened.I think it is not possible on a XP computer? > Or am I wrong. > Thanks by advances > Rc install Pythonwin (pywin32) for a GUI -- http://mail.python.org/mailman/listinfo/python-list
ipv6 validation
Hello, is there any common function for validation if string contains valid ip address(both ipv4 and ipv6)? Or does sb wrote some regular expression for this? thanks J -- http://mail.python.org/mailman/listinfo/python-list
Re: How to run SimpleHTTPServer on IronPython on Mono
Sanghyeon Seo wrote: > I took some time to write this HOWTO: > http://sparcs.kaist.ac.kr/~tinuviel/fepy/howto/simplehttpserver-ironpython-mono-howto.html Thanks for spending the time writing this. Whilst I don't run Mono or anything similar, new Python documentation is surely a welcome thing. > IronPython seems to get much less interest than it deserves. [...] > The purpose of this document is twofold: to show how to run > SimpleHTTPServer on IronPython on Mono, and to debunk some myths like: > > * IronPython doesn't run on Mono But it does require recent versions, according to the document. Requiring the latest stuff straight from the revision control repository is always an inhibiting factor in the adoption of software. > * IronPython doesn't support Python standard library > * IronPython is a toy I don't think people really believe either of these any more. However, the IronPython developers haven't really done a good job at explaining the benefits of their work, or clearing up potential misconceptions. For example, take a look at the previously-promoted Web site: http://www.ironpython.com It's out-of-date and doesn't mention the current Web site, which is a mere section of some corporate "community" site for .NET: hardly a good way of promoting something with (potential for) a fairly decent brand identity. Then, consider the licensing situation: whilst IronPython appears to have a fairly permissive licence [1], Microsoft have decided to put it under their "shared source" umbrella [2], confusing things substantially, since that label used to mean that you could conditionally look at Microsoft's code but do little else with it; even now they promote three licences, one of which being similar but not exactly the same as the "Shared Source License for IronPython". With various existing open source licences, particularly the Free Software licences, you know where you stand almost straight away. Meanwhile, confusing, marketing-directed labelling only makes people less certain about what they're getting into and what's being hidden from them. However, one benefit of Microsoft's desire to simplify their licensing is that the resulting compatibility with existing licences has had some tentative recognition [3]. Finally, there's the issue of the platform. I imagine that many people regard the debate as being over as to whether Mono and other similar projects independent of Microsoft are genuinely open, now that various Free Software-oriented GNU/Linux distributions are planning to distribute Mono, but the Mono developers don't score any publicity points for having belittled some fairly legitimate concerns about things like patent claims related to the various "standards" involved. For what it's worth, nagging concerns about the Java platform's openness (especially related to the add-on standards like J2EE) still linger in the open source community. One other thing, not any fault of the IronPython developers themselves: I guess it doesn't help that the canonical implementation of Python - CPython - keeps growing new features which have already left Jython struggling to catch up. If IronPython users consider themselves to be part of the wider Python community, is it a good thing that they're reliant on Microsoft to keep that community from fragmenting? Paul [1] http://lists.debian.org/debian-legal/2005/08/msg00089.html [2] http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx [3] http://mail.fsfeurope.org/pipermail/press-release/2005q4/000120.html -- http://mail.python.org/mailman/listinfo/python-list
Re: __dict__ strangeness
[moving to python-dev] Alex Martelli wrote: > Georg Brandl <[EMAIL PROTECTED]> wrote: > >> can someone please tell me that this is correct and why: > > IMHO, it is not correct: it is a Python bug (and it would be nice to fix > it in 2.5). Fine. Credits go to Michal Kwiatkowski for discovering that in bug #1448042 which I closed out of ignorance ;) >> >>> class C(object): >> ... pass >> ... >> >>> c = C() >> >>> c.a = 1 >> >>> c.__dict__ >> {'a': 1} >> >>> c.__dict__ = {} >> >>> c.a >> Traceback (most recent call last): >> File "", line 1, in ? >> AttributeError: 'C' object has no attribute 'a' > > So far so good, I think we agree;-). Yes. >> >>> class D(object): >> ... __dict__ = {} >> ... >> >>> d = D() >> >>> d.a = 1 >> >>> d.__dict__ >> {} >> >>> d.__dict__ = {} >> >>> d.a >> 1 > > Yep, that's the bug, fully reproducible in 2.3 and 2.4. FWIW, mucking > around with gc.getreferrers (with a more uniquely identifiable value for > d.a;-) shows a dictionary "somewhere" with keys 'a' and '__dict__'... Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
The cardinality of excluding '*a*b*' from S^n should be (m-1)^(n-1)*(m+n-1), where m=|S|. For m=5 this becomes 4^(n-1)*(n+4), and your table fits this formula. As far as generating and testing, an 'ideal' solution would be to 'start from the ground up', as in excluding length 2 wc, and then length 3, etc, until all wc's have been excluded. The 'ideal' solution would intrinsically exclude wc's and not test against a background generation of all of S^n. Does that make sense? -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing web bots in python
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > I hav a question..How do I write a webbot that logs onto some website, > fills text into a textbox and submit that form, Sorry I am a novice in > python, apparently I have to use urllib, but I hav a few queries on > this, What happens when there are more input interfaces..does urllib > make somekind of a template when it does so..need more info on > this..links and tutorilas would be appreciated..thanx > > Sudharshan S > C.Titus Brown gave a quick but impressive demo of twill at the Pycon lightning talks. I think this will do just what you need. http://www.idyll.org/~t/www-tools/twill/ -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Python compiler
"DaveM" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > On Thu, 16 Mar 2006 13:34:14 +0100, "Méta-MCI" > <[EMAIL PROTECTED]> wrote: > >>Après, vous pourrez aussi fréquenter le newsgroup : >>fr.comp.lang.python >>qui a l'avantage d'être en français. > > But perhaps he's a Flemish speaker - are you trying to start a riot? > > DaveM Yes,I'm a Flemish speaker, I have been to school in the evening to study Englisch and also now for the last year I'm study French. To improve my English it's maybe good to work with English newsgroupes.I'm not looking for a riot,because I don't understand the word.By the way, in case to learn Python,they told me it's the most esay language to start. But ,my question is when I start Python it is a Dos Window that opened.I think it is not possible on a XP computer? Or am I wrong. Thanks by advances Rc -- http://mail.python.org/mailman/listinfo/python-list
Re: Linear regression in NumPy
nikie wrote: > > Hello, I'm glad that helped, but let's not terminate this discussion just yet. I am also interested in answers to your second question: nikie wrote: > "More generally: Is there any kind of documentation that tells me what > the functions in NumPy do, and what parameters they expect, how to > call them, etc. As I said, I'm also new to numpy (only been using it for a week), but my first impression is that the built-in documentation is seriously lacking. For example, the Mathworks docs absolutely crush numpy's. I mean this constructively, and not as a shot at numpy. gave an excellent answer, but I differ with his one point that the docstring for "numpy.linalg.lstsq?" contains an obvious answer to the question. Good documentation should be written in much simpler terms, and examples of the function's use should be included. I wonder if anyone can impart some strategies for quickly solving problems like "How do I do a linear fit in numpy?" if, for example, I don't know which command to use. In Matlab, I would have typed: "lookfor fit" It would have returned 'polyval'. Then: "help polyval" and this problem would have been solved in under 5 minutes. To sum up a wordy post, "What do experienced users find is the most efficient way to navigate the numpy docs? (assuming one has already read the FAQs and tutorials)" Thanks. -Matt -- http://mail.python.org/mailman/listinfo/python-list