Re: question about deleting records from mysql
# [EMAIL PROTECTED] / 2005-07-27 05:12:46 -0700: > ok. did this > > >>> cursor.execute("DELETE FROM table WHERE autoinc > 1000") > 245L > >>> cursor.commit() > > i got an AttributeError 'Cursor' object has no attribute 'commit' > > hmm. what should i do now? RTFM, e. g. here: http://cvs.sourceforge.net/viewcvs.py/mysql-python/MySQLdb/doc/MySQLdb.txt?rev=1.1&view=auto -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
sys.stdout / sys.stderr, subprocess, redirection
Hello, I have a piece of code that gets run in a script that has its stdout closed: import sys sys.stdout = sys.stderr c = subprocess.Popen (..., stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT) and this is what I get: SendingSVNR/permissions Transmitting file data .svn: Commit failed (details follow): svn: 'pre-commit' hook failed with error output: Traceback (most recent call last): (...) File ".../__init__.py", line 40, in run stderr = subprocess.STDOUT) File "/usr/local/lib/python2.4/subprocess.py", line 554, in __init__ errread, errwrite) File "/usr/local/lib/python2.4/subprocess.py", line 986, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory This is the child_traceback: File "/usr/local/lib/python2.4/subprocess.py", line 955, in _execute_child File "/usr/local/lib/python2.4/os.py", line 341, in execvp File "/usr/local/lib/python2.4/os.py", line 379, in _execvpe func(fullname, *argrest) OSError: [Errno 2] No such file or directory Is this a problem in subprocess (I'm using the FreeBSD port of Python-2.4 and subprocess that comes with that release) or is this expected? If my expectations are broken (likely), what should the standard descriptor massaging look like? Subversion code that runs the script can be seen at http://svn.collab.net/viewcvs/svn/trunk/subversion/libsvn_repos/hooks.c (run_hook_cmd()). -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: Super Newbie Question
# [EMAIL PROTECTED] / 2005-04-04 16:39:27 -0700: > In short, how might I go about deleting just the contents of a file? > I tried several methods with my limited knowledge but had no luck. fd = open("your-file") fd.truncate() fd.close() or open("your-file", "w").close() -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: email and smtplib modules
# [EMAIL PROTECTED] / 2005-04-09 16:42:04 -0500: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > > Hi, > > > > I'm writing a small script that generates email and I've noticed that: > > > > 1) one should add the 'To' and 'CC' headers to the email message > > 2) one needs to specify the recipients in the smtplib sendmail() method > > > > Can someone explain how these are related? ... > This design makes many things possible. Most used these days is spam > delivered to one address while apparently to another. What about mailing lists? Quoting from your message as it arrived here: Return-Path: [EMAIL PROTECTED] X-Original-To: [EMAIL PROTECTED] From: Mike Meyer <[EMAIL PROTECTED]> To: python-list@python.org For the OP: Return-Path: header contains the envelope sender (SMTP MAIL command) X-Original-To: is the envelope recipient (SMTP RCPT command) So, despite the email claiming to be sent from Mike to the list, it's actually from the list to me. Please take Mike's note about spam with two grains of salt, the distinction between headers and envelope is vital to the SMTP protocol and many services built around it. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: Signals and system
# [EMAIL PROTECTED] / 2005-04-10 20:55:05 +1000: > Hi folks, > > My python program needs to download a number of files. Each file comes > as a list of mirrors of that file. > > Currently, I am using system (os.system) to run wget. The mechanism is > in a loop, so that it will try all the mirrors while wget is exiting > with a non-zero exit status. This is working fine as long as the user > feels there is no need to interrupt it. > > If wget receives a SIGINT, it stops (as expected) and returns non-zero > (1 from memory). The call to system returns the same status code, > indicating that wget failed, but the program has no knowledge that it > was a signal the killed wget, rather than a failed download, and as such > it tries the next mirror. I would like to be notified if wget received > any signals, so that the user doesn't need to repetitively press Ctrl-C > for each and every mirror to get the downloading process to stop. > > Can someone point me in the right direction? http://docs.python.org/lib/os-process.html#l2h-1682 "On Unix, the return value is the exit status of the process encoded in the format specified for wait()." http://docs.python.org/lib/os-process.html#l2h-1684 "return a tuple containing its pid and exit status indication: a 16-bit number, whose low byte is the signal number that killed the process, and whose high byte is the exit status (if the signal number is zero); the high bit of the low byte is set if a core file was produced" -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: semicolons
# [EMAIL PROTECTED] / 2005-04-12 00:14:03 +0200: >Hello, > > I amafraid of I will stop using semicolons in other languages after one > or two months of python. Writing in multiple programming languages is just like writing or speaking in multiple human languages: you just need to obey the rules of the different grammars and pronounciations. > However I see that python simply ignores the semicolons atd the end of > the lines. That's not true. > What's your advice? I don't want to write full-of-typo php scripts Then don't. > but I see the logic of the python syntax too. Different languages have different "logics". You need to stick to the right set of rules appropriate for the language you're using. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: [perl-python] Python documentation moronicities (continued)
# [EMAIL PROTECTED] / 2005-04-12 03:25:33 -0700: > QUOTE > compile( > pattern[, flags]) > > Compile a regular expression pattern into a regular expression object, > which can be used for matching using its match() and search() methods, > described below. > > The expression's behaviour can be modified by specifying a flags > value. Values can be any of the following variables, combined using > bitwise OR (the | operator). > UNQUOTE > And what the fuck is it unclearly meant by "OR" operator with the > mother fucking bitwise jargon? "bitwise OR (the | operator)": it doesn't speak about an "OR operator", does it? > for a exposition of IT's fucking stupid docs and their fuckhead coders, > see: > http://xahlee.org/Periodic_dosage_dir/t2/xlali_skami_cukta.html Interesting reading, I might send you a few of my pet peeves for inclusion. > you want to ask yourself this question: > Can a seasoned programer, who is expert at least 2 languages, who is > also a expert at Perl and knew regex well, and have just read the doc, > must he, resort to many trial and error to see exactly what the doc is > talking about? While I understand your frustration (I curse the same when I try to use the Python documentation), you are spoiling your message by the (IMNSHO well granted, but still) unhelpful profanity. Unfortunately, the python community seems to bathe in the misorganized half-documentation, see e. g. http://marc.theaimsgroup.com/?l=python-list&m=111303919606261&w=2 especially the reply that (as I read it) suggested reverse engineering as a viable alternative to documentation. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: Compute pi to base 12 using Python?
# [EMAIL PROTECTED] / 2005-04-13 03:27:06 -0700: > Bengt Richter wrote at 03:19 4/13/2005: > This is not homework, nor am I a student, though I am trying to learn > Python. I'm just trying to help an artist acquaintance who needs (I just > learned) the first 3003 digits of pi to the base 12. > > >Hint: Lambert Meertens. Tweak the algorithm you find ;-) > > Sorry. Your hint is beyond me. it says "use google". -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: A little request about spam
# [EMAIL PROTECTED] / 2005-04-14 08:22:48 -0600: > The listowner could turn on the [PYTHON] headers. I hope they don't. > I'm not using spambayes yet, although I'm leaning toward it, but that > step alone could save me some work when trying to decide based on > subject line alone whether or not an email is spam. As it stands now, > it's too easy to decide incorrectly that "Subject: Inelegant" is a > spamdunk. Don't base your decisions (only) on subject then. Oh, and spam sent through the list would have the [PYTHON] space eater too, so what would it buy you? -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: A little request about spam
# [EMAIL PROTECTED] / 2005-04-14 09:06:08 -0600: > Roman Neuhauser wrote: > > > > # [EMAIL PROTECTED] / 2005-04-14 08:22:48 -0600: > > > The listowner could turn on the [PYTHON] headers. > > > > I hope they don't. > > > > What's your reasoning? It's 9 characters ("[PYTHON] ") of screen real estate wasted. Of course it's mail from the python-list, it has the appropriate List-Id header! > > > As it stands now, it's too easy to decide incorrectly that > > > "Subject: Inelegant" is a spamdunk. > > > > Don't base your decisions (only) on subject then. Oh, and spam sent > > through the list would have the [PYTHON] space eater too, so what > > would it buy you? > > Of course I wouldn't base decisions _only_ on whether or not [PYTHON] > appears in the subject. But I ordinarily do base decisions on the whole > subject line, and I think that's perfectly reasonable. There's nothing > else to go on without opening the message, and for HTML-based mail > there's no surer way to let spammers know they've found a live email > addres than to open it. You know that. I have no problem opening HTML emails: I (intentionally) don't have a viewer for them configured in mutt which means I see their source. And I delete them all without reading. For Content-Type: multipart/alternative emails, the text/plain part is displayed, and I mostly don't even get to notice there's a html part. If the text/plain part says something hilarious, like "This is a MIME email, get a better email client" which I've seen in a spam, I get to laugh as well. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: [perl-python] Python documentation moronicities (continued)
# [EMAIL PROTECTED] / 2005-04-13 08:07:06 +1000: > On Tue, 12 Apr 2005 13:06:36 +0200, Roman Neuhauser > <[EMAIL PROTECTED]> wrote: > > >Unfortunately, the python community seems to bathe in the > >misorganized half-documentation, see e. g. > >http://marc.theaimsgroup.com/?l=python-list&m=111303919606261&w=2 > >especially the reply that (as I read it) suggested reverse > >engineering as a viable alternative to documentation. > > As I read the reply, it was a smart-arse attempt at humour, a *PUN* on > the word "list" (mailing list versus Python list). What I would call > "introspection" (not "reverse engineering") was then suggested. > > Moreover, both of the concepts mentioned in the quoted thread > (sequence.index() and the "in" operator) are IMESHO adequately > documented. > > Do you have any examples of what you regard as "misorganized > half-documentation"? Description of classes: * What's with "Programmer's Note", is the other paragraph of the description aimed at salesmen? * Why isn't there a link to a description of "new-style classes" (presumably to the "New-style Classes" essay since, as http://www.python.org/doc/newstyle.html says, NSC aren't integrated into the standard documentation. * Aren't class objects instances of a builtin type? What should I read into ""? distutils: * sections 10.26 through 10.45 are completely empty * http://docs.python.org/dist/listing-packages.html: "when you say packages = ['foo'] in your setup script" couldn't be any more vague I guess. Does the statement belong in the global scope? * http://docs.python.org/dist/listing-packages.html: "Then you would put package_dir = {'': 'lib'} in your setup script.": does that statement belong in the global scope, or is it a keyword argument for setup(), which would mean that the listing at http://docs.python.org/dist/module-distutils.core.html cannot be trusted as complete? lists: this is a matter of taste, but I find the split of list description between http://docs.python.org/lib/typesseq.html and http://docs.python.org/lib/typesseq-mutable.html (without pointers from typesseq.html to typesseq-mutable.html where I would expect them, such as mentioning append()) confusing. The above applies to other mutable sequential types as well, of course. In general, various parts of the documentation often refer the reader to other parts without using html anchors, what should be concise, accurate, and complete description is a meandering essay with vague formulations (see quotes from the distutils manual above), etc. There's also this thing with easy access to individual nodes: I often miss being able to type something like http://docs.python.org/os.path.expanduser and be redirected to http://docs.python.org/lib/module-os.path.html#l2h-1731 Mebbe it's just me, but I've been trying python on and off for several years now, and it's always been precisely its documentation that has made me back out. I know I'll get to know the language quite well some time, but it'll be through scars, and I'll have many f*cks behind me. > Here's a puzzle for you: Where does this list appear? What's missing? > > "..., Mullender, Nagata, Ng, Oner, Oppelstrup, ..." Sorry, I don't have time for puzzles. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: [perl-python] Python documentation moronicities (continued)
# [EMAIL PROTECTED] / 2005-04-17 14:59:50 +0200: > Roman Neuhauser wrote: > > >>Here's a puzzle for you: Where does this list appear? What's missing? > >> > >>"..., Mullender, Nagata, Ng, Oner, Oppelstrup, ..." > > > > Sorry, I don't have time for puzzles. > > nor for contributing, it seems. otherwise, your name would be on that list. Right. There's a finite number of hours in a day, and I chose to spend most of it on FreeBSD, and my name is on that operating system's contributor list. You're welcome to use the results of the work. But anyway, I was honestly asked about what I considered suboptimal in the python documentation, and I honestly answered. Does that bother you? -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: To decode the Subject =?iso-8859-2?Q?=... in email in python
# [EMAIL PROTECTED] / 2005-04-20 00:30:35 -0700: > When parsing messages using python's libraries email and mailbox, the > subject is often encoded using some kind of = notation. Apparently, the > encoding used in this notation is specified like =?iso-8859-2?Q?=... or > =?iso-8859-2?B?=. That's RFC 2047 encoding, both examples introduce an ISO8859-2 string, the first variant says it's ascii-ized using "Q"uoted-Printable, the other says the string is "B"ase64-encoded. > Is there a python library function to decode such a > subject, returning a unicode string? The use would be like > > human_readable = cool_library.decode_equals(message['Subject']) quoting from http://docs.python.org/lib/module-email.Header.html >>> from email.Header import decode_header >>> decode_header('=?iso-8859-1?q?p=F6stal?=') [('p\xf6stal', 'iso-8859-1')] -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: Noobie Question: Using strings and paths in mkdir (os.mkdir("/test/"a))
# [EMAIL PROTECTED] / 2005-04-22 00:13:05 -0700: > Hello! > > I can't seem to get paths and variables working together: > > import os > a = 'books' > os.chdir( '/test') > os.mkdir("/test/"a) > > the last line does not seem to work. os.mkdir(a) makes the directory > books, but i want this directory as a subdirectory of test. > > I also tried: os.mkdir("/test/",a), and trying to make b = 'test' and > then os.mkdir(a b). > > Does someone have any ideas or a link they can give me, I looked under > strings in the python tutorial and library manual but I guess not in > the right spot. http://docs.python.org/ref/string-catenation.html -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: regarding system function
# [EMAIL PROTECTED] / 2005-04-22 08:35:33 +0100: > > --- Robert Kern <[EMAIL PROTECTED]> wrote: > > praba kar wrote: > > > In Php If I send a command to system function > > > then It will return 1 on success and 0 on failure. > > > So based upon that value I can to further work. > > > > > > But In Python If I send a command to system > > > function then It will return 0 only for both > > > conditions(success and failure). > > > > Are you sure about that? > > > > In [3]:os.system('cat foo') > > cat: foo: No such file or directory > > Out[3]:256 > > > > I agree above statement but When I delete a directory > os.system('rm -rf test') > 0 > if directory is not present then I again try to > delete > os.system('rm -rf test') > now this time also It will print > 0 that's the standard behavior of the -f switch -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or PHP?
# [EMAIL PROTECTED] / 2005-04-23 15:53:17 +0200: > Lad wrote: > > >Is anyone capable of providing Python advantages over PHP if there are > >any? > > I am also new to python but I use php for 4 years. I can tell: > > - python is more *pythonic* than php > - python has its own perfume > http://www.1976.com.tw/image/trussardi_python_uomo.jpg and it's nice. > php doesn't have any smell > - writing python programs you feel much better No, *you* feel better. :) > check this: http://wiki.w4py.org/pythonvsphp.html The comparison found there is biased, the author is a Python partisan. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: operator overloading + - / * = etc...
# [EMAIL PROTECTED] / 2006-10-08 11:44:18 +0100: > That's because assignment isn't an operator - that's why (for example) > > print x = 33 > > would be a syntax error. This is a deliberate design decision about > which, history shows, there is little use complaining. Just to clarify: not that there's little complaining about assignment not being an expression, it's useless to complain because all previous complaints have been shot down on the basis of claims of reduced safety and readability. People who complain often fail to see how x = foo() while x: process(x) x = foo() is safer than while x = foo(): process(x) (duplication hampers code safety) or how some other features present in the language, e. g. comprehensions, could make it past the readability check. Everybody has an opinion; those who put the most work in the project get to decide what the software looks like. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list
Re: Killing process
# [EMAIL PROTECTED] / 2005-05-01 05:07:27 -0700: > I actually tried mapping the PID to an integer value and it still > didn't work. At any rate, I found another way to do it. Thanks anyways. What the kind people have been trying to get through is that the win32api.TerminateProcess() does *NOT* take a pid (whether integer or numeric string). Got it? -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- http://mail.python.org/mailman/listinfo/python-list