Re: Speed-up for loops

2010-09-03 Thread Nobody
On Fri, 03 Sep 2010 11:21:36 +0200, Michael Kreim wrote: An anonymous Nobody suggested to use Numpy. I did not do this, because I am very very new to Numpy and I did not figure out a Numpy specific way to do this. Maybe a Numpy expert has something for me? The problem with giving examples

Re: Difference between queues and pipes in multiprocessing

2010-09-09 Thread Nobody
On Thu, 09 Sep 2010 12:23:17 -0700, Ethan Furman wrote: basically a Queue is a syncronization primitive used to share and pass data to and from parent/child processes. A pipe is as the name suggests, a socket pair connected end-to-end allowing for full-duplex communications. Isn't a

Re: accessing a text file

2010-09-09 Thread Nobody
On Wed, 08 Sep 2010 03:30:00 -0700, Baba wrote: Who is licensed to judge what can and cannot be posted as a question? Exactly the same set of people who are licensed to judge what can and cannot be posted as an answer. If you don't like the responses you get here, you could try posting your

Re: Catching a SIGSEGV signal on an import

2010-09-09 Thread Nobody
On Thu, 09 Sep 2010 05:23:14 -0700, Ryan wrote: But, since SIGSEGV is asynchronous SIGSEGV is almost always synchronous. In general, is there anyway to catch a SIGSEGV on import? No. If SIGSEGV is raised, it often indicates that memory has been corrupted. At that point, you can't assume

Re: Expected bahaviour of os.chroot and os.getcwd

2010-09-14 Thread Nobody
On Mon, 13 Sep 2010 19:04:53 +0100, r0g wrote: i.e. So do I always have to change directory after changing into a chroot? You don't *have* to change the directory, but not doing so probably defeats the point of performing a chroot(). The reason I ask is because an app I was running inside the

Re: Converting an ugly path to a shell path

2010-09-14 Thread Nobody
On Tue, 14 Sep 2010 01:07:48 +0200, AmFreak wrote: im using a QFileDialog to let the user select a path that is used later in a command send to the shell like this: retcode = Popen(command + + path, shell=True, stdout = PIPE, stderr = PIPE) The problem that occurs now is when the

Re: os.path.normcase rationale?

2010-09-16 Thread Nobody
On Wed, 15 Sep 2010 14:49:09 +0100, Chris Withers wrote: I'm curious as to why, with a file called Foo.txt os.path.normcase('FoO.txt') will return foo.txt rather than Foo.txt? normcase() doesn't look at the filesystem; it's just string manipulation. --

Re: os.path.normcase rationale?

2010-09-16 Thread Nobody
On Thu, 16 Sep 2010 07:12:16 +1000, Ben Finney wrote: Yes, I know the behaviour is documented The docstring is fairly poor, IMO. You might want to submit a bug report to improve it. The description in the library documentation is misleading: os.path.normcase(path) Normalize the case of

Re: socket.error: [Errno 98] Address already in use

2010-09-18 Thread Nobody
On Sun, 19 Sep 2010 12:27:08 +1200, Lawrence D'Oliveiro wrote: That's why Stevens recommends that all TCP servers use the SO_REUSEADDR socket option. I don’t think I’ve ever used that. It seems to defeat a safety mechanism which was put in for a reason. It was put in for the benefit of

Re: socket.error: [Errno 98] Address already in use

2010-09-19 Thread Nobody
On Sun, 19 Sep 2010 18:42:51 +1200, Lawrence D'Oliveiro wrote: That's why Stevens recommends that all TCP servers use the SO_REUSEADDR socket option. I don’t think I’ve ever used that. It seems to defeat a safety mechanism which was put in for a reason. It was put in for the benefit of

Re: socket.error: [Errno 98] Address already in use

2010-09-21 Thread Nobody
On Mon, 20 Sep 2010 12:00:41 +1200, Lawrence D'Oliveiro wrote: However, some clients choose their own source ports. E.g. rlogin/rsh use privileged (low-numbered) ports, and you can't get the kernel to choose a random privileged port for you. But nobody uses rlogin/rsh any more, They did

Re: os.path.normcase rationale?

2010-09-21 Thread Nobody
On Tue, 21 Sep 2010 10:12:27 +1000, Ben Finney wrote: Another is that filesystems don't have a standard way of determining whether they are case-sensitive. The operating system's driver for that particular filesystem knows, I'm not even sure that's true; with a networked filesytem, some parts

Re: Arrays and CTYPE

