PyPy3 2.1 beta 1 released
PyPy3 2.1 beta 1 We're pleased to announce the first beta of the upcoming 2.1 release of PyPy3. This is the first release of PyPy which targets Python 3 (3.2.3) compatibility. We would like to thank all of the people who donated_ to the `py3k proposal`_ for supporting the work that went into this and future releases. You can download the PyPy3 2.1 beta 1 release here: http://pypy.org/download.html#pypy3-2-1-beta-1 Highlights == * The first release of PyPy3: support for Python 3, targetting CPython 3.2.3! - There are some `known issues`_ including performance regressions (issues `#1540`_ `#1541`_) slated to be resolved before the final release. What is PyPy? == PyPy is a very compliant Python interpreter, almost a drop-in replacement for CPython 2.7.3 or 3.2.3. It's fast due to its integrated tracing JIT compiler. This release supports x86 machines running Linux 32/64, Mac OS X 64 or Windows 32. Also this release supports ARM machines running Linux 32bit - anything with ``ARMv6`` (like the Raspberry Pi) or ``ARMv7`` (like Beagleboard, Chromebook, Cubieboard, etc.) that supports ``VFPv3`` should work. Cheers, the PyPy team -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: PEP8 79 char max
On 30 July 2013 18:52, Grant Edwards invalid@invalid.invalid wrote: On 2013-07-30, Joshua Landau jos...@landau.ws wrote: On 30 July 2013 18:08, Vito De Tullio vito.detul...@gmail.com wrote: Ed Leafe wrote: I had read about a developer who switched to using proportional fonts for coding, and somewhat skeptically, tried it out. After a day or so it stopped looking strange, and after a week it seemed so much easier to read. By my (limited) experience with proportional fonts, they can be useful only with something like elastic tabstops[0]. But, as a general rule, I simply found more squared to just use a fixed-width font. Not if you give up on the whole aligning thing. You don't think that Python code at a given level should all be aligned? I find it very helpful when a given block of code is visually left-aligned. I don't understand what you mean. My coding practices almost never require anything more than the initial indentation to have things line up -- any other form of alignment is in my opinion overrated. Maybe it helps you, but personally I don't like it. As I've been saying, the whole thing is personal preference and proportional fonts for some people, such as I, are fine. Except in that there are no good proportional fonts at 8px :(. To explain, I tend to take the HTML form of alignment by wrapping: open stuff stuff stuff close to open stuff stuff stuff close and thus everything important lines up anyway. Extra non-indentation indents are a burden for me and look worse (again, personal preference). I also find intializers for tables of data to be much more easily read and maintained if the columns can be aligned. Why do you have tables in your Python code? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script help
On 30 July 2013 22:47, Cameron Simpson c...@zip.com.au wrote: On 30Jul2013 09:12, cool1...@gmail.com cool1...@gmail.com wrote: | ** urlib, urlib2 Sure. And I'd use BeautifulSoup to do the parse. You'll need to fetch that. So: urllib[2] to fetch the document and BS to parse it for links, then urllib[2] to fetch the links you want. http://www.crummy.com/software/BeautifulSoup/bs4/download/4.0/ Personally BeautifulSoup + requests is a great combination. Maybe I'm just lazy ;). -- http://mail.python.org/mailman/listinfo/python-list
Re: Share Code: Laptop Lid State
On Wed, Jul 31, 2013 at 4:05 AM, Devyn Collier Johnson devyncjohn...@gmail.com wrote: On 07/30/2013 12:00 PM, Chris Angelico wrote: On Tue, Jul 30, 2013 at 3:06 PM, Devyn Collier Johnson devyncjohn...@gmail.com wrote: Aloha everyone! I attached a script that I thought I could share with everyone for your help. This Python3 script only works on Unix systems. It prints the current state of the lid. This can be used to make a script that performs some action when the lid is closed or open. The script is licensed under LGPLv3 and I will soon upload it to my Launchpad account. Enjoy! There's... no Python code in that. Why not simply open(/proc/acpi/button/lid/LID/state) and read from it, instead of using cat and awk? ChrisA The script returns either open or close instead of printing the whole file contents. I thought some people would find it useful (^_^;). Not having a Linux laptop handy I can't test it, but my point is that text parsing of that nature can be done directly by Python. You can snip out the open or close easily with one, maybe two lines of code at the most, and that without dropping to a shell, a completely superfluous 'cat' process, and awk. You then capture the STDOUT of that and promptly print it to your own STDOUT. Why not either do it truly in Python, or do it directly in a shell script and skip the Python interpreter? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
On Wed, Jul 31, 2013 at 6:45 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: if you care about minimizing every possible byte, you should use a low-level language like C. Then you can give every character 21 bits, and be happy that you don't waste even one bit. Could go better! Since not every character has been assigned, and some are specifically banned (eg U+FFFE and U+D800-U+DFFF), you could cut them out of your representation system and save memory! ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
Op 31-07-13 05:30, Michael Torrie schreef: On 07/30/2013 12:19 PM, Antoon Pardon wrote: So? Why are you making this a point of discussion? I was not aware that the pro and cons of various editor buffer implemantations was relevant to the point I was trying to make. I for one found it very interesting. In fact this thread caused me to wonder how one actually does create an efficient editor. Off the original topic true, but still very interesting. Yes, it can be interesting. But I really think if that is what you want to discuss, it deserves its own subject thread. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
It's not just the number of characters, it's the size and the font. Even fixed-width fonts differ greatly in their readability. I can handle different line widths just fine up til about 120 or so without losing the flow of the program, but some fonts simply make it more difficult at any width. I've tried many, but for some reason I keep coming back to Courier10 at 10 points. I'm almost embarrassed that my choice is such an old and primitive font, but that's how my brain works. In my experience, if code is well-spaced, well-commented, and broken up into logical groups with appropriate blank spaces, line length can be about 3/4 the width of whatever editor is being used. And most editors are wide enough to easily accommodate over 100 characters. -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
Op 30-07-13 21:09, wxjmfa...@gmail.com schreef: Matable, immutable, copyint + xxx, bufferint, O(n) Yes, but conceptualy the reencoding happen sometime, somewhere. Which is a far cry from your previous claim that it happened every time you enter a char. This of course make your case harder to argue. Because the impact of something that happens sometime, somewhere is vastly less than something that happens everytime you enter a char. The internal ucs-2 will never automagically be transformed into ucs-4 (eg). It will just start producing wrong results when someone starts using characters that don't fit into ucs-2. timeit.timeit('a'*1 +'€') 7.087220684719967 timeit.timeit('a'*1 +'z') 1.5685214234430873 timeit.timeit(z = 'a'*1; z = z +'€') 7.169538866162213 timeit.timeit(z = 'a'*1; z = z +'z') 1.5815893830557286 timeit.timeit(z = 'a'*1; z += 'z') 1.606955741596181 timeit.timeit(z = 'a'*1; z += '€') 7.160483334521416 And do not forget, in a pure utf coding scheme, your char or a char will *never* be larger than 4 bytes. sys.getsizeof('a') 26 sys.getsizeof('\U000101000') 48 Nonsense. sys.getsizeof('a'.encode('utf-8')) 18 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script help
Here are some scripts, how do I put them together to create the script I want? (to search a online document and download all the links in it) p.s: can I set a destination folder for the downloads? urllib.urlopen(http://;) possible_urls = re.findall(r'\S+:\S+', text) import urllib2 response = urllib2.urlopen('http://www.example.com/') html = response.read() -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
FSR: === The 'a' in 'a€' and 'a\U0001d11e: ['{:#010b}'.format(c) for c in 'a€'.encode('utf-16-be')] ['0b', '0b0111', '0b0010', '0b10101100'] ['{:#010b}'.format(c) for c in 'a\U0001d11e'.encode('utf-32-be')] ['0b', '0b', '0b', '0b0111', '0b', '0b0001', '0b11010001', '0b0000'] Has to be done. sys.getsizeof('a€') 42 sys.getsizeof('a\U0001d11e') 48 sys.getsizeof('aa') 27 Unicode/utf* i) (primary key) Create and use a unique set of encoded code points. ii) (secondary key) Depending of the wish, memory/performance: utf-8/16/32 Two advantages at the light of the above example: iii) The a has never to be reencoded. iv) An a size never exceeds 4 bytes. Hard job to solve/satisfy i), ii), iii) and iv) at the same time. Is is possible? ;-) The solution is in the problem. jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
Op 31-07-13 10:32, wxjmfa...@gmail.com schreef: Unicode/utf* i) (primary key) Create and use a unique set of encoded code points. FSR does this. st1 = 'a€' st2 = 'aa' ord(st1[0]) 97 ord(st2[0]) 97 ii) (secondary key) Depending of the wish, memory/performance: utf-8/16/32 Whose wish? I don't know any language that allows the programmer choose the internal representation of its strings. If it is the designers choice FSR does this, if it is the programmers choice, I don't see why this is necessary for compliance. Two advantages at the light of the above example: iii) The a has never to be reencoded. FSR: check. Using a container with wider slots is not a reëncoding. If such widening is encoding then your 'choice' between utf-8/16/32 implies that it will also have to reencode when it changes from utf-8 to utf-16 or utf-32. iv) An a size never exceeds 4 bytes. FSR: check. Hard job to solve/satisfy i), ii), iii) and iv) at the same time. Is is possible? ;-) The solution is in the problem. Mayby you should use bytes or bytearrays if that is really what you want. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Python descriptor protocol (for more or less structured data)
Peter, thanks for your response. Sure, you are right when you say that's easier to use standard attribute assigning via __init__. But my intention was: - reducing the complexiticity of __init__ - avoiding boiler-plates (mostly property descriptors inside of the main class) - creating instances (for complex data strings) only if they will be needed, otherwise use default instances (descriptors) - make it prossible that the data structure can be used in static context - like MyClass.attr - to get default values Standard procedure: class C: def __init__(self, one, two=None, three=None, four=None, five=None, ...): if not two is None: self.two = Value(two) else: self.two = Value(self.DEFAULT_4_TWO) ... vs: class C: two = MyDescriptor('default for two') def __init__(self, one, two=None, three=None, four=None, five=None, ...): self.one = one if not two is None: self.two = two ... Probably it will be necessary to set the attribute at first access. Alternatively it may be possible to observe the descriptor til an attribute will be setted e.g. instance.attr.value = 'whatever'. At this point a new instance (like Value) should be created on obj.__dict__. It's the procedure what I'm looking for. ;) Kind Regards, Chris -- http://mail.python.org/mailman/listinfo/python-list
Problem with psycopg2, bytea, and memoryview
Hi all I don't know if this question is more appropriate for the psycopg2 list, but I thought I would ask here first. I have some binary data (a gzipped xml object) that I want to store in a database. For PostgreSQL I use a column with datatype 'bytea', which is their recommended way of storing binary strings. I use psycopg2 to access the database. It returns binary data in the form of a python 'memoryview'. My problem is that, after a roundtrip to the database and back, the object no longer compares equal to the original. memoryview(b'abcdef') == b'abcdef' True cur.execute('create table fmtemp (code int, xml bytea)') cur.execute('insert into fmtemp values (%s, %s)', (1, b'abcdef')) cur.execute('select * from fmtemp where code =1') row = cur.fetchone() row (1, memory at 0xb725f77c) row[1] == b'abcdef' False row[1].tobytes() == b'abcdef' True Using MS SQL Server and pyodbc, it returns a byte string, not a memoryview, and it does compare equal with the original. I can hack my program to use tobytes(), but it would add complication, and it would be database-specific. I would prefer a cleaner solution. Does anyone have any suggestions? Versions - Python: 3.3.2 PostgreSQL: 9.2.4 psycopg2: 2.5 Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with psycopg2, bytea, and memoryview
Frank Millman frank at chagford.com writes: I have some binary data (a gzipped xml object) that I want to store in a database. For PostgreSQL I use a column with datatype 'bytea', which is their recommended way of storing binary strings. I use psycopg2 to access the database. It returns binary data in the form of a python 'memoryview'. [...] Using MS SQL Server and pyodbc, it returns a byte string, not a memoryview, and it does compare equal with the original. I can hack my program to use tobytes(), but it would add complication, and it would be database-specific. I would prefer a cleaner solution. Just cast the result to bytes (`bytes(row[1])`). It will work both with bytes and memoryview objcts. Regards Antoine. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it that easy to install Python ?
OK thanks for your answers. So Python is not a daemon. Is it? Does it have a config file? Actually, each site on the web server is jailed in a chrooted environment. In the chrooted environment, Python appears to be in /usr/bin/python. If I give developers write access to a folder like /usr/lib/python/dist-packages/ (in the chrooted environment), will this be sufficient? Regards Santiago PS: Thanks for all your opinions about how one should install Python but that wasn't the purpose of this thread. Most programs on my servers are compiled. Period. -- http://mail.python.org/mailman/listinfo/python-list
Repository of non-standard modules.
Hi, I am to start a new free-time project in the next couple of weeks. I am ready to use open accessible Python modules not wanting to reinvent the weel :-) Is there any repository where I can find Python modules not being part of the standard distribution? I have some hits by Google but that seems to be far from complete. Thanks in advance, Gabor Urban -- Urbán Gábor Linux is like a wigwam: no Gates, no Windows and an Apache inside. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31 07:16, Joshua Landau wrote: On 30 July 2013 18:52, Grant Edwards wrote: I also find intializers for tables of data to be much more easily read and maintained if the columns can be aligned. Why do you have tables in your Python code? I've had occasion to write things like: for name, value, description in ( (cost, 42, How much it cost), (status, 3141, Status code from ISO-3.14159), ... ): do_something(name, value) print(description) I interpret Grant's statement as wanting the table to look like for name, value, description in ( (cost, 42, How much it cost), (status, 3141, Status code from ISO-3.14159), ... ): do_something(name, value) print(description) which does give some modest readability benefits, but at a creation cost I personally am unwilling to pay. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Repository of non-standard modules.
On Wed, Jul 31, 2013 at 11:53 AM, Gabor Urban urbang...@gmail.com wrote: Hi, I am to start a new free-time project in the next couple of weeks. I am ready to use open accessible Python modules not wanting to reinvent the weel :-) Is there any repository where I can find Python modules not being part of the standard distribution? Check out the Python Package Index: http://pypi.python.org/ Lots of stuff there, not all of it actively developed. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with psycopg2, bytea, and memoryview
Antoine Pitrou solip...@pitrou.net wrote in message news:loom.20130731t114936-...@post.gmane.org... Frank Millman frank at chagford.com writes: I have some binary data (a gzipped xml object) that I want to store in a database. For PostgreSQL I use a column with datatype 'bytea', which is their recommended way of storing binary strings. I use psycopg2 to access the database. It returns binary data in the form of a python 'memoryview'. [...] Using MS SQL Server and pyodbc, it returns a byte string, not a memoryview, and it does compare equal with the original. I can hack my program to use tobytes(), but it would add complication, and it would be database-specific. I would prefer a cleaner solution. Just cast the result to bytes (`bytes(row[1])`). It will work both with bytes and memoryview objcts. Regards Antoine. Thanks for that, Antoine. It is an improvement over tobytes(), but i am afraid it is still not ideal for my purposes. At present, I loop over a range of columns, comparing 'before' and 'after' values, without worrying about their types. Strings are returned as str, integers are returned as int, etc. Now I will have to check the type of each column before deciding whether to cast to 'bytes'. Can anyone explain *why* the results do not compare equal? If I understood the problem, I might be able to find a workaround. Frank -- http://mail.python.org/mailman/listinfo/python-list
importing modules
I am attempting to import modules from Shogun to python from a non-standard python directory ie from my /home/xxx directory. is there a way on ubuntu to selectively some modules, scripts, data from one directory and others modules, scripts from another directory. In other words, is there a file(s) that provide pointers to where these modules are located. regards Sy -- -- http://mail.python.org/mailman/listinfo/python-list
Re: email 8bit encoding
Op 29-07-13 01:41, ru...@yahoo.com schreef: How, using Python-3.3's email module, do I flatten (I think that's the right term) a Message object to get utf-8 encoded body with the headers: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when the message payload was set to a python (unicode) string? I am just trying out some things for my self on python 3.2 so be sure to test this out but you could try the following. msg.set_charset('utf-8') msg['Content-Transfer-Encoding'] = '8bit' -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: import syntax
On Mon, Jul 29, 2013 at 11:37 PM, Joshua Landau jos...@landau.ws wrote: 2d) Realise that the slow part is not what you thought it was This step is mandatory. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Prime number generator
On Tue, Jul 30, 2013 at 4:58 AM, Albert van der Horst alb...@spenarnc.xs4all.nl wrote: Notice that all values from i on are possibly present. So you are better off with a list indexed by forthcoming i's and each item containing a list of primes. What you do then, more or less, is keep track of all dividers of primes to be. This promises to be reasonable efficient. I've done a similar thing in Forth. What do you do when you get up into the billions? It seems inefficient to keep a mostly empty billion-element list hanging around. There is an unpleasant fact about this kind of generators. If you want to go unbounded, you've no choice but remember all primes. If you go bounded, you need to remember 168 up til 1M, say sqrt(limit)/log(limit). This dramatic difference (and the lack of processors) leads one quickly to decide for some upper bound. Actually, take a look at the generator that I posted in this thread, which avoids this. It is unbounded but gets away with only remembering sqrt(N) primes by recursively regenerating the primes already seen as needed. Thus it only uses (2 * N**(1/2) + 4 * N**(1/4) 8 * N**(1/8) + ...) / log(N) extra memory, which I believe is O(sqrt(N)). -- http://mail.python.org/mailman/listinfo/python-list
Lambda function Turing completeness
Is it possible to write a Turing-complete lambda function (which does not depend on named functions) in Python? -- http://mail.python.org/mailman/listinfo/python-list
Script that converts between indentation and curly braces in Python code
Is there any script that converts indentation in Python code to curly braces? The indentation is sometime lost when I copy my code to an application or a website. -- http://mail.python.org/mailman/listinfo/python-list
Re: Script that converts between indentation and curly braces in Python code
On Tue, Jul 30, 2013 at 11:45 PM, Musical Notation musicdenotat...@gmail.com wrote: Is there any script that converts indentation in Python code to curly braces? The indentation is sometime lost when I copy my code to an application or a website. I guess you could google that. What do you mean that indentation is 'sometimes' lost when copying. I think you should walk down that path to understand why you are losing your indentation. It could be you are using tabs instead of spaces for indentation. It could also be that you are inserting your code directly into HTML which of course will eat the extra whitespace. That problem can be solved with pre tags, or maybe even code (but I am not sure about that) If you are copying code to a website like stack exchange you need to precede each line of code with (2 I think!) spaces. They use markdown. If you wanted to add in curly braces, I am guesses the only purpose for this would be that you would convert them back to proper indentation in the copied to environment. So then you have to figure out a way to do that. -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Script that converts between indentation and curly braces in Python code
from __future__ import braces ;) ok, ok, if you *really* want it, you could keep track of how many leading spaces there are (you are using spaces, right?), and insert an open bracket where that number increases and a closing bracket where it decreases. Of course, as with all parsing problems, this is oversimplification... if you have multi-line statements you'll need to check for those (if line starts with or ''', ends with \, or if there's an unclosed bracket or paren...) - but that'd be a reasonable place to start if you're only doing short code snippets. Also, I have to ask, how to you intend this to be used? If there's no indentation it will still be difficult to read, and your readers will then have the problem of figuring out which curly braces to remove (for simple code this might be easy, but for longer things you'd probably want an automated way to re-indent, and a simple search-and-replace will screw up any dictionaries, for instance). -beth On Tue, Jul 30, 2013 at 11:45 PM, Musical Notation musicdenotat...@gmail.com wrote: Is there any script that converts indentation in Python code to curly braces? The indentation is sometime lost when I copy my code to an application or a website. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31, Tim Chase python.l...@tim.thechases.com wrote: On 2013-07-31 07:16, Joshua Landau wrote: On 30 July 2013 18:52, Grant Edwards wrote: I also find intializers for tables of data to be much more easily read and maintained if the columns can be aligned. Why do you have tables in your Python code? I've had occasion to write things like: for name, value, description in ( (cost, 42, How much it cost), (status, 3141, Status code from ISO-3.14159), ... ): do_something(name, value) print(description) I interpret Grant's statement as wanting the table to look like for name, value, description in ( (cost, 42, How much it cost), (status, 3141, Status code from ISO-3.14159), ... ): do_something(name, value) print(description) which does give some modest readability benefits, but at a creation cost I personally am unwilling to pay. I'm actually OK with the creation cost, but not the maintenance cost. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with psycopg2, bytea, and memoryview
Frank Millman frank at chagford.com writes: Thanks for that, Antoine. It is an improvement over tobytes(), but i am afraid it is still not ideal for my purposes. I would suggest asking the psycopg2 project why they made this choice, and if they would reconsider. Returning a memoryview doesn't make much sense IMHO. For example, the standard sqlite3 module returns bytes for BLOB columns, and str for TEXT columns: http://docs.python.org/3.4/library/sqlite3.html#introduction Can anyone explain *why* the results do not compare equal? If I understood the problem, I might be able to find a workaround. Well, under recent Python versions, they should compare equal: Python 3.2.3 (default, Oct 19 2012, 19:53:16) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. memoryview(babc) == babc True Regards Antoine. -- http://mail.python.org/mailman/listinfo/python-list
Re: Lambda function Turing completeness
On Wed 31 Jul 2013 08:53:26 AM CEST, Musical Notation wrote: Is it possible to write a Turing-complete lambda function (which does not depend on named functions) in Python? what should a sinlge Turing-complete lambda function be? For me, a programming language can be Turing-complete or a function can be universal, e.g. like an interpreter for a programming language. bg, Johannes -- GLOBE Development GmbH Königsberger Strasse 260 48157 MünsterGLOBE Development GmbH Königsberger Strasse 260 48157 Münster 0251/5205 390 -- http://mail.python.org/mailman/listinfo/python-list
Re: Script that converts between indentation and curly braces in Python code
Musical Notation: Is there any script that converts indentation in Python code to curly braces? The indentation is sometime lost when I copy my code to an application or a website. pindent.py in the Tools/Scripts directory of Python installations does something similar by adding or removing comments that look like # end if Neil -- http://mail.python.org/mailman/listinfo/python-list
Re: Script that converts between indentation and curly braces in Python code
31.07.13 06:45, Musical Notation написав(ла): Is there any script that converts indentation in Python code to curly braces? The indentation is sometime lost when I copy my code to an application or a website. Look at the pindent.py script. -- http://mail.python.org/mailman/listinfo/python-list
Re: Script that converts between indentation and curly braces in Python code
On Jul 31, 2013, at 19:27, IshIsh ish...@domhain.de wrote: Try from __future__ import braces as the first line of a source file (or typing it in an interactive session), and watch the interpreter's response... SyntaxError: not a chance I already know that.-- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with psycopg2, bytea, and memoryview
Antoine Pitrou solip...@pitrou.net wrote in message news:loom.20130731t150154-...@post.gmane.org... Frank Millman frank at chagford.com writes: Thanks for that, Antoine. It is an improvement over tobytes(), but i am afraid it is still not ideal for my purposes. I would suggest asking the psycopg2 project why they made this choice, and if they would reconsider. Returning a memoryview doesn't make much sense IMHO. I'll try it, and see what they say. For example, the standard sqlite3 module returns bytes for BLOB columns, and str for TEXT columns: http://docs.python.org/3.4/library/sqlite3.html#introduction Can anyone explain *why* the results do not compare equal? If I understood the problem, I might be able to find a workaround. Well, under recent Python versions, they should compare equal: Python 3.2.3 (default, Oct 19 2012, 19:53:16) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. memoryview(babc) == babc True I am using Python 3.3.2. If I try your example above, it does work. However, for some reason, after a round-trip to the server, they do not compare equal. See my original post for a full example. Frank -- http://mail.python.org/mailman/listinfo/python-list
Re: Script that converts between indentation and curly braces in Python code
On Wed, Jul 31, 2013 at 1:39 PM, Beth McNany beth.mcn...@gmail.com wrote: ok, ok, if you *really* want it, you could keep track of how many leading spaces there are (you are using spaces, right?), and insert an open bracket where that number increases and a closing bracket where it decreases. Of course, as with all parsing problems, this is oversimplification... if you have multi-line statements you'll need to check for those (if line starts with or ''', ends with \, or if there's an unclosed bracket or paren...) - but that'd be a reasonable place to start if you're only doing short code snippets. Since the braced version won't run anyway, how about a translation like this: def foo(): print(Hello, world!) for i in range(5): foo() return 42 -- 0-def foo(): 4-print(Hello, 0-world!) 4-for i in range(5): 8-foo() 4-return 42 That's a simple translation that guarantees safe round-tripping, and you can probably do it with a one-liner fwiw... let's see... # Assumes spaces OR tabs but not both # Can't see an easy way to count leading spaces other than: # len(s)-len(s.lstrip()) code = '\n'.join(%d-%s%(len(s)-len(s.lstrip()),s.lstrip()) for s in code.split('\n')) # Recreates with spaces, choose tabs for the multiplication if you prefer code = '\n'.join(' '*int(s.split('-',1)[0])+s.split('-',1)[1] for s in code.split('\n')) These would be better done in a couple of lines, but I like doing one-liners just for fun. :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Script that converts between indentation and curly braces in Python code
On 31/07/2013 14:55, Chris Angelico wrote: [...] Since the braced version won't run anyway, how about a translation like this: def foo(): print(Hello, world!) for i in range(5): foo() return 42 -- 0-def foo(): 4-print(Hello, 0-world!) 4-for i in range(5): 8-foo() 4-return 42 That's a simple translation that guarantees safe round-tripping, and you can probably do it with a one-liner fwiw... let's see... # Assumes spaces OR tabs but not both # Can't see an easy way to count leading spaces other than: # len(s)-len(s.lstrip()) How about len(s.expandtabs()) - len(s.lstrip()) instead? -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with psycopg2, bytea, and memoryview
On 2013-07-31, Frank Millman fr...@chagford.com wrote: Antoine Pitrou solip...@pitrou.net wrote in message news:loom.20130731t114936-...@post.gmane.org... Frank Millman frank at chagford.com writes: I have some binary data (a gzipped xml object) that I want to store in a database. For PostgreSQL I use a column with datatype 'bytea', which is their recommended way of storing binary strings. I use psycopg2 to access the database. It returns binary data in the form of a python 'memoryview'. [...] Using MS SQL Server and pyodbc, it returns a byte string, not a memoryview, and it does compare equal with the original. I can hack my program to use tobytes(), but it would add complication, and it would be database-specific. I would prefer a cleaner solution. Just cast the result to bytes (`bytes(row[1])`). It will work both with bytes and memoryview objcts. Thanks for that, Antoine. It is an improvement over tobytes(), but i am afraid it is still not ideal for my purposes. At present, I loop over a range of columns, comparing 'before' and 'after' values, without worrying about their types. Strings are returned as str, integers are returned as int, etc. Now I will have to check the type of each column before deciding whether to cast to 'bytes'. Can anyone explain *why* the results do not compare equal? If I understood the problem, I might be able to find a workaround. A memoryview will compare equal to another object that supports the buffer protocol when the format and shape are also equal. The database must be returning chunks of binary data in a different shape or format than you are writing it. Perhaps psycopg2 is returning a chunk of ints when you have written a chunk of bytes. Check the .format and .shape members of the return value to see. x = memoryview(b12345) x.format 'B' x.shape (5,) x == b12345 True My guess is you're getting format I from psycopg2. Hopefully there's a way to coerce your desired B format interpretation of the raw data using psycopg2's API. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Script that converts between indentation and curly braces in Python code
So, why do you want to do this? As has been pointed out, its a difficult and likely sizable task to build such a parser. In the end you get something that isn't a computer language -- even tho it looks like one. And it also is probably just as big a job to convert it back to python. So, what is the point? Pardon me for making assumptions, but this seems to be a variation on the theme of 'I don't like python, it doesn't have curly braces'. So if you need curly braces, you have many other languages to choose from. Python isn't one of them. -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
On 07/31/2013 01:23 AM, Antoon Pardon wrote: Op 31-07-13 05:30, Michael Torrie schreef: On 07/30/2013 12:19 PM, Antoon Pardon wrote: So? Why are you making this a point of discussion? I was not aware that the pro and cons of various editor buffer implemantations was relevant to the point I was trying to make. I for one found it very interesting. In fact this thread caused me to wonder how one actually does create an efficient editor. Off the original topic true, but still very interesting. Yes, it can be interesting. But I really think if that is what you want to discuss, it deserves its own subject thread. Subject lines can and should be changed to reflect the ebbs and flows of the discussion. In fact this thread's subject should have been changed a long time ago since the original topic was RE module performance! -- http://mail.python.org/mailman/listinfo/python-list
Re: Script that converts between indentation and curly braces in Python code
On Wed, Jul 31, 2013 at 3:07 PM, Rotwang sg...@hotmail.co.uk wrote: # Assumes spaces OR tabs but not both # Can't see an easy way to count leading spaces other than: # len(s)-len(s.lstrip()) How about len(s.expandtabs()) - len(s.lstrip()) instead? Still comes to the same thing. The only diff is that tabs get treated as eight spaces instead of one (and the bug that a tab elsewhere in the line will result in indentation, which is fixed by lstripping the tab-expanded form). It won't perfectly round-trip with a mixture of tabs and spaces; as it is, you can pick one or the other and run with it. Anyway, the main point is that indentation will work. Sure you might have ugly narrow code, but it'll run with one-space indents. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: binary key in dictionary
In 9004a556-958f-4d1d-81a7-4d1b73134...@googlegroups.com cerr ron.egg...@gmail.com writes: Traceback (most recent call last): File gateway.py, line 2485, in module main() File gateway.py, line 2459, in main cloud_check() File gateway.py, line 770, in cloud_check gnstr_dict[src] = gn_from_cloud(curr_mac) File gateway.py, line 2103, in gn_from_cloud tmpgndict[binmac] += HELLO KeyError: '\x04\xeeu' You're not assigning to tmpgndict[binmac]; you're appending to it. This requires that tmpgndict[binmac] already exists, which it does not. Make sure that tmpgndict[binmac] exists before you try appending to it. -- 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: RE Module Performance
On 07/31/2013 02:32 AM, wxjmfa...@gmail.com wrote: Unicode/utf* Why do you keep using the terms utf and Unicode interchangeably? -- http://mail.python.org/mailman/listinfo/python-list
script to Login a website
I have created a script to log in a website. It gets its username and password from two files, then log's in with this credentials. My code is not showing me what username it is using to login from the file. And I am not sure if it is even opening up the url and prompting for login. I am stuck can someone help me ? import urllib, urllib2 user = open ('users.txt' , 'r') password = open ('password.txt' , 'r') for users in user: password.seek(0) for pass_list in password: login_data = users + '\n' + pass_list print login_data base_url = 'http://mysite.com' #login action we want to post data to response = urllib2.Request(base_url) login_action = '/auth/login' login_action = base_url + login_action response = urllib2.urlopen(login_action, login_data) response.read() print response.headers print response.getcode() -- http://mail.python.org/mailman/listinfo/python-list
Re: how to package embedded python?
okay, well that might turn out to be useful, except i don't quite know how to use it, and there are no from scratch instructions. i managed to download py2exe-0.6.9.zip and unzip it, but how does one install this package? (yes, still a newb at that) then, once installed, how do i say include the entire world instead of just mymodule ? cuz the point of embedding python on my app is that the end-user can run any script at all, not just one module. -- http://mail.python.org/mailman/listinfo/python-list
Re: script to Login a website
In ece5f6b0-16da-4c3a-83d1-6340cb10c...@googlegroups.com wachk...@gmail.com writes: I have created a script to log in a website. It gets its username and password from two files, then log's in with this credentials. My code is not showing me what username it is using to login from the file. And I am not sure if it is even opening up the url and prompting for login. I am stuck can someone help me ? How is the data in 'users.txt' and 'password.txt' organized? Given the filenames, I would expect that 'users.txt' contains one username on each line, and 'password.txt' contains one password on each line, with the first username belonging with the first password, the second username belonging with the second password, and so on. Is this correct? If so, that raises the question of how to handle multiple usernames and passwords. Do you just want to use one, or are you supposed to use them all somehow? Anyway, to begin to solve your problem, I'd copy just the file-reading code into a separate program and add plenty of print statements to make sure it works correctly. Once you have that fixed, then you can worry about the web login stuff. And when you read the contents of each file, be aware that the newlines at the end of each line are included. If you don't want these, be sure to call the rstrip() method to remove traling whitespace. -- 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: PEP8 79 char max
On 2013-07-31, Tim Chase python.l...@tim.thechases.com wrote: On 2013-07-31 07:16, Joshua Landau wrote: On 30 July 2013 18:52, Grant Edwards wrote: I also find intializers for tables of data to be much more easily read and maintained if the columns can be aligned. Why do you have tables in your Python code? For example: if you're writing an assembler, you usually have a table of mnemonics/opcodes/instruction-format/addressing-modes. I've had occasion to write things like: for name, value, description in ( (cost, 42, How much it cost), (status, 3141, Status code from ISO-3.14159), ... ): do_something(name, value) print(description) I interpret Grant's statement as wanting the table to look like for name, value, description in ( (cost, 42, How much it cost), (status, 3141, Status code from ISO-3.14159), ... ): do_something(name, value) print(description) Exactly. When you have more than about 5 columns and 10 rows, having things aligned makes it far, far, easier to maintain. which does give some modest readability benefits, but at a creation cost I personally am unwilling to pay. It only gets typed once, it gets read hundreds or thousands of times. Optimize the common case. -- Grant Edwards grant.b.edwardsYow! I am NOT a nut at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31, Neil Cerutti ne...@norwich.edu wrote: On 2013-07-31, Tim Chase python.l...@tim.thechases.com wrote: On 2013-07-31 07:16, Joshua Landau wrote: On 30 July 2013 18:52, Grant Edwards wrote: I also find intializers for tables of data to be much more easily read and maintained if the columns can be aligned. Why do you have tables in your Python code? I've had occasion to write things like: for name, value, description in ( (cost, 42, How much it cost), (status, 3141, Status code from ISO-3.14159), ... ): do_something(name, value) print(description) I interpret Grant's statement as wanting the table to look like for name, value, description in ( (cost, 42, How much it cost), (status, 3141, Status code from ISO-3.14159), ... ): do_something(name, value) print(description) which does give some modest readability benefits, but at a creation cost I personally am unwilling to pay. I'm actually OK with the creation cost, but not the maintenance cost. In my experience, aligning columns in large tables reduces maintence cost by making it much easier/faster to see what you've got and by providing a way to visually prompt you for the correct value in the correct place when you add new lines. -- Grant Edwards grant.b.edwardsYow! hubub, hubub, HUBUB, at hubub, hubub, hubub, HUBUB, gmail.comhubub, hubub, hubub. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it that easy to install Python ?
On Wed, Jul 31, 2013 at 4:08 AM, santiago.d...@caoba.fr wrote: OK thanks for your answers. So Python is not a daemon. Is it? No. Does it have a config file? Not as such. Arbitrary site-specific customization can be done by creating a sitecustomize module, but this is not standard. There are also some environment variables that you may want to consider setting in the system profile, but none are required or generally recommended: http://docs.python.org/2/using/cmdline.html#environment-variables Actually, each site on the web server is jailed in a chrooted environment. In the chrooted environment, Python appears to be in /usr/bin/python. If I give developers write access to a folder like /usr/lib/python/dist-packages/ (in the chrooted environment), will this be sufficient? I don't have experience with this, but it seems to me that you should place the standard library and site-packages in the chrooted /usr/lib/python2.7 and then set the PYTHONHOME environment variable to /usr/lib. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it that easy to install Python ?
On Wed, Jul 31, 2013 at 10:44 AM, Ian Kelly ian.g.ke...@gmail.com wrote: and then set the PYTHONHOME environment variable to /usr/lib. Rather, just /usr. -- http://mail.python.org/mailman/listinfo/python-list
Re: script to Login a website
On Wednesday, July 31, 2013 12:21:59 PM UTC-4, John Gordon wrote: In ece5f6b0-16da-4c3a-83d1-6340cb10c...@googlegroups.com wachk...@gmail.com writes: I have created a script to log in a website. It gets its username and password from two files, then log's in with this credentials. My code is not showing me what username it is using to login from the file. And I am not sure if it is even opening up the url and prompting for login. I am stuck can someone help me ? How is the data in 'users.txt' and 'password.txt' organized? Given the filenames, I would expect that 'users.txt' contains one username on each line, and 'password.txt' contains one password on each line, with the first username belonging with the first password, the second username belonging with the second password, and so on. Is this correct? If so, that raises the question of how to handle multiple usernames and passwords. Do you just want to use one, or are you supposed to use them all somehow? Anyway, to begin to solve your problem, I'd copy just the file-reading code into a separate program and add plenty of print statements to make sure it works correctly. Once you have that fixed, then you can worry about the web login stuff. And when you read the contents of each file, be aware that the newlines at the end of each line are included. If you don't want these, be sure to call the rstrip() method to remove traling whitespace. -- 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 Hi John let me answer your questions the user.txt file has one user name on each line and so does the password.txt. with this in mind each user will attempt to log in with all the passwords on password.txt file. when it gets to the end of the line it will go to the next user in users.txt and do the same i.e attempt to log in with all the passwords in the file. So to your second question I will use all the users one after the other attempting to log in. I am able to get each user to use x number of passwords in the password.txt that part works fine. The login section is where I am stuck ? Sam -- http://mail.python.org/mailman/listinfo/python-list
Re: Repository of non-standard modules.
On Wed, Jul 31, 2013 at 5:02 AM, Chris Angelico ros...@gmail.com wrote: On Wed, Jul 31, 2013 at 11:53 AM, Gabor Urban urbang...@gmail.com wrote: Hi, I am to start a new free-time project in the next couple of weeks. I am ready to use open accessible Python modules not wanting to reinvent the weel :-) Is there any repository where I can find Python modules not being part of the standard distribution? Check out the Python Package Index: http://pypi.python.org/ There's also the somewhat prettier crate.io. -- http://mail.python.org/mailman/listinfo/python-list
Re: Lambda function Turing completeness
On Wed, Jul 31, 2013 at 12:53 AM, Musical Notation musicdenotat...@gmail.com wrote: Is it possible to write a Turing-complete lambda function (which does not depend on named functions) in Python? Yes, lambda functions are Turing-complete. You can get anonymous recursion by defining the function to take a recursive function argument and then passing it to itself. For example, this will (inefficiently) give you the 13th Fibonacci number: (lambda f, n: f(f, n))(lambda f, n: n if n 2 else f(f, n-2) + f(f, n-1), 13) -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
In my experience, aligning columns in large tables reduces maintence cost by making it much easier/faster to see what you've got and by providing a way to visually prompt you for the correct value in the correct place when you add new lines. Works great until one of the values changes in size. Say: bla = ( 1.0, 1.1, 1.2, 2.0, 2.1, 2.2, 3.0, 2.1, 3.2, ) And one day you have to change '2.1' to '2.0': bla = ( 1.0, 1.1, 1.2, 2.0, 2.0, 2.2, 3.0, 2.1, 3.2, ) If this happens more than once ( or twice, because I'm patient =)), maintaining the alignment becomes a chore. So I only align columns if I'm typing a table I know won't change. -- Marcelo Mallmann Dias -- http://mail.python.org/mailman/listinfo/python-list
Re: Python descriptor protocol (for more or less structured data)
On 7/31/2013 5:16 AM, CWr wrote: Peter, thanks for your response. Sure, you are right when you say that's easier to use standard attribute assigning via __init__. But my intention was: - reducing the complexiticity of __init__ - avoiding boiler-plates (mostly property descriptors inside of the main class) - creating instances (for complex data strings) only if they will be needed, otherwise use default instances (descriptors) - make it prossible that the data structure can be used in static context - like MyClass.attr - to get default values Standard procedure: class C: DEFAULT_4_TWO = somethint # for following code to work def __init__(self, one, two=None, three=None, four=None, five=None, ...): if not two is None: if two is not None: reads better and is the preferred form. 'is not' is a single comparison operator, just like '!=' and 'not in'. The current CPython AST or peephole optimizer happens to notice that the 'is' operator followed by the 'not' operator can be replaced by the 'is not' operator, but this is not guaranteed for all implementations. self.two = Value(two) else: self.two = Value(self.DEFAULT_4_TWO) self.two = Value(two if two is not None else self.DEFAULT_4_TWO) There is no need to introduce the new name DEFAULT_4_TWO. It is a symptom of using the wrong namespace to get the default. class C: two = default def __init__(self, two=None): self.two = Value(two if two is not None else C.two) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
ImportError: No module named appengine.ext
hey learning python problem facing is under when typing on interpreter from google.appengine.ext import db Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named appengine.ext what to do please help . -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with psycopg2, bytea, and memoryview
On 7/31/2013 9:07 AM, Antoine Pitrou wrote: Frank Millman frank at chagford.com writes: Thanks for that, Antoine. It is an improvement over tobytes(), but i am afraid it is still not ideal for my purposes. I would suggest asking the psycopg2 project why they made this choice, and if they would reconsider. Returning a memoryview doesn't make much sense IMHO. I agree. memoryview objects allow Python code to access the internal data of an object that supports the buffer protocol without copying. Example: the binary image data of an image object. They are not intended to be a standalone objects when there is an obvious alternative (in this case, bytes). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
= Works great until one of the values changes in size. Slightly off-topic, but still sort of related (talking about the size of things), I started picking 1e+30 as my really big some time back because the repr of 1e+99 required more than a glance when it appeared in printed output: repr(1e+30) '1e+30' repr(1e+99) '9.9997e+98' This problem was fixed in 2.7 (and presumably in 3.something as well), but it used to be a problem. :-) Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31, Marcelo MD lists...@gmail.com wrote: In my experience, aligning columns in large tables reduces maintence cost by making it much easier/faster to see what you've got and by providing a way to visually prompt you for the correct value in the correct place when you add new lines. Works great until one of the values changes in size. Say: bla = ( 1.0, 1.1, 1.2, 2.0, 2.1, 2.2, 3.0, 2.1, 3.2, ) And one day you have to change '2.1' to '2.0': bla = ( 1.0, 1.1, 1.2, 2.0, 2.0, 2.2, 3.0, 2.1, 3.2, ) If this happens more than once ( or twice, because I'm patient =)), maintaining the alignment becomes a chore. So I only align columns if I'm typing a table I know won't change. Yes, that was my exprience, too. Besides, after studying The Pragmatic Programmer I removed nearly all the tables from my code and reference them (usually with csv module) instead. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31 16:32, Grant Edwards wrote: On 2013-07-31, Tim Chase python.l...@tim.thechases.com wrote: I interpret Grant's statement as wanting the table to look like for name, value, description in ( (cost, 42, How much it cost), (status, 3141, Status code from ISO-3.14159), ... ): do_something(name, value) print(description) Exactly. When you have more than about 5 columns and 10 rows, having things aligned makes it far, far, easier to maintain. As mentioned by Marcelo, when they can vary in length, maintaining is a pain. Even if your editor supports aligning (like vim with Dr. Chip's align.vim plugin). If I have a table of greater dimensions, I tend to refactor into a more readable+maintainable scheme, whether using dicts or named tuples and then break out the rows onto their own lines: from collections import namedtuple Descriptor = namedtuple(Descriptor, [name, value, description]) for name, value, description in ( Descriptor( name=cost, value=42, description=How much it cost, ), Descriptor( name=status, value=3141, description=Status code from ISO-3.14159, ), ): do_something(name, value) print(description) Using a namedtuple, if you forget one of the fields (or add an extra, or misspell one), it yells at you: TypeError: __new__() takes exactly 4 arguments (2 given) TypeError: __new__() takes exactly 4 arguments (6 given) TypeError: __new__() got an unexpected keyword argument 'nmae' There is redundancy of the kwarg params, but this can be skipped if you prefer DRY code to more readable code. Doing this also has the benefit that, when diffing, you don't get noise when columns are merely adjusted visually. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31, Neil Cerutti ne...@norwich.edu wrote: Besides, after studying The Pragmatic Programmer I removed nearly all the tables from my code and reference them (usually with csv module) instead. I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). -- Grant Edwards grant.b.edwardsYow! Spreading peanut at butter reminds me of gmail.comopera!! I wonder why? -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31 16:32, Grant Edwards wrote: On 2013-07-31, Tim Chase python.l...@tim.thechases.com wrote: I interpret Grant's statement as wanting the table to look like for name, value, description in ( (cost, 42, How much it cost), (status, 3141, Status code from ISO-3.14159), ... ): do_something(name, value) print(description) Exactly. When you have more than about 5 columns and 10 rows, having things aligned makes it far, far, easier to maintain. As mentioned by Marcelo, when they can vary in length, maintaining is a pain. Even if your editor supports aligning (like vim with Dr. Chip's align.vim plugin). If I have a table of greater dimensions, I tend to refactor into a more readable+maintainable scheme, whether using dicts or named tuples and then break out the rows onto their own lines: from collections import namedtuple Descriptor = namedtuple(Descriptor, [name, value, description]) for name, value, description in ( Descriptor( name=cost, value=42, description=How much it cost, ), Descriptor( name=status, value=3141, description=Status code from ISO-3.14159, ), ): do_something(name, value) print(description) Using a namedtuple, if you forget one of the fields (or add an extra, or misspell one), it yells at you: TypeError: __new__() takes exactly 4 arguments (2 given) TypeError: __new__() takes exactly 4 arguments (6 given) TypeError: __new__() got an unexpected keyword argument 'nmae' There is redundancy of the kwarg params, but this can be skipped if you prefer DRY code to more readable code. Doing this also has the benefit that, when diffing, you don't get noise when columns are merely adjusted visually. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named appengine.ext
On Wed, Jul 31, 2013 at 7:51 PM, Jaiky jaiprakashsingh...@gmail.com wrote: hey learning python problem facing is under when typing on interpreter from google.appengine.ext import db Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named appengine.ext what to do please help . -- http://mail.python.org/mailman/listinfo/python-list You do not have the Google AppEngine packages installed on your system. You may want to get the AppEngine SDK or the AppEngine development server. -- Chris “Kwpolska” Warrick http://kwpolska.tk PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named appengine.ext
In 719f0bd8-cddc-4b28-97ee-08b56d359...@googlegroups.com Jaiky jaiprakashsingh...@gmail.com writes: from google.appengine.ext import db Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named appengine.ext what to do please help . Has the Google App Engine library been installed on your system? -- 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: ImportError: No module named appengine.ext
you mean to say SDK for python ?/ -- http://mail.python.org/mailman/listinfo/python-list
Using system python vs. updated/current version
Hello there, What would be considered the correct/best way to run a current release of python locally vs. the installed system version? On openSUSE 12.3, the repos currently have 2.7.3 and 3.3.0. As far as I know, I'm not really hitting any limitations with the existing versions - my skills just aren't that far along - so its not a burning 'need' but I'm still curious/interested in the topic. Also... in some places in the 'Net I see references to installing everything 'locally' via pip, etc. in virtualenvs and not touching the system installed version of python... yet most linux distros seem to have many/most such packages available in their package repos, which seems like it'd be easier to install via the package manager and let it keep things updated. Could someone touch on what they feel the pros and cons would be either way? Thanks, Monte -- http://mail.python.org/mailman/listinfo/python-list
Editing tabular data [was: PEP8 79 char max]
I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). My guess is it would be more foolproof to edit that stuff with a spreadsheet. Skip -- http://mail.python.org/mailman/listinfo/python-list
RE: PEP8 79 char max
Grant Edwards wrote: On 2013-07-31, Neil Cerutti ne...@norwich.edu wrote: Besides, after studying The Pragmatic Programmer I removed nearly all the tables from my code and reference them (usually with csv module) instead. I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). -- Grant Edwards grant.b.edwardsYow! Spreading peanut at butter reminds me of gmail.comopera!! I wonder why? -- True, but a CSV file is easy to edit in something like a spreadsheet application (LibreOffice/MS Office); alignment becomes automatic then. Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31, Grant Edwards invalid@invalid.invalid wrote: On 2013-07-31, Neil Cerutti ne...@norwich.edu wrote: Besides, after studying The Pragmatic Programmer I removed nearly all the tables from my code and reference them (usually with csv module) instead. I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). Yes, but it is much easier to manipulate and view. I often still edit the tables with Vim, but when I just want to view them I can open them with Excel and get a very attractive display or printout with minimal effort. If it turns out I need to convert the table to some new format, tools are abundant. A couple of big wins: It turned out later that some other entity needed the same data. It has allowed me to add functionality to my program without even editing the program. Wouldn't be cool to add a new instruction by to my assembler, including documentation, merely by editing a csv file? (I admit that would need quite a bit of engineering to work, but it would be cool.) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31, Neil Cerutti ne...@norwich.edu wrote: On 2013-07-31, Grant Edwards invalid@invalid.invalid wrote: On 2013-07-31, Neil Cerutti ne...@norwich.edu wrote: Besides, after studying The Pragmatic Programmer I removed nearly all the tables from my code and reference them (usually with csv module) instead. I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). Yes, but it is much easier to manipulate and view. I often still edit the tables with Vim, but when I just want to view them I can open them with Excel and get a very attractive display or printout with minimal effort. If you're good at Excel. I use a spreadsheet at most a few times a year, and it has been many years since I've used Excel. I find that doing _anything_ with Excel generally involves at least an hour of hairpulling and swearing. Libreoffice isn't much better. If it turns out I need to convert the table to some new format, tools are abundant. True. A couple of big wins: It turned out later that some other entity needed the same data. It would save the two seconds it takes to extract the lines from the Python file. It has allowed me to add functionality to my program without even editing the program. Now you're playing with semantics. If I have a bunch of lines containing values separated by commas, and I'm editting them, then it makes no difference to me which file they're in -- I'm still adding functionality be editing a table of data. Wouldn't be cool to add a new instruction by to my assembler, including documentation, merely by editing a csv file? (I admit that would need quite a bit of engineering to work, but it would be cool.) Yes, that's cool, and that's pretty much how it works. Those csv lines just happen to be in the same file as the rest of the assembler source rather than in a second file. -- Grant Edwards grant.b.edwardsYow! Hello? Enema Bondage? at I'm calling because I want gmail.comto be happy, I guess ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Editing tabular data [was: PEP8 79 char max]
On 2013-07-31, Skip Montanaro s...@pobox.com wrote: I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). My guess is it would be more foolproof to edit that stuff with a spreadsheet. Many years ago, I worked with somebody who used a spreadsheet like that. I tried it and found it to be way too cumbersome. The overhead involved of putting tables in to slew of different files and starting up LibreOffice to edit/view them is huge compared to just editing them with emacs in a file along with the source code. Maybe my computer is too old/slow. Maybe it's just due to how bad I am at Excel/LibreOffice... -- Grant Edwards grant.b.edwardsYow! I haven't been married at in over six years, but we gmail.comhad sexual counseling every day from Oral Roberts!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Editing tabular data [was: PEP8 79 char max]
On 2013-07-31, Rhodri James rho...@wildebst.demon.co.uk wrote: On Wed, 31 Jul 2013 19:39:29 +0100, Skip Montanaro s...@pobox.com wrote: I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). My guess is it would be more foolproof to edit that stuff with a spreadsheet. There's nothing foolproof about using a spreadsheet! I edit csv files using Excel all the time. But I don't use it to edit my hand-created data files. It does too much meddling. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Editing tabular data [was: PEP8 79 char max]
On Wed, 31 Jul 2013 19:39:29 +0100, Skip Montanaro s...@pobox.com wrote: I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). My guess is it would be more foolproof to edit that stuff with a spreadsheet. There's nothing foolproof about using a spreadsheet! -- Rhodri James *-* Wildebeest Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
pcurl and network connection's problem
I am having problems with pycurl in my threads , when i run it , it does correctly but some times the connection has been established but nothing will be downloaded and the threads stay alive without doing any thing (especially when the network's speed is slow and has aborted status) . i can't use TIMEOUT because i don't have the max time for downloading how can i solve this problem in python -- http://mail.python.org/mailman/listinfo/python-list
RE: Using system python vs. updated/current version
memilanuk wrote: Hello there, What would be considered the correct/best way to run a current release of python locally vs. the installed system version? On openSUSE 12.3, the repos currently have 2.7.3 and 3.3.0. As far as I know, I'm not really hitting any limitations with the existing versions - my skills just aren't that far along - so its not a burning 'need' but I'm still curious/interested in the topic. You should be able to install both Python 2 and 3 in most modern Linux distributions (at the same time). I would not change the system Python version. If you are not blocked from running Python 3 by some necessary dependency then you should use it. Otherwise, use the most recent Python version you can. Also... in some places in the 'Net I see references to installing everything 'locally' via pip, etc. in virtualenvs and not touching the system installed version of python... yet most linux distros seem to have many/most such packages available in their package repos, which seems like it'd be easier to install via the package manager and let it keep things updated. Could someone touch on what they feel the pros and cons would be either way? Virtual envs are great if you work on multiple projects and want to keep each project's dependencies separate and manageable. This will let you change dependencies to a newer version based on project rather than having to change the dependency for all projects. Not to mention this also allows you to install packages on hosts that you do not have access to install them to the system packages directory. On a personal machine, I would install some things like pip/virtualenv (/numpy maybe) to system packages directory but keep most packages in a project specific directory (i.e. virtualenv). Thanks, Monte This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31, Grant Edwards invalid@invalid.invalid wrote: On 2013-07-31, Neil Cerutti ne...@norwich.edu wrote: On 2013-07-31, Grant Edwards invalid@invalid.invalid wrote: On 2013-07-31, Neil Cerutti ne...@norwich.edu wrote: Besides, after studying The Pragmatic Programmer I removed nearly all the tables from my code and reference them (usually with csv module) instead. I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). Yes, but it is much easier to manipulate and view. I often still edit the tables with Vim, but when I just want to view them I can open them with Excel and get a very attractive display or printout with minimal effort. If you're good at Excel. I use a spreadsheet at most a few times a year, and it has been many years since I've used Excel. I find that doing _anything_ with Excel generally involves at least an hour of hairpulling and swearing. Libreoffice isn't much better. If it turns out I need to convert the table to some new format, tools are abundant. True. A couple of big wins: It turned out later that some other entity needed the same data. It would save the two seconds it takes to extract the lines from the Python file. ...assuming I'm not creating a maintenance problem by duplicating the table. Most likely you would end up externalizing the table at that point, right? It has allowed me to add functionality to my program without even editing the program. Now you're playing with semantics. If I have a bunch of lines containing values separated by commas, and I'm editting them, then it makes no difference to me which file they're in -- I'm still adding functionality be editing a table of data. The separation of data and program is more distinct in my version, but you're right, of course. An internal representation in addition has the advantage of being able to directly use Python identifiers and expressions, too. But if you take advantage of those features when the time comes to externalize your data it's more work. The only cost you pay more than what I've already spent at that point is whatever time you spent creating the non-external version to begin with. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
RE: pcurl and network connection's problem
sam319 wrote: I am having problems with pycurl in my threads , when i run it , it does correctly but some times the connection has been established but nothing will be downloaded and the threads stay alive without doing any thing (especially when the network's speed is slow and has aborted status) . i can't use TIMEOUT because i don't have the max time for downloading how can i solve this problem in python So you want to wait hours/days/years for a failed download? You should always set a timeout that is sane. If you anticipate network slowness, then set your timeout to something larger like 2-3 minutes. IIRC, the timeout only affects connection establishment so that will not help out your use case but I want to emphasize that you always want a timeout to be set. Pycurl has an option for LOW_SPEED_LIMIT/LOW_SPEED_TIME which should allow you to set a minimum transfer speed which will abort the transfer. This should solve your problem where the connection is created but nothing is being downloaded. See: http://stackoverflow.com/questions/4960021/handle-pycurl-hang-on-twitter-streaming-api Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: Editing tabular data [was: PEP8 79 char max]
My guess is it would be more foolproof to edit that stuff with a spreadsheet. Many years ago, I worked with somebody who used a spreadsheet like that. I really love Emacs, however... One of the traders here where I work (who shall not be named) had a space-delimited data file with hundreds of rows and 50 or so columns. I could never get him to edit it in any kind of spreadsheet or put it in a database (expecting him to master SQL would have been pointless - I would have had to write a GUI tool for him). He always modified it in Emacs, and would delete columns, add extra spaces, fragmentary rows, etc. He'd edit this file late at night, the automated processes the next morning would crap out, and I would scramble to try and find and fix the problem before the market opened. This is clearly a case where choosing the proper tool is important. I agree that using a spreadsheet to edit a 3x5 CSV file is likely overkill (might just as well use Notepad or TextEdit), but tabular data are tabular data, no matter how they might be delimited, and if there are many of those little data critters, there are better tools than a text editor (or Python IDE) for maintaining them. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
Le mercredi 31 juillet 2013 07:45:18 UTC+2, Steven D'Aprano a écrit : On Tue, 30 Jul 2013 12:09:11 -0700, wxjmfauth wrote: And do not forget, in a pure utf coding scheme, your char or a char will *never* be larger than 4 bytes. sys.getsizeof('a') 26 sys.getsizeof('\U000101000') 48 Neither character above is larger than 4 bytes. You forgot to deduct the size of the object header. Python is a high-level object-oriented language, if you care about minimizing every possible byte, you should use a low-level language like C. Then you can give every character 21 bits, and be happy that you don't waste even one bit. -- Steven ... char never consumes or requires more than 4 bytes ... jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: Using system python vs. updated/current version
On 07/31/2013 12:17 PM, Prasad, Ramit wrote: You should be able to install both Python 2 and 3 in most modern Linux distributions (at the same time). I would not change the system Python version. I hadn't really planned on mucking with the system python... I recall from a long while back (on Mac OSX) as that being a Bad Thing ;) But that is kind of (one of) the question(s) here... I presume it is 'possible' to run a local version of python, installed in the user's home directory... just curious if its worth the hassle. If you are not blocked from running Python 3 by some necessary dependency then you should use it. Otherwise, use the most recent Python version you can. Are there any significant flaws with v.3.3.0 that would necessitate upgrading to the most recent version (3.3.2?) The only 'dependency' I have as far as 2.7.x is concerned is that I've become rather accustomed to using spyder (IDE)... which at this point doesn't support python3 - definitely a bummer. On a personal machine, I would install some things like pip/virtualenv (/numpy maybe) to system packages directory but keep most packages in a project specific directory (i.e. virtualenv). What about larger gui toolkits like PyQt? Some material I browsed (skimmed) indicated that it wasn't quite as simple to run straight from a virtualenv...? How much of a pain are virtualenvs when working from an IDE? -- http://mail.python.org/mailman/listinfo/python-list
Re: Using system python vs. updated/current version
On 7/31/2013 2:35 PM, memilanuk wrote: Hello there, What would be considered the correct/best way to run a current release of python locally vs. the installed system version? On openSUSE 12.3, the repos currently have 2.7.3 and 3.3.0 released April 2012. 2.7.5 100+?? bug fixes. and released Sept 2012, fewer bug fixes. As far as I know, I'm not really hitting any limitations with the existing versions Quite possible. However, anyone using Idle should get the latest versions since there have been many Idle fixes since last September. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: script to Login a website
On Wed, Jul 31, 2013 at 11:33 AM, wachk...@gmail.com wrote: I have created a script to log in a website. It gets its username and password from two files, then log's in with this credentials. My code is not showing me what username it is using to login from the file. And I am not sure if it is even opening up the url and prompting for login. I am stuck can someone help me ? import urllib, urllib2 user = open ('users.txt' , 'r') password = open ('password.txt' , 'r') for users in user: password.seek(0) for pass_list in password: login_data = users + '\n' + pass_list print login_data I think you will note that login_data is overwritten each password loop. In the end of all of the above you have the last users followed by a newline, followed by the last pass_list You might want to think about putting the code below in a function that can be called after print login_data above if you want to check each username and password combination. base_url = 'http://mysite.com' #login action we want to post data to response = urllib2.Request(base_url) login_action = '/auth/login' login_action = base_url + login_action response = urllib2.urlopen(login_action, login_data) I don't think the above line provides login_data as specified by the spec: http://docs.python.org/2/library/urllib2.html#module-urllib2 It looks like data needs to be tuples response.read() print response.headers print response.getcode() -- Once you correct the top of your code I recommend Requests module since its easier to understand, simpler, and better documented than the standard url stuff. You can find it at http://docs.python-requests.org/en/latest/ http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Editing tabular data [was: PEP8 79 char max]
On Wednesday, July 31, 2013 2:39:29 PM UTC-4, Skip Montanaro wrote: I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). My guess is it would be more foolproof to edit that stuff with a spreadsheet. Skip Has anyone tried Pyspread? http://manns.github.io/pyspread/ -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
On Wed, Jul 31, 2013 at 9:15 PM, wxjmfa...@gmail.com wrote: ... char never consumes or requires more than 4 bytes ... The integer 5 should be able to be stored in 3 bits. sys.getsizeof(5) 14 Clearly Python is doing something really horribly wrong here. In fact, sys.getsizeof needs to be changed to return a float, to allow it to more properly reflect these important facts. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Using system python vs. updated/current version
On 7/31/2013 4:19 PM, memilanuk wrote: Are there any significant flaws with v.3.3.0 that would necessitate upgrading to the most recent version (3.3.2?) Go to the overview page http://docs.python.org/3/index.html and click on 'What's new in Python 3.3' to get to http://docs.python.org/3/whatsnew/3.3.html Click the 'changelog' link at the end of the first sentence. http://docs.python.org/3.3/whatsnew/changelog.html Browse through the 3.3.1 and 3.3.2 sections for bug fixes. Decide if any of the entries are relevant to you. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Editing tabular data [was: PEP8 79 char max]
Has anyone tried Pyspread? I have not. I have a fundamental problem with spreadsheets, the extremely narrow view of the workspace. There was a piece on NPR the other day about some errors in some modeling applications. I missed most of it (does someone have a link? I'm on my phone right now), but the expert commentator was saying that they are working on standard structures for these sorts of complex modeling simulations. I think they will need more than that. Something like pyspread might allow you to mix structured and object oriented programming with the convenience if a spreadsheet. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Using system python vs. updated/current version
On 1/08/2013 4:35 AM, memilanuk wrote: Also... in some places in the 'Net I see references to installing everything 'locally' via pip, etc. in virtualenvs and not touching the system installed version of python... yet most linux distros seem to have many/most such packages available in their package repos, which seems like it'd be easier to install via the package manager and let it keep things updated. Could someone touch on what they feel the pros and cons would be either way? Generally, if your OS installs a version of Python by default you should leave it alone because the OS itself is dependent on it. Updating to newer versions of Python or installed libraries can introduce version conflict errors in system-level apps, which is a bad thing. Similarly, using the system install libraries ties you to those versions. This may not be an issue if you're just scripting a few helper tools for your system, but it's an unnecessary hinderance if you're developing independent applications. Tools like virtualenv or zc.buildout provide a handy way of sandboxing the dependencies of individual applications. They let you build more than one app in parallel and not let the dependencies of one interfere with the others. Of equal importance is their use in deploying to other machines. With virtualenv, you can create a list of installed libraries with: pip freeze requirements.txt To ensure a target machine has all of the dependencies your application needs you can then do: pin install -r requirements.txt So: for simple scripts, just go with the system install. For serious development work, I highly recommend using virtualenv or zc.buildout to contain each development environment. -- http://mail.python.org/mailman/listinfo/python-list
Re: Editing tabular data [was: PEP8 79 char max]
On Wed, Jul 31, 2013 at 8:02 PM, Grant Edwards invalid@invalid.invalid wrote: On 2013-07-31, Skip Montanaro s...@pobox.com wrote: I don't understand. That just moves them to a different file -- doesn't it? You've still got to deal with editing a large table of data (for example when I want to add instructions to your assembler). My guess is it would be more foolproof to edit that stuff with a spreadsheet. Many years ago, I worked with somebody who used a spreadsheet like that. I tried it and found it to be way too cumbersome. The overhead involved of putting tables in to slew of different files and starting up LibreOffice to edit/view them is huge compared to just editing them with emacs in a file along with the source code. Maybe my computer is too old/slow. Maybe it's just due to how bad I am at Excel/LibreOffice... I'm glad someone else feels that way! At work, we have a number of CSV files (at my boss's insistence; I would much rather they be either embedded in the source, or in some clearer and simpler format) which I like to manipulate in SciTE, rather than OO/LibreOffice. (I'll not distinguish those two. Far as I'm concerned, they're one product with two names.) My boss can't understand why I do this. I can't understand why he objects to having to edit code files to alter internal data. I have pointed him to [1] but to no avail. The one thing I would do, though, is align with tabs rather than spaces. That gives you an 8:1 (if you keep your tabs at eight, which I do) improvement in maintainability, because edits that don't cross a boundary don't require fiddling with the layout. [1] http://thedailywtf.com/Articles/Soft_Coding.aspx ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Using system python vs. updated/current version
On Wed, Jul 31, 2013 at 7:35 PM, memilanuk memila...@gmail.com wrote: Also... in some places in the 'Net I see references to installing everything 'locally' via pip, etc. in virtualenvs and not touching the system installed version of python... yet most linux distros seem to have many/most such packages available in their package repos, which seems like it'd be easier to install via the package manager and let it keep things updated. Could someone touch on what they feel the pros and cons would be either way? I personally like to compile some things from source (CPython, Pike, etc - though not everything, I use a prepackaged PostgreSQL, for instance). There's no harm in installing a new CPython on a Linux box - just type 'sudo make altinstall' (or however you become root), and it'll give you a binary called python3.4 or whatever version, without touching your system Python. That lets you run as many versions as you like, in parallel, though you may have issues running 3.3.0 and 3.3.2 (but there should be no reason to do so - just use 3.3.2). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script help
On 31/07/2013 6:15 PM, cool1...@gmail.com wrote: Here are some scripts, how do I put them together to create the script I want? (to search a online document and download all the links in it) 1. Think about the requirements. 2. Write some code. 3. Test it. 4. Repeat until requirements are met. p.s: can I set a destination folder for the downloads? Yes. Show us you're actively trying to solve this yourself rather than just asking us to write the code for you. -- http://mail.python.org/mailman/listinfo/python-list
[issue18596] enable usage of AddressSanitizer in CPython [PATCH]
halfie added the comment: Using, # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS __attribute__((no_address_safety_analysis)) __attribute__ ((noinline)) instead of, # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS __attribute__((no_address_safety_analysis)) seems to be a more future-proof (against inlining) solution. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18596 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18585] Add a text truncation function
Vajrasky Kok added the comment: Monsieur Pitrou, thanks for the explanation. Actually, IMHO I prefer, 'hello (...)' should be the minimum words we can use not '(...)' because '(...)' does not make any sense. But, anyway, it's your call. :) Anyway, using your summarize2.patch: textwrap.summarize('hello world!', width=6) '(...)' textwrap.summarize('hello world!', width=5) Traceback (most recent call last): File stdin, line 1, in module File /home/ethan/Documents/code/python/cpython/Lib/textwrap.py, line 378, in summarize return w.summarize(text, placeholder=placeholder) File /home/ethan/Documents/code/python/cpython/Lib/textwrap.py, line 314, in summarize raise ValueError(placeholder too large for max width) ValueError: placeholder too large for max width Why? '(...)' is 5 characters only. I checked the patch and found out that the placeholder is ' (...)' (with space) and you compare the width with the placeholder. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18585 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18214] Stop purging modules which are garbage collected before shutdown
Antoine Pitrou added the comment: See issue10068 and issue7140. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18214 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17933] format str bug in urllib request.py
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17933 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18573] In unittest.TestCase.assertWarns doc there is some text about assertRaises()
py.user added the comment: What second line? the second line patched in the diff file -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18573 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18605] 2.7: test_threading hangs on Solaris 9
New submission from Maciej Bliziński: Python version: 2.7.5 OS: Solaris 9 Architecture: sparc Looks similar to Issue5114 and Issue6643 but both are now closed. It seems specific to Solaris 9, I'm not seeing this issue on Solaris 10. The symptom is that test_threading hangs indefinitely (tested overnight) . When running pstack on the process, I'm seeing this: - lwp# 1 / thread# 1 ff3dc734 lwp_park (0, 0, 0) ff3d3c74 s9_lwp_park (0, 0, 0, 1, feed4f48, 18f5a4) + 28 ff3dc698 s9_handler (0, 0, 0, 1, feed4f48, 18f5a4) + 90 ff1dea70 _sema_wait (0, feee66a0, fed6b054, feee6000, 2a298478, d1f20) + 1d4 ff1dec30 sema_wait (81aa8, ff1dec24, 722a5b4b, 1101c, feed4f48, 134d60) + c feed4f48 sem_wait (81aa8, 0, fed6b1ac, 0, 0, 1) + 20 ff050890 PyThread_acquire_lock (81aa8, 1, fed6b214, 2, 0, 1ae778) + 5c ff05524c lock_PyThread_acquire_lock (0, 22030, 0, 13ee40, 16a298, 55150) + 50 fefa779c PyCFunction_Call (1ae788, 22030, 0, ff0d8eb8, 55150, ff0551fc) + e4 ff016b14 PyEval_EvalFrameEx (18f5a0, 0, 0, d4f66, 16a298, 22030) + 5ee8 ff0185d0 PyEval_EvalCodeEx (12c968, 0, 18f5a0, 4, 1, 18f5a4) + 924 ff0168f8 PyEval_EvalFrameEx (1902b8, 0, 1, 1765c0, 16a298, 1b12d0) + 5ccc ff0185d0 PyEval_EvalCodeEx (13f608, 0, 1902b8, 4, 1, 1902bc) + 924 ff0168f8 PyEval_EvalFrameEx (154748, 0, 1, 31f7f, 16a298, 1b1250) + 5ccc ff0185d0 PyEval_EvalCodeEx (10d650, 54a50, 154748, 2203c, 0, 2203c) + 924 fef8e11c function_call (22038, 22030, 1386f0, 2203c, 130730, 22030) + 168 fef604e8 PyObject_Call (130730, 22030, 1386f0, ff0e0340, fef8dfb4, 0) + 60 ff0137dc PyEval_EvalFrameEx (169110, 0, 22030, 10e62d, 16a298, 22030) + 2bb0 ff017478 PyEval_EvalFrameEx (168f80, 0, 169114, 1769fa, 16a298, 16a298) + 684c ff017478 PyEval_EvalFrameEx (176cb0, 0, 168f84, 12a2c0, 16a298, 16a298) + 684c ff0185d0 PyEval_EvalCodeEx (13f410, 176cb4, 176cb0, 13433c, 1, 0) + 924 fef8e040 function_call (1b26f0, 134330, 0, ff1bc000, 1b26f0, 0) + 8c fef604e8 PyObject_Call (1b26f0, 134330, 0, ff0e0340, fef8dfb4, 134320) + 60 fef6e530 instancemethod_call (0, 134330, 0, 0, 1b26f0, 134bd0) + a4 fef604e8 PyObject_Call (c3b48, 22030, 0, ff0e0340, fef6e48c, 0) + 60 ff01051c PyEval_CallObjectWithKeywords (c3b48, 22030, 0, 0, 0, 0) + 68 ff05568c t_bootstrap (63bd0, 0, 0, 0, 16a298, ff0e2804) + 4c ff1e53a4 _lwp_start (0, 0, 0, 0, 0, 0) - lwp# 2 / thread# 2 ff3dc734 lwp_park (0, 0, 0) ff3d3c74 s9_lwp_park (0, 0, 0, 1, b64a0d58, 136818) + 28 ff3dc698 s9_handler (0, 0, 0, 1, b64a0d58, 136818) + 90 ff1dea70 _sema_wait (0, feee66a0, fec6b054, feee6000, 2a298478, d1f20) + 1d4 ff1dec30 sema_wait (8ab00, ff1dec24, 722a5b4b, 1101c, feed4f48, 134d60) + c feed4f48 sem_wait (8ab00, 0, fec6b1ac, 0, 0, 1) + 20 ff050890 PyThread_acquire_lock (8ab00, 1, fec6b214, 2, 0, 1ae610) + 5c ff05524c lock_PyThread_acquire_lock (0, 22030, 0, 13ee40, 156168, 55160) + 50 fefa779c PyCFunction_Call (1ae620, 22030, 0, ff0d8eb8, 55160, ff0551fc) + e4 ff016b14 PyEval_EvalFrameEx (18fe60, 0, 0, d4f66, 156168, 22030) + 5ee8 ff0185d0 PyEval_EvalCodeEx (12c968, 0, 18fe60, 4, 1, 18fe64) + 924 ff0168f8 PyEval_EvalFrameEx (18fce8, 0, 1, 1765c0, 156168, 1b11b0) + 5ccc ff0185d0 PyEval_EvalCodeEx (13f608, 0, 18fce8, 4, 1, 18fcec) + 924 ff0168f8 PyEval_EvalFrameEx (18fb88, 0, 1, 136155, 156168, 1a2930) + 5ccc ff0185d0 PyEval_EvalCodeEx (48b60, 18fb8c, 18fb88, 19d41c, 1, 2203c) + 924 fef8e11c function_call (22038, 19d410, 1b3c00, 2203c, 130370, 22030) + 168 fef604e8 PyObject_Call (130370, 19d410, 1b3c00, ff0e0340, fef8dfb4, 19d400) + 60 ff0137dc PyEval_EvalFrameEx (18fa20, 0, 19d410, 10e62d, 156168, 134950) + 2bb0 ff017478 PyEval_EvalFrameEx (18f890, 0, 18fa24, 1769fa, 156168, 156168) + 684c ff017478 PyEval_EvalFrameEx (18f728, 0, 18f894, 12a2c0, 156168, 156168) + 684c ff0185d0 PyEval_EvalCodeEx (13f410, 18f72c, 18f728, 19d3fc, 1, 0) + 924 fef8e040 function_call (1b26f0, 19d3f0, 0, ff1bc000, 1b26f0, 0) + 8c fef604e8 PyObject_Call (1b26f0, 19d3f0, 0, ff0e0340, fef8dfb4, 19d3e0) + 60 fef6e530 instancemethod_call (0, 19d3f0, 0, 0, 1b26f0, 1b1250) + a4 fef604e8 PyObject_Call (1aeaf8, 22030, 0, ff0e0340, fef6e48c, 0) + 60 ff01051c PyEval_CallObjectWithKeywords (1aeaf8, 22030, 0, 0, 0, 0) + 68 ff05568c t_bootstrap (63c30, 0, 0, 0, 156168, ff0e2804) + 4c ff1e53a4 _lwp_start (0, 0, 0, 0, 0, 0) -- components: Tests messages: 193978 nosy: automatthias priority: normal severity: normal status: open title: 2.7: test_threading hangs on Solaris 9 type: compile error versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18605 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17998] internal error in regular expression engine
Larry Hastings added the comment: There is now a need to rush. I'm hoping to cut the release in about two days, so we can have Python 3.4a1 on time. Can we resolve this in the next day or two? Sorry for the short notice. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18257] Two copies of python-config
Larry Hastings added the comment: Is there any resolution for this likely to happen soon? I'm hoping to cut Python 3.4a1 in about two days, so one of three things is gonna happen: 1) This gets fixed. 2) This gets lowered from release blocker. 3) The release slips. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18257 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5845] rlcompleter should be enabled automatically
Larry Hastings added the comment: This issue seems to have stalled. But it's still marked as a release blocker, which means I can't release Python 3.4a1 in two days if this issue is still open. One of three things will happen: 1) This issue is marked closed. 2) This issue is downgraded from release blocker. 3) The alpha slips. IMO the optimal solution is that tab preceded by only whitespace indents, and tab preceded by any non-whitespace character attempts to complete. Can we goad readline into behaving this way? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18071] _osx_support compiler_fixup
Roundup Robot added the comment: New changeset addd9210816b by Ned Deily in branch '2.7': Issue #18071: Extension module builds on OS X could fail with TypeError http://hg.python.org/cpython/rev/addd9210816b -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16245] Update html.entities.html5 dictionary and parseentities.py
Larry Hastings added the comment: This is still marked as a release blocker. I guess this is a tickler for Ezio to go check and see if there's a new entities file. Ezio: can you get this issue closed or downgraded in the next two days? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16245 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com