Re: execute bash builtins in python

2010-03-17 Thread Nobody
On Fri, 12 Mar 2010 08:15:49 -0500, Steve Holden wrote: For shell=True I believe you should provide the command as a single string, not a list of arguments. Using shell=True with an argument list is valid. On Unix, it's seldom what you want: it will invoke /bin/sh to execute the first

Re: Challenge: escape from the pysandbox

2010-03-04 Thread Nobody
On Wed, 03 Mar 2010 03:37:44 +0100, Victor Stinner wrote: I see, makes perfect sense. This then raises the question whether it's important to have a 100% fool proof python sandbox without help from the OS, or this goal is not only too ambitious but also not really a useful one. This is

Re: using subprocess.Popen env parameter

2010-03-04 Thread Nobody
On Wed, 03 Mar 2010 09:05:47 -0800, enda man wrote: cl_path = ms_vc_path + '\VC\bin' The backslash is used as an escape character within string literals. Either use raw strings: cl_path = ms_vc_path + r'\VC\bin' or escape the backslashes: cl_path = ms_vc_path + '\\VC\\bin'

Re: The future of frozen types as the number of CPU cores increases

2010-02-23 Thread Nobody
On Mon, 22 Feb 2010 22:27:54 -0800, sjdevn...@yahoo.com wrote: Basically, multiprocessing is always hard--but it's less hard to start without shared everything. Going with the special case (sharing everything, aka threading) is by far the stupider and more complex way to approach

Re: When will Java go mainstream like Python?

2010-02-23 Thread Nobody
On Wed, 24 Feb 2010 12:22:05 +1300, Lawrence D'Oliveiro wrote: Java - The JVM code been hacked to death by Sun engineers (optimised) Python - The PVM code has seen speed-ups in Unladen or via Pyrex.. ad-infinitum but nowhere as near to JVM Python is still faster, though. I think a key

Re: Fighting with subprocess.Popen

2010-02-15 Thread Nobody
On Sun, 14 Feb 2010 21:43:22 +0100, Christian Heimes wrote: Below is a test case that demonstrates this. Tests 1 2 concatenate the command and the argument, Tests 3 4 mimic the python docs and use the form Popen([mycmd, myarg], ...), which never seems to work. It doesn't work with

Re: Executing a command from within python using the subprocess module