2010-09-21 Thread Nobody
On Mon, 20 Sep 2010 15:47:32 -0700, Glenn Pringle wrote: Ok. I ran into a problem here. I have been dabbling with Python and I thought that this would be a good exercise but I got stuck. I have a DLL and one of the functions(getState) in that DLL returns an array. If the DLL was written in

Re: Subprocess does not return for longer-running process

2010-09-22 Thread Nobody
On Tue, 21 Sep 2010 23:54:04 -0700, Dennis Lee Bieber wrote: As your Traceback clearly indicates, the Popen() call has already completed; it's *the os.waitpid() call* that's blocking, but that's entirely to be expected given its defined behavior. If you don't want to wait around for the

Re: how to get partition information of a hard disk with python

2010-09-22 Thread Nobody
On Wed, 22 Sep 2010 00:31:04 +0200, Hellmut Weber wrote: I'm looking for a possibility to access the partiton inforamtion of a hard disk of my computer from within a python program. Have you considered parsing /proc/partitions? -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way for rotating a matrix of data?

2010-09-22 Thread Nobody
On Tue, 21 Sep 2010 19:38:06 -0700, Raphaël Plasson wrote: Actually, I more precisely extract my 2D array from much higher dimensions data (i.e. 10-20 fields of different data in 3 dimensions of space+1 dimension of time), contained in a hdf5 file. I typically would like to extract arbitrary

Re: Subprocess does not return for longer-running process

2010-09-23 Thread Nobody
On Thu, 23 Sep 2010 12:25:53 +1200, Lawrence D'Oliveiro wrote: And I can't think of any reason why you should use os.waitpid() or similar; use the .wait() method. I have used WNOHANG to poll for completion of a subprocess while providing progress updates to the user. This can be done via

Re: Check whether file is being written to

2010-09-23 Thread Nobody
On Thu, 23 Sep 2010 17:55:52 +0200, Diez B. Roggisch wrote: Last time I checked, file-locking in unix was co-operative. Linux supports mandatory locking, but it's seldom enabled. -- http://mail.python.org/mailman/listinfo/python-list

Re: Subprocess does not return for longer-running process

2010-09-24 Thread Nobody
On Fri, 24 Sep 2010 15:18:47 +1200, Lawrence D'Oliveiro wrote: And I can't think of any reason why you should use os.waitpid() or similar; use the .wait() method. I have used WNOHANG to poll for completion of a subprocess while providing progress updates to the user. This can be done via

Re: Raw Sockets - IP-Encapsulation

2010-09-24 Thread Nobody
On Thu, 23 Sep 2010 21:41:19 +0200, Matthias Guentert wrote: I would like to create an IP tunnel using the IP protocol type 4 (socket.IPPROTO_IPIP) on a Linux host. (I also would be happy if I could create a GRE tunnel) The thing is, I just don't understand how I such a socket could be

Re: SocketServer: replace network by hard drive

2010-09-25 Thread Nobody
On Fri, 24 Sep 2010 19:28:45 +0200, Thomas Jollans wrote: If you're using UNIX, and you don't actually need the stream to be passed via the hard drive (why would you?), but for some reason want to use the file system, look info UNIX/local sockets. But, really, I'm guessing that local TCP

Re: SocketServer: replace network by hard drive

2010-09-25 Thread Nobody
On Sat, 25 Sep 2010 14:45:29 +0200, Thomas Jollans wrote: The problem with using the loopback interface is that it's still network access, which can run into all kinds of issues with security policies, firewalls, etc. What kind of crappy firewall blocks loopback traffic? Really? The sort

Re: how to get partition information of a hard disk with python

2010-09-30 Thread Nobody
On Thu, 30 Sep 2010 11:41:48 +0300, Anssi Saari wrote: I'm looking for a possibility to access the partiton inforamtion of a hard disk of my computer from within a python program. Have you considered parsing /proc/partitions? One could also just read the partition table directly, it's on

Re: Crummy BS Script

2010-10-03 Thread Nobody
On Sat, 02 Oct 2010 22:15:31 -0700, flebber wrote: Cargo Cult Coding? Not sure what it is but it sounds good. Imitation without understanding, aka monkey-see-monkey-do. http://en.wikipedia.org/wiki/Cargo_cult -- http://mail.python.org/mailman/listinfo/python-list

Re: SQLite is quite SQL compliant

