[issue46003] os.replace is not cross-platform: at least improve documentation

2021-12-08 Thread nobody
nobody added the comment: Thank you again, closing this issue. -- stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/i

[issue46003] os.replace is not cross-platform: at least improve documentation

2021-12-07 Thread nobody
nobody added the comment: Thank you for your replies. I have been reading more and conclude that I/O programming on Windows and Linux are two different things. Python is not cross-platform in the sense that a Python program always works on different operating systems but that you can make

[issue46003] os.replace is not cross-platform: at least improve documentation

2021-12-06 Thread nobody
New submission from nobody : When using threads, os.replace gives no errors on Linux. On Windows however you get PermissionErrors like: '[WinError 5] Access is denied' for os.replace and '[Errno 13] Permission denied' when reading the os.replace file. The only way I could get this to work

IPython and dumb terminal

2019-04-30 Thread Nobody
Recent versions of IPython ignore $TERM and blindly assume that you're using something similar to xterm. Does it have an option to disable this "feature"? -- https://mail.python.org/mailman/listinfo/python-list

import inspect error

2018-09-17 Thread nobody
I have following errors running on Ubuntu 18, any insight how to fix it? Thank you. Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import inspect Traceback (most recent call last): File "",

Re: Numpy slow at vector cross product?

2016-11-21 Thread Nobody
On Mon, 21 Nov 2016 14:53:35 +, BartC wrote: > Also that the critical bits were not implemented in Python? That is correct. You'll notice that there aren't any loops in numpy.cross. It's just a wrapper around a bunch of vectorised operations (*, -, []). If you aren't taking advantage of

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-25 Thread Nobody
On Mon, 24 Oct 2016 11:14:05 -0700, jladasky wrote: > I gather that non-blocking keyboard input functions aren't the easiest > thing to implement. They seem to depend on the operating system. Indeed. It's somewhat harder to implement one on an OS which doesn't take it for granted that the

Re: try-except with no exceptions

2016-10-15 Thread Nobody
On Thu, 13 Oct 2016 15:06:25 +0100, Daiyue Weng wrote: > I know that such try-catch usage is generally a bad practice, since it > can't locate the root of the exceptions. > > I am wondering how to correct the code above Either identify the specific exceptions you're expecting, or if you're

Re: I am newbie who can explain this code to me?

2016-09-20 Thread Nobody
On Tue, 20 Sep 2016 15:12:39 +0200, Peter Otten wrote: > because they don't build lists only to throw them away. The lists could have been avoided by using iterators, e.g. import itertools as it keys = xrange(256) vals = it.imap(chr, keys) max(it.imap(operator.setitem, it.repeat(d), keys,

Re: Strange behaviour with numbers in exponential notation

2016-09-04 Thread Nobody
On Fri, 02 Sep 2016 18:18:08 +0200, Christian Gollwitzer wrote: > 1e26 denotes a *floating point number* Floating point has finite > precision, in CPython it is a 64bit IEEE number. The largest exact > integer there is 2**53 (~10^16), everything beyond cannot be accurately > represented. Uh,

Re: importing down in code rather than at top of file.

2016-08-29 Thread Nobody
On Tue, 30 Aug 2016 04:15:05 +1000, Chris Angelico wrote: > Don't imagine; test. Testing alone isn't really good enough. There may be perfectly valid reasons to avoid the import which won't show up in anything less than the most thorough testing imaginable. Personally I wouldn't defer an import

Re: ctypes Usage Note

2016-08-02 Thread Nobody
On Mon, 01 Aug 2016 18:41:53 -0700, Lawrence D’Oliveiro wrote: > Sometimes people load a library with ctypes like this: > > libc = ctypes.cdll.LoadLibrary("libc.so") That specific example is unlikely to work on any modern Linux system, as libc.so is typically a linker script rather than a

Re: ImportError: Import by filename is not supported when unpickleing

2016-07-28 Thread Nobody
On Wed, 27 Jul 2016 22:47:15 -0400, Larry Martell wrote: > Also let me add that initially I was calling Popen with shell=False and > the arguments in a list, and that was failing with: > > arg 2 must contain only strings That indicates that you're calling Popen() incorrectly. > And when I

