Re: How to call and execute C code in Python?

2012-05-13 Thread Terry Reedy
2012, 5:35 *Subject:* Python-list Digest, Vol 104, Issue 57 - Forwarded Message - [snip the remaining hundread of lines of the digist] David, please post just your message as a new thread and do not include the whole digist. -- Terry Jan Reedy -- http://mail.python.org/mailman/listi

Re: Where is the most recent Tkinter information

2012-05-16 Thread Terry Reedy
.5.11, released a couple of months ago. tkinter does not change much because tk does not change much. But bugs are fixed as reported. A fix for an obscure bug affecting certain *nix systems was committed just today. The docs do need improving. -- Terry Jan Reedy -- http://mail.python.org/ma

Re: Newbie questions on import & cmd line run

2012-05-16 Thread Terry Reedy
ules) called by a .py program. How would I get that? I only ask as it comes in handy if one distributes a program. I mean, you only give people what they actually need. Look at the trace module. Of course, you distribute files, not functions. There are various packaging programs that do a module import trace rather than function call trace. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-17 Thread Terry Reedy
hat to isdigit, which makes a point of noting this particular edge case. I think both should read (choosing either decimals or digits) Return True if S has at least one character and all are decimals/digits, False otherwise. Feel free to submit an issue. -- Terry Jan Reedy -- http://ma

Re: tiny script has memory leak

2012-05-17 Thread Terry Reedy
rint>> f (which I think is deprecated). In the sense that in Py3, print is a function with a file parameter: print(random.randint(0, sys.maxint), file=f) The idiosyncratic ugliness of >>file was one reason for the change. Adding the option to specify separator and terminator was another. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: str.isnumeric and Cuneiforms

2012-05-17 Thread Terry Reedy
IC SIGN ONE ESHE3;Nl;0;L1;N; 12459;CUNEIFORM NUMERIC SIGN TWO ESHE3;Nl;0;L2;N; 1245A;CUNEIFORM NUMERIC SIGN ONE THIRD DISH;Nl;0;L1/3;N; 1245B;CUNEIFORM NUMERIC SIGN TWO THIRDS DISH;Nl;0;L2/3;N; When there is a value, it comes just before the last 'N'. The

Re: Doctest documentation?

2012-05-20 Thread Terry Reedy
gs.python.org/issue14865 I determined that the removing bug first happened with 3.2.0 and then 2.7.3 (but not 2.7.2, released 4 months after 3.2.0). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: what do these mean

2012-05-20 Thread Terry Reedy
if not 0. If course, this just goes to show what code should be unit-tested. It is so easy to mis-type and not notice even when the code in ones head is correct and even pretty trivial. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: 2.x, 3.x iOS static build: Fatal Python error: exceptions bootstrapping error.

2012-05-20 Thread Terry Reedy
d. Also tried source from here: http://stackoverflow.com/a/4177748/1337666. But no luck, same problem. Porting Python core will be very helpful for my iOS application. Any hint will be appreciated. Best Regards -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Help doing it the "python way"

2012-05-24 Thread Terry Reedy
ighbours(coords)) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: pygame: transparency question

2012-05-29 Thread Terry Reedy
fill the surface with a color and then set that color as the colorkey. Is this the only way or does pygame have a function to make the whole surface transparent? I recommend that you ask this on the pygame list, also accessible via news.gmane.org. -- Terry Jan Reedy -- http://mail.python.org

Re: python3 raw strings and \u escapes

2012-05-30 Thread Terry Reedy
.3, 'u' is being restored. I have inquired on pydev list whether the difference above should also be restored, and mentioned this thread. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: installing modules in Enthought Python

2012-05-30 Thread Terry Reedy
work. However, maybe they do something non-standard in the site module, including disabling site-packages. Try >>> import sys; sys.path to see if sys.path includes site-packages and what it does include. If you put a directory in site-packages, make sure it has an __init__.py fi

Re: Tkinter deadlock on graceful exit

2012-05-30 Thread Terry Reedy
tried making the gui thread the master thread? (I somehow expect that the gui thread should be the last to shut down.) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: reading txt file

2012-05-31 Thread Terry Reedy
ters printed in a fixed 10 chars per inch font such as Courier.) There is also text at the bottom after a separator line -- ... so you will have to catch that and stop there. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: CPython 2.7: Weakset data changing size during internal iteration

