Re: Python 3 resuma a file download

2015-07-01 Thread Cameron Simpson
inary files, and we are not talking about _those_ chunks. Cheers, Cameron Simpson Life is uncertain. Eat dessert first. - Jim Blandy -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposed keyword to transfer control to another function

2015-07-17 Thread Cameron Simpson
on't need an extra keyword, so no programs will be broken because they used "transfer", "goto" or whatever other new keyword as an identifier. Oooh I like this. The parallel makes sense, and as you say, no new keyword. Yes, "return from" is my new preferred comm

on keeping things civil (was: Encoding of Python 2 string literals)

2015-07-23 Thread Cameron Simpson
which incite anger in me. I urge you to consider this approach. Venting, I remain, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Gmail eats Python

2015-07-26 Thread Cameron Simpson
o knows if it was caused by GMail. Hard to tell at this point. (*) However, it does look like something may have treated a plain text message as plain text in format=flowed form. Or perhaps some user agent has just gone rogue. Cheers, Cameron Simpson in rec.moto, jsh wrote: Dan Nitschke wrote: &g

Re: Gmail eats Python

2015-07-26 Thread Cameron Simpson
On 26Jul2015 09:02, Laura Creighton wrote: In a message of Sun, 26 Jul 2015 00:58:08 -, Grant Edwards writes: You use mutt or something else decent as your MUA. I do -- the problem is all the gmail users out there. Take heart - gmail used to do much worse than this:-) Cheers, Cameron

Re: sys path modification

2015-07-27 Thread Cameron Simpson
th is in place. Any time you pull from an exterior place, you need to be sure the exterior place doesn't have unexpected code - if someone untrusted can insert python code into the extra lib path then they may get it imported. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: AttributeError: LineLogic instance has no attribute 'probe'

2015-07-27 Thread Cameron Simpson
egal, but wrong. It will result in LineLogic having the default initialisation i.e. nothing, as the __init__ function is not part of the class. But yes, this would all be clearer had the OP posted the code instead of a tiny out of context snippet. Cheers, Cameron Simpson Motorcycling is ind

Re: What happens when python seeks a text file

2015-07-29 Thread Cameron Simpson
g needed then a seek() to any position obtained by tell() should be reliable. In short: line beginnings are not the only places where you can safely seek. Though they may be conveniently available. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Gmail eats Python

2015-07-29 Thread Cameron Simpson
gle octal digit). 16 registers - you forget the alternate register set. Since the UNIX V7 kernel code never made use of them we used to use them as a crude messaging system from user space, as what you put there sayed there, globally accessible by other users. Cheers, Cameron Simpson TeX: Whe

Re: Gmail eats Python

2015-07-29 Thread Cameron Simpson
ess. ^A, ^E, ^P and ^N are really quite critical. Laura (happy emacs user since 1979) Cheers, Cameron Simpson (happy vi user since 1985) English is a living language, but simple illiteracy is no basis for linguistic evolution. - Dwight MacDonald -- https://mail.python.org/mailman/listinfo/python-list

Re: My code won't work if I double click the saved file

2015-07-29 Thread Cameron Simpson
cutable. I do not use Windows, but I believe you can adjust these associations. However, the first question (to verify that this is the issue) is: if you deliberately invoke python2 and execute your code with it, does it behave the same way as when you currently double click on the file? Chee

Re: [Tutor] Mailbox

2015-07-30 Thread Cameron Simpson
quot;fname" confused in your code. Based on your code, "fname" is supposed to be the filename (a string) and "fn" is meant to be the open file object (a file), since you have this line: fn = open(fname) However, you set "fn" from raw_input when you sho

Re: How to re-write this bash script in Python?

2015-07-31 Thread Cameron Simpson
se probably true. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: How to re-write this bash script in Python?