2010-02-15 Thread Nobody
On Tue, 16 Feb 2010 00:11:36 +0800, R (Chandra) Chandrasekhar wrote: One other question I forgot to ask is this why is there a terminal backslash in subprocess.call(\ Removing the backslash makes the function fail. I wonder why, because is supposed to allow multi-line strings. I am

Re: MemoryError, can I use more?

2010-02-12 Thread Nobody
On Fri, 12 Feb 2010 19:21:22 -0500, Echavarria Gregory, Maria Angelica wrote: I am developing a program using Python 2.5.4 in windows 32 OS. The amount of data it works with is huge. I have managed to keep memory footprint low, but have found that, independent of the physical RAM of the

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-11 Thread Nobody
On Wed, 10 Feb 2010 12:17:51 -0800, Anthony Tolle wrote: 4. Consider switching to Python 3.x, since there is only one string type (unicode). However: one drawback of Python 3.x is that the repr() of a Unicode string is no longer restricted to ASCII. There is an ascii() function which behaves

Re: Is a merge interval function available?

2010-02-11 Thread Nobody
On Wed, 10 Feb 2010 23:03:29 -0500, Steve Holden wrote: intervals = sorted(intervals, key = lambda x: x[0]) Since Python uses lexical sorting and the intervals are lists isn't the key specification redundant here? Yes, but I wanted to make it explicit. Well, omitting the key= would

Re: A silly question on file opening

2010-02-10 Thread Nobody
On Wed, 10 Feb 2010 21:23:08 +, Steven D'Aprano wrote: The solution to this is to remember that Windows accepts forward slashes as well as backslashes, and always use the forward slash. So try: open(D:/file) and see if that works. The solution is not to hard-code pathnames in your

Re: Is a merge interval function available?

2010-02-10 Thread Nobody
On Wed, 10 Feb 2010 15:23:42 -0800, Peng Yu wrote: I'm wondering there is already a function in python library that can merge intervals. For example, if I have the following intervals ('[' and ']' means closed interval as in

Re: TABS in the CPython C source code

2010-02-07 Thread Nobody
On Sun, 07 Feb 2010 05:49:28 +, Nobody wrote: The size-8 tabs look really bad in an editor configured with tab size 4, as is common in Windows. I'm concluding that the CPython programmers configure their Visual Studio's to *nix convention. 8-column tabs aren't a *nix convention; that's

Re: WCK and PIL

2010-02-06 Thread Nobody
On Fri, 05 Feb 2010 21:05:53 -0800, darnzen wrote: I've written an app using the wck library (widget construction kit, see http://www.effbot.org), in addition to the wckGraph module. What I'd like to do, is take the output of one of my windows (happens to be a graph), and save it as a *.png

Re: intolerant HTML parser

2010-02-06 Thread Nobody
On Sat, 06 Feb 2010 11:09:31 -0800, Jim wrote: I generate some HTML and I want to include in my unit tests a check for syntax. So I am looking for a program that will complain at any syntax irregularities. I am familiar with Beautiful Soup (use it all the time) but it is intended to cope

Re: How to print all expressions that match a regular expression

2010-02-06 Thread Nobody
On Sun, 07 Feb 2010 00:26:36 +, Steven D'Aprano wrote: So there isn't such a routine just because some of the regular expressions cannot be enumerated. No. There isn't a routine because no-one has yet felt any need to write one. However, some of them can be enumerated. I guess I have to

Re: TABS in the CPython C source code

2010-02-06 Thread Nobody
On Sat, 06 Feb 2010 21:31:52 +0100, Alf P. Steinbach wrote: The size-8 tabs look really bad in an editor configured with tab size 4, as is common in Windows. I'm concluding that the CPython programmers configure their Visual Studio's to *nix convention. 8-column tabs aren't a *nix convention;

Re: Repost: Read a running process output

2010-02-05 Thread Nobody
On Fri, 05 Feb 2010 03:57:17 -0800, Ashok Prabhu wrote: I very badly need this to work. I have been googling out for a week with no significant solution. I open a process p1 which does keeps running for 4+ hours. It gives some output in stdout now and then. I open this process with

Re: Refreshing of urllib.urlopen()

2010-02-04 Thread Nobody
On Wed, 03 Feb 2010 21:33:08 -0600, Michael Gruenstaeudl wrote: I am fairly new to Python and need advice on the urllib.urlopen() function. The website I am trying to open automatically refreshes after 5 seconds and remains stable thereafter. With urllib.urlopen().read() I can only read

Re: read a process output with subprocess.Popen

2010-02-04 Thread Nobody
On Thu, 04 Feb 2010 04:28:20 -0800, Ashok Prabhu wrote: I m trying a read the output of a process which is running continuously with subprocess.Popen. However the readline() method hangs for the process to finish. Please let me know if the following code can be made to work with

Re: Need help with a program

2010-02-03 Thread Nobody
On Tue, 02 Feb 2010 15:07:05 -0800, Aahz wrote: If you have a problem and you think that regular expressions are the solution then now you have two problems. Regex is really overkill for the OP's problem and it certainly doesn't improve readability. If you're going to use a quote, it works

Re: converting XML to hash/dict/CustomTreeCtrl

2010-02-03 Thread Nobody
On Wed, 03 Feb 2010 08:07:50 +1100, Astan Chee wrote: Sorry for being vague but here my question about converting an xml into a dict. I found some examples online but none gives the dict/result I want. Which is kinda wrong. I expect the dict to have the Space usage summary, but it

Re: How to guard against bugs like this one?

2010-02-03 Thread Nobody
On Tue, 02 Feb 2010 10:38:53 -0800, Carl Banks wrote: I don't know if that's necessary. Only supporting the foo.h case would work fine if Python behaved like gcc, i.e. if the current directory referred to the directory contain the file performing the import rather than in the process' CWD.

Re: How to guard against bugs like this one?

2010-02-02 Thread Nobody
be lexically scoped. The general pattern is: 1) You have something which refers to a resource by name. 2) There is a sequence of places which are searched for this name. Searching the current directory by default is the problem. Nobody in their right mind has . in the shell PATH and IMO

Re: Python and Ruby

2010-02-01 Thread Nobody
On Sun, 31 Jan 2010 22:36:32 +, Steven D'Aprano wrote: for example, in if you have a function 'f' which takes two parameters to call the function and get the result you use: f 2 3 If you want the function itself you use: f How do you call a function of no arguments? There's

Re: Python and Ruby

