Re: When convert two sets with the same elements to lists, are the lists always going to be the same?

2012-05-04 Thread Cameron Simpson
set(['c', 'b', 'a']) The language does not say these will get the same iteration order. It happens that the Python you're using, today, does that. You can't learn the language specification from watching behaviour; you learn the guarrenteed behaviour

Re: Problem with time.time() standing still

2012-05-05 Thread Cameron Simpson
em I'd be running the process under strace (or dtrace or ktrace depending on flavour) to see what actual OS system calls are being made during this behaviour. Is this feasible for you? Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ A slipping sear could let your M203 gre

Re: Problem with time.time() standing still

2012-05-06 Thread Cameron Simpson
On 06May2012 09:18, Bob Cowdery wrote: | On 05/05/2012 23:05, Cameron Simpson wrote: | > On 05May2012 20:33, Bob Cowdery wrote: | > | [...] calls to time.time() always return the same | > | time which is usually several seconds in the past or future and always | > | has no fra

Re: sorting 1172026 entries

2012-05-06 Thread Cameron Simpson
emp.append((parser.parse(line[0]), float(line[1]))) print "after read loop", time() and so on. AT least then you will have more feel for what part of your code is taking so long. Ceers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ The shortest path between any

Re: sorting 1172026 entries

2012-05-06 Thread Cameron Simpson
On 06May2012 17:10, Chris Rebert wrote: | On Sun, May 6, 2012 at 4:54 PM, Cameron Simpson wrote: | > On 06May2012 18:36, J. Mwebaze wrote: | > | > for filename in txtfiles: | > | >    temp=[] | > | >    f=open(filename) | > | >    for line in f.readlines(): | &

Re: new to Python - modules to leverage Perl scripts?

2012-05-07 Thread Cameron Simpson
| > 3) Run the Perl commands in parallel (to take less time) | | multiprocessing? Though your problem may be I/O-bound. If he stuffs the inputs into TemporaryFiles he can attach them to subprocess.Popen() stdin and just not wait. Dispatch them all and collect afterwards. Only tempfile and subprocess needed; no ne

Re: sorting 1172026 entries

2012-05-07 Thread Cameron Simpson
On 07May2012 11:02, Chris Angelico wrote: | On Mon, May 7, 2012 at 10:31 AM, Cameron Simpson wrote: | > I didn't mean per .append() call (which I'd expect to be O(n) for large | > n), I meant overall for the completed list. | > | > Don't the realloc()s make it O(n^

Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-09 Thread Cameron Simpson
nts... intellectual property goes by other rules I think. Patents _are_ IP. You may mean "copyright", also IP. Copyright goes to the author, except that most companies require employees to assign it to the company, including the Berne Convention "moral rights" (such as attribution).

Re: Mailing list assistance: manual unsubscribing of failed recipient?

2012-05-09 Thread Cameron Simpson
he message. [...] | I've already forwarded a bounce to ab...@azet.sk but have heard | nothing back. This isn't the list's fault, but maybe the listowner can | deal with the spam coming back. Try "postmaster". I'm not sure "abuse" is so widely implemented. -- Cameron S

Re: Dealing with the __str__ method in classes with lots of attributes

2012-05-10 Thread Cameron Simpson
no_save=no_save, maildb_path=os.environ['MAILDB'], maildir_cache={}) This removes a lot of guff from some common procedures. Hope this helps, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ There's a fine line between pathos and pathetic. - David Stivers s...@stat.rice.edu DoD #857 -- http://mail.python.org/mailman/listinfo/python-list

Re: Dealing with the __str__ method in classes with lots of attributes

2012-05-11 Thread Cameron Simpson
tion stuff.) My "O" class (back in the thread) deliberately shows only the [a-z]* attributes so the user gets the public object state without the noise of private attributes. For __repr__ I might print everything. Haven't gone that far yet. Cheers, -- Cameron Simpson DoD#743 h

Re: bash/shell to python