2012-06-01 Thread Terry Reedy
ock around the if-statement so no other thread can change self.data during the iteration. 2. Weakset members remove themselves from the set before returning None. (Just a thought, in case you are not using threads). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: CPython 2.7: Weakset data changing size during internal iteration

2012-06-01 Thread Terry Reedy
ell that class has been exercised and tested. Please do submit a patch if you can if one is needed. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Where is the latest step by step guide to use Jython to compilePython into Java?

2012-06-04 Thread Terry Reedy
On 6/4/2012 11:35 AM, David Shi wrote: Please post plain text rather than html. It just works better and is the convention for this newsgroup and mailing list. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I get the constructor signature for built-in types?

2012-06-05 Thread Terry Reedy
by the way, thanks for the example, as it might crash Idle even after my current patch. I will have to check. See http://bugs.python.org/issue12510 if interested.) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: ttk.Spinbox missing?

2012-06-06 Thread Terry Reedy
her ttk widgets, you should be able to contribute a patch. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: English version for Mémento Python 3 (draft, readers needed)

2012-06-06 Thread Terry Reedy
quot;American English"? Typically I've just seen "see other side", or (very occasionally) "see reverse" and "see obverse". While this nice document is intended to be printed on two sides of one card or sheet, it may also get printed on two sheets. 'see page 1' and 'see page 2' will work either way -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Python libraries portable?

2012-06-08 Thread Terry Reedy
they should be available across all platforms, otherwise you would need to check see http://docs.python/library for details of the standard library -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange Problem with pythonw.exe

2012-06-09 Thread Terry Reedy
t across installs. The most likely change to me would be in the registry. So if it were my machine, I would fire up regedit, back up the registry, search it for 'pythonw', look at the results, and perhaps delete all pythonw entries. Then reinstall the core component. You might also tr

Re: mode for file created by open

2012-06-09 Thread Terry Reedy
discussion here, someone could open a tracker issue with a specific proposal. Keep in mind that 'mode' is already a parameter name for the mode of opening, as opposed to the permission mode for subsequent users. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: mode for file created by open

2012-06-09 Thread Terry Reedy
On 6/9/2012 6:25 PM, Neal Becker wrote: Terry Reedy wrote: The original open builtin was a thin wrapper around old C's stdio.open. Open no longer has that constraint. After more discussion here, someone could open a tracker issue with a specific proposal. Keep in mind that 'mode

Re: Strange Problem with pythonw.exe

2012-06-10 Thread Terry Reedy
.3, to catch .idlerc problems and report to the user rather than quit. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Pytz error: unpack requires a string argument of length 44

2012-06-13 Thread Terry Reedy
that is a bug.) Since fp.read cannot read too many bytes, it must have read too little. ("Read up to n bytes from the object and return them.") You could look in C:\code\SoF\serversonfire\pytz\__init__.py and see what file fp is supposed to be and then take a look at the file. Is it empty? Is anything read before the statement that failer? -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Terry Reedy
then or for his next site or for the initial Facebook a few months later, that would suggest an answer. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Terry Reedy
lasses come with a corresponding iterator. Yes, you could also run it in a loop or simulate lazy-eval manually (with yield) There is nothing simulated about yield. Python mostly does what you tell it to do. You just have to learn how to tell it to do what you want. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Use of internal ctypes objects

2012-06-15 Thread Terry Reedy
depends on what you mean by 'safe'. "Internal" generally means 'use at your own risk' and 'subject to change (in future releases) without notification'. On the other hand, they should not silently reformat your disk ;-). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Terry Reedy
On 6/15/2012 3:04 PM, Paul Rubin wrote: Terry Reedy writes: Python iterators can do lazy evaluation. All the builtin classes come with a corresponding iterator. ... I wouldn't say iterators do lazy evaluation in the Scheme or Haskell sense. Lazy evaluation imho means evaluation is def

Re: Academic citation of Python

2012-06-16 Thread Terry Reedy
. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Academic citation of Python

2012-06-16 Thread Terry Reedy
On 6/16/2012 5:01 PM, Christian Heimes wrote: Am 16.06.2012 22:44, schrieb Terry Reedy: Rossum, Guido van, et al, *The Python Language Reference*, Python Software Foundation; http://docs.python.org/py3k/reference/index.html Actually it's "van Rossum, Guido", not "Rossum,

Re: How does python bytecode works?

2012-06-17 Thread Terry Reedy
ile Python code to whatever it compiles to. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: lazy evaluation of a variable

