The PTVS gang (from microsoft) would like to hear from python-list users!
? Hi - we're a few engineers (not marketers!) that work on Python Tools for Visual Studio (http://pytools.codeplex.com). It's a free OSS plug-in that turns VS into a decent Python IDE. It has some nice features like mixed-mode Python/C++ debugging, debugging on Linux from Visual Studio and IPython integration. Some of our users have been encouraging us to enhance PTVS and add support for some Data Science focused features scenarios. As such we'd *love* to get your input regarding your current stack, workflow and pain points before taking the next steps. It does not matter if you use Windows, Visual Studio, love/hate Microsoft - we'd just love to understand your environment a bit better especially if you use tools like Excel, R, Matlab, Mathematica, numpy, scipy, Pandas, ... As a thank you, 50 people will be randomly selected to receive a $5 Starbucks Coffee card! Here is a link to the survey which should take about 2 minutes to complete. https://www.surveymonkey.com/s/VSForDataScience If you know others that might be interested in taking this survey, *please* forward it to them - much appreciated. Thanks for your participation! -- https://mail.python.org/mailman/listinfo/python-list
Executing pl/sql script File in python without sqlclient
Is there a way to execute pl/sql Script files through Python without sqlclient. i have checked cx_oracle and i guess it requires oracle client, so is there a way to execute without oracle client. -- https://mail.python.org/mailman/listinfo/python-list
soap library for python-3.x
Hi, We have to start a project of developing a soap server in python-3.x for which I am looking for a soap server side library. Please let me know what are the options available and which of these libraries are actively maintained. Thanks. Regards, Deepika Nagpal ::Disclaimer:: The contents of this email and any attachment(s) are confidential and intended for the named recipient(s) only. It shall not attach any liability on C-DOT. Any views or opinions presented in this email are solely those of the author and may not necessarily reflect the opinions of C-DOT. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. -- https://mail.python.org/mailman/listinfo/python-list
RE: Executing pl/sql script File in python without sqlclient
Is there a way to execute pl/sql Script files through Python without sqlclient. https://code.google.com/p/pypyodbc/ might work for you... i have checked cx_oracle and i guess it requires oracle client, so is there a way to execute without oracle client. Right, as the name implies it uses the oci interface and hence needs that library available. jlc -- https://mail.python.org/mailman/listinfo/python-list
how to split this kind of text into sections
I have a long text, which should be splitted into some sections, where all sections have a pattern like following with different KEY. And the /n/r can not be used to split I don't know whether this can be done easily, for example by using RE module [demo text starts] a line we do not need I am section axax I am section bbb, we can find that the first 2 lines of this section all startswith 'I am section' .(and here goes many other text)... let's continue to let's continue, yeah .(and here goes many other text)... I am using python I am using perl .(and here goes many other text)... [demo text ends] the above text should be splitted as a LIST with 3 items, and I also need to know the KEY for LIST is ['I am section', 'let's continue', 'I am using']: lst=[ '''I am section axax I am section bbb, we can find that the first 2 lines of this section all startswith 'I am section' .(and here goes many other text)...''', '''let's continue to let's continue, yeah .(and here goes many other text)...''', '''I am using python I am using perl .(and here goes many other text)...''' ] I hope I have state myself clear. Regards -- https://mail.python.org/mailman/listinfo/python-list
Re: how to split this kind of text into sections
In article mailman.9492.1398431281.18130.python-l...@python.org, oyster lepto.pyt...@gmail.com wrote: I have a long text, which should be splitted into some sections, where all sections have a pattern like following with different KEY. And the /n/r can not be used to split I don't know whether this can be done easily, for example by using RE module [demo text starts] a line we do not need I am section axax I am section bbb, we can find that the first 2 lines of this section all startswith 'I am section' .(and here goes many other text)... let's continue to let's continue, yeah .(and here goes many other text)... I am using python I am using perl .(and here goes many other text)... [demo text ends] This kind of looks like a standard INI file. Check out https://docs.python.org/2/library/configparser.html, it may do what you need. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to split this kind of text into sections
On Fri, Apr 25, 2014 at 11:07 PM, oyster lepto.pyt...@gmail.com wrote: the above text should be splitted as a LIST with 3 items, and I also need to know the KEY for LIST is ['I am section', 'let's continue', 'I am using']: It's not perfectly clear, but I think I have some idea of what you're trying to do. Let me restate what I think you want, and you can tell be if it's correct. You have a file which consists of a number of lines. Some of those lines begin with the string I am section, others begin let's continue, and others begin I am using. You want to collect those three sets of lines; inside each collection, every line will have that same prefix. Is that correct? If so, we can certainly help you with that. If not, please clarify. :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
MacOS 10.9.2: threading error using python.org 2.7.6 distribution
I've run into a threading error in some code when I run it on MacOS that works flawlessly on a *BSD system running the same version of python. I'm running the python 2.7.6 for MacOS distribution from python.org's downloads page. I have tried to reproduce the error with a simple example, but so far haven't been able to find the element or my code that triggers the error. I'm hoping someone can suggest some things to try and/or look at. Googling for pyton and the error returns exactly two pages, neither of which are any help. When I run it through the debugger, I'm getting the following from inside threading.start(). python fails to provide a stack trace when I step into _start_new_thread(), which is a pointer to thread.start_new_thread(). It looks like threading.__bootstrap_inner() may be throwing an exception which thread.start_new_thread() is unable to handle, and for some reason the stack is missing so I get no stack trace explaining the error. It looks like thread.start_new_thread() is in the binary object, so I can't actually step into it and find where the error is occurring. /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py(745)start() - _start_new_thread(self.__bootstrap, ()) (Pdb) s /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py(750)start() - self.__started.wait() (Pdb) Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from Warning: No stack to get attribute from My test code (which works) follows the exact same structure as the failing code, making the same calls to the threading module's objects' methods: import threading class MyThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): print MyThread runs and exits. def main(): try: t = MyThread() t.start() except Exception as e: print Failed with {!r}.format(e) if __name__ == '__main__': main() The actual thread object that's failing looks like this: class RTF2TXT(threading.Thread): Takes a directory path and a Queue as arguments. The directory should be a collection of RTF files, which will be read one-by-one, converted to text, and each output line will be appended in order to the Queue. def __init__(self, path, queue): threading.Thread.__init__(self) self.path = path self.queue = queue def run(self): logger = logging.getLogger('RTF2TXT') if not os.path.isdir(self.path): raise TypeError, supplied path must be a directory for f in sorted(os.listdir(self.path)): ff = os.path.join(self.path, f) args = [ UNRTF_BIN, '-P', '.', '-t', 'unrtf.text', ff ] logger.debug(Processing file {} with args {!r}.format(f, args)) p1 = subprocess.Popen( args, stdout=subprocess.PIPE, universal_newlines=True) output = p1.communicate()[0] try: output = output.decode('utf-8', 'ignore') except Exception as err: logger.error(Failed to decode output: {}.format(err)) logger.error(Output was: {!r}.format(output)) for line in output.split(\n): line = line.strip() self.queue.put(line) self.queue.put(EOF) Note: I only run one instance of this thread. The Queue object is used to pass work off to another thread for later processing. If I insert that object into the test code and run it instead of MyThread(), I get the error. I can't see anything in there that should cause problems for the threading module though... especially since this runs fine on another system with the same version of python. Any thoughts on what's going on here? -- https://mail.python.org/mailman/listinfo/python-list
Re: soap library for python-3.x
Deepika Nagpal deep...@cdot.in writes: We have to start a project of developing a soap server in python-3.x for which I am looking for a soap server side library. Please let me know what are the options available and which of these libraries are actively maintained. Thanks. You can start with URL:https://wiki.python.org/moin/WebServices. Good hunting! ::Disclaimer:: The contents of this email and any attachment(s) are confidential and intended for the named recipient(s) only. It shall not […] This is nonsense (you deliberately sent this message to a public forum), and obnoxious in its demands. Please ensure your future messages are sent without this boilerplate. -- \ “I used to think that the brain was the most wonderful organ in | `\ my body. Then I realized who was telling me this.” —Emo Philips | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: MacOS 10.9.2: threading error using python.org 2.7.6 distribution
On Fri, Apr 25, 2014 at 11:43 PM, Matthew Pounsett matt.pouns...@gmail.com wrote: If I insert that object into the test code and run it instead of MyThread(), I get the error. I can't see anything in there that should cause problems for the threading module though... especially since this runs fine on another system with the same version of python. Any thoughts on what's going on here? First culprit I'd look at is the mixing of subprocess and threading. It's entirely possible that something goes messy when you fork from a thread. Separately: You're attempting a very messy charset decode there. You attempt to decode as UTF-8, errors ignored, and if that fails, you log an error... and continue on with the original bytes. You're risking shooting yourself in the foot there; I would recommend you have an explicit fall-back (maybe re-decode as Latin-1??), so the next code is guaranteed to be working with Unicode. Currently, it might get a unicode or a str. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
len() of unsized object - ks test
Hello all, I am trying to perform a Kolmogorov-Smirnov test in Python but I'm having a few difficulties. # My files are netCDF so I import them as follows: control=netCDF4.Dataset('/data/cr1/jmitchel/Q0/swh/controlperiod/south_west/swhcontrol_swest_concatannavg_1D.nc','r') # The string is simply a 1D array # Then performing the ks test: kstest(control,'norm') # I then get the following error: File stdin, line 1, in module File /usr/local/sci/lib/python2.7/site-packages/scipy/stats/stats.py, line 3413, in kstest N = len(vals) TypeError: len() of unsized object Any ideas on why this isn't working would be great. Thanks, Jamie -- https://mail.python.org/mailman/listinfo/python-list
Re: how to split this kind of text into sections
On 2014-04-25 23:31, Chris Angelico wrote: On Fri, Apr 25, 2014 at 11:07 PM, oyster lepto.pyt...@gmail.com wrote: the above text should be splitted as a LIST with 3 items, and I also need to know the KEY for LIST is ['I am section', 'let's continue', 'I am using']: It's not perfectly clear, but I think I have some idea of what you're trying to do. Let me restate what I think you want, and you can tell be if it's correct. You have a file which consists of a number of lines. Some of those lines begin with the string I am section, others begin let's continue, and others begin I am using. You want to collect those three sets of lines; inside each collection, every line will have that same prefix. Is that correct? If so, we can certainly help you with that. If not, please clarify. :) My reading of it (and it took me several tries) was that two subsequent lines would begin with the same N words. Something like the following regexp: ^(\w.{8,}).*\n\1.* as the delimiter (choosing 6 arbitrarily as an indication of a minimum match length to). A naive (and untested) bit of code might look something like MIN_LEN = 6 def overlap(s1, s2): chars = [] for c1, c2 in zip(s1,s2): if c1 != c2: break chars.append(c1) return ''.join(chars) prevline = output_number = 1 output = defaultdict(list) key = None with open(input.txt) as f: for line in f: if len(line) = MIN_LEN and prevline[:MIN_LEN] == line[:MIN_LEN]: key = overlap(prevline, line) output[key].append(line) prevline = line There are some edge-cases such as when multiple sections are delimited by the same overlap, but this should build up a defaultdict keyed by the delimiters with the corresponding lines as the values. -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: len() of unsized object - ks test
On 2014-04-25 15:07, Jamie Mitchell wrote: Hello all, I am trying to perform a Kolmogorov-Smirnov test in Python but I'm having a few difficulties. # My files are netCDF so I import them as follows: control=netCDF4.Dataset('/data/cr1/jmitchel/Q0/swh/controlperiod/south_west/swhcontrol_swest_concatannavg_1D.nc','r') A brief look at the documentation online says that 'control' is an instance that _describes_ the dataset: A netCDF Dataset is a collection of dimensions, groups, variables and attributes. Together they describe the meaning of data and relations among data fields stored in a netCDF file. So I don't think that it's the data itself. # The string is simply a 1D array # Then performing the ks test: kstest(control,'norm') # I then get the following error: File stdin, line 1, in module File /usr/local/sci/lib/python2.7/site-packages/scipy/stats/stats.py, line 3413, in kstest N = len(vals) TypeError: len() of unsized object Any ideas on why this isn't working would be great. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to split this kind of text into sections
oyster writes: I have a long text, which should be splitted into some sections, where all sections have a pattern like following with different KEY. itertools.groupby, if you know how to extract a key from a given line. And the /n/r can not be used to split Yet you seem to want to have each line as a unit? You could group lines straight from some file object using itertools.groupby and then ''.join each group. (It's \n and \r, and \r\n when they are both there, but you can just let Python read the lines.) -- https://mail.python.org/mailman/listinfo/python-list
Re: how to split this kind of text into sections
On Fri, 25 Apr 2014 21:07:53 +0800, oyster wrote: I have a long text, which should be splitted into some sections, where all sections have a pattern like following with different KEY. And the /n/r can not be used to split I don't know whether this can be done easily, for example by using RE module [... snip example ...] I hope I have state myself clear. Clear as mud. I'm afraid I have no idea what you mean. Can you explain the decision that you make to decide whether a line is included, or excluded, or part of a section? [demo text starts] a line we do not need How do we decide whether the line is ignored? Is it the literal text a line we do not need? for line in lines: if line == a line we do not need\n: # ignore this line continue I am section axax I am section bbb, we can find that the first 2 lines of this section all startswith 'I am section' Again, is this the *literal* text that you expect? .(and here goes many other text)... let's continue to let's continue, yeah .(and here goes many other text)... I am using python I am using perl .(and here goes many other text)... [demo text ends] the above text should be splitted as a LIST with 3 items, and I also need to know the KEY for LIST is ['I am section', 'let's continue', 'I am using']: How do you decide that they are the keys? lst=[ '''I am section axax I am section bbb, we can find that the first 2 lines of this section all startswith 'I am section' .(and here goes many other text)...''', '''let's continue to let's continue, yeah .(and here goes many other text)...''', '''I am using python I am using perl .(and here goes many other text)...''' ] Perhaps it would be better if you show a more realistic example. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: len() of unsized object - ks test
On Fri, 25 Apr 2014 07:07:54 -0700, Jamie Mitchell wrote: Hello all, I am trying to perform a Kolmogorov-Smirnov test in Python but I'm having a few difficulties. # My files are netCDF so I import them as follows: control=netCDF4.Dataset('/data/cr1/jmitchel/Q0/swh/controlperiod/ south_west/swhcontrol_swest_concatannavg_1D.nc','r') # The string is simply a 1D array # Then performing the ks test: kstest(control,'norm') # I then get the following error: File stdin, line 1, in module File /usr/local/sci/lib/python2.7/site-packages/scipy/stats/stats.py, line 3413, in kstest N = len(vals) TypeError: len() of unsized object Any ideas on why this isn't working would be great. My guess is that you are calling len() on something that doesn't have a length :-) But seriously, first of, what does vals contain? Look at the documentation for the kstest function. Does it have a parameter called vals? If so, what argument are you providing for that? Make sure that it is what you expect it is. What does the documentation for netCDF4.Dataset say? Perhaps you have to *read* from the file, not just open it? control = netCDF4.Dataset(filename,'r') data = control.read() # Perhaps this? kstest(data,'norm') But I'm just guessing. You'll need to read the documentation to see what arguments are expected, then you'll need to check what arguments you're actually providing. Doing: print(repr(control)) may help. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: how to split this kind of text into sections
On Fri, 25 Apr 2014 09:18:22 -0400, Roy Smith wrote: In article mailman.9492.1398431281.18130.python-l...@python.org, oyster lepto.pyt...@gmail.com wrote: [demo text starts] a line we do not need I am section axax I am section bbb, we can find that the first 2 lines of this section all startswith 'I am section' .(and here goes many other text)... let's continue to let's continue, yeah .(and here goes many other text)... I am using python I am using perl .(and here goes many other text)... [demo text ends] This kind of looks like a standard INI file. I don't think so. INI files are a collection of KEY=VALUE or KEY:VALUE pairs, and the example above shows nothing like that. The only thing which is even vaguely ini-like is the header [demo text starts], and my reading of that is that it is *not* part of the file, but just an indication that the OP is giving a demo. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: len() of unsized object - ks test
On Friday, April 25, 2014 3:07:54 PM UTC+1, Jamie Mitchell wrote: Hello all, I am trying to perform a Kolmogorov-Smirnov test in Python but I'm having a few difficulties. # My files are netCDF so I import them as follows: control=netCDF4.Dataset('/data/cr1/jmitchel/Q0/swh/controlperiod/south_west/swhcontrol_swest_concatannavg_1D.nc','r') # The string is simply a 1D array # Then performing the ks test: kstest(control,'norm') # I then get the following error: File stdin, line 1, in module File /usr/local/sci/lib/python2.7/site-packages/scipy/stats/stats.py, line 3413, in kstest N = len(vals) TypeError: len() of unsized object Any ideas on why this isn't working would be great. Thanks, Jamie Thanks for your help. Steven your right I wasn't reading in the file on netCDF4.Dataset, I was just opening it. I have rectified it now - a silly mistake! Thanks again, Jamie -- https://mail.python.org/mailman/listinfo/python-list
possible bug in re expression?
Whilst translating some javascript code I find that this A=re.compile('.{1,+3}').findall(p) doesn't give any error, but doesn't manage to find the strings in p that I want len(A)==0, the correct translation should have been A=re.compile('.{1,3}').findall(p) which works fine. should re.compile('.{1,+3}') raise an error? It doesn't on python 2.7 or 3.3. -- Robin Becker -- https://mail.python.org/mailman/listinfo/python-list
Re: possible bug in re expression?
On Sat, Apr 26, 2014 at 2:30 AM, Robin Becker ro...@reportlab.com wrote: Whilst translating some javascript code I find that this A=re.compile('.{1,+3}').findall(p) doesn't give any error, but doesn't manage to find the strings in p that I want len(A)==0, the correct translation should have been A=re.compile('.{1,3}').findall(p) which works fine. should re.compile('.{1,+3}') raise an error? It doesn't on python 2.7 or 3.3. I would say the surprising part is that your js code doesn't mind an extraneous character in the regex. In a brace like that, negative numbers have no meaning, so I would expect the definition of the regex to look for digits, not anything that can be parsed as a number. So you've uncovered a bug in your code that just happened to work in js. Should it raise an error? Good question. Quite possibly it should, unless that has some other meaning that I'm not familiar with. Do you know how it's being interpreted? I'm not entirely sure what you mean by len(A)==0, as == isn't an operator in Python or JS. Best way to continue, I think, would be to use regular expression matching (rather than findall'ing) and something other than dot, and tabulate input strings, expected result (match or no match), what JS does, and what Python does. For instance: Regex: ^a{1,3}$ : Not expected, not Python a: Expected, Python aa: Expected, Python aaa: Expected, Python : Not expected, not Python Just what we'd expect. Now try the same thing with the plus in there. I'm finding that none of the above strings yields a match. Maybe there's something else being matched? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Moving to an OOP model from an classically imperitive one
Héllo, I have no definitive answer regarding the OOP/functional mismatch. 2014-04-24 18:53 GMT+02:00 tim.thel...@gmail.com: A reasonable compromise might be to keep the *data* assocated with a SubuserProgram in a class, maybe together with a few methods that are tightly coupled to it, but have the major pieces of functionality such as install() implemented by separate functions that operate *on* the class, rather than being inside it. I think this is sound advice. I'm still not sure what I'll come up with. One of the other reasons why an OOP model might be right for me is that of caching. I currently load a lot of attributes regarding programs from disk, and I do so multiple times, I could either pass those attributes around, OR, using a class, I could store those attributes in the object after loading them just once. You could also use a generator with a somekind of memoization/cache. I have no experience with OOP except in the domain of GUIs (where it seems inescapable, all major toolkits use OOP) I have some experience in GUIs with Python in a proprietary framework. I have a bias for OOP and Python in particular. I started exploring Scheme through Guile and other languages more or less. I am asking myself the question what is the interest of functional programming or so called. Scheme doesn't enforce functional code or immutability. It's actually more open somewhat because of the macro system among other things. Outside any performance considerations or implementations details like GIL. Scheme and (all?) *LISP don't use the infix notation*. probably because you can work around it but IMO not fully. The infix notations allows to write things like: people.move_to(paris). It's easy to read, as «Subject Verb Complement»... Class based OOP is prefered because of that, in a lot of situations. IMO, if OOP won, it's because of readability, and in particular Class based OOP. JavaScript OOP is useless in asynchronous context, see http://repl.it/Rrf/2. Maybe you can work around this feature with JavaScript descriptors easly, I did not try that. so I'm not yet sure how this will turn out. I skimmed through the code, but it's very superficial reading, like I installed pycharm to ask for help...: - CamelCase is usually for class names. That said, sometime variable holding classes are called my_object_class or my_object_factory - I think permissions.py would be easier to read with a class... or a function that initialize the dictionary as intented and just use dict methods onward. - To I read code, I have a systematic method I call gunshot/destructive/production rules/function inlining/develop (as the dual of factorize). I started with subuser.py, I got: http://dpaste.com/1797075/ def getSubuserCommands(): Returns a list of commands that may be called by the user. def isPathToSubuserCommand(path): directory, executableName = os.path.split(path) return executableName.startswith(subuser-) externalCommandPaths = queryPATH(isPathToSubuserCommand) externalCommands = [] subuserPrefixLength=len(subuser-) for externalCommandPath in externalCommandPaths: commandDir, executableName = os.path.split(externalCommandPath) commandName = executableName[subuserPrefixLength:] externalCommands.append(commandName) external_subuser_commands = list(set(externalCommands)) return list(set( os.listdir(paths.getSubuserCommandsDir())).difference(nonCommands)) + external_subuser_commands It's kind of easier to read. Gremlin is a DSL that allows to navigate a graph. That's exactly what happens here (and all the timehttp://en.wikipedia.org/wiki/Transderivational_search long nowhttp://en.wikipedia.org/wiki/Kundalini_syndrome#The_Physio-Kundalini_Syndrome_Index ).wrapped_ http://en.wikipedia.org/wiki/Net.artin(tesseracthttp://en.wikipedia.org/wiki/Tesseract_%28disambiguation%29). I'd like to write the above as: subuser.commands = (subuser.path.directories + subuser.user.path.directories).filter(is_command).distinct().memoize() I think it's possible in Ruby. I'm quite interested by the subject. Elm language (see reactconfhttp://reactconf.com/) and your graphical IDEhttp://thobbs.cz/works/2013/graphical-elm/Intro.htmlis very interesting, do you know about Domain Specific Modeling Forum http://www.dsmforum.org/? I started to put some thinking grouped together. Also I started proto-py to gather code ideas, but it's still offline. My plan is to mimick subuser to see, what happens. Can be of interest Scala @ Systems @ Twitterhttps://news.ycombinator.com/item?id=7618969 Nice project by the way, with a better see also section that I could do :) -- https://mail.python.org/mailman/listinfo/python-list
Re: retrieve source code from code object as returned by compile()
in python3, I do inspect.getsource(object) [dochttps://docs.python.org/3/library/inspect.html#inspect.getsource], I don't know the limitations. On Python 2, there is meta https://pypi.python.org/pypi/meta. My interest is different, I use to retrieve the definition of function to submit it to a database, instead of stored procedures, but I have the source of the code. It can also be used to retrieve the ast. 2014-04-25 4:50 GMT+02:00 Justin Ezequiel justin.ezequ...@gmail.com: On Thursday, April 24, 2014 1:53:38 PM UTC+8, Gregory Ewing wrote: Alternatively you could create a .pyc file out of the code object and then use Easy Python Decompiler on that. The following snippet of code should do that: (Taken from: http://stackoverflow.com/questions/8627835/generate-pyc-from-python-ast) Woohoo! Success! Thank you Greg! -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: how to split this kind of text into sections
On 4/25/2014 9:07 AM, oyster wrote: I have a long text, which should be splitted into some sections, where all sections have a pattern like following with different KEY. Computers are worse at reading your mind than humans. If you can write rules that another person could follow, THEN we could help you translate the rules to Python. If you have 1 moderate length file or a few short files, I would edit them by hand to remove ignore lines and put a blank line between sections. A program to do the rest would then be easy. the above text should be splitted as a LIST with 3 items, and I also need to know the KEY for LIST is ['I am section', 'let's continue', 'I am using']: This suggests that the rule for keys is 'first 3 words of a line, with contractions counted as 2 words'. Correct? Another possible rule is 'a member of the following list: ...', as you gave above but presumably expanded. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Proper deletion of selected items during map iteration in for loop
What is the proper way to delete selected items during iteration of a map? What I want to do is: for (k, v) in m.items(): if f(k): # do some processing of v and save result elsewhere del m[k] But this gives (as should be expected): RuntimeError: dictionary changed size during iteration In the past I've accumulated the keys to be deleted in a separate list, but this time there are likely to be a large number of them, so is there some better way? -- Charles Hixson -- https://mail.python.org/mailman/listinfo/python-list
Re: possible bug in re expression?
On 2014-04-25 17:55, Chris Angelico wrote: On Sat, Apr 26, 2014 at 2:30 AM, Robin Becker ro...@reportlab.com wrote: Whilst translating some javascript code I find that this A=re.compile('.{1,+3}').findall(p) doesn't give any error, but doesn't manage to find the strings in p that I want len(A)==0, the correct translation should have been A=re.compile('.{1,3}').findall(p) which works fine. should re.compile('.{1,+3}') raise an error? It doesn't on python 2.7 or 3.3. I would say the surprising part is that your js code doesn't mind an extraneous character in the regex. In a brace like that, negative numbers have no meaning, so I would expect the definition of the regex to look for digits, not anything that can be parsed as a number. So you've uncovered a bug in your code that just happened to work in js. Should it raise an error? Good question. Quite possibly it should, unless that has some other meaning that I'm not familiar with. Do you know how it's being interpreted? I'm not entirely sure what you mean by len(A)==0, as == isn't an operator in Python or JS. Best way to continue, I think, would be to use regular expression matching (rather than findall'ing) and something other than dot, and tabulate input strings, expected result (match or no match), what JS does, and what Python does. For instance: Regex: ^a{1,3}$ : Not expected, not Python a: Expected, Python aa: Expected, Python aaa: Expected, Python : Not expected, not Python Just what we'd expect. Now try the same thing with the plus in there. I'm finding that none of the above strings yields a match. Maybe there's something else being matched? The DEBUG flag helps to show what's happening: r = re.compile('.{1,+3}', flags=re.DEBUG) any None literal 123 literal 49 max_repeat 1 4294967295 literal 44 literal 51 literal 125 When it's parsing the pattern it's doing this: .OK, match any character {Looks like the start of a quantifier 1OK, the minimum count ,OK, the maximum count probably follows +Error; it looks like the '{' was a literal Trying again from the brace: {Literal 1Literal ,Literal +Repeat the previous item one or more times 3Literal }Literal -- https://mail.python.org/mailman/listinfo/python-list
Re: Proper deletion of selected items during map iteration in for loop
On Sat, Apr 26, 2014 at 3:53 AM, Charles Hixson charleshi...@earthlink.net wrote: What is the proper way to delete selected items during iteration of a map? What I want to do is: for (k, v) in m.items(): if f(k): # do some processing of v and save result elsewhere del m[k] But this gives (as should be expected): RuntimeError: dictionary changed size during iteration In the past I've accumulated the keys to be deleted in a separate list, but this time there are likely to be a large number of them, so is there some better way? One easy way is to explicitly coalesce the items() view into a list: for k, v in list(m.items()): That would work, but you effectively duplicate your entire dictionary into a list. More likely, you should simply snapshot the keys: for k in list(m): # Your example code isn't using v, but I # assume the real code does v = m[k] if f(k): # as above del m[k] This and your previous technique of accumulating a delete-me list would be the two standard ways to filter a dictionary with a loop. (I say with a loop because there's a third way to filter a dictionary, and that's with a comprehension. But I don't know of a really clean way to save v elsewhere for the cases where the dict isn't keeping that key.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Proper deletion of selected items during map iteration in for loop
On 2014-04-25 18:53, Charles Hixson wrote: What is the proper way to delete selected items during iteration of a map? What I want to do is: for (k, v) in m.items(): if f(k): # do some processing of v and save result elsewhere del m[k] But this gives (as should be expected): RuntimeError: dictionary changed size during iteration In the past I've accumulated the keys to be deleted in a separate list, but this time there are likely to be a large number of them, so is there some better way? The other way is to build a new dictionary. Actually, there's a third way. Iterate over a snapshot: for (k, v) in list(m.items()): if f(k): # do some processing of v and save result elsewhere del m[k] -- https://mail.python.org/mailman/listinfo/python-list
Re: possible bug in re expression?
On 4/25/2014 12:30 PM, Robin Becker wrote: Whilst translating some javascript code I find that this A=re.compile('.{1,+3}').findall(p) doesn't give any error, but doesn't manage to find the strings in p that I want len(A)==0, the correct translation should have been A=re.compile('.{1,3}').findall(p) which works fine. should re.compile('.{1,+3}') raise an error? It doesn't on python 2.7 or 3.3. And it should not because it is not an error. '+' means 'match 1 or more occurrences of the preceding re' and the preceding re is ','. re.match('a{1,+3}', 'a{1,,,3}').group() 'a{1,,,3}' I suppose that one could argue that '{' alone should be treated as special immediately, and not just when a matching '}' is found, and should disable other special meanings. I wonder what JS does if there is no matching '}'? -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: xlutils 1.7.1 released!
*sigh* subject line fail... On 25/04/2014 19:48, Chris Withers wrote: Hi All, I'm pleased to announce the release of xlutils 1.7.1: http://pypi.python.org/pypi/xlutils/1.7.1 This release has a couple of small changes: - Add support for time cells in when using View classes. - Add support for ``.xlsx`` files when using View classes, at the expense of formatting information being available. Full docs here: http://pythonhosted.org/xlutils/ Details of all things Python and Excel related can be found here: http://www.python-excel.org/ cheers, Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- https://mail.python.org/mailman/listinfo/python-list
Re: Proper deletion of selected items during map iteration in for loop
On 4/25/2014 2:04 PM, Matthew Barnett wrote: On 2014-04-25 18:53, Charles Hixson wrote: What is the proper way to delete selected items during iteration of a map? What I want to do is: for (k, v) in m.items(): if f(k): # do some processing of v and save result elsewhere del m[k] But this gives (as should be expected): RuntimeError: dictionary changed size during iteration In the past I've accumulated the keys to be deleted in a separate list, but this time there are likely to be a large number of them, so is there some better way? The other way is to build a new dictionary. If you expect to delete more than half the keys *and* if there are no other references to the dict, such that you need the particular object mutated, this might be better. Actually, there's a third way. Iterate over a snapshot: for (k, v) in list(m.items()): if f(k): # do some processing of v and save result elsewhere del m[k] Since a pre-snapshot of items or even just keys will be longer than a list of keys to be deleted, I would stick with the latter. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
xlutils 1.7.0 released!
Hi All, I'm pleased to announce the release of xlutils 1.7.1: http://pypi.python.org/pypi/xlutils/1.7.1 This release has a couple of small changes: - Add support for time cells in when using View classes. - Add support for ``.xlsx`` files when using View classes, at the expense of formatting information being available. Full docs here: http://pythonhosted.org/xlutils/ Details of all things Python and Excel related can be found here: http://www.python-excel.org/ cheers, Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- https://mail.python.org/mailman/listinfo/python-list
Re: MacOS 10.9.2: threading error using python.org 2.7.6 distribution
In article captjjmpxuj9n3cdqch0ojavksfvrqjwhh1gst3fafkcgyw5...@mail.gmail.com, Chris Angelico ros...@gmail.com wrote: On Fri, Apr 25, 2014 at 11:43 PM, Matthew Pounsett matt.pouns...@gmail.com wrote: If I insert that object into the test code and run it instead of MyThread(), I get the error. I can't see anything in there that should cause problems for the threading module though... especially since this runs fine on another system with the same version of python. Any thoughts on what's going on here? First culprit I'd look at is the mixing of subprocess and threading. It's entirely possible that something goes messy when you fork from a thread. FWIW, the Python 2 version of subprocess is known to be thread-unsafe. There is a Py2 backport available on PyPI of the improved Python 3 subprocess module: http://bugs.python.org/issue20318 https://pypi.python.org/pypi/subprocess32/ -- Ned Deily, n...@acm.org -- https://mail.python.org/mailman/listinfo/python-list
Re: Proper deletion of selected items during map iteration in for loop
On 2014-04-25 14:50, Terry Reedy wrote: If you expect to delete more than half the keys *and* if there are no other references to the dict, such that you need the particular object mutated, this might be better. If that's your precondition, then it might be better to do something like keep = {} for (k, v) in m.items(): if f(k): # do some processing of v and save result elsewhere else: keep[k] = v m.clear() m.update(keep) del keep # optionally free this back up when done This would allow things that refer to m to retain the same reference, but should have the same result as deleting them without having to duplicate what the OP describes as a large volume of data. Either way, the options are mostly 1) clone the entire .items() into a list, and iterate over that for deleting from your underlying view (what Chris Matthew suggest) 2) iterate over the items, storing up the ones to delete and delete them all at the end (what the OP mentions having tried before) 3) iterate over the items, storing up the ones to keep, delete the rest, and then put the kept ones back (what I code above) The choice between #2 and #3 hinge on whether you expect to delete more than half the items. If you plan to delete more than half, store the ones to keep (#3); if you plan to delete less than half, store the ones to delete (#2). -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: Installing PyGame?
Ned Deily wrote: I disagree that installing a bunch of disparate software from various sources via binary installers and/or source is to be preferred to a modern third-party package manager on OS X like MacPorts or Homebrew. That's just setting yourself up for a long-term maintenance headache. What could be easier than: sudo port install py27-game That's fine if it works, but the OP said he'd already tried various things like that and they *didn't* work for him. And I've had trouble in the past with MacPorts and/or Fink (can't remember exactly which one it was) installing libraries that were incompatible with other things I use and messing them up, so I've learned to be wary of them. Those problems were probably due to some unusual features of my setup, and wouldn't occur for most other people. But because I don't use those tools, I can't give any recommendations about how to troubleshoot them. All I can do is explain what works for me. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Installing PyGame?
Ryan Hiebert wrote: I've chosen to use MacPorts because it keeps things separate, because when things get hosed using the system libraries, I don't have to erase my whole system to get back to a vanilla OS X install. I don't know what you're doing to hose your system that badly. I've never had a problem that couldn't be fixed by deleting whatever the last thing was I added that caused it. Also the problems I had with one of the third-party package managers was because it *didn't* keep its own stuff properly separated. It installed libraries on my regular library path so that they got picked up by things that they weren't appropriate for. I'm not saying that MacPorts is a bad thing. If it's the *only* thing you use, it's probably fine. But I use a wide variety of libraries, not all of them available that way, and many of them installed from source, and I find it's less hassle overall to do everything the native MacOSX way wherever possible. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: retrieve source code from code object as returned by compile()
Amirouche Boubekki wrote: in python3, I do inspect.getsource(object) [doc https://docs.python.org/3/library/inspect.html#inspect.getsource], I don't know the limitations. The limitation relevant here is that it requires the original source file to be present. :-) -- Greg -- https://mail.python.org/mailman/listinfo/python-list
feedparser error
python 2.7.2 The following code has an error and I can not figure out why: import feedparser d = feedparser.parse('http://bl.ocks.org/mbostock.rss') numb = len(d['entries']) for post in d.entries: print post.pubDate+\n --- the error is : print post.pubDate+\n File build\bdist.win32\egg\feedparser.py, line 416, in __getattr__ raise AttributeError, object has no attribute '%s' % key AttributeError: object has no attribute 'pubDate' --- The only thing I can think of is feedparser does not like uppercase(pubDate)? I can not change someone else's rss. What can I do here? -- https://mail.python.org/mailman/listinfo/python-list
Using Python to get push notifications from an RSS feed?
As a little project for myself (and to help get immediate player notes for my fantasy baseball team), I'm wondering what modules I might need to do this. Basically, I'd like to get immediate notification when a new player note has been added to an RSS feed. Since it will only be for specified players, I suppose I would use something like ElementTree to read the data and figure out if the update is about a relevant player, but how do I check the RSS feed (constantly) in the first place? I was reading a little about Universal Feed Parser, but I'm still not sure about how to do the push notification aspect. I'd like immediate notifications if possible, or will I have to settle for periodically checking the feed? If the latter, how do I ensure I only check the newest updates since the last time, and not everything? Thanks! John -- https://mail.python.org/mailman/listinfo/python-list
Play back and record sound *at the same time* for n seconds
Hello, to program an art project that involves sound feedback I need a way to get a python script to to play back and to record sound *at the same time* for n seconds. Which strategy/sound module would you recommend, and could you post dummy code that shows how to get it to play and record simultaneously? Thanks a lot! Tom -- https://mail.python.org/mailman/listinfo/python-list
[issue21340] Possible concurrency bug in asyncio, AttributeError in tasks.py
Guido van Rossum added the comment: Oh wait, it looks like the assert failed because KeyboardInterrupt hit right at that point. I ran the program a few times and when I hit ^C I get a traceback at a different point in the code each time. This is as expected. You must have hit the rare case where it hit right at the assert -- then the behavior I described can happen. Anyway, I think this would fix it: --- a/asyncio/tasks.py Fri Apr 18 09:51:35 2014 -0700 +++ b/asyncio/tasks.py Thu Apr 24 23:44:57 2014 -0700 @@ -76,7 +76,8 @@ return self.gen.gi_code def __del__(self): -frame = self.gen.gi_frame +gen = getattr(self, 'gen', None) +frame = getattr(gen, 'gi_frame', None) if frame is not None and frame.f_lasti == -1: func = self.func code = func.__code__ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21340 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17552] socket.sendfile()
akira added the comment: I'm confused. Why is blocksize necessary at all? My guess, it may be used to implement socket.send()-based fallback. Its meaning could be the same as *length* parameter in shutil.copyfileobj The fallback is useful if os.sendfile doesn't exists or it doesn't accept given parameters e.g., if *file* is not mmap-like enough for os.sendfile. using os.path.getsize(file.name) looks risky to me Why not fstat(fd) ? os.path.getsize(file.name) in msg217121 is a pseudo-code (as said in the comment) that expresses the intent that if *nbytes* parameter is not specified (None) then socket.sendfile should send bytes from the file until EOF is reached. In real code, if *nbytes is None*; I would just call os.sendfile repeatedly with a large constant *nbytes* parameter until os.sendfile returns 0 (meaning EOF) without asking the file size explicitly It assumes socket.sendfile doesn't specify its behaviour if the file size changes between the calls. The pseudo-code in msg217121 is my opinion about the public interface for socket.sendfile -- It is different from the one in the current socket-sendfile5.patch -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17552 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21348] File C:\Python27\lib\distutils\msvc9compiler.py, line 295, in query_vcvarsal l raise ValueError(str(list(result.keys()))) ValueError: [u'path']
Stefan Krah added the comment: This looks like a duplicate of #7511. -- nosy: +skrah resolution: - duplicate stage: - resolved status: open - closed superseder: - msvc9compiler.py: ValueError when trying to compile with VC Express ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21348 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20434] Fix error handler of _PyString_Resize() on allocation failure
Roundup Robot added the comment: New changeset 4f79c3827adc by Kristján Valur Jónsson in branch '2.7': Issue #20434 Correct error handlin of _PyString_Resize and _PyBytes_Resize http://hg.python.org/cpython/rev/4f79c3827adc -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20434 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21349] crash in winreg SetValueEx with memoryview
Changes by Berker Peksag berker.pek...@gmail.com: -- nosy: +zach.ware ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21349 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21225] io.py: Improve docstrings for classes
Roundup Robot added the comment: New changeset e33a036fd784 by Andrew Kuchling in branch '3.4': #21225: copy docstrings from base classes http://hg.python.org/cpython/rev/e33a036fd784 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21225 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21336] ntpath.splitdrive fails on None argument
Eric V. Smith added the comment: I'm going to close this as not a bug. Feel free to reopen it if there's use case for passing in None. -- resolution: - not a bug stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21336 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1465646] test_grp test_pwd fail
yaccz added the comment: Also fails on group + which is afaik a thing for ldap. tested with python 2.6.9 on suse linux enterprise -- nosy: +yaccz ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1465646 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21350] bug in file.writelines accepting buffers
New submission from Brian Kearns: In file.writelines, the conditions in this if statement are bogus. If f-f_binary and AsReadBuffer succeeds (returns 0), AsCharBuf is still tried. So, for example, passing an array('c') to a file('wb').writelines fails, when it seems the intention of the code/comments was to have it succeed. -- files: fix_file_writelines-py27.patch keywords: patch messages: 217162 nosy: bdkearns priority: normal severity: normal status: open title: bug in file.writelines accepting buffers type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file35036/fix_file_writelines-py27.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21350 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21350] bug in file.writelines accepting buffers
Changes by Brian Kearns bdkea...@gmail.com: Removed file: http://bugs.python.org/file35036/fix_file_writelines-py27.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21350 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21350] bug in file.writelines accepting buffers
Changes by Brian Kearns bdkea...@gmail.com: Added file: http://bugs.python.org/file35037/fix_file_writelines-py27.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21350 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21305] PEP 466: update os.urandom
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21305 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21349] crash in winreg SetValueEx with memoryview
New submission from Zachary Ware: The new test fails with the patch applied: == ERROR: test_setvalueex_with_memoryview (__main__.LocalWinregTests) -- Traceback (most recent call last): File P:\ath\to\2.7\cpython\lib\test\test_winreg.py, line 336, in test_setvalueex_with_memoryview SetValueEx(ck, test_name, None, REG_BINARY, memoryview('val')) TypeError: Objects of type 'memoryview' can not be used as binary registry values -- -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21349 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21349] crash in winreg SetValueEx with memoryview
Brian Kearns added the comment: Oops, updated test. -- Added file: http://bugs.python.org/file35038/fix_winreg_setvalueex-py27.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21349 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21349] crash in winreg SetValueEx with memoryview
Changes by Brian Kearns bdkea...@gmail.com: Removed file: http://bugs.python.org/file35031/fix_winreg_setvalueex-py27.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21349 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17552] socket.sendfile()
Giampaolo Rodola' added the comment: Given the opinions expressed so far I: - got rid of the blocksize parameter - got rid of the use_fallback parameter - added a count parameter - used os.fstat() to figure out the total file size and passed it directly to sendfile() I'm attaching socket-sendfile6.patch which includes docs and many new tests. Hopefully this should be the final one (yet to review though). -- Added file: http://bugs.python.org/file35039/socket-sendfile6.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17552 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21344] save scores or ratios in difflib get_close_matches
Russell Ballestrini added the comment: Adding patch to update tests to use Tim Peters suggestion of assertListEqual over assertEqual for list compares. -- Added file: http://bugs.python.org/file35040/diff-lib-tim-peters-assert-list-equals.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21344 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21347] Don't use a list argument together with shell=True in subprocess' docs
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo versions: +Python 2.7, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21347 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21338] Silent mode for compileall
Éric Araujo added the comment: Patch looks to me comprehensive and backward-compatible. Thanks Thomas! -- nosy: +eric.araujo stage: needs patch - commit review type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21338 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21351] refcounts not respected at process exit
New submission from Min RK: Reference counts appear to be ignored at process cleanup, which allows inter-dependent `__del__` methods to hang on exit. The problem does not seem to occur for garbage collection of any other context (functions, etc.). I have a case where one object must be cleaned up after some descendent objects. Those descendents hold a reference on the parent and not vice versa, which should guarantee that they are cleaned up before the parent. This guarantee is satisfied by Python 3.3 and below, but not 3.4. The attached test script hangs at exit on most (not all) runs on 3.4, but exits cleanly on earlier versions. -- components: Interpreter Core files: tstgc.py messages: 217168 nosy: minrk priority: normal severity: normal status: open title: refcounts not respected at process exit versions: Python 3.4 Added file: http://bugs.python.org/file35041/tstgc.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21351 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21351] refcounts not respected at process exit
Nathan Stocks added the comment: This affects me as well. I have to manually clean up objects in the correct order in script I am working on under 3.4.0. I have this problem under both OS X 10.9.2 Mavericks and under CentOS 6.5 -- nosy: +nathan.stocks ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21351 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21352] improve indexing
New submission from bob gailer: Inconsistencies / confusion with documentation Index Tab. Example (line numbers added for comments that follow): 1 max 2 built-in function 3 max (datetime.date attribute) 4 (datetime.datetime attribute) 5 (datetime.time attribute) 6 max() built-in function 7 (decimal.Context method) 8 (decimal.Decimal method) 9 (in module audioloop) The following all lead to confusion and frustration: Having 3 rows (1, 3, 6)that begin with max. Having an entry (1) that does nothing when double-clicked. double-clicking (2) takes us to a reference rather than a definition. RECOMMENDATION: change to: max() built-in function (sequence operation) (decimal.Context method) (decimal.Decimal method) max (datetime.date attribute) (datetime.datetime attribute) (datetime.time attribute) where double-clicking the first line goes to the max() definition in 2. Built-in Functions These comments apply, with a number of variations, to most built-in functions index entries. -- assignee: docs@python components: Documentation messages: 217170 nosy: bgailer, docs@python priority: normal severity: normal status: open title: improve indexing type: enhancement versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21352 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21352] improve indexing
Changes by Zachary Ware zachary.w...@gmail.com: -- versions: -Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21352 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21344] save scores or ratios in difflib get_close_matches
Tim Peters added the comment: Russell, I'm still looking for a sufficiently compelling use case here: something tangible and useful that can be done with the new function that can't be easily done now. I plan to write a web API that accepts a word, 'doge' and returns a list of possible suggestions and scores is not a use case for scores. It's merely tautological that if you want to return scores then you need a function that does return scores. A use case would more address _why_ the scores are useful. What would the user of your web API _do_ with the scores? What's the point? users may want to cache (memonize) common queries for super fast look ups isn't a use case for scores either. If they wanted to, they could already cache the results of calling `get_close_matches()` - the results of any function can be cached; exposing scores has nothing to do with whether results can be cached. the new function will give end-users the opportunity to inspect the scoring algos output is also more tautological than a use case. _Why_ would a user want to stare at the scores? What useful things(s) could they do with them? I was added to this issue because I wrote these functions to begin with. At the time, I thought - and asked - about exposing the scores, but nobody (including me) had a _use_ for doing so that justified the added bother of writing maintaining the additional code and tests and docs. I'm stilling looking for a use here more substantial than, essentially, just saying well, without showing the scores we can't show the scores. To me the scores just aren't interesting beyond which words' scores exceed a cutoff, and the ordering of words based on their similarity scores - but `get_close_matches()` already captures those uses. What other use(s) _do_ you have for the scores? I'm afraid just to display them isn't compelling enough - you're the only one ever to ask for that, and you already know how to do it yourself ;-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21344 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21351] refcounts not respected at process exit
Tim Peters added the comment: Just noting that, for me, the problem goes away if del c, c2 is added as the last line of the test. This suggests the problem is due to changes in end-of-life module cleanup. Without that line, I see 3 kinds of output: 1. del child del child del parent parent deleted 2. del parent parent still has 2 children parent still has 2 children ... repeated forever ... 3. del child del parent parent still has 1 children parent still has 1 children ... repeated forever ... -- nosy: +tim.peters ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21351 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16104] Compileall script: add option to use multiple cores
Jim Jewett added the comment: ProcessPoolExecutor already defaults to using cpu_count if max_workers is None. Consistency with that might be useful too. (and a default of 1 to mean nothing in parallel is sensible...) -- nosy: +Jim.Jewett ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16104 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21351] refcounts not respected at process exit
Changes by Tim Peters t...@python.org: -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21351 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21344] save scores or ratios in difflib get_close_matches
Russell Ballestrini added the comment: Tim, You bring up some great points and insight I was missing. To me the scores just aren't interesting beyond which words' scores exceed a cutoff, and the ordering of words based on their similarity scores - but `get_close_matches()` already captures those uses. For a *word*, and a corpus of *possibilities*, how does one choose a satisfactory *cutoff* without inspecting the output of the scoring algorithm? Personally, I don't want to inpect scores for inspection sake, I want to inspect scores so I can make an informed decision for the *n* and *cutoff* input arguments. Its true that after reading and digesting the source code for `get_close_matches()` I could (and did) implement a version that returns scores. My goal was to share this code and what better way then to fix the problem upstream. I understand the desire to keep the standard library lean and useful to reduce the amount of burden the code is to maintain. I will understand if we decide not to include these patches, I can always maintain a fork and share on pypi. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21344 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20050] distutils should check PyPI certs when connecting to it
Changes by William Tisäter will...@defunct.cc: -- nosy: +tiwilliam ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20050 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21314] Document '/' in signatures
Changes by Terry J. Reedy tjre...@udel.edu: -- status: open - title: Bizarre help - Document '/' in signatures ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21314 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: +Python 3.5 -Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21321 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21325] Missing Generic EXIF library for images in the standard library
Terry J. Reedy added the comment: Generic ideas like this, without specific patch or patch prospect, should be first posted on python-ideas. You can reopen this if there is a concrete proposal with some support. However, I agree with Brett about an Exif module. We do not even have an image library in the stdlib. And according to https://en.wikipedia.org/wiki/Exchangeable_image_file_format the 'standard' is in practice a bit of a mess with constantly added extensions. There are multiple Exif modules on PyPi and that is where they belong, along with 1000s of other niche modules. https://pypi.python.org/pypi?%3Aaction=searchterm=Exifsubmit=search -- nosy: +terry.reedy resolution: - rejected stage: - resolved status: open - closed versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21325 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21337] Add tests for Tix
Changes by Terry J. Reedy tjre...@udel.edu: -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21337 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21341] Configuring 'font' with ttk.Style for 'TEntry' does not change displayed font
Terry J. Reedy added the comment: This appears to be a tcl/tk(ttk) issue. You rediscovered what is documented here: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Entry.html Table 40. ttk.Entry options fontUse this option to specify the font of the text that will appear in the widget; see Section 5.4, “Type fonts”. For reasons that are unclear to the author, this option cannot be specified with a style. -- nosy: +terry.reedy resolution: - third party stage: - resolved status: open - closed versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21341 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8387] use universal newline mode in csv module examples
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: -Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8387 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21351] refcounts not respected at process exit
Antoine Pitrou added the comment: (the 3 kinds of output are probably due to hash randomization) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21351 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21351] refcounts not respected at process exit
Antoine Pitrou added the comment: Looking into it, it's normal for refcounts to be ignored: those objects belong to reference cycles: tstgc.__dict__ - p (or c, or c2) - p.__class__ (i.e. Parent, or Child respectivel)) - Parent.__dict__ - Parent.__del__ (or Parent.__init__, or Parent.child) - Parent.__del__.__globals__ (which is tstgc.__dict__) Since p, c, c2 belong to reference cycles, they get collected in an undefined order. Obviously, Parent.__del__ is buggy (it runs into an infinite loop when self.children != 0). Before Python 3.4, the module globals would have been set to None at shutdown, which would have broken those cycles, but caused other well-known problems. It's probably impossible to find a scheme that satisfies all constraints, so we'll see in the future if the new scheme brings more drawbacks than advantages (right now, my own evaluation is obviously that it's a step forward). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21351 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21351] refcounts not respected at process exit
Tim Peters added the comment: I think Antoine is right on all counts. The most surprising bit may be that p, c, and c2 are in reference cycles, but - surprising or not - that's always been true. The reason it worked before 3.4 is that CPython happened to break the cycles via the nasty hack of binding each module global to None at shutdown. minrk, note that gc in CPython does not (for example) run in a separate thread. That's why, when it triggers, the infinite loop in your Parent.__del__ will in fact run forever. gc runs in the same thread (the main thread) as Parent.__del__, so spinning in the Parent.__del__ loop prevents anything else (including more gc) from ever being done. Take out the infinite loop, and all three objects (p, c, c2) are collected. But the order in which they're collected isn't defined (because they're all in cyclic trash), and even changes from run to run because hash randomization changes the order in which they appear when traversing testgc.__dict__. An interesting question remaining is how you _could_ force a finalization order in this case, in a way that doesn't rely on implementation accidents. A clean way doesn't spring to my mind immediately. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21351 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted
Antoine Pitrou added the comment: Haven't reviewed the patch, but you should definitely add a unit test for the bugfix. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21321 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21349] crash in winreg SetValueEx with memoryview
Antoine Pitrou added the comment: Brian, it's not obvious (to me) what the original issue is (crash?) and why the new test expects a TypeError. Also, is it a 2.7-only issue or does it also affect Python 3? -- nosy: +pitrou, stutzbach ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21349 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21349] crash in winreg SetValueEx with memoryview
Brian Kearns added the comment: Are you aware of the old/new buffer interfaces and their usages? Did you actually try the code? crash would be obvious. Objects that support only the new buffer interface define tp_as_buffer with fields representing the old buffer interface as null. So, everywhere that uses the old buffer interface usually checks both tp_as_buffer != NULL and tp_as_buffer-bf_getreadbuffer != NULL. That second check is missing here before calling bf_getreadbuffer. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21349 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21353] document Popen.args attribute
New submission from akira: It is convenient to have Popen.args available. Especially when dealing with multiple processes e.g., to log failures mentioning the command that was used to spawn the child process. subprocess module itself uses it while raising CalledProcessError or TimeoutExpired exceptions. The documentation patch is attached. -- assignee: docs@python components: Documentation files: docs-subprocess-document_Popen_args_attribute.patch keywords: patch messages: 217183 nosy: akira, docs@python priority: normal severity: normal status: open title: document Popen.args attribute type: enhancement versions: Python 3.3, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file35042/docs-subprocess-document_Popen_args_attribute.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21353 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com