2010-10-03 Thread Nobody
On Sat, 02 Oct 2010 13:06:12 -0700, Ravi wrote: The documentation of the sqlite module at http://docs.python.org/library/sqlite3.html says: ...allows accessing the database using a nonstandard variant of the SQL... But if you see SQLite website they clearly say at

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-05 Thread Nobody
On Tue, 05 Oct 2010 13:57:11 +1100, Ben Finney wrote: Here's your problem. Don't ever use a bare ‘except’ unless you know exactly why you're doing so. Rather, figure out what exception types you want to catch, and catch *only* those types. If I use a bare except, I usually have a good reason,

Re: Unicode Support in Ruby, Perl, Python, Emacs Lisp

2010-10-10 Thread Nobody
On Sat, 09 Oct 2010 15:45:42 -0700, Sean McAfee wrote: I'll have to say, as far as text processing goes, the most beautiful lang with respect to unicode is emacs lisp. In elisp code (e.g. Generate a Web Links Report with Emacs Lisp ), i don't have to declare none of the unicode or encoding

Re: Help with pointers when calling from python to C

2010-10-10 Thread Nobody
On Fri, 08 Oct 2010 18:02:15 +0200, Jonas H. wrote: On 10/08/2010 05:23 PM, Carolyn MacLeod wrote: How do I pass an integer by reference to a C function? That's impossible in pure Python. The only thing I can think of is a wrapper in C. I didn't see the original message, but if you're

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-11 Thread Nobody
On Mon, 11 Oct 2010 05:42:39 -0700, Ethan Furman wrote: If I'm catching exceptions in order to perform clean-up, I'll use a bare except and re-raise the exception afterwards. In that situation, a bare except is usually the right thing to do. Wrong way to do it. What, then, is the right way

Re: How is correct use of eval()

