Re: Reading file bit by bit

2010-06-07 Thread Nobody
On Mon, 07 Jun 2010 02:31:08 -0700, Richard Thomas wrote: You're reading those bits backwards. You want to read the most significant bit of each byte first... Says who? There is no universal standard for bit-order. Among bitmap image formats, XBM is LSB-first while BMP and PBM are MSB-first.

Re: How do subprocess.Popen(ls | grep foo, shell=True) with shell=False?

2010-06-10 Thread Nobody
On Wed, 09 Jun 2010 21:15:48 -0700, Chris Seberino wrote: How do subprocess.Popen(ls | grep foo, shell=True) with shell=False? The same way that the shell does it, e.g.: from subprocess import Popen, PIPE p1 = Popen(ls, stdout=PIPE) p2 = Popen([grep, foo], stdin=p1.stdout, stdout = PIPE)

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

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

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 lengths

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

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 binary

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 user

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 or

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's only an

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 on

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: 64 bit memory usage

2010-12-09 Thread Nobody
Rob Randall rob.randa...@gmail.com 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

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: 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 rm -f does

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 =

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 thats

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

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

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 busy aka

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

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 use literal

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

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

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

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 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_inst,

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 know

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

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

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

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 with

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

Re: Beginner. 2d rotation gives unexpected results.

2013-07-23 Thread Nobody
On Tue, 23 Jul 2013 15:11:43 +0200, Peter Otten wrote: The conversion to int introduces a rounding error that accumulates over time. Most floating point calculations introduce a rounding error. If the calculations are iterated, the error will accumulate. In general, you want to avoid

Re: Using sudo to write to a file as root from a script

2013-08-09 Thread Nobody
On Thu, 08 Aug 2013 23:11:09 -0500, Adam Mercer wrote: I'm trying to write a script that writes some content to a file root through sudo, but it's not working at all. I am using: command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file] You can't create a pipeline like this. All

Re: Using sudo to write to a file as root from a script

2013-08-09 Thread Nobody
On Fri, 09 Aug 2013 21:12:20 +0100, Nobody wrote: Try: command = ['sudo', 'tee', config_file] p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = p.communicate('channel') Oops; you also need stdin=subprocess.PIPE. -- http://mail.python.org

Re: python and displaying on 10 bit monitors

