Re: Is it a bug?

2009-08-25 Thread Jan Kaliszewski
25-08-2009 o 22:51:14 Gleb Belov wrote: I have two questions: 1) Is it possible and if so, how do I access each individual element? Are there any indexes and what is the syntax? It's a 'Read-The-Friendly-Manual' question. (hint: library reference - Built-in Types - ...) --

Re: break unichr instead of fix ord?

2009-08-25 Thread Jan Kaliszewski
d loosely) so that it too now fails with characters outside the BMP. [snip] Does not this effectively make unichr() and ord() useless on Windows for all but a subset of unicode characters? Are you sure, you couldn't have UCS-4-compiled Python distro for Windows?? :-O *j -- Jan Kaliszewsk

Re: Need help with Python scoping rules

2009-08-26 Thread Jan Kaliszewski
ch "recursive" references in Python). -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: all possible matchings of elements of two lists

2009-08-26 Thread Jan Kaliszewski
permutations of two lists given and select any combination and use zip to get the tuples. Repeat this for all possible combinations. Any other ideas? See: module itertools -- there are (OOTB) some combinatoric generators that may be useful for you. *j -- Jan Kaliszewski (zuo) -- http

Re: Need help with Python scoping rules

2009-08-26 Thread Jan Kaliszewski
def fact(fact, n): if n < 2: return 1 else: return n * fact(fact, n - 1) fact(fact, 3) *j -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding iadd for dictionary like objects

2009-08-26 Thread Jan Kaliszewski
return cls 32 33 return cls_wrapper 34 35 36 @verbose_cls(dict) 37 class VerboseDict(dict): 38 pass 39 40 41 @verbose_cls(int) 42 class MyInt(int): 43 44 @verbose_func 45 def __iadd__(self, other): 46 int.__add__(self, other) # can do something more

Re: Overriding iadd for dictionary like objects

2009-08-26 Thread Jan Kaliszewski
44 @verbose_func 45 def __iadd__(self, other): 46 int.__add__(self, other) # can do something more interesting 47 48 49 if __name__ == '__main__': 50 d = VerboseDict() 51 52 print("d['a'] = 3") 53 d['a'] = MyInt(3) 54 55 print("d['a'] += 3") 56 d['a'] += MyInt(3) *j -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help with Python scoping rules

2009-08-27 Thread Jan Kaliszewski
14:17:15 Steven D'Aprano wrote: The class is a scope, and inside the class scope, you can access local names. What you can't do is access the class scope from inside nested functions. s/from inside nested functions/from inside nested scopes Besides that detail, I fully agree.

Re: copy construtor question

2009-08-29 Thread Jan Kaliszewski
"'shallow' or 'deepcopy'") ...but in such cases as copying existing objects it is usualy better (though less romantic :-)) to use an ordinary function (e.g. simply copy.copy() or copy.deepcopy(), as Gabriel has pointed). Regards, *j -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding iadd for dictionary like objects

2009-08-30 Thread Jan Kaliszewski
PS. Sorry for sending 2 posts -- the latter is the correct one. Cheers, *j -- http://mail.python.org/mailman/listinfo/python-list

Re: An assessment of the Unicode standard

2009-08-30 Thread Jan Kaliszewski
nification would mean terrible impoverishment of our (humans') culture and, as a result, terrible squandering of our intelectual, emotional, cognitive etc. potential -- especially if such unification were a result of intentional policy (and not of a slow and 'patient' process of synth

Re: Efficient way to sum a product of numbers...

2009-08-31 Thread Jan Kaliszewski
em__, names), hours))', ... ) for t in tests: ... print t ... timeit.repeat(t, setup, number=1000) ... print ... sum(v * r[k] for k,v in m) [6.2493009567260742, 6.1892399787902832, 6.2634339332580566] sum(starmap(mul, ((r[name], hour) for name, hour in m))) [9.3293819427490234, 10.280816

Re: Efficient way to sum a product of numbers...

