Re: Split a list into two parts based on a filter?

2013-06-12 Thread Terry Reedy
On 6/12/2013 7:39 AM, Roy Smith wrote: starts. But, somewhat more seriously, I wonder what, exactly, it is that freaks people out about: [(new_songs if s.is_new() else old_songs).append(s) for s in songs] Clearly, it's not the fact that it build and immediately discards a list, because that

Re: Split a list into two parts based on a filter?

2013-06-12 Thread Terry Reedy
On 6/12/2013 12:57 PM, Fábio Santos wrote: Why is there no builtin to consume a generator? I find that odd. There are several builtins than consume generators -- and do something useful with the yielded objects. What you mean is "Why is there no builtin to uselessly consume a generator?" The

Re: .mat files processing in Python

2013-06-12 Thread Terry Reedy
On 5/27/2013 4:43 PM, Romila Anamaria wrote: I am beginner in Python programming and I want to make an application Please post plain test only, not html (with a font size too small to read ;-). Don't send attachments, especially not 2 MB files. -- Terry Jan Reedy -- http://mail.python.org/

Re: Pywart: The problem with "Rick Johnson"

2013-06-12 Thread Terry Reedy
On 6/4/2013 11:45 PM, Mike Hansen wrote: Is "Rick Johnson" the alter ego of Xah Lee, or is he the result of a cross breeding experiement with a troll by Saruman at Isengard? He is a Python programmer competent enough with tkinter to have given useful answers to me and others. He occasionally

Re: Version Control Software

2013-06-13 Thread Terry Reedy
On 6/13/2013 6:20 PM, Zero Piraeus wrote: : On 13 June 2013 17:53, Grant Edwards wrote: Unfortunately, something that requires typing commands would not fly. I haven't used it (very rarely use GUI dev tools), but Tortoise Hg seems to have a decent reputati

Re: Pattern Search Regular Expression