2012-06-17 Thread Terry Reedy
mport lazy def f(): var = lazy.var See Peter's post for using properties instead. That probably scales better for multiple lazy attibutes. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Py3.3 unicode literal and input()

2012-06-18 Thread Terry Reedy
like to see ported to Python 3 have not been. The purpose of reintroducing 'u' is to encourage more porting of Python 2 code. Period. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: module name vs '.'

2012-06-18 Thread Terry Reedy
7;src.directory', ) Conclusion: putting periods in the name of module files (including directories) except for .py- extensions, is generally a bad idea. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem porting class to python3.2

2011-06-02 Thread Terry Reedy
ease reply directly. Done, in addition to public posting. Please reply to the public posting so others can learn also. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Something is rotten in Denmark...

2011-06-02 Thread Terry Reedy
ions matche the semantics of lambda in other languages. They are definitely highly limited in the scope of what they can do. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is this so much faster?

2011-06-02 Thread Terry Reedy
one has an expression, wrapping it as a function to use map is surely slower. Have you tried return math.sqrt(sum([h*i*i for i,h in enumerate(histogram)]) / self.Area()) or same without [] brackets? i*i should be faster than i**2 in any version. Is it skipping the creation of a list? A bi

Re: Lambda question

2011-06-05 Thread Terry Reedy
x,n): for i in range(0,len(x),n): yield x[i:i+n] f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc Packing tail recursion into one line is bad for both understanding and refactoring. Use better names and a docstring gives def group(seq, n): 'Yield from seq successive d

Re: Lambda question

2011-06-06 Thread Terry Reedy
[]), # no input, no output #(('abc',0), ValueError), # group size positive (('abc',1), ['a','b','c']), (('abcd',2), ['ab','cd']), (('abcde',2), ['ab', 'cd', 

Re: Lambda question

2011-06-06 Thread Terry Reedy
On 6/6/2011 1:29 PM, rusi wrote: On Jun 5, 11:33 pm, Terry Reedy wrote: Let me add something not said much here about designing functions: start with both a clear and succinct definition *and* test cases. (I only started writing tests first a year ago or so.) I am still one year in the

Re: Lambda question

