Re: Validating string for FDQN

2011-06-07 Thread Nobody
On Tue, 07 Jun 2011 15:52:05 +1000, Chris Angelico wrote: >> [1] If a hostname ends with a dot, it's fully qualified. > > Outside of BIND files, when do you ever see a name that actually ends > with a dot? Whenever it is entered that way. This may be necessary on complex networks with local sub

Re: How good is security via hashing

2011-06-07 Thread Nobody
On Tue, 07 Jun 2011 13:27:59 +0100, Robin Becker wrote: >> If you want the full 16 bytes of unpredictability, why don't you just >> read 16 bytes from >> /dev/urandom and forget about all the other stuff? > > I have a vague memory that the original author felt that entropy might > run out or somet

Re: How good is security via hashing

2011-06-08 Thread Nobody
On Tue, 07 Jun 2011 19:38:29 -0700, Paul Rubin wrote: >> Personally, I'd take whatever "cheap" entropy I can get and hash it. >> If you're going to read from /dev/urandom, limit it to a few bytes per >> minute, not per request. > > That's really not going to help you. In what way? If I need sec

Re: The pythonic way equal to "whoami"

2011-06-08 Thread Nobody
On Wed, 08 Jun 2011 21:58:17 +0800, TheSaint wrote: >> os.geteuid > This return 0 for *root* . I don't know if it's a standard for all distro. UID 0 is the "superuser". The name "root" is conventional, but it's the EUID (effective UID) which is used in permission checks; the kernel doesn't care a

Re: the stupid encoding problem to stdout

2011-06-09 Thread Nobody
On Thu, 09 Jun 2011 22:14:17 +0100, Sérgio Monteiro Basto wrote: > Exactly the opposite , if python don't know the encoding should not try > decode to ASCII. What should it decode to, then? You can't write characters to a stream, only bytes. > I want python don't care about encoding terminal a

Re: Handling emails

2011-06-12 Thread Nobody
On Sun, 12 Jun 2011 21:57:38 +0800, TheSaint wrote: > However, some line will fail to decode correctly. I can't imagine why emails > don't comply to a standard. Any headers should be in ASCII; Non-ASCII characters should be encoded using quoted-printable and/or base-64 encoding. Any message wit

Re: working with raw image files

2011-06-14 Thread Nobody
On Tue, 14 Jun 2011 19:25:32 -0400, Dave Angel wrote: > You said in an earlier message to ignore the RAW format. However, if > your file matches a typical camera's raw file It doesn't. He's dealing with a raw array of fixed-size integers (i.e. what you would get if you took a C array and wrote

Re: working with raw image files

2011-06-14 Thread Nobody
On Tue, 14 Jun 2011 13:13:07 -0700, kafooster wrote: > Ok, I solved the problem with matplotlib > > fileobj = open("hand.raw", 'rb') > data = numpy.fromfile(fileobj,dtype=np.uint16) > data = numpy.reshape(data,(96,470,352)) > imshow(data[:,:,40],cmap='gray') > show() > > the error was caused by

Re: data type and logarithm

2011-06-16 Thread Nobody
On Thu, 16 Jun 2011 01:37:08 -0700, simona bellavista wrote: > print rho.dtype > print entropy.dtype > > I get |S22 , what's that? A string. You probably want to convert "columns" to floats before appending its elements to the array. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Lisp : car and cdr

2011-06-18 Thread Nobody
On Fri, 17 Jun 2011 16:45:38 +0200, Franck Ditter wrote: > Hi, I'm just wondering about the complexity of some Python operations > to mimic Lisp car and cdr in Python... > > def length(L) : > if not L : return 0 > return 1 + length(L[1:]) Python's lists are arrays/vectors, not linked lists.

Re: Strategy to Verify Python Program is POST'ing to a web server.

2011-06-18 Thread Nobody
On Sat, 18 Jun 2011 04:34:55 -0700, [email protected] wrote: > I am wondering what your strategies are for ensuring that data > transmitted to a website via a python program is indeed from that > program, and not from someone submitting POST data using some other > means. > Any remedy? Supply t

Re: opening a file

2011-06-20 Thread Nobody
On Sun, 19 Jun 2011 23:00:38 -0700, Tim Hanson wrote: > This works: > infile=open('/foo/bar/prog/py_modules/this_is_a_test','r') > > This doesn't: > infile=open('~/prog/py_modules/this_is_a_test','r') > > Can't I work with files using Unix expressions? The argument is treated literally, just li

Re: poll of filesystem

2011-07-02 Thread Nobody
On Sat, 02 Jul 2011 11:40:46 +0200, Belisko Marek wrote: > just want to use poll method to get data from /proc file system. Use > simple code for it. Problem is it seems poll return POLLIN flag but > when I try to read data it's always empty. Could be a problem changes > are so fast that print can

Re: Problem!!

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

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

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

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

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

Re: Large number multiplication

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