2013-06-15 Thread Terry Reedy
On 6/15/2013 12:28 PM, subhabangal...@gmail.com wrote: Suppose I want a regular expression that matches both "Sent from my iPhone" and "Sent from my iPod". How do I write such an expression--is the problem, "Sent from my iPod" "Sent from my iPhone" which can be written as, re.compile("Sent fro

Re: Timsort in Cpython

2013-06-15 Thread Terry Reedy
On 6/15/2013 4:21 PM, alphons...@gmail.com wrote: Well. I'm going to have a ton of fun trying to make sense of this. http://hg.python.org/cpython/file/default/Objects/listsort.txt is pretty clear (to me) for most of the basics. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/p

Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread Terry Reedy
On 6/15/2013 8:03 PM, MRAB wrote: On 15/06/2013 23:10, alex23 wrote: \__init__.py", line 123 raise CodecRegistryError,\ ^ SyntaxError: invalid syntax To me that traceback looks like it's Python 3 trying to run code written for Python 2. If that is the case, the ^ should be under the ',' (a

Re: Version Control Software

2013-06-16 Thread Terry Reedy
On 6/16/2013 1:29 AM, Chris Angelico wrote: On Sun, Jun 16, 2013 at 3:20 PM, Steven D'Aprano If you're bringing in the *entire* CPython code base, as shown here: http://hg.python.org/ This is the python.org collection of repositories, not just cpython. keep in mind that it includes the eq

Re: Version Control Software

2013-06-16 Thread Terry Reedy
On 6/16/2013 11:48 AM, Lele Gaifax wrote: Roy Smith writes: In article , Chris Kwpolska Warrick wrote: (I��m using wc -c to count the bytes in all files there are. du is unaccurate with files smaller than 4096 bytes.) It's not that du is not accurate, it's that it's measuring something

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Terry Reedy
On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace:

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Terry Reedy
On 6/17/2013 1:17 PM, Νίκος wrote: On Mon, Jun 17, 2013 at 8:55 AM, Simpleton wrote: On 17/6/2013 5:22 μμ, Terry Reedy wrote: When you interpret Python code, do you put data in locations with integer addresses? I lost you here. Memory in biological brains is not a linear series of bits

Re: decorator to fetch arguments from global objects

2013-06-18 Thread Terry Reedy
On 6/18/2013 5:47 AM, andrea crotti wrote: Using a CouchDB server we have a different database object potentially for every request. We already set that db in the request object to make it easy to pass it around form our django app, however it would be nice if I could set it once in the API and

Re: os.putenv() has no effect

2013-06-18 Thread Terry Reedy
On 6/18/2013 12:49 PM, Johannes Bauer wrote: Hi group, I've tracked down a bug in my application to a rather strange phaenomenon: os.putenv() doesn't seem to have any effect on my platform (x86-64 Gentoo Linux, Python 3.2.3): os.getenv("PATH") '/usr/joebin:/usr/local/bin:/usr/bin:/bin:/usr/ga

Re: Why is regex so slow?

2013-06-18 Thread Terry Reedy
On 6/18/2013 4:30 PM, Grant Edwards wrote: On 2013-06-18, Antoine Pitrou wrote: Roy Smith panix.com> writes: You should read again on the O(...) notation. It's an asymptotic complexity, it tells you nothing about the exact function values at different data points. So you can have two O(n) rou

Re: collecting variable assignments through settrace

2013-06-18 Thread Terry Reedy
On 6/18/2013 2:38 PM, skunkwerk wrote: Hi, I'm writing a custom profiler that uses sys.settrace. I was wondering if there was any way of tracing the assignments of variables inside a function as its executed, without looking at locals() at every single line and comparing them to see if anything

Re: Writing Extensions for Python 3 in C

2013-06-19 Thread Terry Reedy
On 6/18/2013 6:24 AM, Aditya Avinash wrote: Hi. This is the last place where I want to ask a question. I have searched for lots of tutorials and documentation on the web but, didn't find a decent one to develop extensions for Python 3 using a custom compiler (mingw32, nvcc). Please help me. I w

Re: decorator to fetch arguments from global objects

2013-06-19 Thread Terry Reedy
On 6/19/2013 4:03 AM, Wolfgang Maier wrote: Wolfgang Maier biologie.uni-freiburg.de> writes: andrea crotti gmail.com> writes: 2013/6/18 Terry Reedy udel.edu> Decorators are only worthwhile if used repeatedly. What you specified can easily be written, for instance, as def sa

Re: A Beginner's Doubt

2013-06-19 Thread Terry Reedy
On 6/19/2013 9:58 AM, augusto...@gmail.com wrote: Hello! This is my first post in this group and the reason why I came across here is that, despite my complete lack of knowledge in the programming area, I received an order from my teacher to develop a visually interactive program, until 20th J

Re: Does upgrade from 2.7.3 to 2.7.5 require uninstall?

2013-06-20 Thread Terry Reedy
On 6/20/2013 2:44 PM, Alister wrote: On Thu, 20 Jun 2013 11:35:49 -0700, Wanderer wrote: Do I need to uninstall Python 2.7.3 before installing Python 2.7.5? Thanks that will depend on your operating system an possibly the variety of python "Python 2.7.3' and 'Python 2.7.5' are by trademark

Re: n00b question on spacing

2013-06-21 Thread Terry Reedy
On 6/21/2013 5:17 PM, Yves S. Garret wrote: Hi, I have a question about breaking up really long lines of code in Python. I have the following line of code: log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'], settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider) G

Re: n00b question on spacing

2013-06-23 Thread Terry Reedy
On 6/22/2013 9:20 PM, MRAB wrote: [snip] One vs not-one isn't good enough. Some languages use the singular with any numbers ending in '1'. Some languages have singular, dual, and plural. Etc. It's surprising how inventive people can be! :-) In the Idle output window for file grepping, I just c

Re: Is this PEP-able? fwhile

2013-06-25 Thread Terry Reedy
On 6/25/2013 7:17 AM, jim...@aol.com wrote: for i in range(n) while safe(i): .. Combined for-while and for-if statements have been proposed before and rejected. We cannot continuously add simple compositions to the langauge. I disagree. The problem IMO is that python 'for's are a different

Re: re.finditer() skips unicode into selection

2013-06-26 Thread Terry Reedy
On 6/26/2013 3:18 PM, akshay.k...@gmail.com wrote: I am using the following Highlighter class for Spell Checking to work on my QTextEdit. class Highlighter(QSyntaxHighlighter): pattern = ur'\w+' def __init__(self, *args): QSyntaxHighlighter.__init__(self, *args) self

Re: Why is the argparse module so inflexible?

2013-06-27 Thread Terry Reedy
On 6/27/2013 8:54 AM, Andrew Berg wrote: I've begun writing a program with an interactive prompt, and it needs to parse input from the user. I thought the argparse module would be great for this, It is outside argparse's intended domain of application -- parsing command line arguments. The gr

Re: Why is the argparse module so inflexible?