2013-08-14 Thread Nobody
On Tue, 13 Aug 2013 05:25:34 -0700, rlkling wrote: Or, asking another way, are there any python libraries that display images to 10 bit monitors as 10 bit images, and not scaled to 8 bit? This should be possible using PyOpenGL and GLUT, with: glutInitDisplayString(red=10 green=10

Re: Pair of filenos read/write each other?

2013-08-14 Thread Nobody
On Tue, 13 Aug 2013 16:10:41 -0700, Jack Bates wrote: Is there anything like os.pipe() where you can read/write both ends? There's socket.socketpair(), but it's only available on Unix. Windows doesn't have AF_UNIX sockets, and anonymous pipes (like the ones created by os.pipe()) aren't

Re: Interface and duck typing woes

2013-08-29 Thread Nobody
On Wed, 28 Aug 2013 18:09:22 -0300, Joe Junior wrote: Of course I don't want to check isistance(), I like duck typing, but should I check if hasattr() and callable() before adding to the container? That won't tell you if the object has a quack() method but with incompatible semantics (e.g.

Re: subprocess.Popen instance hangs

2013-08-30 Thread Nobody
On Thu, 29 Aug 2013 17:00:21 -0800, Tim Johnson wrote: ## This appears to be what works. def __exec(self,args) : Run the process with arguments p = subprocess.Popen(args,stderr=subprocess.PIPE,stdout=subprocess.PIPE) while 1 : output =

Re: A Pragmatic Case for Static Typing

2013-09-02 Thread Nobody
On Mon, 02 Sep 2013 09:44:20 +, Steven D'Aprano wrote: One factor I don't see very often mentioned is that static typing increases coupling between distant parts of your code. If func() changes from returning int to MyInt, everything that calls func now needs to be modified to accept

Re: python script hangs when run from subprocess

2013-09-07 Thread Nobody
On Sat, 07 Sep 2013 03:55:02 -0700, larry.mart...@gmail.com wrote: I have a python script and when I run it directly from the command line it runs to completion. But I need to run it from another script. I do that like this: p = subprocess.Popen(cmd, stdout=subprocess.PIPE,

Re: Can I trust downloading Python?

2013-09-09 Thread Nobody
On Sun, 08 Sep 2013 03:37:15 +, Dave Angel wrote: You can run a 32bit Python on 64bit OS, but not the oter way around. And most people just match the bitness of Python against the bitness of the OS. AFAICT, most people run 32-bit Python on any version of Windows. [And this isn't limited

Re: Monitor key presses in Python?

2013-09-09 Thread Nobody
On Mon, 09 Sep 2013 10:39:43 -0700, eamonnrea wrote: Is there a way to detect if the user presses a key in Python that works on most OS's? I've only seen 1 method, and that only works in Python 2.6 and less. There's no generic solution to this. At a minimum, there's getting key presses from

Re: Language design

2013-09-10 Thread Nobody
On Tue, 10 Sep 2013 17:07:09 +1000, Ben Finney wrote: * Python requires every programmer to know, or quickly learn, the basics of Unicode: to know that text is not, and never will be again, synonymous with a sequence of bytes. If only the Python developers would learn the same lesson ...

Re: Send alt key to subprocess.PIPE stdin

2013-09-11 Thread Nobody
On Wed, 11 Sep 2013 07:26:32 -0700, Wanderer wrote: How do I send the command 'Alt+D' to subprocess.PIPE? You don't. GUI programs don't read stdin, they receive key press events from the windowing system. -- https://mail.python.org/mailman/listinfo/python-list

Re: Language design

2013-09-12 Thread Nobody
On Wed, 11 Sep 2013 00:53:53 +, Steven D'Aprano wrote: and most routines that handle file names accept either text strings or bytes strings: I was going to say that just leaves environ and argv. But I see that os.environb was added in 3.2. Which just leaves argv. --

Re: Send alt key to subprocess.PIPE stdin

2013-09-12 Thread Nobody
On Fri, 13 Sep 2013 01:27:53 +1000, Chris Angelico wrote: That said, though: These sorts of keystrokes often can be represented with escape sequences (I just tried it in xterm and Alt-D came out as \e[d), Technically, that would be Meta-D (even if your Meta key has Alt printed on it).

Re: Why do I have to use global so much when using Turtle?

2013-09-22 Thread Nobody
On Sat, 21 Sep 2013 21:39:07 -0700, John Ladasky wrote: However, neither Screen.ontimer() not Screen.onkeypress() appear to give me a way to pass arguments to functions of my own. Why don't they? Is this some limitation of Tk? I have worked with other GUI's before, and I don't remember

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Nobody
On Thu, 26 Sep 2013 10:26:48 +0300, Νίκος wrote: How can i wrote the two following lines so for NOT to throw out KeyErrors when a key is missing? city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] ) or gi.time_zone_by_addr( os.environ['REMOTE_ADDR'] ) or Άγνωστη Î

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Nobody
On Sat, 05 Oct 2013 00:38:51 -0700, galeomaga wrote: #!/usr/bin/python import time f = open('/home/martin/Downloads/a.txt') while 1: for line in f: print line; time.sleep(1); So you're trying to implement tail -f? First, check that tail -f actually works for

Re: Applying 4x4 transformation to 3-element vector with numpy

2013-10-09 Thread Nobody
On Tue, 08 Oct 2013 23:10:16 -0700, John Nagle wrote: I only need affine transformations. This is just moving the coordinate system of a point, not perspective rendering. I have to do this for a lot of points, and I'm hoping numpy has some way to do this without generating extra garbage

Re: Receive packet using socket

2013-10-09 Thread Nobody
On Wed, 09 Oct 2013 08:37:39 -0700, tspiegelman wrote: I am trying to use socket to send / receive a packet (want to recreate some functionality of hping3 and port it to windows and mac as a tcp ping). I am having some problems with the recv functionality of socket. Below is the script I am

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-11 Thread Nobody
On Thu, 10 Oct 2013 14:12:36 +, Grant Edwards wrote: Nope. i is electical current (though it's more customary to use upper case). I is steady-state current (either AC or DC), i is small-signal current. -- https://mail.python.org/mailman/listinfo/python-list

Re: What version of glibc is Python using?

2013-10-12 Thread Nobody
On Sat, 12 Oct 2013 05:43:22 -0600, Ian Kelly wrote: Easier said than done. The module is currently written in pure Python, and the comment Note: Please keep this module compatible to Python 1.5.2 would appear to rule out the use of ctypes to call the glibc function. Last I heard, there was

Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-26 Thread Nobody
On Sat, 26 Oct 2013 20:41:58 -0500, Tim Chase wrote: I'd be just as happy if Python provided a sloppy string compare that ignored case, diacritical marks, and the like. Simply ignoring diactrics won't get you very far. Most languages which use diactrics have standard conversions, e.g. ö - oe,

Re: how to avoid checking the same condition repeatedly ?

2013-10-28 Thread Nobody
On Mon, 28 Oct 2013 09:50:19 +, Wolfgang Maier wrote: So my question is: is there an agreed-upon generally best way of dealing with this? Yes. Just leave the test inside the loop. If you're sufficiently concerned about performance that you're willing to trade clarity for it, you shouldn't

Re: getpeername() on stdin?

2013-10-31 Thread Nobody
On Thu, 31 Oct 2013 12:16:23 -0400, Roy Smith wrote: I want to do getpeername() on stdin. I know I can do this by wrapping a socket object around stdin, with s = socket.fromfd(sys.stdin.fileno(), family, type) but that requires that I know what the family and type are. What I want to

Re: getpeername() on stdin?

2013-11-02 Thread Nobody
On Fri, 01 Nov 2013 14:55:38 -0400, random832 wrote: If it's possible to get this information with only the fd, then why does socket.fromfd require them? The only person who can answer that is whoever came up with socket.fromfd() in the first place. I initially suspected that it might have

Re: convert string to bytes without changing data (encoding)

2012-08-30 Thread Nobody
On Wed, 29 Aug 2012 19:39:15 -0400, Piet van Oostrum wrote: Reading from stdin/a file gets you bytes, and not a string, because Python cannot automagically guess what format the input is in. Huh? Oh, it can certainly guess (in the absence of any other information, it uses the current

Re: Moving folders with content

2012-09-15 Thread Nobody
On Sat, 15 Sep 2012 04:36:00 +, jyoung79 wrote: I am working in both OS X Snow Leopard and Lion (10.6.8 and 10.7.4). I'm simply wanting to move folders (with their content) from various servers to the hard drive and then back to different directories on the servers. I want to be

Re: Moving folders with content

2012-09-16 Thread Nobody
On Sun, 16 Sep 2012 12:40:18 +0200, Hans Mulder wrote: But you should get into the habit of using shell=False whenever possible, because it is much easier to get it right. More accurately, you should get into the habit of passing a list as the first argument, rather than a string. On

Re: portable way of locating an executable (like which)

2012-09-20 Thread Nobody
On Thu, 20 Sep 2012 23:06:46 +0200, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Note that which attempts to emulate the behaviour of execvp() etc. The exec(3) manpage will

Re: Exact integer-valued floats

2012-09-21 Thread Nobody
On Fri, 21 Sep 2012 17:29:13 +, Steven D'Aprano wrote: The question is, what is the largest integer number N such that every whole number between -N and N inclusive can be represented as a float? If my tests are correct, that value is 9007199254740992.0 = 2**53. Have I got this right?

Re: Exact integer-valued floats

2012-09-22 Thread Nobody
On Fri, 21 Sep 2012 15:23:41 -0700, Paul Rubin wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Have I got this right? Is there a way to work out the gap between one float and the next? Yes, 53-bit mantissa as people have mentioned. That tells you what ints can be

Re: what is the difference between st_ctime and st_mtime one is the time of last change and the other is the time of last modification, but i can not understand what is the difference between 'change'

2012-09-28 Thread Nobody
On Fri, 28 Sep 2012 06:12:35 -0700, 陈伟 wrote: what is the difference between st_ctime and st_mtime one is the time of last change and the other is the time of last modification, but i can not understand what is the difference between 'change' and 'modification'. st_mtime is updated when the

Re: what is the difference between st_ctime and st_mtime one is the time of last change and the other is the time of last modification, but i can not understand what is the difference between 'change'

2012-09-29 Thread Nobody
On Fri, 28 Sep 2012 11:48:23 -0600, Kristen J. Webb wrote: NOTE: I am a C programmer and new to python, so can anyone comment on what the st_ctime value is when os.stat() is called on Windows? The documentation[1] says: st_ctime - platform dependent; time of most recent metadata change on

Re: Insert item before each element of a list

2012-10-08 Thread Nobody
On Mon, 08 Oct 2012 12:28:43 -0700, mooremathewl wrote: import itertools x = [1, 2, 3] y = list(itertools.chain.from_iterable(('insertme', x[i]) for i in range(len(x y ['insertme', 1, 'insertme', 2, 'insertme', 3] [i for j in [1,2,3] for i in ('insertme', j)]

Re: Checking for dlls in ctypes

2012-10-13 Thread Nobody
On Fri, 12 Oct 2012 12:28:17 -0400, Dave Angel wrote: Using bare excepts is almost never a good idea. If it works you get no clues what went wrong. For example, a typo in source code can trigger a bare exception, as can a user typing Ctrl-C. So when you're using bare excepts, you have

Re: overriding equals operation

2012-10-16 Thread Nobody
On Tue, 16 Oct 2012 08:51:46 -0500, Pradipto Banerjee wrote: I am trying to define class, where if I use a statement a = b, then instead of a pointing to the same instance as b, it should point to a copy of b, but I can't get it right. It cannot be done. Name binding (variable = value) is a

Re: Watching output and put back in background

2012-10-19 Thread Nobody
On Thu, 18 Oct 2012 14:05:58 +0100, andrea crotti wrote: Maybe a solution would be to redirect the stderr to file and watch that instead.. Or otherwise I could use a thread for each shell command, but I would like to avoid head-aches with possible race-conditions.. If you're running

Re: locking files on Linux

2012-10-19 Thread Nobody
On Thu, 18 Oct 2012 14:44:27 +0100, andrea crotti wrote: Uhh I see thanks, I guess I'll use the good-old .lock file (even if it might have some problems too). In which case, you don't see. A lock file is also advisory, i.e. it only affects applications which explicitly check for a lock file.

Re: Preserving unicode filename encoding

2012-10-20 Thread Nobody
On Sat, 20 Oct 2012 13:43:16 -0700, Julien Phalip wrote: I've noticed that the encoding of non-ascii filenames can be inconsistent between platforms when using the built-in open() function to create files. For example, on a Ubuntu 10.04.4 LTS box, the character u'ş' (u'\u015f') gets encoded

Re: a.index(float('nan')) fails

2012-10-27 Thread Nobody
On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote: Containment of nan in collection is tested by is, not ==. AFAICT, it isn't specific to NaN. The test used by .index() and in appears to be equivalent to: def equal(a, b): return a is b or a == b IOW, it always checks

Re: a.index(float('nan')) fails

2012-10-27 Thread Nobody
On Sat, 27 Oct 2012 08:56:16 +0200, Thomas Rachel wrote: Am 27.10.2012 06:48 schrieb Dennis Lee Bieber: I don't know about the more modern calculators, but at least up through my HP-41CX, HP calculators didn't do (binary) floating point... They did a form of BCD with a fixed number of

Re: ctypes free memory which is allocated in C DLL

2012-10-27 Thread Nobody
On Sat, 27 Oct 2012 07:42:01 -0700, zlchen.ken wrote: I have a DLL which written in C language, one of the function is to allocate a structure, fill the members and then return the pointer of the structure. After Python called this function, and done with the returned structure, I would

Re: Avoiding defunct processes

2012-11-02 Thread Nobody
On Thu, 01 Nov 2012 19:16:17 -0700, Richard wrote: I create child processes with subprocess.Popen(). Then I either wait for them to finish or kill them. Either way these processes end up as defunct until the parent process completes: $ ps e 6851 pts/5Z+ 1:29 [python] defunct You

Re: Subprocess puzzle and two questions

2012-11-15 Thread Nobody
On Wed, 14 Nov 2012 20:49:19 -0500, Roy Smith wrote: I'm slightly surprised that there's no way with the Python stdlib to point a DNS query at a specific server Me too, including the only slightly part. The normal high-level C resolver routines (getaddrinfo/getnameinfo, or even the old

Re: Subprocess puzzle and two questions

2012-11-16 Thread Nobody
On Thu, 15 Nov 2012 20:07:38 -0500, Roy Smith wrote: gethostbyname() and getaddrinfo() use the NSS (name-service switch) mechanism, which is configured via /etc/nsswitch.conf. Depending upon configuration, hostnames can be looked up via a plain text file (/etc/hosts), Berkeley DB files, DNS,

Re: latin1 and cp1252 inconsistent?

2012-11-16 Thread Nobody
On Fri, 16 Nov 2012 13:44:03 -0800, buck wrote: When a user agent [browser] would otherwise use a character encoding given in the first column [ISO-8859-1, aka latin1] of the following table to either convert content to Unicode characters or convert Unicode characters to bytes, it must

Re: latin1 and cp1252 inconsistent?

2012-11-17 Thread Nobody
On Sat, 17 Nov 2012 08:56:46 -0800, buck wrote: Given that the only differences between the two are for code points which are in the C1 range (0x80-0x9F), which should never occur in HTML, parsing ISO-8859-1 as Windows-1252 should be harmless. should is a wish. The reality is that documents

Re: Getting a seeded value from a list

2012-11-20 Thread Nobody
On Mon, 19 Nov 2012 21:45:55 -0800, frednotbob wrote: What I'm trying to do is set a persistent state for the levels generated by make_map(), so the player can move between floors without generating a totally new randomized floor each time. You need to distinguish between immutable data (e.g.

Re: Encoding conundrum

2012-11-21 Thread Nobody
On Wed, 21 Nov 2012 03:24:01 -0800, danielk wrote: import sys sys.stdout.encoding 'cp437' Hmmm. So THAT'S why I am only able to use 'cp437'. I had (mistakenly) thought that I could just indicate whatever encoding I wanted, as long as the codec supported it. sys.stdout.encoding

Re: How to pass class instance to a method?

2012-11-26 Thread Nobody
On Sun, 25 Nov 2012 04:11:29 -0800, ALeX inSide wrote: How to statically type an instance of class that I pass to a method of other instance? Python isn't statically typed. You can explicitly check for a specific type with e.g.: if not isinstance(arg, SomeType): raise

Re: os.popen and the subprocess module

2012-11-29 Thread Nobody
On Thu, 29 Nov 2012 10:09:44 +0100, Thomas Rachel wrote: The variant with shell=True is more os.popen()-like, but has security flaws (e.g., what happens if there are spaces or, even worse, ;s in the command string? I think that you're conflating the shell= option with whether the command is a

Re: Imaging libraries in active development?

2012-11-29 Thread Nobody
On Wed, 28 Nov 2012 04:30:25 -0800, Alasdair McAndrew wrote: What I want to know is - what are the current standard libraries for image processing in Python which are in active development? NumPy/SciPy. PIL is fine for loading/saving image files (although if you're using a GUI toolkit, that

Re: forking and avoiding zombies!

2012-12-12 Thread Nobody
On Tue, 11 Dec 2012 13:25:36 +, andrea crotti wrote: But actually why do I need to move away from the current directory of the parent process? It's not required, it's just best practice. Often, the current directory is simply whichever directory it happened to inherit from the shell which

Re: Most discussion on comp.lang.python is about developing with Python

2013-11-14 Thread Nobody
On Wed, 13 Nov 2013 15:35:56 -0500, bob gailer wrote: I joined a week or so ago. The subject line was copied from the description of comp.lang.python aka python-list@python.org. I am very disappointed to see so much energy and bandwidth going to conversations that bash individuals.

Re: question about file handling with with

2012-03-29 Thread Nobody
On Wed, 28 Mar 2012 11:31:21 +0200, Jabba Laci wrote: Is the following function correct? Is the input file closed in order? def read_data_file(self): with open(self.data_file) as f: return json.loads(f.read()) Yes. The whole point of being able to use a file as a context

Re: simple rsa from javascript to python

2012-04-02 Thread Nobody
On Mon, 02 Apr 2012 16:19:05 -0700, Astan Chee wrote: and I'm trying to convert this into python and I'm rather stuck with pycrypto as there is no example on how to make the public key with a mod and exponent (or I've probably missed it). from Crypto.PublicKey import RSA mod =

Re: No os.copy()? Why not?

2012-04-04 Thread Nobody
On Wed, 04 Apr 2012 08:14:18 -0400, Roy Smith wrote: And sparse files are really hard to reproduce, at least on Unix: on Linux even the system's cp doesn't guarantee sparseness of the copy (the manual mentions a crude heuristic). I imagine the heuristic is to look for blocks of all zeros.

Re: Reading Live Output from a Subprocess

2012-04-06 Thread Nobody
On Thu, 05 Apr 2012 23:57:49 -0700, bunslow wrote: Okay, I've been trying for days to figure this out, posting on forums, Googling, whatever. I have yet to find a solution that has worked for me. (I'm using Python 3.2.2, Ubuntu 11.04.) Everything I've tried has led to buffered output being

Re: escaping/encoding/formatting in python

2012-04-06 Thread Nobody
On Thu, 05 Apr 2012 22:28:19 -0700, rusi wrote: All this mess would vanish if the string-literal-starter and ender were different. You still need an escape character in order to be able to embed an unbalanced end character. Tcl and PostScript use mirrored string delimiters (braces for Tcl,

<    1   2   3   4   5   6   7   8   >