2012-05-20 Thread Cameron Simpson
badopts=1 ;; *)break ;; esac shift done # ... parse non-option arguments ... [ $badopts ] && { echo "$usage" >&2; exit 2; } # ... rest of program ... There's nothing hard there. Cheers, -- Cameron Simpson DoD#743 http:/

Re: Wish: Allow all log Handlers to accept the level argument

2012-05-24 Thread Cameron Simpson
wanted to add and remove handlers a lot I might well expect (or at least imagine) it to be a set. So I too find: root.handlers[-1] a risky thing to say, and harder to read because it assumes something I would not want to rely on. Versus the original proposal that avoids all need to know how log

Re: Email Id Verification

2012-05-24 Thread Cameron Simpson
I hope someone's validated that regexp before using it to validate email addresses:-) I'm amazed. (And amazed that the sheer code smell doesn't drive the author away from suggesting it.) The mere presence of nesting comments in RFC2822 addresses prevents using a single regexp to parse them

Re: Email Id Verification

2012-05-24 Thread Cameron Simpson
cluding nesting comments. Regexps don't do recursion. | Can anyone tell me how to use this and what is the meaning of | this | \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* If you don't understand it, DON'T use it. And in any case, it is simplistic (== wrong). As pointed out by

Re: Email Id Verification

2012-05-25 Thread Cameron Simpson
you refuse to accept the e-mail address at | which the reeive e-mail all day every day. And it will get better. If the validation code is sufficiently widespread, the user may be unable to complain or report the issue. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Don't have

Re: getting started

2012-05-25 Thread Cameron Simpson
ey: I spent a brief while confused that this doesn't work: o = object() o.x = 1 and that I needed to do this: class O(object): pass o = O() o.x = 1 until I realised that plain "object", the root of all classes, doesn't accept arbitrary attributes. But subclasse

Re: mode for file created by open

2012-06-08 Thread Cameron Simpson
trictive mode to os.open and open it up with fchmod. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ It was a joke, OK? If we thought it would actually be used, we wouldn't have written it! - Marc Andreessen on the creation of a tag -- http://mail.python.org/mailman/listinfo/python-list

Re: mode for file created by open

2012-06-09 Thread Cameron Simpson
On 09Jun2012 07:42, Neal Becker wrote: | Cameron Simpson wrote: | Doesn't anyone else think it would be a good addition to open to specify a file | creation mode? Like posix open? Avoid all these nasty workarounds? -1 open() is cross platform. os.open() is platform specific, generally

Re: mode for file created by open

2012-06-09 Thread Cameron Simpson
On 09Jun2012 18:25, Neal Becker wrote: | I haven't seen the current code - I'd guess it just uses posix open. | So I would guess it wouldn't be difficult to add the creation mode argument. | How about call it cr_mode? What shall it contain on Windows? What shall it contain on Jyth

Re: mode for file created by open

2012-06-09 Thread Cameron Simpson
ectly, or raise a ValueError if it is supplied and not whatever means "default open". A huge -1000 for arguments that have meaning but are ignored. This is why I'm -1 to start with: a file permission bitmap is a posix.open() value. It does not map portably to the genera

Re: Threads vs subprocesses

2012-06-17 Thread Cameron Simpson
priority queue where the lowest time is the next | > to be retrieved. | | You're right, of course. Thought I'd point out that a heapq works nicely for this, or it has for me in this scenario , anyway. -- Cameron Simpson -- http://mail.python.org/mailman/listinfo/python-list

Re: lazy evaluation of a variable

2012-06-17 Thread Cameron Simpson
lated news, can one make "properties" for modules? I was wondering about this a month or so ago. -- Cameron Simpson If your new theorem can be stated with great simplicity, then there will exist a pathological exception.- Adrian Mathesis -- http://mail.python.org/mailman/listinfo/python-list

Python-URL! - weekly Python news and links (Jun 7)

2011-06-07 Thread Cameron Laird
[Drafted by Gabriel Genellina.] QOTW: "'Reminds me of the catch-phrase from the first Pirates of the Caribbean movie: 'It's more of a guideline than a rule.'" - Tim Roberts, 2011-05-27, on the "mutator-methods-return-None" Announcing two maintenance releases (including security fixes): 2.5.

Re: The pythonic way equal to "whoami"

2011-06-08 Thread Cameron Simpson
no, wrong suggestion. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Dangerous stuff, science. Lots of us not fit for it. - H.C. Bailey, _The Long Dinner_ -- http://mail.python.org/mailman/listinfo/python-list

Python-URL! - weekly Python news and links (Jun 14)

2011-06-14 Thread Cameron Laird
[Originally drafted by Gabriel Genellina.] QOTW: "Well, it's incompatible with the Python compiler I keep in my head. Have these developers no consideration for backward-thinking- compatibility?" (Ben Finney, 2011-06-10, on certain old but not-so-obvious change) Python versions 2.7.2 and 3

Re: break in a module

2011-06-14 Thread Cameron Simpson
d rather | not use either one. The more levels of indentation in a module, the | harder it is to follow. And exceptions really should not be involved | in execution flow control, but in the handling of abnormal situations | instead. | | Considering that other complex statements have special flo

Re: break in a module

2011-06-17 Thread Cameron Simpson
lines of generators' "raise StopIteration". Then the import machinery can catch it, no new keyword is needed and no existing keyword needs feature creeping. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ And it is not our part here to take th

Re: break in a module

2011-06-21 Thread Cameron Simpson
On 18Jun2011 03:50, Steven D'Aprano wrote: | On Sat, 18 Jun 2011 12:36:42 +1000, Cameron Simpson wrote: | > Just to throw another approach into the mix (because I was thinking | > about the "finally" word), what about: | > | > raise StopImport | > | > alon

Re: break in a module

2011-06-21 Thread Cameron Simpson
On 21Jun2011 20:04, I wrote: | So the caller does an: | | import foo | | as normal, with no special wrapping. And the module goes: | | spam() | if condition: | raise StopIteration | ham() | cheese() Of course, that should be StopImport, not StopIteration. Cheers, -- Cameron

Re: Looking PDF module

2011-06-24 Thread Cameron Laird
On Jun 24, 6:45 am, "neil.suffi...@gmail.com" wrote: > You might also want to have a look at Pisa (http://www.xhtml2pdf.com/ > ) . It's based on reportlab but might suit you better. There's more to the story. As with many things, the answer is, "it depends". In this case, there are so many varia

Re: How can I make a program automatically run once per day?

2011-07-09 Thread Cameron Simpson
course) that I can make | >it automatically run at a set time each night? | | Use your operating system's facilities to run timed jobs. | | Unix/Linux: Cron jobs | Windows: Scheduled Tasks | Mac: don't know, but probably Cron too Yep. Macs are UNIX, BSD derived. -- Ca

Re: Code hosting services

2011-07-13 Thread Cameron Simpson
n you guys recommend? | | BTW, I'll likely be sticking with Mercurial for revision control. | TortoiseHg is a wonderful tool set and I managed to get MercurialEclipse | working well. I'm using bitbucket and liking it. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/c

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Cameron Simpson
blishing the sentinal's name to your callers i.e. may they really return _MISSING legitimately from their functions? Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ What's fair got to do with it? It's going to happen.- Lawrence of Arabia -- http://mail.python.org/mailman/listinfo/python-list

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Cameron Simpson
On 15Jul2011 20:17, Steven D'Aprano wrote: | Cameron Simpson wrote: | > I suppose there's no scope for having the append-to-the-list step sanity | > check for the sentinel (be it None or otherwise)? | | It is not my responsibility to validate data during construction, only t

Re: Looking for general advice on complex program

2011-07-15 Thread Cameron Simpson
annoying, and problematic if you're using multiple threads), _and_ you can put meta info inside it, like pid files etc. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ I had a wierd dream with Ken Thompson in it once. - George Politis -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for general advice on complex program

2011-07-16 Thread Cameron Simpson
l overwrite | that memory. I'm afraid of taking up lots of space that I don't need | with this program. Don't be. | The docs indicate that Unix recovers the memory, but I'm not sure about Windows. I confess to disliking Windows, but I do not believe it is that broke

Re: Looking for general advice on complex program

2011-07-16 Thread Cameron Simpson
n the same file for write more than once (hence the umask 0777 thing, to prevent that); secondly you can put stuff in it though that makes removing the directory more work when you're done with it. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ THE LOST WORLD is based

Re: Possible File iteration bug

2011-07-16 Thread Cameron Simpson
kay, we've come up with the solution of a new exception, PauseIteration, | that the iterator protocol will recognise. One might suggest that Billy could wrp his generator in a Queue(1) and use the .empty() test, and/or raise his own PauseIteration from the wrapper. -- Cameron Simpson DoD#743

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-16 Thread Cameron Simpson
know it is, being so myself. You haven't yet reached that happy state. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Will you come quietly, or shall I use earplugs? -- http://mail.python.org/mailman/listinfo/python-list

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-16 Thread Cameron Simpson
On 16Jul2011 19:29, Andrew Berg wrote: | Of everything I've read on tabs vs. spaces, this is what makes the most | sense to me: | http://www.iovene.com/61/ Makes sense to me. Thanks for the URL. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Every particle continu

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-16 Thread Cameron Simpson
On 17Jul2011 13:09, Steven D'Aprano wrote: | Cameron Simpson wrote: | > On 16Jul2011 09:51, rantingrick trolled: | > | Evidence: Tabs ARE superior! | > | -- | > | I have begun to believe that tabs are far more superior to space

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Cameron Simpson
11. Spreadsheets have | been around for a LONG time. Stop living the past. The past was better. Always was and will be increasingly so in the future. Stop fighting the tide! -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Pardon my driving, I'm trying to reload. -- http://mail.python.org/mailman/listinfo/python-list

Re: Crazy what-if idea for function/method calling syntax

2011-07-17 Thread Cameron Simpson
bah(y) Adding your syntax causes silent breakage later instead of immediate syntax error now. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ hybrid rather than pure; compromising rather than clean; distorted rather than straightforward; ambiguous rather than articulated;

Re: I am fed up with Python GUI toolkits...

2011-07-20 Thread Cameron Simpson
ions: mandating behaviour is a little pointless - it can't be enforced, few directives are unambiguously one sidedly good and so mandating stuff is divisive and will drive people away. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ It's quite difficult to remind people

Re: I am fed up with Python GUI toolkits...

2011-07-23 Thread Cameron Simpson
ge, in not small part because CSS lacks a "not" - you can't say "style everything except blah", which means you have to enumerate a bazillion combinations and you're still playing guessing games. So, yes, the every author's look'n'feel is gratuitousl

Re: PyWart: PEP8: A cauldron of inconsistencies.

2011-07-27 Thread Cameron Simpson
#x27;ll all fall behind. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ I think... Therefore I ride. I ride... Therefore I am. - Mark Pope -- http://mail.python.org/mailman/listinfo/python-list

Python-URL! - weekly Python news and links (Aug 10)

2011-08-10 Thread Cameron Laird
QOTW: "If an elegant solution doesn't occur to me right away, then I first compose the most obvious solution I can think of. Finally, I refactor it until elegance is either achieved or imagined." - Neil Cerutti, 2011-07-28 What is the real purpose of __all__? http://old.nabble.com/__all

Python-URL! - weekly Python news and links (Aug 10)

2011-08-10 Thread Cameron Laird
QOTW: "If an elegant solution doesn't occur to me right away, then I first compose the most obvious solution I can think of. Finally, I refactor it until elegance is either achieved or imagined." - Neil Cerutti, 2011-07-28 What is the real purpose of __all__? http://old.nabble.com/__all

Re: Reusable ways to wrapping thread locking techniques

2011-08-15 Thread Cameron Simpson
nup code. It's worth it just to make everything more readable. The fact that it makes the code smaller and easier to maintain and less bug prone is just sugar. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ My mind is like a blotter: Soaks it up, gets it

Re: Order of addresses returned by socket.gethostbyname_ex()

2011-08-22 Thread Cameron Simpson
terfaces were initialised. So getting the LAN first may merely be fortuitous. I wouldn't rely on it, especially if interfaces come and go. What if you queried your routing table instead? Usually there's just one default route, and hopefully it would be configured to use the "best&

Re: Order of addresses returned by socket.gethostbyname_ex()

2011-08-22 Thread Cameron Simpson
On 22Aug2011 04:29, Tomas Lid�n wrote: | On 22 Aug, 12:06, Cameron Simpson wrote: | > It would not surprise me if the order was related to the order a scan of | > the system interfaces yields information, and I would imagine that may | > be influenced by the order in which the interf

Python-URL! - weekly Python news and links (Aug 25)

2011-08-25 Thread Cameron Laird
[Original draft by Gabriel Genellina.] QOTW: "Python is a programming language, not an ice cream shop." - Steven D'Aprano, 2011-08-10, on providing the language with just "more choices" Comparing the relative speed of `i += 1` and `i = i + 1` http://groups.google.com/group/comp.lang.

Re: about if __name == '__main__':

2011-08-28 Thread Cameron Simpson
he top level command line program logic is at the top of the file where it is easy to find, not buried in the middle or at the bottom. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Anarchy is not lack of order. Anarchy is lack of ORDERS. -- http://mail.python.org/mailman/listinfo/python-list

Re: Threads in Python

2011-09-01 Thread Cameron Simpson
form. Some use a mix of heavyweight (threads with distinct pids) and lightweight threads. | But, in Python, only one thread actually ever executes actual Python | code at any given time. In CPython this is true. Other implementations like Jython can use other threading models; I'd expect

Re: idiomatic analogue of Perl's: while (<>) { ... }

2011-09-01 Thread Cameron Simpson
uffered regardless). So Steven saw stuff flushed on newlines and you would see stuff flushed when you explicitly flush or when the buffer fills (probably doesn't happen for your use because you need a response, and never write enough to fill the buffer). Cheers, -- Cameron Simpson DoD#74

Re: Best way to check that you are at the beginning (the end) of an iterable?

2011-09-07 Thread Cameron Simpson
raise IndexError, "%s: got more than one element (%s, %s, ...)" \ % (icontext, it, elem) if first: raise IndexError, "%s: got no elements" % icontext return it Which I use as a definite article in places where

Re: Best way to check that you are at the beginning (the end) of an iterable?

2011-09-07 Thread Cameron Simpson
n just use a boolean if you like. I have plent of loops like: first = true for i in iterable: if first: blah ... ... first = False Cheap and easy. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Bye and bye, God caught his eye, - Epitaph for a waiter by

Python-URL! - weekly Python news and links (Mar 23)

2011-03-23 Thread Cameron Laird
QOTW: "So far as I know, that actually just means that the test suite is insufficient." - Peter Seebach, when an application passes all its tests http://groups.google.com/group/comp.lang.lisp/msg/29aff9595bb0eac0 Administrative note: it's been a while--since the end of October 2010, in fact;

Python-URL! - weekly Python news and links (Apr 2)

2011-04-02 Thread Cameron Laird
QOTW: "Let us cease to nourish those fabled ones who dwell under bridges." - Tom Zych http://groups.google.com/group/comp.lang.python/msg/c1052c962becfc26 Look for "Python Insider" below. Then read through everything there. You'll want to know about this one. Once again, the PSF sp

Python-URL! - weekly Python news and links (Apr 9)

2011-04-09 Thread Cameron Laird
QOTW: [You'll have to see it for yourself: !Viva 2.7.1!] http://groups.google.com/group/comp.lang.python/msg/8d79c5ee3913f82d "De-briefing" is characteristically something we do too little; there's a LOT of value in systematic examination of what we've experienced. Unladen Swallow pre

Re: Python IDE/text-editor

2011-04-17 Thread Cameron Simpson
rom my preferred editor and some terminals (and, under X11, a good window manager - I like FVWM). That way one can pick the pieces one likes and use them together. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ The more I ride the more I notice and the more fearful I beco

Python-URL! - weekly Python news and links (Apr 21)

2011-04-21 Thread Cameron Laird
QOTW: "Python is a pragmatic language, so all the rules come pre- broken." - Mel http://groups.google.com/group/comp.lang.python/msg/208face4a8e00062 Look! In the sky! It's a SciPy demonstration! It's a business! No, it's ForecastWatch: http://goo.gl/AvzqZ EuroPython 201

Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread Cameron Simpson
t 'bc' also has arbitrary precision floating | point math and a standard math library. Floating point math? I thought, historically at least, that bc is built on dc (arbitrary precision integer math, reverse polish syntax) and that consequently bc uses fixed point math rather than f

Python-URL! - weekly Python news and links (May 10)

2011-05-10 Thread Cameron Laird
[This content provided by Gabriel Genellina, despite what the "From:" line says.] QOTW: "Often, the cleverness of people is inversely proportional to the amount of CPU power and RAM that they have in their computer. Unfortunately, the difficulty in debugging and maintaining code is often directl

Python-URL! - weekly Python news and links (May 18)

2011-05-18 Thread Cameron Laird
QOTW: "When did we come to the idea that people should be able to program in a language without actually learning it? The fact that Python comes so close to that possibility is nothing short of revolutionary. I suppose one day a reasoning android will be able to sit down at the terminal of a sta

Re: Overuse of try/except/else?

2011-05-20 Thread Cameron Simpson
function and catches the return value or raised exception. Anyone who calls the returned callable later gets the return value or the exception reraised as appropriate, so one can avoid the dangerous "catch everything and log" scenario. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.e

Python-URL! - weekly Python news and links (May 26)

2011-05-26 Thread Cameron Laird
[This edition drafted by Gabriel Genellina.] QOTW: "They did a study once to determine the best tool for development. Turns out that the most productive tool was generally the one that the user believed was the most productive. In hindsight I think that that was rather obvious." - D'Arcy J.M. C

Re: Permissions issues with zipfile

2017-09-04 Thread Cameron Simpson
ing on the server and some local or something)? You're on Linux. Install strace and see what: strace python your-program.py shows you. Just in case the zip file's being opened with a funny mode or something. It is always good to be totally sure of exactly what system call is failin

Re: How do I find what kind of exception is thrown.

2017-09-05 Thread Cameron Simpson
On 05Sep2017 19:44, Cameron Simpson wrote: Almost anything which says "Errno ..." is almost always an OSError (or an IOError as I found the other day). I try to be quite picky about these. So for example: Oh yes, and on a UNIX host such as Solaris the command "man 2 intro&

Re: How do I find what kind of exception is thrown.

2017-09-05 Thread Cameron Simpson
o be quite picky about these. So for example: try: fp = open(filename) except OSError as e: if e.errno == errno.ENOENT: # file missing ... act as if the file were empty ... else: # other badness - let the exception escape raise Cheers, Cameron Simpson (

Re: python console menu level looping

2017-09-24 Thread Cameron Simpson
. This has two advantages: It means you can turn it off anywhere and next time around the loop will stop, whereas doing things directly with continue or break requires "structural" control because they only jump out of the innermost loop, and also they act right now, preventing other relevant st

Re: Running a GUI program haults the calling program (linux)

2017-09-25 Thread Cameron Simpson
first fork() the process, then exec() the new app. There are a few steps to do this properly, so google for "python fork exec". No, subprocess does this stuff for you. I think the OP's missed some important stuff out. -- Cameron Simpson Baseball cards that suck in energy and run

Re: Running a GUI program haults the calling program (linux)

2017-09-26 Thread Cameron Simpson
for it to terminate. GUI programs are not special. Therefore, if your calling python program is blocking, it is blocking somewhere other that this line of code. Please show us where. Consider putting print() calls through your code to locate where your program stalls. Cheers, Cameron Simpson (

Re: Running a GUI program haults the calling program (linux)

2017-09-26 Thread Cameron Simpson
don't read them then the pipes can fill, stalling the app. Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: Boolean Expressions

2017-09-26 Thread Cameron Simpson
sion : True and True = True Correct. (In my head; haven't run the code.) E) Set bool_five equal to the result of True and True Entire Expression : True and True = True Correct. Cheers, Cameron Simpson ERROR 155 - You can't do that. - Data General S200 Fortran error code list -- https://mail.python.org/mailman/listinfo/python-list

Re: Boolean Expressions

2017-09-26 Thread Cameron Simpson
0 => zero/false If all this seems confusing I wonder about your understanding of the plain English words "and" and "or", but your English seems otherwise perfectly fine to me, so that would be very surprising. Can you write some plain English sentences where "and"

Re: Boolean Expressions

2017-09-26 Thread Cameron Simpson
On 26Sep2017 20:55, Cai Gengyang wrote: On Wednesday, September 27, 2017 at 6:45:00 AM UTC+8, Cameron Simpson wrote: On 26Sep2017 14:43, Cai Gengyang wrote: >C) Set bool_three equal to the result of >19 % 4 != 300 / 10 / 10 and False > 19 % 4 = 3 which is equal to 300 / 10 / 10 = 3,

Re: Distributing multiple packages with on setup.py

2017-09-30 Thread Cameron Simpson
The release script looks for the latest one. Note that this is all one code repo at my end; the script knows how to assemble just the relevant files for a particular module. Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: newb question about @property

2017-09-30 Thread Cameron Simpson
o a sanity check, they named the internal value very similarly. By using "_temperature" they (a) keep the name very similar and (b) make it clear that the internal value is "private", not intended for direct use by code outside the class. Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: Logging from files doesn't work

2017-10-11 Thread Cameron Simpson
n off it goes with a FileHandler for that path for the filing actions for that maildir. So you're not contrained to drop log files all through your source tree (ewww!) My opinion is that you should decide where your logfiles _should_ live; it generally has nothing (or little) to do with the module name. I keep mine, generally, in various subdirectories of "$HOME/var/log". Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: how to read in the newsreader

2017-10-16 Thread Cameron Simpson
a nice threaded way. Digests have many problems, some of which you're well aware of. I wish they weren't even an option. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: PEP 249 Compliant error handling

2017-10-18 Thread Cameron Simpson
such in order to improve error messages to the end user. Or perhaps more conveniently for the end user, possibly an option supplied at db connect time, though I'd entirely understand wanting a cursor option so that one can pick and choose in a fine grained fashion. Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: Sockets but calling from different programs

2017-10-25 Thread Cameron Simpson
assA import A from classB import B from classC import C conn = A(address, port) sender = B(conn, other-stuff...) receiver = C(conn, other-stuff...) B.speak("foo") and so forth. Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: from packaging import version as pack_version ImportError: No module named packaging

2017-10-27 Thread Cameron Simpson
ing python-setuptools but all of these did not fix this issue. You need to fetch the "packaging" module. That is what pip is for, eg: pip install --user packaging The --user is to install it in your "personal" python library space. Cheers, Cameron Simpson (formerly c...@zip.com.

Re: Problem with subprocess.Popen and EINTR

2017-10-28 Thread Cameron Simpson
On 29Oct2017 10:11, Cameron Simpson wrote: It may be a bug. Or it may be a system call which cannot be meaningfulling retried. But had you considered only activating the handler around the sleep? You still need to copy with SIGINT single I infer that you send this from outside the program

Re: Problem with subprocess.Popen and EINTR

2017-10-28 Thread Cameron Simpson
al at all, and therefore prevents the signal interrupting system calls. So you activate your dummy-quit-sleeping function only around the sleep itself. Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: from packaging import version as pack_version ImportError: No module named packaging

2017-10-30 Thread Cameron Simpson
reach for "sudo" by reflex. It _will_ get you into trouble one day, either by doing unintended damage to your stuff or by raising the ire of some sysadmin when you try it on some system that is their responsibility. Thank you, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: Vim, ctags jump to python standard library source

2017-10-30 Thread Cameron Simpson
tags-file -a -R /path/to/your/python/lib" not scan the python library? Haven't tried it myself, and the tags file would be HUGE... Hmm... [~]fleet*> ctags -o testtags -a -R /usr/lib/python2.7 [~]fleet*> L testtags -rw-rw-r-- 1 cameron cameron 7208525 31 Oct 10:19 t

Re: Looping on a list in json

2017-11-04 Thread Cameron Simpson
sic idea is to make a small data structure of your own (just the dictionary runner_lists in the example above) and fill it in with the infomation you care about in a convenient and useful shape. Then just return the data structure. The actual data structure will depend on what you need to do with this later. Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: [TSBOAPOOOWTDI]using names from modules

2017-11-04 Thread Cameron Simpson
's example: joinpath(dirname(...), ...) You can see I've given a distinctive name to "join", which would otherwise be pretty vague. Cheers, Cameron Simpson (formerly c...@zip.com.au)" -- https://mail.python.org/mailman/listinfo/python-list

Re: Looping on a list in json

2017-11-04 Thread Cameron Simpson
]["RacingFormGuide"]["Event"]["Runners"] That's the beauty of offering untested code: I don't have to find and fix my errors:-) Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: python3 byte decode

2017-11-04 Thread Cameron Simpson
t;s".decode() returns the string value "s", and Python is internally deciding to reuse the existing "s" from the left half of your comparison. It can do this because strings are immutable. (For example, "+=" on a string makes a new string). Hoping this is now more clear, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Mailing list moderators

2017-11-05 Thread Cameron Simpson
ython-list and subscribe, and see if things seem better than the newsgroup. Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

Re: Ideas about how software should behave

2017-11-08 Thread Cameron Simpson
tive. I'm not a big believer in "egoless programming" as my ego is bound up in my desire for quality, but a consequence of that is that criticism _is_ received personally, and therefore it should be as well phrased as feasible. Before signing out, let me hark to some words from the glorious film "Harvey": "I used to be smart. I recommend nice." Cheers, Cameron Simpson (formerly c...@zip.com.au) -- https://mail.python.org/mailman/listinfo/python-list

inspecting a callable for the arguments it accepts

2017-11-14 Thread Cameron Simpson
t at submittion time. Here's an example failure at runtime: pilfer.py: WorkerThreadPool:Later-1:WorkerThreadPool: worker thread: ran task: exception! (, TypeError('() takes 0 positional arguments but 1 was given',), ) Traceback (most recent call last): File "

Re: from xx import yy

2017-11-14 Thread Cameron Simpson
Usually I define a small class for this kind of thing and keep all the state in class instances. That way it can scale (keeping multiple "states" at once). However, it does depend on your particular situation. I find situations where I want to directly change "global" valu

Re: inspecting a callable for the arguments it accepts

2017-11-14 Thread Cameron Simpson
On 15Nov2017 09:12, Chris Angelico wrote: On Wed, Nov 15, 2017 at 8:05 AM, Cameron Simpson wrote: I know that this isn't generally solvable, but I'm wondering if it is partially solvable. I have a task manager which accepts callables, usually functions or generators, and calls th

Re: from xx import yy

2017-11-16 Thread Cameron Simpson
mod1 Making: mod2.mod1 --> mod1, mod1.x --> 1 Then: mod2.py: mod1.x = 2 Making: mod2.mod1 --> mod1, mod1.x --> 2 Because you're adjusting the reference "mod1.x", _not_ the distinct reference "mod2.x". Cheers, Cameron Simpson (formerly c...@zip.com.a

Re: "help( pi )"

2017-11-17 Thread Cameron Simpson
ngs to straight things. Roughly 3.' Now, I accept that the "CPython coaleases some values to shared singletons" thing is an issue, but the language doesn't require it, and one could change implementations such that applying a docstring to an object _removed_ it from the m

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