2015-07-31 Thread Cameron Simpson
On 31Jul2015 18:26, Chris Angelico wrote: On Fri, Jul 31, 2015 at 6:15 PM, Cameron Simpson wrote: For example, bash lacks decent timezone support, so I can well believe random832's guess that your five-hour offset is a simulation of that; but Python can do much better work with timezone

Re: Most pythonic way of rotating a circular list to a canonical point

2015-08-01 Thread Cameron Simpson
len(list2). If that element equals elem0, _then_ compare the list at that point as you suggested. Is there an aspect of this which doesn't work? Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Most pythonic way of rotating a circular list to a canonical point

2015-08-01 Thread Cameron Simpson
On 01Aug2015 15:55, Lukas Barth wrote: On Sunday, August 2, 2015 at 12:32:25 AM UTC+2, Cameron Simpson wrote: Fine. This also eliminates any solution which just computes a hash. Exactly. Might I suggest instead simply starting with the leftmost element in the first list; call this elem0

__main__ vs official module name: distinct module instances

2015-08-01 Thread Cameron Simpson
when accessed by the code as cs.app.maildb, are there other implications to such a change that would break real world code? Cheers, Cameron Simpson The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man.- George Bernard Shaw -- https://mail.python.org/mailman/listinfo/python-list

Re: Most Pythonic way to store (small) configuration

2015-08-02 Thread Cameron Simpson
7;t let it get too weird - that would probably be a sign you do want to reach for JSON or YAML. But start with INI. Simple and easy. Cheers, Cameron Simpson A squealing tire is a happy tire. - Bruce MacInnes, Skip Barber Driving School instructor -- https://mail.python.org/mailman/listinfo/python-list

Re: __main__ vs official module name: distinct module instances

2015-08-02 Thread Cameron Simpson
On 02Aug2015 17:41, Steven D'Aprano wrote: On Sun, 2 Aug 2015 01:53 pm, Cameron Simpson wrote: Maybe this should be over in python-ideas, since there is a proposal down the bottom of this message. But first the background... I've just wasted a silly amount of time debugging an

Re: __main__ vs official module name: distinct module instances

2015-08-02 Thread Cameron Simpson
. How does this play with, for instance, zipimport, where there's no actual file name for the module? To my eyes, badly, which IMO strengthens my case for addressing the situation in the interpreter instead of requiring increasingly complex gyrations on the part of every programmer on the pl

Re: Most Pythonic way to store (small) configuration

2015-08-04 Thread Cameron Simpson
etc) then we're back in the risk zone. So on the whole I am against python code as the config file format. Really, who needs a Turing complete configuration file? Go with something simple, both in syntax and semantics. It is easier to read, easier to write/modify, and easier to access from

Re: except block isn't catching exception

2015-08-08 Thread Cameron Simpson
thread, even if the signal was received in another thread. Cheers, Cameron Simpson Meddle not in the affairs of dragons, for you are crunchy and good with ketchup. -- https://mail.python.org/mailman/listinfo/python-list

Re: except block isn't catching exception

2015-08-08 Thread Cameron Simpson
On 08Aug2015 18:17, Chris Angelico wrote: On Sat, Aug 8, 2015 at 6:11 PM, Cameron Simpson wrote: From: https://docs.python.org/3/library/signal.html#execution-of-python-signal-handlers we have: A Python signal handler does not get executed inside the low-level (C) signal handler

Re: Pipes

2015-08-09 Thread Cameron Simpson
stuff. "subprocess" is part of the library. I'm not sure what metric you're using here for "easy to learn". Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Pipes

2015-08-09 Thread Cameron Simpson
s, but you're still left with what is it. It is like a for loop, but you know that by now. Is there an up to date book on 3.x even. Every book seems to be from 2006 or so. Not sure, sorry. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Pipes

2015-08-09 Thread Cameron Simpson
nce. And a much better attempt than other "let the user write plain English" attempts like COBOL or SQL (less proselike, but definitely of that aim). There is of course Elisa :-) https://pypi.python.org/pypi/babbler/ Though it isn't programming... Cheers, Cameron Simpson My