2010-02-01 Thread Nobody
On Mon, 01 Feb 2010 14:35:57 -0800, Jonathan Gardner wrote: If it was common-place to use Curried functions and partial application in Python, you'd probably prefer f a b c to f(a)(b)(c) as well. That's just the point. It isn't common to play with curried functions or monads or anything

Re: Python and Ruby

2010-02-01 Thread Nobody
On Mon, 01 Feb 2010 14:13:38 -0800, Jonathan Gardner wrote: I judge a language's simplicity by how long it takes to explain the complete language. That is, what minimal set of documentation do you need to describe all of the language? That's not a particularly good metric, IMHO. A simple

Re: HTML Parser which allows low-keyed local changes?

2010-02-01 Thread Nobody
On Sun, 31 Jan 2010 20:57:31 +0100, Robert wrote: I tried lxml, but after walking and making changes in the element tree, I'm forced to do a full serialization of the whole document (etree.tostring(tree)) - which destroys the human edited format of the original HTML code. makes it rather

Re: Python and Ruby

2010-01-31 Thread Nobody
On Sat, 30 Jan 2010 16:58:34 +, tanix wrote: I'm not familiar with Ruby, but most languages are cleaner than Python once you get beyond the 10-minute introduction stage. I'd have to agree. The only ones that beat Python in that department are Javascript and PHP. Plus CSS and HTML if you

Re: Python and Ruby

2010-01-31 Thread Nobody
On Sun, 31 Jan 2010 03:01:51 -0800, rantingrick wrote: That's also true for most functional languages, e.g. Haskell and ML, as well as e.g. Tcl and most shells. Why require f(x) or (f x) if f x will suffice? yuck! wrapping the arg list with parenthesis (python way) makes the most sense.

Re: Utility to screenscrape sites using javascript ?

2010-01-31 Thread Nobody
On Sat, 30 Jan 2010 11:28:47 -0800, KB wrote: I have a service I subscribe to that uses javascript to stream news. There's a Python interface to SpiderMonkey (Mozilla's JavaScript interpreter): http://pypi.python.org/pypi/python-spidermonkey Thanks! I don't see a documentation page,

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread Nobody
On Sun, 31 Jan 2010 13:41:55 -0600, Tim Chase wrote: The previous absolute-path fails in cmd.exe for a variety of apps because the / is treated as a parameter/switch to the various programs. Fortunately, the Python path-handling sub-system is smart enough to do the right thing, even when

Re: Default path for files

2010-01-30 Thread Nobody
On Sun, 24 Jan 2010 15:08:15 +, Rotwang wrote: Hi all, can anybody tell me whether there's a way to change the default location for files to be opened by open()? I'd like to be able to create files somewhere other than my Python folder without having to write the full path in the filename

Re: myths about python 3

2010-01-30 Thread Nobody
On Wed, 27 Jan 2010 12:56:10 -0800, John Nagle wrote: Arguably, Python 3 has been rejected by the market. Arguably, Python 3 has not yet been accepted by the market. Part of it is down to a catch-22: applications won't use Python 3 if the libraries on which they depend don't support it, and

Re: Python and Ruby

2010-01-30 Thread Nobody
On Wed, 27 Jan 2010 15:29:05 -0800, Jonathan Gardner wrote: There's a lot of magic in Ruby as well. For instance, function calls are made without parentheses. That's also true for most functional languages, e.g. Haskell and ML, as well as e.g. Tcl and most shells. Why require f(x) or (f x) if

Re: Keyboard input

2010-01-30 Thread Nobody
On Fri, 29 Jan 2010 16:53:43 +, Mr.SpOOn wrote: I'm using the raw_input method and it works fine, but I noted that I can't use backspace and when I accidentally press shift space (because I need to input uppercase letters separated by a space) it writes some strange characters. So, is

Re: Utility to screenscrape sites using javascript ?

2010-01-30 Thread Nobody
On Sat, 30 Jan 2010 06:21:01 -0800, KB wrote: I have a service I subscribe to that uses javascript to stream news. Ideally I would like to use python to parse the information for me. Note there is an option to take a static snapshot of the current stream but that is still done via Javascript.

Re: subprocess troubles

2010-01-22 Thread Nobody
On Thu, 21 Jan 2010 11:25:08 +0100, Tomas Pelka wrote: have a problem with following piece of code: -- import subprocess paattern = python cmd = /usr/bin/locate arg1 = -i arg2 = -d /var/www/books/mlocate.db arg3 = str( + pattern) p1

Re: medians for degree measurements

