[Q] Function Point Analysis (FPA) - Equivalent lines of code of Python
Hi, In FPA, there are tables which shows equivalent lines of code for each Function Point (FP) for a number of programming languages. e.g. http://www.qsm.com/?q=resources/function-point-languages-table/index.html However, I have yet to find the figures for Python. Is someone able to advise the closest language equivalent. Regards -- http://mail.python.org/mailman/listinfo/python-list
Re: are there pros or contras, keeping a connection to a (sqlite) database ?
On 09/09/2010 12:29 AM, CM wrote: On Sep 8, 1:09 pm, Stef Mientki stef.mien...@gmail.com wrote: hello, I wrap my database in some class, and on creation of the instance, a connection to the database is created, and will stay connected until the program exists, something like this: self.conn = sqlite3.connect ( self.filename ) Now I wonder if there are pros or contras to keep the connection to the database continuously open ? thanks, Stef Mientki I do the same thing--good to hear from John that keeping it open is OK. But another question that this provokes, at least for me is: what happens when you call .connect() on the same database multiple times from within different parts of the same app? Is that bad? And is it that there now multiple connections to the database, or one connection that has multiple names in different namespaces within the app? CM, Do you talk about a multithreaded environment? or only about an environment with logically separate blocks (or with generators), and multiple objects each keeping their own connection. As far as I know sqlite can be compiled to be thread safe, but is not necessarily be default. No idea about the library used b python. I personally just started sqlite in one of my apps with multithrading and in order to be safe I went for the conservative approach connect, perform transactions, commit and close. However this is probably overkill and later in time I might also ty to keep connections open in order to increse performance. I'm not even sure what a connection really is; I assumed it was nothing more than a rule that says to write to the database with the file named in the parentheses. Further elaboration from the community would be helpful. Thanks, Che -- http://mail.python.org/mailman/listinfo/python-list
Re: [Q] Function Point Analysis (FPA) - Equivalent lines of code of Python
Nicholas yue.nicho...@gmail.com writes: e.g. http://www.qsm.com/?q=resources/function-point-languages-table/index.html However, I have yet to find the figures for Python. Is someone able to advise the closest language equivalent. That table looks pretty bogus, but of the languages on the list, perl is probably about the closest to python in spirit and code density. -- http://mail.python.org/mailman/listinfo/python-list
SendKeys and Python 2.7
Hi, I would like to send code from Vim [1] to R [2] on Microsoft Windows. Vim needs python 2.7 but the pre-compiled SendKeys module [3] is only avaiable for python 2.6. How can I make SendKeys work with python 2.7? I don't know how to compile python code. Is there an alternative to SendKeys? I'm sending to R only ^v to paste the content of the clipboard. Thanks, Jakson Aquino [1] http://www.vim.org/ [2] http://www.r-project.org/ [3] http://www.rutherfurd.net/python/sendkeys/#binaries -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] Arguments from the command line
On Wed, 08 Sep 2010 21:58:49 -0700, Dennis Lee Bieber wrote: On Thu, 09 Sep 2010 12:38:04 +1200, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand declaimed the following in gmane.comp.python.general: In message mailman.501.1283789339.29448.python-l...@python.org, Hugo Arts wrote: sys.argv is a list of all arguments from the command line ... Interesting that Python didnt bother to mimic the underlying POSIX convention of passing the command line as arguments to the mainline routine. What mainline routine... The only programming language(s) I've ever used that requires there be something called main in order to start a program is the C/C++ family. Java uses a method defined as public static void main(String[] args) My college COBOL never used multifile assignments, so I'm not sure if there was a difference between main and linked modules. There isn't, but command line argument passing is implementation- dependent and is complicated by the ability to define callable sub- programs in the same source file as the main program. The most general method is to use ACCEPT statements. MicroFocus COBOL uses ACCEPT ... FROM ARGUMENT-NUMBER, AIX COBOL uses a special system call and ICL 2900 COBOL and IBM COBOL/400, where the command line uses function call notation, map the command line arguments into a LINKAGE SECTION. In short: this area of COBOL is a mess. PL/I specifies the main procedure with an OPTIONS(MAIN) clause and declares the integer ARGC_ and pointer ARGV_ variables in it, which are used like their C equivalents. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | -- http://mail.python.org/mailman/listinfo/python-list
cath a timeout of httplib (Python 2.6.5)
Hi!. I have a problem with httplib and timeout. (I use python 2.6.5 and httplib) I have the next code for the http connection (its a WebService Client). === def ejecutaComandos(self,opcion, URL, commandString, conn, id): #pdb.set_trace() #fechatransacciones = conciliatorTime() #status = conn.status #date_transacc = fechatransacciones.getCompleteDate() try: try: enviaCommand = conn.request(POST, str(URL), commandString) respuestaCommand = conn.getresponse() except Exception as e: print 'Error de conexion: ',e #intentar=raw_input(Desea intentar nuevamente (S/N) : ) exit(1) respuestaWSDL = respuestaCommand.read() #print respuestaCommand nom_rand = str(random.choice('lmnopqrstuvwxyzABCDEFGHIJ'))+str(random.choice('abcdefghijk')) FileRand = nom_rand+'_tmp.xml' newFile = creaArchivos(FileRand,self.output) a = newFile.creaFile('w') #a = open('../output/responseXML.tmp', 'w') a.write(respuestaWSDL) a.close() #print XP_LOG+'respuesta de HLAPI recibida...'+str(date_transacc) #return respuestaWSDL return a.name #except httplib.HTTPException as he: except Exception as he: print Error de ejecucion ...: %s % (he) else: print Error inesperado... === I need resend the command when a timeout error present, my idea its use a while. === while (intentar=='S'): try: enviaCommand = conn.request(POST, str(URL), commandString) respuestaCommand = conn.getresponse() raise Exception except Exception as e: print 'Error de conexion: ',e intentar=raw_input(Desea intentar nuevamente (S/N) : ) if (intentar=='N'): exit(1) === But the information of enviaCommand it is lost, and it been only None, then fail resend. As I can resend the information without the command loses itself. Greetings and tanks!. -- Mauricio Martinez Garcia morfeo...@gmail.com Si encuentras un trébol de cuatro hojas..., hallaras la felicidad. Pero ¿Sabes?, seguramente no la encontrarás, porque la felicidad se encuentra en silencio guardada en una jaula. EL trebol de Cuatro hojas nunca será de nadie... ¿Que te parece si te adueñas de un trébol de tres hojas?... 我渴望得到幸福, 我渴望得到幸福, 和你一起得到幸福, 成为你的幸福, 带我离开, 带我远离这个地方, 笼中之鸟, 不能飞翔的鸟, 不会哭泣的鸟, 孤单的鸟, 因此请带我离开, 我渴望得到幸福, 只要在你身边我便感到幸福, 只要你微笑我便感到幸福, 初次的心愿成为了最后的愿望, 这里是妖精等待着的, 我们两人的约定地点, 因此请代我离开, 为了忘却现实, 为了停留在梦幻之中, 为了永远能够思念你, 带我离开, 我渴望得到幸福, 找到四叶三叶草, 就能得到幸福 不过, 请保守秘密 三叶草的白花 在哪里开放? 它的叶有多少瓣? 四叶三叶草 我想令你得到幸福 可是我不能成为你的人 -- http://mail.python.org/mailman/listinfo/python-list
32 bit bdist_wininst vs x64 platform
A reportlab user is using 32 bit python on x64 win 2003. he has a problem installing our bdist_wininst exe because the installer cannot find python. Apparently the installer is looking at HKLM\Software to locate python, but on x64 32 bit program requests get redirected to HKLM\Software\Wow6432Node (Extended explanation in KB article 896459). Is this fixable by me making a local patch to my distutils to check for the real platform and modifying the RegOpenKeyEx call? Or is there some distutils magic that I'm missing? Does anyone know if the bdist_msi might be better? -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: SendKeys and Python 2.7
On Thu, 2010-09-09 at 07:07 -0300, Jakson A. Aquino wrote: Vim needs python 2.7 From where do you base this assertion? I have been using vim 7.3 (with embedded python) with python 2.6 pretty much since it has been released. :version VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 29 2010 07:21:44) [...] :python import sys; print sys.version 2.6.5 (release26-maint, Aug 28 2010, 21:57:54) [GCC 4.4.4] -- http://mail.python.org/mailman/listinfo/python-list
importing module
Hi all Lets assume I have the following structure of directories and python modules: Root-dir |_dir1 |_ script1.py |_dir2 |_ script2.py |_sudir2 |_ script3.py Is it possible to import script1 into script2 and script3? Or do have to put script1.py into the Lib\site-packages folder of my Python installation so that it'll be in the standard module search path? Thx greets Dominique * This e-mail and any files attached are strictly confidential, may be legally privileged and are intended solely for the addressee. If you are not the intended recipient please notify the sender immediately by return email and then delete the e-mail and any attachments immediately. The views and or opinions expressed in this e-mail are not necessarily the views of Talaris Holdings Limited or any of its subsidiaries and the Talaris Group of companies, their directors, officers and employees make no representation about and accept no liability for its accuracy or completeness. You should ensure that you have adequate virus protection as the Talaris Group of companies do not accept liability for any viruses. Talaris Holdings Limited Registered No. 6569609 and Talaris Limited Registered No 6569621 are both registered in England with their registered office at: Talaris House, Crockford Lane, Chineham Business Park, Basingstoke, RG24 8QZ * -- http://mail.python.org/mailman/listinfo/python-list
Catching a SIGSEGV signal on an import
Is there anyway to catch a SIGSEGV signal that results from an import? I'd like to get a list of all modules on the sys.path. The module pkgutil has a nice method, walk_packages, to do just that. But, there is a third party extension that throws a SIGSEGV when imported. I tried to create a signal handler with the signal module like: #!/bin/env python import pkgutil import signal import traceback def handler(signal, stackframe): raise ImportError # Handle seg faults that may occur during an import signal.signal(signal.SIGSEGV, handler) if __name__ == __main__: goodMods = [] def onerror(pkgName): sys.stdout.write('Unable to import package %s\n' % pkgName) traceback.print_exc(file=sys.stdout) sys.stdout.write('\n') #sys.stdout.flush() for importer, mod, ispkg in pkgutil.walk_packages(path=None, onerror=onerror): goodMods.append(mod) for m in goodMods: sys.stdout.write(m + '\n') sys.stdout.flush() This sometimes works. But, since SIGSEGV is asynchronous it is not guaranteed to work all the time. In general, is there anyway to catch a SIGSEGV on import? If so, is there a way to use that with pkgutil.walk_packages to get all the modules on sys.path? Thanks, Ryan -- http://mail.python.org/mailman/listinfo/python-list
Re: importing module
Holzwarth, Dominique (Berne Branch) wrote: Hi all Lets assume I have the following structure of directories and python modules: Root-dir |_dir1 |_ script1.py |_dir2 |_ script2.py |_sudir2 |_ script3.py Is it possible to import script1 into script2 and script3? Or do have to put script1.py into the Lib\site-packages folder of my Python installation so that it'll be in the standard module search path? You have three options - put script1.py into a directory in python's search path - modify the PYTHONPATH environment variable to include /path/to/dir1 - add a .pth file in a directory already in python's search path http://docs.python.org/library/site.html#module-site http://docs.python.org/install/#inst-search-path Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] Arguments from the command line
Dennis Lee Bieber wrote: On Thu, 09 Sep 2010 12:38:04 +1200, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand declaimed the following in gmane.comp.python.general: In message mailman.501.1283789339.29448.python-l...@python.org, Hugo Arts wrote: sys.argv is a list of all arguments from the command line ... Interesting that Python didnt bother to mimic the underlying POSIX convention of passing the command line as arguments to the mainline routine. What mainline routine... The only programming language(s) I've ever used that requires there be something called main in order to start a program is the C/C++ family. [ ... ] My college COBOL never used multifile assignments, so I'm not sure if there was a difference between main and linked modules. Historical COBOL had a PROCEDURE DIVISION which marked the start of execution. But historical COBOL didn't pass parameters anyway. You read your optional arguments from a file, or accepted a few from an input device. I don't know PL/I generally, but with Multics PL/I any externally accessible procedure could be called from the command line: any_program$ea_proc a b c passing (for example) 'a', 'b', and 'c' as parameters. If the parameters were declared as variable-length character strings: ea_proc: proc (x, y, z); dcl (x, y, z) char (*); ... this would even work. Illustrating that the command-line-parameter-passing question is a deal with the operating system at least as much as it's a language issue. Posix aren't the only O/S. Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] Arguments from the command line
Dennis Lee Bieber wlfr...@ix.netcom.com writes: FORTRAN just differentiates by having the main file start with PROGRAM random_name whereas subfiles are all either (or both) SUBROUTINE another_name(args) FUNCTION that_other_name(args) no BLOCKDATA? -- http://mail.python.org/mailman/listinfo/python-list
Re: cPickle segfault with nested dicts in threaded env
On Wed, Sep 8, 2010 at 6:55 PM, Paul Rubin no.em...@nospam.invalid wrote: Carl Banks pavlovevide...@gmail.com writes: Since Python 2.7 is released, Python 2.5 is no longer accepting bug fixes, only security fixes. So be aware. Segfaults should be treated as security holes unless there's convincing reasons that no exploit is possible. So the bug should be reported against 2.5 as well as later versions. Hi Paul, Thanks for the input, it sounds reasonable to me. I reported it the maintainers can decide what to do with it: http://bugs.python.org/issue9812 Thanks again everyone, Kenneth -- http://mail.python.org/mailman/listinfo/python-list
Python script for repairing .mov file ?
Jave is much better; http://yfrog.com/naattempt1hj -- http://mail.python.org/mailman/listinfo/python-list
how to extract an implicit dict expression (with statement return)
Hi, I do not know how to subject my problem in a better way. I have the following statement: return [ dict(x1 = elem.x1, x2 = elem.x2, x3 = elem.x3,) for elem in method(in_values) ] How can I transform it to an explicit description: result = ... return result Could not found a description for the here used form of for and what [...] means. Need this for debugging. Thanks for any help. Regards, Fritz -- http://mail.python.org/mailman/listinfo/python-list
Re: how to extract an implicit dict expression (with statement return)
On Thu, Sep 9, 2010 at 11:20 AM, Fritz Loseries fr...@loseries.info wrote: Hi, I do not know how to subject my problem in a better way. I have the following statement: return [ dict(x1 = elem.x1, x2 = elem.x2, x3 = elem.x3,) for elem in method(in_values) ] How can I transform it to an explicit description: result = ... return result Could not found a description for the here used form of for and what [...] means. Need this for debugging. Thanks for any help. Regards, Fritz [ ] defines a list literal [1,2,3] [1, 2, 3] type(_) type 'list' This particular syntax [ for ___ in ___] is a list comprehension. It's creating an inline for-loop to generate a list. You can just lift the whole expression for the assignment. result = [ dict(x1 = elem.x1, x2 = elem.x2, x3 = elem.x3,) for elem in method(in_values) ] return result -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] with statement syntax forces ugly line breaks?
On 08/09/2010 20:30, MRAB wrote: On 08/09/2010 19:07, Georg Brandl wrote: Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out. FYI, that should be thine indenting. My/thy before a consonant, mine/thine before a vowel. Compare with a/an, which we still do. Hopefully correct, but certainly better than you knowledge of Spanish :) Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Slice a list of lists?
On 08/09/2010 21:23, Jonno wrote: On Wed, Sep 8, 2010 at 3:18 PM, Jonnojonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 3:06 PM, Jonnojonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 2:11 PM, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Wed, Sep 8, 2010 at 2:55 PM, Jonnojonnojohn...@gmail.com wrote: I know that I can index into a list of lists like this: a=[[1,2,3],[4,5,6],[7,8,9]] a[0][2]=3 a[2][0]=7 but when I try to use fancy indexing to select the first item in each list I get: a[0][:]=[1,2,3] a[:][0]=[1,2,3] Why is this and is there a way to select [1,4,7]? -- It's not fancy indexing. It's called taking a slice of the existing list. Look at it this way a[0] means take the first element of a. The first element of a is [1,2,3] a[0][:] means take all the elements in that first element of a. All the elements of [1,2,3] are [1,2,3]. a[:] means take all the elements of a. So a[:] is [[1,2,3],[4,5,6],[7,8,9]]. a[:][0] means take the first element of all the elements of a. The first element of a[:] is [1,2,3]. There is no simple way to get [1,4,7] because it is just a list of lists and not an actual matrix. You have to extract the elements yourself. col = [] for row in a: col.append(row[0]) You can do this in one line using a list comprehension: [ row[0] for row in a ] Thanks! (to Andreas too). Totally makes sense now. Now if I want to select the first item in every 2nd item of list a (ie: [1,7]) can I use ::2 anywhere or do I need to create a list of indices to use in a more complex for loop? Seems like the simplest way would be: [row[0] for row in a][::2] The fastest way to find out is probably typing at the interactive prompt. Just jump in at the deep end and see what happens. Then wait until someone tells you to use the timeit module. Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] with statement syntax forces ugly line breaks?
On 09/09/2010 17:07, Mark Lawrence wrote: On 08/09/2010 20:30, MRAB wrote: On 08/09/2010 19:07, Georg Brandl wrote: Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out. FYI, that should be thine indenting. My/thy before a consonant, mine/thine before a vowel. Compare with a/an, which we still do. X-Antispam: NO; Spamcatcher 6.0.4. Score 1 Hopefully correct, but certainly better than you knowledge of Spanish :) Or /your/ knowledge of English! (Muphry's Law) :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Slice a list of lists?
On Thu, Sep 9, 2010 at 10:58 AM, Robert Kern robert.k...@gmail.com wrote: Please keep responses on the mailing list. However, I will reply below this one time. On Thu, Sep 9, 2010 at 10:35, Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 4:26 PM, Robert Kern robert.k...@gmail.com wrote: A motivating example: [~] |1 import numpy [~] |2 a = numpy.array([[1,2,3],[4,5,6],[7,8,9]]) [~] |3 a array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) [~] |4 a[0,2] 3 [~] |5 a[2,0] 7 [~] |6 a[0,:] array([1, 2, 3]) [~] |7 a[:,0] array([1, 4, 7]) -- Robert Kern Thanks Robert. I'm actually much more familiar and comfortable with arrays so I know how to slice them. The problem is that the data comes from lines in a file which are not all of equal length. My understanding is that I need to manipulate the data as lists until I can get all the lists of equal length at which point I can make an array from it. If you have ragged arrays, then you do not want to slice down columns to begin with. You might run into a row that does not have a value at that column. If you need to slice down columns (whether the object remains a list of lists or a numpy array), then you need to create a rectangular array regardless. Do that first, then I recommend using numpy arrays. Slicing down columns (probably) won't help you with that. Understood. My data actually has 2 features which make it non-rectangular in most circumstances. One is the extra element at the start of every nth line (I now know how to remove that) and the second is that some lines contain more data than others. My data is essentially a m,m,n array but data from each row is shifted to the next line when the line is full (4 columns). A new row then starts a new line. I want to pick out the data and assign it to an array but I'm wondering whether I should first try to take the data on the extra lines, remove it and stick it on the end of the original line (the data from one row could extend onto multiple lines). Or whether I'm better trying to create the array using loops to index my way through the lines the way they already are laid out. Hope this makes sense. -- http://mail.python.org/mailman/listinfo/python-list
Re: Difference between queues and pipes in multiprocessing
James Mills wrote: On Wed, Aug 4, 2010 at 7:20 PM, Navkirat Singh navkir...@gmail.com wrote: I was wondering what are the differences between queues and pipes implemented using multiprocessing python module. Am I correct if I say, in pipes, if another process writes to one receiving end concurrently, then an error will be raised and in queues the later processes data will just queued up? basically a Queue is a syncronization primitive used to share and pass data to and from parent/child processes. A pipe is as the name suggests, a socket pair connected end-to-end allowing for full-duplex communications. Isn't a pipe's communications one-way, requiring two of them to achieve full-duplex? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Printing the name of a variable
Does an arbitrary variable carry an attribute describing the text in its name? I'm looking for something along the lines of: x = 10 print x.name 'x' Perhaps the x.__getattribute__ method? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing the name of a variable
On Thu, 2010-09-09 at 12:43 -0700, Stephen Boulet wrote: Does an arbitrary variable carry an attribute describing the text in its name? I'm looking for something along the lines of: x = 10 print x.name 'x' Perhaps the x.__getattribute__ method? Thanks. Variables are not objects and so they have no attributes. You can't really de-reference the object being referenced as it can potentially contain multiple references, but an innacurate way of doing this would be, e.g. x = [1, 2, 3] y = x g = globals() varnames = [i for i in g if g[i] is x] ['x', 'y'] But this cries the question: why do you want to do this? And usually that question is asked when someone thinks that a: you shouldn't need to do this and b: whatever the desired effect there is probably a better way of accomplishing it. -- http://mail.python.org/mailman/listinfo/python-list
Why does linecache avoid stdin? How can I get equivalent of inspect.getsource() for an interactive session?
Here's my goal: To enable a function for interactive session use that, when invoked, will put source code for a specified object into a plaintext file. Based on some initial research, this seems similar to ipython's %save magic command (?) Example: def put(filename, object): f = open(filename, w) f.write(inspect.getsource(object)) f.close() Of course, in an interactive session, if you define a function: def addit(a,b): return a+b And then try to run inspect.getsource() on it, you'll get an exception: inspect.getsource(addit) Traceback (most recent call last): File stdin, line 1, in module File C:\Python26\lib\inspect.py, line 689, in getsource lines, lnum = getsourcelines(object) File C:\Python26\lib\inspect.py, line 678, in getsourcelines lines, lnum = findsource(object) File C:\Python26\lib\inspect.py, line 526, in findsource raise IOError('could not get source code') IOError: could not get source code This appears to be due to the fact that the linecache standard library module doesn't include stdin (?) Can anyone help shed some light on why this is -- and perhaps provide feedback on whether this goal is feasible? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: SendKeys and Python 2.7
Hi! Example for send ^V (with PyWin32): import time,win32api,win32con win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0) win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | 0, 0) time.sleep(0.05) win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | win32con.KEYEVENTF_KEYUP, 0) win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0) @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list
Re: Difference between queues and pipes in multiprocessing
On Thu, 09 Sep 2010 12:23:17 -0700, Ethan Furman wrote: basically a Queue is a syncronization primitive used to share and pass data to and from parent/child processes. A pipe is as the name suggests, a socket pair connected end-to-end allowing for full-duplex communications. Isn't a pipe's communications one-way, requiring two of them to achieve full-duplex? He's talking about multiprocessing.Pipe(), not a Unix pipe. On Unix, multiprocessing.Pipe() uses a socket pair if duplex==True and a pipe if duplex==False. On Windows it uses a named pipe (which can be either unidirectional or bidirectional). -- http://mail.python.org/mailman/listinfo/python-list
Re: accessing a text file
On Wed, 08 Sep 2010 03:30:00 -0700, Baba wrote: Who is licensed to judge what can and cannot be posted as a question? Exactly the same set of people who are licensed to judge what can and cannot be posted as an answer. If you don't like the responses you get here, you could try posting your questions on 4chan. If nothing else, that will give you a whole new perspective on what an unfriendly response really looks like. -- http://mail.python.org/mailman/listinfo/python-list
Re: Catching a SIGSEGV signal on an import
On Thu, 09 Sep 2010 05:23:14 -0700, Ryan wrote: But, since SIGSEGV is asynchronous SIGSEGV is almost always synchronous. In general, is there anyway to catch a SIGSEGV on import? No. If SIGSEGV is raised, it often indicates that memory has been corrupted. At that point, you can't assume that the Python runtime is still functional. In general, even attempting to catch it is a bad idea. Particularly in a high-level language; getting it right in C is hard enough. -- http://mail.python.org/mailman/listinfo/python-list
Re: accessing a text file
Nobody nob...@nowhere.com writes: If you don't like the responses you get here, you could try posting your questions on 4chan. If nothing else, that will give you a whole new perspective on what an unfriendly response really looks like. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list
analysis of algoritms
Hi In below code the outer loop test in step 4 will execute ( n + 1 ) times (note that an extra step is required to terminate the for loop, hence n + 1 and not n executions), which will consume T4( n + 1 ) time. (from http://en.wikipedia.org/wiki/Analysis_of_algorithms) 1get a positive integer from input 2if n 10 3print This might take a while... 4for i = 1 to n 5for j = 1 to i 6print i * j 7print Done! Why does step 4 execute n+1 times? what is the exta step mentioned above tnx Baba -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing the name of a variable
On 9/9/2010 3:43 PM, Stephen Boulet wrote: In Python, 'variable' is a synonym for name and identifier,' An object can have 0 to many names attached to it. An object can also be a member of 0 to many collections. Modules, classes, and functions have 'definition name' strings attached to them as their .__name__ attribute. This attribute is used to display the 'value' of these objects, as in def f(): pass f function f at 0x00F05420 The __name__ attribute is also used in the idiom if __name__ == '__main__': print(I am the main module) I am the main module to determine if a module is being run as the main module as imported into another module. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
how to kill a subprocess
Hi There, I'm calling a python script from a php script which again calls a perl script with subprocess.popen(). This seems to work fine so far only that once the python script completed it is becoming a zombie because the perl script in the background is still running... so before i exit the python script, i would need to kill my perl subprocess. How can i do so? Thank you for hints suggestions! Ron -- http://mail.python.org/mailman/listinfo/python-list
Re: analysis of algoritms
On 9 September 2010 23:39, Baba raoul...@gmail.com wrote: Hi In below code the outer loop test in step 4 will execute ( n + 1 ) times (note that an extra step is required to terminate the for loop, hence n + 1 and not n executions), which will consume T4( n + 1 ) time. (from http://en.wikipedia.org/wiki/Analysis_of_algorithms) 1get a positive integer from input 2if n 10 3print This might take a while... 4for i = 1 to n 5for j = 1 to i 6print i * j 7print Done! Why does step 4 execute n+1 times? what is the exta step mentioned above Because it does two things: - increase i - check whether i is still smaller than n. If it is not, the loop is terminated Still, this is quite a simplification of what's really going on... Almar -- http://mail.python.org/mailman/listinfo/python-list
[ANN] ACCU 2011 Conference Call for Proposals -- deadline approaching
Hi all, This is a reminder that the deadline for the ACCU 2011 CfP is approaching fast--26th of September 2010. If you have not sent your proposals yet, below there are more details on how to do so. Call for Proposals - ACCU 2011 April 13-16, 2011. Barcelo Oxford Hotel, Oxford, UK Submission deadline: 26th of September 2010 Email proposals to: Giovanni Asproni, confere...@accu.org http://www.accu.org/conference twitter: @accu2011 #accu2011 We invite you to propose a session for this leading software development conference. We have a long tradition of high quality sessions covering many aspects of software development, from programming languages (e.g., Java, C#, Python, Erlang, Haskell, Ruby, Groovy, C, C++, etc.), and technologies (libraries, frameworks, databases, etc.) to subjects about the wider development environment such as testing, architecture and design, development process, analysis, patterns, project management, and softer aspects such as team building, communication and leadership. Sessions may be either tutorial-based, presentations of case studies, or take the form of interactive workshops. We are always open to novel formats, so please contact us with your idea. The standard length of a session is 90 minutes, with some exceptions. In order to allow less experienced speakers to speak at the conference without the pressure of filling a full 90 minutes, we reserve a number of shorter 45 minute sessions. If you would like to run a session please let us know by emailing your proposals to confere...@accu.org by the 26th of September 2010 at the latest. Please include the following to support your proposal: * Title (a working title if necessary) * Type (tutorial, workshop, case study, etc.) * Duration (45/90 min) * Speaker name(s) * Speaker biography (max 150 words) * Description (approx 250 words) Proposals about specific products and technologies will be taken under consideration only if they are open source and available for free (at least for non-commercial use). If you are interested in talking about a proprietary technology, there is the possibility of sponsored sessions which are presented outside the standard conference schedule. Please, email confere...@accu.org for more information. If you are interested in knowing more about the conference you may like to consult the website for previous years' editions at http://www.accu.org/conference for background information. Speakers running one or more full 90 minute sessions receive a special conference package including free attendance, and assistance with their travel and accommodation costs. Speakers filling a 45 minute slot qualify for free conference attendance on the day of their session. The conference has always benefited from the strength of its programme. Please help us make 2011 another successful event. Giovanni Asproni Conference Chair -- http://mail.python.org/mailman/listinfo/python-list
Re: analysis of algoritms
On 9/9/10 4:39 PM, Baba wrote: Hi In below code the outer loop test in step 4 will execute ( n + 1 ) times (note that an extra step is required to terminate the for loop, hence n + 1 and not n executions), which will consume T4( n + 1 ) time. (from http://en.wikipedia.org/wiki/Analysis_of_algorithms) 1get a positive integer from input 2if n 10 3print This might take a while... 4for i = 1 to n 5for j = 1 to i 6print i * j 7print Done! Why does step 4 execute n+1 times? what is the exta step mentioned above You may wish to ask the question on the associated Discussion page for that article. Hopefully the author of that statement will notice it there. They are almost certainly not here. That said, an extra step is required because a real implementation of that algorithm in a language will create a variable `i` initialized to 1, increment it each round through the loop, and check it before running the loop. When the check indicates that it equals n + 1 (not n!) it will exit the loop. That particular pseudocode notation hides that detail. Of course, there are ways to implement that pseudocode that do not require the last check, but none of real importance. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: are there pros or contras, keeping a connection to a (sqlite) database ?
On Thu, Sep 9, 2010 at 12:29 AM, CM cmpyt...@gmail.com wrote: [...] I'm not even sure what a connection really is; I assumed it was nothing more than a rule that says to write to the database with the file named in the parentheses. [...] The following list is not exclusive, but these are the first things that I can think of. - SQLite connections have state like uncommitted transactions - SQLite connections have page caches and metadata caches (tables, structures and indices) Opening and closing SQLite connections is very cheap, but keeping connections open is usually a better approach. You have to have a global setting like the path to the database file anyway; so you can wrap a global connection object in a factory function just as well. In database applications that use the raw DB-APi i usually start with something like: def get_con(): # return database connection ... HTH -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: are there pros or contras, keeping a connection to a (sqlite) database ?
On Sep 9, 4:41 am, News123 news1...@free.fr wrote: On 09/09/2010 12:29 AM, CM wrote: On Sep 8, 1:09 pm, Stef Mientki stef.mien...@gmail.com wrote: hello, I wrap my database in some class, and on creation of the instance, a connection to the database is created, and will stay connected until the program exists, something like this: self.conn = sqlite3.connect ( self.filename ) Now I wonder if there are pros or contras to keep the connection to the database continuously open ? thanks, Stef Mientki I do the same thing--good to hear from John that keeping it open is OK. But another question that this provokes, at least for me is: what happens when you call .connect() on the same database multiple times from within different parts of the same app? Is that bad? And is it that there now multiple connections to the database, or one connection that has multiple names in different namespaces within the app? CM, Do you talk about a multithreaded environment? or only about an environment with logically separate blocks (or with generators), and multiple objects each keeping their own connection. More the latter. My calls to make a connection to the database are from within different classes that serve different aspects of the GUI. I have something like an anti-MVC pattern here, like ravioli code, where each GUI element gets what it needs from the database. They are all running in the main GUI thread. There is also, though, a wxPython timer (wxTimer) that will occasionally initiate a read or write to the database, though it will already have an open connection. Why? How would this matter? As far as I know sqlite can be compiled to be thread safe, but is not necessarily be default. No idea about the library used b python. I haven't dealt with the issue of thread safety before, haven't thought about it really. I personally just started sqlite in one of my apps with multithrading and in order to be safe I went for the conservative approach connect, perform transactions, commit and close. However this is probably overkill and later in time I might also ty to keep connections open in order to increse performance. So far the many calls to .connect() approach has not seemed problematic for my app. But I have nothing to compare it to. Che -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does linecache avoid stdin? How can I get equivalent of inspect.getsource() for an interactive session?
On Thursday 09 September 2010, it occurred to Mark Hirota to exclaim: Here's my goal: To enable a function for interactive session use that, when invoked, will put source code for a specified object into a plaintext file. Based on some initial research, this seems similar to ipython's %save magic command (?) Example: def put(filename, object): f = open(filename, w) f.write(inspect.getsource(object)) f.close() Of course, in an interactive session, if you define a function: def addit(a,b): return a+b And then try to run inspect.getsource() on it, you'll get an exception: inspect.getsource(addit) What inspect.getsource is is simply this: It finds out which module the object belongs to, checks the __file__ of that module, opens it (or the corresponsing .py file), and finds the right bit. This won't work for extension modules as they have no Python source, and it won't work for objects created on the interactive console or using exec, or eval, as they have no source file. Traceback (most recent call last): File stdin, line 1, in module File C:\Python26\lib\inspect.py, line 689, in getsource lines, lnum = getsourcelines(object) File C:\Python26\lib\inspect.py, line 678, in getsourcelines lines, lnum = findsource(object) File C:\Python26\lib\inspect.py, line 526, in findsource raise IOError('could not get source code') IOError: could not get source code This appears to be due to the fact that the linecache standard library module doesn't include stdin (?) Can anyone help shed some light on why this is -- and perhaps provide feedback on whether this goal is feasible? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue cleanup
On 9/8/2010 6:20 PM, Paul Rubin wrote: What tricks on tricks? Even the fanciest GC's are orders of magnitude less complicated than any serious database, optimizing compiler, OS kernel, file system, etc. Real-world software is complicated. Get used to that fact, and look for ways to manage the complexity and keep complex programs safe. Choosing to program with unsafe methods because you wish the complexity didn't exist is just deluded. Garbage collectors are difficult from a theoretical standpoint, and it's very difficult to make a correct concurrent garbage collector without using formal methods. But garbage collectors are not large pieces of code. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: analysis of algoritms
Baba raoul...@gmail.com writes: In below code the outer loop test in step 4 will execute ( n + 1 ) times (note that an extra step is required to terminate the for loop, hence n + 1 and not n executions), which will consume T4( n + 1 ) time. (from http://en.wikipedia.org/wiki/Analysis_of_algorithms) 1get a positive integer from input 2if n 10 3print This might take a while... 4for i = 1 to n 5for j = 1 to i 6print i * j 7print Done! Why does step 4 execute n+1 times? what is the exta step mentioned above In the outer loop test [...], the important word is _test_. Line 4 has to test the value of i against n, which results in true n times and in false once (where it jumps to instruction 7). Note that this would be true even with python loops using range(n) or xrange(n), where the test is not an integer comparison. (Note also how this last remark tries to avoid complete off-topic-ness of this discussion in this group :-) -- Alain. -- http://mail.python.org/mailman/listinfo/python-list
Re: analysis of algoritms
On 2:59 PM, Baba wrote: Hi In below code the outer loop test in step 4 will execute ( n + 1 ) times (note that an extra step is required to terminate the for loop, hence n + 1 and not n executions), which will consume T4( n + 1 ) time. (from http://en.wikipedia.org/wiki/Analysis_of_algorithms) 1get a positive integer from input 2if n 10 3print This might take a while... 4for i = 1 to n 5for j = 1 to i 6print i * j 7print Done! Why does step 4 execute n+1 times? what is the exta step mentioned above tnx Baba Why are you posting a question about BASIC syntax in a Python forum? Python has no such statement, and its close approximations work much differently. If you really want an abstract answer, then you should be decomposing those BASIC statements into smaller atoms. The for statement is composed of at least three atoms, one of which is probably executed n+1 times. A BASIC for statement for i=1 to n decomposes into approximately: 4a, i = 1 4bcompare i to n 4cskip if greater 5, 6 do some stuff 4d increment i Note that the increment happens after steps 5 and 6, but it's part of line 4 Also note that the exact details depend thoroughly on the brand and version of BASIC, there being at least 60 versions out there. For example, I can think of at least three cases for what i will equal on line 7. Incidentally, in some versions of BASIC, 4b and 4c might come after 4d, and only be executed n times. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Difference between queues and pipes in multiprocessing
Nobody wrote: On Thu, 09 Sep 2010 12:23:17 -0700, Ethan Furman wrote: basically a Queue is a syncronization primitive used to share and pass data to and from parent/child processes. A pipe is as the name suggests, a socket pair connected end-to-end allowing for full-duplex communications. Isn't a pipe's communications one-way, requiring two of them to achieve full-duplex? He's talking about multiprocessing.Pipe(), not a Unix pipe. On Unix, multiprocessing.Pipe() uses a socket pair if duplex==True and a pipe if duplex==False. On Windows it uses a named pipe (which can be either unidirectional or bidirectional). Ah. I was confusing it with os.pipe(). Many thanks. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: how to kill a subprocess
cerr ron.egg...@gmail.com writes: I'm calling a python script from a php script which again calls a perl script with subprocess.popen(). This seems to work fine so far only that once the python script completed it is becoming a zombie because the perl script in the background is still running... so before i exit the python script, i would need to kill my perl subprocess. How can i do so? x.terminate() (and then x.wait()) where x is the value returned by subprocess.Popen(). -- Alain. P/S: I'm not sure why the python process survives, and I think your use of zombie is not correct (afaik a zombie is an exited process whose parent hasn't called wait() yet) -- http://mail.python.org/mailman/listinfo/python-list
Re: how to kill a subprocess
On Sep 9, 3:29 pm, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: cerr ron.egg...@gmail.com writes: I'm calling a python script from a php script which again calls a perl script with subprocess.popen(). This seems to work fine so far only that once the python script completed it is becoming a zombie because the perl script in the background is still running... so before i exit the python script, i would need to kill my perl subprocess. How can i do so? x.terminate() (and then x.wait()) where x is the value returned by subprocess.Popen(). Well, this is what I have: writelog(starting GPS simulator) commandlist=[GPSsim,proto,GPSfile] writelog(commandlist[0]+ +commandlist[1]+ +commandlist[2]) process=subprocess.Popen(commandlist) writelog(GPS simulator started) ... ... os.kill(process.pid,9) os.wait() but this is not working for me... :( any clues? P/S: I'm not sure why the python process survives, and I think your use of zombie is not correct (afaik a zombie is an exited process whose parent hasn't called wait() yet) This is what I have: localhost cgi-bin # ps ax | grep py 11853 ?Z 0:00 [python2.6] defunct 12029 pts/1S+ 0:00 grep --colour=auto py The 'Z' you see there stands for Zombie -- http://mail.python.org/mailman/listinfo/python-list
Re: how to kill a subprocess
On 09/09/2010 23:52, cerr wrote: On Sep 9, 3:29 pm, Alain Ketterlinal...@dpt-info.u-strasbg.fr wrote: cerrron.egg...@gmail.com writes: I'm calling a python script from a php script which again calls a perl script with subprocess.popen(). This seems to work fine so far only that once the python script completed it is becoming a zombie because the perl script in the background is still running... so before i exit the python script, i would need to kill my perl subprocess. How can i do so? x.terminate() (and then x.wait()) where x is the value returned by subprocess.Popen(). Well, this is what I have: writelog(starting GPS simulator) commandlist=[GPSsim,proto,GPSfile] writelog(commandlist[0]+ +commandlist[1]+ +commandlist[2]) process=subprocess.Popen(commandlist) writelog(GPS simulator started) ... ... os.kill(process.pid,9) os.wait() but this is not working for me... :( any clues? P/S: I'm not sure why the python process survives, and I think your use of zombie is not correct (afaik a zombie is an exited process whose parent hasn't called wait() yet) This is what I have: localhost cgi-bin # ps ax | grep py 11853 ?Z 0:00 [python2.6]defunct 12029 pts/1S+ 0:00 grep --colour=auto py The 'Z' you see there stands for Zombie How about: process.kill() # New in Python 2.6 or: os.kill(process.pid, 9) then: process.wait() or: os.waitpid(process.pid, 0) -- http://mail.python.org/mailman/listinfo/python-list
Re: SendKeys and Python 2.7
On Thu, Sep 9, 2010 at 5:40 PM, Michel Claveau - MVP enleverlesx_xx...@xmclavxeaux.com.invalid wrote: Hi! Example for send ^V (with PyWin32): import time,win32api,win32con win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0) win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | 0, 0) time.sleep(0.05) win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | win32con.KEYEVENTF_KEYUP, 0) win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0) Thank you very much! Your code solved my problem. I added some lines to set the focus into R before the ^V and then back to Vim: import time,win32api,win32con,win32com.client shell = win32com.client.Dispatch(WScript.Shell) shell.AppActivate(R Console) win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0) win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | 0, 0) time.sleep(0.05) win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | win32con.KEYEVENTF_KEYUP, 0) win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0) shell.AppActivate(Vim) Best regards, Jakson Aquino -- http://mail.python.org/mailman/listinfo/python-list
Re: analysis of algoritms
On Thu, 09 Sep 2010 18:26:52 -0400, Dave Angel da...@ieee.org wrote: On 2:59 PM, Baba wrote: Hi In below code the outer loop test in step 4 will execute ( n + 1 ) times (note that an extra step is required to terminate the for loop, hence n + 1 and not n executions), which will consume T4( n + 1 ) time. (from http://en.wikipedia.org/wiki/Analysis_of_algorithms) 1get a positive integer from input 2if n 10 3print This might take a while... 4for i = 1 to n 5for j = 1 to i 6print i * j 7print Done! Why does step 4 execute n+1 times? what is the exta step mentioned above tnx Baba Why are you posting a question about BASIC syntax in a Python forum? Python has no such statement, and its close approximations work much differently. If you really want an abstract answer, then you should be decomposing those BASIC statements into smaller atoms. The for statement is composed of at least three atoms, one of which is probably executed n+1 times. A BASIC for statement for i=1 to n decomposes into approximately: 4a, i = 1 4bcompare i to n 4cskip if greater 5, 6 do some stuff 4d increment i REM And the vuitally important: 4e GOTO 4b But, as Robert noted, this is undoubtedly pseudocode rather than BASIC. Pity it's not Python-oriented pseudocode... Note that the increment happens after steps 5 and 6, but it's part of line 4 Also note that the exact details depend thoroughly on the brand and version of BASIC, there being at least 60 versions out there. For example, I can think of at least three cases for what i will equal on line 7. Incidentally, in some versions of BASIC, 4b and 4c might come after 4d, and only be executed n times. DaveA -- http://mail.python.org/mailman/listinfo/python-list
reading multiple files
I have 3 files which are constantly being updated therefore I use tail -f /var/log/file1, tail -f /var/log/file2, and tail -f /var/log/file3 For 1 file I am able to manage by tail -f /var/log/file1 | python prog.py prog.py looks like this: f=sys.stdin for line in f: print line But how can I get data from /var/log/file2 and /var/log/file3 ? I prefer a native python way instead of doing tail -f TIA -- http://mail.python.org/mailman/listinfo/python-list
Re: how to kill a subprocess
cerr ron.egg...@gmail.com writes: x.terminate() (and then x.wait()) where x is the value returned by subprocess.Popen(). Well, this is what I have: writelog(starting GPS simulator) commandlist=[GPSsim,proto,GPSfile] writelog(commandlist[0]+ +commandlist[1]+ +commandlist[2]) process=subprocess.Popen(commandlist) writelog(GPS simulator started) ... ... os.kill(process.pid,9) os.wait() but this is not working for me... :( any clues? Should be ok. A minor point: os.kill(...) and os.wait() have equivalent (portable) convenience methods on Popen. Also, it may be better to send SIGTERM (15) instead of SIGKILL, to ensure the victim can die gracefully (e.g., remove temp files). P/S: I'm not sure why the python process survives, and I think your use of zombie is not correct (afaik a zombie is an exited process whose parent hasn't called wait() yet) This is what I have: localhost cgi-bin # ps ax | grep py 11853 ?Z 0:00 [python2.6] defunct 12029 pts/1S+ 0:00 grep --colour=auto py The 'Z' you see there stands for Zombie This is from man ps: Processes marked defunct are dead processes (so-called zombies) that remain because their parent has not destroyed them properly. These processes will be destroyed by init(8) if the parent process exits. So the problem is with what launches this python process (11853). If this process is the python interpreter running the program above, check how you launch it. If this process is something else, check its parent process. -- Alain. -- http://mail.python.org/mailman/listinfo/python-list
weighted mean; weighted standard error of the mean (sem)
I am looking for some reaally basic statistical tools. I have some sample data, some sample weights for those measurements, and I want to calculate a mean and a standard error of the mean. Here are obvious places to look: numpy scipy.stats statsmodels It seems to me that numpy's mean and average functions have their names backwards. That is, often a mean is defined more generally than average, and includes the possibility of weighting, but in this case it is average that has a weights argument. Can these functions be merged/renamed/deprecated in the future? It's clear to me that mean should allow for weights. None of these modules, above, offer standard error of the mean which incorporates weights. numpy's sem doesn't, and that's the closest thing. numpy's var doesn't allow weights. There aren't any weighted variances in the above modules. Again, are there favoured codes for these functions? Can they be incorporated appropriately in the future? Most immediately, I'd love to get code for weighted sem. I'll write it otherwise, but if I do I'd love to know whom to bug to get it incorporated into numpy.sem ... Thanks! None of them have this basic function. Has anyone written one? -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed-up for loops
Stefan Behnel stefan...@behnel.de wrote in message news:mailman.563.1283921317.29448.python-l...@python.org... BartC, 08.09.2010 03:45: Getting back to the OP's code again (trivial and pointless as it might seem), I got these results: C (gcc 3.4.5 -O3) 0.8 secs C (DMC-o) 2.3 secs C (lccwin32 -O) 2.9 secs BTW, I wonder why the code takes a whole 0.8 seconds to run in your gcc test. Maybe you should use a newer GCC version. It shouldn't take more than a couple of milliseconds (for program startup, OS calls, etc.), given that the output is a constant. It turns out the 0.8 second version cheats. It counts to a billion, but does not do the work asked (a=a+10). The fastest time that will do what it is requested, is about 1.2 seconds, when register-based, and about 3 seconds when memory-based. This reduces the slowdown on Python 3 from 220x to 150x, and down to 60x when register-versions are not counted (as use of registers can't be guaranteed). (Python 2 was about 20% faster.) -- Bartc -- http://mail.python.org/mailman/listinfo/python-list
Re: reading multiple files
Mag Gam magaw...@gmail.com writes: I have 3 files which are constantly being updated therefore I use tail -f /var/log/file1, tail -f /var/log/file2, and tail -f /var/log/file3 For 1 file I am able to manage by tail -f /var/log/file1 | python prog.py prog.py looks like this: f=sys.stdin for line in f: print line But how can I get data from /var/log/file2 and /var/log/file3 ? Use shell tricks, e.g., with bash: yourpythonprog (tail -f .../file1) (tail -f .../file2) (...) and let your prog open its three parameters like regular files (they are fifos actually). If your shell doesn't support (...), create the fifos and redirect tail output before launching your prog. If you want purer python, launch the three tail -f with subprocess, and use the select module to get input (you didn't explain the logic you will follow to track three files---you may not need select if you expect one line from each file before waiting for the next line of any). I prefer a native python way instead of doing tail -f Emulating tail will require a lot of stat/seeks, and finding lines will require an additional level of complexity. Also, tail -f has a cost [*]. The only way to avoid it is to use inotify, which seems to have a python interface, available at http://pyinotify.sourceforge.net/ (I've never used it). Again, emulating tail -f with inotify is significant work. -- Alain. [*] Paul Rubin is one of the authors, I think he reads this group. -- http://mail.python.org/mailman/listinfo/python-list
Re: weighted mean; weighted standard error of the mean (sem)
On 10 September 2010 10:36, C Barrington-Leigh cpblpub...@gmail.com wrote: Most immediately, I'd love to get code for weighted sem. I'll write it otherwise, but if I do I'd love to know whom to bug to get it incorporated into numpy.sem ... The best place to ask about numpy related stuff is the numpy mailing list at: http://mail.scipy.org/mailman/listinfo/numpy-discussion This is also the best place to present a patch if you have code to contribute. In my experience the numpy devs are always happy to have new contributors, but be sure to discuss the problem first, as the folk over there might be able to provide a solution which doesn't require a new patch. Cheers, Tim Thanks! None of them have this basic function. Has anyone written one? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
How Python works: What do you know about support for negative indices?
Hello Folks. It doesn't seem to be common knowledge when and how a[x] gets translated to a[x+len(x)]. So, here's a short info post on how Python supports negative indices for sequences. I've put the answer below, but if you want to quickly test your own knowledge, ask yourself which of these support negative indices: 'abcde'[-2] # builtin string class, bracket syntax 'abcde'.__getitem__(-2)# builtin class, magic method collections.deque('abcde')[-2] # extension class, bracket syntax collections.deque('abcde').__getitem__[-2] # extension class, magic method class S(str): pass class T(str): def __getitem__(self, i): print(i) return 'd' class U(str): def __getitem__(self, i): print(i) return 'd' def __len__(self): return 5 class V(str): 'str subclass overriding key methods' def __getitem__(self, i): print(i) return 'd' def __len__(self): return 5 def __iter__(self): return iter('abcde') def __contains__(self, val): return val in 'abcde' class W: 'object subclass registered as Sequence' def __init__(self, data): self.data = data def __getitem__(self, i): print(i) return 'd' def __len__(self): return 5 def __iter__(self): return iter('abcde') def __contains__(self, val): return val in 'abcde' collections.Sequence.register(V) class X(collections.Sequence): 'Subclass the Sequence abstract base class' def __init__(self, data): self.data = data def __getitem__(self, i): print(i) return 'd' def __len__(self): return 5 def __iter__(self): return iter('abcde') def __contains__(self, val): return val in 'abcde' Essentially, the example raise these questions: * Are negative indices tied to the grammar (i.e. binary subscription)? * Does it matter if you call a magic method instead of using brackets? * Are they tied to particular concrete classes (str, list, tuple, deque, dict)? * If so, how does subclassing affect index handling? * What parts of user defined classes affect handling of indices? * Are they part of the abstract layer (PyObject_GetItem)? * Are they tied to the Sequence ABC? * How are mapping lookups differentiated (d[-2] where d is a Mapping)? - Answers below -- | | | | | | | | | | | | | | | | The first five examples support negative indices. The builtin sequence types: str, deque, list and tuple, all have negative index support built in to their concrete implementations (such as str.__getitem__) and that behavior persists for subclassers as long as they don't override __getitem__. The parse of a['x'] matches the subscription rule in Grammar/ Grammar. That compiles the BINARY_SUBSCR opcode which pops off the evaluated expressions for a and x and calls the abstract layer, PyObject_GetItem() which routes most calls to the concrete implementation (i.e. myobj.__getitem__). The exception to concrete dispatch is a fast path for builtin classes or their subclasses that 1) are recognized as sequences (i.e. not a dictionary and have not overridden __getitem__) 2) where x is an index (i.e. not a float) If so, it is passed to an intermediate abstract layer, PySequence_SetItem() which will apply negative index handling iff the sequence defines a __len__ method. In other words, the handling of negative indices is always up to the concrete class. It is not part of the grammar, or the definition of subscriptions, or the dispatch sequence. The docs guarantee that Python's builtin sequences implement support for negative indices ( http://docs.python.org/dev/reference/expressions.html#subscriptions ) and they all do so through their individual __getitem__ implementations. Builtin Python sequences also have a fast path that make negative index handling automatic, but this is just an invisible optimization and can be bypassed by calling myobj.__getitem__ directly. Note on slicing: slices are handled the same way (at least in 3.x), so it is the responsibility of concrete classes to add support if they choose to do so. Some, like lists tuples and string do support slicing and some objects like deque do not. Interestingly, the grammar has rules for slicing, but that is implemented as making a slice instance as the argument to the lookup. The actual lookup work is dispatched to the concrete class and there is no fast path along the way. Hope you all found this to be informative, Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: weighted mean; weighted standard error of the mean (sem)
The best place to ask about numpy related stuff is the numpy mailing list at: http://mail.scipy.org/mailman/listinfo/numpy-discussion This is also the best place to present a patch if you have code to contribute. In my experience the numpy devs are always happy to have new contributors, but be sure to discuss the problem first, as the folk over there might be able to provide a solution which doesn't require a new patch. Thanks, Tim, Ooops -- the sem() I mentioned is sciypy.stats.sem, not in numpy... Does your advice hold? Thanks, c -- http://mail.python.org/mailman/listinfo/python-list
Re: weighted mean; weighted standard error of the mean (sem)
On 10 September 2010 11:43, C Barrington-Leigh cpblpub...@gmail.com wrote: The best place to ask about numpy related stuff is the numpy mailing list at: http://mail.scipy.org/mailman/listinfo/numpy-discussion This is also the best place to present a patch if you have code to contribute. In my experience the numpy devs are always happy to have new contributors, but be sure to discuss the problem first, as the folk over there might be able to provide a solution which doesn't require a new patch. Thanks, Tim, Ooops -- the sem() I mentioned is sciypy.stats.sem, not in numpy... Does your advice hold? Thanks, For discussion out that function you probably want the scipy-user mailing list. For completeness, here's the full list of related mailing lists: http://www.scipy.org/Mailing_Lists Cheers, Tim c -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing the name of a variable
Albert Hopkins mar...@letterboxes.org writes: On Thu, 2010-09-09 at 12:43 -0700, Stephen Boulet wrote: Does an arbitrary variable carry an attribute describing the text in its name? Variables are not objects and so they have no attributes. Another way of thinking about is that there are no variables, only bindings between references and objects. The bindings are not directly accessible and have no attributes. Any object may have zero, one, or many references to it at any given time. Those references might be names, or something else (such as an index in a container). Python does nothing to make the references accessible to the object. If you want to keep track of such associations, you need to employ some mechanism to do so explicitly. You can't really de-reference the object being referenced as it can potentially contain multiple references Including the case where an object has no explicit references beyond the current expression. But this cries the question: why do you want to do this? And usually that question is asked when someone thinks that a: you shouldn't need to do this and b: whatever the desired effect there is probably a better way of accomplishing it. To anticipate a common case: if you feel you need to maintain a mapping between names and objects, Python's built-in mapping type is ‘dict’; use that. -- \ “If you do not trust the source do not use this program.” | `\—Microsoft Vista security dialogue | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: How Python works: What do you know about support for negative indices?
Raymond Hettinger pyt...@rcn.com writes: It doesn't seem to be common knowledge when and how a[x] gets translated to a[x+len(x)]. So, here's a short info post on how Python supports negative indices for sequences. Thanks for this. Could you post your messages using a channel that doesn't arbitrarily split your paragraphs into long-short-long-short lines? It makes paragraphs burdensome to read, and I skipped most of the message because of that. I encourage anyone whose messages are munged like that to seek correction from their mail service provider, and switch to a different one until it's fixed. -- \ “Oh, I realize it's a penny here and a penny there, but look at | `\ me: I've worked myself up from nothing to a state of extreme | _o__) poverty.” —Groucho Marx | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: reading multiple files
Thanks for your response. I was going by this thread, http://mail.python.org/pipermail/tutor/2009-January/066101.html makes you wonder even if its possible. I will try your first solution by doing mkfifo on the files. On Thu, Sep 9, 2010 at 9:19 PM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Mag Gam magaw...@gmail.com writes: I have 3 files which are constantly being updated therefore I use tail -f /var/log/file1, tail -f /var/log/file2, and tail -f /var/log/file3 For 1 file I am able to manage by tail -f /var/log/file1 | python prog.py prog.py looks like this: f=sys.stdin for line in f: print line But how can I get data from /var/log/file2 and /var/log/file3 ? Use shell tricks, e.g., with bash: yourpythonprog (tail -f .../file1) (tail -f .../file2) (...) and let your prog open its three parameters like regular files (they are fifos actually). If your shell doesn't support (...), create the fifos and redirect tail output before launching your prog. If you want purer python, launch the three tail -f with subprocess, and use the select module to get input (you didn't explain the logic you will follow to track three files---you may not need select if you expect one line from each file before waiting for the next line of any). I prefer a native python way instead of doing tail -f Emulating tail will require a lot of stat/seeks, and finding lines will require an additional level of complexity. Also, tail -f has a cost [*]. The only way to avoid it is to use inotify, which seems to have a python interface, available at http://pyinotify.sourceforge.net/ (I've never used it). Again, emulating tail -f with inotify is significant work. -- Alain. [*] Paul Rubin is one of the authors, I think he reads this group. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing the name of a variable
Stephen Boulet wrote: Does an arbitrary variable carry an attribute describing the text in its name? I'm looking for something along the lines of: x = 10 print x.name 'x' Perhaps the x.__getattribute__ method? Thanks. Hmm. Recent scholarship suggests that the Iliad and the Odyssey may not have been written by Homer, but by someone else with the same name. Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: How Python works: What do you know about support for negativeindices?
Ben Finney ben+pyt...@benfinney.id.au wrote in message news:874ody9w3v@benfinney.id.au... Raymond Hettinger pyt...@rcn.com writes: It doesn't seem to be common knowledge when and how a[x] gets translated to a[x+len(x)]. So, here's a short info post on how Python supports negative indices for sequences. Thanks for this. Could you post your messages using a channel that doesn't arbitrarily split your paragraphs into long-short-long-short lines? It makes paragraphs burdensome to read, and I skipped most of the message because of that. I encourage anyone whose messages are munged like that to seek correction from their mail service provider, and switch to a different one until it's fixed. -- \ “Oh, I realize it's a penny here and a penny there, but look at | `\ me: I've worked myself up from nothing to a state of extreme | _o__) poverty.” —Groucho Marx | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list It came across fine for me (on much maligned Outlook Express, no less). -Mark -- http://mail.python.org/mailman/listinfo/python-list
[issue9810] bzip2 build sometimes fails (VS8.0)
New submission from Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: bzip2 project sometimes fails to build pyd file. This is because (snip) nmake /nologo /f makefile.msc lib (snip) nmake /nologo /f makefile.msc clean is run by bzip2.vcproj, but lib command won't create bzip2.exe nor bzip2recover.exe, wheres clean will try to delete these files without checking their existence. Technically it is easy to fix this. (Replace del ... with if exists ... del .in bzip2-1.0.5/makefile.msc) But is it allowed to modify external project files? Thank you. -- components: Build messages: 115930 nosy: ocean-city priority: normal severity: normal status: open title: bzip2 build sometimes fails (VS8.0) versions: Python 2.7, Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9810 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9609] make cProfile multi-stack aware
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9609 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9622] Allow to set profile/trace function globally
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9622 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9116] test_capi.test_no_FatalError_infinite_loop crash on Windows
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Here is the patch. On VS8.0 or above, * Avoid DebugBreak() call by IsDebuggerPresent(). * Tell abort() not to print message to console or window. -- keywords: +patch Added file: http://bugs.python.org/file18809/py3k_fix_test_capi_crash.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9116 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9733] Can't iterate over multiprocessing.managers.DictProxy
Ask Solem a...@opera.com added the comment: I expected I could iterate over a DictProxy as I do over a regular dict. DictProxy doesn't support iterkeys(), itervalues(), or iteritems() either. So while iter(d) could do iter(d.keys()) behind the scenes, it would mask the fact that this would not return an *iterator* over the keys, but send a potentially long list of keys back to the client. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9733 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9811] strftime strips '%' from unknown format codes on OS X
New submission from Sverre Johansen sverre.johan...@gmail.com: There seems to be a platform difference in the way stftime handles unknown format codes. In OSX Python removes the percentage sign from the returned string when the format code is unknown. In Linux it leaves it. Look at the following example: This is Python 3.1.2 in Ubuntu: Python 3.1.2 (r312:79147, Apr 15 2010, 15:35:48) [GCC 4.4.3] on linux2 Type help, copyright, credits or license for more information. import datetime datetime.datetime.now().strftime(%q) '%q' And this is Python 3.1.2 on Max OSX: Python 3.1.2 (r312:79147, Sep 9 2010, 11:11:24) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type help, copyright, credits or license for more information. import datetime datetime.datetime.now().strftime(%q) 'q' I've gotten the same result in 2.5, 2.6 and 3.1. FYI, this broke some code that parsed the same string first with strftime, and then used string interpolation (The mac version deleted all percentage signs before '('): datetime.datetime.now().strftime(%Y - %(foobar)s) % {foobar: egg} This does not work in OSX. -- components: Library (Lib) messages: 115933 nosy: sverrejoh priority: normal severity: normal status: open title: strftime strips '%' from unknown format codes on OS X type: behavior versions: Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9811 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9796] Add summary tables for unittest API
Michael Foord mich...@voidspace.org.uk added the comment: This has been on my 'todo list' for a long time. Feel free to get to it before me. Please *don't* include the now deprecated assert* methods in the table. I'd like to move all the deprecated methods to a separate section of the documentation. As Raymond says - just the assert* methods from TestCase will be the biggest value for the unittest docs, so +1 to his comment (and suggestion on grouping and including example). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9796 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9799] Compilation error for branch py3k on AIX 6
Sébastien Sablé sa...@users.sourceforge.net added the comment: OK for me to close it as a compiler bug since there is a workaround. It would be great if we could detect this compiler and deactivate this optimization automatically, but I am too lazy to search the xlc compiler documentation for a way to do that. I suppose that the people who will be confronted to this problem (the 4 of us in the world who compile Python on AIX with xlc) will find this issue and the correct flag to make it work. Also I am using xlc instead of gcc because it provides some better optimization for this architecture. If the computed gotos optimization only works with gcc, then it may be more interesting to use the gcc compiler instead (I will do some benchs). -- status: pending - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9799 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9811] strftime strips '%' from unknown format codes on OS X
Sverre Johansen sverre.johan...@gmail.com added the comment: This is because of differences in GNU and BSD C stdlib; I get the same results using the BSD and GNU versions of `date`. $ date +%q What does Python typically do in cases like this? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9811 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9799] Compilation error for branch py3k on AIX 6
Changes by Antoine Pitrou pit...@free.fr: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9799 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9804] ascii() does not always join surrogate pairs
Antoine Pitrou pit...@free.fr added the comment: New patch with tests. -- Added file: http://bugs.python.org/file18810/backslashsurrogates2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9804 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3125] test_multiprocessing causes test_ctypes to fail
Ask Solem a...@opera.com added the comment: As no one has been able to confirm that this is still an issue, I'm closing it as out of date. The issue can be reopened if necessary. -- resolution: accepted - out of date status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3125 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3111] multiprocessing ppc Debian/ ia64 Ubuntu compilation error
Ask Solem a...@opera.com added the comment: As no one is able to confirm that this is still an issue, I'm closing it. It can be reopened if necessary. -- resolution: - out of date ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3111 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9757] Add context manager protocol to memoryviews
Nick Coghlan ncogh...@gmail.com added the comment: Sounds good - I'd say just commit whenever you're happy with it then. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9757 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9738] Document the encoding of functions bytes arguments of the C API
STINNER Victor victor.stin...@haypocalc.com added the comment: #6543 changed the encoding of the filename argument of PyRun_SimpleFileExFlags() (and all functions based on PyRun_SimpleFileExFlags) and c_filename attribute of the compiler (private) structure in Python 3.1.3: use utf-8 in strict mode instead of filesystem encoding with surrogateescape. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9738 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9713] Py_CompileString fails on non decode-able paths.
STINNER Victor victor.stin...@haypocalc.com added the comment: #6543 changed the encoding of the filename argument of PyRun_SimpleFileExFlags() (and all functions based on PyRun_SimpleFileExFlags) and c_filename attribute of the compiler (private) structure in Python 3.1.3: use utf-8 in strict mode instead of filesystem encoding with surrogateescape. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9713 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8611] Python3 doesn't support locale different than utf8 and an non-ASCII path (POSIX)
STINNER Victor victor.stin...@haypocalc.com added the comment: See also #9713 (Py_CompileString fails on non decode-able paths) and #9738 (Document the encoding of functions bytes arguments of the C API). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8611 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9757] Add context manager protocol to memoryviews
Antoine Pitrou pit...@free.fr added the comment: Committed in r84649. Thanks for the comments! -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9757 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9609] make cProfile multi-stack aware
Changes by Daniel Stutzbach dan...@stutzbachenterprises.com: -- nosy: +stutzbach ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9609 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9808] Implement os.getlogin on Windows
Brian Curtin cur...@acm.org added the comment: After a quick glance the patch looks alright, just cleaned a few things up in issue9808.diff (moved the #include up with others, removed 'is not None' from tests). The test skip decorator could also be moved to the LoginTests class level. Is there any reason the variables could legitimately be different from what getlogin reports? -- assignee: - brian.curtin stage: - patch review Added file: http://bugs.python.org/file18811/issue9808.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9808 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2745] Add support for IsWow64Process
R. David Murray rdmur...@bitdance.com added the comment: See also Issue7860. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2745 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9811] strftime strips '%' from unknown format codes on OS X
R. David Murray rdmur...@bitdance.com added the comment: Python's strftime is a thin wrapper around the system strftime. This means, for example, that a slightly different set of % codes is supported on windows vs linux. So, from Python's point of view this is at *most* a doc bug. That said, I think there have been some rumblings about writing our own strftime, but I don't know if anyone is serious about it. -- assignee: - d...@python components: +Documentation -Library (Lib) nosy: +belopolsky, d...@python, r.david.murray versions: +Python 2.7, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9811 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9805] Documentation on old-style formatting of dicts is overly restrictive
Ken Basye ken.ba...@gmail.com added the comment: I think Eric is correct; it's a dupe. And I was wrong about not otherwise being able to format an empty dictionary - %s % (d,) will always work and is arguably the right thing to do anyway. -- type: behavior - versions: -Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9805 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9812] cPickle segfault with nested dicts in threaded env
New submission from Kenneth Dombrowski kdombrow...@gmail.com: FreeBSD 8.0-RELEASE-p2 Python 2.5.5 amd64 attached diff provides a test for cpickle which reproduces a segfault when pickling 15 nested dicts in a threaded environment cpickle.patch attached to http://bugs.python.org/issue3640 applys cleanly to the 2.5 source and fixes this issue i understand 2.5 is no longer maintained except for security fixes, i leave it up to the maintainers to decide if this segfault warrants a security patch thank you -- components: Extension Modules files: test_cpickle.nested_dicts_in_threaded_env.diff keywords: patch messages: 115950 nosy: kdombrowski priority: normal severity: normal status: open title: cPickle segfault with nested dicts in threaded env type: crash versions: Python 2.5 Added file: http://bugs.python.org/file18812/test_cpickle.nested_dicts_in_threaded_env.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9812 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9809] Wrong Registery Entries on win64
Brian Curtin cur...@acm.org added the comment: Wow6432Node registry entries are for applications running WOW - aka 32-bit applications on a 64-bit platform. The 64-bit Python installer is placing its entries in the appropriate location. See the winreg documentation for information that might help fixing this setuptools bug, in particular this section: http://docs.python.org/py3k/library/winreg#bit-specific -- components: +Windows nosy: +brian.curtin resolution: - invalid stage: - committed/rejected type: - behavior versions: -Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9809 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9805] Documentation on old-style formatting of dicts is overly restrictive
Changes by R. David Murray rdmur...@bitdance.com: -- resolution: - duplicate stage: needs patch - committed/rejected status: open - closed superseder: - %-formatting and dicts ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9805 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9811] strftime strips '%' from unknown format codes on OS X
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: I think there have been some rumblings about writing our own strftime Yes, see issue #3173. Another related issue is #9650 which discusses how to properly document strftime codes. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9811 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9808] Implement os.getlogin on Windows
Jon Anglin jang...@fortresgrand.com added the comment: I can't answer that for the 'LOGNAME' environment variable on non-Windows systems, I was just keying off of what the docs claimed. As for Windows, I just came across this article http://support.microsoft.com/kb/273633 that shows we can not rely on this in the test. I only put those environment variables in the test because I thought this test was a little weak (what else can we do?) user_name = os.getlogin() self.assertNotEqual(0, len(user_name)) Even though %USERNAME% == os.getlogin() MOST of the time. It should be removed from the test. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9808 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9609] make cProfile multi-stack aware
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Here is a new patch. When 'allthreads' is specified to cProfile.Profile.enable(), profling is enabled on all threads. The testsuite tests to see that all threads do indeed register, it does not attempt to validate the timings. It turns it on for all threads (in all interpreter states). Maybe this is overdoing it. Interpreter states is something new to me, a py3k feature? Now, the problem with this approach is that it only works with threads already in existence when called. The global appcoach that we used to solve a similar problem in Stackless Python, however, will invoke the tracing/profiling functionality for all tasklets, even if they were new. The same would be useful for threads in regular python, especially in long running server applications. However, this patch stands on its own. This particular shortcoming could be fixed later. -- Added file: http://bugs.python.org/file18813/cprofile2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9609 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9609] make cProfile multi-stack aware
Changes by Daniel Stutzbach dan...@stutzbachenterprises.com: -- nosy: +georg.brandl stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9609 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9808] Implement os.getlogin on Windows
Jon Anglin jang...@fortresgrand.com added the comment: Here is an updated patch with the updated test. This test does not use either the LOGNAME or USERNAME environment variables. -- Added file: http://bugs.python.org/file18814/issue9808.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9808 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9812] cPickle segfault with nested dicts in threaded env
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Python has several known crashers, they are not considered as security holes. It seems that FreeBSD has a small stack size for threads (64k); did you try to increase it with thread.stack_size(10**6)? -- nosy: +amaury.forgeotdarc, loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9812 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9410] Add Unladen Swallow's optimizations to Python 3's pickle.
Antoine Pitrou pit...@free.fr added the comment: The patch was finally committed in r84653. Thanks to everyone who participated in this. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9410 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9807] deriving configuration information for different builds with the same prefix
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: IMO there should not be any need to fetch information from config.h or the Makefile. What about a sys.build_config dictionary containing all the necessary data? -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9807 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7300] Unicode arguments in str.format()
Changes by Florent Xicluna florent.xicl...@gmail.com: -- nosy: +flox ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7300 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8556] Confusing string formatting examples
Changes by Florent Xicluna florent.xicl...@gmail.com: -- nosy: +flox ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8556 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9804] ascii() does not always join surrogate pairs
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: I agree with the feature and the patch, with two minor nits: - Py_UCS4 should be used in place of unsigned long - *p = 0xD800 is the most selective test and should be the first -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9804 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8913] Document that datetime.__format__ is datetime.strftime
Changes by Florent Xicluna florent.xicl...@gmail.com: -- nosy: +flox ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8913 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com