Re: looking for standard/builtin dict-like data object

2015-08-10 Thread Cameron Simpson
g particular flavours. And the result us a tuple, not a dict. I also thought the stdlib had some kind of "namespace" class with this kind of API, but I can't find it now:-( Cheers, Cameron Simpson Always code as if the guy who ends up maintaining your code will be a violent ps

Re: looking for standard/builtin dict-like data object

2015-08-10 Thread Cameron Simpson
On 11Aug2015 14:09, Chris Angelico wrote: On Tue, Aug 11, 2015 at 1:40 PM, Cameron Simpson wrote: I also thought the stdlib had some kind of "namespace" class with this kind of API, but I can't find it now:-( It does - types.SimpleNamespace(). It accepts keyword arguments, a

Re: Qestion

2015-08-23 Thread Cameron Simpson
he's on RedHat Linux 5 (or CentOS 5) the system Python is 2.4.3. Cheers, Cameron Simpson "How do you know I'm Mad?" asked Alice. "You must be," said the Cat, "or you wouldn't have come here." -- https://mail.python.org/mailman/listinfo/python-list

Re: Connecting Terminal to Python 3.5

2015-08-29 Thread Cameron Simpson
important. Do you have backups of your system? Time Machine is a standard part of OSX, is incredibly easy to set up and generally great. Are you using it? Cheers, Cameron Simpson 186,282 miles per second - Not just a good idea, It's the Law! -- https://mail.python.org/mailman/listinfo/python-list

Re: Why Python is not both an interpreter and a compiler?

2015-08-31 Thread Cameron Simpson
ir design). Languages like Python aim for a more freindly and flexible programming syntax, and some of the price of that is more indirection between "byte code" and the underlying machine operations. Cheers, Cameron Simpson remember, information is not knowledge, knowledge is not

Re: Low level file descriptors and high-level Python files

2015-09-01 Thread Cameron Simpson
ose() fd2 is not closed, but fd is still open for further use. Cheers, Cameron Simpson This is not a bug. It's just the way it works, and makes perfect sense. - Tom Christiansen I like that line. I hope my boss falls for it. - Chaim Frenkel -- https://mail.python.org/mailman/listinfo/python-list

Re: Low level file descriptors and high-level Python files

2015-09-01 Thread Cameron Simpson
On 02Sep2015 08:01, Cameron Simpson wrote: One circumstance where you might use fdopen and _not_ want .close to close the underlying service is when you're handed a file descriptor over which you're supposed to perform some I/O, and the I/O library functions use high level file

Re: Can anyone help me run python scripts with http.server?

2015-09-06 Thread Cameron Simpson
you can run it standalone without Apache. I'm knocking something together right now using Flask, and I'm intending to run it without Apache at all. There'll be an haproxy in front of it for other reasons, but to get off the ground you don't even need that. Cheers, Cameron Simpson

Re: Can anyone help me run python scripts with http.server?

2015-09-07 Thread Cameron Simpson
On 07Sep2015 14:57, Chris Angelico wrote: On Mon, Sep 7, 2015 at 2:05 PM, Cameron Simpson wrote: Another nice thing about Flask is that you can run it standalone without Apache. I'm knocking something together right now using Flask, and I'm intending to run it without Apache at all

Re: Lightwight socket IO wrapper

2015-09-20 Thread Cameron Simpson
partial data packets) into a network packet, etc. Cheers, Cameron Simpson If you lie to the compiler, it will get its revenge.- Henry Spencer -- https://mail.python.org/mailman/listinfo/python-list

Re: Lightwight socket IO wrapper

2015-09-20 Thread Cameron Simpson
On 21Sep2015 12:40, Chris Angelico wrote: On Mon, Sep 21, 2015 at 11:55 AM, Cameron Simpson wrote: On 21Sep2015 10:34, Chris Angelico wrote: If you're going to add sequencing and acknowledgements to UDP, wouldn't it be easier to use TCP and simply prefix every message with a two-b