2010-01-22 Thread Nobody
On Fri, 22 Jan 2010 16:09:03 -0800, Steve Howell wrote: I just saw the thread for medians, and it reminded me of a problem that I need to solve. We are writing some Python software for sailing, and we need to detect when we've departed from the median heading on the leg. Calculating

Re: Problems with the date of modification of files on the flash drive in windows

2010-01-22 Thread Nobody
On Fri, 22 Jan 2010 21:23:37 -0800, Aleksey wrote: I write crossplatform program and have next problem under windows (under linux is all OK) : I'm trying to get the UTC modification date of files on the flash drive under windows. In the flash card system is FAT. Timestamps stored on a FAT

Re: substitution

2010-01-18 Thread Nobody
On Mon, 18 Jan 2010 11:21:54 +0100, superpollo wrote: what is the most pythonic way to substitute substrings? say the subs are: quuux -- foo foo -- bar baz -- quux then i cannot apply the subs in sequence (say, .replace() in a loop), otherwise: fooxxxbazyyyquuux -- fooxxxbazyyyfoo

Re: Is python not good enough?

2010-01-15 Thread Nobody
On Fri, 15 Jan 2010 12:34:17 -0800, John Nagle wrote: Actually, no. It's quite possible to make a Python implementation that runs fast. It's just that CPython, a naive interpreter, is too primitive to do it. I was really hoping that Google would put somebody good at compilers in charge

Re: chr(12) Form Feed in Notepad

2010-01-15 Thread Nobody
On Fri, 15 Jan 2010 10:42:43 -0800, W. eWatson wrote: I thought I'd put a page break, chr(12), character in a txt file I wrote to skip to the top of the page. It doesn't work. Comments? The 1970's are over, and neither Notepad nor your printer attempts to maintain compatibility with a

Re: integer and string compare, is that correct?

2010-01-11 Thread Nobody
On Sun, 10 Jan 2010 23:13:55 -0800, Dan Bishop wrote: If you actually need to perform comparisons across types, you can rely upon the fact that tuple comparisons are non-strict and use e.g.:         a = 5         b = '5'         (type(a).__name__, a) (type(b).__name__, b)         True

Re: sys.stdout vs. sys.stderr

2010-01-11 Thread Nobody
On Mon, 11 Jan 2010 10:09:36 +0100, Martin v. Loewis wrote: In Python 3.1 is there any difference in the buffering behavior of the initial sys.stdout and sys.stderr streams? No. Were they different at some earlier point in Python's evolution? That depends on the operating system. These

Re: pyserial: Unexpected Local Echo

2010-01-11 Thread Nobody
On Mon, 11 Jan 2010 23:27:03 +0800, Steven Woody wrote: I am using pyserial. But I always get the local echo after I write some characters onto serial port and I find no way to disable this behavior. When I say 'local echo', I mean the next read operation will get characters that was just

Re: Interesting (?) problem

2010-01-11 Thread Nobody
On Mon, 11 Jan 2010 18:57:24 +0100, mk wrote: I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. P.S. One clarification: those lists are actually more complicated

Re: subprocess.Popen does not close pipe in an error case

2010-01-10 Thread Nobody
On Wed, 06 Jan 2010 19:05:40 -0800, Steven K. Wong wrote: Well, the example code at http://www.python.org/ ... /subprocess.html#replacing-shell-pipeline has the same issue: Perhaps the doc can be improved to remind folks to close p1.stdout if the calling process doesn't need it, unless

Re: Ask how to use HTMLParser

2010-01-10 Thread Nobody
On Fri, 08 Jan 2010 11:44:48 +0800, Water Lin wrote: I am a new guy to use Python, but I want to parse a html page now. I tried to use HTMLParse. Here is my sample code: -- from HTMLParser import HTMLParser Note that HTMLParser only tokenises HTML; it doesn't actually

Re: lightweight encryption of text file

2010-01-10 Thread Nobody
On Fri, 08 Jan 2010 20:14:51 +0100, Daniel Fetchinson wrote: I have a plain text file which I would like to protect in a very simple minded, yet for my purposes sufficient, way. I'd like to encrypt/convert it into a binary file in such a way that possession of a password allows anyone to

Re: lightweight encryption of text file

2010-01-10 Thread Nobody
On Sun, 10 Jan 2010 09:59:31 +0100, Daniel Fetchinson wrote: Thanks, this looks very simple too, but where is the decryption code? Wikipedia seems to suggest that encryption and decryption are both the same but running crypt on the output of crypt doesn't give back the original string. So