Re: reshape with xyz ordering

2016-07-26 Thread Nobody
On Tue, 26 Jul 2016 07:10:18 -0700, Heli wrote: > I sort a file with 4 columns (x,y,z, somevalue) and I sort it using > numpy.lexsort. > > ind=np.lexsort((val,z,y,x)) > > myval=val[ind] > > myval is a 1d numpy array sorted by x,then y, then z and finally val. > > how can I reshape correctly

Re: math.frexp

2016-07-15 Thread Nobody
On Fri, 15 Jul 2016 21:39:31 +1000, Steven D'Aprano wrote: > prod *= (m1*m2) Should be: prod = m1*m2 or: prod *= m1 (in the latter case, there's no point in decomposing prod). Of course, if the result overflows, it's going to overflow whether you use the naive

Re: Getting number of neighbours for a 3d numpy arrays

2016-07-12 Thread Nobody
Some common ways to handle the boundary condition: 1. Generate clamped indices, test for validity and substitute invalid entries with an "identity" element. E.g. ijk = np.mgrid[:a,:b,:c] i,j,k = ijk i0,j0,k0 = np.maximum(0,ijk-1) i1,j1,k1 = np.minimum(np.array(a,b,c).T-1,ijk+1) n1 =

Re: Compression of random binary data

2016-07-11 Thread Nobody
On Mon, 11 Jul 2016 10:52:08 -0700, jonas.thornvall wrote: > What kind of statistic law or mathematical conjecture or is it even a > physical law is violated by compression of random binary data? You can't create an invertable mapping between a set with 2^N elements (e.g. the set of all N-bit

Re: Don't put your software in the public domain

