Re: Python CPU

2011-04-03 Thread Nobody
On Sun, 03 Apr 2011 10:15:34 -0700, John Nagle wrote: > Note that if you run out of return point stack, or parameter > stack, you're stuck. So there's a hardware limit on call depth. > National Semiconductor once built a CPU with a separate return > point stack with a depth of 20. Big mista

Re: Python CPU

2011-04-01 Thread Nobody
On Fri, 01 Apr 2011 08:38:27 -0700, Brad wrote: > I've heard of Java CPUs. Has anyone implemented a Python CPU in VHDL > or Verilog? Java is a statically-typed language which makes a distinction between primitive types (bool, int, double, etc) and objects. Python is a dynamically-typed language w

Re: C Callback Function using ctypes

2011-03-26 Thread Nobody
On Sat, 26 Mar 2011 05:23:27 +0300, OJ wrote: > Hi I am opening a shared library which has defined the following > callback prototype: > extern void DebugMessage(int level, const char *message, ...); > > My implementation in Python looks like this: > DEBUGFUNC = ctypes.CFUNCTYPE(None, ctypes.c_in

Re: Writing to a file

2011-03-26 Thread Nobody
On Fri, 25 Mar 2011 19:39:11 -0600, Littlefield, Tyler wrote: > >with open(test_absname, 'w') as test: > what's the difference in that and test = ...? I can see why you mentioned > the os.path for cross-platform, but I don't understand why someone would > use with over =. Using "with" will a

Re: os.stat bug?

2011-03-21 Thread Nobody
On Mon, 21 Mar 2011 09:32:11 +0100, Laszlo Nagy wrote: > So the state of the process changes to "STOP", but the program does not > stop until the os.stat call returns back (sometimes for 30 seconds). > > Could it be a problem with the operation system? Is it possible that an > os.stat call requ

Re: Reading/Writing files

2011-03-19 Thread Nobody
On Fri, 18 Mar 2011 16:00:55 -0700, Ethan Furman wrote: Dan Stromberg wrote: > / works fine on windows, and doesn't require escaping ("/foo/bar"). "/" works fine in most contexts, but not in shell commands, where "/" is conventionally used to indicate a switch. Commands which follow this convent

Re: ctypes pointer to structure memory swap

2011-03-18 Thread Nobody
On Fri, 18 Mar 2011 15:16:40 -0700, Wanderer wrote: > Thanks for the reply, but I'm still not sure I understand. Why should > Object1 be at address1 and Object2 be at address2 and the next moment > Object2 is at address1 and Object1 is at address2? I'll try casting > them to see what the value is

Re: ctypes pointer to structure memory swap

2011-03-18 Thread Nobody
On Fri, 18 Mar 2011 10:34:35 -0700, Wanderer wrote: > I'm observing some strange behavior with ctypes. I created this test > code to try to figure out what I'm doing wrong creating pointers to > structures. What makes you think that you're doing anything wrong. Note that the hex number shown whe

Re: creating RAW sockets

2011-03-17 Thread Nobody
On Wed, 16 Mar 2011 23:50:03 -0700, moijes12 wrote: > Now,please can someone guide(as in what should I read and NOT as in > give me the code) me in decoding the IP header of packets using python > 3.0.1. The "struct" module is the usual approach for decoding binary data structures. Fields which a

Re: creating RAW sockets

2011-03-16 Thread Nobody
On Wed, 16 Mar 2011 22:36:07 -0700, moijes12 wrote: > Traceback (most recent call last): > File "getsockopt_handler.py", line 7, in ? > send.bind((gethostbyname(gethostname()),5)) > socket.error: (99, 'Cannot assign requested address') Specifying a port number isn't meaningful for a raw

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Nobody
On Mon, 14 Mar 2011 12:39:35 -0700, Paul Rubin wrote: > Finally I concocted an "infinite" example which we agreed is artificial: > you are given a list of generators denoting real numbers, for example > pi generates the infinite sequence 3,1,4,1,5,9... while e generates > 2,7,1,8,... You can sor

Re: OT: processes, terminals and file descriptors on *nix (was: Re: attach to process by pid?)

2011-03-12 Thread Nobody
On Sat, 12 Mar 2011 00:49:08 +0100, Alexander Kapps wrote: > I still try to digest your explanations. I thought, that processes > just do something like dup()'ing the file descriptors of their > terminal but after some strace experiments, I think that is totally > wrong. Actually, the way that

Re: Just finished reading of "What’s New In Python 3.0"

2011-03-11 Thread Nobody
On Thu, 10 Mar 2011 17:58:50 -0800, n00m wrote: > http://docs.python.org/py3k/whatsnew/3.0.html > > What's the fuss abt it? Imo all is ***OK*** with 3k (in the parts I > understand). Some of use Python 2.x as a general-purpose Unix scripting language. For that purpose, Python 3.x's obsession wit

Re: attach to process by pid?

2011-03-10 Thread Nobody
On Thu, 10 Mar 2011 23:55:51 +0100, Alexander Kapps wrote: >>> I think he wants to attach to another process's stdin/stdout and >>> read/write from/to them. >>> I don't know if this is possible but it would be a great addition for >>> psutil. >> >> It's not even a meaningful concept, let alone pos

Re: attach to process by pid?

2011-03-10 Thread Nobody
On Thu, 10 Mar 2011 20:22:11 +0100, Giampaolo Rodolà wrote: > I think he wants to attach to another process's stdin/stdout and > read/write from/to them. > I don't know if this is possible but it would be a great addition for psutil. It's not even a meaningful concept, let alone possible. -- ht

RE: subprocess running ant

2011-03-03 Thread Nobody
On Thu, 03 Mar 2011 13:27:34 -0500, Thom Hehl wrote: > Actually, I just figured out the issue is that I need to run ant.bat > instead of just ant. :( Add shell=True to the Popen() call. -- http://mail.python.org/mailman/listinfo/python-list

Re: arbitrary precision linear algebra

2011-03-02 Thread Nobody
On Wed, 02 Mar 2011 06:42:22 -0800, Ben123 wrote: > Hello. I have a written Python program which currently uses numpy to > perform linear algebra operations. Specifically, I do matrix*matrix, > matrix*vector, numpy.linalg.inv(matrix), and linalg.eig(matrix) > operations. Now I am interested in all

Re: getpass and IDEs

2011-02-26 Thread Nobody
On Fri, 25 Feb 2011 11:50:35 -0500, Andrew wrote: > I find that calling getpass produces a warning noting that it can't > suppress output, if I'm using idle, wingide, or a few others. If I'm > running from the console it works fine, but then I can't make use of > ide-integrated debugging. > > I

Re: Is this a safe use of eval?

2011-02-24 Thread Nobody
On Thu, 24 Feb 2011 15:24:51 +0200, Frank Millman wrote: > Thanks, Christian. I had a look at that recipe, but I must say that Paul's > suggestion is much simpler - > >from ast import literal_eval >method_name = 'calc_area' >args = literal_eval('(100,200)') >result = getattr(my_i

Re: Is setdefaultencoding bad?

2011-02-23 Thread Nobody
On Wed, 23 Feb 2011 04:14:29 -0800, Chris Rebert wrote: >> Ok, but that the interface handles UTF-8 strings >> are still ok? The defaultencoding is still ascii. > > Yes, that's fine. UTF-8 is an excellent encoding choice, and > encoding/decoding should always be done explicitly in Python, so the

Re: Is setdefaultencoding bad?

2011-02-22 Thread Nobody
On Tue, 22 Feb 2011 19:34:21 -0800, moerchendiser2k3 wrote: > Hi, I embedded Py2.6.1 in my app and I use UTF-8 encoded strings > everywhere in the interface, so the interface between my app and > Python is UTF-8 so I can simply write: > > print u"\uC042" > print u"\uC042".encode("utf_8") > > and

Re: client server socket interaction (inetd)

2011-02-18 Thread Nobody
On Fri, 18 Feb 2011 07:23:35 -0800, Tim wrote: > When LaTeX encounters a problem it stops processing, asks the user > what to do (like abort/retry, kind-of), and does whatever the user > says. The daemon.py script handles that okay from the command line, > but if I'm understanding you this will be

Re: Best way to gain root privileges

2011-02-16 Thread Nobody
On Thu, 17 Feb 2011 01:47:10 +0100, Alexander Kapps wrote: >> Having said that I'm possibly arriving at the conclusion that a quick >> perl script might be the simplest/easiest and most secure option - I >> read perl includes code to safely run suid perl scripts - will dig out >> my perl tomes. >

Re: Reassign or discard Popen().stdout from a server process

2011-02-11 Thread Nobody
On Thu, 10 Feb 2011 08:35:24 +, John O'Hagan wrote: >> > But I'm still a little curious as to why even unsuccessfully attempting >> > to reassign stdout seems to stop the pipe buffer from filling up. >> >> It doesn't. If the server continues to run, then it's ignoring/handling >> both SIGPIPE

Re: Reassign or discard Popen().stdout from a server process

2011-02-08 Thread Nobody
On Fri, 04 Feb 2011 15:48:55 +, John O'Hagan wrote: > But I'm still a little curious as to why even unsuccessfully attempting to > reassign stdout seems to stop the pipe buffer from filling up. It doesn't. If the server continues to run, then it's ignoring/handling both SIGPIPE and the EPIPE

Re: os.path.join doubt

2011-02-03 Thread Nobody
On Thu, 03 Feb 2011 06:31:49 +, Steven D'Aprano wrote: > On Wed, 02 Feb 2011 20:46:12 -0800, harryos wrote: > >> In windows ,I tried this >> >> p1 = "C:\Users\me\Documents" >> p2 = "..\Pictures\images\my.jpg" Don't do this; backslash is significant within Python string literals. If want to

Re: Reassign or discard Popen().stdout from a server process

2011-02-03 Thread Nobody
On Tue, 01 Feb 2011 08:30:19 +, John O'Hagan wrote: > I can't keep reading because that will block - there won't be any more > output until I send some input, and I don't want it in any case. > > To try to fix this I added: > > proc.stdout = os.path.devnull > > which has the effect of stopp

Re: Trying to decide between PHP and Python

2011-01-05 Thread Nobody
On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > The indentation-as-block is unique, Not at all. It's also used in occam, Miranda, Haskell and F#. -- http://mail.python.org/mailman/listinfo/python-list

Re: OSError: [Errno 26] Text file busy during subprocess.check_call() :seems os dependent

2010-12-30 Thread Nobody
On Thu, 30 Dec 2010 13:46:35 -0800, harijay wrote: > Each Thread receives a dynamically generated shell script from some > classes I wrote and then runs the script using > > subprocess.call(["shell_script_file.sh"]) > But I get the same "OSError: [Errno 26] Text file busy" error "Text file bus

Re: Trying to parse a HUGE(1gb) xml file

2010-12-25 Thread Nobody
On Sun, 26 Dec 2010 01:05:53 +, Tim Harig wrote: >> XML is typically processed sequentially, so you don't need to create a >> decompressed copy of the file before you start processing it. > > Sometimes XML is processed sequentially. When the markup footprint is > large enough it must be. Qu

Re: Trying to parse a HUGE(1gb) xml file

2010-12-25 Thread Nobody
On Sat, 25 Dec 2010 14:41:29 -0500, Roy Smith wrote: >> XML works extremely well for large datasets. One advantage it has over many legacy formats is that there are no inherent 2^31/2^32 limitations. Many binary formats inherently cannot support files larger than 2GiB or 4Gib due to the use of 32

Re: Generator question

2010-12-23 Thread Nobody
On Wed, 22 Dec 2010 15:49:31 -0800, Dan Stromberg wrote: > def generator(): > i = 0 > while True: > yield i > i += 1 Shorter version: from itertools import count as generator -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to parse a HUGE(1gb) xml file

2010-12-23 Thread Nobody
On Wed, 22 Dec 2010 23:54:34 +0100, Stefan Sonnenberg-Carstens wrote: > Normally (what is normal, anyway?) such files are auto-generated, > and are something that has a apparent similarity with a database query > result, encapsuled in xml. > Most of the time the structure is same for every "row"

Re: subprocess.Popen() and a .msi installer

2010-12-18 Thread Nobody
On Fri, Dec 17, 2010 at 17:57, Sebastian Alonso wrote: > Hey everyone, I'm working on a script which uses subprocess to launch a > bunch of installers, but I'm getting problems with .msi installers > although .exe ones work fine. The output I get is this: > import subprocess p = subproce

Re: Making os.unlink() act like "rm -f"

2010-12-11 Thread Nobody
On Sat, 11 Dec 2010 12:04:01 -0500, Roy Smith wrote: > I just wrote an annoying little piece of code: > > try: > os.unlink("file") > except OSError: >pass > > The point being I want to make sure the file is gone, but am not sure if > it exists currently. Essentially, I want to do what "

Re: unicode compare errors

2010-12-10 Thread Nobody
On Fri, 10 Dec 2010 11:51:44 -0800, Ross wrote: > Since I can't control the encoding of the input file that users > submit, how to I get past this? How do I make such comparisons be > True? On Fri, 10 Dec 2010 12:07:19 -0800, Ross wrote: > I found I could import codecs that allow me to read the

Re: 64 bit memory usage

2010-12-09 Thread Nobody
Rob Randall wrote: > I am trying to understand how much memory is available to a 64 bit python > process running under Windows XP 64 bit. > > When I run tests just creating a series of large dictionaries containing > string keys and float values I do not seem to be able to grow the process > bey

Re: Comparison with False - something I don't understand

2010-12-06 Thread Nobody
On Mon, 06 Dec 2010 08:32:18 -0500, Mel wrote: > Apparently, at the end of his research, Alan Turing was trying out the idea > of 'oracles', where a computable process would have access to an > uncomputable process to get particular results. I would imagine that the > idea here was to clarify

Re: How to send an IP packet in Python?

2010-12-02 Thread Nobody
On Thu, 02 Dec 2010 03:12:42 -0800, yegorov-p wrote: > I have sniffed some packet and now I would like to send it with the > help of python. > But for some reason python send that: > As you can see, python ignores my headers and creates its own. It isn't Python doing that, but the OS. At least

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-12-02 Thread Nobody
On Thu, 02 Dec 2010 12:17:53 +0100, Peter Otten wrote: >> This was actually a critical flaw in Python 3.0, as it meant that >> filenames which weren't valid in the locale's encoding simply couldn't be >> passed via argv or environ. 3.1 fixed this using the "surrogateescape" >> encoding, so now it'

Re: Comparison with False - something I don't understand

2010-12-02 Thread Nobody
On Thu, 02 Dec 2010 07:28:30 +, Harishankar wrote: > When I run pychecker through my modules I get the message that > comparisons with "False" is not necessary and that it might yield > unexpected results. > > Yet in some situations I need to specifically check whether False was > returned

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-12-01 Thread Nobody
On Wed, 01 Dec 2010 10:34:24 +0100, Peter Otten wrote: >> Python 3.x's decision to treat filenames (and environment variables) as >> text even on Unix is, in short, a bug. One which, IMNSHO, will mean that >> Python 2.x is still around when Python 4 is released. > > For filenames in Python 3 the

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-12-01 Thread Nobody
On Wed, 01 Dec 2010 02:14:09 +, MRAB wrote: > If the filenames are to be shown to a user then there needs to be a > mapping between bytes and glyphs. That's an encoding. If different > users use different encodings then exchange of textual data becomes > difficult. OTOH, the exchange of binar

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-11-30 Thread Nobody
On Tue, 30 Nov 2010 18:53:14 +0100, Peter Otten wrote: >> I think this is wrong. In Unix there is no concept of filename >> encoding. Filenames can have any arbitrary set of bytes (except '/' and >> '\0'). But the filesystem itself neither knows nor cares about >> encoding. > > I think you mi

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-11-30 Thread Nobody
On Mon, 29 Nov 2010 21:26:23 -0800, Dan Stromberg wrote: > Does anyone know what I need to do to read filenames from stdin with > Python 3.1 and subsequently open them, when some of those filenames > include characters with their high bit set? Use "bytes" rather than "str". Everywhere. This means

Re: Comparing floats

2010-11-28 Thread Nobody
On Sat, 27 Nov 2010 18:23:48 -0500, Terry Reedy wrote: >> Therefore, to implement this multiplication operation I need to have a >> way to verify that the float tuples C and D are "equal". > > I might try the average relative difference: > sum(abs((i-j)/(i+j)) for i,j in zip(C,D))/n # assuming le

Re: bug? mmap doesn't like 0-length files

2010-11-22 Thread Nobody
On Mon, 22 Nov 2010 20:33:08 -0500, Neal Becker wrote: > I don't see anything in linux man-page about the underlying C mmap function > not accepting 0-length files. My mmap(2) manpage says: ERRORS ... EINVAL (since Linux 2.6.12) length was 0. -- http://mail.pyth

Re: Reading bz2 file into numpy array

2010-11-22 Thread Nobody
On Mon, 22 Nov 2010 11:37:22 +0100, Peter Otten wrote: >> is there a convenient way to read bz2 files into a numpy array? > > Try > f = bz2.BZ2File(filename) > data = numpy.fromstring(f.read(), numpy.float32) That's going to hurt if the file is large. You might be better off either extracting

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 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 password entry rathe

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 pr

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 re

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 th

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: 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 "somethin

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 b

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 versio

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

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-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 a

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. I

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 proces

Re: Filename for stdout

2010-10-21 Thread Nobody
Richard Gibbs 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 = os.readlink('/proc/self/fd/0') This isn't

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 ps

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 f

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

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

2010-10-15 Thread Nobody
eresting file system > 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 mem

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

2010-10-14 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 otherfile > > I suppose I could just use os.system() here but I'd rather keep the > Unix shell completely out of the picture (which

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, stdout=subprocess.

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: 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. Be

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

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

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: 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 enco

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 reaso

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 > http://sqlite

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: 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

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? T

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 s

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: 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. >> >>

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-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 don

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 arbitra

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: 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 th

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 writte

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 par

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. > > B

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

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

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 cas

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. -- http://mail.python.org/mailman

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 wh

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 th

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 th

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 qu

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. >> >

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 wi

<    1   2   3   4   5   6   7   8   >