Re: lightweight encryption of text file

2010-01-10 Thread Nobody
On Sun, 10 Jan 2010 15:30:12 +, Steven D'Aprano wrote: Thanks, this looks very simple too, but where is the decryption code? Wikipedia seems to suggest that encryption and decryption are both the same but running crypt on the output of crypt doesn't give back the original string. So

Re: integer and string compare, is that correct?

2010-01-10 Thread Nobody
Hellmut Weber wrote: being a causal python user (who likes the language quite a lot) it took me a while to realize the following: max = '5' n = 5 n = max False Section 5.9 Comparison describes this. Can someone give me examples of use cases Peter Otten wrote: The use cases

Re: lightweight encryption of text file

2010-01-10 Thread Nobody
On Sun, 10 Jan 2010 08:54:51 -0800, Paul Rubin wrote: Nobody nob...@nowhere.com writes: RC4 (aka ArcFour) is quite trivial to implement, and better than inventing your own cipher or using a Vignere: ... That's a cute implementation, but it has no authentication and doesn't include any

Re: lightweight encryption of text file

2010-01-10 Thread Nobody
On Sun, 10 Jan 2010 12:26:05 -0800, Paul Rubin wrote: I'd like it a lot if the Python stdlib could include a serious cryptography module. And I'd like a truckload of gold ;) Right now, even asking for HTTPS support is too much to ask. Heck, even asking for the fake HTTPS support to be

Re: subprocess.Popen does not close pipe in an error case

2010-01-09 Thread Nobody
On Wed, 06 Jan 2010 11:39:37 -0800, Steven K. Wong wrote: Suppose now all the prog1.poll() calls/loop are replaced by a single prog1.wait(). Without the explicit prog1.stdout.close(), prog1.wait() will not return, so the calling process still hangs. Because calling prog1.wait() means that the

Re: Printing plain text with exact positioning on Windows

2010-01-07 Thread Nobody
On Tue, 05 Jan 2010 11:40:25 -0800, KvS wrote: Hardcopy document formats such as PostScript and PDF use positions relative to the edges of the page, not the margins. Right. Still, Acrobat Reader by default scales the contents to fit on a page and creates some margins by doing so, no? So if

Re: please help shrink this each_with_index() implementation

2010-01-06 Thread Nobody
On Tue, 05 Jan 2010 12:20:58 -0800, Marco Nawijn wrote: You could use the build-in function enumerate inside a list comprehension. seq = range(5) [ (i,s) for i,s in enumerate(seq) ] [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)] Just use list(), i.e. list(enumerate(seq)). --

Re: please help shrink this each_with_index() implementation

2010-01-06 Thread Nobody
On Tue, 05 Jan 2010 19:46:01 -0800, alex23 wrote: They will tell me how to use except: (which is a good example why a program should not use exceptions for its normal control flow if at all possible). Really? Magic functions that coerce and eat errors are a better coding technique than

Re: subprocess.Popen does not close pipe in an error case