Re: making socket.getaddrinfo use cached dns

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

Re: json decode issue

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

Re: Python ++ Operator?

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

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

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

Re: shlex parsing

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

Re: monotonically increasing memory usage

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

Re: with statement and context managers

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

Re: Hardlink sub-directories and files

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

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

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

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

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

Re: subprocess.Popen and thread module

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

Re: Processing a large string

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

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

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

Re: How to print non-printable chars??

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

Re: pythonw.exe

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

Re: testing if a list contains a sublist

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

Re: subprocess.Popen question

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

Re: testing if a list contains a sublist

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

Re: CGI: Assign FieldStorage values to variables

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

Re: Wait for a keypress before continuing?

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

Re: List spam

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

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

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

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

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

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

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

Re: Hiding token information from users

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

Re: Checking Signature of Function Parameter

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

Re: killing a script

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

Re: Detecting Ctrl-Alt-Del in Windows

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

Re: Detecting Ctrl-Alt-Del in Windows

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

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

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

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

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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: Behaviour of subprocess.Popen, ssh and nohup I don't understand

2011-04-06 Thread Nobody
On Wed, 06 Apr 2011 09:47:21 +0200, Adriaan Renting wrote: > This solves the problem using stdin=open(os.devnull, 'rb') instead of > stdin=None makes it run even if there is input from stdin in the > foreground process. > > The operating system is Ubuntu 8.04 > I understood what Suspended (tty in

Re: Trapping the segfault of a subprocess.Popen

2011-04-06 Thread Nobody
On Wed, 06 Apr 2011 02:20:22 -0700, Pierre GM wrote: > I need to run a third-party binary from a python script and retrieve > its output (and its error messages). I use something like process = subprocess.Popen(options, stdout=subprocess.PIPE, > stderr=subprocess.PIPE) (info_out, info_er

Re: Spam on the mailing list

2011-04-07 Thread Nobody
On Thu, 07 Apr 2011 01:03:31 +1000, Chris Angelico wrote: > I don't know whether it's ironic or in some way Pythonesque, but this > is the only mailing list that I've seen significant amounts of spam > on... Bear in mind that the mailing list has a bidirectional gateway to the comp.lang.python ne

Re: How to get a PID of a child process from a process openden with Popen()

2011-04-08 Thread Nobody
On Fri, 08 Apr 2011 07:43:41 -0700, Miki Tebeka wrote: >> p = subprocess.Popen(shlex.split("kdesu -u test program")) >> >> How can I aquire the PID of the program which kdesu starts? > > You can run "ps --ppid " and get the line containing test program. > The first field there should be the

Re: Feature suggestion -- return if true

2011-04-11 Thread Nobody
On Tue, 12 Apr 2011 13:01:43 +1000, James Mills wrote: >> That's still not equivalent. "return expr or None" will always >> terminate the function. The OP's request was for something which would >> terminate the function if and only if expr is non-false. > > The OP did not state this at all. > Th

Re: Pythonic infinite for loop?

2011-04-14 Thread Nobody
On Fri, 15 Apr 2011 12:10:52 +1000, Chris Angelico wrote: > One, is there a way to make an xrange object and leave the top off? itertools.count() > And two, can the entire thing be turned into a list comprehension or > something? Generally any construct with a for loop that appends to a > list i

Re: Reading Huge UnixMailbox Files

2011-04-26 Thread Nobody
On Tue, 26 Apr 2011 15:39:37 -0400, Brandon McGinty wrote: > I'm trying to import hundreds of thousands of e-mail messages into a > database with Python. > However, some of these mailboxes are so large that they are giving > errors when being read with the standard mailbox module. > I created a bu

Re: Reading Huge UnixMailbox Files

2011-04-27 Thread Nobody
On Tue, 26 Apr 2011 14:02:23 -0700, Dan Stromberg wrote: > For the archive: This assumes traditional mbox. A SysV-ish sendmail, > for example, may not like it. sendmail itself doesn't deal with mailboxes or spool files; that task is left to the local delivery agent (e.g. mail.local or procmail).

Re: Compile 32bit C-lib on 64 bit

2011-05-01 Thread Nobody
On Sun, 01 May 2011 22:14:14 +0200, Hegedüs Ervin wrote: > When I'm compiling it on 64bit, gcc says: > > /usr/bin/ld: skipping incompatible /lib32/lib3rdpartyCrypt.so when > searching for -l3rdpartyCrypt > > There _is_ the .so in /lib32 directory: > > ELF 32-bit LSB shared object, Intel 80386,

Re: os.popen command working differently on Windows

2011-05-13 Thread Nobody
On Thu, 12 May 2011 15:21:41 +0100, Tim Golden wrote: > os.popen returns a file-like object from which you can read any error > messages generated. The documentation doesn't say, but if it's anything like the Unix popen() function, with mode='r' the returned file-like object will correspond to th

Re: unicode by default

2011-05-14 Thread Nobody
On Fri, 13 May 2011 14:53:50 -0500, harrismh777 wrote: > The unicode consortium is very careful to make sure that thousands > of symbols have a unique code point (that's great !) but how do these > thousands of symbols actually get displayed if there is no font > consortium? Are there collec

Re: How best to convert a string "list" to a python list

2011-05-14 Thread Nobody
On Fri, 13 May 2011 10:15:29 -0700, noydb wrote: > I want some code to take the items in a semi-colon-delimted string "list" > and places each in a python list. I came up with below. In the name of > learning how to do things properly, do you experts have a better way of > doing it? > x = "red;

Re: connect SIGINT to custom interrupt handler

2011-05-15 Thread Nobody
On Sun, 15 May 2011 09:44:04 +, Christoph Scheingraber wrote: > signal.signal(signal.SIGINT, interrupt_handler) > This worked fine in some rare lucky cases, but most of the times, the > module I am using (my university's seismology project) catches the SIGINT > and quits: > > select.error: (

Re: connect SIGINT to custom interrupt handler

2011-05-15 Thread Nobody
On Sun, 15 May 2011 17:05:57 +, Christoph Scheingraber wrote: > Is it correct anyway to have > > signal.siginterrupt(signal.SIGINT, False) > > in my custom interrupt_handler function No. > or should it be outside but after > signal.signal(signal.SIGINT, interrupt_handler)? Yes. -- htt

Re: connect SIGINT to custom interrupt handler

2011-05-15 Thread Nobody
On Sun, 15 May 2011 14:32:13 +, Christoph Scheingraber wrote: > I now have signal.siginterrupt(signal.SIGINT, False) in the line > below signal.signal(signal.SIGINT, interrupt_handler) > > Unfortunately, pressing ^c still results in the same interrupt error. Sorry; I wasn't paying sufficient

Re: obviscating python code for distribution

2011-05-16 Thread Nobody
On Sun, 15 May 2011 23:41:23 -0600, Littlefield, Tyler wrote: > Here's kind of what I want to prevent. I want to write a multi-player > online game; everyone will essentually end up connecting to my server to > play the game. I don't really like the idea of security through > obscurity, but I w

Re: Image processing to auto adjust colors in python ?

2011-05-16 Thread Nobody
On Mon, 16 May 2011 10:11:43 -0700, goldtech wrote: > I'm processing thumbnails with python but one thing I need to do is to > auto-adjust an image for the "best" colors. I am using ffmpeg to get > thumbs three seconds into a video, sometimes the image is too dark. > Normally I'd go into somethin

Re: connect SIGINT to custom interrupt handler

2011-05-19 Thread Nobody
On Wed, 18 May 2011 07:16:40 -0700, Jean-Paul Calderone wrote: > Setting SA_RESTART on SIGINT is probably the right thing to do. It's not > totally clear to me from the messages in this thread if you managed to get > that approach working. He didn't; select() isn't SA_RESTART-able. Unfortunatel

Re: obviscating python code for distribution

2011-05-20 Thread Nobody
On Fri, 20 May 2011 07:10:45 +, Steven D'Aprano wrote: > How confident are we that the verification software tests every possible > vulnerability, Formal verification is based upon mathematical proof, not empirical results. As Dijkstra said: "Program testing can be used to show the presence

Re: and becomes or and or becomes and

2011-05-28 Thread Nobody
On Sun, 22 May 2011 15:39:33 -0700, Tim Roberts wrote: > That IS funny. Interesting how a careful choice of arugments will fool us. > One of my favorite math jokes is like that. A teacher asked a student to > reduce the following fraction: > 16 > > 64 > > He says "all I have to do is

Re: How to catch a line with Popen

2011-05-28 Thread Nobody
On Sun, 29 May 2011 00:01:56 +0800, TheSaint wrote: > I'm looking into subprocess.Popen docs. I've launch the program with its > arguments and that's smooth. I'm expecting to read the output by > *comunicate()* at every line that prgram may blow during the process, but > the output is given only w

Re: float("nan") in set or as key

2011-05-29 Thread Nobody
On Sun, 29 May 2011 10:29:28 +, Steven D'Aprano wrote: >> The correct answer to "nan == nan" is to raise an exception, because >> you have asked a question for which the answer is nether True nor False. > > Wrong. That's overstating it. There's a good argument to be made for raising an e

Re: float("nan") in set or as key

2011-06-01 Thread Nobody
On Sun, 29 May 2011 23:31:19 +, Steven D'Aprano wrote: >> That's overstating it. There's a good argument to be made for raising an >> exception. > > If so, I've never heard it, and I cannot imagine what such a good > argument would be. Please give it. Exceptions allow you to write more nat

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

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, vals))

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 inter

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 system

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 vect

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 "", line

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 I

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 secure

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 th

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 p

<    1   2   3   4   5   6   7   8   >