2009-08-31 Thread Jan Kaliszewski
31-08-2009 o 22:28:56 Jan Kaliszewski wrote: >>> setup = "from itertools import starmap, imap ; from operator import mul; import random, string; names = [rndom.choice(string. ascii_letters) for x in xrange(1)]; hours = [random.randint( 1, 12) for x in xrange(1000)]; m = zi

Re: map

2009-09-01 Thread Jan Kaliszewski
st, itertools.repeat('booHoo'))) Cheers, *j -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating slice notation from string

2009-09-02 Thread Jan Kaliszewski
;> # Using map. >>> x[slice(*map(int, s.strip("[]").split(":")))] [3] >>> # Using a list comprehension. >>> x[slice(*[int(i) for i in s.strip("[]").split(":")])] [3] Of course, you could also do something like this: ev

Re: Creating slice notation from string

2009-09-02 Thread Jan Kaliszewski
Erratum: eval(str(x) + s) -- but it's worse: less secure (e.g. if s could be user-typed) and most probably much more time-consuming (especially the latter). There should be *repr* instead of *str*. *j -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating slice notation from string

2009-09-02 Thread Jan Kaliszewski
p("[]").split(":")])] Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '' Similar problem with [2:]. Ideas? x = [1,4,3,5,4,6,5,7] s = '[3:6]' x[slice(*((int(i) if i els

Re: using queue

2009-09-02 Thread Jan Kaliszewski
y the best with a powerful single core; with more cores it becomes being suprisingly inefficient. The culprit is Pythn GIL and the way it [mis]cooperates with OS scheduling. See: http://www.dabeaz.com/python/GIL.pdf Yo *j -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: Usage of main()

2009-09-04 Thread Jan Kaliszewski
hanks to using the __main__ idiom (i.e. 'if __name__ == "__main__":' condition). Cheers, *j -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: Usage of main()

2009-09-04 Thread Jan Kaliszewski
ic code in functions -- because, as we noted: * in practice it is considerably faster, * it helps you with using functions & class browsers. Cheers, *j -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: possible attribute-oriented class

2009-09-04 Thread Jan Kaliszewski
27;a': 1, 'c': 89, 'b': 2}),\ # 'third': '3rd', 'first': 1} print(struct._as_str(8)) # output: # { # second: 2.0 # sub: # { # a: 1 # c: 89 # b: 2 # } # third: 3rd # first: 1 # } What do you think about it? Cheers, *j -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: possible attribute-oriented class

2009-09-04 Thread Jan Kaliszewski
04-09-2009 Ken Newton wrote: I like this version very much. I'm ready to put this into practice to see how it works in practice. [snip] Not only you (Ken) and me. :-) It appears that the idea is quite old. Nick Coghlan replied at [email protected]: Jan Kaliszewski wrote: What d

Re: possible attribute-oriented class

2009-09-05 Thread Jan Kaliszewski
05-09-2009 Steven D'Aprano wrote: On Fri, 04 Sep 2009 22:37:15 +0200, Jan Kaliszewski wrote: Named tuples (which indeed are really very nice) are read-only, but the approach they represent could (and IMHO should) be extended to some kind of mutable objects. [snip] What sort of exten

Re: Q on explicitly calling file.close

2009-09-06 Thread Jan Kaliszewski
finally: f.close() Obviously it doesn't substitute catching with 'except', but I don't see how it could disturb that. Cheers, *j -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: possible attribute-oriented class

2009-09-06 Thread Jan Kaliszewski
scripting (which is still important area of Python usage). -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/listinfo/python-list

Re: possible attribute-oriented class

2009-09-07 Thread Jan Kaliszewski
08-09-2009 o 02:15:10 Steven D'Aprano wrote: On Mon, 7 Sep 2009 09:37:35 am Jan Kaliszewski wrote: 06-09-2009 o 20:20:21 Ethan Furman wrote: > ... I love being able to type > >current_record.full_name == last_record.full_name > > instead of > >

Re: An assessment of the Unicode standard

2009-09-10 Thread Jan Claeys
Op Sun, 30 Aug 2009 15:28:55 -0700, schreef r: > I said it before and i will say it again. I DON"T CARE WHAT LANGUAGE WE > USE AS LONG AS IT IS A MODERN LANGUAGE FOUNDED ON IDEALS OF > SIMPLICITY Maybe we should use a language that has a Turing-complete grammar, so that even computers can un

How to do module configuration properly

2010-10-22 Thread Jan Kosinski
I have created a python module, which contains a bunch of utility functions that use a number of global variables (directory and file names, etc.). I want to move that global variables to an external configuration file and I want to load all global variables from that configuration file when mod

Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-27 Thread Jan Gosmann
fact, this is what I find if I run the program with a smaller test cases. There the memory consumption is less with Python 3.6. Cheers, Jan -- https://mail.python.org/mailman/listinfo/python-list

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-27 Thread Jan Gosmann
On 27 Mar 2017, at 18:30, Peter Otten wrote: Are you perchance comparing 32-bit Python 3.5 with 64-bit Python 3.6? I don't think so. [sys.maxsize](https://docs.python.org/3/library/platform.html#cross-platform) indicates both to be 64-bit. -- https://mail.python.org/mailman/listinfo/python-

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-27 Thread Jan Gosmann
On 27 Mar 2017, at 18:42, Chris Angelico wrote: Are you able to share the program? I could try it on my system and see if the same thing happens. Yes, it is on GitHub (use the fixes branch): https://github.com/ctn-archive/gosmann-frontiers2017/tree/fixes Installation instructions are in the

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-27 Thread Jan Gosmann
with 3.6 because things get written to the swap partition. Jan -- https://mail.python.org/mailman/listinfo/python-list

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-27 Thread Jan Gosmann
ddress space is actually used. In fact, the code might be especially bad to fragmentation because it takes a lot of small NumPy arrays and concatenates them into larger arrays. But I'm still surprised that this is only a problem with Python 3.6 (if this hypothesis is correct). Jan -- htt

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-28 Thread Jan Gosmann
On 28 Mar 2017, at 3:08, Peter Otten wrote: > Perhaps numpy's default integer type has changed (assuming you are using > integer arrays, I did look at, but not into your code)? > > You could compare > numpy.array([42]).itemsize > 8 > > for the two interpreters. Both report 8 for integer and

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-28 Thread Jan Gosmann
n fact, the code might be especially bad to fragmentation because it takes a lot of small NumPy arrays and concatenates them into larger arrays. But I'm still surprised that this is only a problem with Python 3.6 (if this hypothesis is correct). Jan Generally speaking, VMM vs RSS doesn't

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-29 Thread Jan Gosmann
On 28 Mar 2017, at 14:21, INADA Naoki wrote: On Wed, Mar 29, 2017 at 12:29 AM, Jan Gosmann wrote: I suppose smaller and faster benchmark is better to others looking for it. I already stopped the azure instance. [...] There are no maxrss difference in "smaller existing examples"

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-29 Thread Jan Gosmann
be able to demonstrate the effect with simple example code because I haven't the slightest idea what is causing it. Also, I'm not sure how much more time I want to invest in this. After all it is a problem that might never get noticed by any users of the software. Jan -- https://mail.python.

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-30 Thread Jan Gosmann
That's great news. I'm busy with other things right now, but will look into your findings in more detail later. On 03/30/2017 02:09 PM, INADA Naoki wrote: Filed an issue: https://bugs.python.org/issue29949 Thanks for your report, Jan. On Fri, Mar 31, 2017 at 3:04 AM, INADA Na

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-31 Thread Jan Gosmann
ost people won't run models of the size of Spaun, so usually the memory requirements will be much lower Jan -- https://mail.python.org/mailman/listinfo/python-list

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-31 Thread Jan Gosmann
sets and frozensets? Or any other way I can be helpful in fixing this? (There are a few questions in this thread that I haven't answered so far, but as the problem seems to be identified it might not be worth spending time on that.) Jan -- https://mail.python.org/mailman/listinfo/python-list

Re: Bigotry (you win, I give up)

2017-04-26 Thread Jan Coombs
kered, or a good believing nationalist citizen, you can easily believe that you know everything. Then you just get on and do it, regardless. So don't blame Hxxler or anyone else, acquire knowledge, and do testing, even when it's only your view of Python that might change. Jan Coombs -- https://mail.python.org/mailman/listinfo/python-list

cPickle fails on manually compiled and executed Python function

2017-07-17 Thread Jan Gosmann
an this be considered a bug? (In that case I could open an issue in the bug tracker.) Cheers, Jan -- https://mail.python.org/mailman/listinfo/python-list

Re: cPickle fails on manually compiled and executed Python function

2017-07-18 Thread Jan Gosmann
On 07/18/2017 01:07 AM, dieter wrote: "Jan Gosmann" writes: [...] fn = load_pyfile('fn.py')['fn'] [...] "pickle" (and "cpickle") are serializing functions as so called "global"s, i.e. as a module reference together with a name. T

Re: First python program, syntax error in while loop

2013-05-06 Thread Terry Jan Reedy
On 5/6/2013 11:31 AM, Roy Smith wrote: In article , Chris Angelico wrote: On Mon, May 6, 2013 at 11:08 PM, Roy Smith wrote: On the other hand, I've long since given up trying to remember operator precedence in various languages. If I ever have even the slightest doubt, I just go ahead and p

Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Terry Jan Reedy
On 5/7/2013 9:22 AM, jmfauth road forth on his dead hobbyhorse to hijack yet another thread: # Py 3.3 ascii and non ascii chars timeit.repeat("a = 'hundred'; 'x' in a") [0.11426985953005442, 0.10040049292649655, 0.09920834808588097] timeit.repeat("a = 'maçãé€ẞ'; 'é' in a") [0.23455951882567

Re: Get filename using filefialog.askfilename

2013-05-07 Thread Terry Jan Reedy
ined by the mode ('b' present or not), buffer arg, and maybe something else. You can look in the io chapter or use dir() and help() as John G. suggested. Python programmers should really learn to use dir(), help(), and the manuls, including the index and module index. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Making safe file names

2013-05-07 Thread Terry Jan Reedy
On 5/7/2013 3:58 PM, Andrew Berg wrote: Currently, I keep Last.fm artist data caches to avoid unnecessary API calls and have been naming the files using the artist name. However, artist names can have characters that are not allowed in file names for most file systems (e.g., C/A/T has forward s

Re: cello library

2013-05-08 Thread Terry Jan Reedy
with (file in open($(File, NULL), "prices.bin", "wb"))) { ... } An interesting question is whether it could be used to convert or rewrite Python to C. __ Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: object.enable() anti-pattern

2013-05-08 Thread Terry Jan Reedy
On 5/9/2013 1:23 AM, Steven D'Aprano wrote: Besides, this is not to denigrate the idea of a read() function that takes a filename and returns its contents. But that is not an object constructor. It may construct a file object internally, but it doesn't return the file object, so it is completely

Re: Forming a small python programming group

2013-05-09 Thread Terry Jan Reedy
On 5/9/2013 2:59 AM, kreta06 wrote: Hi All, I'm looking for one or two medium-advanced python programmers to practice programming on a Windows 7 platform. In addition, any interests in writing python code to query Microsoft SQL databases (2005-2008) is also welcomed. I've coded in python 2.7 an

Re: Old version docs don't link to current version

2013-05-12 Thread Terry Jan Reedy
On 5/12/2013 10:12 AM, Chris Angelico wrote: Not sure if this is an oversight or something deliberate... could be either. From http://docs.python.org/3.0/library/http.server.html there's no link to the current docs, even though from http://docs.python.org/3/library/http.server.html it's possibl

Re: object.enable() anti-pattern

2013-05-12 Thread Terry Jan Reedy
On 5/12/2013 1:14 PM, Wayne Werner wrote: On Fri, 10 May 2013, Gregory Ewing wrote: Wayne Werner wrote: You don't ever want a class that has functions that need to be called in a certain order to *not* crash. That seems like an overly broad statement. What do you think the following should d

Re: object.enable() anti-pattern

2013-05-12 Thread Terry Jan Reedy
ess bugs, easier to comprehend, change/update your code. Easier to use the class. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Message passing syntax for objects | OOPv2

2013-05-12 Thread Terry Jan Reedy
On 5/12/2013 1:18 PM, Ned Batchelder wrote: On 5/8/2013 10:39 PM, Mark Janssen wrote: ...The field needs re-invented and re-centered.[...] For anyone who want to be involved. See the wikiwikiweb -- a tool that every programmer should know and use -- and these pages: ComputerScienceVersionTwo

Re: Fwd: Python for philosophers

2013-05-14 Thread Terry Jan Reedy
2013/5/14 Steven D'Aprano mailto:[email protected]>> >Python is not named after the snake, but after Monty Python the British >comedy troupe. And they picked their name because it sounded funny. That does not mean they were unaware that Pythons are snakes. "

Re: Writing a blog post on the new Enum.

2013-05-14 Thread Terry Jan Reedy
On 5/14/2013 3:52 AM, Chris Angelico wrote: On Tue, May 14, 2013 at 9:40 AM, Fábio Santos wrote: http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html class Text(unicode, Enum): one = u'one' two = u'two' three = u'three' Is this supposed to

Re: Python for philosophers

2013-05-15 Thread Terry Jan Reedy
On 5/15/2013 9:17 PM, Tim Daneliuk wrote: http://pvspade.com/Sartre/cookbook.html Wikedly funny. -- http://mail.python.org/mailman/listinfo/python-list

Re: python script is not running

2013-05-18 Thread Terry Jan Reedy
On 5/18/2013 6:12 AM, Avnesh Shakya wrote: hi, i want to run python script which generating data into json fromat, I am using crontab, but it's not executing... my python code-- try.py -- import json import simplejson as json import sys def tryJson(): saved = sys.stdout correctF

Re: how to run another file inside current file?

2013-05-18 Thread Terry Jan Reedy
On 5/18/2013 7:15 AM, Kevin Xi wrote: Hi, It's better to specify version of python you work with. Absolutely. I know nothing about python 3 but in python 2 you can do this with `exec`. Example: > f = file('otherFile.py') > exec f Py 2 has execfile that does the above. Py 3 do as above

Re: Future standard GUI library

2013-05-18 Thread Terry Jan Reedy
On 5/18/2013 10:03 AM, Beinan Li wrote: Not sure if this is the right place to talk about this. It is. Even less sure if I can move this discussion to tkinter list, The idea of replacing tkinter is not about improving tkinter ;-). Do you think tkinter is going to be the standard python bu

Re: TypeError: unbound method add() must be called with BinaryTree instance as first argument (got nothing instead)

2013-05-18 Thread Terry Jan Reedy
On 5/18/2013 3:46 PM, Peter Otten wrote: Dan Stromberg wrote: python 2.x, python 3.x and pypy all give this same error, though jython errors out at a different point in the same method. By the way, 3.x doesn't have unbound methods, so that should work. It does for this example (3.3.1) >>> c

Re: Harmonic distortion of a input signal

2013-05-19 Thread Terry Jan Reedy
On 5/19/2013 6:49 PM, Oscar Benjamin wrote: import numpy as np Create a square wave signal: x = np.zeros(50) x[:25] = -1 x[25:] = +1 x array([-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., 1., 1.

Re: Future standard GUI library

2013-05-20 Thread Terry Jan Reedy
On 5/20/2013 1:04 AM, Vito De Tullio wrote: Terry Jan Reedy wrote: Do you think tkinter is going to be the standard python built-in gui solution as long as python exists? AT the moment, there is nothing really comparable that is a realistic candidate to replace tkinter. FLTK? (http

Re: What was the project that made you feel skilled in Python?

2013-05-20 Thread Terry Jan Reedy
On 5/20/2013 3:36 PM, Thomas Murphy wrote: talking about "patches" in the stdlib? Is there a separate library of patches? http://bugs.python.org http://docs.python.org/devguide/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Myth Busters: % "this old style of formatting will eventually be removed from the language"

2013-05-22 Thread Terry Jan Reedy
On 5/22/2013 10:24 AM, Denis McMahon wrote: Indeed, removing %-formatting could break a substantial amount of live code, with potentially significant maintenance effort in the user While I would like to see % formatting go away everntually*, other developers would not. In any case, I agree th

Re: What was the project that made you feel skilled in Python?

2013-05-22 Thread Terry Jan Reedy
On 5/22/2013 9:05 AM, Ben Finney wrote: I wanted to simulate a particular board game, and had others in mind with some common mechanics. This resulted in a library for rolling dice in different combinations, and looking up result tables https://pypi.python.org/pypi/alea>. Have you cosidered a

Re: subclassing from unittest

2013-05-22 Thread Terry Jan Reedy
class UpperSub(StdTestCase): pass unittest.main(verbosity=2, exit=False) # prints (3.3) -- Ran 0 tests in 0.000s OK Same as before the subclasses were added. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about evaluating raw_input() responses

2013-05-23 Thread Terry Jan Reedy
On 5/23/2013 12:47 AM, Steven D'Aprano wrote: On Wed, 22 May 2013 22:31:04 +, Alister wrote: Please write out 1000 time (without using any form of loop) "NEVER use input in python <3.0 it is EVIL"* But all joking aside, eval is dangerous, yes, but it is not "evil". He put that label o

Re: subclassing from unittest

2013-05-23 Thread Terry Jan Reedy
On 5/23/2013 2:58 AM, Ulrich Eckhardt wrote: Well, per PEP 8, classes use CamelCaps, so your naming might break automatic test discovery. Then, there might be another thing that could cause this, and that is that if you have an intermediate class derived from unittest.TestCase, that class on its

Re: how to get the socket module compiled with SSL support

2013-05-23 Thread Terry Jan Reedy
On 5/23/2013 9:58 AM, Kihup Boo wrote: I am trying to make an HTTPS connection and read that HTTPS support is only available if the socket module was compiled with SSL support. _http://www.jython.org/docs/library/httplib.html_ Can someone elaborate on this? Where can I get the socket module for

Re: PEP 378: Format Specifier for Thousands Separator

2013-05-23 Thread Terry Jan Reedy
On 5/23/2013 2:42 PM, Dave Angel wrote: On 05/23/2013 11:26 AM, Carlos Nepomuceno wrote: eggs(a,f) Traceback (most recent call last): File "", line 1, in eggs(a,f) File "", line 1, in eggs def eggs(spam, ham): return spam % ham TypeError: not all arguments converted during string formattin

Re: Non-identifiers in dictionary keys for **expression syntax

2013-05-23 Thread Terry Jan Reedy
On 5/23/2013 2:52 PM, Matthew Gilson wrote: This is a question regarding the documentation around dictionary unpacking. The documentation for the call syntax (http://docs.python.org/3/reference/expressions.html#grammar-token-call) says: "If the syntax **expression appears in the function call,

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Terry Jan Reedy
On 5/24/2013 4:14 AM, Peter Brooks wrote: What is the easiest way to reorder a sequence pseudo-randomly? That is, for a sequence 1,2,3,4 to produce an arbitrary ordering (eg 2,1,4,3) that is different each time. I'm writing a simulation and would like to visit all the nodes in a different order

Re: Short-circuit Logic

2013-05-26 Thread Terry Jan Reedy
On 5/26/2013 7:11 AM, Ahmed Abdulshafy wrote: if not allow_zero and abs(x) < sys.float_info.epsilon: print("zero is not allowed") The reason for the order is to do the easy calculation first and the harder one only if the first passes. -- http://mail.python.org/mail

Re: Output from to_bytes

2013-05-26 Thread Terry Jan Reedy
On 5/26/2013 8:02 AM, Mok-Kong Shen wrote: for k in range(8,12,1): print(k.to_bytes(2,byteorder='big')) http://bugs.python.org/issue9951 http://bugs.python.org/issue3532 import binascii as ba for k in range(8,12,1): print(ba.hexlify(k.to_bytes(2,byteorder='big'))) >>> b'0008' b'0

Re: Encodign issue in Python 3.3.1 (once again)

2013-05-26 Thread Terry Jan Reedy
On 5/26/2013 12:36 PM, Νίκος Γκρ33κ wrote: This is the code that although correct becaus it works with englisg(standARD ASCII letters) it wont with Greek: if( log ): name = log # print specific client header info cur.execute('''SELECT hits, money FROM clients WHERE name

Re: Cutting a deck of cards

2013-05-26 Thread Terry Jan Reedy
On 5/26/2013 3:54 PM, Carlos Nepomuceno wrote: From: [email protected] [...] Not in Python3.x decks = 6 list(range(13 * 4 * decks)) == range(13 * 4 * decks) False Adiaŭ Marc What does "list(range(13 * 4 * decks))" returns in Python 3?

Re: Short-circuit Logic

2013-05-26 Thread Terry Jan Reedy
On 5/26/2013 4:22 PM, Roy Smith wrote: In article , Terry Jan Reedy wrote: On 5/26/2013 7:11 AM, Ahmed Abdulshafy wrote: if not allow_zero and abs(x) < sys.float_info.epsilon: print("zero is not allowed") The reason for the order is to do the eas

Re: Python error codes and messages location

2013-05-27 Thread Terry Jan Reedy
On 5/27/2013 12:54 PM, Carlos Nepomuceno wrote: I think PEP 3151 is a step ahead! That's almost exactly what I was looking for. Why did it take so long to have that implemented? Since this PEP involved changing existing features, rather than adding som

Re: Python #ifdef

2013-05-28 Thread Terry Jan Reedy
On 5/28/2013 6:25 PM, Joel Goldstick wrote: On Tue, May 28, 2013 at 6:18 PM, Mark Lawrence mailto:[email protected]>> wrote: On 28/05/2013 20:46, Carlos Nepomuceno wrote: I'd like to have something like '#ifdef' to mix code from Python 2 and 3 in a single file.

Re: The state of pySerial

2013-05-29 Thread Terry Jan Reedy
On 5/29/2013 4:00 PM, William Ray Wing wrote: On May 29, 2013, at 2:23 PM, Ma Xiaojun wrote: Hi, all. pySerial is probably "the solution" for serial port programming. Physical serial port is dead on PC but USB-to-Serial give it a second life. Serial port stuff won't interest end users at all.

Re: The state of pySerial

2013-05-29 Thread Terry Jan Reedy
On 5/29/2013 3:47 PM, Grant Edwards wrote: On 2013-05-29, Ma Xiaojun wrote: pySerial is probably "the solution" for serial port programming. Physical serial port is dead on PC but USB-to-Serial give it a second life. Serial port stuff won't interest end users at all. But it is still used in th

Finding Relative Maxima in Python3

2013-05-31 Thread Lourens-Jan Ugen
Hi all, The last few days I've been working on a script to manipulate some scientific data. One thing I would like to be able to do is find relative maxima in a data set. I'm using numpy in python3 (which I think I can't do without because of utf16 encoding of my data source) and a series of n

Re: Future standard GUI library

2013-06-01 Thread Terry Jan Reedy
On 6/1/2013 4:46 PM, Chris Angelico wrote: On Sun, Jun 2, 2013 at 4:18 AM, Wolfgang Keller wrote: And by "screenworkers" I didn't refer to programmers. Those people rarely have to use the stuff that they implement. Of course not, programmers never use software they've themselves written. Ne

Re: Python 2-3 compatibility

2013-06-02 Thread Terry Jan Reedy
pported operand type(s) for /: 'int' and 'str' " There are more tips on that page, a reference to the six module, and more hits on the search page. Good luck. You are not the first to support the same range of versions (and for the same reasons). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Interactive interpreter hooks

2013-06-03 Thread Terry Jan Reedy
On 6/3/2013 3:55 AM, Steven D'Aprano wrote: The sys module defines two hooks that are used in the interactive interpreter: * sys.displayhook(value) gets called with the result of evaluating the line when you press ENTER; * sys.excepthook(type, value, traceback) gets called with the details of t

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-05 Thread Terry Jan Reedy
On 6/5/2013 2:11 AM, Russ P. wrote: But then, what would you expect of a language that allows you to write x = 1 > x = "Hello" It's all loosey goosey -- which is fine for many applications but certainly not for critical ones. I believe Shedskin, a Python *subset* compiler*, will reject tha

Dijkstra (was Re: Source code to identify user through browser?)

2013-06-05 Thread Terry Jan Reedy
the 'Averages are not extreme' theorem. Corollary: if min(s) == 1 and sum(S) > n, then max(S) > 1 'Pigeonhole Principle' -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Mistakes in documentation

2013-06-06 Thread Terry Jan Reedy
On 6/6/2013 8:01 AM, Paul Volkov wrote: Where can I submit little mistakes in Python documantation? I found one while browsing tutorial.pdf (Python 3.3.2): Section 3.1 says (on page 12): >>> word[2:5] # characters from position 2 (included) to 4 (excluded) ’tho’ Shouldn't the comment say "5 (e

Re: Idiomatic Python for incrementing pairs

2013-06-08 Thread Terry Jan Reedy
cleaner but a bit slower than your in-lined version. I did not use __iadd__ and += because unpacking 'other' (here the process return) in the call does the error checking ('exactly two values') for 'free'. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Terry Jan Reedy
On 6/10/2013 12:09 PM, Rui Maciel wrote: We've established that you don't like attribute declarations, at least those you describe as not fulfill a technical purpose. What I don't understand is why you claim that that would "cause nothing but trouble". Three answers: Look how much trouble it

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Terry Jan Reedy
On 6/10/2013 9:18 AM, Rui Maciel wrote: class Model: points = [] lines = [] Unless you actually need keep the points and lines ordered by entry order, or expect to keep sorting them by whatever, sets may be better than lists. Testing that a point or line is in the model wil

Re: py_compile vs. built-in compile, with __future__

2013-06-10 Thread Terry Jan Reedy
On 6/10/2013 11:33 AM, dhyams wrote: The built-in compile() function has a "flags" parameter that one can use to influence the "__future__" mechanism. However, py_compile.compile, which I'm using to byte-compile code, doesn't have an equivalent means to do this. That flag was added to compile b

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Terry Jan Reedy
On 6/10/2013 4:13 PM, Rui Maciel wrote: Terry Jan Reedy wrote: Three answers: Look how much trouble it has already caused ;-) Since you are a self-declared newbie, believe us! Since, be definition, useless code can do no good, it can only cause trouble. Think about it. I don't doubt

"Don't rebind built-in names*" - it confuses readers

2013-06-10 Thread Terry Jan Reedy
dle stays confused and will wrongly color the list instance name until it is changed. Calling the file list 'fnames' or 'filenames' would have been clearer to both me and Idle. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-10 Thread Terry Jan Reedy
On 6/10/2013 10:56 PM, Steven D'Aprano wrote: I was initially confused and reading the code still takes a small bit of extra mental energy. Idle stays confused and will wrongly color the list instance name until it is changed. Calling the file list 'fnames' or 'filenames' would have been clearer

Re: [pyxl] xlrd-0.8.0 .xlsx formatting_info=True not implemented

2012-08-31 Thread Albert-Jan Roskam
time http://cran.r-project.org/web/packages/xlsx/xlsx.pdf   Regards, Albert-Jan ~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health,

Re: print without ()

2017-09-06 Thread Jan Erik Moström
On 7 Sep 2017, at 8:14, Andrej Viktorovich wrote: If I use command print "aaa" in console I get error. So, why this is allowed in sample? You're probably using Python 2 for the listed script and Python 3 when you try in the console. = jem -- https://mail.python.org/mailman/listinfo/python-l

Re: Old Man Yells At Cloud

2017-09-19 Thread Jan Erik Moström
On 19 Sep 2017, at 13:01, bartc wrote: My bill in a store came to £3.20 (GBP3.20), so I handed over £10.20. I was given back £16.90 in change! It turned out the cashier had entered £20.10 as the amount tendered. It was sorted out in the end. Sometimes its easier not to be bother making the

Book recommendation for Spark/Pyspark?

2017-11-13 Thread Albert-Jan Roskam
its cover. Thanks! Albert-Jan -- https://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   >