Re: Lightwight socket IO wrapper

2015-09-21 Thread Cameron Simpson
On 21Sep2015 18:07, Chris Angelico wrote: On Mon, Sep 21, 2015 at 5:59 PM, Marko Rauhamaa wrote: Chris Angelico : On Mon, Sep 21, 2015 at 4:27 PM, Cameron Simpson wrote: For sizes below 128, one byte of length. For sizes 128-16383, two bytes. And so on. Compact yet unbounded

Re: Successfully send sms with python

2015-09-22 Thread Cameron Simpson
instead of just \r do you need to follow every .write() with a .flush()? if the Serial object is a buffered stream that will be necessary Cheers, Cameron Simpson Motorcycling is indeed a delightful pastime.- Honda Rider Training Film -- https://mail.python.org/mailman/listinfo/python-list

Re: Successfully send sms with python

2015-09-23 Thread Cameron Simpson
ad of which big dumb button to push. Besides, he came here saying: I'm doing this, what am I doing wrong? We're trying to help him with this. It is not always about the final destination you know. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Modify environment variable for subprocess

2015-09-23 Thread Cameron Simpson
subprocess.Popen. That is the most direct and controllable method. Cheers, Cameron Simpson Tachyon: A gluon that's not completely dry. -- https://mail.python.org/mailman/listinfo/python-list

Re: ConnectionError handling problem

2015-09-24 Thread Cameron Simpson
le actions, and let the rest escape. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: ConnectionError handling problem

2015-09-24 Thread Cameron Simpson
On 24Sep2015 20:57, shiva upreti wrote: Thank you Cameron. I think the problem with my code is that it just hangs without raising any exceptions. And as mentioned by Laura above that when I press CTRL+C, it just catches that exception and prints ConnectionError which is definitely a lie in

Re: ConnectionError handling problem

2015-09-25 Thread Cameron Simpson
On 24Sep2015 22:46, shiva upreti wrote: On Friday, September 25, 2015 at 10:55:45 AM UTC+5:30, Cameron Simpson wrote: On 24Sep2015 20:57, shiva upreti wrote: >Thank you Cameron. >I think the problem with my code is that it just hangs without raising any >exceptions. And as mentioned

Re: ConnectionError handling problem

2015-09-26 Thread Cameron Simpson
On 26Sep2015 09:46, Gonzalo V wrote: Hi Cameron. i had the same problems and you have to tell to python what to do with the connect problem. Definitely. That's why we're encouraging him to handle specific exceptions. try this: ... except *urllib.error.HTTPError* as e:

Re: ConnectionError handling problem

2015-09-30 Thread Cameron Simpson
On 29Sep2015 23:04, shiva upreti wrote: On Friday, September 25, 2015 at 12:55:01 PM UTC+5:30, Cameron Simpson wrote: Ok. You original code says: try: r=requests.post(url, data=query_args) except: print "Connection error" and presumably we think your code is hanging

Re: ConnectionError handling problem

2015-10-01 Thread Cameron Simpson
On 30Sep2015 23:56, Laura Creighton wrote: In a message of Thu, 01 Oct 2015 07:30:59 +1000, Cameron Simpson writes: Most likely the Ctrl-C interrupts whatever system call is hanging, causing it to return (failed, probably with errno EINTR). And the python program resumes because the OS system

Re: Only getting the first 6 lines

2015-10-01 Thread Cameron Simpson
ant if the output of your command is large or slow, as it does not need to suck the whole thing into memory or to wait for it to finish a long procedure. With "ps" these issues are pretty minor; with some other programs it can be significant, especially if the other program _doesn&#

Re: Ignore stderr and use return code

2015-10-25 Thread Cameron Simpson
r of df, consider calling os.statvfs() directly from Python: https://docs.python.org/3/library/os.html#os.statvfs Iam using python 2.7 on Linux It is the same in Python 2. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get python socket to use a specific interface

