Re: Portable locale usage

2011-09-06 Thread Thomas Jollans
On 06/09/11 16:46, ssegvic wrote: > For the moment, I only wish to properly sort a Croatian text file > both on Windows and Linux (I am a cautious guy, I like reachable > goals). > When the locale is properly set, sorting works like a charm > with mylist.sort(key=locale.strxfrm). The problem with

Re: Portable locale usage

2011-09-07 Thread Thomas Jollans
On 07/09/11 12:39, ssegvic wrote: > On 6 ruj, 17:53, Thomas Jollans wrote: >> On 06/09/11 16:46, ssegvic wrote: >> >>> For the moment, I only wish to properly sort a Croatian text file >>> both on Windows and Linux (I am a cautious guy, I like reachable >>&g

Re: Looking for open-source Python projects to help out with

2011-09-07 Thread Thomas Jollans
On 07/09/11 04:19, Littlefield, Tyler wrote: > Hello: > I've got a bit of time on my hands, so I'm curious what sorts of > projects there are that people needs help with. I'd like to choose > something that doesn't have a ton of red tape, but is stable, which is > why I ask here instead of just Goo

Re: Portable locale usage

2011-09-07 Thread Thomas Jollans
On 07/09/11 20:33, Siniša Šegvić wrote: > I expect that most of my Windows users will not care > to configure their computers with the national locale > (and besides, that does not seem to work, anyway). Are, on Windows, the default system region/language setting, and the locale, distinct? (And,

Re: Problems of Symbol Congestion in Computer Languages

2011-03-01 Thread Mark Thomas
I know someone who was involved in creating a language called A+. It was invented at Morgan Stanley where they used Sun keyboards and had access to many symbols, so the language did have set symbols, math symbols, logic symbols etc. Here's a keyboard map including the language's symbols (the red ch

Creating a very simple revision system for photos in python

2011-03-11 Thread Thomas W
I`m thinking about creating a very simple revision system for photos in python, something like bazaar, mercurial or git, but for photos. The problem is that handling large binary files compared to plain text files are quite different. Has anybody done something like this or have any thoughts about

Re: Creating a very simple revision system for photos in python

2011-03-11 Thread Thomas W
On 11 Mar, 17:23, Tim Golden wrote: > On 11/03/2011 16:05, Chris Hulan wrote: > > > > > > > > > > > On Mar 11, 9:56 am, Thomas W  wrote: > >> I`m thinking about creating a very simple revision system for photos > >> in python, something l

threading.Semaphore (quite long)

2011-03-28 Thread Thomas Rachel
python -m t 3 improves Semaphore() by putting self.__cond.release() into a finally: clause. python -m t 4 "destroys" this beautiful new concept by throwing an Asserion at the appropriate (worst case) place (instead of a KeyboardInterrupt). So the question is: Bug(report) doe to finally:,

Suggest some exercises on Python

2011-04-05 Thread Jins Thomas
e in python. But i'm feeling it's too much complicated for my capability. Cheers Jins thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: How to program in Python to run system commands in 1000s of servers

2011-04-07 Thread Thomas Rachel
hat's what he needs to do, since it wasn't very clear. Maybe that works. But it is much, much worse than using keys... Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Namespaces in functions vs classes

2011-04-17 Thread Richard Thomas
On Apr 17, 8:56 pm, Chris Rebert wrote: > On Sun, Apr 17, 2011 at 12:30 PM, Gerald Britton > > > > > > > > > > wrote: > > I apologize if this has been answered before or if it is easy to find > > in the docs. (I couldn't find it but might have missed it) > > > I'm trying to understand the differe

Re: Pickling over a socket

2011-04-20 Thread Thomas Rachel
unctions appropriately. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem receiving UDP broadcast packets.

2011-04-20 Thread Thomas Heller
s regardless of their source IP address? This probably is more of a Linux networking question than a Python question, but I'm hoping somebody has solved this problem in Python. You must set the network interface to promiscous mode on the receiving side: os.system("ifconfig eth0

Re: Feature suggestion -- return if true

2011-04-21 Thread Thomas Rachel
('this') yield "first try", var1.hobgle(var2) var3 = last_resort(var1) yield "second try", var3.wiglat(var2) yield "default value", "Even that did not work." Disclaimer: Untested, but you should get the idea. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Closing generators

2011-04-21 Thread Thomas Rachel
manager deliberately left away, or just forgotten? It is fine to work with "with" on a file or other closable object - why not on a generator, without contextlib.closing()? TIA, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Closing generators

2011-04-22 Thread Thomas Rachel
only since 2.5. But in these (admittedly rarely) cases, it is better practice to close explicitly, isn't it? Unsure, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Closing generators

2011-04-23 Thread Thomas Rachel
robably due to the fact that this feature is needed so rarely (although it would have been nice to have it always...). Thanks for the answers, Thomas [1] Maybe in this way: class GeneratorClosing(object): """Take a parameterless generator functon and make it a context man

Re: Changing baud rate doesn't allow second command

2011-04-25 Thread Thomas Rachel
er.baudrate" instead of "print ser.baudrate", so that could be a source of behavioral differences. #import os #program = 'C:\Program Files\Program.exe'+'-start' #os.system(r'program) I suppose this doesn't belong to the problem? Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Argument of the bool function

2011-04-25 Thread Thomas Rachel
Am 10.04.2011 18:21, schrieb Mel: Chris Angelico wrote: Who would use keyword arguments with a function that takes only one arg anyway? It's hard to imagine. Maybe somebody trying to generalize function calls (trying to interpret some other language using a python program?) # e.g. input win

Re: dict.setdefault()

2011-04-25 Thread Thomas Rachel
k2=v2). Then you cannot set the key clobberexistingvalues to False via the update method any longer... Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Changing baud rate doesn't allow second command

2011-04-25 Thread Thomas Rachel
se setBaudrate() instead of close() and creating a new connection? I can't see why it should make a difference, but I as well can't see why your approach is not working, especially as it works if you do it manually... Maybe your target device expects to get something signalled via the

Re: sockets: bind to external interface

2011-04-25 Thread Thomas Rachel
0? Ah. That's what I really wanted. Thanks a lot. I wonder why that was not mentioned in the tutorial I used ... Generally, it seems better to use '' instead of '0.0.0.0' in this case in order to stay compatible with other address families, especially INET6. Thomas --

Re: sockets: bind to external interface

2011-04-25 Thread Thomas Rachel
r will be kept for a certain time on order not to kill any existing connections. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Argument of the bool function

2011-04-25 Thread Thomas Rachel
Am 25.04.2011 16:29, schrieb Thomas Rachel: or maybe even better (taking care for closures): function = bool value = 'the well at the end of the world' ## ... actions.append(lambda val=value: function(val)) ## ... for function in actions: results.append(function()) Or yet even bett

Re: Py_INCREF() incomprehension

2011-04-26 Thread Thomas Rachel
Am 26.04.2011 14:21, schrieb Thomas Rachel: Especially look at the concepts called "borrowed reference" vs. "owned reference". http://docs.python.org/extending/extending.html#reference-counting-in-python will be quite helpful. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Py_INCREF() incomprehension

2011-04-26 Thread Thomas Rachel
uot;, outdata); free(outdata); return ret; } BTW: Is there any reason for using calloc()? malloc() would probably be faster... Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Cannot get past this string related issue

2011-04-26 Thread Thomas Rachel
looks like following [DB_INFO] server = "server" database = "database" user = "user" password = "password" I think if you will have seen the output above, you will probably see what is wrong here: too many "s. :-) HTH & HAND! Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Py_INCREF() incomprehension

2011-04-26 Thread Thomas Rachel
got it, but don't need it, we do Py_(X)DECREF(). BTW: Is there any reason for using calloc()? malloc() would probably be faster... may be, I didn't measure it ever... but calloc() gives clear space... :) Ok. (But as sizeof(char) is, by C standard definition, always 1, you can write it

Re: Py_INCREF() incomprehension

2011-04-26 Thread Thomas Rachel
t ask this, because I don't set errstring with PyErr_SetString, but I get TypeError - how does Python knows, this error raised? There is magic inside... :-) Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Development tools and practices for Pythonistas

2011-04-26 Thread Thomas Rachel
his way, you can easily change from 2.0 you are working on to 1.5 requested by the customer. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Development tools and practices for Pythonistas

2011-04-26 Thread Thomas Rachel
Am 26.04.2011 20:42, schrieb Algis Kabaila: Thomas, have you tried bzr (Bazaar) and if so do you consider hg (Mercurial) better? I have played around with bzr, but afterwards more with hg which gave me a better beeling (don't know why)... Thomas -- http://mail.python.org/mailman/lis

Re: client-server parallellised number crunching

2011-04-27 Thread Thomas Rachel
y not? It might depend on some settings you set (keepalive etc.); but generally you should get an exception when trying a communication over a disconnected connection (over a disconnection? ;-)) When going over tne network, aviod pickling. Better use an own protocol. Thomas -- http://mail.py

Re: Py_INCREF() incomprehension

2011-04-27 Thread Thomas Rachel
one instance internally, it is not possible any longer to unload the module without a memory leak... As already stated - you might want to have a look at some other C modules and mimic their behaviour... (and hope they are doing it right...) Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Development tools and practices for Pythonistas

2011-04-27 Thread Thomas Rachel
Am 27.04.2011 13:17, schrieb Jean-Michel Pichavant: You're mistaking, SVN is not restricted to solo work. However it's more suitable for solo work than git. Why? I personally found hg much better than svn. That's why I migrated all my projects. Thomas -- http://mail.pyt

Re: Need your help

2011-04-28 Thread Thomas Rachel
ts etc.), and can re-use them if necessary, in order to prepend/append data. Closing can happen additionally, if the user wants. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-04-30 Thread Thomas Rachel
max: yield a a, b = b, a+b def fib(max=None, num=None): if num is None: return list(fibgen(max=max)) else: from itertools import islice return list(islice(fib(max=max), num)) Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-04-30 Thread Thomas Rachel
calls fib() twice, and each of those calls fib() twice, and you get the point... yes - but they are called one after the other, so the "twice" call counts only for execution speed, not for recursion depth. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: how to do random / SystemRandom switch

2011-04-30 Thread Thomas Rachel
= random.SystemRandom() else: randobj = random.Random() and then use from myrandom import randobj as random and then use random's methods (randrange, random, whatever), no matter where they come from. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Py_INCREF() incomprehension

2011-05-01 Thread Thomas Rachel
ch :) Understandable. That's that the printf debugging of the refcounts can be good for - even if you don't really have a problem. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: checking if a list is empty

2011-05-06 Thread Richard Thomas
On May 6, 7:36 am, Jabba Laci wrote: > Hi, > > If I want to check if a list is empty, which is the more pythonic way? > > li = [] > > (1) if len(li) == 0: > ... > or > (2) if not li: > ... > > Thanks, > > Laszlo I prefer (1), it feels more explicit about what I'm testing. The fact that empty sequ

Re: Dictionary Views -- good examples? [was Re: Python 3 dict question]

2011-05-08 Thread Thomas Rachel
first(myDict.items()) ... and get a StopIteration if the dict is empty. If you do def first(x, default=None): for i in x: return i return default you might have an alternative approach to do so. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the bitness of an arbitrary executable with Python

2011-05-09 Thread Richard Thomas
On May 9, 9:52 pm, Andrew Berg wrote: > I need to find whether a given file is 32-bit or 64-bit (and raise an > exception if the file doesn't exist or isn't an executable file). I > thought platform.architecture() would do this, but it returns ('64bit', > '') no matter what value I assign to the e

Re: Converting a set into list

2011-05-15 Thread Thomas Rachel
n loops are compiled into python, therfore they are the fastest. Which loops do you mean here? Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: indirect assignment question

2011-05-17 Thread Thomas Rachel
('mainWindow', 'window'), ('menuitem_output_on', 'outputToggleMenu'), ('button_toggle_output', 'outputToggleButton'), ('textview_log', 'logView'), ('scrolledwindow_log', 'logScrollWindow'), ) for name, selfname in assignmap: val = widgetDic[name] = self.wTree.get_widget(name) setattr(self, selfname, val) HTH, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: checking if a list is empty

2011-05-22 Thread Thomas Rachel
false. Right. And not only that: Python objects resp. classes not claiming to have a truth value (__nonzero__), but a length (__len__) are judged by that concerning their truth value: iff the length is 0, their truth value is False. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: List of WindowsError error codes and meanings

2011-05-26 Thread Thomas Heller
File "", line 1, in OverflowError: long int too large to convert to int >>> ctypes.FormatError(0x80040005 - (2**32-1)) 'Kein Cache zum Verarbeiten vorhanden.' >>> Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner needs advice

2011-05-27 Thread Thomas Rachel
nt(item) is valid syntax in every version of Python from 1.5 to 3.2, and it does the same thing in all of them. C and C++ guys complain if these languages are intermixed. Even there it is possible to write a program which is valid in both of them. Nevertheless, they are two different languages.

Re: Python's super() considered super!

2011-05-27 Thread Thomas Rachel
l, not Python. ACK. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: scope of function parameters (take two)

2011-05-30 Thread Thomas Rachel
ly it would have been possible to do otherwise, but then it would be a different language. Objects can be mutable, period. In MATLAB, e.g., you have what you desire here: you always have to pass your object around and get another ne back, even if you just add or remove a field of a struct or change the value of a field. HTH, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Something is rotten in Denmark...

2011-05-31 Thread Thomas Rachel
)(i)) ... gs[0](0) 0 There is a simpler way: with >>>> fs = [] >>>> for i in range(4): > ...fs.append(lambda n, i=i: i + n) > ... you give each lambda a different default argument. >>>> fs[0](0) > 0 Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Installation issue with Python 3.6.2.

2017-09-05 Thread Thomas Jollans
the screen grab it proceeds and simply hangs > > at " pre version"?? > > I will appreciate any help. > > Than you, > > Venkat > > > > Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10 > > -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: execfile and import not working

2017-09-06 Thread Thomas Jollans
f you start "python" from the terminal, rather than using IDLE? If not, is there an error message? - If python (in the terminal) hangs, and you press Ctrl+C, what happens? - If you start idle from the terminal and do what you've been doing so far, are there any error messages? -

Re: Run python module from console

2017-09-06 Thread Thomas Jollans
e can help you do this. https://docs.python.org/3/library/runpy.html However, as others have hinted, if you want to run bits of Python from Python, then it's probably better to use functions. -- Thomas -- https://mail.python.org/mailman/listinfo/python-list

Re: non-standard glibc location

2017-09-07 Thread Thomas Jollans
link python not > with the system glibc but with my custom glibc? > > Cheers, > Daniel > > > -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: remove path forever

2017-09-07 Thread Thomas Jollans
d never do. > > Yes, my PYTHONPATH looks like: > C:\Users\me\AppData\Local\Programs\Python\Python36-32 > C:\Users\me\AppData\Local\Programs\Python\Python36-32\DLLs > C:\Users\me\AppData\Local\Programs\Python\Python36-32\Lib > > Should I remove them? I suppose installer did s

Re: class inheritance when not defined

2017-09-08 Thread Thomas Jollans
you've redefined "object", these are the same. Python 2 had, for historical reasons, a distinction between "old-style" and "new-style" classes. It normally doesn't matter much, but explicitly inheriting from object makes a class new-style. -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: Delay a computation in another thread

2017-09-08 Thread Thomas Jollans
huts down? > > Also, what happens if it tries to print after the interpreter shuts down? > Where > does output go? On Linux, I think it would go to the same virtual terminal as it did before, if that still exists. (Otherwise, to /dev/null). This is how processes that started out at

Re: Key Error: "city"

2017-09-09 Thread Thomas Jollans
, in this case, makes your code far more elegant: a formatted string literal <https://docs.python.org/3/reference/lexical_analysis.html#f-strings> alert = (f"Today's forecast for {city}: The temperature will range from {low_temperature} " f" to {high_temperature}{temperature_unit} Conditions will be {weather_conditions}") -- Thomas -- https://mail.python.org/mailman/listinfo/python-list

Re: People choosing Python 3

2017-09-11 Thread Thomas Jollans
g any time soon (certainly not before RHEL includes python3 by default. > > Regards, > > INADA Naoki > -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: array.array()'s memory shared with multiprocessing.Process()

2017-09-11 Thread Thomas Jollans
eries of memory-mapped files to pass the data without pickling, or, if your code is only going to run on Unix, something involving shared memory through multiprocessing.Array. -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: array.array()'s memory shared with multiprocessing.Process()

2017-09-12 Thread Thomas Jollans
On 12/09/17 10:21, gerlando.fala...@gmail.com wrote: > Il giorno lunedì 11 settembre 2017 12:19:27 UTC+2, Thomas Jollans ha scritto: >> On 2017-09-10 23:05, iurly wrote: >>> As far as I'm concerned, I'm probably better off using double buffers to >>> avoid

Re: Fw: Problems Installing Python36

2017-09-12 Thread Thomas Jollans
users who don't make as much effort to find a solution. I can't say I understand the ins and outs of installing things on Windows... is there anything that can be done? Best, Thomas > I have tried repeatedly to install various Python versions (32-bit or > 64-bit), but the sa

Re: Python dress

2017-09-13 Thread Thomas Jollans
all seeing them go into paroxysms of gender confusion when Prince >> Charles, >> Duke of Edinburgh, appears in public wearing a kilt. >> > You do know that Prince Charles is the Prince of Wales and that the Duke > of Edinburgh is his father, don't you? :-) Big differenc

Re: Python dress

2017-09-13 Thread Thomas Jollans
ld" at the machine in a menacing, regal voice. if it yields, it is Python 2.3 or newer. -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: "tkinter"

2017-09-13 Thread Thomas Jollans
On 2017-09-13 14:33, leam hall wrote: > On Wed, Sep 13, 2017 at 8:28 AM, Stefan Ram wrote: > >> I presume that "tkinter" is intended to be pronounced >> "logically": >> >> T K inter (tee kay inter /ti keI In t%/) >> >> . But it would be faster to pronounce it >> >> T kinter (tee kinter /ti

Re: the core values of the Python "platform"

2017-09-13 Thread Thomas Jollans
s > question of the community. What would you consider the top (<= 5) core > values? >>> import this > > Regards > > > Darin > > [1] http://www.nodesummit.com/videos/?the-video-node2017=45 > -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: "tkinter"

2017-09-13 Thread Thomas Jollans
On 2017-09-13 16:47, Rick Johnson wrote: > leam hall wrote: > {TEE-KAY-ENTER} enter? not inter? -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-18 Thread Thomas Jollans
s_, and that's what really matters > here, a print function is always three more keystrokes than > a print statement. Or perhaps, in analogy to playing a guitar, a keystroke can involve multiple (partially or practically simultaneous) keypresses. In which case, no. -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-20 Thread Thomas Jollans
t;>> print 1 File "", line 1 print 1 ^ SyntaxError: Missing parentheses in call to 'print' >>> exec 'print 1' File "", line 1 exec 'print 1' ^ SyntaxError: Missing parentheses in call to 'exec'

Re: Old Man Yells At Cloud

2017-09-20 Thread Thomas Jollans
g in the US. There you are, adding up the prices on the products you pick up, figuring out (approximately) how much you'll owe, you go to pay, and the next thing you know there's some unspecified (!) markup added to the price. D'Arcy, I'm with the cashier. You're clearly

Re: Fwd: Issues with python commands in windows powershell

2017-09-21 Thread Thomas Jollans
; + FullyQualifiedErrorId : CommandNotFoundException >> >> >> I'm very new so honestly have no idea what the issue may be, but from >> previously trying to use python I think it may have something to do with >> configuring windows environment variables? Not sure, but just something >> I've ran into in the past previous times trying to learn python for more >> data analysis purposes. >> >> Any help would be greatly appreciated! >> >> Thanks a lot, >> >> Joey Steward >> > > -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: errors with json.loads

2017-09-21 Thread Thomas Jollans
)? It looks to me like the root cause of the problem was that they copied the code from a web page, and the web page contained invalid JSON. -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: Even Older Man Yells at Whippersnappers

2017-09-21 Thread Thomas Jollans
On 2017-09-19 20:21, Stefan Ram wrote: > I do not use UTF-8 > Why on earth not?! -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: Easy way to get a list of tuples.

2017-09-21 Thread Thomas Jollans
ion. py> a_list = [] py> a_list += 1,2,3 py> a_list [1, 2, 3] py> a_list.append(4) py> a_list [1, 2, 3, 4] py> a_list += 4 Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not iterable py> a_list.append((5,6,7)) py> a_list [1, 2, 3, 4, (5, 6, 7)] py> -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: Easy way to get a list of tuples.

2017-09-21 Thread Thomas Jollans
On 2017-09-21 12:38, Sayth Renshaw wrote: > Thanks Thomas yes you are right with append. I have tried it but just can't > get it yet as append takes only 1 argument and I wish to give it 3. > > I am really having trouble creating the groups of 3, since I am getting one > c

Re: How to ingore "AttributeError: exception

2017-09-22 Thread Thomas Jollans
with pass be good or are there easier ways ) , > > > try: > Z_block = block.data.data.di_data.data[0][0]except AttributeError as e: > > pass try: return self.some.attribute.or.another except AttributeError: return DEFAULT_VALUE is a perfectly good patte

Re: Assertions

2017-09-22 Thread Thomas Jollans
> nan > 0 False >>> nan == 0 False >>> not(nan > 0) True >>> cmp(nan, 0) -1 >>> cmp(0, nan) 1 Of course I see why the behavior of NaN is hard to swallow: in a sense the logical thing to do would be to raise a ValueError (or TypeError) when comparing to NaN - seeing as the operation doesn't make much sense in the first place - but it's better to not have an edge case where comparing two floats can raise, but only under very unusual circumstances. Cheers, Thomas -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: xml: TypeError: write() got an unexpected keyword argument 'short_empty_elements'

2017-09-22 Thread Thomas Jollans
Maybe this would be considered a bug by lxml. Maybe it won't. http://lxml.de/ links to a bug tracker and a mailing list. -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: Assertions

2017-09-22 Thread Thomas Jollans
> > NAN != x > > return True. Just to make the implication explicit: >>> from math import nan >>> nan is nan True >>> nan == nan False >>> nan != nan True >>> -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: Calling methods without objects?

2017-09-25 Thread Thomas Jollans
On 26/09/17 00:49, Stefan Ram wrote: > |>>> from random import randint > | > |>>> randint > |> > | > |>>> randint.__self__ > | > | > |>>> randint( 2, 3 ) > |2 > > It seems I am calling the method »randint« of the object at > »0x389798«, but I do not have to write the object into the > call!?

Re: TypeError with map with no len()

2017-09-25 Thread Thomas Jollans
On 25/09/17 18:44, john polo wrote: > Python List, > > I am trying to make practice data for plotting purposes. I am using > Python 3.6. The instructions I have are > > import matplotlib.pyplot as plt > import math > import numpy as np > t = np.arange(0, 2.5, 0.1) > y1 = map(math.sin, math.pi*t) I

Re: Calling methods without objects?

2017-09-25 Thread Thomas Jollans
On 26/09/17 01:04, Thomas Jollans wrote: > > In [1]: class C: > >...: def m(self): > >...: return True I'll have to give my MUA a stern talking to about the importance of whitespace. Anyway, you know what I mean. > >...: -- https://mail.python.org/mailman/listinfo/python-list

Re: PyQt: Parenting a Widget

2017-09-26 Thread Thomas Jollans
ade soon. The differences between PyQt4 and PyQt5 aren't massive, but they've moved around some classes (QtGui has been split into two packages, which is going to be annoying to migrate) and support for old-style signal and slot syntax has been dropped (good riddance). Also, if you're using Python 2: don't. Just don't. It's not 2012 any more. (I don't know what you're using, but /usr/bin/python is normally Python 2) > > so the button is the central widget. To use the Label, I think I would have > to create a composite widget which is too complicated for me, currently. > > Now. it works so I tested some more and added: > def popup_dialog(self): > x = Dialog(self) > y = Dialog(self) > y.show() > if x.exec_(): > print(x.spn.value()) > AND > > class Dialog(QDialog): > self.connect(self.cncl_btn, SIGNAL('clicked()'), self.close) > > So my dialog pops up and because exec_ is being called on 'x', I have to > first close that widget before I can interact with my button and 'y'. > However, let's say I close the 'x' dialog - then I can click on 'Button' and > I get two more dialogs which don't lock anything - why?? > -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie problem with urllib.request.urlopen

2017-09-26 Thread Thomas Jollans
x27;') > as conn: > print(conn) You may have messed up some quotes there. > --- > Thanks, > Bernie. > -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: PyQt: Parenting a Widget

2017-09-26 Thread Thomas Jollans
On 2017-09-26 16:41, Veek M wrote: > Thanks - i'm on debian stretch so python 2.7 is what I use. https://packages.debian.org/stretch/python3 https://packages.debian.org/stretch/python3-pyqt4 https://packages.debian.org/stretch/python3-pyqt5 -- https://mail.python.org/mailman/listinfo/python-li

Re: auto installing dependencies with pip to run a python zip application ?

2017-09-26 Thread Thomas Jollans
On 26/09/17 20:47, Irmen de Jong wrote: > Hi, > I've been using Python's executable zip application feature to neatly > package my little game into a single "executable" file. > Here "executable" means the user can simply start it by doubleclicking > it, or launching it from a shell prompt. Of cour

Re: Boolean Expressions

2017-09-26 Thread Thomas Jollans
On 27/09/17 00:23, Cai Gengyang wrote: > I'm trying to understand the logic behind AND. I looked up Python logic tables > > False and False gives False > False and True gives False > True and False gives False > True and True gives True. > > So does that mean that the way 'and' works in Python is t

Re: Spacing conventions

2017-09-27 Thread Thomas Jollans
my preferred tool, the Anaconda plugin for Sublime Text, sometime gets PEP 8 operator spacing wrong, and complains operators without spaces even where PEP8 explicitly recommends not using spaces. Read PEP 8, follow it if possible, but use your best judgement. Readability is important, blindly

Re: Parentheses (as after "print")

2017-09-27 Thread Thomas Jollans
"", line 1 import (os, sys) ^ SyntaxError: invalid syntax >>> from os import (listdir, chdir) >>> listdir, chdir (, ) >>> Of course the reasons the second syntax was eventually added to the language don't apply in the first case, but this does look a bit inconsistent... -- Thomas -- https://mail.python.org/mailman/listinfo/python-list

Re: Printing a Chunk Of Words

2017-09-27 Thread Thomas Jollans
On 2017-09-27 13:51, Matt Wheeler wrote: > With deepest apologies to all involved... > > On Tue, 26 Sep 2017 at 08:42 Gregory Ewing > wrote: > >> Ben Bacarisse wrote: >>> Think functional! This is 257 characters: >> >> 250 chars, 17 shorter than the text it produces: >> >> a=[];o=[];n=[];A=list

Re: Printing a Chunk Of Words

2017-09-27 Thread Thomas Jollans
On 2017-09-27 16:38, Matt Wheeler wrote: > On Wed, 27 Sep 2017 at 13:58 Thomas Jollans wrote: > >>> Reproducing the original string exactly the best I've managed is 260: >>> >>> t,f,a,o,n='True','False','and','or',

Re: Textwrap doesn't honour NO-BREAK SPACE

2017-09-29 Thread Thomas Jollans
On 2017-09-29 08:58, Frank Millman wrote: > > It confirms that the problem was there in 3.5, but is fixed in 3.6. > Same on Linux: 3.5 has the bug, 3.6 doesn't. (Python 3.5 from Red Hat, 3.6 from Anaconda) -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: Drain specialist Was: Beginners and experts

2017-09-29 Thread Thomas Jollans
ber to clear a drain would be > kinda like hiring a whiz-bang C programmer to configure your > email server--it isn't that he or she *can't* do it... > You mean like Tuppy Glossop's Plumbo-Jumbo, I assume? https://www.flickr.com/photos/leff/7746149 -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: Line terminators in Python?

2017-09-29 Thread Thomas Jollans
ndows. For binary I/O, it doesn't. (This means that it's important to specify text or binary mode in your calls to open() if you want your code to be portable). \r\n is not translated to \n on Unix. So, if you want your code to do the right thing, use \n. -- Thomas -- https://mail.python.org/mailman/listinfo/python-list

Re: Redirecting stdio streams with a context manager

2017-09-29 Thread Thomas Jollans
On 29/09/17 19:06, Steve D'Aprano wrote: > In the standard library's contextlib.py module, there is a class for > redirecting > standard I/O streams, and two public functions. The code is short enough to > reproduce here: > > # From Python 3.5 > > class _RedirectStream: > _stream = None >

Re: The mysterious ways of Python mailing list

2017-09-30 Thread Thomas Jollans
cases, it looks like the delay is always before the message is received (i.e., accepted) by mail.python.org. This looks like greylisting. I have no idea why messages "from" regular list users coming through large, reputable ISPs would be regularly greylisted, but I suppose what will b

Re: newb question about @property

2017-10-01 Thread Thomas Jollans
On 01/10/17 03:52, Stefan Ram wrote: > MRAB writes: >> raise ValueError("Temperature below -273 is not possible") > -273.15 > Either way, that depends. https://en.wikipedia.org/wiki/Negative_temperature#Examples -- https://mail.python.org/mailman/listinfo/python-list

Re: Escape-Sequenzen in einem String identifizieren

2017-10-01 Thread Thomas Jollans
27;" >>> print(s) two lines >>> print(repr(s)) 'two\nlines' >>> > Hat jemand eine Idee? Im Prinzip würde ich in so einem Fall eifach empfehlen, alle Zeilenumbrüche, egal wie sie aussehen, pauschal zu ersetzen: s.replace('\r\n', '\n') -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: newb question about @property

2017-10-02 Thread Thomas Jollans
at endpoints > they handle, for instance. The point is that there are plenty of useful decorators that have nothing to do with dunder methods. -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-03 Thread Thomas Jollans
On 03/10/17 20:05, Dennis Lee Bieber wrote: > > while True: > x = input("Enter a number (blank to exit) => ") > if x: > try: > ix = int(x) > print("Square = %s" % (ix * ix) ) #why invoke > exponential > except chec

<    1   2   3   4   5   6   7   8   9   10   >