2010-01-06 Thread Nobody
On Tue, 05 Jan 2010 15:50:39 -0800, Steven K. Wong wrote: Below, I have a Python script that launches 2 child programs, prog1 and prog2, with prog1's stdout connected to prog2's stdin via a pipe. (It's like executing prog1 | prog2 in the shell.) If both child programs exit with 0, then the

Re: IOError - cannot create file (linux daemon-invoked script)

2010-01-05 Thread Nobody
On Mon, 04 Jan 2010 21:30:31 -0800, cassiope wrote: One more tidbit observed: my last note, that it works when using seteuid/setegid? Well - that only applies if the daemon is running under strace (!). It fails if started directly by root, or if the strace session has ended, leaving the

Re: fsync() doesn't work as advertised?

2010-01-05 Thread Nobody
On Mon, 04 Jan 2010 08:09:56 -0800, Brian D wrote: If I'm running a process in a loop that runs for a long time, I occasionally would like to look at a log to see how it's going. I know about the logging module, and may yet decide to use that. Still, I'm troubled by how fsync() doesn't

Re: IOError - cannot create file (linux daemon-invoked script)

2010-01-04 Thread Nobody
On Sun, 03 Jan 2010 13:56:24 -0800, cassiope wrote: I'm changing the uid and gid in the daemon (which runs with root permissions until the fork and uid/gid change). The uid and gid are confirmed by printing os.getuid() and os.getgid() in the script. Those tell you the *real* UID/GID.

Re: Potential Conflicts by Installing Two Versions of Python (Windows)?

2010-01-02 Thread Nobody
On Fri, 01 Jan 2010 17:37:40 -0800, W. eWatson wrote: I suspect that if one installs v2.4 and 2.5, or any two versions, that one will dominate, or there will be a conflict. I suppose it would not be possible to choose which one should be used. Comments? The only inherent conflict is that

Re: Simple distributed example for learning purposes?

2009-12-30 Thread Nobody
On Sat, 26 Dec 2009 20:06:02 +, Tim Golden wrote: I'm trying to come up with something which will illustrate the usefulness of a distributed processing model. Since I may not be using the term distributed exactly, my criteria are: * It should be clear that the application produces

Re: subprocess returncode is masked

2009-12-30 Thread Nobody
On Mon, 28 Dec 2009 17:12:23 +0100, Emmanuel wrote: I'm using Python 2.6 and the new subprocess module to get the exit value of an external executable. It appears the return value given by wait() or poll() operations is masked under Unix: I only get the lower 8 bits. So an exit value of

Re: Portable way to tell if a process is still alive

2009-12-30 Thread Nobody
On Tue, 29 Dec 2009 12:35:11 +0430, Laszlo Nagy wrote: Suppose we have a program that writes its process id into a pid file. Usually the program deletes the pid file when it exists... But in some cases (for example, killed with kill -9 or TerminateProcess) pid file is left there. I would

Re: python gtk: input box and enter

2009-12-23 Thread Nobody
On Tue, 22 Dec 2009 23:41:31 -0800, edgue wrote: How do I use gtk to enter a (hidden) text press ENTER ... done? Connect the gtk.Entry's activate signal to the click() method: self.entry.connect(activate, self.click) -- http://mail.python.org/mailman/listinfo/python-list

Re: Seek support for new slice syntax PEP.

2009-12-18 Thread Nobody
On Fri, 18 Dec 2009 09:49:26 -0500, Colin W. wrote: You don't say, but seem to imply that the slice components include None. That's how missing components are implemented at the language level: class foo: = def __getitem__(self, s): = return s =

Re: Seek support for new slice syntax PEP.

2009-12-17 Thread Nobody
On Mon, 14 Dec 2009 14:18:49 -0500, Terry Reedy wrote: Many more people uses range objects (xrange in 2.x). A range object has the same info as a slice object *plus* it is iterable. This isn't quite true, as a range cannot have a stop value of None, i.e. you can't represent [n:] or [:] etc as

Re: read text file byte by byte

2009-12-16 Thread Nobody
On Mon, 14 Dec 2009 21:37:33 -0300, Gabriel Genellina wrote: There are no file objects in 3.x. The file() function no longer exists. The return value from open(), will be an instance of _io.something depending upon the mode, e.g. _io.TextIOWrapper for 'r', _io.BufferedReader for 'rb',

Re: read text file byte by byte

2009-12-14 Thread Nobody
On Sun, 13 Dec 2009 22:56:55 -0800, sjdevn...@yahoo.com wrote: The 3.1 documentation specifies that file.read returns bytes: Does it need fixing? There are no file objects in 3.x. The file() function no longer exists. The return value from open(), will be an instance of _io.something

Re: read text file byte by byte

2009-12-14 Thread Nobody
On Mon, 14 Dec 2009 03:14:11 +, MRAB wrote: You originally stated that you want to scramble the bytes -- if you mean to implement some sort of encryption algorithm you should know that most of them work in blocks as the key is longer than one byte. Block ciphers work in blocks.

Re: Seek support for new slice syntax PEP.

2009-12-14 Thread Nobody
On Mon, 14 Dec 2009 10:03:16 -0800, Dave wrote: Just as sets may now be written as {3,'hi'}, I propose that slices should be available using [start:end] syntax. Following example comes from projecteuler.net problem 166. The Numeric community would also like this, as would the general python

Re: Moving from PHP to Python. Is it Possible

2009-12-13 Thread Nobody
On Fri, 11 Dec 2009 12:26:30 +0200, Sancar Saran wrote: 1-) Can I create Global (read/write access anywhere from my code) Multi dimensional, associative array (or hash) and store any kind of variable type. Global, no; at least not in the sense of e.g. C. Python doesn't have a global

Re: read text file byte by byte