2015-10-26 Thread Cameron Simpson
tself? Using the correct IP address should normally be sufficient. The system you're talking to won't know anything about the device, only the address. Try skipping the device binding step. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get python socket to use a specific interface

2015-10-27 Thread Cameron Simpson
On 27Oct2015 10:00, Robin Becker wrote: On 26/10/2015 22:29, Cameron Simpson wrote: On 26Oct2015 12:33, Robin Becker wrote: . $ ifconfig eth0 Link encap:Ethernet HWaddr 00:...4 GB) Interrupt:16 eth0:0Link encap:Ethernet HWa... Do you need

Re: how to get python socket to use a specific interface

2015-10-28 Thread Cameron Simpson
ching for a particular device is annoying and weird and possibly even pointless. Anyhow my upstream provider has taken over the problem so hopefully I will get the address cleared at some point. Ok. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Most space-efficient way to store log entries

2015-10-28 Thread Cameron Simpson
pression obtained will be small and the loss from any base64 post step will undo it all. He may be better off keeping conventional text logs and just rotating them and compressing the rotated copies. Cheers, Cameron Simpson Hoping to shave precious seconds off the time it would take me to

Re: Most space-efficient way to store log entries

2015-10-29 Thread Cameron Simpson
them uncompressed and using compression in the transfer. "ssh -o compression=yes" or "rsync -z", etc. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Most space-efficient way to store log entries

2015-10-29 Thread Cameron Simpson
On 29Oct2015 23:16, Laura Creighton wrote: In a message of Fri, 30 Oct 2015 08:28:07 +1100, Cameron Simpson writes: On 29Oct2015 09:15, Laura Creighton wrote: Did the OP say he wanted to keep his compressed logfiles on a local disk? What if he wants to send them across the internet to some

Re: Most space-efficient way to store log entries

2015-10-29 Thread Cameron Simpson
may be able to mount one end or the other as a remote filesystem. Then you can benchmark plain old "cp" over SMB or NFS etc. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Creating PST files using Python

2015-11-03 Thread Cameron Simpson
ard limit - I don't know. Bad, bad idea. It is a very strange request. But very corporate/government in mindset. Alas, I cannot help to the with any tools or module for his task. Cheers, Cameron Simpson Microsoft Mail: as far from RFC-822 as you can get and still pretend to

Re: time module

2015-11-07 Thread Cameron Simpson
://docs.python.org/3/library/time.html#time.time Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Cameron Simpson
... complain about timeout, reciting "e" in the message ... Cheers, Cameron Simpson I think you're confusing "recognizing" and "understanding" with "caring". The net is cruel, sometimes, but always fair. - Rick Gordon -- https://mail.python.org/mailman/listinfo/python-list

Hi

2015-11-12 Thread Cameron Houliston
Can I have a link to use python Sent from Mail for Windows 10 -- https://mail.python.org/mailman/listinfo/python-list

Re: find which Python libraries are most influential in scientific research

2015-11-14 Thread Cameron Simpson
nothing on the page that looks like it should need any JavaScript (hmm, some mouseovers but I'm pretty sure that can be mediated entirely in CSS, perhaps less "smoothly"). There does seems to be a nice long list of relevant Python packages listed there though. Cheers, Cameron

Re: Bi-directional sub-process communication

2015-11-23 Thread Cameron Simpson
Works just fine and avoids all the worrying about ordering etc. Israel, do you have control over the protocol between you and your subprocess? If so, adding tags is easy and effective. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Bi-directional sub-process communication

2015-11-23 Thread Cameron Simpson
On 24Nov2015 16:25, Cameron Simpson wrote: Completely untested example code: class ReturnEvent: def __init__(self): self.event = Event() With, of course: def wait(self): return self.event.wait() Cheers, Cameron Simpson Maintainer's Motto: If we can't fix it, it a

Re: Bi-directional sub-process communication

2015-11-23 Thread Cameron Simpson
) return RE def process_response(tag, response_data): RE = re_by_tag.pop(tag) RE.result = response_data RE.event.set() ... CherryPy request handler ... RE = submit_request(your_query_info) RE.wait() response_data = RE.result Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: http://bugs.python.org/issue19495 timeit enhancement