2013-06-27 Thread Terry Reedy
On 6/27/2013 2:18 PM, Dave Angel wrote: On 06/27/2013 02:05 PM, Terry Reedy wrote: On 6/27/2013 8:54 AM, Andrew Berg wrote: I've begun writing a program with an interactive prompt, and it needs to parse input from the user. I thought the argparse module would be great for this,

Re: ? get negative from prod(x) when x is positive integers

2013-06-28 Thread Terry Reedy
On 6/28/2013 10:38 AM, Vincent Davis wrote: I have a list of a list of integers. The lists are long so i cant really show an actual example of on of the lists, but I know that they contain only the integers 1,2,3,4. so for example. s2 = [[1,2,2,3,2,1,4,4],[2,4,3,2,3,1]] I am calculating the prod

Re: Why is the argparse module so inflexible?

2013-06-28 Thread Terry Reedy
On 6/29/2013 12:12 AM, rusi wrote: On Saturday, June 29, 2013 7:06:37 AM UTC+5:30, Ethan Furman wrote: On 06/27/2013 03:49 PM, Steven D'Aprano wrote: [rant] I think it is lousy design for a framework like argparse to raise a custom ArgumentError in one part of the code, only to catch it elsewhe

Re: MeCab UTF-8 Decoding Problem

2013-06-29 Thread Terry Reedy
On 6/29/2013 10:02 AM, Dave Angel wrote: On 06/29/2013 07:29 AM, fob...@gmail.com wrote: Hi, Using Python 2.7 on Linux, presumably? It'd be better to be explicit. I am trying to use a program called MeCab, which does syntax analysis on Japanese text. It is generally nice to give a link w

Re: MeCab UTF-8 Decoding Problem

2013-06-29 Thread Terry Reedy
On 6/29/2013 11:32 AM, Terry Reedy wrote: I am trying to use a program called MeCab, which does syntax analysis on Japanese text. It is generally nice to give a link when asking about 3rd party software. https://code.google.com/p/mecab/ In this case, nearly all the non-boilerplate text is

Re: Closures in leu of pointers?

2013-06-29 Thread Terry Reedy
On 6/29/2013 3:47 PM, Ian Kelly wrote: On Sat, Jun 29, 2013 at 1:33 PM, Steven D'Aprano wrote: On Sat, 29 Jun 2013 12:20:45 -0700, cts.private.yahoo wrote: Huh? What language are you programming in? Python doesn't have implied scoping in non-intuitive ways. def f(x): def g(y):

Re: Closures in leu of pointers?

2013-06-29 Thread Terry Reedy
On 6/29/2013 5:21 PM, Ian Kelly wrote: On Sat, Jun 29, 2013 at 2:53 PM, Terry Reedy wrote: # The alternative for either program or people is a 1-pass + backtracking process where all understandings are kept provisional until the end of the body and revised as required. 2 passes are simpler

Re: Closures in leu of pointers?

2013-06-29 Thread Terry Reedy
On 6/30/2013 1:46 AM, Ian Kelly wrote: On a related note, I think that generator functions should in some way be explicitly marked as such in the declaration, rather than needing to scan the entire function body for a yield statement to determine whether it's a generator or not. I agree that o

Re: Python list code of conduct

2013-07-02 Thread Terry Reedy
On 7/2/2013 7:46 PM, Roy Smith wrote: In article , Ned Deily wrote: If you find a bug in Python, don't send it to comp.lang.python; file a bug report in the issue tracker. I would revise this to "If you are have really found a bug in Python..." How does a newbie know? I'm not sure I agre

Re: Important features for editors

2013-07-05 Thread Terry Reedy
On 7/4/2013 2:52 PM, Ferrous Cranus wrote: Like you never downloaded serials/keygens/patch/cracks for warez and torrents websites. Morality aside, why would I? Today I bought 8 games on GOG.com for about $22 - drm and virus free and easy download and install. If I get 10 hours of fun from 2

Re: analyzing time

2013-07-05 Thread Terry Reedy
On 7/5/2013 3:18 PM, noydb wrote: I have a table with a column of type date, with dates and time This is a datetime in Python parlance. combined (like '1/6/2013 3:52:69PM'), that spans many months. How would I pull out records that are the first and last entries per day? Sort on that colu

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Terry Reedy
On 7/6/2013 8:37 AM, Russel Walker wrote: I know this is simple but I've been starring at it for half an hour and trying all sorts of things in the interpreter but I just can't see where it's wrong. def supersum(sequence, start=0): result = start for item in sequence: try:

Explain your acronyms (RSI?)