2016-06-05 Thread Nobody
On Sat, 04 Jun 2016 12:28:33 +1000, Steven D'Aprano wrote: >> OTOH, a Free software licence is unilateral; the author grants the user >> certain rights, with the user providing nothing in return. > > That's not the case with the GPL. > > The GPL requires the user (not the end-user, who merely

Re: Don't put your software in the public domain

2016-06-03 Thread Nobody
On Fri, 03 Jun 2016 09:15:55 -0700, Lawrence D’Oliveiro wrote: >> [quoted text muted] > > A licence is quite different from a contract. A contract requires some > indication of explicit agreement by both parties, a licence does not. More precisely, it requires "mutual consideration", i.e. each

Re: setrecursionlimit

2016-05-19 Thread Nobody
On Wed, 18 May 2016 09:19:25 -0700, Ned Batchelder wrote: > Is there a way to know how large the C stack can grow, Yes. For the main thread, getrlimit(RLIMIT_STACK). For other threads, pthread_attr_getstacksize(). > and how much it will grow for each Python function call? No. Depending upon

Re: Remove directory tree without following symlinks

2016-04-23 Thread Nobody
On Sat, 23 Apr 2016 00:56:33 +1000, Steven D'Aprano wrote: > I want to remove a directory, including all files and subdirectories under > it, but without following symlinks. I want the symlinks to be deleted, not > the files pointed to by those symlinks. Note that this is non-trivial to do

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Nobody
On Thu, 21 Apr 2016 18:05:40 +1000, Steven D'Aprano wrote: > The specific problem I am trying to solve is that I have a sequence of > strings (in this case, error messages from a Python traceback) and I'm > looking for repeated groups that may indicate mutually recursive calls. E.g. > suppose

Re: How to make Python interpreter a little more strict?

2016-03-27 Thread Nobody
On Sat, 26 Mar 2016 23:30:30 +, John Pote wrote: > So I have sympathy with the OP, I would expect the compiler to pick this > up Why? The code is valid, the compiler knows how to generate the appropriate bytecode for it. The compiler isn't "lint". Reporting code which is actually invalid

Re: numpy arrays

2016-03-23 Thread Nobody
> What you want is called *transposing* the array: > > http://docs.scipy.org/doc/numpy/reference/generated/numpy.transpose.html > > That should be a sufficiently fast operation. Transposing itself is fast, as it just swaps the strides and dimensions without touching the data (i.e. it returns a

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Nobody
On Mon, 15 Feb 2016 15:28:27 +1100, Ben Finney wrote: > The behaviour is already implemented in the standard library. What I'm > looking for is a way to use it (not re-implement it) that is public API > and isn't scolded by the library documentation. So, basically you want (essentially) the

Re: python 3.4, os.walk does not walk into cdroms

2015-12-18 Thread Nobody
On Thu, 17 Dec 2015 14:03:25 +0100, Siegfried Kaiser wrote: > I have a problem with os.walk - it does not walk into a mounted cdrom, I > do not see the cdrom in the walk at all. > What can I do to walk into cdrom? 1. Are you sure that the directory tree contains the actual mount point, not

Re: Why my image is in bad quality ?

2015-12-16 Thread Nobody
On Wed, 16 Dec 2015 06:04:37 -0800, fsn761304 wrote: > pixbufObj = Gdk.pixbuf_get_from_window(window, x, y, width, height) ... > image = Image.frombuffer("RGB", (width, height), > pixbufObj.get_pixels(), 'raw', 'RGB', 0, 1) The second-to-last argument should

Re: What does a list comprehension do (was: Late-binding of function defaults (was Re: What is a function parameter =[] for?))

2015-11-26 Thread Nobody
On Wed, 25 Nov 2015 14:51:23 +0100, Antoon Pardon wrote: > Am I missing something? The issue is with lambdas rather than with list comprehensions per se. Python's lambdas capture free variables by reference, not value. > x = 3 > f = lambda y: x + y > f(0) 3

Re: Regular expressions

2015-11-03 Thread Nobody
On Wed, 04 Nov 2015 14:23:04 +1100, Steven D'Aprano wrote: >> Its very name indicates that its default mode most certainly is regular >> expressions. > > I don't even know what grep stands for. >From the ed command "g /re/p" (where "re" is a placeholder for an arbitrary regular expression).

Re: Unbuffered stderr in Python 3

2015-11-02 Thread Nobody
On Mon, 02 Nov 2015 18:52:55 +1100, Steven D'Aprano wrote: > In Python 2, stderr is unbuffered. > > In most other environments (the shell, C...) stderr is unbuffered. > > It is usually considered a bad, bad thing for stderr to be buffered. What > happens if your application is killed before the

Re: Postscript to pdf

2015-09-21 Thread Nobody
On Sun, 20 Sep 2015 23:11:20 +0200, Baladjy KICHENASSAMY wrote: > i tried this > > def save(): > Canevas.update() > Canevas.postscript(file=tkFileDialog.asksaveasfilename(), > colormode='color') > subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"]) > > > i got the ps

Re: Putting the main program in a main function

2015-09-14 Thread Nobody
On Mon, 14 Sep 2015 09:13:47 +0200, ast wrote: > is it advised to always write programs like that ? If global (module-scope) variables are initialised by main, then those variables won't exist unless main() is run, which means that you can't use it as a module, only as a script. IMHO, global

Re: subdividing a rectangle using numpy

2015-09-10 Thread Nobody
On Thu, 10 Sep 2015 22:05:07 -0500, Seb wrote: > The key to my solution was to use numpy's meshgrid to generate the > coordinates for defining the sub-units. However, it seems awfully > complex and contrived, Half a dozen lines of code is "complex and contrived"? Also, you should lose marks

Re: -2146826246 in win32com.client for empty #N/A cell in Excel

2015-08-16 Thread Nobody
On Sun, 16 Aug 2015 09:53:32 -0700, Sven Boden wrote: Anyone knows how to handle a #N/A cell in Excel in the proper way? 0x800A07FA is how xlErrNA (error 2042) is marshalled. This isn't specific to Python; you'll get the same value using e.g C# or VB.NET. There's a fairly thorough article on

Re: So what's happening here?

2015-06-05 Thread Nobody
On Fri, 05 Jun 2015 13:11:13 +, Paul Appleby wrote: (I'd have thought that id(a[1]) and id(b[1]) would be the same if they were the same element via different views, but the id's seem to change according to rules that I can't fathom.) First, a[1] and b[1] aren't views, they're scalars.

Re: Help with pipes, buffering and pseudoterminals

2015-04-05 Thread Nobody
On Sun, 05 Apr 2015 12:20:48 -0700, Daniel Ellis wrote: This only seems to print from the parent process. I read that I need to do the os.read call for the fork to happen. I've also tried printing *after* the os.read call. The child process has its std{in,out,err} attached to the

Re: subprocess and stdin.write(), stdout.read()

2015-03-24 Thread Nobody
On Tue, 24 Mar 2015 12:08:24 -0700, Tobiah wrote: But if I want to send a string to stdin, how can I do that without stdin.write()? p.communicate(string) This seems to work: Only because the amounts of data involved are small enough to avoid deadlock. If both sides write more data

Re: Is there a cairo like surface for the screen without the window hassle

2015-02-03 Thread Nobody
On Mon, 02 Feb 2015 14:20:56 +0100, Antoon Pardon wrote: I need to have a program construct a number of designs. Of course I can directly use a pfd surface and later use a pdf viewer to check. But that becomes rather cumbersome fast. But if I use a cairo-surface for on the screen I suddenly

Re: Can numpy do better than this?

2015-01-10 Thread Nobody
On Thu, 08 Jan 2015 09:56:50 -0800, Rustom Mody wrote: Given a matrix I want to shift the 1st column 0 (ie leave as is) 2nd by one place, 3rd by 2 places etc. This code works. But I wonder if numpy can do it shorter and simpler. def shiftcols(mat): iy,ix = np.indices(mat.shape)

Re: Neat little programming puzzle

2014-12-16 Thread Nobody
On Tue, 16 Dec 2014 00:46:16 -0500, Jason Swails wrote: I liked this problem because naive solutions scale as O(2^N), begging for a more efficient approach. Project Euler has this one, twice; problems 18 and 67. The difference between the two is that problem 18 has 15 rows while problem 67

Re: why can't download file from linux server into local window disk c:

2014-12-09 Thread Nobody
To: pengsir On Tue, 09 Dec 2014 00:14:15 -0800, pengsir wrote: localpath = 'c:' sftp.get(filepath, localpath) with open(localpath, 'wb') as fl: PermissionError: [Errno 13] Permission denied: 'c:' It's trying to open c:, which is a drive, as if it was a file. You have to specify the

Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Nobody
On Tue, 09 Dec 2014 00:14:15 -0800, pengsir wrote: localpath = 'c:' sftp.get(filepath, localpath) with open(localpath, 'wb') as fl: PermissionError: [Errno 13] Permission denied: 'c:' It's trying to open c:, which is a drive, as if it was a file. You have to specify the destination

Re: time.monotonic() roll over

2014-12-04 Thread Nobody
On Thu, 04 Dec 2014 16:25:44 +0100, ast wrote: There is no roll over problem with time.time() since the very first one in planned far in the future, but time.time() can go backward when a date update throught NTP server is done. time.monotonic() is monotonic but roll over often (every 49.7

Re: Cherrypy - prevent browser prefetch?

2014-12-03 Thread Nobody
On Tue, 02 Dec 2014 21:41:33 +, John Gordon wrote: GET shouldn't cause any business data modifications, but I thought it was allowed for things like logging out of your session. GET isn't supposed to have observable side-effects. Observable excludes things like logs and statistics, but

Re: Cherrypy - prevent browser prefetch?

2014-12-02 Thread Nobody
On Mon, 01 Dec 2014 11:28:42 -0900, Israel Brewster wrote: I'm running to a problem, specifically from Safari on the Mac, where I start to type a URL, and Safari auto-fills the rest of a random URL matching what I started to type, and simultaneously sends a request for that URL to my server,

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: Simple Python script as SMTP server for outgoing e-mails?

2013-07-22 Thread Nobody
On Mon, 22 Jul 2013 14:19:57 +0200, Gilles wrote: Incidently, how do ISP MTAs find whether the remote MTA is legit or running on some regular user's computer? Look up the IP address in a database. If they don't have a database, perform a reverse DNS lookup and reject anything which looks like

Re: Concurrent writes to the same file

2013-07-11 Thread Nobody
On Wed, 10 Jul 2013 22:57:09 -0600, Jason Friedman wrote: Other than using a database, what are my options for allowing two processes to edit the same file at the same time? When I say same time, I can accept delays. What do you mean by edit? Overwriting bytes and appending bytes are simple

Re: How do I get the OS System Font Directory(Cross-Platform) in python?

2013-07-11 Thread Nobody
On Thu, 11 Jul 2013 08:32:34 -0700, Metallicow wrote: How do I get the OS System Font Directory(Cross-Platform) in python? What makes you think the system *has* a system font directory? In the traditional X11 model, the only program which needs fonts is the X server, and that can be configured

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-04 Thread Nobody
On Thu, 04 Jul 2013 13:38:09 +0300, Νίκος wrote: So you are also suggesting that what gesthostbyaddr() returns is not utf-8 encoded too? The gethostbyaddr() OS function returns a byte string with no specified encoding. Python 3 will doubtless try to decode that to a character string using

Re: Popen in Python3

2013-06-19 Thread Nobody
On Wed, 19 Jun 2013 23:03:05 +, Joseph L. Casale wrote: I am trying to invoke a binary that requires dll's in two places all of which are included in the path env variable in windows. When running this binary with popen it can not find either, passing env=os.environ to open made no

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Nobody
On Fri, 14 Jun 2013 18:16:05 +0300, Nick the Gr33k wrote: My question is why the expr (name and month and year) result in the value of the last variable whic is variable year? For much the same reason that an OR expression returns the first true value. or and and only evaluate as many

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Nobody
On Fri, 14 Jun 2013 19:30:27 +, Grant Edwards wrote: 2. Returning one the objects that result from the evaluation of the operands instead of returning True or False. This is what seems to be confusing him. This is much less common than short-circuit evaluation. FWIW, Lisp

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Nobody
On Fri, 14 Jun 2013 16:49:11 +, Steven D'Aprano wrote: Unlike Javascript though, Python's idea of truthy and falsey is actually quite consistent: Beyond that, if a user-defined type implements a __nonzero__() method then it determines whether an instance is true or false. If it implements

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Nobody
On Sat, 15 Jun 2013 03:56:28 +1000, Chris Angelico wrote: With a few random oddities: bool(float(nan)) True I somehow expected NaN to be false. Maybe that's just my expectations that are wrong, though. In general, you should expect the behaviour of NaN to be the opposite of what you

Re: A few questiosn about encoding

2013-06-13 Thread Nobody
On Thu, 13 Jun 2013 12:01:55 +1000, Chris Angelico wrote: On Thu, Jun 13, 2013 at 11:40 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: The *mechanism* of UTF-8 can go up to 6 bytes (or even 7 perhaps?), but that's not UTF-8, that's UTF-8-plus-extra-codepoints. And a proper

Re: Don't rebind built-in names* - it confuses readers

2013-06-13 Thread Nobody
On Thu, 13 Jun 2013 01:23:27 +, Steven D'Aprano wrote: Python does have a globally-global namespace. It is called builtins, and you're not supposed to touch it. Of course, being Python, you can if you want, but if you do, you are responsible for whatever toes you shoot off. Modifying

Re: A few questiosn about encoding

2013-06-12 Thread Nobody
On Wed, 12 Jun 2013 14:23:49 +0300, Νικόλαος Κούρας wrote: So, how many bytes does UTF-8 stored for codepoints 127 ? U+..U+007F 1 byte U+0080..U+07FF 2 bytes U+0800..U+ 3 bytes =U+1 4 bytes So, 1 byte for ASCII, 2 bytes for other Latin characters, Greek, Cyrillic, Arabic,

RE: Popen and reading stdout in windows

2013-06-11 Thread Nobody
On Tue, 11 Jun 2013 01:50:07 +, Joseph L. Casale wrote: I am using Popen to run the exe with communicate() and I have sent stdout to PIPE without luck. Just not sure what is the proper way to iterate over the stdout as it eventually makes its way from the buffer. The proper way is:

Re: A few questiosn about encoding

2013-06-09 Thread Nobody
On Sun, 09 Jun 2013 03:44:57 -0700, Νικόλαος Κούρας wrote: Since 1 byte can hold up to 256 chars, why not utf-8 use 1-byte for values up to 256? Because then how do you tell when you need one byte, and when you need two? If you read two bytes, and see 0x4C 0xFA, does that mean two

Re: Python Game Development?

2013-06-08 Thread Nobody
On Fri, 07 Jun 2013 08:53:03 -0700, letsplaysforu wrote: I was planning on making a small 2D game in Python. Are there any libraries for this? I know of: [snip] There's also Pyglet. -- http://mail.python.org/mailman/listinfo/python-list

Re: how to detect the character encoding in a web page ?

2013-06-06 Thread Nobody
On Thu, 06 Jun 2013 03:55:11 +1000, Chris Angelico wrote: The HTTP header is completely out of band. This is the best way to transmit encoding information. Otherwise, you assume 7-bit ASCII and start parsing. Once you find a meta tag, you stop parsing and go back to the top, decoding in the

Re: Changing filenames from Greeklish = Greek (subprocess complain)

2013-06-04 Thread Nobody
On Mon, 03 Jun 2013 23:28:21 -0700, nagia.retsina wrote: I can't believe Chrome whcih by default uses utf8 chosed iso-8859-1 to presnt the filenames. Chrome didn't choose ISO-8859-1, the server did; the HTTP response says: Content-Type: text/html;charset=ISO-8859-1 --

Re: Changing filenames from Greeklish = Greek (subprocess complain)

2013-06-04 Thread Nobody
On Tue, 04 Jun 2013 00:58:42 -0700, Νικόλαος Κούρας wrote: Τη Τρίτη, 4 Ιουνίου 2013 10:39:08 π.μ. UTC+3, ο χρήστης Nobody έγραψε: Chrome didn't choose ISO-8859-1, the server did; the HTTP response says: Content-Type: text/html;charset=ISO-8859-1 From where do you see this $ wget -S -O

Re: Changing filenames from Greeklish = Greek (subprocess complain)

2013-06-02 Thread Nobody
On Sat, 01 Jun 2013 08:44:36 -0700, Νικόλαος Κούρας wrote: CalledProcessError: Command '/home/nikos/public_html/cgi-bin/files.py' returned non-zero exit status 1 args = (1, '/home/nikos/public_html/cgi-bin/files.py') cmd = '/home/nikos/public_html/cgi-bin/files.py'

Re: Create a file in /etc/ as a non-root user

2013-05-31 Thread Nobody
On Fri, 31 May 2013 02:12:58 -0700, BIBHU DAS wrote: I am a python novice;request all to kindly bear with me. fd = open('/etc/file','w') fd.write('jpdas') fd.close() The above snippet fails with: IOError: [Errno 13] Permission denied: '/etc/file' As it should. Any Idea how to

Re: Short-circuit Logic

2013-05-30 Thread Nobody
On Thu, 30 May 2013 12:07:40 +0300, Jussi Piitulainen wrote: I suppose this depends on the complexity of the process and the amount of data that produced the numbers of interest. Many individual floating point operations are required to be within an ulp or two of the mathematically correct

Re: Short-circuit Logic

2013-05-30 Thread Nobody
On Thu, 30 May 2013 19:38:31 -0400, Dennis Lee Bieber wrote: Measuring 1 foot from the 1000 foot stake leaves you with any error from datum to the 1000 foot, plus any error from the 1000 foot, PLUS any azimuth error which would contribute to shortening the datum distance. First, let's

  1   2   3   4   5   6   7   8   >