2011-06-06 Thread Terry Reedy
On 6/6/2011 12:52 PM, Terry Reedy wrote: def group(seq, n): 'Yield from seq successive disjoint slices of length n & the remainder' if n<=0: raise ValueError('group size must be positive') for i in range(0,len(seq), n): yield seq[i:i+n] for inn,out in ( (('

Re: How good is security via hashing

2011-06-07 Thread Terry Reedy
get at the same functions with ctypes. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: International translation of docs - is it a scam?

2011-06-07 Thread Terry Reedy
ng asked about another and ask if legit. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic Zero Padding.

2011-06-07 Thread Terry Reedy
; "Testing {0:0{1}d}".format(42, 9) 'Testing 00042' One cannot use a nested field in the 'name' part of the field (before the ':' (I tried), but are pretty free to nest in the actual specification part after the ':'. >>>

Re: the stupid encoding problem to stdout

2011-06-09 Thread Terry Reedy
ant python don't care about encoding terminal and send characters as they are or for a file . You can't write characters to a stream, only bytes. Characters, representations are for people, byte representations are for computers. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.6 OR 3.2

2011-06-09 Thread Terry Reedy
couple of years ago, users were people who were already programming with 2.x. That is changing now. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: how to inherit docstrings?

2011-06-09 Thread Terry Reedy
ily on a little help from the language to explicitly request to inherit the docstring. An empty docstring "" could be interpreted as 'ditto' ;-) It would be useless otherwise. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: __doc__ immutable for classes

2011-06-10 Thread Terry Reedy
ng of the underlying function, accessed through a custom method.__getattr__. It is not writable through the bound method. I presume this is because method.__setattr__ blocks the write. Directly binding a new string to the underlying function does work. -- Terry Jan Reedy -- http://mail.python.

Re: PyQt

2011-06-10 Thread Terry Reedy
Show both actual import statement and resulting traceback and error. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Unsupported operand type(s) for +: 'float' and 'tuple'

2011-06-10 Thread Terry Reedy
s not) with Find Next and the second hit is the offending line ("T0 = initCost*0,1"). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursion error in metaclass

2011-06-10 Thread Terry Reedy
K = super().__new__(cls, name, bases, dict) if mro: assert K.__mro__ == (K,) + mro return K you are in an endless loop. Since uou do not pass dict to get_mro. it passes {} to type and MC1 and the test for docstring fails and the loop is broken and the empty class

Re: Recursion error in metaclass

2011-06-11 Thread Terry Reedy
On 6/11/2011 7:38 AM, Steven D'Aprano wrote: On Sat, 11 Jun 2011 01:33:25 -0400, Terry Reedy wrote: On 6/10/2011 11:34 PM, Steven D'Aprano wrote: I have a metaclass in Python 3.1: class MC1(type): @staticmethod def get_mro(bases): print('

Re: Square bracket and dot notations?

2011-06-11 Thread Terry Reedy
me class problem. All the methods are therefore given leading underscore names to avoid this. [But there still could be a clash if someone used field names with leading underscores!] Python reserves and uses __xxx__ for system names just to avoid clashes. -- Terry Jan Reedy -- http://mail.py

Re: How to avoid "()" when writing a decorator accepting optional arguments?

2011-06-11 Thread Terry Reedy
ner(*args, **kwargs): msg = "%s is deprecated" % fun.__name__ warnings.warn(msg, category=DeprecationWarning, stacklevel=2) return fun(*args, **kwargs) rturn inner The parameterized version will be simpler also (with None possibility deleted). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: __dict__ is neato torpedo!

2011-06-11 Thread Terry Reedy
s automatically: class simpleObject(): pass a = simpleObject() b = simpleObject() a.val1 = 1 a.val2 = 2 b.__dict__.update(a.__dict__) a.val1 = 'a' a.val1 'a' a.val2 2 b.val1 1 b.val2 2 -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Subsetting a dataset

2011-06-12 Thread Terry Reedy
database programs. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: working with raw image files

2011-06-13 Thread Terry Reedy
the scipy list (or PIL list, if there is one) than here. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: split long string in two code lines

2011-06-13 Thread Terry Reedy
in parentheses, brackets, and braces, so no fragile trailing backslash needed. ('Fragile', because invisible space or tab after '\' is an error.) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Terry Reedy
10 5 6 411 8 9 712 For zip(*arr) to work properly, each line of arr should have the same length, which means that either each value of d has the same length or that you find the max length and pad lines with blanks up to the max length. The code above assumes the first. If the items in each value of d are not strings, more fiddling is needed. The printed field size is also arbitrary. It needs adjusting for the actual max length. You might want to adjust it for each key-value pair in the dict, which is to say, each column of the resulting table. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: working with raw image files

2011-06-14 Thread Terry Reedy
urers, including Nikon, Canon and Sony, encrypt portions of the file in an attempt to prevent third-party tools from accessing them.[2]" A real mess. '.raw' is used (among others) by Panasonic and Leica. Not clear if .raw is the same for both. -- Terry Jan Reedy -- http://mai

Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Terry Reedy
, are essentially the inverse of * and ** in function definitions, where they say to collect arguments. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: How to form a dict out of a string by doing regex ?

2011-06-15 Thread Terry Reedy
t per line would make the problem pretty simple, with no regex required. How do I traverse through it and form 3 dicts of Point , Polygon and Linestring containing the co-ordinates ? Dicts map keys to values. I do not see any key values above. It looks like you really want three sets. -- Terry

Re: data type and logarithm

2011-06-16 Thread Terry Reedy
= np.append(rho,columns[0]) entropy = np.append(entropy,columns[1]) rho = mp.append(rho, float(r)) # same with entropy) does numpy really not let you write Python stype rho.append(float(r)) ? There are also numpy,scipy lists for numpy,scipy questions. -- Terry Jan Reedy -- http:/

Re: Fast Python in Programming Contests

2011-06-16 Thread Terry Reedy
ive. Any such site that wanted to make even a pretense of fairness would provide Cython for converting augmented Python programs to C and thence compiled just like C programs. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing python27.dll on Win 7 64-bit

2011-06-16 Thread Terry Reedy
b for each .dll and .pyd. Most likely you need to put the Python libs directory into your system PATH (not PYTHONPATH) variable. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Trapping MySQLdb warnings

2011-06-16 Thread Terry Reedy
rnings: warnings.catch_warnings is a context manager, not an exception. This is a TypeError in 3.x, which requires that exceptions be instances of BaseException. Try except warnings.Warning, warn: Substitute specific MySQLdb warning class, whatever it is, for Warning. -- Terry Jan Reedy -

Re: Trapping MySQLdb warnings

2011-06-16 Thread Terry Reedy
On 6/16/2011 3:01 PM, Tim Johnson wrote: * Terry Reedy [110616 10:50]: The machinery in the warnings module is only for instances of subsclasses of Warning. Are the warnings from MySQLdb properly such objects? If so, what class are they? The warnings are sent directly to stdout. No way

Re: bug in large file writes, 2.x and 3.x

2011-06-17 Thread Terry Reedy
s? (Personally, I'm betting on Windows). Python should not know the difference betweeen 'c:xxx' and 's:xxx'. The error comes from Windoes. But 100 million bytes does not seem really large for today's systems. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: PyGUI 2.5

2011-06-17 Thread Terry Reedy
On 6/16/2011 11:18 PM, Greg Ewing wrote: PyGUI 2.5 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Lots of new stuff in this version. Highlights include: Greg left out the most important to me: "Now works with Python 3 on MacOSX and Windows!" -- Terry

Re: How do you copy files from one location to another?

2011-06-17 Thread Terry Reedy
ectory manually? If you want more control of which files to copy, between 1 and all, look as os.walk and the glob module. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you copy files from one location to another?

2011-06-18 Thread Terry Reedy
done. Perhaps 'synctree' would be a candidate for addition to shutil. If copytree did not prohibit an existing directory as destination, it could be used for synching with an 'ignore' function. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Strategy to Verify Python Program is POST'ing to a web server.

2011-06-18 Thread Terry Reedy
tes by the same control id supercede previous vote. There should be a 'thank you for voting' response for each vote. I suspect IP addr. is recorded with vote too. I have not heard of specific problems with electronic proxy voting. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Lisp : car and cdr

2011-06-19 Thread Terry Reedy
e general data structure than a true sequence of atoms. But TREP (for tree-processing) is not as catchy as LISP (for list processing). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: threading : make stop the caller

2011-06-19 Thread Terry Reedy
_list: task_list.pop().start() or if the list is static for task in task_list: task.start() -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: How to iterate on a changing dictionary

2011-06-19 Thread Terry Reedy
t;>> {0: 0, 65: 65, 39: 39, 13: 13, 78: 78, 52: 52, 26: 26, 91: 91} -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: How to iterate on a changing dictionary

2011-06-19 Thread Terry Reedy
to do, but you may find it easier to use the 'filter' function (which takes an iterable, so possibly use dict.iteritems() for that).It'll keep some and not others, and then you can make use of just the ones you get back. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: threading : make stop the caller

2011-06-19 Thread Terry Reedy
ores names based on glob-style patterns." -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: How to iterate on a changing dictionary

2011-06-20 Thread Terry Reedy
;, ...) that you cannot accidentally modify and can repeatedly copy. For each game, copy to a list game = list(balls). Then random.shuffle(game), and game.pop() balls as needed. Other situations will need other solutions. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: running multiple scripts -- which way is more elegant?

2011-06-20 Thread Terry Reedy
cript (ImportError: Import by filename is not supported.) Look at builtin function __import__(filename). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the best way to write this base class?

2011-06-20 Thread Terry Reedy
nest attributes (for instance, a list of sub-items), you'll probably want to go with XML and ElementTree. I guess you can also use JSON (which uses a syntax similar to Python's dictionaries) but I've never really tried to make one of those by hand before so I'm not sure how wel

Re: Boolean result of divmod

2011-06-20 Thread Terry Reedy
On 6/20/2011 8:28 PM, Gnarlodious wrote: What is the easiest way to get the first number as boolean? divmod(99.6, 30.1) Or do I have to say: flote, rem=divmod(99.6, 30.1) bool(flote) divmod(x,y) == x//y, x%y so bool(x//y) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo

Re: Generator Frustration

2011-06-20 Thread Terry Reedy
nt (or lambda expression). It returns an instance of class 'generator, as you note here > and will test as such with 'if type(result)==types.GeneratorType:'. It is the result, and not the function, that is the generator (a type of iterator). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: new string-formatting preferred? (was "What is this syntax ?")

2011-06-20 Thread Terry Reedy
. print(multiwarn('iterator')) Here is a more complex example: class chunk(): def __init__(self, a, b): self.a,self.b = a,b c=chunk(1, (3,'hi')) print('{0.__class__.__name__} object has attributes int a <{0.a}> and tuple b with members <{0.b[0]}>

Re: Do we still need to inherit from "object" to create new-style classes?

2011-06-21 Thread Terry Reedy
ay need updating ;-). The core 3.x docs have been updated by removing all reference to old-style classes and the modifier 'new-style'. The concept 'new-style' only exists in opposition to 'old-style'. 3.x just has classes, and all are subclasses of object. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Don't understand SequenceMatcher from difflib

2011-06-21 Thread Terry Reedy
int(list(SequenceMatcher('a','abc').get_matching_blocks())) shows the problem you posted in one easily read line of input and output. I only waded through the distracting code and output you posted to find that problem because I patched SequenceMatcher last fall. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: new string-formatting preferred? (was "What is this syntax ?")

2011-06-21 Thread Terry Reedy
On 6/21/2011 7:33 AM, Tim Chase wrote: On 06/20/2011 09:17 PM, Terry Reedy wrote: On 6/20/2011 8:46 PM, Tim Chase wrote: On 06/20/2011 05:19 PM, Ben Finney wrote: “This method of string formatting is the new standard in Python 3.0, and should be preferred to the % formatting described in

Re: something about performence

2011-06-21 Thread Terry Reedy
) for i in gift_line.split()] same for this line > if uin_a==uin_b: > score=y+gift > print uin_a,score > y_line=uin_y.next() > gift_line=uin_gift.next() > if uin_a print uin_a,y > y_line=uin_y.next() > if uin_a>uin_b: > print uin_b,gift > gift_line=uin_gift.next() > except StopIteration: > break -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Terry Reedy
tion to be obtained on a modestly powered computer in less than one minute." That statement is for C, not Python. Python is efficient with human time, but not machine time. If something really takes a minute in C, allow yourself at least 10 minutes or even more with plain CPython. --

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Terry Reedy
On 6/21/2011 8:00 PM, Paul Rubin wrote: Terry Reedy writes: efficient implementation will allow a solution to be obtained on a modestly powered computer in less than one minute." If something really takes a minute in C, allow yourself at least 10 minutes or even more with plain CPython.

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-22 Thread Terry Reedy
On 6/22/2011 1:32 AM, Paul Rubin wrote: Terry Reedy writes: If the best C program for a problem takes 10 seconds or more, then applying the same 1 minute limit to Python is insane, and contrary to the promotion of good algorithm thinking. The Euler problems are not the only algorithm

Re: what happens inside?

2011-06-22 Thread Terry Reedy
also not hashable (if any element is not hashable) and cannot be used as dict keys. >>> hash(a) Traceback (most recent call last): File "", line 1, in hash(a) TypeError: unhashable type: 'list' -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Project-wide variable...

2011-06-23 Thread Terry Reedy
ve it be available in all submodules. Am I missing something? Yes. Make a project ~template.py file that includes the common import. Mine is something like #!python3 '''project_dir/.py -- 2011 Copyright Terry Jan Reedy ''' from test import ftest,itest def t

Re: Interpreting Left to right?

2011-06-23 Thread Terry Reedy
3,. Disassembly of bytecode shows how an expression was parsed. >>> from dis import dis >>> dis('(1,2)+3,') 1 0 LOAD_CONST 3 ((1, 2)) 3 LOAD_CONST 2 (3) 6 BINARY_ADD 7 BUILD_TUPLE

Re: Project-wide variable...

2011-06-23 Thread Terry Reedy
the use of Data is at toplevel or in a class statement outside a def. or if that can't be done: 2) Can I tell ModuleTest.py to "look upstream" for Data? Yes if ModuleTest imports Executable, but circular imports are a bad idea. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Interpreting Left to right?

2011-06-24 Thread Terry Reedy
erhaps best to expand "a = b = c" to "a = c; b = c" and see the first as an abbreviation thereof -- just delete the 'c;'. If I have ever used this sort of multiple assignment, it has been for simple unambiguous things like "a = b = 0". -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Project-wide variable...

2011-06-24 Thread Terry Reedy
On 6/24/2011 7:30 AM, Gnarlodious wrote: On Jun 24, 12:27 am, Terry Reedy wrote: 1) Can I tell Executable.py to share Data with ModuleTest.py? After the import is complete, yes. import ModuleTest ModuleTest.Data = Data This works if the use of Data is inside a function that is not called

Re: python overloading

2011-06-24 Thread Terry Reedy
even checkout? How do i get read-only access? I believe that exact link is for web viewing. What was your exact svn or tortoise svn command? -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

<    3   4   5   6   7   8   9   10   11   12   >