2013-07-06 Thread Terry Reedy
"rms has crippling RSI" (anonymous, as quoted by Skip). I suspect that 'rms' = Richard M Stallman (but why lower case? to insult him?). I 'know' that RSI = Roberts Space Industries, a game company whose Kickstarter project I supported. Whoops, wrong context. How about 'Richard Stallman Insanit

Re: Editor Ergonomics [was: Important features for editors]

2013-07-09 Thread Terry Reedy
On 7/9/2013 8:12 AM, Neil Cerutti wrote: On 2013-07-09, Jason Friedman wrote: I am right-handed and use a lefty-mouse about 50% of the time. It was difficult at first, now I'm almost as fast lefty as righty. As has been stated by others, changing the muscles being used reduces the impact on any

Re: Stack Overflow bans Mats Peterson (was Re: ....)

2013-07-10 Thread Terry Reedy
On 7/10/2013 3:55 AM, Mats Peterson wrote: A moderator who calls himself “animuson” on Stack Overflow doesn’t want to face the truth. He has deleted all my postings regarding Python regular expression matching being extremely slow compared to Perl. Additionally my account has been suspended for 7

Re: Recursive class | can you modify self directly?

2013-07-10 Thread Terry Reedy
On 7/10/2013 4:58 AM, Russel Walker wrote: There is the name x and the class instance (the object) which exists somewhere in memory that x points to. self is just another name that points to the same object (not self in general but the argument passed to the self parameter when a method is calle

Re: GeoIP2 for retrieving city and region ?

2013-07-12 Thread Terry Reedy
On 7/12/2013 1:19 PM, Ian Kelly wrote: Try this: 1) Go to http://incloak.com (or any other free web proxy site). 2) Paste in the URL http://www.geoiptool.com and press Enter 3) See where it thinks you are now. When I tried it, it placed me on the wrong side of the Atlantic Ocean. Me to. Than

Re: Understanding other people's code

2013-07-12 Thread Terry Reedy
On 7/12/2013 10:22 AM, L O'Shea wrote: Hi all, I've been asked to take over a project from someone else and to extend the functionality of this. The project is written in Python which I haven't had any real experience with (although I do really like it) so I've spent the last week or two settling

Re: Beazley 4E P.E.R, Page29: Unicode

2013-07-14 Thread Terry Reedy
On 7/13/2013 11:09 PM, vek.m1...@gmail.com wrote: http://stackoverflow.com/questions/17632246/beazley-4e-p-e-r-page29-unicode Is this David Beazley? (You referred to 'DB' later.) "directly writing a raw UTF-8 encoded string such as 'Jalape\xc3\xb1o' simply produces a nine-character string U+

Re: Timing of string membership (was Re: hex dump w/ or w/out utf-8 chars)

