zeep, infinite recursion
Running this command: python3.6 -m zeep exmaple.wsdl I get this (this is only the end of the traceback): part = element.signature(schema, standalone=False) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/indicators.py", line 252, in signature parts.append(element.signature(schema, standalone=False)) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/indicators.py", line 561, in signature parts.append('{%s: %s}' % (name, element.signature(schema, standalone=False))) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/element.py", line 263, in signature value = self.type.signature(schema, standalone=False) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/types/complex.py", line 437, in signature part = element.signature(schema, standalone=False) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/indicators.py", line 252, in signature parts.append(element.signature(schema, standalone=False)) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/indicators.py", line 561, in signature parts.append('{%s: %s}' % (name, element.signature(schema, standalone=False))) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/element.py", line 263, in signature value = self.type.signature(schema, standalone=False) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/types/complex.py", line 437, in signature part = element.signature(schema, standalone=False) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/indicators.py", line 252, in signature parts.append(element.signature(schema, standalone=False)) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/indicators.py", line 561, in signature parts.append('{%s: %s}' % (name, element.signature(schema, standalone=False))) File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/element.py", line 259, in signature from zeep.xsd import ComplexType RecursionError: maximum recursion depth exceeded Looks like an infinite recursion to me. Due to a non-disclosure agreement, I'm not able to send you the example wsdl. But I can tell that the very same WSDL works with Oracle Java Web Services. So the WSDL itself is fine. Could this be a bug in zeep? Thanks, Laszlo -- https://mail.python.org/mailman/listinfo/python-list
Re: zeep, infinite recursion
Nagy László Zsolt writes: > Running this command: > > python3.6 -m zeep exmaple.wsdl > > I get this (this is only the end of the traceback): > ... > from zeep.xsd import ComplexType > RecursionError: maximum recursion depth exceeded > > Looks like an infinite recursion to me. Due to a non-disclosure > agreement, I'm not able to send you the example wsdl. But I can tell > that the very same WSDL works with Oracle Java Web Services. So the > WSDL itself is fine. > > Could this be a bug in zeep? It could be some sort of bug, of course, but (not knowing anything about WSDLs or zeeps) it could be that the data is deeper than Python's default recursion depth, which is rather small. You could try setting a higher limit and see if the call succeeds then. (Search for Python's maximum recursion depth. I don't remember the incantation but it should be easy to find.) -- https://mail.python.org/mailman/listinfo/python-list
Re: zeep, infinite recursion
Nagy László Zsolt wrote: > Running this command: > > python3.6 -m zeep exmaple.wsdl This example is no more, we heave ceased to see it, it's gone to meet its maker... this is an ex-ex-ample. > line 259, in signature > from zeep.xsd import ComplexType > RecursionError: maximum recursion depth exceeded > > Looks like an infinite recursion to me. Due to a non-disclosure > agreement, I'm not able to send you the example wsdl. So you tell us it's just restin' under an NDA. > But I can tell > that the very same WSDL works with Oracle Java Web Services. So the WSDL > itself is fine. > Could this be a bug in zeep? A bug in zeep, or the example, or the Java stuff. An easy thing to try: increase the recursion limit with sys.setrecursionlimit(2000) -- https://mail.python.org/mailman/listinfo/python-list
repeat until keypressed
In good old pascal there was this one-liner command: repeat until keypressed Apparently there is no built-in analogue for that in python. I have explored several different possibilities (pyglet, keyboard, curses, ginput (from matplotlib) and others) but not managed to find anything that works the way I want. In the following example I just want to replace 'waitforbuttonpress' with something like 'continueuntilbuttonpress' if such a command exists. It could be a mouseclick or a keystroke from the terminal, for instance 'shift', 'space' or some character. Poul Riis import warnings warnings.filterwarnings("ignore",".*GUI is implemented.*") from pylab import * ion() plot1=subplot(2,1,1) plot2=subplot(2,1,2) for i in range(20): plot1.plot([20*(sin(i/10)+1)],[cos(i/10)],'bo') ### The following two lines should be replaced by ### something like "Go on until some key is pressed - then break" if plt.waitforbuttonpress(): break pause(0.1) draw() for i in range(20): plot2.plot([20*(sin(i/10)+1)],[-cos(i/10)],'ro') pause(0.1) draw() ioff() -- https://mail.python.org/mailman/listinfo/python-list
Re: repeat until keypressed
On 05/29/2017 03:14 PM, Poul Riis wrote: In good old pascal there was this one-liner command: repeat until keypressed Apparently there is no built-in analogue for that in python. I have explored several different possibilities (pyglet, keyboard, curses, ginput (from matplotlib) and others) but not managed to find anything that works the way I want. In the following example I just want to replace 'waitforbuttonpress' with something like 'continueuntilbuttonpress' if such a command exists. It could be a mouseclick or a keystroke from the terminal, for instance 'shift', 'space' or some character. Poul Riis ### The following two lines should be replaced by ### something like "Go on until some key is pressed - then break" if plt.waitforbuttonpress(): break Hello, What about try: for i in range(20): plot1.plot([20*(sin(i/10)+1)],[cos(i/10)],'bo') except KeyboardInterrupt: pass # you could also print a message You'd be using CTRL+C to interrupt the loop. jm -- https://mail.python.org/mailman/listinfo/python-list
Re: repeat until keypressed
Poul Riis wrote: > In good old pascal there was this one-liner command: > repeat until keypressed > > Apparently there is no built-in analogue for that in python. I have > explored several different possibilities (pyglet, keyboard, curses, ginput > (from matplotlib) and others) but not managed to find anything that works > the way I want. > > In the following example I just want to replace 'waitforbuttonpress' with > something like 'continueuntilbuttonpress' if such a command exists. It > could be a mouseclick or a keystroke from the terminal, for instance > 'shift', 'space' or some character. How about combining waitforbuttonpress() with pause()? import warnings warnings.filterwarnings("ignore", ".*GUI is implemented.*") from pylab import * def plot_them(): plot1 = subplot(2, 1, 1) plot2 = subplot(2, 1, 2) for i in range(20): plot1.plot([20*(sin(i/10)+1)], [cos(i/10)], 'bo') if waitforbuttonpress(timeout=0.1): return for i in range(20): plot2.plot([20*(sin(i/10)+1)], [-cos(i/10)], 'ro') if waitforbuttonpress(timeout=0.1): return ion() plot_them() waitforbuttonpress() ioff() -- https://mail.python.org/mailman/listinfo/python-list
error i m getting in line no 4
import util def run_test (test): if test == 0: grid = [] util.create_grid (grid) print (len (grid)) print (len (grid[0])) print (len (grid[1])) print (len (grid[2])) print (len (grid[3])) print (grid[0][0]) print (grid[1][2]) print (grid[2][1]) print (grid[3][3]) elif test == 1: grid = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] util.print_grid (grid) elif test == 2: grid = [[2,0,2,0],[0,4,0,8],[0,16,0,128],[2,2,2,2]] util.print_grid (grid) elif test == 3: grid = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] print (util.check_lost (grid)) elif test == 4: grid = [[2,0,2,0],[0,4,0,8],[0,16,0,128],[2,2,2,2]] print (util.check_lost (grid)) elif test == 5: grid = [[2,2,2,2],[2,2,2,2],[2,2,2,2],[2,2,2,2]] print (util.check_lost (grid)) elif test == 6: grid = [[4,16,2,4],[2,4,16,2],[2,4,8,4],[4,8,4,2]] print (util.check_lost (grid)) elif test == 7: grid = [[4,2,8,2],[2,8,16,8],[16,32,8,4],[4,8,4,2]] print (util.check_lost (grid)) elif test == 8: grid = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] print (util.check_won (grid)) elif test == 9: grid = [[2,0,2,0],[0,4,0,8],[0,16,0,128],[2,2,2,2]] print (util.check_won (grid)) elif test == 10: grid = [[2,2,2,2],[2,2,2,2],[2,2,2,2],[2,2,2,2]] print (util.check_won (grid)) elif test == 11: grid = [[4,16,2,4],[2,4,16,2],[2,4,8,4],[4,8,4,2]] print (util.check_won (grid)) elif test == 12: grid = [[2,32,2,4],[4,2,16,2],[8,0,8,4],[2,0,4,2]] print (util.check_won (grid)) elif test == 13: grid = [[2,2,8,0],[0,8,16,0],[16,32,8,8],[2,8,4,4]] print (util.check_won (grid)) elif test == 14: grid = [[64,32,32,2],[8,4,2,0],[4,2,0,0],[2,0,0,0]] print (util.check_won (grid)) elif test == 15: grid = [[64,32,32,2],[8,4,2,0],[4,2,0,0],[2,0,0,0]] print (util.check_won (grid)) elif test == 16: grid = [[128,4,0,0],[8,4,2,0],[4,2,0,2],[2,0,0,0]] print (util.check_won (grid)) elif test == 17: grid = [[4,2,8,2],[2,8,16,8],[16,32,8,4],[4,8,4,2]] test_grid = util.copy_grid (grid) print (grid[0][0],test_grid[0][0]) print (grid[1][2],test_grid[1][2]) print (grid[3][3],test_grid[3][3]) grid[0][0] = 64 grid[1][2] = 64 grid[3][3] = 64 print (grid[0][0],test_grid[0][0]) print (grid[1][2],test_grid[1][2]) print (grid[3][3],test_grid[3][3]) elif test == 18: grid1 = [[4,2,8,2],[2,8,16,8],[16,32,8,4],[4,8,4,2]] grid2 = [[4,2,8,2],[2,8,16,8],[16,32,8,4],[4,8,4,2]] print (util.grid_equal (grid1, grid2)) elif test == 19: grid1 = [[4,2,8,2],[2,8,16,8],[16,32,8,4],[4,8,4,2]] grid2 = [[4,2,8,2],[2,8,16,4],[16,32,8,4],[4,8,4,2]] print (util.grid_equal (grid1, grid2)) elif test == 20: grid1 = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] grid2 = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] print (util.grid_equal (grid1, grid2)) elif test == 21: grid1 = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] grid2 = [[2,4,8,16],[32,64,128,256],[512,1024,2048,4096],[8192,16384,32768,65536]] print (util.grid_equal (grid1, grid2)) elif test == 22: grid1 = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] grid2 = [[2,2,2,2],[2,2,2,2],[2,2,2,2],[2,2,2,2]] print (util.grid_equal (grid1, grid2)) def run_one_test (): test = int (input ("")) run_test (test) def run_all_tests (): for test in range (23): print ("Test",test) run_test (test) run_one_test () -- https://mail.python.org/mailman/listinfo/python-list
Re: error i m getting in line no 4
On Tue, May 30, 2017 at 2:36 AM, Mohd Gausul Abdeen wrote: > import util > > def run_test (test): > if test == 0: > grid = [] > util.create_grid (grid) Is this your actual code, or did you lose formatting when you posted it? Either way, make sure you retain indentation in Python code. Also, you need to post the actual error you're getting. We are mindreaders, it's true, but it's a matter of courtesy to not force us to exercise our magical abilities on your behalf. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: error i m getting in line no 4
And you can simplify the code with something like this for all of the "grid=" statements new_grid = [[], [0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0], [2,0,2,0],[0,4,0,8],[0,16,0,128],[2,2,2,2], [0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]], [2,0,2,0],[0,4,0,8],[0,16,0,128],[2,2,2,2], [2,2,2,2],[2,2,2,2],[2,2,2,2],[2,2,2,2]] ## etc grid=new_grid[test] This also assumes that you want grid to be a list, and not a list of lists. -- https://mail.python.org/mailman/listinfo/python-list
Three good posts on speeding up CPython
http://www.corsix.org/content/micro-optimisations-can-speed-up-cpython https://www.corsix.org/content/compilers-cpython-interpreter-main-loop https://www.corsix.org/content/why-are-slots-so-slow -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
pypinfo: CLI to easily view PyPI download statistics via Google's BigQuery.
https://github.com/ofek/pypinfo -- https://mail.python.org/mailman/listinfo/python-list
SweetRegex
Hi folks, First poor old Ethan Furman loses his job as a vastly superior Enum is set into the wild, but now it looks as if MRAB is out owing to this https://github.com/ac1235/python-SweetRegex. I believe tht we need to have a whip round to ensure that neither Ethan or MRAB lose out finacially. Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
[Ask for Review] Scalpl: A lightweight wrapper to operate on nested dictionaries (yet another)
Hi everyone :) I wanted to share with you the work I have done for the past few days. It is the first time for me to make my code public, so I would really appreciate if some of you find time to give me feedbacks and tips regarding this project :) So, here is Scalpl ! https://github.com/ducdetronquito/scalpl It is a lightweight wrapper that helps you to operate on nested dictionaries through the built-in dict API, by using dot-separated string keys. You might find it useful when working with document-oriented database queries, REST APIs, configuration files, etc... It's *not* a drop-in replacement for your dictionaries, just syntactic sugar to avoid this['annoying']['kind']['of']['things'] and prefer['a.different.approach']. The benefits of Scalpl are the following: - Faster than addict or Box. - Allows you to use the entire dict API 'with.this.kind.of.keys'. - Almost no instantiation/conversion cost, it's just a wrapper. You can install it via pip (Python3 only): pip3 install scalpl Have a great week :) ! Guillaume -- https://mail.python.org/mailman/listinfo/python-list
embed a package for proper fun script
Hello, How it is possible to embed a package in my project? I mean, in my python script I have written import openpyxl So, the user may not have installed that package and doesn't understand what is pip! Please let me know the instructions or any document regarding that. Regards, Mahmood -- https://mail.python.org/mailman/listinfo/python-list
Re: repeat until keypressed
On 5/29/2017 12:14 PM, Dennis Lee Bieber wrote: On Mon, 29 May 2017 06:14:46 -0700 (PDT), Poul Riis declaimed the following: In good old pascal there was this one-liner command: repeat until keypressed Apparently there is no built-in analogue for that in python. I have explored several different possibilities (pyglet, keyboard, curses, ginput (from matplotlib) and others) but not managed to find anything that works the way I want. What OS? In the following example I just want to replace 'waitforbuttonpress' with something like 'continueuntilbuttonpress' if such a command exists. It could be a mouseclick or a keystroke from the terminal, for instance 'shift', 'space' or some character. I'm presuming this "waitforbuttonpress" is a feature of pylab -- but I can't be sure as you used the polluting "import *" (Google seems to indicate it is matplotlib) Under Windows one has access to the msvcrt module if msvcrt.kbhit(): break ... But I don't know how this will interact with a graphical window (the msvcrt module provides functions for /console/ interaction [kbhit, getch, putch, ungetch] and for locking regions of files) If a tk(inter) window has input focus, the msvcrt console key functions do not work. For instance, when one runs code via IDLE, IDLE's Shell gets the focus. I documented this for IDLE under "IDLE-console differences" after someone reported a problem with kbhit on Stackoverflow. I presume it is true for other GUIs. If one has a tkinter GUI, the following might work: go = True def key_pressed(event): go = False while go: calculate() root.update() # allow events to be processed The while-loop can be and in some cases will have to be replaced by root.after calls. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: The argparse docs don't say who's responsible for closing FileType objects
Bob Kline wrote: > The subject line pretty much says it all. Should the programmer close the > file? If the programmer does that, and the user has asked that the file > object be hooked up to standard in (or standard out) what will happen? If > the programmer doesn't close it, does it get closed cleanly in the face of > an exception? > > Thanks! There's an example in the module docstring: """ The following is a simple usage example that sums integers from the command-line and writes the result to a file:: parser = argparse.ArgumentParser( description='sum the integers at the command line') parser.add_argument( 'integers', metavar='int', nargs='+', type=int, help='an integer to be summed') parser.add_argument( '--log', default=sys.stdout, type=argparse.FileType('w'), help='the file where the sum should be written') args = parser.parse_args() args.log.write('%s' % sum(args.integers)) args.log.close() """ To handle exceptions you can rewrite args.log.write('%s' % sum(args.integers)) args.log.close() as with args.log as outstream: outstream.write('%s' % sum(args.integers)) The reason I still don't use FileType is that I usually don't want to (1) open the file immediately in parse_args() (2) close sys.stdXXX My workaround are various wrappers along the line of myopen() below... $ cat argparse_myopen.py import argparse import sys from contextlib import contextmanager parser = argparse.ArgumentParser( description='sum the integers at the command line') parser.add_argument( 'integers', metavar='int', nargs='+', type=int, help='an integer to be summed') parser.add_argument( '--log', default=sys.stdout, help='the file where the sum should be written') args = parser.parse_args() @contextmanager def myopen(file, mode= "r"): assert mode == "w" if hasattr(file, "write"): yield file else: with open(file, mode) as outstream: yield outstream with myopen(args.log, "w") as out: print(sum(args.integers), file=out) assert out.closed == (out is not sys.stdout) print("Bye") $ python3 argparse_myopen.py 1 2 --log tmp.txt Bye $ cat tmp.txt 3 $ python3 argparse_myopen.py 2 3 5 Bye ...that I'm going to consolidate into a single one. Someday. -- https://mail.python.org/mailman/listinfo/python-list