2009-12-13 Thread Nobody
On Sun, 13 Dec 2009 12:39:26 -0800, Dennis Lee Bieber wrote: You originally stated that you want to scramble the bytes -- if you mean to implement some sort of encryption algorithm you should know that most of them work in blocks as the key is longer than one byte. Block ciphers work in

Re: a list/re problem

2009-12-12 Thread Nobody
On Fri, 11 Dec 2009 12:49:42 -0800, Ed Keith wrote: the following works: r = re.compile('\*(.+)\*') def f(s): m = r.match(s) if m: return m.group(1) else: return '' n = [f(x) for x in l if r.match(x)] But it is inefficient, because it is

Re: switch

2009-12-10 Thread Nobody
On Thu, 10 Dec 2009 05:47:19 +, Steven D'Aprano wrote: I string together a bunch of elif statements to simulate a switch if foo == True: blah elif bar == True: blah blah elif bar == False: blarg elif This isn't what would normally be considered a switch (i.e.

Re: subprocess kill

2009-12-09 Thread Nobody
On Mon, 07 Dec 2009 11:04:06 +0100, Jean-Michel Pichavant wrote: When using shell=True, your process is started in a shell, meaning the PID of your subprocess is not self.luca.pid, self.luca.pid is the PID of the shell. This isn't true for a simple command on Unix (meaning a program name

Re: When will Python 3 be fully deployed

2009-12-09 Thread Nobody
On Sun, 06 Dec 2009 22:10:15 +, Edward A. Falk wrote: I recently read that many libraries, including Numpy have not been ported to Python 3. When do you think that Python 3 will be fully deployed? It will never be fully deployed. There will always be people out there who haven't felt it

Re: switch

2009-12-09 Thread Nobody
On Tue, 08 Dec 2009 21:02:44 -0800, Kee Nethery wrote: I string together a bunch of elif statements to simulate a switch if foo == True: blah elif bar == True: blah blah elif bar == False: blarg elif This isn't what would normally be considered a switch (i.e.

Re: When will Python 3 be fully deployed

2009-12-09 Thread Nobody
On Wed, 09 Dec 2009 10:28:40 -0800, Rami Chowdhury wrote: But on Unix, it's a square-peg-round-hole situation. I dunno, I find it rather useful not to have to faff about with encoding to/from when working with non-ASCII files (with non-ASCII filenames) on Linux. For the kind of task I'm

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-12-05 Thread Nobody
On Fri, 04 Dec 2009 00:33:57 +, Steven D'Aprano wrote: Just to be contrary, I *like* mbox. Me too. :-) Me too. Why? What features or benefits of mbox do you see that make up for it's disadvantages? Simplicity and performance. Maildir isn't simple when you add in the filesystem or

Re: question about subprocess and shells

2009-12-05 Thread Nobody
On Fri, 04 Dec 2009 13:38:11 -0800, Ross Boylan wrote: If one uses subprocess.Popen(args, ..., shell=True, ...) When args finishes execution, does the shell terminate? Either way seems problematic. That depends upon what args is. On Unix, if args ends with a , the shell will terminate as

Re: Specifying an API for a straeming parser

2009-12-05 Thread Nobody
On Fri, 04 Dec 2009 13:51:15 -0800, tyler wrote: Howdy folks, I'm working on a JSON Python module [1] and I'm struggling with an appropriate syntax for dealing with incrementally parsing streams of data as they come in (off a socket or file object). The underlying C-level parsing library

Re: Help in wxpython

2009-12-03 Thread Nobody
On Thu, 03 Dec 2009 07:55:19 +, r0g wrote: I have to recommend to opposite, stick with wx. What's the point of tying yourself into GTK when wx works on Mac, PC and Linux? The main drawbacks are that wxWidgets sucks compared to GTK or Qt (mostly due to being modelled on the Win32 API, which

Re: Object Not Callable, float?

2009-11-30 Thread Nobody
On Mon, 30 Nov 2009 01:07:53 -0500, Mel wrote: In FORTRAN and PL/I words were un-reserved to a degree that's really bizarre. A short post can't begin to do it justice -- let's just mention that IF and THEN could be variable names, and DO 100 I=1.10 . The syntaxes were carefully crafted

Re: TypeError: an integer is required

2009-11-30 Thread Nobody
On Sun, 22 Nov 2009 18:29:25 +, MRAB wrote: os.open(C://Users//lutfi//Documents//te//log.txt , a ) open(C://Users//lutfi//Documents//te//log.txt , a ) Backslashes need to be doubled; forward slashes don't. -- http://mail.python.org/mailman/listinfo/python-list

Re: python and vc numbers

2009-11-30 Thread Nobody
On Mon, 30 Nov 2009 21:02:00 +1100, Daniel Dalton wrote: That did the trick, thanks, after I append [-2] Further testing under screen says otherwise -- it seems to give me the tty number, not the virtual console number. Is there any way to figure out what virtual console I'm am in I'm

Re: peppy

2009-11-30 Thread Nobody
On Tue, 01 Dec 2009 08:51:20 +0200, Johann Spies wrote: After reading about peppy on Freshmeat I decided to try it out after installing it using easy_install. But: $ peppy File /usr/lib/python2.5/site-packages/peppy-0.13.2-py2.5.egg/peppy/lib/multikey.py, line 120, in module

Re: Minimally intrusive XML editing using Python

2009-11-23 Thread Nobody
On Mon, 23 Nov 2009 17:45:24 +0100, Thomas Lotze wrote: What's your real problem, or use case? Are you just concerned with diffing, or are others likely to read the xml, and want it formatted the way it already is? I'd like to put the XML under revision control along with other stuff.

Re: Relative versus absolute paths on Windows

2009-11-23 Thread Nobody
On Tue, 24 Nov 2009 02:23:19 +0100, Christian Heimes wrote: Gregory Ewing wrote: ntpath.join('d:\\foo', '\\bar') '\\bar' This does seem like a bug, though -- the correct result should really be 'd:\\bar', since that's what you would get if you used the name '\\bar' with 'd:' as your

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-23 Thread Nobody
On Mon, 23 Nov 2009 22:06:29 +0100, Alf P. Steinbach wrote: 10. It says UnicodeDecodeError on mail nr. something something. That's what you get for using Python 3.x ;) If you must use 3.x, don't use the standard descriptors. If you must use the standard descriptors in 3.x, call detach() on

Re: sys.stdout is not flushed

2009-11-23 Thread Nobody
On Mon, 23 Nov 2009 23:08:25 +0100, Diez B. Roggisch wrote: Try printing stdout.write('\r--%d') ^M--0^M--1^M--2^M--3... ;) But it's probably good enough for the OP's purposes. -- http://mail.python.org/mailman/listinfo/python-list

Re: Imitating tail -f

2009-11-22 Thread Nobody
On Sun, 22 Nov 2009 03:43:31 +0100, Ivan Voras wrote: The problem is: poll() always returns that the fd is ready (without waiting), but read() always returns an empty string. Actually, it doesn't matter if I turn O_NDELAY on or off. select() does the same. Regular files are always ready for

Re: python simply not scaleable enough for google?

2009-11-21 Thread Nobody
On Fri, 20 Nov 2009 09:51:49 -0800, sturlamolden wrote: You can make a user-space scheduler and run a 10 tasklets on a threadpool. But there is a GIL in stackless as well. Nobody wants 10 OS threads, not with Python, not with Go, not with C. Also note that Windows has native

Re: Go versus Brand X

2009-11-21 Thread Nobody
On Fri, 20 Nov 2009 17:12:36 -0800, Aahz wrote: Comparing Go to another computer language -- do you recognize it? Here is a language so far ahead of its time that it was not only an improvement on its predecessors but also on nearly all its successors. - C. A. R. Hoare (although he was

Re: getting properly one subprocess output

2009-11-20 Thread Nobody
On Thu, 19 Nov 2009 06:21:09 -0800, Bas wrote: Below is the script I use to automatically kill firefox if it is not behaving, maybe you are looking for something similar. lines = os.popen('ps ax|grep firefox').readlines() This isn't robust. It will kill any process with firefox anywhere in

Re: Command line arguments??

2009-11-18 Thread Nobody
On Tue, 17 Nov 2009 23:57:55 +, Rhodri James wrote: Quote the filenames or escape the spaces: C:\Python26\Python.exe C:\echo.py C:\New Folder\text.txt We've been living with this pain ever since windowed GUIs encouraged users to put spaces in their file names (Apple, I'm looking at

Re: getting properly one subprocess output

2009-11-18 Thread Nobody
On Wed, 18 Nov 2009 12:25:14 +0100, Jean-Michel Pichavant wrote: I'm currently inspecting my Linux process list, trying to parse it in order to get one particular process (and kill it). I ran into an annoying issue: The stdout display is somehow truncated (maybe a terminal length issue, I

<    1   2   3   4   5   6   7   8   >