2013-07-14 Thread Terry Reedy
On 7/14/2013 10:56 AM, Chris Angelico wrote: On Sun, Jul 14, 2013 at 11:44 PM, wrote: timeit.repeat("a = 'hundred'; 'x' in a") [0.11785943134991479, 0.09850454944486256, 0.09761604599423179] timeit.repeat("a = 'hundreœ'; 'x' in a") [0.23955250303158593, 0.2195812612416752, 0.2213389699740

Re: List comp help

2013-07-14 Thread Terry Reedy
On 7/14/2013 1:10 PM, Joseph L. Casale wrote: I have a dict of lists. I need to create a list of 2 tuples, where each tuple is a key from the dict with one of the keys list items. my_dict = { 'key_a': ['val_a', 'val_b'], 'key_b': ['val_c'], 'key_c': [] } [(k, x) for k, v in my_di

Re: a little more explicative error message?

2013-07-16 Thread Terry Reedy
On 7/16/2013 1:44 AM, Vito De Tullio wrote: Hi I was writing a decorator and lost half an hour for a stupid bug in my code, but honestly the error the python interpreter returned to me doesn't helped... $ python3 Python 3.3.0 (default, Feb 24 2013, 09:34:27) [GCC 4.7.2] on linux Type "help", "c

Re: Is this a bug?

2013-07-16 Thread Terry Reedy
On 7/16/2013 2:04 PM, Ian Kelly wrote: The documentation appears to be wrong. It says: """ If a name binding operation occurs anywhere within a code block, all uses of the name within the block are treated as references to the current block. This can lead to errors when a name is used within a

Re: Help with pygame

2013-07-16 Thread Terry Reedy
On 7/16/2013 1:29 PM, Daniel Kersgaard wrote: I'm having a little trouble, tried Googling it, but to no avail. > Currently, I'm working on making a snake game, however > I'm stuck on a simple border. To give a variation of the other answers, it would be easier if you drew the four sides more s

Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Terry Reedy
On 7/18/2013 3:29 AM, Aseem Bansal wrote: About reading comp.lang.python can you suggest how to read it and reply? To read this list as a newsgroup use news.gmane.org. The difference between the mailing list interface and newsgroup interface is that the latter automatically segregates messag

Re: Converting a list of lists to a single list

2013-07-23 Thread Terry Reedy
On 7/23/2013 5:52 PM, st...@divillo.com wrote: I think that itertools may be able to do what I want but I have not been able to figure out how. A recursive generator suffices. I want to convert an arbitrary number of lists with an arbitrary number of elements in each list into a single list a

Re: Converting a list of lists to a single list

2013-07-24 Thread Terry Reedy
On 7/23/2013 7:02 PM, Terry Reedy wrote: On 7/23/2013 5:52 PM, st...@divillo.com wrote: I think that itertools may be able to do what I want but I have not been able to figure out how. What you want is a flattened product with unchanged components of the successive products omitted in the

Re: Strange behaviour with os.linesep

2013-07-24 Thread Terry Reedy
On 7/23/2013 7:41 PM, Dennis Lee Bieber wrote: On 23 Jul 2013 15:25:12 GMT, Steven D'Aprano declaimed the following: On Tue, 23 Jul 2013 13:42:13 +0200, Vincent Vande Vyvre wrote: On Windows a script where de endline are the system line sep, the files are open with a double line in Eric4, No

Re: Python 3: dict & dict.keys()

2013-07-24 Thread Terry Reedy
On 7/24/2013 12:34 PM, Chris Angelico wrote: Side point: Why is iterating over a dict equivalent to .keys() rather than .items()? It feels odd that, with both options viable, the implicit version iterates over half the dict instead of all of it. Obviously it can't be changed now, even if .items(

Re: RE Module Performance

2013-07-24 Thread Terry Reedy
On 7/24/2013 11:00 AM, Michael Torrie wrote: On 07/24/2013 08:34 AM, Chris Angelico wrote: Frankly, Python's strings are a *terrible* internal representation for an editor widget - not because of PEP 393, but simply because they are immutable, and every keypress would result in a rebuilding of t

Re: RE Module Performance

2013-07-24 Thread Terry Reedy
On 7/24/2013 2:15 PM, Chris Angelico wrote: On Thu, Jul 25, 2013 at 3:52 AM, Terry Reedy wrote: For my purpose, the mock Text works the same in 2.7 and 3.3+. Thanks for that report! And yes, it's going to behave exactly the same way, because its underlying structure is an ordered li

Re: Python 3: dict & dict.keys()

2013-07-24 Thread Terry Reedy
On 7/24/2013 4:34 PM, Prasad, Ramit wrote: I am still not clear on the advantage of views vs. iterators. A1: Views are iterables that can be iterated more than once. Therefore, they can be passed to a function that re-iterates its inputs, or to multiple functions. They support 'x in view' as

Re: Beginner. 2d rotation gives unexpected results.

2013-07-24 Thread Terry Reedy
On 7/24/2013 5:17 PM, Joshua Landau wrote: import math as m GAH! Why on earth would you do such a thing? for the same reason people do 'import tkinter as tk': to minimize typing and maximize clarity. In this case, from math import sin, cos, radians also works well -- Terry Jan Reed

Re: Python 3: dict & dict.keys()

2013-07-25 Thread Terry Reedy
On 7/25/2013 12:21 PM, Ethan Furman wrote: On 07/25/2013 09:11 AM, Prasad, Ramit wrote: Hmm, that is a change that makes some sense to me. Does the view get updated when dictionary changes or is a new view needed? I assume the latter. Nope, the former. That is a big advantage that the views

Re: Creating a Simple User Interface for a Function

2013-07-25 Thread Terry Reedy
On 7/25/2013 4:58 PM, CTSB01 wrote: 1) I decided to use Python 2.7, and I will be sure to specify this in all future threads. Given that you are not using any libraries, let alone one that does not run on Python 3, I strongly recommend using the latest version (3.3). 2) It is a list of posit

Re: Creating a Simple User Interface for a Function

2013-07-25 Thread Terry Reedy
Some additional comments. On 7/25/2013 7:00 PM, Terry Reedy wrote: On 7/25/2013 4:58 PM, CTSB01 wrote: 1) I decided to use Python 2.7, and I will be sure to specify this in all future threads. Given that you are not using any libraries, let alone one that does not run on Python 3, I

Re: Help

2013-07-25 Thread Terry Reedy
On 7/26/2013 1:06 AM, ty...@familyrobbins.com wrote: I'm a bit new to python and I'm trying to create a simple program which adds words and definitions to a list, and then calls them forward when asked to. Why are you not putting them in a Python dict, which is made for this? Unless you have a

Re: Division and multiplication have a different behavior in the overflow case

2013-07-27 Thread Terry Reedy
On 7/27/2013 1:48 PM, Marco wrote: In Python 3, when we hava a division and both the result and at least one operand are too large to convert to float, we get an exception: >>> 2**1028 / 2**-2 int/float gets converted to float/float and the int to float conversion is not possible. The re

Re: FSR and unicode compliance - was Re: RE Module Performance

2013-07-28 Thread Terry Reedy
On 7/28/2013 11:52 AM, Michael Torrie wrote: 3. UTF-8 and UTF-16 encodings, being variable width encodings, mean that slicing a string would be very very slow, Not necessarily so. See below. and that's unacceptable for the use cases of python strings. I'm assuming you understand big O notat

Re: RE Module Performance

2013-07-28 Thread Terry Reedy
On 7/28/2013 2:29 PM, Chris Angelico wrote: On Sun, Jul 28, 2013 at 7:19 PM, Joshua Landau wrote: Somewhat off topic, but befitting of the triviality of this thread, do I understand correctly that you are saying garbage collection never causes any noticeable slowdown in real-world circumstanc

Re: dynamic type returning NameError:

2013-07-28 Thread Terry Reedy
On 7/28/2013 9:38 PM, Tim O'Callaghan wrote: Hi, I hope that this hasn't been asked for the millionth time, so my apologies if it has. I have a base class (BaseClass - we'll call it for this example) with an http call that i would like to inherit into a dynamic class at runtime. We'll call t

Re: AssertionError: Headers already set! Status: 500 Internal Server Error Content-Type: text/plain Content-Length: 59

2013-07-29 Thread Terry Reedy
On 7/29/2013 8:55 AM, Jaiky wrote: learning web concpt in python wrote code in /usr/lib/cgi-bin/hello_world.py ### #!/usr/bin/env python import webapp2 This is an external package. form =""" http://www/google.com/

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Terry Reedy
On 7/29/2013 11:50 AM, Ian Kelly wrote: On Mon, Jul 29, 2013 at 9:43 AM, Steven D'Aprano wrote: Comparing floats to Fractions gives unexpected results: # Python 3.3 py> from fractions import Fraction py> 1/3 == Fraction(1, 3) False but: py> 1/3 == float(Fraction(1, 3)) True I expected that

Re: What do you do when a library is outdated?

2013-07-29 Thread Terry Reedy
On 7/29/2013 12:14 PM, Matt wrote: I'm fairly new to python but have experience in other languages. What do you generally do when a library is outdated? I asked a question on a few forums and everyone has been pointing me to Mechanize, but it will not work with 3.3 What do you do? Update it yo

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Terry Reedy
On 7/29/2013 1:29 PM, Steven D'Aprano wrote: On Mon, 29 Jul 2013 13:08:20 -0400, Terry Reedy wrote: In other words, there can be multiple unequal Franctions that have the same float value: for instance, Fraction(1,3) and Fraction(6004799503160661, 18014398509481984) > So f

Re: PEP8 79 char max

2013-07-29 Thread Terry Reedy
On 7/29/2013 3:43 PM, Devyn Collier Johnson wrote: In Python programming, the PEP8 recommends limiting lines to a maximum of 79 characters because "There are still many devices around that are limited to 80 character lines" "plus, limiting windows to 80 characters makes it possible to have sev

Re: PEP8 79 char max

2013-07-29 Thread Terry Reedy
On 7/29/2013 5:01 PM, Terry Reedy wrote: On 7/29/2013 3:43 PM, Devyn Collier Johnson wrote: In Python programming, the PEP8 recommends limiting lines to a maximum of 79 characters because "There are still many devices around that are limited to 80 character lines" "plus, limi

Re: Bitwise Operations

2013-07-29 Thread Terry Reedy
On 7/29/2013 7:44 PM, Chris Angelico wrote: But there's an easier way: x = 0b101 & 0b010 x 0 I think that might do what you want. Also check out the bin() function, which will turn an integer into a string of digits. >>> bin(0b101 | 0b010) '0b111' Now you are set to go. Have fun. -- Terry

Re: RE Module Performance

2013-07-30 Thread Terry Reedy
On 7/30/2013 1:40 PM, Joshua Landau wrote: Additionally, who says a language couldn't use, say, B-Trees for all of its list-like types, including strings? Tk apparently uses a B-tree in its text widget. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Python descriptor protocol (for more or less structured data)

2013-07-31 Thread Terry Reedy
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

Re: Problem with psycopg2, bytea, and memoryview

2013-07-31 Thread Terry Reedy
On 7/31/2013 9:07 AM, Antoine Pitrou wrote: Frank Millman 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 recon

Re: Checking compatibility of a script across Python versions automatically

2012-06-18 Thread Terry Reedy
On 6/18/2012 3:24 PM, Andrew Berg wrote: Are there any tools out there that will parse a script and tell me if it is compatible with an arbitrary version of Python and highlight any Not that I know of. incompatibilities? I need to check a few of my scripts that target 3.2 to see if I can make

Re: Custom build of Python

2012-06-20 Thread Terry Reedy
On 6/20/2012 2:24 PM, KACVINSKY Tom wrote: I had reason to build Python 2.6.8 with Microsoft Visual Studio 2010. I was able to get the pcbuild solution to build, and I have the necessary exes/dlls/pyds in the amd64 build directory. What is not clear to is how to complete the build and make an i

Re: DirectX Screenshot with python possible?

2012-06-20 Thread Terry Reedy
On 6/20/2012 2:24 PM, Sverre wrote: I'm in need for a function that is able to make a screenshot from a directx full screen. PIL is only able to take a snapshot from the desktop, but not from any directx screen. Has someone a tip for an existing module? Perhaps pygame has (or wraps) such a f

Re: None shown in output

2012-06-21 Thread Terry Reedy
On 6/21/2012 11:42 PM, Xander Solis wrote: Hello Python list, Noob here with a newbie question. I'm reading and working on the exercise of the book, Learn Python the Hard way 2.0. When I use this code, I get "None" on the output. My question is why does this happen? None is the default return

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-22 Thread Terry Reedy
On 6/22/2012 11:53 AM, Albert van der Horst wrote: In article , Kevin Walzer wrote: On 6/11/12 8:01 AM, Wolfgang Keller wrote: Tkinter is imho honestly the very best "argument" if you want to make potential new users turn their backs away from Python for good. Just show them one GUI implement

Re: SSL handshake hanging, despite bugfix in stdlib

2012-06-23 Thread Terry Reedy
On 6/23/2012 1:29 PM, Michael Gundlach wrote: Hello, http://bugs.python.org/issue5103 fixed a bug in Python2.6 where SSL's I believe the fix first appeared in 2.6.6. handshake would hang indefinitely if the remote end hangs. However, I'm getting hanging behavior in an IMAP script. When I C

Re: SSL handshake hanging, despite bugfix in stdlib

2012-06-25 Thread Terry Reedy
On 6/25/2012 8:34 AM, Michael Gundlach wrote: Hello again Terry (and mailing list), On Sun, Jun 24, 2012 at 9:34 AM, Michael Gundlach mailto:gundl...@gmail.com>> wrote: I've now changed to 2.7.3, and if I don't write back in the next few days, it means that that fixed the problem -- tha

Re: How can i call array_length to get the length of array object?

2012-06-25 Thread Terry Reedy
On 6/25/2012 8:54 AM, Mark Lawrence wrote: On 25/06/2012 02:17, Ben Finney wrote: Mark Lawrence writes: On 24/06/2012 09:15, gmspro wrote: Why __len__() where the original name if array_length? Why is method names like __NAME__ ? These are questions answered by getting a thorough groundin

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-25 Thread Terry Reedy
On 6/25/2012 11:35 PM, Steven D'Aprano wrote: (Rick, don't make me regret communicating with you again.) On Mon, 25 Jun 2012 19:28:01 -0700, rantingrickjohnson wrote: However, there is something to be said for "old habits die hard". I myself lament every time i must type->(, then blah, then->)

Re: json.loads() should return a more specific error

2012-06-27 Thread Terry Reedy
On 6/27/2012 8:45 AM, Roy Smith wrote: Before I go open an enhancement request, what do people think of the idea that json.load() should return something more specific than ValueError? I do not know of any written policy about when to create custom error classes in the stdlib. I know there are

Re: 2to6 ?

2012-06-27 Thread Terry Reedy
On 6/27/2012 10:36 AM, Thomas Heller wrote: Is there a tool, similar to 2to3, which converts python2 code to code using six.py, so that it runs unchanged with python2 *and* python 3? Others have expressed a similar wish, but I do not know that anyone has actually revised 2to3 to make a 2to6, o

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-27 Thread Terry Reedy
On 6/27/2012 3:08 PM, Serhiy Storchaka wrote: On 27.06.12 14:22, Stefan Behnel wrote: For comparison, the revival of the "u" string prefix in Py3.3 is a simple change in the parser grammar that's easy to maintain And even this simple change has caused unexpected issues (see issues #15054 and

Re: TKinter Frame Size automatic

2012-06-28 Thread Terry Reedy
On 6/28/2012 9:07 AM, hkara...@gmail.com wrote: I have a question about the frame size. I want to create Tabbed window. There will be one Window and tabs in this window. The page will be displayed whenever the user press the corresponding tab. This is simple NoteBook behaviour from Tkinter. I do

Re: moving methods from class to instance of other class

2012-06-28 Thread Terry Reedy
On 6/28/2012 2:59 AM, lars van gemerden wrote: class A(object): def __init__(self): self.name = 'a' def do(self): print 'A.do: self.name =', self.name class B(object): def __init__(self): self.name = 'b' The question is: How do i move the 'do' method f

Re: code review

2012-06-29 Thread Terry Reedy
On 6/29/2012 4:49 PM, Littlefield, Tyler wrote: I am no expert but from what have picked up so far from x import is frowned upon in most cases from x import * # frowned on by many as reader will not necessarily know what that imports, conflicts are possible, and if you import * twice, reader m

Re: code review

2012-06-29 Thread Terry Reedy
On 6/29/2012 4:43 PM, Alister wrote: from x import * is frowned upon, however, from x import y is fine IMHO. well I said I was no expert & picking things up. re investigation I see your reasoning and yes it was the from X import * I was thinking of. Although a simple import X retaining the n

Re: code review

2012-06-30 Thread Terry Reedy
On 6/30/2012 5:35 PM, Thomas Jollans wrote: On 06/30/2012 11:07 PM, Alain Ketterlin wrote: Thomas Jollans writes: def is_valid_password(password): return mud.minpass <= len(password) <= mud.maxpass Which of the two comparisons is done first anyway? "In the face of ambiguity, refuse th

Re: how to use tkinter in python3.2?

2012-06-30 Thread Terry Reedy
On 7/1/2012 12:25 AM, contro opinion wrote: I am on Windows, but... tiger@ocean:~$ python3.2 Python 3.2.3 (default, Jul 1 2012, 11:07:14) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter Traceback (most recent call last): File

Re: code review

2012-07-01 Thread Terry Reedy
On 7/1/2012 2:54 AM, Steven D'Aprano wrote: So no, Python has always included chained comparisons, and yes, it is shameful that a language would force you to unlearn standard notation in favour of a foolish consistency with other operators. Comparisons aren't special because they return bools. T

Re: code review

2012-07-02 Thread Terry Reedy
On 7/2/2012 1:20 AM, Dennis Lee Bieber wrote: Obviously, someone coming over from VB or R or any other single language x who hasn't read the Python reference is going to be surprised as something or other. So what. The manuals, including the tutorial, are there for a reason. The main poin

Re: how to solve this tclerror?

2012-07-02 Thread Terry Reedy
On 7/2/2012 10:14 AM, contro opinion wrote: i solve it myself 1.download tile-0.8.4.0.tar.gz Or install the latest tcl/tk 8.5(.11), which includes tile/tkk and bug fixes, instead of the rather old 8.4.?. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: 2to6 ?

2012-07-02 Thread Terry Reedy
On 7/2/2012 11:02 AM, Thomas Heller wrote: Am 27.06.2012 20:06, schrieb Terry Reedy: On 6/27/2012 10:36 AM, Thomas Heller wrote: Is there a tool, similar to 2to3, which converts python2 code to code using six.py, so that it runs unchanged with python2 *and* python 3? Others have expressed a

Re: helping with unicode

2012-07-02 Thread Terry Reedy
On 7/2/2012 8:49 PM, self.python wrote: it's a simple source view program. the codec of the target website is utf-8 so I read it and print the decoded which re-encodes before printing -- #-*-coding:utf8-*- import urllib2 rf=urllib2

Re: helping with unicode

2012-07-02 Thread Terry Reedy
On 7/2/2012 8:49 PM, self.python wrote: it's a simple source view program. the codec of the target website is utf-8 so I read it and print the decoded which re-encodes before printing -- #-*-coding:utf8-*- import urllib2 rf=urllib2

  1   2   3   4   5   6   7   8   9   10   >