[ANN] pypiserver 1.1.0 - minimal private pypi server
Hi, I've just uploaded pypiserver 1.1.0 to the python package index. pypiserver is a minimal PyPI compatible server. It can be used to serve a set of packages and eggs to easy_install or pip. pypiserver is easy to install (i.e. just 'pip install pypiserver'). It doesn't have any external dependencies. http://pypi.python.org/pypi/pypiserver/ should contain enough information to easily get you started running your own PyPI server in a few minutes. The code is available on github: https://github.com/schmir/pypiserver Changes in version 1.1.0 - implement multi-root support (one can now specify multiple package roots) - normalize pkgnames, handle underscore like minus - sort files by their version, not alphabetically - upgrade embedded bottle to 0.11.6 - upgrade waitress to 0.8.2 in the standalone script - merge vsajip's support for verify, doc_upload and remove_pkg -- Cheers Ralf -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
A new webpage promoting Compiler technology for CPython
Hey all, With Numba and Blaze we have been doing a lot of work on what essentially is compiler technology and realizing more and more that we are treading on ground that has been plowed before with many other projects. So, we wanted to create a web-site and perhaps even a mailing list or forum where people could coordinate and communicate about compiler projects, compiler tools, and ways to share efforts and ideas. The website is: http://compilers.pydata.org/ This page is specifically for Compiler projects that either integrate with or work directly with the CPython run-time which is why PyPy is not presently listed. The PyPy project is a great project but we just felt that we wanted to explicitly create a collection of links to compilation projects that are accessible from CPython which are likely less well known. But that is just where we started from. The website is intended to be a community website constructed from a github repository. So, we welcome pull requests from anyone who would like to see the website updated to reflect their related project.Jon Riehl (Mython, PyFront, ROFL, and many other interesting projects) and Stephen Diehl (Blaze) and I will be moderating the pull requests to begin with. But, we welcome others with similar interests to participate in that effort of moderation. The github repository is here: https://github.com/pydata/compilers-webpage This is intended to be a community website for information spreading, and so we welcome any and all contributions. Thank you, Travis Oliphant -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Exception ... in generator object ... ignored Messages
Ami Tavory wrote: From: Peter Otten __pete...@web.de To: python-list@python.org Cc: Date: Thu, 14 Feb 2013 09:00:58 +0100 Subject: Re: Exception ... in generator object ... ignored Messages How did the subject get into the message body? Ami Tavory wrote: Hi, Running the unit tests for some generator code, prints, as a side effect, numerous messages of the form: ... Exception NameError: global name 'l' is not defined in generator object _dagpype_internal_fn_act at 0x9d4c500 ignored Exception AttributeError: 'NoneType' object has no attribute 'close' in generator object split at 0x7601640 ignored Exception AttributeError: 'NoneType' object has no attribute 'close' in generator object split at 0x7601690 ignored ... The tests otherwise run fine. Is there any way to catch the point where such a message originates, and print a traceback? I find it difficult to debug otherwise. I've tried running Python with -W error, catching warnings with context managers, and so forth, but without any success. def g(): ... try: ... yield 42 ... finally: ... 1/0 ... for item in g(): ... break ... Exception ZeroDivisionError: 'integer division or modulo by zero' in generator object g at 0x7f990243b0f0 ignored Can you exhaust the generator? for item in g(): ... pass ... Traceback (most recent call last): File stdin, line 1, in module File stdin, line 5, in g ZeroDivisionError: integer division or modulo by zero Explicitly closing the generator seems to work, too: x = g() next(x) 42 x.close() Traceback (most recent call last): File stdin, line 1, in module File stdin, line 5, in g ZeroDivisionError: integer division or modulo by zero So basically the thing is that, as you've shown, if you exhaust a generator or force-close it, an exception is indeed thrown. However, in this were the case then unittest would identify it as a problem, and I could relatively easily get a traceback and see from where it's originating. However, the unittests are passing fine (except for the pesky messages), so it's something else. I'm starting to think that what's happening is something like this: I have a cascade of generator objects (some hold on to others), and the unittests check both the exhaustion case and the non-exhaustion case (both cases are valid use cases). *Later on*, after the tests finish, the garbage collector starts tearing down the generator cascade, but in a different order. Some generators, while closing down, are attempting to close down other generators that no longer exist. So, notwithstanding your correct answer - I'm still stumped about finding out how to get rid of these annoying messages. Posting a minimal example that exposes the behaviour and reflects the situation in your actual code would definitely a good idea ;) But short of closing your generators in a controlled manner the only thing that might help is avoiding global names in the finally clause. Globals are all set to None when the module object is destroyed. Code that runs in that phase may fail for that reason: $ cat tmp.py class X: def __init__(self, name): self.name = name x = X(whatever) def g(): try: yield 42 finally: print x.name y = g() next(y) $ python tmp.py Exception AttributeError: 'NoneType' object has no attribute 'name' in generator object g at 0x7f3dbf3580f0 ignored $ cat tmp2.py class X: def __init__(self, name): self.name = name x = X(whatever) def g(x=x): try: yield 42 finally: print x.name y = g() next(y) $ python tmp2.py whatever I'd still recommend fixing the cause rather than the symptoms... -- http://mail.python.org/mailman/listinfo/python-list
Re: Awsome Python - chained exceptions
Am 15.02.2013 08:51, schrieb Rick Johnson: How could a line in the try block ever be considered offensive? My suggestion of offensive does not imply ignorance on /my/ part[...] Well, it seems to imply that you are not aware of the subtle difference between offending and offensive. The irony on that was probably lost in my last posting, since you are still repeating this mistake. Now, concerning the rest, you are relying on too many implications that others should draw from what you wrote that are not clear. This doesn't help you getting across what you want to say. Further, you wrote Which (by showing the offensive line) is quite clear to me., i.e. that there can be offensive lines, then you go on to /i/ never suggested that ANY line in ANY block was offensive. Those two statements just don't fit together, see for yourself which of them you want to clarify or not, but please stop blaming others for your slips! You're welcome. Uli -- http://mail.python.org/mailman/listinfo/python-list
Re: Java NIO server and Python asyncore client
On Tuesday, February 5, 2013 10:09:28 AM UTC+2, foobar...@gmail.com wrote: Can someone help answer this? http://stackoverflow.com/questions/14698020/java-nio-server-and-python-asyncore-client Blocking python client works, asyncore doesn't work. There was return missing in writeable(). Modified code:: import socket import select import asyncore class Connector(asyncore.dispatcher): def __init__(self, host, port): asyncore.dispatcher.__init__(self) self.debug = True self.buffer = bytes(hi,ascii) self.create_socket(socket.AF_INET,socket.SOCK_STREAM) print(Connector.connect(({},{})).format(host,port)) self.connect((host, port)) def handle_connect(self): print(handle_connect()) # not called -- def handle_read(self): print(handle_read()) self.recv(4096) self.close() def writable(self): print(writable()) return len(self.buffer) 0 # remember RETURN def handle_write(self): print(handle_write()) sent = self.send(self.buffer) print(send({}).format(self.buffer[0:sent])) self.buffer = self.buffer[sent:] def handle_close(self): print(handle_close()) self.close() connector = Connector(localhost, 12000) # Handler() print(asyncore.loop() enter) asyncore.loop() print(asyncore.loop() leave) BSD socket communication framework does not itself support connection indications on connection-oriented protocols, so asyncore fakes the indication by detecting if socket is writable. As the writable was false = no write event = no connection indication. asyncore usage and documentation is bad, so when using the module, read the source code to understand it's usage and functioning, or use other implementation eg. Tornado. -- http://mail.python.org/mailman/listinfo/python-list
multiple 2.7.3 versions?
A colleague reports that this python from a recent Ubuntu x86_x64 Python 2.7.3 (default, Sep 26 2012, 21:51:14) contains a fix of this bug http://bugs.python.org/issue15212 however, all of my other Python 2.7.3s seem to lack this 'fix'. I would have thought that for a fix to appear in python we should at least get a micro version change, but the text here http://docs.python.org/2/faq/general.html#how-stable-is-python The developers issue “bugfix” releases of older versions, so the stability of existing releases gradually improves. Bugfix releases, indicated by a third component of the version number (e.g. 2.5.3, 2.6.2), are managed for stability; only fixes for known problems are included in a bugfix release, and it’s guaranteed that interfaces will remain the same throughout a series of bugfix releases. would seem to indicate that changes to the spelling of a public variable would not change even with a change to the micro level so my colleague's machine should not produce this output from compiler import consts dir(consts) ['CO_FUTURE_ABSIMPORT', 'CO_FUTURE_DIVISION', 'CO_FUTURE_PRINT_FUNCTION', 'CO_FUTURE_WITH_STATEMENT', 'CO_GENERATOR', 'CO_GENERATOR_ALLOWED', 'CO_NESTED', 'CO_NEWLOCALS', 'CO_OPTIMIZED', 'CO_VARARGS', 'CO_VARKEYWORDS', 'OP_APPLY', 'OP_ASSIGN', 'OP_DELETE', 'SC_CELL', 'SC_FREE', 'SC_GLOBAL_EXPLICIT', 'SC_GLOBAL_IMPLICIT', 'SC_LOCAL', 'SC_UNKNOWN', '__builtins__', '__doc__', '__file__', '__name__', '__package__'] where the originally mis-spelled SC_GLOBAL_EXPLICT has changed to SC_GLOBAL_EXPLICIT. Can someone explain how this 'fix' is leaking out onto his machine? On all the other machines I have access to I'm seeing something similar to this C:\tmppython Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. from compiler import consts dir(consts) ['CO_FUTURE_ABSIMPORT', 'CO_FUTURE_DIVISION', 'CO_FUTURE_PRINT_FUNCTION', 'CO_FUTURE_WITH_STATEMENT', 'CO_GENERATOR', 'CO_GENERATOR_ALLOWED', 'CO_NESTED', 'CO_NEWLOCALS', 'CO_OPTIMIZED', 'CO_VARARGS', 'CO_VARKEYWORDS', 'OP_APPLY', 'OP_ASSIGN', 'OP_DELETE', 'SC_CELL', 'SC_FREE', 'SC_GLOBAL_EXPLICT', 'SC_GLOBAL_IMPLICIT', 'SC_LOCAL', 'SC_UNKNOWN', '__builtins__', '__doc__', '__file__', '__name__', '__package__'] -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: First attempt at a Python prog (Chess)
On 13 February 2013 23:25, Chris Hinsley chris.hins...@gmail.com wrote: New to Python, which I really like BTW. First serious prog. Hope you like it. I know it needs a 'can't move if your King would be put into check' test. But the weighted value of the King piece does a surprising emergent job. #!/usr/bin/python -tt # -*- coding: utf-8 -*- # Copyright (C) 2013 Chris Hinsley, GPL V3 License import sys import random import os PLY = 3 EMPTY = 0 BLACK = 1 WHITE = 2 NO_CAPTURE = 3 MAY_CAPTURE = 4 MUST_CAPTURE = 5 def piece_type(piece): return EMPTY if piece == 32 else BLACK if chr(piece) in 'KQRBNP' else WHITE You call chr(piece) many times in this program. It would be better to just have piece be a string rather than always converting it to one every time you want to do something. Also comparing it with a numeric code is fairly cryptic. I guess that ascii 32 is a space character but I'd have to look that up to be sure. def display_board(board): print ' a b c d e f g h' print '+---+---+---+---+---+---+---+---+' for row in range(8): for col in range(8): Why not make board a list of lists. Then you can do: for row in board: for piece in row: rather than using range(). Or perhaps you could have a dict that maps position tuples to pieces, e.g.: {(1, 2): 'k', ...} sys.stdout.write('| ') sys.stdout.write(chr(board[row * 8 + col])) sys.stdout.write(' ') sys.stdout.write('|') print 8 - row print '+---+---+---+---+---+---+---+---+' You seem to be using sys.stdout.write as a way of printing without a trailing newline. In Python 2 you can get this effect by using: print 'foo', (note the trailing comma). In Python 3 you would do print('foo', end=' ') You can use the Python 3 syntax in your Python 2 script if you do from __future__ import print_function so that your script works on Python 2 and 3. Also I would probably separate the function that generates the text representing the board from the code that actually sends that information to stdout. def piece_moves(board, index, dx, dy, capture_flag, distance): piece = board[index] type = piece_type(piece) cx = index % 8 cy = index / 8 You can use divmod for this: cx, cy = divmod(index, 8) Also in Python 3 index / 8 will return a float. Use // for floor division in both versions (from __future__ import division). for step in range(distance): nx = cx + (dx * (step + 1)) ny = cy + (dy * (step + 1)) Why not make a function that yields these values and loop over that? def continued_moves(x, y, dx, dy): while 0 = x 8 and 0 = y 8: x += dx y += dy yield x, y if nx in range(8) and ny in range(8): Use chained comparisons 0 = x 8 rather than testing for membership in a range object. x in range(N, M) creates (in Python 2) a list integers and then (in 2 or 3) iterates over that list to find an object equal to x. This is inefficient and not as clear. newindex = ny * 8 + nx newpiece = board[newindex] With a list of lists you could access the board with board[ny][nx] which is clearer. Or with the dict: board[(nx, ny)]. The code below is overly indented. consider factoring it into functions. newtype = piece_type(newpiece) if capture_flag == MUST_CAPTURE: if newtype != EMPTY and newtype != type: board[index] = ' ' if (ny == 0 or ny == 7) and chr(piece) in 'Pp': for promote in 'QRBN' if type == BLACK else 'qrbn': board[newindex] = promote yield board else: board[newindex] = piece yield board board[index], board[newindex] = piece, newpiece elif capture_flag == MAY_CAPTURE: if newtype == EMPTY or newtype != type: board[index], board[newindex] = ' ', piece yield board board[index], board[newindex] = piece, newpiece Rather than modifying and unmodifying the board in place (which is fragile), could you not just have the compute_score function compute the score as if the move had taken place? Then you could just yield the move and the score. break elif newtype == EMPTY: board[index] = ' ' if (ny == 0 or ny == 7) and chr(piece) in 'Pp': for promote in 'QRBN' if type == BLACK else 'qrbn': board[newindex] = promote yield board else: board[newindex] = piece yield board board[index], board[newindex] = piece, newpiece else: break def pawn_moves(board, index, options): for x, y, flag, distance
Re: First attempt at a Python prog (Chess)
On 15/02/2013 11:22, Oscar Benjamin wrote: Why not make board a list of lists. Then you can do: for row in board: for piece in row: rather than using range(). Or perhaps you could have a dict that maps position tuples to pieces, e.g.: {(1, 2): 'k', ...} I'm laughing slightly here because, at the monthly London Python Dojo, we often find ourselves implementing board-game mechanics of one sort or another: Boggle, Battleships, Sliding block, Connect 4, Noughts-and-Crosses, even things like Game of Life (which has a board of sorts). And the how shall we represent the board? question is pretty much the first thing any team asks themselves. And you always get someone in favour of lists of lists, someone for one long list, someone who likes a string, someone (me) who likes a sparse dict keyed on coords, someone else likes nested defaultdicts, and occasionally more outlandish schemes. We even went to the extent of having a Dojo a few months back which was solely about implementing the ideal board for varying characteristics, but we didn't come to any conclusions :) (Also I seem to remember that the OP was advised earlier precisely to abandon lists of lists in favour of something else). TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Python trademark under attack -- the PSF needs your help
On 14/02/2013 21:52, Steven D'Aprano wrote: Hello all, The Python Software Foundation is the organisation which protects and manages the boring bits of keeping a big open source project alive: the legal and contractual parts, funding for projects, trademarks and copyrights. If you are based in Europe, or know somebody who uses Python in Europe, the PSF needs your help. There is a company in the UK who has applied to trademark the name Python and are claiming the *exclusive* right to use the word Python for software, servers, and web services over the entire European Union. You can read more about this here: http://pyfound.blogspot.com/2013/02/python-trademark-at-risk-in-europe-we.html If you have documentation of European user groups, trade associations, books, conferences, scans of job advertisements for Python programmers, software that uses some variation of Python in the name, etc. your evidence will be helpful in defeating this attempted grab of the Python name. Err... http://www.amazon.co.uk/s/ref=nb_sb_noss_1?url=search-alias%3Dapsfield-keywords=python One would think that is enough. 8,457 published results - practically all of them referring to Python (the language), none to my knowledge referring to python.co.uk Surely and open/shut case. -- Regards, Giles Coochey, CCNA, CCNAS NetSecSpec Ltd +44 (0) 7983 877438 http://www.coochey.net http://www.netsecspec.co.uk gi...@coochey.net smime.p7s Description: S/MIME Cryptographic Signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Python trademark under attack -- the PSF needs your help
Giles Coochey, 15.02.2013 12:24: On 14/02/2013 21:52, Steven D'Aprano wrote: Hello all, The Python Software Foundation is the organisation which protects and manages the boring bits of keeping a big open source project alive: the legal and contractual parts, funding for projects, trademarks and copyrights. If you are based in Europe, or know somebody who uses Python in Europe, the PSF needs your help. There is a company in the UK who has applied to trademark the name Python and are claiming the *exclusive* right to use the word Python for software, servers, and web services over the entire European Union. You can read more about this here: http://pyfound.blogspot.com/2013/02/python-trademark-at-risk-in-europe-we.html If you have documentation of European user groups, trade associations, books, conferences, scans of job advertisements for Python programmers, software that uses some variation of Python in the name, etc. your evidence will be helpful in defeating this attempted grab of the Python name. Err... http://www.amazon.co.uk/s/ref=nb_sb_noss_1?url=search-alias%3Dapsfield-keywords=python One would think that is enough. 8,457 published results - practically all of them referring to Python (the language), none to my knowledge referring to [domain stripped] Surely and open/shut case. I'm sure it's a pure marketing thing for their domain. I'd expect the number of links to their site to rise rapidly during the next weeks, that's very likely worth the bit of money they'd pay to their lawyer(s). Seriously - who's ever heard of them before this? So it worked already, didn't it? My advice: don't mention their name or their domain in any of your blog posts etc., and definitely don't link to them. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: First attempt at a Python prog (Chess)
On 15 February 2013 11:36, Tim Golden m...@timgolden.me.uk wrote: On 15/02/2013 11:22, Oscar Benjamin wrote: Why not make board a list of lists. Then you can do: for row in board: for piece in row: rather than using range(). Or perhaps you could have a dict that maps position tuples to pieces, e.g.: {(1, 2): 'k', ...} I'm laughing slightly here because, at the monthly London Python Dojo, we often find ourselves implementing board-game mechanics of one sort or another: Boggle, Battleships, Sliding block, Connect 4, Noughts-and-Crosses, even things like Game of Life (which has a board of sorts). And the how shall we represent the board? question is pretty much the first thing any team asks themselves. And you always get someone in favour of lists of lists, someone for one long list, I always get confused when doing this about which of my coordinates needs to be multiplied (i.e. whether I am in Fortran or C order). someone who likes a string, someone (me) who likes a sparse dict keyed on coords, Clearly better than the others. someone else likes nested defaultdicts, and occasionally more outlandish schemes. We even went to the extent of having a Dojo a few months back which was solely about implementing the ideal board for varying characteristics, but we didn't come to any conclusions :) In this case the innermost loop of the program is over the pieces on the board. Clearly you want a data structure that allows you to iterate directly over them. (Actually since that loop is to calculate the score I would replace it with a function that computes the change in score as a result of each move). (Also I seem to remember that the OP was advised earlier precisely to abandon lists of lists in favour of something else). Actually the suggestion was for the list of lists (instead of a flat list). Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: Python trademark under attack -- the PSF needs your help
Giles Coochey wrote: [...] If you have documentation of European user groups, trade associations, books, conferences, scans of job advertisements for Python programmers, software that uses some variation of Python in the name, etc. your evidence will be helpful in defeating this attempted grab of the Python name. Err... http://www.amazon.co.uk/s/ref=nb_sb_noss_1?url=search-alias%3Dapsfield-keywords=python One would think that is enough. Giles, thank you for taking the time to respond, but I'm sorry to say that I don't think your response is helpful. Unless you are a trademark lawyer, your intuition about how trivially easy this will be is probably not going to be accurate. You would probably think it was presumptuous for a trademark lawyer to venture an opinion on how easy it is to write some piece of software. The same applies in reverse. We need to listen to the experts in European trademark law, those who know what sort of evidence the European Trademark Office consider meaningful and significant. These people have told the Python Software Foundation what needs to be done to fight this trademark application, and trust me, spend two seconds doing a search on Amazon is *not* it. Dismissing the trademark grab as: Surely and open/shut case. is the simplest way to ensure that the PSF loses their appeal and the right to the name Python in Europe. If anyone has the sort of documentary evidence which the PSF has requested, and can scan and email them to the PSF, that will be helpful. If anyone is willing and able to donate money to the foundation to help with the legal expenses, estimated at tens of thousands of dollars, to challenge this trademark application, that will also be helpful. If you have a blog, please consider spreading the word. The PSF needs all the help it can get, but it needs to be the sort of help set out here: http://pyfound.blogspot.com/2013/02/python-trademark-at-risk-in-europe-we.html If anyone is thinking of doing something trivially easy which anyone can do, such as googling python, trust me, the PSF has already done it. The PSF is looking for the sort of help that they can't get by typing into a search engine. If anyone can help, that's great. If you can't help, then please don't discourage those who can by claiming this is trivial. Thank you. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python trademark under attack -- the PSF needs your help
On 15/02/2013 14:04, Steven D'Aprano wrote: Giles Coochey wrote: [...] If you have documentation of European user groups, trade associations, books, conferences, scans of job advertisements for Python programmers, software that uses some variation of Python in the name, etc. your evidence will be helpful in defeating this attempted grab of the Python name. Err... http://www.amazon.co.uk/s/ref=nb_sb_noss_1?url=search-alias%3Dapsfield-keywords=python One would think that is enough. Giles, thank you for taking the time to respond, but I'm sorry to say that I don't think your response is helpful. Unless you are a trademark lawyer, your intuition about how trivially easy this will be is probably not going to be accurate. You would probably think it was presumptuous for a trademark lawyer to venture an opinion on how easy it is to write some piece of software. The same applies in reverse. We need to listen to the experts in European trademark law, those who know what sort of evidence the European Trademark Office consider meaningful and significant. These people have told the Python Software Foundation what needs to be done to fight this trademark application, and trust me, spend two seconds doing a search on Amazon is *not* it. Dismissing the trademark grab as: Surely and open/shut case. is the simplest way to ensure that the PSF loses their appeal and the right to the name Python in Europe. If anyone has the sort of documentary evidence which the PSF has requested, and can scan and email them to the PSF, that will be helpful. If anyone is willing and able to donate money to the foundation to help with the legal expenses, estimated at tens of thousands of dollars, to challenge this trademark application, that will also be helpful. If you have a blog, please consider spreading the word. The PSF needs all the help it can get, but it needs to be the sort of help set out here: http://pyfound.blogspot.com/2013/02/python-trademark-at-risk-in-europe-we.html If anyone is thinking of doing something trivially easy which anyone can do, such as googling python, trust me, the PSF has already done it. The PSF is looking for the sort of help that they can't get by typing into a search engine. If anyone can help, that's great. If you can't help, then please don't discourage those who can by claiming this is trivial. Thank you. In order to register Python in Europe it has to be deemed registrable by OHIM. It is clearly not registrable as there is substantial prior use. -- Regards, Giles Coochey, CCNA, CCNAS NetSecSpec Ltd +44 (0) 7983 877438 http://www.coochey.net http://www.netsecspec.co.uk gi...@coochey.net smime.p7s Description: S/MIME Cryptographic Signature -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple 2.7.3 versions?
Robin Becker wrote: A colleague reports that this python from a recent Ubuntu x86_x64 Python 2.7.3 (default, Sep 26 2012, 21:51:14) contains a fix of this bug http://bugs.python.org/issue15212 however, all of my other Python 2.7.3s seem to lack this 'fix'. [...] Can someone explain how this 'fix' is leaking out onto his machine? The major Linux distros, including Ubuntu, tend to release their own bug fixes independently to official Python releases. I guess that the fix your colleague is seeing is from Ubuntu. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: First attempt at a Python prog (Chess)
On 15/02/2013 13:11, Oscar Benjamin wrote: On 15 February 2013 11:36, Tim Golden m...@timgolden.me.uk wrote: And the how shall we represent the board? question is pretty much the first thing any team asks themselves. And you always get someone in favour of lists of lists, someone for one long list, I always get confused when doing this about which of my coordinates needs to be multiplied (i.e. whether I am in Fortran or C order). How true. This last time, my team split into two: one half to handle the display, the other working on the algorithm. We ended up having to draw a really simple diagram on the back of an envelope with the x,y pairs written out and pass it back and forth as *everyone* kept forgetting which went first. (Also I seem to remember that the OP was advised earlier precisely to abandon lists of lists in favour of something else). Actually the suggestion was for the list of lists (instead of a flat list). Ah, ok. I'd only followed the thread casually. (And I was too lazy to go back and check). TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: First attempt at a Python prog (Chess)
On Sat, Feb 16, 2013 at 2:36 AM, Tim Golden m...@timgolden.me.uk wrote: How true. This last time, my team split into two: one half to handle the display, the other working on the algorithm. We ended up having to draw a really simple diagram on the back of an envelope with the x,y pairs written out and pass it back and forth as *everyone* kept forgetting which went first. I'm sorry, I don't follow. People forgot that x comes before y, like it does in everything algebraic? Or is it that people lost track of which axis you called 'x' and which you called 'y'? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: First attempt at a Python prog (Chess)
On 2013-02-15, Oscar Benjamin oscar.j.benja...@gmail.com wrote: if score best_score or best_score is None: You need the None check first to avoid an exception from the comparison. if best_score is None or score best_score: -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: First attempt at a Python prog (Chess)
Tim Golden writes: On 15/02/2013 13:11, Oscar Benjamin wrote: On 15 February 2013 11:36, Tim Golden wrote: And the how shall we represent the board? question is pretty much the first thing any team asks themselves. And you always get someone in favour of lists of lists, someone for one long list, I always get confused when doing this about which of my coordinates needs to be multiplied (i.e. whether I am in Fortran or C order). How true. This last time, my team split into two: one half to handle the display, the other working on the algorithm. We ended up having to draw a really simple diagram on the back of an envelope with the x,y pairs written out and pass it back and forth as *everyone* kept forgetting which went first. Surely you knew to have f1(board, x, y) for getting whatever is at (x,y) and f2(store, x, y, wev) for putting wev at (x,y). Why didn't you do that? -- http://mail.python.org/mailman/listinfo/python-list
inheritance and how to use it
Hi, I use a module downloaded from the net. Now I want to build my own class, based on the class SerialInstrument offered in this module - and in my class I would like to initialize a few things, using e. g. the method clear() offered by SerialInstrument. Hence I type: class myClass(SerialInstrument) self.clear(self) def f1(self, str1, str2) ...do something etc. I then get the message "self not know" from the statement self.clear(self). I have tried many other notations - none worked. What works is however the following code - specifying myClass without the self.clear(self) in it: x = myClass("argument") x.clear() How can I integrate this call into the definition of myClass? Thanks for advice. Bob -- http://mail.python.org/mailman/listinfo/python-list
Re: Python trademark under attack -- the PSF needs your help
On Feb 15, 2013 8:13 AM, Jason Swails jason.swa...@gmail.com wrote: SNIP I'm not offering much help here, more like wondering aloud. Doesn't Google (not to mention other software companies) have an interest staked in binding the Python name with the Python language? I can't imagine python.co.uk staging a successful campaign against one of the best-known companies in computers (that employs Python's creator, no less). That very last part is actually no longer the case: https://tech.dropbox.com/2012/12/welcome-guido/ Regardless, your general point still stands. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: inheritance and how to use it
On 02/15/2013 11:59 AM, Bob Brusa wrote: Hi, I use a module downloaded from the net. Now I want to build my own class, based on the class SerialInstrument offered in this module - and in my class I would like to initialize a few things, using e. g. the method clear() offered by SerialInstrument. Hence I type: class myClass(SerialInstrument) self.clear(self) def f1(self, str1, str2) ...do something etc. I then get the message self not know from the statement self.clear(self). I have tried many other notations - none worked. What works is however the following code - specifying myClass without the self.clear(self) in it: x = myClass(argument) x.clear() How can I integrate this call into the definition of myClass? Thanks for advice. Bob By initialize, I'll assume you want this code to execute when your class is instantiated. The way to do that is with a method called __init__(). Notice the double underscore at begin and end. class myClass(SerialInstrument): def __init__(self): self.val1 = 42 self.val2 = 31 #... also initialize the base class self.clear() def f1(self, str1, str2): You should also call the __init__() method of the base class. But I don't know whether you're using Python2 or Python3, so I won't write that call This is without knowing anything about your base class, so there may be many other adjustments to be made. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: inheritance and how to use it
Am 15.02.2013 17:59 schrieb Bob Brusa: Hi, I use a module downloaded from the net. Now I want to build my own class, based on the class SerialInstrument offered in this module - and in my class I would like to initialize a few things, using e. g. the method clear() offered by SerialInstrument. Hence I type: class myClass(SerialInstrument) self.clear(self) def f1(self, str1, str2) ...do something etc. I then get the message self not know from the statement self.clear(self). Which is absolutely correct. Besides, I would have expected some syntax errors. You try to execute the clear() method during the definition of the class, not during the instantiation. Instantiation happens in the __init__() method. You'll have to do it like this: class myClass(SerialInstrument): def __init__(self, *a, **k): # accept all parameters super(myClass, self).__init__(*a, **k) self.clear() # I don't think that self is to be given twice here... def f1(self, str1, str2): pass I have tried many other notations - none worked. What works is however the following code - specifying myClass without the self.clear(self) in it: x = myClass(argument) x.clear() Here the clear() is called on the object which has been created, so after calling the __init__() above (which is, roughly, equivalent to calling it at the bottom of __init__()). Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: inheritance and how to use it
Am 15.02.2013 18:11, schrieb Dave Angel: On 02/15/2013 11:59 AM, Bob Brusa wrote: Hi, I use a module downloaded from the net. Now I want to build my own class, based on the class SerialInstrument offered in this module - and in my class I would like to initialize a few things, using e. g. the method clear() offered by SerialInstrument. Hence I type: class myClass(SerialInstrument) self.clear(self) def f1(self, str1, str2) ...do something etc. I then get the message self not know from the statement self.clear(self). I have tried many other notations - none worked. What works is however the following code - specifying myClass without the self.clear(self) in it: x = myClass(argument) x.clear() How can I integrate this call into the definition of myClass? Thanks for advice. Bob By initialize, I'll assume you want this code to execute when your class is instantiated. The way to do that is with a method called __init__(). Notice the double underscore at begin and end. class myClass(SerialInstrument): def __init__(self): self.val1 = 42 self.val2 = 31 #... also initialize the base class self.clear() def f1(self, str1, str2): You should also call the __init__() method of the base class. But I don't know whether you're using Python2 or Python3, so I won't write that call This is without knowing anything about your base class, so there may be many other adjustments to be made. I defined (which should clear visa-buffers when instantiating the class): class myvisa(visa.SerialInstrument): def __init__ (self): self.clear() def io (self, printstr, askstr): ...cut when I run (python 2.7) a program using this class I get this: C:\Projekte\TDSsw\mypythonpython chk_clear_1.py Traceback (most recent call last): File chk_clear_1.py, line 8, in module from myvisa import * File C:\Projekte\TDSsw\mypython\myvisa.py, line 15, in module class myvisa(visa.SerialInstrument): File C:\Projekte\TDSsw\mypython\myvisa.py, line 121, in myvisa visa.Instrument.clear() TypeError: unbound method clear() must be called with Instrument instance as first argument (got nothing instead) would it help to define instead: class myvisa(visa.SerialInstrument): def __init__ (self): x = SerialInstrument(self) x.clear() #and then forget about this x? def io (self, printstr, askstr): ...cut -- http://mail.python.org/mailman/listinfo/python-list
Re:
here is the code in hier_block2.py: # # Copyright 2006,2007 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # from gnuradio_core import hier_block2_swig try: import pmt except ImportError: from gruel import pmt # # This hack forces a 'has-a' relationship to look like an 'is-a' one. # # It allows Python classes to subclass this one, while passing through # method calls to the C++ class shared pointer from SWIG. # # It also allows us to intercept method calls if needed # class hier_block2(object): Python wrapper around the C++ hierarchical block implementation. Provides convenience functions and allows proper Python subclassing. def __init__(self, name, input_signature, output_signature): Create a hierarchical block with a given name and I/O signatures. self._hb = hier_block2_swig(name, input_signature, output_signature) def __getattr__(self, name): Pass-through member requests to the C++ object. if not hasattr(self, _hb): raise RuntimeError(hier_block2: invalid state--did you forget to call gr.hier_block2.__init__ in a derived class?) return getattr(self._hb, name) def connect(self, *points): Connect two or more block endpoints. An endpoint is either a (block, port) tuple or a block instance. In the latter case, the port number is assumed to be zero. To connect the hierarchical block external inputs or outputs to internal block inputs or outputs, use 'self' in the connect call. If multiple arguments are provided, connect will attempt to wire them in series, interpreting the endpoints as inputs or outputs as appropriate. if len (points) 1: raise ValueError, (connect requires at least one endpoint; %d provided. % (len (points),)) else: if len(points) == 1: self._hb.primitive_connect(points[0].to_basic_block()) else: for i in range (1, len (points)): self._connect(points[i-1], points[i]) def _connect(self, src, dst): (src_block, src_port) = self._coerce_endpoint(src) (dst_block, dst_port) = self._coerce_endpoint(dst) self._hb.primitive_connect(src_block.to_basic_block(), src_port, dst_block.to_basic_block(), dst_port) def _coerce_endpoint(self, endp): if hasattr(endp, 'to_basic_block'): return (endp, 0) else: if hasattr(endp, __getitem__) and len(endp) == 2: return endp # Assume user put (block, port) else: raise ValueError(unable to coerce endpoint) def disconnect(self, *points): Disconnect two endpoints in the flowgraph. To disconnect the hierarchical block external inputs or outputs to internal block inputs or outputs, use 'self' in the connect call. If more than two arguments are provided, they are disconnected successively. if len (points) 1: raise ValueError, (disconnect requires at least one endpoint; %d provided. % (len (points),)) else: if len (points) == 1: self._hb.primitive_disconnect(points[0].to_basic_block()) else: for i in range (1, len (points)): self._disconnect(points[i-1], points[i]) def _disconnect(self, src, dst): (src_block, src_port) = self._coerce_endpoint(src) (dst_block, dst_port) = self._coerce_endpoint(dst) self._hb.primitive_disconnect(src_block.to_basic_block(), src_port, dst_block.to_basic_block(), dst_port) def msg_connect(self, src, srcport, dst, dstport): self.primitive_msg_connect(src.to_basic_block(), srcport, dst.to_basic_block(), dstport); def msg_disconnect(self, src, srcport, dst, dstport): self.primitive_msg_disconnect(src.to_basic_block(), srcport, dst.to_basic_block(), dstport); def message_port_register_hier_in(self, portname): self.primitive_message_port_register_hier_in(pmt.pmt_intern(portname)); def
Re: First attempt at a Python prog (Chess)
On Sat, Feb 16, 2013 at 2:36 AM, Tim Golden m...@timgolden.me.uk wrote: How true. This last time, my team split into two: one half to handle the display, the other working on the algorithm. We ended up having to draw a really simple diagram on the back of an envelope with the x,y pairs written out and pass it back and forth as *everyone* kept forgetting which went first. On 15/02/2013 15:49, Chris Angelico wrote: I'm sorry, I don't follow. People forgot that x comes before y, like it does in everything algebraic? Or is it that people lost track of which axis you called 'x' and which you called 'y'? On 15/02/2013 16:48, Jussi Piitulainen wrote: Surely you knew to have f1(board, x, y) for getting whatever is at (x,y) and f2(store, x, y, wev) for putting wev at (x,y). Why didn't you do that? To be honest I don't remember exactly what we did get confused over; it was probably whether our origin was top left and/or whether we were storing in row or in column order. But in any case, my experience is that stuff which is perfectly easy to reason about and write as Jussi has above when you're just coding quietly on your own becomes a confused ball of mess as soon as you're part of a Dojo team with 60 minutes to come up with a solution. (Not saying that we couldn't have managed better; merely that we didn't). TJG -- http://mail.python.org/mailman/listinfo/python-list
Re:
oh and the version of python is 2.7.3 THanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: inheritance and how to use it
Am 15.02.2013 18:06, schrieb Thomas Rachel: Am 15.02.2013 17:59 schrieb Bob Brusa: Hi, I use a module downloaded from the net. Now I want to build my own class, based on the class SerialInstrument offered in this module - and in my class I would like to initialize a few things, using e. g. the method clear() offered by SerialInstrument. Hence I type: class myClass(SerialInstrument) self.clear(self) def f1(self, str1, str2) ...do something etc. I then get the message self not know from the statement self.clear(self). Which is absolutely correct. Besides, I would have expected some syntax errors. You try to execute the clear() method during the definition of the class, not during the instantiation. Instantiation happens in the __init__() method. You'll have to do it like this: class myClass(SerialInstrument): def __init__(self, *a, **k): # accept all parameters super(myClass, self).__init__(*a, **k) self.clear() # I don't think that self is to be given twice here... def f1(self, str1, str2): pass I have tried many other notations - none worked. What works is however the following code - specifying myClass without the self.clear(self) in it: x = myClass(argument) x.clear() Here the clear() is called on the object which has been created, so after calling the __init__() above (which is, roughly, equivalent to calling it at the bottom of __init__()). Thomas Thomas, This does not work either. The error comes while python analyses the code - even prior to executing my program But what I want to achieve is that this clear() is executed when the class is instantiatedwhich I do with the code x = myClass(COM7) Of course, when scanning the class definition, the argument COM7 is not yet known. Thanks for further help. Bob -- http://mail.python.org/mailman/listinfo/python-list
Re: First attempt at a Python prog (Chess)
On 2013-02-15 16:17, Neil Cerutti wrote: On 2013-02-15, Oscar Benjamin oscar.j.benja...@gmail.com wrote: if score best_score or best_score is None: You need the None check first to avoid an exception from the comparison. Only in Python 3. if best_score is None or score best_score: -- http://mail.python.org/mailman/listinfo/python-list
Re: First attempt at a Python prog (Chess)
Only in Python 3. Use best practices always, not just when you have to. *Matt Jones* On Fri, Feb 15, 2013 at 11:52 AM, MRAB pyt...@mrabarnett.plus.com wrote: On 2013-02-15 16:17, Neil Cerutti wrote: On 2013-02-15, Oscar Benjamin oscar.j.benja...@gmail.com wrote: if score best_score or best_score is None: You need the None check first to avoid an exception from the comparison. Only in Python 3. if best_score is None or score best_score: -- http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: inheritance and how to use it
On 02/15/2013 12:23 PM, Bob Brusa wrote: Am 15.02.2013 18:11, schrieb Dave Angel: On 02/15/2013 11:59 AM, Bob Brusa wrote: Hi, I use a module downloaded from the net. Now I want to build my own class, based on the class SerialInstrument offered in this module - and in my class I would like to initialize a few things, using e. g. the method clear() offered by SerialInstrument. Hence I type: class myClass(SerialInstrument) self.clear(self) def f1(self, str1, str2) ...do something etc. I then get the message self not know from the statement self.clear(self). I have tried many other notations - none worked. What works is however the following code - specifying myClass without the self.clear(self) in it: x = myClass(argument) x.clear() How can I integrate this call into the definition of myClass? Thanks for advice. Bob By initialize, I'll assume you want this code to execute when your class is instantiated. The way to do that is with a method called __init__(). Notice the double underscore at begin and end. class myClass(SerialInstrument): def __init__(self): self.val1 = 42 self.val2 = 31 #... also initialize the base class self.clear() def f1(self, str1, str2): You should also call the __init__() method of the base class. But I don't know whether you're using Python2 or Python3, so I won't write that call This is without knowing anything about your base class, so there may be many other adjustments to be made. I defined (which should clear visa-buffers when instantiating the class): class myvisa(visa.SerialInstrument): def __init__ (self): self.clear() I still don't see the call to the superclass __init__(). Get that code from Bob Brusa's message. def io (self, printstr, askstr): ...cut when I run (python 2.7) a program using this class I get this: C:\Projekte\TDSsw\mypythonpython chk_clear_1.py Traceback (most recent call last): File chk_clear_1.py, line 8, in module from myvisa import * File C:\Projekte\TDSsw\mypython\myvisa.py, line 15, in module class myvisa(visa.SerialInstrument): File C:\Projekte\TDSsw\mypython\myvisa.py, line 121, in myvisa visa.Instrument.clear() TypeError: unbound method clear() must be called with Instrument instance as first argument (got nothing instead) would it help to define instead: class myvisa(visa.SerialInstrument): def __init__ (self): x = SerialInstrument(self) x.clear()#and then forget about this x? def io (self, printstr, askstr): ...cut Besides being indented wrong (did you even try it ?), that code doesn't begin to be what you want. You're calling clear on some other instance, then throwing that instance away, and not clearing the one you just created. But as I said before, you haven't said word-one about what the base class looks like, or how it's supposed to be used, nor when clear() is supposed to be called. You also aren't showing us the code which got the error, so I can't see how we could help. What does the code around line 115 look like? Is it part of the same class definition? -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: inheritance and how to use it
On 02/15/2013 12:50 PM, Bob Brusa wrote: Am 15.02.2013 18:06, schrieb Thomas Rachel: Am 15.02.2013 17:59 schrieb Bob Brusa: Hi, I use a module downloaded from the net. Now I want to build my own class, based on the class SerialInstrument offered in this module - and in my class I would like to initialize a few things, using e. g. the method clear() offered by SerialInstrument. Hence I type: class myClass(SerialInstrument) self.clear(self) def f1(self, str1, str2) ...do something etc. I then get the message self not know from the statement self.clear(self). Which is absolutely correct. Besides, I would have expected some syntax errors. You try to execute the clear() method during the definition of the class, not during the instantiation. Instantiation happens in the __init__() method. You'll have to do it like this: class myClass(SerialInstrument): def __init__(self, *a, **k): # accept all parameters super(myClass, self).__init__(*a, **k) self.clear() # I don't think that self is to be given twice here... def f1(self, str1, str2): pass I have tried many other notations - none worked. What works is however the following code - specifying myClass without the self.clear(self) in it: x = myClass(argument) x.clear() Here the clear() is called on the object which has been created, so after calling the __init__() above (which is, roughly, equivalent to calling it at the bottom of __init__()). Thomas Thomas, This does not work either. The error comes while python analyses the code - even prior to executing my program But what I want to achieve is that this clear() is executed when the class is instantiatedwhich I do with the code x = myClass(COM7) Of course, when scanning the class definition, the argument COM7 is not yet known. Thanks for further help. Bob Your error is on line 115, so what does it look like, and its context? I expect you're never getting to the line x = myClass(). -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: inheritance and how to use it
Am 15.02.2013 19:03, schrieb Dave Angel: On 02/15/2013 12:23 PM, Bob Brusa wrote: Am 15.02.2013 18:11, schrieb Dave Angel: On 02/15/2013 11:59 AM, Bob Brusa wrote: Hi, I use a module downloaded from the net. Now I want to build my own class, based on the class SerialInstrument offered in this module - and in my class I would like to initialize a few things, using e. g. the method clear() offered by SerialInstrument. Hence I type: class myClass(SerialInstrument) self.clear(self) def f1(self, str1, str2) ...do something etc. I then get the message self not know from the statement self.clear(self). I have tried many other notations - none worked. What works is however the following code - specifying myClass without the self.clear(self) in it: x = myClass(argument) x.clear() How can I integrate this call into the definition of myClass? Thanks for advice. Bob By initialize, I'll assume you want this code to execute when your class is instantiated. The way to do that is with a method called __init__(). Notice the double underscore at begin and end. class myClass(SerialInstrument): def __init__(self): self.val1 = 42 self.val2 = 31 #... also initialize the base class self.clear() def f1(self, str1, str2): You should also call the __init__() method of the base class. But I don't know whether you're using Python2 or Python3, so I won't write that call This is without knowing anything about your base class, so there may be many other adjustments to be made. I defined (which should clear visa-buffers when instantiating the class): class myvisa(visa.SerialInstrument): def __init__ (self): self.clear() I still don't see the call to the superclass __init__(). Get that code from Bob Brusa's message. def io (self, printstr, askstr): ...cut when I run (python 2.7) a program using this class I get this: C:\Projekte\TDSsw\mypythonpython chk_clear_1.py Traceback (most recent call last): File chk_clear_1.py, line 8, in module from myvisa import * File C:\Projekte\TDSsw\mypython\myvisa.py, line 15, in module class myvisa(visa.SerialInstrument): File C:\Projekte\TDSsw\mypython\myvisa.py, line 121, in myvisa visa.Instrument.clear() TypeError: unbound method clear() must be called with Instrument instance as first argument (got nothing instead) would it help to define instead: class myvisa(visa.SerialInstrument): def __init__ (self): x = SerialInstrument(self) x.clear()#and then forget about this x? def io (self, printstr, askstr): ...cut Besides being indented wrong (did you even try it ?), that code doesn't begin to be what you want. You're calling clear on some other instance, then throwing that instance away, and not clearing the one you just created. But as I said before, you haven't said word-one about what the base class looks like, or how it's supposed to be used, nor when clear() is supposed to be called. You also aren't showing us the code which got the error, so I can't see how we could help. What does the code around line 115 look like? Is it part of the same class definition? Dave, to make it more clear, I attach a cut-down version of my program. It includes comments to explain in more detail what my problem is. Bob / edit history: 15-02-2013 Creation import sys import visa import time class myvisa(visa.SerialInstrument): provide utilities to handle the instrument #def __init__ (): this doe not work #self.clear() def io (self, printstr, askstr): combines a print and an ask-string into a single call res = 0 try: antw = self.ask(askstr) except: antw = time-out res = 1 print printstr + antw return res strich = | ; pfeil = - print start of program q1.py iodev = COM9 tds = myvisa(iodev, baud_rate = 57600) tds.clear() # this call I want to be called automatically when instantiating the class cmd = *idn?; tds.io(pfeil+cmd+strich,cmd) cmd = status?; tds.write(cmd) # exit with something in the visa-buffer and this will # lead to a de-chronization between write and reads when # executing a next program print end of program -- http://mail.python.org/mailman/listinfo/python-list
Re: inheritance and how to use it
On 02/15/2013 01:28 PM, Bob Brusa wrote: snip to make it more clear, I attach a cut-down version of my program. It includes comments to explain in more detail what my problem is. Bob Good job cutting down the sample. Naturally, it'd have been smart to tell us you don't get the same traceback this way. But it looks like the first problem is in that missing __init__() method. Instead of saying it doe not work it'd be good to examine just what error traceback you got when you did have it there. I suspect it's because you're passing parameters in when you invoke it (iodev, baud_rate = 57600) but you don't have any arguments. You don't even have the self argument. You are also missing the super call, as outlined earlier in this thread. So the base class won't being properly initialized once you fix the first problem. Reread Thomas Rachel's message, and if you still can't make it work, tell us what errors you still get, or what you don't understand. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Awsome Python - chained exceptions
On 14.02.13 08:39, Steven D'Aprano wrote: Here is one example of using raise to re-raise an exception you have just caught: import errno paths = [here, there, somewhere else] for location in paths: filename = os.path.join(location, prefs.ini) try: f = open(filename) except IOError as e: if e.errno != errno.ENOENT: # File not found. raise In Python 3.3: try: f = open(filename) except FileNotFound: pass But not all errnos have special OSError subclasses. -- http://mail.python.org/mailman/listinfo/python-list
Exception running GNU module op25_grc.py : AttributeError: 'gr_hier_block2_sptr' object has no attribute 'set_callback'
I am using using ubuntu 12.10 i am trying to run a python block, namely OP25, in GNU Radio Companion v3.6.3-35-g4435082f, which uses python version 2.7.3 for some reason although python3.2 is in the lib folder. I run the following trace command in terminal: ~$ python -m trace --count -C . op25_grc.py Here is the output with an error: Imported legacy fsk4 Using Volk machine: ssse3_32 Traceback (most recent call last): File /usr/lib/python2.7/runpy.py, line 162, in run_module_as_main _main__, fname, loader, pkg_name) File /usr/lib/python2.7/runpy.py, line 72, in run_code exec code in run_globals File /usr/lib/python2.7/trace.py, line 819, in main() File /usr/lib/python2.7/trace.py, line 807, in main t.runctx(code, globs, globs) File /usr/lib/python2.7/trace.py, line 513, in runctx exec cmd in globals, locals File op25_grc.py, line 493, in tb = op25_grc() File op25_grc.py, line 231, in __init_ self.wxgui_fftsink2_0_0.set_callback(wxgui_fftsink2_0_0_callback) File /usr/local/lib/python2.7/dist-packages/gnuradio/gr/hier_block2.py, line 54, in getattr return getattr(self._hb, name) AttributeError: 'gr_hier_block2_sptr' object has no attribute 'set_callback' The code for op25_grc.py: #!/usr/bin/env python ## # Gnuradio Python Flow Graph # Title: Op25 Grc # Generated: Wed Feb 13 19:37:41 2013 ## from baz import message_callback from baz import op25 from gnuradio import audio from gnuradio import blks2 from gnuradio import eng_notation from gnuradio import gr from gnuradio import window from gnuradio.eng_option import eng_option from gnuradio.gr import firdes from gnuradio.wxgui import fftsink2 from gnuradio.wxgui import forms from gnuradio.wxgui import scopesink2 from gnuradio.wxgui import waterfallsink2 from grc_gnuradio import wxgui as grc_wxgui from optparse import OptionParser import ConfigParser import math import wx class op25_grc(grc_wxgui.top_block_gui): def __init__(self): grc_wxgui.top_block_gui.__init__(self, title=Op25 Grc) _icon_path = /usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ## # Variables ## self._config_freq_config = ConfigParser.ConfigParser() self._config_freq_config.read(.grc_op25) try: config_freq = self._config_freq_config.getfloat(main, freq) except: config_freq = 434075000 self.config_freq = config_freq self.freq = freq = config_freq self._config_xlate_offset_config = ConfigParser.ConfigParser() self._config_xlate_offset_config.read(.grc_op25) try: config_xlate_offset = self._config_xlate_offset_config.getfloat(main, xlate_offset) except: config_xlate_offset = 0 self.config_xlate_offset = config_xlate_offset self.click_freq = click_freq = freq-config_xlate_offset self.xlate_offset_fine = xlate_offset_fine = 0 self.xlate_offset = xlate_offset = freq-click_freq self.samp_rate = samp_rate = 48000 self.samp_per_sym = samp_per_sym = 5+1 self.decim = decim = 20 self._config_xlate_bandwidth_config = ConfigParser.ConfigParser() self._config_xlate_bandwidth_config.read(.grc_rtl) try: config_xlate_bandwidth = self._config_xlate_bandwidth_config.getfloat(main, xlate_bandwidth) except: config_xlate_bandwidth = 24000 self.config_xlate_bandwidth = config_xlate_bandwidth self.auto_tune_offset = auto_tune_offset = 0 self.xlate_bandwidth = xlate_bandwidth = config_xlate_bandwidth self.variable_static_text_0 = variable_static_text_0 = freq+xlate_offset+xlate_offset_fine+auto_tune_offset self.pre_channel_rate = pre_channel_rate = samp_rate/decim self.gain = gain = 20 self.fine_click_freq = fine_click_freq = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE*samp_per_sym self.auto_tune_offset_freq = auto_tune_offset_freq = auto_tune_offset*op25.SYMBOL_DEVIATION self.audio_mul = audio_mul = 2 ## # Message Queues ## op25_decoder_0_msgq_out = baz_message_callback_0_msgq_in = gr.msg_queue(2) ## # Blocks ##
Re: Implicit conversion to boolean in if and while statements
On 10.02.13 13:37, Steven D'Aprano wrote: Unfortunately, Python has a minor design flaw. One of the most common use-cases for sets is for membership testing of literal sets: def example(arg): if arg in {'spam', 'ham', 'eggs', 'cheese'}: ... Unfortunately, set literals create *mutable* sets, not frozensets. That means that the compiler wastes time and memory creating am over-allocated mutable set object. If set literals created immutable frozensets, there would be some nice opportunities for the compiler to optimize this use-case. CPython 3.2 optimizes this special case and creates a constant frozenset. $ echo arg in {'spam', 'ham', 'eggs', 'cheese'} | python3.2 -m dis - 1 0 LOAD_NAME0 (arg) 3 LOAD_CONST 5 (frozenset({'cheese', 'eggs', 'ham', 'spam'})) 6 COMPARE_OP 6 (in) 9 POP_TOP 10 LOAD_CONST 4 (None) 13 RETURN_VALUE -- http://mail.python.org/mailman/listinfo/python-list
Re: How would you do this?
On Thursday, February 14, 2013 5:19:51 PM UTC-7, eli m wrote: On Thursday, February 14, 2013 4:09:37 PM UTC-8, Oscar Benjamin wrote: On 14 February 2013 23:34, eli m techgeek...@gmail.com wrote: I want to make a guess the number game (Which i have), but i want to make the computer play the game against itself. How would i do this? Your question would make more sense if you would show your program and also explain how you would like the output to look when the computer played itself. Oscar This is my code: #Guess the number game import random run = 0 while run == 0: print (I am thinking of a number between 1 and 100) num = random.randint(1, 100) num = int(num) guesses = 0 guessestaken = 0 while guesses == 0: try: guess = raw_input(Your guess:) guess = int(guess) guessestaken = (guessestaken) + 1 guessestaken = int(guessestaken) if guess == (num): print 'Correct! It took you', int(guessestaken), 'guesses!' playagain = raw_input(Do you want to play again?) if playagain == yes: guesses = 1 if playagain == no: run = 1 if guess num: print (My number is lower) if guess num: print (My number is higher) except TypeError, err: print (Not a valid number) I would like it to show the computer guessing the numbers. Hello. I think you code is Python 2.7. My solution uses Python 3 but I can help you convert it if the solution is what you are looking for. My approach as to create a class that tries to guess the right number. This code also eliminates raw_input. I didn't know how important having it respond via raw_input is to you. Code follows: import random import sys class Guesser(): def __init__(self): self.low = 1 self.high = 100 def getRand(self,x,y): num = random.randint(x,y) return num def guess(self,guess,boundary): if boundary == : self.low = guess elif boundary == : self.high = guess else: self.low = 1 self.high = 100 return self.getRand(self.low,self.high) def playagain(self): choice = ['Y','N'] return random.choice(choice) run = 0 while run == 0: guess=1 guesses=0 guessestaken = 0 comp = Guesser() num = comp.getRand(1,100) result = print (I am thinking of a number between 1 and 100) while guesses == 0: guessestaken += 1 try: guess = comp.guess(guess,result) # replaces input except: print(Unexpected error:, sys.exc_info()[0]) raise print(Your guess:, guess) if guess == num: print('Correct! It took you', guessestaken, 'guesses!') guesses = 1 elif guess num: print(My number is lower) result = else: print(My number is higher) result = print(Do you want to play again?) playagain = comp.playagain()# replaces input print(playagain) if playagain == N: run = 1 Please let me know if you have questions or would like to discuss this solution further. Cheers! vduncan -- http://mail.python.org/mailman/listinfo/python-list
python math problem
I am trying to calculate the coordinates at the end of a line. The length and angle of the line are given and I am using the following formula: x = (math.sin(math.radians(angle)) * length) y = (math.cos(math.radians(angle)) * length) The following are sample answers in the format (x, y) to the given length/angle values of the line: 120/0 = (0.0, 25.0) 120/89 = (24.9961923789, 0.436310160932) 120/90 = (25.0, 1.53075794228e-15) 120/91 = (24.9961923789, -0.436310160932) Why am I getting a string number instead of the expected answer for 120/90 which should be (25.0, 0.0). This happens at all multiples of 90 (i.e. 180 and 270) -- Kene :: kemen...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: inheritance and how to use it
Am 15.02.2013 19:06, schrieb Dave Angel: On 02/15/2013 12:50 PM, Bob Brusa wrote: Am 15.02.2013 18:06, schrieb Thomas Rachel: Am 15.02.2013 17:59 schrieb Bob Brusa: Hi, I use a module downloaded from the net. Now I want to build my own class, based on the class SerialInstrument offered in this module - and in my class I would like to initialize a few things, using e. g. the method clear() offered by SerialInstrument. Hence I type: class myClass(SerialInstrument) self.clear(self) def f1(self, str1, str2) ...do something etc. I then get the message self not know from the statement self.clear(self). Which is absolutely correct. Besides, I would have expected some syntax errors. You try to execute the clear() method during the definition of the class, not during the instantiation. Instantiation happens in the __init__() method. You'll have to do it like this: class myClass(SerialInstrument): def __init__(self, *a, **k): # accept all parameters super(myClass, self).__init__(*a, **k) self.clear() # I don't think that self is to be given twice here... def f1(self, str1, str2): pass I have tried many other notations - none worked. What works is however the following code - specifying myClass without the self.clear(self) in it: x = myClass(argument) x.clear() Here the clear() is called on the object which has been created, so after calling the __init__() above (which is, roughly, equivalent to calling it at the bottom of __init__()). Thomas Thomas, This does not work either. The error comes while python analyses the code - even prior to executing my program But what I want to achieve is that this clear() is executed when the class is instantiatedwhich I do with the code x = myClass(COM7) Of course, when scanning the class definition, the argument COM7 is not yet known. Thanks for further help. Bob Your error is on line 115, so what does it look like, and its context? I expect you're never getting to the line x = myClass(). Hi Dave and Thomas, yep - now its working: See also attachment q4.py C:\Projekte\TDSsw\mypythonpython q4.py start of program q4.py -*idn? | SPEAG,TDS,RUID:00.00-00.00 FW:2. SID:00.00-00.00 FW:01.00.00 end of program Thanks for your kind help - bob / edit history: 15-02-2013 Creation import sys import visa import time class myvisa(visa.SerialInstrument): provide utilities to handle the instrument def __init__(self, addr): # accept all parameters super(myvisa, self).__init__(addr, baud_rate = 57600) self.clear() # Thomas does not think that self is to be given twice # he is right! def io (self, printstr, askstr): combines a print and an ask-string into a single call res = 0 try: antw = self.ask(askstr) except: antw = time-out res = 1 print printstr + antw return res strich = | ; pfeil = - print start of program q4.py iodev = COM7 tds = myvisa(iodev) cmd = *idn?; tds.io(pfeil+cmd+strich,cmd) cmd = status?; tds.write(cmd) # exit with something in the visa-buffer and this will # lead to a de-chronization between write and reads when # executing a next program print end of program -- http://mail.python.org/mailman/listinfo/python-list
Re: python math problem
On 02/15/2013 11:39 AM, Kene Meniru wrote: I am trying to calculate the coordinates at the end of a line. The length and angle of the line are given and I am using the following formula: x = (math.sin(math.radians(angle)) * length) y = (math.cos(math.radians(angle)) * length) The following are sample answers in the format (x, y) to the given length/angle values of the line: 120/0 = (0.0, 25.0) 120/89 = (24.9961923789, 0.436310160932) 120/90 = (25.0, 1.53075794228e-15) 120/91 = (24.9961923789, -0.436310160932) Why am I getting a string number instead of the expected answer for 120/90 which should be (25.0, 0.0). This happens at all multiples of 90 (i.e. 180 and 270) Floating point calculations on a computer (ANY computer, and ANY programming language) can *never* be expected to be exact! (Think about 1/3 , PI, and sqrt(2) for instance.)The values written out as 1.53075794228e-15 is the (scientific notation) representation of .00153075794228. Is that not close enough to zero for your purposes? (Or is it that you don't understand the 'e-15' portion of the output?) -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo/python-list
Re: python math problem
On Fri, Feb 15, 2013 at 2:39 PM, Kene Meniru kene.men...@illom.org wrote: I am trying to calculate the coordinates at the end of a line. The length and angle of the line are given and I am using the following formula: x = (math.sin(math.radians(angle)) * length) y = (math.cos(math.radians(angle)) * length) The following are sample answers in the format (x, y) to the given length/angle values of the line: 120/0 = (0.0, 25.0) 120/89 = (24.9961923789, 0.436310160932) 120/90 = (25.0, 1.53075794228e-15) This is not a string, it is scientific notion for 1.53... times 10 to the -15th power. Because of rounding errors caused by doing floating point math on in binary, you get a very small number instead of 0. 120/91 = (24.9961923789, -0.436310160932) Why am I getting a string number instead of the expected answer for 120/90 which should be (25.0, 0.0). This happens at all multiples of 90 (i.e. 180 and 270) -- Kene :: kemen...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python math problem
Am 15.02.2013 20:39, schrieb Kene Meniru: I am trying to calculate the coordinates at the end of a line. The length and angle of the line are given and I am using the following formula: x = (math.sin(math.radians(angle)) * length) y = (math.cos(math.radians(angle)) * length) The following are sample answers in the format (x, y) to the given length/angle values of the line: 120/0 = (0.0, 25.0) 120/89 = (24.9961923789, 0.436310160932) 120/90 = (25.0, 1.53075794228e-15) 120/91 = (24.9961923789, -0.436310160932) Why am I getting a string number instead of the expected answer for 120/90 which should be (25.0, 0.0). This happens at all multiples of 90 (i.e. 180 and 270) Kene, are you sure your length is 120? It seems to be 25. I did these calculations with length = 25 and then your numbers make perfect sense. Bob -- http://mail.python.org/mailman/listinfo/python-list
Re: Implicit conversion to boolean in if and while statements
On Tue, Feb 12, 2013 at 10:48 AM, Rick Johnson rantingrickjohn...@gmail.com wrote: On Monday, February 11, 2013 11:55:19 PM UTC-6, Chris Angelico wrote: On Tue, Feb 12, 2013 at 12:06 PM, 8 Dihedral wrote: A permanently mutated list is a tuple of constant objects. I nominate this line as bemusing head-scratcher of the week. Actually the statement is fact IF you can grok it through the eyes of clarity. A permanently mutated list... A list that has been mutated permanently, that is, it cannot be changed back into a list. psst: i have a sneaking suspicion that he his referring to tuples, let's see. FYI, the general consensus here is that he (8 Dihedral) is a bot. It posts in non sequiturs and fails to respond meaningfully to direct queries. A few months ago I posed an obvious Turing test for it, which it failed. http://thread.gmane.org/gmane.comp.python.general/718489 Your naive effort to extort meaning from its nonsense is admirable, however. -- http://mail.python.org/mailman/listinfo/python-list
Re: python math problem
Bob Brusa wrote: Kene, are you sure your length is 120? It seems to be 25. I did these calculations with length = 25 and then your numbers make perfect sense. Bob Thanks. You are right I was actually using 25 -- Kene :: kemen...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python math problem
Joel Goldstick wrote: This is not a string, it is scientific notion for 1.53... times 10 to the -15th power. Because of rounding errors caused by doing floating point math on in binary, you get a very small number instead of 0. I was just doing some testing and it was not equating to zero. Perhaps if I rounded it up I may be more successful. -- Kene :: kemen...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Curious to see alternate approach on a search/replace via regex
On 08.02.13 03:08, Ian Kelly wrote: I think what we're seeing here is that the time needed to look up the compiled regular expression in the cache is a significant fraction of the time needed to actually execute it. There is a bug issue for this. See http://bugs.python.org/issue16389 . -- http://mail.python.org/mailman/listinfo/python-list
New User-Need-Help
Hi, I am very new to Python, I am using the e-book Python Programming for the Absolute Beginner and am starting with a simple Game Over Program. This is the code:which is extremely simple! printGame Over raw_input(\n\nPress Enter Key to exit) That's it. It is supposed to bring up a window that says Game Over and at the bottom say Press enter Key to exit and when you press the enter key it is supposed to exit(big suprise). But all it does is highlight raw_input and says invalid syntax Now, if I just put print Game Over then it says Game Over UNDERNEATH the code I just printed! now I am following the book to the *pixel* and that is not what is supposed to happen! Please email me back as soon as you get this...(if you are not to busy). Thanks,Nicholas -- http://mail.python.org/mailman/listinfo/python-list
Re: New User-Need-Help
On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski spiceninj...@gmail.comwrote: Hi, I am very new to Python, I am using the e-book Python Programming for the Absolute Beginner and am starting with a simple Game Over Program. This is the code:which is extremely simple! printGame Over raw_input(\n\nPress Enter Key to exit) welcome Nicholas One important thing about python is indentation is important. You have presented your code in a way that can't be. Can you actually copy your program and paste it into an email message. Also, Windows, Linux, Mac? That's it. It is supposed to bring up a window that says Game Over and at the bottom say Press enter Key to exit and when you press the enter key it is supposed to exit(big suprise). But all it does is highlight raw_input and says invalid syntax Now, if I just put print Game Over then it says Game Over UNDERNEATH the code I just printed! now I am following the book to the *pixel* and that is not what is supposed to happen! Please email me back as soon as you get this...(if you are not to busy). Thanks,Nicholas -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple 2.7.3 versions?
On 2/15/2013 5:53 AM, Robin Becker wrote: A colleague reports that this python from a recent Ubuntu x86_x64 Python 2.7.3 (default, Sep 26 2012, 21:51:14) Look at the date. This is Ubuntu's updated 2.7.3. It really should be '2.7.3.1' or '2.7.3b' or '2.7.3-ubuntu' or '2.7.3 -- 2012 Sep 6 update' or even '2.7.4a0'. contains a fix of this bug http://bugs.python.org/issue15212 which will be in 2.7.4 for everyone else. Can someone explain how this 'fix' is leaking out onto his machine? Ubuntu considers getting fixes to people early a feature, not a 'leak'. On all the other machines I have access to I'm seeing something similar to this Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Notice the date again -- the original release date of 2.7.3. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: New User-Need-Help
Am Freitag, 15. Februar 2013 schrieb Joel Goldstick : On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski spiceninj...@gmail.com javascript:_e({}, 'cvml', 'spiceninj...@gmail.com'); wrote: Hi, I am very new to Python, I am using the e-book Python Programming for the Absolute Beginner and am starting with a simple Game Over Program. This is the code:which is extremely simple! printGame Over raw_input(\n\nPress Enter Key to exit) welcome Nicholas One important thing about python is indentation is important. You have presented your code in a way that can't be. Can you actually copy your program and paste it into an email message. Also, Windows, Linux, Mac? That's it. It is supposed to bring up a window that says Game Over and at the bottom say Press enter Key to exit and when you press the enter key it is supposed to exit(big suprise). But all it does is highlight raw_input and says invalid syntax Now, if I just put print Game Over then it says Game Over UNDERNEATH the code I just printed! now I am following the book to the *pixel* and that is not what is supposed to happen! Please email me back as soon as you get this...(if you are not to busy). Thanks,Nicholas -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com Nicholas, Could it be that you use a more recent version ( e. g. 3.3) of python? I found that raw_input is indeed no longer recognized. Use input instead and your code will work - at least it did so with python 3.3 on my iPad. Bob -- Von Gmail Mobile gesendet -- http://mail.python.org/mailman/listinfo/python-list
Re: New User-Need-Help
In mailman.1848.1360964736.2939.python-l...@python.org Deborah Piotrowski spiceninj...@gmail.com writes: This is the code:which is extremely simple! printGame Over raw_input(\n\nPress Enter Key to exit) That's it. Does your code really have everything on one line, as you posted? If so, that's the problem. It should be broken into two separate lines: print Game Over raw_input(\n\nPress Enter Key to exit) I can't believe the book put all that code on one line... -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Howto parse a string using a char in python
Hi, I am looking for the python2.7 function(s) to parse a string from a colon character : Sounds simple enough. For example, a string like 123456:789. I just need the 123456 substring.(left of the :) I have looked at regular expressions and string functions, so far no luck. Custom function required? Thank you. - Spoog98 -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple 2.7.3 versions?
In article kfmdu8$iim$1...@ger.gmane.org, Terry Reedy tjre...@udel.edu wrote: On 2/15/2013 5:53 AM, Robin Becker wrote: On all the other machines I have access to I'm seeing something similar to this Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Notice the date again -- the original release date of 2.7.3. FYI - the date is a build date; it doesn't tell you much about the source code base used for that Python build. The tag to the left of it *may* tell you something, for example, if the build is made from an hg checkout or if the build is from an official tagged source tarball. In this case, default doesn't tell much. But if it had the hg rev used for the checkout, you have some indication of what it contains. The official rev tags for each release are available here: http://hg.python.org/cpython/tags -- Ned Deily, n...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
Re: New User-Need-Help
print Game Over input(\n\nPress the Enter Key to Exit) Syntax Error: Invalid Syntax On Fri, Feb 15, 2013 at 3:48 PM, Bob Brusa bob.br...@gmail.com wrote: Am Freitag, 15. Februar 2013 schrieb Joel Goldstick : On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski spiceninj...@gmail.com wrote: Hi, I am very new to Python, I am using the e-book Python Programming for the Absolute Beginner and am starting with a simple Game Over Program. This is the code:which is extremely simple! printGame Over raw_input(\n\nPress Enter Key to exit) welcome Nicholas One important thing about python is indentation is important. You have presented your code in a way that can't be. Can you actually copy your program and paste it into an email message. Also, Windows, Linux, Mac? That's it. It is supposed to bring up a window that says Game Over and at the bottom say Press enter Key to exit and when you press the enter key it is supposed to exit(big suprise). But all it does is highlight raw_input and says invalid syntax Now, if I just put print Game Over then it says Game Over UNDERNEATH the code I just printed! now I am following the book to the *pixel* and that is not what is supposed to happen! Please email me back as soon as you get this...(if you are not to busy). Thanks,Nicholas -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com Nicholas, Could it be that you use a more recent version ( e. g. 3.3) of python? I found that raw_input is indeed no longer recognized. Use input instead and your code will work - at least it did so with python 3.3 on my iPad. Bob -- Von Gmail Mobile gesendet -- Nicholas J. Piotrowski -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto parse a string using a char in python
On 2013-02-15 18:04, Steve Goodwin wrote: Hi, I am looking for the python2.7 function(s) to parse a string from a colon character : Sounds simple enough. For example, a string like 123456:789. I just need the 123456 substring.(left of the :) I have looked at regular expressions and string functions, so far no luck. Custom function required? With just a single character, it sounds like you want something like whole = 123456:789 parts = whole.split(':') # or .split(':', 1) interesting = parts[0] No custom function needed. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: New User-Need-Help
print uses the new syntax e.g. print(example) in 3.r Sent from my BlackBerry® wireless device -Original Message- From: Deborah Piotrowski spiceninj...@gmail.com Date: Fri, 15 Feb 2013 16:08:17 To: Bob Brusabob.br...@gmail.com Cc: Joel Goldstickjoel.goldst...@gmail.com; python-list@python.orgpython-list@python.org Subject: Re: New User-Need-Help print Game Over input(\n\nPress the Enter Key to Exit) Syntax Error: Invalid Syntax On Fri, Feb 15, 2013 at 3:48 PM, Bob Brusa bob.br...@gmail.com wrote: Am Freitag, 15. Februar 2013 schrieb Joel Goldstick : On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski spiceninj...@gmail.com wrote: Hi, I am very new to Python, I am using the e-book Python Programming for the Absolute Beginner and am starting with a simple Game Over Program. This is the code:which is extremely simple! printGame Over raw_input(\n\nPress Enter Key to exit) welcome Nicholas One important thing about python is indentation is important. You have presented your code in a way that can't be. Can you actually copy your program and paste it into an email message. Also, Windows, Linux, Mac? That's it. It is supposed to bring up a window that says Game Over and at the bottom say Press enter Key to exit and when you press the enter key it is supposed to exit(big suprise). But all it does is highlight raw_input and says invalid syntax Now, if I just put print Game Over then it says Game Over UNDERNEATH the code I just printed! now I am following the book to the *pixel* and that is not what is supposed to happen! Please email me back as soon as you get this...(if you are not to busy). Thanks,Nicholas -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com Nicholas, Could it be that you use a more recent version ( e. g. 3.3) of python? I found that raw_input is indeed no longer recognized. Use input instead and your code will work - at least it did so with python 3.3 on my iPad. Bob -- Von Gmail Mobile gesendet -- Nicholas J. Piotrowski -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto parse a string using a char in python
On Fri, Feb 15, 2013 at 6:04 PM, Steve Goodwin sgood...@cfl.rr.com wrote: Hi, I am looking for the python2.7 function(s) to parse a string from a colon character : Sounds simple enough. For example, a string like 123456:789. I just need the 123456 substring.(left of the :) 123456:789.split(:)[0] -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto parse a string using a char in python
In 511ebf0c$0$21334$9a6e1...@unlimited.newshosting.com Steve Goodwin sgood...@cfl.rr.com writes: I am looking for the python2.7 function(s) to parse a string from a colon character : Sounds simple enough. For example, a string like 123456:789. I just need the 123456 substring.(left of the :) I have looked at regular expressions and string functions, so far no luck. Custom function required? Use the split() string function. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto parse a string using a char in python
On 15/02/2013 23:04, Steve Goodwin wrote: Hi, I am looking for the python2.7 function(s) to parse a string from a colon character : Sounds simple enough. For example, a string like 123456:789. I just need the 123456 substring.(left of the :) I have looked at regular expressions and string functions, so far no luck. Custom function required? Thank you. - Spoog98 More likely a visit to the opticians :) See http://docs.python.org/2/library/stdtypes.html#string-methods for the find and index methods. -- Cheers. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list
Re: New User-Need-Help
In mailman.1855.1360969699.2939.python-l...@python.org Deborah Piotrowski spiceninj...@gmail.com writes: print Game Over input(\n\nPress the Enter Key to Exit) Syntax Error: Invalid Syntax You're probably using Python version 3, but the book was written for version 2. The print statement is handled a bit differently in version 3. Change your print statement to look like this: print(Game Over) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: New User-Need-Help
Print needs parense in python 3 On Feb 15, 2013 5:48 PM, Bob Brusa bob.br...@gmail.com wrote: Am Freitag, 15. Februar 2013 schrieb Joel Goldstick : On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski spiceninj...@gmail.com wrote: Hi, I am very new to Python, I am using the e-book Python Programming for the Absolute Beginner and am starting with a simple Game Over Program. This is the code:which is extremely simple! printGame Over raw_input(\n\nPress Enter Key to exit) welcome Nicholas One important thing about python is indentation is important. You have presented your code in a way that can't be. Can you actually copy your program and paste it into an email message. Also, Windows, Linux, Mac? That's it. It is supposed to bring up a window that says Game Over and at the bottom say Press enter Key to exit and when you press the enter key it is supposed to exit(big suprise). But all it does is highlight raw_input and says invalid syntax Now, if I just put print Game Over then it says Game Over UNDERNEATH the code I just printed! now I am following the book to the *pixel* and that is not what is supposed to happen! Please email me back as soon as you get this...(if you are not to busy). Thanks,Nicholas -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com Nicholas, Could it be that you use a more recent version ( e. g. 3.3) of python? I found that raw_input is indeed no longer recognized. Use input instead and your code will work - at least it did so with python 3.3 on my iPad. Bob -- Von Gmail Mobile gesendet -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto parse a string using a char in python
Steve, I am looking for the python2.7 function(s) to parse a string from a colon character : Sounds simple enough. For example, a string like 123456:789. I just need the 123456 substring.(left of the :) How about: newstr = str[:str.find(':')] -- GC smime.p7s Description: S/MIME cryptographic signature -- http://mail.python.org/mailman/listinfo/python-list
Re: New User-Need-Help
WAIT!! It works now, I just needed to save it in script. Thank you guys so much!! My best regards, Nicholas On Fri, Feb 15, 2013 at 4:21 PM, Joel Goldstick joel.goldst...@gmail.comwrote: Print needs parense in python 3 On Feb 15, 2013 5:48 PM, Bob Brusa bob.br...@gmail.com wrote: Am Freitag, 15. Februar 2013 schrieb Joel Goldstick : On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski spiceninj...@gmail.com wrote: Hi, I am very new to Python, I am using the e-book Python Programming for the Absolute Beginner and am starting with a simple Game Over Program. This is the code:which is extremely simple! printGame Over raw_input(\n\nPress Enter Key to exit) welcome Nicholas One important thing about python is indentation is important. You have presented your code in a way that can't be. Can you actually copy your program and paste it into an email message. Also, Windows, Linux, Mac? That's it. It is supposed to bring up a window that says Game Over and at the bottom say Press enter Key to exit and when you press the enter key it is supposed to exit(big suprise). But all it does is highlight raw_input and says invalid syntax Now, if I just put print Game Over then it says Game Over UNDERNEATH the code I just printed! now I am following the book to the *pixel* and that is not what is supposed to happen! Please email me back as soon as you get this...(if you are not to busy). Thanks,Nicholas -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com Nicholas, Could it be that you use a more recent version ( e. g. 3.3) of python? I found that raw_input is indeed no longer recognized. Use input instead and your code will work - at least it did so with python 3.3 on my iPad. Bob -- Von Gmail Mobile gesendet -- Nicholas J. Piotrowski -- http://mail.python.org/mailman/listinfo/python-list
Re: New User-Need-Help
On 2/15/2013 4:45 PM, Deborah Piotrowski wrote: I am very new to Python, I am using the e-book Python Programming for the Absolute Beginner and am starting with a simple Game Over Program. This is the code:which is extremely simple!\ printGame Over raw_input(\n\nPress Enter Key to exit) That code is two statements. It should either have a semicolon printGame Over; raw_input(\n\nPress Enter Key to exit) or be entered on two lines printGame Over raw_input(\n\nPress Enter Key to exit) That's it. It is supposed to bring up a window that says Game Over I don't know what system you are running on, but print just prints to the window you are running in and does not bring up a new window. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Implicit conversion to boolean in if and while statements
On Sat, Feb 16, 2013 at 7:12 AM, Ian Kelly ian.g.ke...@gmail.com wrote: FYI, the general consensus here is that he (8 Dihedral) is a bot. It posts in non sequiturs and fails to respond meaningfully to direct queries. A few months ago I posed an obvious Turing test for it, which it failed. http://thread.gmane.org/gmane.comp.python.general/718489 Which, I might add, was something awesome. I find Dihedral pretty amusing, tbh... permanently mutated list is an interesting concept. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple 2.7.3 versions?
On 2/15/2013 6:06 PM, Ned Deily wrote: In article kfmdu8$iim$1...@ger.gmane.org, Terry Reedy tjre...@udel.edu wrote: On 2/15/2013 5:53 AM, Robin Becker wrote: On all the other machines I have access to I'm seeing something similar to this Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Notice the date again -- the original release date of 2.7.3. FYI - the date is a build date; it doesn't tell you much about the source code base used for that Python build. If a build called 2.7.3 is built on the 2.7.3 release date, one may reasonably think that it is built from the 2.7.3 code released on that date. Besides which, I recognized that as the header from the PSF distributed build ;-). More problematical is any build, even of the same name, built later, by anyone else, as with Ubuntu releases. But if it had the hg rev used for the checkout, you have some indication of what it contains. My impression is that Ubuntu does not build from any of *our* hg revs, but that they cherry pick patches to apply in their repository. I agree that is they gave *their* repository url and checkout id, that would be helpful. We could possible do that with our releases too. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Help with creating django-admin.py file
Hello everyone, I am trying to follow this tutorial: https://docs.djangoproject.com/en/1.4/topics/install/#installing-official-release I am on step 3 as of now (scroll down a little bit to see it). For some reason when I run the code in terminal I get: zsh: permission denied: /Library/Python/2.7/site-packages/django.pth Here is my terminal with path information and everything: Yonatan-Orens-MacBook-Pro-2% echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin Yonatan-Orens-MacBook-Pro-2% which django-admin.py django-admin.py not found Yonatan-Orens-MacBook-Pro-2% python -c from distutils.sysconfig import get_python_lib; print get_python_lib() /Library/Python/2.7/site-packages Yonatan-Orens-MacBook-Pro-2% echo documents/django/trunk/django-trunk /Library/Python/2.7/site-packages/django.pth zsh: permission denied: /Library/Python/2.7/site-packages/django.pth Would anyone be able to help me resolve this issue? Thank you for your time, Yoni201. -- http://mail.python.org/mailman/listinfo/python-list
Re: python math problem
On Feb 16, 6:39 am, Kene Meniru kene.men...@illom.org wrote: x = (math.sin(math.radians(angle)) * length) y = (math.cos(math.radians(angle)) * length) A suggestion about coding style: from math import sin, cos, radians # etc etc x = sin(radians(angle)) * length y = cos(radians(angle)) * length ... easier to write, easier to read. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 113, Issue 111
Hi, I don't know if I should ask this on here, or in the tutor section, but I heard that http://www.lighttable.com was an innovative IDE, so I was wondering if it works for python since I'm learning python over time. Thanks! On Fri, Feb 15, 2013 at 5:25 PM, python-list-requ...@python.org wrote: Send Python-list mailing list submissions to python-list@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to python-list-requ...@python.org You can reach the person managing the list at python-list-ow...@python.org When replying, please edit your Subject line so it is more specific than Re: Contents of Python-list digest... Today's Topics: 1. Re: Howto parse a string using a char in python (John Gordon) 2. Re: New User-Need-Help (John Gordon) 3. Re: Howto parse a string using a char in python (Tim Chase) 4. Re: Howto parse a string using a char in python (David Robinow) 5. Re: Howto parse a string using a char in python (Mark Lawrence) 6. Re: Howto parse a string using a char in python (Gary Chambers) 7. Re: New User-Need-Help (Joel Goldstick) 8. Re: New User-Need-Help (Deborah Piotrowski) -- Forwarded message -- From: John Gordon gor...@panix.com To: python-list@python.org Cc: Date: Fri, 15 Feb 2013 23:11:52 + (UTC) Subject: Re: Howto parse a string using a char in python In 511ebf0c$0$21334$9a6e1...@unlimited.newshosting.com Steve Goodwin sgood...@cfl.rr.com writes: I am looking for the python2.7 function(s) to parse a string from a colon character : Sounds simple enough. For example, a string like 123456:789. I just need the 123456 substring.(left of the :) I have looked at regular expressions and string functions, so far no luck. Custom function required? Use the split() string function. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- Forwarded message -- From: John Gordon gor...@panix.com To: python-list@python.org Cc: Date: Fri, 15 Feb 2013 23:14:20 + (UTC) Subject: Re: New User-Need-Help In mailman.1855.1360969699.2939.python-l...@python.org Deborah Piotrowski spiceninj...@gmail.com writes: print Game Over input(\n\nPress the Enter Key to Exit) Syntax Error: Invalid Syntax You're probably using Python version 3, but the book was written for version 2. The print statement is handled a bit differently in version 3. Change your print statement to look like this: print(Game Over) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- Forwarded message -- From: Tim Chase python.l...@tim.thechases.com To: Steve Goodwin sgood...@cfl.rr.com Cc: python-list@python.org Date: Fri, 15 Feb 2013 17:16:26 -0600 Subject: Re: Howto parse a string using a char in python On 2013-02-15 18:04, Steve Goodwin wrote: Hi, I am looking for the python2.7 function(s) to parse a string from a colon character : Sounds simple enough. For example, a string like 123456:789. I just need the 123456 substring.(left of the :) I have looked at regular expressions and string functions, so far no luck. Custom function required? With just a single character, it sounds like you want something like whole = 123456:789 parts = whole.split(':') # or .split(':', 1) interesting = parts[0] No custom function needed. -tkc -- Forwarded message -- From: David Robinow drobi...@gmail.com To: Steve Goodwin sgood...@cfl.rr.com Cc: python-list@python.org Date: Fri, 15 Feb 2013 18:19:09 -0500 Subject: Re: Howto parse a string using a char in python On Fri, Feb 15, 2013 at 6:04 PM, Steve Goodwin sgood...@cfl.rr.com wrote: Hi, I am looking for the python2.7 function(s) to parse a string from a colon character : Sounds simple enough. For example, a string like 123456:789. I just need the 123456 substring.(left of the :) 123456:789.split(:)[0] -- Forwarded message -- From: Mark Lawrence breamore...@yahoo.co.uk To: python-list@python.org Cc: Date: Fri, 15 Feb 2013 23:20:06 + Subject: Re: Howto parse a string using a char in python On 15/02/2013 23:04, Steve Goodwin wrote: Hi, I am looking for the python2.7 function(s) to parse a string from a colon character : Sounds simple enough. For example, a string like 123456:789. I just need the 123456 substring.(left of the :) I have looked at regular expressions and string functions, so far no luck. Custom function required?
Small program ideas
Any small program ideas? I would prefer to stick to command line ones. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Small program ideas
On 02/15/2013 10:22 PM, eli m wrote: Any small program ideas? I would prefer to stick to command line ones. Thanks. How about these two: - simulation of a street crossing with green/red lights allowing cars and pedestrians to pass in one direction then another - simulation of an elevator in a building: buttons on each floor to call the elevator, buttons inside to go to a particular floor, multiple floors can be selected at the same time, creating a queue of floors to go to. -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python trademark under attack -- the PSF needs your help
Stefan Behnel wrote: I'm sure it's a pure marketing thing for their domain. I'd expect the number of links to their site to rise rapidly during the next weeks, that's very likely worth the bit of money they'd pay to their lawyer(s). I doubt that. The amount of time required to make a trademark application is significant, measured in months or years of elapsed time and persons-days or -weeks, in effort. Seriously - who's ever heard of them before this? So it worked already, didn't it? Just because they aren't Microsoft or Apple doesn't mean they aren't a serious vendor in their space. My advice: don't mention their name or their domain in any of your blog posts etc., and definitely don't link to them. This would be the there's no such thing as bad publicity theory. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Small program ideas
On Friday, February 15, 2013 7:52:57 PM UTC-8, Mitya Sirenef wrote: On 02/15/2013 10:22 PM, eli m wrote: Any small program ideas? I would prefer to stick to command line ones. Thanks. How about these two: - simulation of a street crossing with green/red lights allowing cars and pedestrians to pass in one direction then another - simulation of an elevator in a building: buttons on each floor to call the elevator, buttons inside to go to a particular floor, multiple floors can be selected at the same time, creating a queue of floors to go to. -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ Could i make these text and not visual? That is what i am trying to do. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python trademark under attack -- the PSF needs your help
On Feb 14, 4:52 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: You can also testify to the fact that when you read or hear of the name Python in relation to computers and the Internet, you think of Python the programming language. Has anyone considered a search of Amazon for Python, or more particularly searches at sites that Amazon uses to do business in Europe? -- http://mail.python.org/mailman/listinfo/python-list
Re: Small program ideas
On 02/15/2013 10:57 PM, eli m wrote: On Friday, February 15, 2013 7:52:57 PM UTC-8, Mitya Sirenef wrote: On 02/15/2013 10:22 PM, eli m wrote: Any small program ideas? I would prefer to stick to command line ones. Thanks. How about these two: - simulation of a street crossing with green/red lights allowing cars and pedestrians to pass in one direction then another - simulation of an elevator in a building: buttons on each floor to call the elevator, buttons inside to go to a particular floor, multiple floors can be selected at the same time, creating a queue of floors to go to. -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ Could i make these text and not visual? That is what i am trying to do. Of course - just think up some textual representation before starting on the code. -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ -- http://mail.python.org/mailman/listinfo/python-list
Re: python math problem
Dennis Lee Bieber wrote: Classical CompSci teachings when working with floating point numbers is to NEVER compare for equality. Instead one should compare against some epsilon: Don't compare floats for equality is reasonably good advice. Adding never to that advice, especially when shouting as you do, moves it into the category superstition. Consider: - Python floating point integers are exact for entire range of -2**53 to 2**53, or about -9 million million to +9 million million; if you are working with floats that have integral values in this range, testing for equality is perfectly fine. - If you work exclusively with fractional powers of two, such as 1/2, 1/4, 1/8, 1/16, etc. floats are typically exact. - Testing against an epsilon raises as many problems as it solves: + What epsilon should I pick? How do I know if my epsilon is too small, and therefore I'm rejecting values that I should accept, or too large, and so I'm accepting values I should reject? + If my epsilon is too small, calculating abs(x - y) = epsilon is exactly equivalent to x == y, only slower. + Should I test for absolute error, or relative error? + If relative error, how do I deal with values around zero where division is likely to introduce excessive rounding error? + Not to mention the risk of dividing by zero. - And how do I deal with INFs? py x = float('inf') py x == x True py abs(x - x) = 1e-14 False -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python trademark under attack -- the PSF needs your help
The news is featured as an article on Groklaw now. Those folks are on it... http://www.groklaw.net/article.php?story=20130215074839583 -- http://mail.python.org/mailman/listinfo/python-list
Re: Exception running GNU module op25_grc.py : AttributeError: 'gr_hier_block2_sptr' object has no attribute 'set_callback'
On 02/15/2013 02:00 PM, matt.doolittl...@gmail.com wrote: I am using using ubuntu 12.10 i am trying to run a python block, namely OP25, in GNU Radio Companion v3.6.3-35-g4435082f, which uses python version 2.7.3 for some reason although python3.2 is in the lib folder. I run the following trace command in terminal: ~$ python -m trace --count -C . op25_grc.py Here is the output with an error: Imported legacy fsk4 Using Volk machine: ssse3_32 Traceback (most recent call last): File /usr/lib/python2.7/runpy.py, line 162, in run_module_as_main _main__, fname, loader, pkg_name) File /usr/lib/python2.7/runpy.py, line 72, in run_code exec code in run_globals File /usr/lib/python2.7/trace.py, line 819, in main() File /usr/lib/python2.7/trace.py, line 807, in main t.runctx(code, globs, globs) File /usr/lib/python2.7/trace.py, line 513, in runctx exec cmd in globals, locals File op25_grc.py, line 493, in tb = op25_grc() File op25_grc.py, line 231, in __init_ self.wxgui_fftsink2_0_0.set_callback(wxgui_fftsink2_0_0_callback) File /usr/local/lib/python2.7/dist-packages/gnuradio/gr/hier_block2.py, line 54, in getattr return getattr(self._hb, name) AttributeError: 'gr_hier_block2_sptr' object has no attribute 'set_callback' The code for op25_grc.py: #!/usr/bin/env python ## # Gnuradio Python Flow Graph # Title: Op25 Grc # Generated: Wed Feb 13 19:37:41 2013 ## snip and the code from hier_block2_.py: # # Copyright 2006,2007 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio is free software; you can redistribute it and/or modify snip My goal is to fix the error: AttributeError: 'gr_hier_block2_sptr' object has no attribute 'set_callback' so that the block op25_grc.py will run in GNU radio companion. i have been unable to find any sort of solution to this problem anywhere. some have said its a version problem with GNUradio but as i posted above i have the latest version. Any help will be greatly appreciated. Thank you very much! I'm rather surprised somebody hasn't jumped in by now. I thought your reworded query was quite well done. One of the source files is pretty large, but it's not your code, so that perhaps cannot be helped. I'm not sure why you included the code from hier_block2_.py, as I cannot see any reference to it. I'm surprised at the comment in the first file that said the code was generated. if it was generated by your efforts, perhaps there was something wrong with that. I know nothing about this gnuradio thingie, and you didn't supply a website url. I was wondering if the module is even intended to be run standalone, but I suppose the if __name__ == __main__ thing is a clue that it's supposed to. I found the mixture of trace lines to confuse the stack trace immensely, since the exception doesn't occur in the last source line quoted. Somebody better than I had best jump in and help. The error message referenced class gr_hier_block2_sptr, but I don't see where this is defined. So I'm not sure how to tell whether it does or should have a set_callback method. If nobody else jumps in, I'd suggest finding a forum that supports gnuradio, and ask there. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: The python computer language
On 02/16/2013 12:33 AM, Bama Parameshwaran wrote: http://OBFUSCATED.info/ Without any text body, you surely don't expect any of us to follow a link ?? -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Python trademark - A request for civility
Folks, It seems that people have been sending threats and abuse to the company claiming a trademark on the name Python. And somebody, somewhere, may have launched a DDOS attack on their website. The Python Software Foundation has asked the community for restraint and civility during this dispute. Abuse and threats just bring the Python community into disrepute. http://pyfound.blogspot.com/2013/02/asking-for-civility-during-our.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list
[issue13153] IDLE crashes when pasting non-BMP unicode char on Py3
Ned Deily added the comment: LGTM. The patch does prevent the crash in IDLE which is certainly an improvement until such time as someone investigates having Tk/tkinter fully support non-BMP characters. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13153 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17200] telnetlib.read_until() timeout uses the wrong units
Serhiy Storchaka added the comment: 0 and None must be different. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17200 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5308] cannot marshal objects with more than 2**31 elements
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5308 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13555] cPickle MemoryError when loading large file (while pickle works)
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13555 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16991] Add OrderedDict written in C
Eric Snow added the comment: Are there any objections to this unittest cleanup patch? I'd like to commit it separately prior to anything that will go in for the C OrderedDict. -- Added file: http://bugs.python.org/file29077/cleanup-test-collections.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16991 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17208] add note/warning about daemon threads
New submission from Antoine Pitrou: People are generally not aware of the properties of daemon threads. I suggest to add a note such as the following: « Daemon threads are abruptly stopped at shutdown. Their resources (such as open files, database transactions, etc.) may not be released properly. If you want your threads to stop gracefully, make them non-daemonic and use a suitable signalling mechanism such as an Event. » -- assignee: docs@python components: Documentation messages: 182133 nosy: docs@python, pitrou, sbt priority: normal severity: normal status: open title: add note/warning about daemon threads type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17208 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16991] Add OrderedDict written in C
Eric Snow added the comment: Incidently, I'm just about done with the OrdereDict patch. I'm attaching the current one. At present it passes the unit tests, but I have two memory-related issues and a number of open questions (that I don't think are critical). The patch has the unittest cleanup merged in just so it will show up in reviewboard. -- Added file: http://bugs.python.org/file29078/odict.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16991 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16991] Add OrderedDict written in C
Changes by Eric Snow ericsnowcurren...@gmail.com: Removed file: http://bugs.python.org/file28839/cleanup-test-collections.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16991 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16991] Add OrderedDict written in C
Changes by Eric Snow ericsnowcurren...@gmail.com: Removed file: http://bugs.python.org/file28956/odict.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16991 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17208] add note/warning about daemon threads
Tim Golden added the comment: +1 This is essentially the answer to the naive user's question: Why would anyone *not* use daemon threads given that they're less hassle to manage? -- nosy: +tim.golden ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17208 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue979407] urllib2 digest auth totally broken
Michele Orrù added the comment: Isn't this issue fixed and tested on Lib/test/test_urllib2.py:1304? -- nosy: +maker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue979407 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17209] get_wch() doesn't handle KeyboardInterrupt
New submission from raymontag: If I've initialized a window in curses, try to get a single character with get_wch() and press Ctrl+C, the program crashes even if I handle KeyboardInterrupt. Here's a code example. import curses scr = curses.initscr() try: char = scr.get_wch() except KeyboardInterrupt: pass With getch() instead of get_wch() it works though. -- components: Library (Lib) messages: 182137 nosy: raymontag priority: normal severity: normal status: open title: get_wch() doesn't handle KeyboardInterrupt versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17209 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17209] get_wch() doesn't handle KeyboardInterrupt
Changes by raymontag kkoe...@posteo.de: -- type: - crash ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17209 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16043] xmlrpc: gzip_decode has unlimited read()
Christian Heimes added the comment: +1 for a keyword argument I also have to add a limit to GzipDecodedResponse(). Python 2.6 and 3.1 are not affected by the issue. The problematic code was added in 2.7 and 3.2. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16043 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17201] Use allowZip64=True by default
Ramchandra Apte added the comment: LGTM. -- nosy: +Ramchandra.Apte ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17210] documentation of PyUnicode_Format() states wrong argument type requirements
New submission from Stefan Behnel: The current documentation says: PyObject* PyUnicode_Format(PyObject *format, PyObject *args) Return value: New reference. Return a new string object from format and args; this is analogous to format % args. The args argument must be a tuple. According to the implementation, however, args can be a tuple, a unicode string, or an arbitrary mapping, i.e. everything that Python's % operator allows for strings as well. -- assignee: docs@python components: Documentation messages: 182140 nosy: docs@python, scoder priority: normal severity: normal status: open title: documentation of PyUnicode_Format() states wrong argument type requirements type: behavior versions: Python 2.6, Python 2.7, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17210 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13153] IDLE crashes when pasting non-BMP unicode char on Py3
Ramchandra Apte added the comment: @Ned Deily Tk, at least on my system, doesn't render Unicode characters, even within BMP correctly but the characters are kept (cut-and-paste works correctly) What you mean by support. -- nosy: +Ramchandra.Apte ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13153 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17179] Incorrect use of type function in types.new_class
Ramchandra Apte added the comment: @Daniel Urban Me too. -- nosy: +Ramchandra.Apte ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17179 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17179] Incorrect use of type function in types.new_class
Changes by Ramchandra Apte maniandra...@gmail.com: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17179 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17211] pkgutil.iter_modules and walk_packages should return a namedtuple
New submission from Ramchandra Apte: Will attach a patch soon. -- components: Library (Lib) messages: 182143 nosy: Ramchandra.Apte priority: normal severity: normal status: open title: pkgutil.iter_modules and walk_packages should return a namedtuple type: enhancement versions: Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com