2014-06-12 Thread Cameron Simpson
7;m mentioning it in support of the use case. Cheers, Cameron Simpson 1993 Explorer - Cage? Hell, it's a prison. - Will Hartung vfr...@netcom.com -- https://mail.python.org/mailman/listinfo/python-list

Re: tempfile.py", line 83, in once_lock = _allocate_lock() thread.error: can't allocat lock

2014-06-13 Thread Cameron Simpson
It may be that this issue has been fixed in a later release of Python than the one currently installed on your HP-UX box. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: tempfile.py", line 83, in once_lock = _allocate_lock() thread.error: can't allocat lock

2014-06-14 Thread Cameron Simpson
o the side, for example in /opt/python-2.7.7. Then use that python executable (eg /opt/python-2.7.7/bin/python) to see if the problem still exists. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Cameron Simpson
retty clearly (to me) describes blocking=False, by contrasting it with a behaviour that would obtain if blocking=True. It is in the clause describing "the blocking argument set to False", after all. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: How do you use `help` when write your code

2014-07-06 Thread Cameron Simpson
ly. A quick'n'dirty debug tool. ''' global D_mode if D_mode: X(fmt, *args) I use X() for ad hoc right now debugging and D() for turn on at need debugging. Surprisingly handy. Many many of my modules have "from cs.logutils import X, D

Re: Saving

2014-07-06 Thread Cameron Simpson
So you don't write code, test and _then_ save. You write code and save. Then test from the saved file. Cheers, Cameron Simpson I'm Bubba of Borg. Y'all fixin' to be assimilated. -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposal: === and !=== operators

2014-07-09 Thread Cameron Simpson
using "from __future__ import equals" in Python 3.5, and then to become the default behaviour in 3.6. * To support non-reflexive types, allow === and !=== operators, which are like == and != except they don't call `is` first. [...] I don't like the spelling. They seem

Re: Proposal: === and !=== operators

2014-07-09 Thread Cameron Simpson
- because it is thread local it doesn't asynchronously affect other running code - it doesn't introduce a new operator - it affects a tightly constrainted behaviour, and can obviously be extended to other special cases if they arise The downside is that it could break code dep

Re: How to write match nth grouped subexpression?

2014-07-10 Thread Cameron Simpson
nly one). If you write a little test script (untested): import re TESTLINE = "Hours logged: 12" regexp = re.compile( r'Hours logged: (\d+)' ) m = regexp.match(TESTLINE) print "subgroup 1:", m.group(1) that should print "12". Cheers, Cameron Simpson

context manager based alternative to Re: Proposal: === and !===

2014-07-10 Thread Cameron Simpson
the programmer, in that they can set the domain in which the behaviour obtains. Cheers, Cameron Simpson Q: How many user support people does it take to change a light bulb? A: We have an exact copy of the light bulb here and it seems to be working fine. Can you tell me what kind of sy

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread Cameron Simpson
ackets. The outermost ( and ) are regexp grouping brackets, not text. On their own you don't need them, but they mark out the regexp between them for later reference or for use with a repeating modifier like ?, * or +. So in this instance they do not add anything special to the regexp.

Re: context manager based alternative to Re: Proposal: === and !===

2014-07-11 Thread Cameron Simpson
On 10Jul2014 17:34, Ethan Furman wrote: On 07/10/2014 05:20 PM, Cameron Simpson wrote: Here's an alternative proposal that doesn't involve a new operator. [snip float-context manager stuff] Decimal has a context manager like that already (I don't know if it supports allowin

Re: context manager based alternative to Re: Proposal: === and !===

2014-07-11 Thread Cameron Simpson
On 11Jul2014 14:37, Chris Angelico wrote: On Fri, Jul 11, 2014 at 11:17 AM, Roy Smith wrote: In article , Cameron Simpson wrote: [... context manager changing NaN comparisons ...] I'm a bit wary of anything that makes a global, even if temporary, change to comparisons' behavi

Re: New to Python

2014-07-31 Thread Cameron Simpson
d you elaborate on what ou actually need? And your Python background, if any. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Davis putnam algorithm for satisfiability...

2014-08-04 Thread Cameron Simpson
To my mind, that constitutes a backtrack: back up, and try a different way (on the modified cnf and deep_copy). Cheers, Cameron Simpson import sys import math import copy final_list = [] def sat(cnf): while( len(cnf) > 1 ): in_item = single_clause(cnf) #in_i

Re: try/exception - error block

2014-08-04 Thread Cameron Simpson
the stderr of his python subprocess went, but never heard back. Cheers, Cameron Simpson Reality is that which refuses to go away when I stop believing in it. - Phillip K. Dick -- https://mail.python.org/mailman/listinfo/python-list

Re: Davis putnam algorithm for satisfiability...

2014-08-06 Thread Cameron Simpson
On 05Aug2014 07:03, varun...@gmail.com wrote: Thank you Cameron. Your post was very helpful. If you don't mind I'd like to ask you the purpose of the final list in the very beginning of the code. It is being updated and then checked for the presence of a literal. If a literal is

Re: Test for an empty directory that could be very large if it is not empty?

2014-08-07 Thread Cameron Simpson
reason for wanting to know if a directory is empty that I can imagine is when you want to remove it, and if that applies here it is better to just try to remove it and ask for forgiveness later. Disclaimer: Windows may not offer this handy safety net. Cheers, Cameron Simpson Of course no descri

Re: Is print thread safe?

2014-08-11 Thread Cameron Simpson
each object, and a "write" for the separators. There is no mention of locking. On that basis, I would find the interleaving described normal and expected. And certainly not "broken". Just use a lock! And rebind "print"! Or use the logging system! Cheers, Cameron

Re: Is print thread safe?

2014-08-11 Thread Cameron Simpson
s might; avoid as many things as possible). Also, the code above uses an RLock; less prone to deadlock than a plain mutex Lock. Cheers, Cameron Simpson A host is a host from coast to coast & no one will talk to a host that's close Unless the host (that isn't close) is busy, hung o

Re: Is print thread safe?

2014-08-11 Thread Cameron Simpson
On 12Aug2014 09:56, Steven D'Aprano wrote: Cameron Simpson wrote: On 12Aug2014 02:07, Steven D'Aprano wrote: Is this documented somewhere? In python/2.7.6/reference/simple_stmts.html#index-22, "print" is described in terms of a "write" for each object, an

Re: a python console in bluestacks

2014-08-13 Thread Cameron Simpson
g/ and use that. Maybe he wants Python to run on the emulator? Just an idea... Cheers, Cameron Simpson The wonderous pulp and fibre of the brain had been substituted by brass and iron; he had taught wheelwork to think. - Harry Wilmot Buxton 1832, referring to Charles Babba

Re: how to change the time string into number?

2014-08-14 Thread Cameron Simpson
Someone who has used one may correct me here. import time time.tzname ('China Standard Time', 'China Daylight Time') Ok. Have a look at time.timezone. That may help you. Cheers, Cameron Simpson On 8/14/2014 3:25 PM, Cameron Simpson wrote: On 14Aug2014 14:52, luofeiyu

Re: how to change the time string into number?

2014-08-14 Thread Cameron Simpson
allows the strptime parser to keep recognising text. Imagine, for example, that the timezone were embedded in the middle of the string for some reason. It looks like you platform does not support storing the time zone information in the C library "struct tm", and therefore it does not

Re: problem on top-post

2014-08-14 Thread Cameron Simpson
ation, too. Thanks, Cameron Simpson Shape without form, shade without colour, Paralysed force, gesture without motion;- T.S. Eliot, _The Hollow Men_ -- https://mail.python.org/mailman/listinfo/python-list

Re: timedelta problem

2014-08-15 Thread Cameron Simpson
hon version. On some flavour of Windows I believe. Cheers, Cameron Simpson Our friend Trefayne is really most intuitive; you may trust that anything he says is absolutely true.- Aylebourne -- https://mail.python.org/mailman/listinfo/python-list

Re: For using python ability, what should I do???

2014-08-17 Thread Cameron Simpson
a huge web framework! Write something simple that can run in a console or shell prompt or simple IDE. But it really does help to solve a (small) problem of interest to yourself. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: How can I get the timezone time of a location?

2014-08-19 Thread Cameron Simpson
find somewhere (online?) The Olsen db maps a zone name (a physical region usually not shaped like a longitude "slice") where a particular legal rule exists for the local time offset. Cheers, Cameron Simpson Speed costs money. How fast do you want to go? - C. Shelby -- https://mail.python.org/mailman/listinfo/python-list

Re: How to look up historical time zones by date and location

2014-08-19 Thread Cameron Simpson
ct. Please see if that helps you, and if not, come back. Cheers, Cameron Simpson Ignorance is preferable to error; and he is less remote from the truth who believes nothing, than he who believes what is wrong. - Thomas Jefferson -- https://mail.python.org/mailman/listinfo/python-list

Re: Halfway point between interactive and daemon?

2014-08-22 Thread Cameron Simpson
I can “check” on it when I need to with a tail -f /var/log/mylog.log. But then I have the problem of managing the log size. And also I either have to wait for stdout to flush, or insert sys.stdout.flush() after any of my print()’s. Log messages should be going to stderr anyway, which by defau

Re: Thread terminate

2014-08-28 Thread Cameron Simpson
more lightweight than spawning distinct processes. CHeers, Cameron Simpson UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. - Doug Gwyn -- https://mail.python.org/mailman/listinfo/python-list

Re: I have tried and errored a reasonable amount of times

2014-08-30 Thread Cameron Simpson
it "o"), when you call: o.method_name_here(1,2) it invokes the function MyClass.method_name_here(o,1,2). So because the string "no" is an instance of str, the code: "no".isupper() runs the function str.isupper("no"), which examines its argument for u

Re: Distinguishing between maildir, mbox, and MH files/directories?

2014-08-31 Thread Cameron Simpson
except IOError: if fp is not None: fp.close() return False fp.close() return from_ == 'From ' I would use these is code somewhat like this (imagining your use case): if ismaildir(path): ... elif ismhdir(path): ... elif ismbox(path):

Re: subprocess module usage

2014-09-01 Thread Cameron Simpson
does not fail outright, it will presumably do the _wrong_ thing. Cheers, Cameron Simpson Music journalism: People who can't write interviewing people who can't talk for people who can't read. - Frank Zappa -- https://mail.python.org/mailman/listinfo/python-list

Re: Editing text with an external editor in Python

2014-09-01 Thread Cameron Simpson
People keep assuming injection is all about malice and being hacked. It is not. It is also about robustness and reliability, and possible silent failure/misfunction. Cheers, Cameron Simpson st...@ensoniq.com says... | Motorcycle maintenence is an art, isn't it? By the time you've finished, it's a black art. - Dave Parry -- https://mail.python.org/mailman/listinfo/python-list

Re: error while writing program to send mail.

2014-09-01 Thread Cameron Simpson
efine it; you need to do so. After you sort that, you then have a ython problem: you have said "$s" in your format string, but the python "%" operator expected "%s" in the format string. Sort these two things and see how things proceed. Cheers, Cameron Simpso

<    11   12   13   14   15   16   17   18   19   20   >