2010-10-11 Thread Nobody
On Mon, 11 Oct 2010 11:18:37 -0700, Chris Rebert wrote: What is correct way to use this function? To not use it in the first place if at all possible (use int(), float(), getattr(), etc. instead, Use read(). Oh wait, Python doesn't have that. Because parsing literals and executing code are

Re: How is correct use of eval()

2010-10-11 Thread Nobody
On Tue, 12 Oct 2010 01:26:25 +0100, Nobody wrote: What is correct way to use this function? To not use it in the first place if at all possible (use int(), float(), getattr(), etc. instead, Use read(). Oh wait, Python doesn't have that. Because parsing literals and executing code

Re: send command to parent shell

2010-10-13 Thread Nobody
On Wed, 13 Oct 2010 06:30:15 -0700, Martin Landa wrote: is there a way how to send command from python script to the shell (known id) from which the python script has been called? For Unix, this should work, but in general it's the wrong thing to do: import os import signal

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-13 Thread Nobody
On Wed, 13 Oct 2010 14:58:57 -0700, Roger Davis wrote: My understanding is that this functionality is best coded via subprocess.Popen(). I need to read output from these spawned children via a pipe from their stdout, hence something like p= subprocess.Popen(args,

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-15 Thread Nobody
On Thu, 14 Oct 2010 08:48:45 -0700, Roger Davis wrote: On a related point here, I have one case where I need to replace the shell construct externalprog somefile otherfile I suppose I could just use os.system() here but I'd rather keep the Unix shell completely out of the picture

Re: open() throws permission error and I don't get why

2010-10-15 Thread Nobody
locations. I've established, through logging, that postfix runs my script with UID nobody GID nobody. The directory I'm attempting to write has permissions 0770. The directory's group is not nobody, but the user nobody is a member of the relevant group. Nevertheless, python throws an IOError

Re: please help explain this result

2010-10-17 Thread Nobody
On Sun, 17 Oct 2010 03:58:21 -0700, Yingjie Lan wrote: I played with an example related to namespaces/scoping. The result is a little confusing: a=1 def f(): a = a + 1 return a f() UnboundLocalError: local variable 'a' referenced before assignment If you want to modify a

Re: Classes in a class: how to access variables from one in another

2010-10-18 Thread Nobody
On Mon, 18 Oct 2010 14:35:58 +, fab wrote: So my way of coding it is the following: class zone(GtkDrawingArea): class systemOfCoordinates: self.xmin = -5 self.xmax = 5 self.ymin = -5 self.ymax = 5 self isn't meaningful within a class definition. It's far from

Re: Script to capture stderr of subprocess

2010-10-20 Thread Nobody
On Tue, 19 Oct 2010 11:21:49 -0700, jslow...@gmail.com wrote: Actually, if it was possible, it would be nice to capture all the bytes going between stdin and stdout in a file as well for debugging purposes. If the child process expects to be running on a terminal, you would need to use a

Re: Filename for stdout

2010-10-21 Thread Nobody
Richard Gibbs richard.gi...@smooth-stone.com wrote: If my python script is called with stdout (or stdin or stderr) redirected to a file, how can I find the filename under Linux?  Under Windows? On Linux, you can read the /proc/self/fd/* symlinks, e.g.: stdin_filename =

Re: memory management - avoid swapping/paging

2010-10-21 Thread Nobody
On Thu, 21 Oct 2010 02:34:15 -0700, Jon Clements wrote: I'm after something that says: I want 512mb of physical RAM, I don't want you to page/swap it, if you can't do that, don't bother at all. Now I'm guessing, that an OS might be able to grant that, but later on have to kill the process as

Re: python shell silently ignores termios.tcsetattr()

2010-10-21 Thread Nobody
On Wed, 20 Oct 2010 16:18:57 +, kj wrote: I tried to fix the problem by applying the equivalent of stty -echo within a python interactive session, but discovered that this setting is immediately (and silently) overwritten. FWIW, I don't see this behaviour with Python 2.6.5 on Linux. If I

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-26 Thread Nobody
On Tue, 26 Oct 2010 14:44:11 +, Grant Edwards wrote: There is no difference based on the name of your executable, how it is built, or what libraries it links to; the only difference is in its run-time behaviour, whether it invokes any GUI functions or not. No, we're not talking about

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-26 Thread Nobody
On Wed, 27 Oct 2010 13:46:28 +1300, Lawrence D'Oliveiro wrote: Why would you want both CLI and GUI functions in one program? An obvious example was the one which was being discussed, i.e. the Python interpreter. Depending upon the script, it may need to behave as a command-line utility (read

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-28 Thread Nobody
On Thu, 28 Oct 2010 12:54:03 +1300, Lawrence D'Oliveiro wrote: Why would you want both CLI and GUI functions in one program? An obvious example was the one which was being discussed, i.e. the Python interpreter. But the Python interpreter has no GUI. It may have one if you use wx,

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Nobody
On Fri, 05 Nov 2010 10:12:05 -0400, Philip Semanchuk wrote: As others have said, ^ is for XOR. That's buried here in the documentation: http://docs.python.org/release/2.7/reference/... Not that I would have expected you to find it there since that's pretty dense. In fact, older versions of

Re: *** glibc detected *** gdb: malloc(): smallbin double linked list

2010-11-05 Thread Nobody
On Fri, 05 Nov 2010 19:39:12 +, John Reid wrote: I've compiled Python 2.7 (r27:82500, Nov 2 2010, 09:00:37) [GCC 4.4.3] on linux2 with the following configure options ./configure --prefix=/home/john/local/python-dbg --with-pydebug I've installed numpy and some other packages but

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Nobody
On Fri, 05 Nov 2010 22:51:10 +, Seebs wrote: IMHO, the lack of a reference manual for the language itself is a major hole in Python's documentation. I'm a bit lost here. Could you highlight some of the differences between a reference manual for the language itself and something written

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Nobody
On Sun, 07 Nov 2010 00:06:25 +, Steven D'Aprano wrote: A reference manual tells you how to use the language. A specification tells you how to implement it. Surely a tutorial tells you *how* to use the language. I wouldn't expect a reference manual to teach me how to run and edit

Re: http error 301 for urlopen

2010-11-07 Thread Nobody
On Sun, 07 Nov 2010 20:51:50 -0500, D'Arcy J.M. Cain wrote: urllib2.HTTPError: HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop. The last 30x error message was: Moved Permanently I can open the link in browser. Any way to get solve this? Thanks.

Re: Commercial or Famous Applicattions.?

2010-11-10 Thread Nobody
On Wed, 10 Nov 2010 13:07:58 +, Martin Gregorie wrote: FWIW the thing that really irritated me about fetchmail is the way it only deletes messages at the end of a session and never cleans up after itself. If a session gets timed out or otherwise interrupted the messages that were read

Re: multiple discontinued ranges

2010-11-10 Thread Nobody
On Wed, 10 Nov 2010 09:34:14 -0800, xoff wrote: I am curious, why wouldn't you advise something like this: for i in chain(range(3,7) + range(17,23)): Because it constructs all three lists (both of the individual ranges and their concatenation) in memory. For a trivial example, that isn't a

Re: subprocess pipe

2010-11-15 Thread Nobody
On Sun, 14 Nov 2010 19:47:55 +, Tim Harig wrote: On 2010-11-14, Camille Harang mammi...@garbure.org wrote: # pg_dump prompts for password so I inject it in stdin. pgsql.stdin.write('MY_PASSWORD' + '\n') For security reasons, some programs use direct access to the TTY system for

Re: Flush stdin

2014-10-18 Thread Nobody
On Fri, 17 Oct 2014 12:38:54 +0100, Empty Account wrote: I am using netcat to listen to a port and python to read stdin and print to the console. nc -l 2003 | python print_metrics.py sys.stdin.flush() doesn’t seem to flush stdin, You can't flush an input stream. so I am using the

Re: Flush stdin

2014-10-18 Thread Nobody
On Sat, 18 Oct 2014 12:32:07 -0500, Tim Chase wrote: On 2014-10-18 17:55, Nobody wrote: On Fri, 17 Oct 2014 12:38:54 +0100, Empty Account wrote: I am using netcat to listen to a port and python to read stdin and print to the console. nc -l 2003 | python print_metrics.py

Re: Flush stdin

2014-10-21 Thread Nobody
On Sat, 18 Oct 2014 18:42:00 -0700, Dan Stromberg wrote: On Sat, Oct 18, 2014 at 6:34 PM, Dan Stromberg drsali...@gmail.com wrote: Once the nc process actually write()s the data to its standard output (i.e. desriptor 1, not the stdout FILE*) I'm not sure why you're excluding stdout, but even

Re: Status of side-effecting functions in python

2014-10-27 Thread Nobody
On Mon, 27 Oct 2014 17:14:58 +0200, Marko Rauhamaa wrote: In POSIX, a write(2) system call on file blocks until all bytes have been passed on to the file system. The only exception (no pun intended) I know is the reception of a signal. Writing to a file (or block device) will return a short

Re: accents in windows

2014-10-31 Thread Nobody
On Thu, 30 Oct 2014 08:30:49 -0400, C@rlos wrote: thanks U, but the real problem is: i have a path C:\Users\yanet\Desktop\áaaéeeíiiióooúuuñnn this path is correct, áaaéeeíiiióooúuuñnn is the name of a directory but when i try to use os.walk() usin this path, dont work, for os this path dont

Re: fileno() not supported in Python 3.1

2014-11-14 Thread Nobody
On Thu, 13 Nov 2014 15:48:32 -0800, satishmlmlml wrote: import sys for stream in (sys.stdin, sys.stdout, sys.stderr): print(stream.fileno()) io.UnsupportedOperation: fileno Is there a workaround? Try: sys.stdin.buffer.fileno() or maybe

Re: Problem!!

2011-07-05 Thread Nobody
On Sun, 03 Jul 2011 16:58:24 -0700, amir chaouki wrote: the problem is when i use the seek function on windows it gives me false results other then the results on *ux. the file that i work with are very large about 10mb. This is probably an issue with how the underlying C functions behave on

Re: How do twisted and multiprocessing.Process create zombies?

2011-07-06 Thread Nobody
On Tue, 05 Jul 2011 14:52:49 -0700, bitcycle wrote: In python, using twisted loopingcall, multiprocessing.Process, and multiprocessing.Queue; is it possible to create a zombie process. And, if so, then how? A zombie is a process which has terminated but hasn't been wait()ed on (aka reaped) by

Re: Should ctypes handle mis-matching structure return ABI between mingw and MSVC?

2011-07-06 Thread Nobody
On Wed, 06 Jul 2011 11:12:47 +0800, Just Fill Bugs wrote: According the Bug 36834 of gcc, there is a mis-matching between mingw and MSVC when a struct was returned by value from a C function. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36834 Should ctypes handle this situation

Re: Large number multiplication

2011-07-06 Thread Nobody
On Wed, 06 Jul 2011 22:05:52 +0200, Christian Heimes wrote: On the other hand FFT are based on e, complex numbers or trigonometric functions (=floats), which mean you'll get rounding errors. It's possible to perform a DFT over any field. Schoenhage-Strassen uses a DFT over a finite field

Re: making socket.getaddrinfo use cached dns

2011-07-08 Thread Nobody
On Fri, Jul 8, 2011 at 4:18 AM, high bandwidth widebandwi...@gmail.com wrote: I use cached dns lookups with pdnsd on my ubuntu machine to speed up web access as regular lookups can take 15-30 seconds. However, python's mechanize and urllib etc use socket.getaddrinfo, which seems not to be

Re: json decode issue

2011-07-14 Thread Nobody
On Thu, 14 Jul 2011 10:22:44 -0700, Miki Tebeka wrote: I'm trying to decode JSON output of a Java program (jackson) and having some issues. The cause of the problem is the following snippet: { description: ... lives\uMOVE™ OFFERS , } Which causes ValueError: Invalid \u

Re: Python ++ Operator?

2011-07-16 Thread Nobody
On Fri, 15 Jul 2011 23:09:02 +0200, Stefan Behnel wrote: or the more direct pointer management: *ptr++=value; More direct, sure. But readable? Well, only when you know what this specific pattern does. If you have to think about it, it may end up hurting your eyes before you figure it out.

Re: Is there a way to customise math.sqrt(x) for some x?

2011-07-16 Thread Nobody
On Sat, 16 Jul 2011 19:14:47 +1000, Chris Angelico wrote: Only thing I can think of is: import math math.sqrt=lambda(x) x.__sqrt__(x) if x.whatever else math.sqrt(x) math.sqrt=(lambda sqrt=math.sqrt: lambda x: x.__sqrt__(x) if hasattr(x,'__sqrt__') else sqrt(x))() --

Re: shlex parsing

2011-07-28 Thread Nobody
On Thu, 28 Jul 2011 17:48:34 +0200, Web Dreamer wrote: I would like to parse this TCL command line with shlex: '-option1 [get_rule A1 B2] -option2 $VAR -option3 TAG' s = s.replace('[','[') s = s.replace(']',']') Note that this approach won't work if you have nested brackets or braces.

Re: monotonically increasing memory usage

2011-07-28 Thread Nobody
On Thu, 28 Jul 2011 11:52:25 +0200, Pedro Larroy wrote: pickling Just crossposting this from stackoverflow: http://stackoverflow.com/questions/6857006/ Any hints? AFAIK, it's because the Pickler object keeps a reference to each object so that pointer-sharing works; if you write the

Re: with statement and context managers

2011-08-02 Thread Nobody
On Wed, 03 Aug 2011 12:15:44 +1000, Steven D'Aprano wrote: I'm not greatly experienced with context managers and the with statement, so I would like to check my logic. Somebody (doesn't matter who, or where) stated that they frequently use this idiom: spam = MyContextManager(*args) for

Re: Hardlink sub-directories and files

2011-08-03 Thread Nobody
On Tue, 02 Aug 2011 02:32:54 -0700, loial wrote: However I do not think it is possible to hard link directories ? Modern Unices disallow hard links to directories, as it makes the directory tree not a tree, so anything which performs a recursive walk must explicitly check for cycles to avoid

Re: Inconsistencies with tab/space indentation between Cygwin/Win32?

2011-08-04 Thread Nobody
On Thu, 04 Aug 2011 13:55:37 +0930, Christian Gelinek wrote: I find it at least confusing to read that Python expects a tab size of 8 but at the same time uses 4 spaces for one indent level. Or maybe I am completely on the wron track here? 4-column indents are a convention, not a rule. You

Re: Question about encoding, I need a clue ...

2011-08-06 Thread Nobody
On Fri, 05 Aug 2011 14:07:54 -0400, Geoff Wright wrote: I guess what it boils down to is that I would like to get a better handle on what is going on so that I will know how best to work through future encoding issues. Thanks in advance for any advice. Here are the specifics of my problem.

Re: subprocess.Popen and thread module

2011-08-11 Thread Nobody
Danny Wong (dannwong) dannw...@cisco.com wrote:        cmd_output = subprocess.Popen(['scm', 'load', '--force', '-r', nickname, '-d', directory, project], stdout=subprocess.PIPE, stderr=subprocess.PIPE)        status = cmd_output.wait() If you redirect stdout and/or stderr to a pipe, you must

Re: Processing a large string

2011-08-11 Thread Nobody
On Thu, 11 Aug 2011 19:03:36 -0700, goldtech wrote: Say I have a very big string with a pattern like: akakksssk3dhdhdhdbddb3dkdkdkddk3dmdmdmd3dkdkdkdk3asnsn. I want to split the sting into separate parts on the 3 and process each part separately. I might run into memory limitations if

Re: os.system() on Windows in Tkinter app spawns console window

2011-08-12 Thread Nobody
On Fri, 12 Aug 2011 22:49:32 -0400, Kevin Walzer wrote: I'm developing a Tkinter app for a Windows customer, and the app bundles several command-line tools (ported from Unix). I call out to these console tools from the Tkinter app via os.system(). However, in the frozen version of my app,

Re: How to print non-printable chars??

2011-08-12 Thread Nobody
On Sat, 13 Aug 2011 00:59:42 -0400, Julio Cesar Rodriguez Cruz wrote: Hi all, If I open an .exe file in any text editor I get lot of odd chars, what I want is to know how to output those chars if I have the hexadecimal code. I found out how to do the reverse process with the quopri module,

Re: pythonw.exe

2011-08-14 Thread Nobody
On Sun, 14 Aug 2011 06:23:45 -0700, Ronald Reynolds wrote: in my python directory there is a python.exe file which I understand completely but there is also a pythonw.exe DOS seems to honor the pythonw command (No error message) but nothing happens. What is pythonw.exe? Windows distinguishes

Re: testing if a list contains a sublist

2011-08-16 Thread Nobody
On Tue, 16 Aug 2011 01:26:54 +0200, Johannes wrote: what is the best way to check if a given list (lets call it l1) is totally contained in a second list (l2)? Best is subjective. AFAIK, the theoretically-optimal algorithm is Boyer-Moore. But that would require a fair amount of code, and

Re: subprocess.Popen question

2011-08-16 Thread Nobody
On Tue, 16 Aug 2011 02:03:50 -0500, Danny Wong (dannwong) wrote: I'm executing a command which I want to capture the standard/stderr output into a file (which I have with the code below), but I also want the standard output to go into a variable so I can process the information for the

Re: testing if a list contains a sublist

2011-08-17 Thread Nobody
On Tue, 16 Aug 2011 09:57:57 -0400, John Posner wrote: How about using Python's core support for == on list objects: for i in range(alist_sz - slist_sz + 1): if slist == alist[i:i+slist_sz]: return True This is bound to be asymptotically O(alist_sz * slist_sz), even

Re: CGI: Assign FieldStorage values to variables

2011-08-17 Thread Nobody
On Wed, 17 Aug 2011 02:06:31 -0700, Gnarlodious wrote: I get a construct like this: form=FieldStorage(None, None, [MiniFieldStorage('name1', 'Val1'), MiniFieldStorage('name2', 'Val2'), MiniFieldStorage('name3', 'Val3')]) Now how would I assign every variable name* its value? Don't do

Re: Wait for a keypress before continuing?

2011-08-18 Thread Nobody
On Thu, 18 Aug 2011 01:24:30 -0700, peter wrote: This is very similar to my solution, which was to use stty turn off keyboard echo, then repeatedly read sys.stdin.read(1) until a unique keystroke had been defined. For example, the 'Insert' key seems to return a sequence of four codes, namely

Re: List spam

2011-08-18 Thread Nobody
On Thu, 18 Aug 2011 14:30:37 +0100, Tim Golden wrote: I really like this list as part of my learning tools but the amount of spam that I've been getting from it is CRAZY. Doesn't anything get scanned before it sent to the list? I haven't seen any significant quantity of spam on the list for

Re: How to convert a list of strings into a list of variables

2011-08-18 Thread Nobody
On Thu, 18 Aug 2011 16:09:43 +, John Gordon wrote: How would you convert a list of strings into a list of variables using the same name of the strings? So, [red, one, maple] into [red, one, maple] If the strings and the object names are exactly the same, you could use eval(). Eval

Re: relative speed of incremention syntaxes (or i=i+1 VS i+=1)

2011-08-21 Thread Nobody
On Sun, 21 Aug 2011 09:52:23 -0700, Laurent wrote: I did many tests and i = i + 1 always seems to be around 2% faster than i += 1. This is no surprise as the += notation seems to be a syntaxic sugar layer that has to be converted to i = i + 1 anyway. Am I wrong in my interpretation? It

Re: Order of addresses returned by socket.gethostbyname_ex()

2011-08-22 Thread Nobody
On Sun, 21 Aug 2011 23:37:42 -0700, Tomas Lidén wrote: In what order are the addresses returned by socket.gethostbyname_ex()? We know that gethostbyname() is indeterministic but hope that gethostbyname_ex() has a specified order. It doesn't. In fact, the order of the IP addresses may have

Re: Hiding token information from users

2011-08-24 Thread Nobody
On Tue, 23 Aug 2011 06:27:39 -0700, Tobiah wrote: I am making QR codes that cell phone users scan in order to make use of an application. Part of the information is a token that needs to be passed on to the server, but I'd rather not allow a person examining the QR code to be able to see

Re: Checking Signature of Function Parameter

2011-08-29 Thread Nobody
On Sun, 28 Aug 2011 14:20:11 -0700, Travis Parks wrote: More importantly, I want to make sure that predicate is callable, accepting a thing, returning a bool. The callable part is do-able, the rest isn't. The predicate may accept an arbitrary set of arguments via the *args and/or **kwargs

Re: killing a script

2011-08-29 Thread Nobody
On Sun, 28 Aug 2011 18:15:56 -0700, Russ P. wrote: Is there a simple way to ensure that the first Control-C will kill the whole darn thing, i.e, the top-level script? Thanks. You might try using subprocess.Popen() or subprocess.call() rather than os.system(). os.system() calls the platform's

Re: Detecting Ctrl-Alt-Del in Windows

2011-09-01 Thread Nobody
On Thu, 01 Sep 2011 08:52:49 -0700, Den wrote: Obviously, this is a windows-based question. I know that Ctrl-Alt-Del is handled deep inside the OS, and I'm not trying to interrupt that. But is there some way to detect that a C-A-D has been pressed? Not reliably. You might infer that

Re: Detecting Ctrl-Alt-Del in Windows

2011-09-03 Thread Nobody
On Fri, 02 Sep 2011 17:55:41 +1000, Chris Angelico wrote: That's why you have to hit CAD to get to the login form in some versions of Windows. The whole point of that secure sequence is that the OS and only the OS responds. Although I heard somewhere that that's more gimmick than guarantee,

Re: Can't use subprocess.Popen() after os.chroot() - why?

2011-09-06 Thread Nobody
On Sun, 04 Sep 2011 07:22:07 -0700, Erik wrote: I'm trying to do the following: os.chroot(/tmp/my_chroot) p = Popen(/bin/date, stdin=PIPE, stdout=PIPE, stderr=PIPE) but the Popen call is dying with the following exception: LookupError: unknown encoding: string-escape Am I missing

Re: How to structure packages

2011-09-08 Thread Nobody
On Thu, 08 Sep 2011 10:29:26 +1000, Steven D'Aprano wrote: I suppose one class per file might be useful for those using an editor with no search functionality. Other than that, is there any justification for this rule? Any Java fans want to defend this? Not a Java fan, but: The Java compiler

Re: try... except with unknown error types

2011-09-10 Thread Nobody
On Wed, 31 Aug 2011 21:01:34 +, Chris Torek wrote: Still, it sure would be nice to have a static analysis tool that could answer questions about potential exceptions. :-) ) That's an impossibility in a dynamic language. If you call f.read() where f was passed in as a parameter, the

Re: killing a script

2011-09-10 Thread Nobody
On Sat, 10 Sep 2011 11:25:40 +1000, Steven D'Aprano wrote: and sure enough, man 3 system says: I don't consider having to look up documentation for a function in a completely different language (in this case, C) as documented behaviour of os.system. Well, tough luck. os.system() is a

Re: How to structure packages

2011-09-10 Thread Nobody
On Fri, 09 Sep 2011 11:37:44 +1000, Chris Angelico wrote: The Java compiler also acts as a make program. If it doesn't find a .class file for a needed class, it will search for the corresponding .java file and compile that. So to compile a complex program, you only need to compile the

Re: PC locks up with list operations

2011-09-12 Thread Nobody
On Wed, 31 Aug 2011 22:47:59 +1000, Steven D'Aprano wrote: Linux seems to fair badly when programs use more memory than physically available. Perhaps there's some per-process thing that can be used to limit things on Linux? As far as I know, ulimit (user limit) won't help. It can limit the

Re: Cancel or timeout a long running regular expression

2011-09-16 Thread Nobody
On Thu, 15 Sep 2011 14:54:57 -0400, Terry Reedy wrote: I was thinking there might be a technique I could use to evaluate regular expressions in a thread or another process launched via multiprocessing module and then kill the thread/process after a specified timeout period. Only solution I

Re: Cancel or timeout a long running regular expression

2011-09-17 Thread Nobody
On Fri, 16 Sep 2011 18:01:27 -0400, Terry Reedy wrote: Now, can you write that as a heuristic *algorithm* def dangerous_re(some_re):? return re.search(r'\\\d', some_re) is not None That will handle the most extreme case ;) If the OP is serious about analysing regexps,

Re: os independent rename

2011-09-17 Thread Nobody
On Sat, 17 Sep 2011 20:28:32 +0430, Lee Harr wrote: So, what is the best way to do this that will behave the same across operating systems? Delete the destination first, but after checking that it isn't the same as the source. On Windows, that last bit is harder than it seems. A string-based

<    1   2   3   4   5   6   7   8   >