Re: can someone explain the concept of "strings (or whatever) being immutable"

2014-06-03 Thread Cameron Simpson
, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Introduction to my fellow Python Friends

2013-08-11 Thread Cameron Simpson
ist in the best possible way? | I hope to have a wonderful time with Python here. I hope i am not wasting | your time. Sorry for the inconvenience if i am. Not at all. Cheers, -- Cameron Simpson I have no help to send, therefore I must go myself. - Aragorn son of Arathorn -- http://mail.pyt

Re: default python os x

2013-08-21 Thread Cameron Simpson
in particular OSX "env" does not have it. A shell function can do the same though: py20() { ( unset PYTHONSTARTUP exec python2.0 ${1+"$@"} ) } I've said py20 instead of python2.0 primarily because bash is a bit... picky about function names and reje

Re: PEPs should be included with the documentation download

2013-08-21 Thread Cameron Simpson
desktop icons, ready for instant opening. I agree I rarely need the PEPs unless I want to look up something unusual. Cheers, -- Cameron Simpson I need your clothes, your boots, and your motorcycle. - Arnold Schwarzenegger, Terminator 2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Interface and duck typing woes

2013-08-28 Thread Cameron Simpson
e alone in sometimes being frustrated chasing a deeply nested runtime error that static type checking might have found up front. Cheers, -- Cameron Simpson "waste cycles drawing trendy 3D junk" - Mac Eudora v3 config option -- http://mail.python.org/mailman/listinfo/python-list

Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of

2013-08-28 Thread Cameron Simpson
tart -DSSL [...] | My script were all workign in the previous VPS enviroment, the script is correct is just a few minor thing in the new VPS env that they need to be taken care of thus prohibit my script to run.. Your previous VPS used "suexec" in the Apache. This one does not. Cheers,

Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of

2013-08-28 Thread Cameron Simpson
specific directory for these files and give ONLY THAT write permission for "nobody". And then use a full pathname to the directory in his CGI script - a relative path makes ill founded assumptions about the current working directory of the script. Cheers, -- Cameron Simpson A gent

Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of

2013-08-28 Thread Cameron Simpson
is. Normal practice is to specify vhost specific log paths inside each website's VirtualHost clause, thus splitting the log for each website out into separate files. http://httpd.apache.org/docs/2.2/mod/core.html#virtualhost Notice the ErrorLog directive inside the clause. Cheers, -- Cameron Si

Re: argparse - specify order of argument parsing?

2013-08-31 Thread Cameron Simpson
md -a --no-foo Would turn on "all" options then turn off "foo". Hard to do if you look for "more important" options and then less important options. I'm personally against out-of-order option handling; it confuses things for the user. If you (as the user) need

Re: How do I process this using Python?

2013-08-31 Thread Cameron Simpson
en JSON, but has already been passed through json.loads() for you. What does type(the_json) say? What does repr(the_json) say? Print both. I would guess it has already been parsed. Cheers, -- Cameron Simpson Sattinger's Second Law: Even though you've plugged it in, it still won't work until you switch it on. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to split with "\" character, and licence copyleft mirror of ©

2013-09-01 Thread Cameron Simpson
pedia.org/wiki/Copyleft | to distribute my app. Isn't that a copyright symbol? I'd have a look at the "uncidoedata" module, myself. Cheers, -- Cameron Simpson Just because Unix is a multiuser system doesn't mean I want to share it with anybody!- Paul Tomblin, in rec.aviation.military -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: use of built-in exceptions

2013-09-02 Thread Cameron Simpson
This is all just examples of course. Cheers, -- Cameron Simpson Whether you're getting laid or not, the glass is still half empty. - Dan Hillman, alt.peeves Massgasm -- http://mail.python.org/mailman/listinfo/python-list

Re: UnicodeDecodeError issue

2013-09-04 Thread Cameron Simpson
On 04Sep2013 12:38, Dave Angel wrote: | 'file' isn't magic. Chuckle... | What heuristics it uses, I don't know, but it has | hundreds of them. ... because the file of heuristics is /usr/share/file/magic :-) See "man 5 magic". Cheers, -- Cameron Simpson A va

Re: Weighted choices

2013-09-08 Thread Cameron Simpson
oices = [(10, "Apple"), (10+20, "Pear"), (10+20+15, "Banana")... ] | | generate random integer in the range of the sum of the weights, and accept | the last tuple whose first element is less than the integer. Search it with the bisect module, not linearly! Cheers, -- Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: How do I calculate a mean with python?

2013-09-16 Thread Cameron Simpson
what it is doing wrong I would write a mean like this: def mean(values): return sum(values) / len(values) There are circumstances where that is simplistic, but it is the classic definition of the mean. Cheers, -- Cameron Simpson Microsoft Mail: as far from RFC-822 as you can get and s

Re: Re for Apache log file format

2013-10-08 Thread Cameron Simpson
try: dt = datetime.strptime(humantime, "[%d/%b/%Y:%H:%M:%S") except ValueError, e: dt = None if dt is None: tzinfo = None else: tzinfo = tzinfo[:-1] and proceeeds otherwise (we have a few different

Re: class implementation

2013-10-08 Thread Cameron Simpson
Pykkar.__init__(self) ... any of your own init stuff ... Likewise for your world_l class. BTW, it is conventional to start class names with an upper case letters. Just style, but it helps other people when reading your code. Cheers, -- Cameron Simpson It looks like you've got

Re: I am never going to complain about Python again

2013-10-09 Thread Cameron Simpson
:-( A friend forwarded me a link a few months ago; PHP apparently got some subclassing support that basicly seemed to support "mixins"; it looked ghastly. Cheers, -- Cameron Simpson Strong typing isn't for weak minds; the argument 'strong typing is for weak minds' is for weak minds. - Guy Harris -- https://mail.python.org/mailman/listinfo/python-list

Re: class implementation

2013-10-10 Thread Cameron Simpson
ot get hidden by the (overly long IMO) included material and readers can get on with looking at your stuff, knowing that if necessary they can wade through the other stuff. Cheers, -- Cameron Simpson Any profit should go to Arnie's `get the daemon carved on Mount Rushmore' fund.

Re: I am never going to complain about Python again

2013-10-10 Thread Cameron Simpson
" part eluded my eye. When *is* it > appropriate? Apparently not during an equal test. I must say that I read the footnote [2] as a directive to the programmer. "If you need to do this, a good way is to compare magnitudes is appropriate." Cheers, -- Cameron Simpson My life is

Re: Skipping decorators in unit tests

2013-10-10 Thread Cameron Simpson
ttp://pastebin.com/20CmHQ7Y Speaking for myself, I would be include to recast this code: @absolutize def addition(a, b): return a + b into: def _addition(a, b): return a + b addition = absolutize(_addition) Then you can unit test both _addition() and addition(). And so f

Re: Skipping decorators in unit tests

2013-10-10 Thread Cameron Simpson
On 10Oct2013 19:44, Ned Batchelder wrote: > On 10/10/13 6:12 PM, Cameron Simpson wrote: > >Speaking for myself, I would be include to recast this code: > > > > @absolutize > > def addition(a, b): > > return a + b > > > >into: > >

Re: Skipping decorators in unit tests

2013-10-10 Thread Cameron Simpson
On 11Oct2013 02:55, Steven D'Aprano wrote: > On Fri, 11 Oct 2013 09:12:38 +1100, Cameron Simpson wrote: > > Speaking for myself, I would be include to recast this code: > > > > @absolutize > > def addition(a, b): > > return a + b > &

Re: Skipping decorators in unit tests

2013-10-10 Thread Cameron Simpson
On 11Oct2013 14:42, Ben Finney wrote: > Cameron Simpson writes: > > On 11Oct2013 02:55, Steven D'Aprano > > wrote: > > > def undecorate(f): > > > """Return the undecorated inner function from function f.""" > > &g

Re: Skipping decorators in unit tests

2013-10-10 Thread Cameron Simpson
On 11Oct2013 05:51, Steven D'Aprano wrote: > On Fri, 11 Oct 2013 15:36:29 +1100, Cameron Simpson wrote: > > But is it reliable? Will it work on any decorated function? > > *Any* decorated function? No, of course not, since decorators can do > anything they like: [...

Re: Multi-threading in Python vs Java

2013-10-10 Thread Cameron Simpson
like deque) are thread safe, so a lot of the coordination is pretty easy. And of course context managers make Locks and Semaphores very easy and reliable to use: L = Lock() ... with L: ... do locked stuff ... ... ... I'm sure you'll get longer and more nuance

Re: Multi-threading in Python vs Java

2013-10-11 Thread Cameron Simpson
rocessing > module. And, for contrast, I would not. Threads are my friends and Python threads seem eminently suited to the above scenario. Cheers, -- Cameron Simpson [Alain] had been looking at his dashboard, and had not seen me, so I ran into him. - Jean Alesi on his qualifying prang at Imola '93 -- https://mail.python.org/mailman/listinfo/python-list

Re: Skipping decorators in unit tests

2013-10-11 Thread Cameron Simpson
g "+"). Cheers, -- Cameron Simpson I very strongly suggest that you periodically place ice packs over the abused areas. - Steve Garnier -- https://mail.python.org/mailman/listinfo/python-list

Re: Testing BlockHosts

2013-10-17 Thread Cameron Simpson
e. Or behind a firewall that blocks ping but passes specific other traffic. Or... This seems like a rather vague question. What has this to do with Python? -- Cameron Simpson NOTWORK: n. A network when it is acting flaky. Origin (?) IBM. - Hackers' Dictionary -- https://mail.python.o

Re: Python on a MacBook Pro (not my machine)

2013-10-27 Thread Cameron Simpson
eside the editor pane) and vim with syntax highlighting. And a web browser open on a local copy of the 2.x or 3.x HTML docs - I keep one of each on my desktop for easy access. I'm not an IDE person, so I can't speak to those (even IDLE). Cheers, -- Cameron Simpson You want to tempt the wrath of the whatever from high atop the thing? - Toby Zeigler, _The_West_Wing_ - Election Night -- https://mail.python.org/mailman/listinfo/python-list

Re: Help me with this code PLEASE

2013-11-05 Thread Cameron Simpson
jects (and not querying the stored values via SQL - eg WHERE), then: make a column of type BLOB, convert Python values to bytes using pickle, store. And of course the reverse. It is not a great use of an RDB, but it seems to adhere to what you ask. -- Cameron Simpson -- https://mail.python.org/ma

Re: Python on a MacBook Pro (not my machine)

2013-11-06 Thread Cameron Simpson
interpreter segfaults and crashes on the second command! > I'll start a new thread to deal with that problem. I think there was some discussion of this bug with Mavericks very recently on the list. Possibly fixed in more recent builds. Cheers, -- Cameron Simpson Uhlmann's R

surprising exception text

2015-03-08 Thread Cameron Simpson
Gotta love this: TypeError: decoding with 'utf-8' codec failed (TypeError: '_io.BufferedReader' does not support the buffer interface) Not to worry:-) Cheers, Cameron Simpson The Design View editor of Visual InterDev 6.0 is currently incompatible with Compatibili

Re: surprising exception text

2015-03-08 Thread Cameron Simpson
On 08Mar2015 18:52, Mark Lawrence wrote: On 08/03/2015 18:20, Steven D'Aprano wrote: Mark Lawrence wrote: On 08/03/2015 09:15, Cameron Simpson wrote: Gotta love this: TypeError: decoding with 'utf-8' codec failed (TypeError: '_io.BufferedReader' does not support t

Re: Newbie question about text encoding

2015-03-08 Thread Cameron Simpson
been a pure pleasure to work with, little though I have done that so far. Cheers, Cameron Simpson There is no human problem which could not be solved if people would simply do as I advise. - Gore Vidal -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Cameron Simpson
binary" mode and decoding each to a string. So you know the consumed length from the binary half; that they're different lengths after decoding to strings is then irrelevant. Cheers, Cameron Simpson These are my principles, and if you don't like them, I have others. - Groucho Marx -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3: Reading a text/binary mixed file

2015-03-10 Thread Cameron Simpson
On 10Mar2015 22:38, Paulo da Silva wrote: On 10-03-2015 04:14, Cameron Simpson wrote: On 10Mar2015 04:01, Paulo da Silva wrote: But this is very tricky! I am on linux, but if I ran this program on windows I needed to change it to "eat" also the '\r'. If you're

Re: Did https://pypi.python.org/pypi/ became huge and slow?

2015-03-10 Thread Cameron Simpson
latency) put a VERY noticable upfront cost to every HTTPS connection versus HTTP. Once underway, they're essentially the same (per connection). Cheers, Cameron Simpson The Eight Fallacies of Distributed Computing - Peter Deutsch 1. The network is reliable 2. Latency is zero 3.

Re: Did https://pypi.python.org/pypi/ became huge and slow?

2015-03-10 Thread Cameron Simpson
ise people are going to get quite confused. Yes. Also, "pypi" should redirect to "pypi/" otherwise all the relative links will be off-by-one. Not to mention normalising to a single URL for caching/mapping etc. Cheers, Cameron Simpson IE 5.0 introduces nothing but a bunch o

Re: Python3 "pickle" vs. stdin/stdout - unable to get clean byte streams in Python 3

2015-03-12 Thread Cameron Simpson
you binary streams; I always need to put an encoder/decoder on them to use text. Did that just the other day. BTW, this is on some UNIX variant? Should not be very relevant... Further questions: What does self.proc.stdout.__class__ say? And for stdin? Cheers, Cameron Simpson My opinions are borrowed from someone who no longer needs them. -- katma...@uga.cc.uga.edu -- https://mail.python.org/mailman/listinfo/python-list

Re: regex help

2015-03-13 Thread Cameron Simpson
the result ends in a dot, add a single zero. Cheers, Cameron Simpson C'mon. Take the plunge. By the time you go through rehab the first time, you'll be surrounded by the most interesting people, and if it takes years off of your life, don't sweat it. They'll be the l

Re: Pexpect idea - but can I handle curses?

2015-03-14 Thread Cameron Simpson
o python curses (with the correct $TERM on the output side). But I suspect it might be just as easy to implement your own top by parsing stuff from /proc. Your call... Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Odd ValueError using float

2015-03-14 Thread Cameron Simpson
Apple LLVM 6.0 (clang-600.0.56)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> int('1.3') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int(

Re: Python 2 to 3 conversion - embrace the pain

2015-03-15 Thread Cameron Simpson
..] Decided to do a sweep of a range of possible things they may have been talking about, and fixed issue in under 15 minutes. [...] Sadly becoming the norm. People will just whinge and complain but never actually report issues in Open Source. https://twitter.com/grahamdumpleton/status/569

Re: Python 2 to 3 conversion - embrace the pain

2015-03-16 Thread Cameron Simpson
on multiple systems. But I definitely have code that works so much better in python 3 that I will never backport it; the example I have in mind started as python 2 and spent years in bytes/text indecision and confusion. Bite the bullet and go py3, an a whole class of pervasive issue just g

Re: Python 2 to 3 conversion - embrace the pain

2015-03-17 Thread Cameron Simpson
se. IMO Mercurial is better anyway, but SVN shot itself in the foot with the install requirements. I'm capable of following linear procedures. But I'm also capable of deciding that procedures are unreasonably complex, especially when they have bugs. Cheers, Cameron Simpson Wag

Re: Supply condition in function call

2015-03-26 Thread Cameron Simpson
n varnames ]) return varstuple and then "test1()" can look like this: def test1(a, b, condition): for i, j in zip(a,b): c = i + j if condition(vartuple(locals())): print("Foo") which makes it much easier to write test2 and so on later. Does this help? Cheers, Cameron Simpson Your reality is lies and balderdash, and I'm glad to say that I have no grasp of it. - Baron Munchausen -- https://mail.python.org/mailman/listinfo/python-list

Re: Supply condition in function call

2015-03-26 Thread Cameron Simpson
On 26Mar2015 10:03, Peter Otten <__pete...@web.de> wrote: Cameron Simpson wrote: vars = locals() varnames = list(vars.keys()) That leaves varnames in undefined order. Consider varnames = sorted(vars) Actually, not necessary. I started with sorted, but it is irrelevant

Re: Supply condition in function call

2015-03-26 Thread Cameron Simpson
with the "named" tuple values (which would normally not start with "_"), and it is explicitly documented. Thanks Peter! Cheers, Cameron Simpson Nothing is impossible for the man who doesn't have to do it. -- https://mail.python.org/mailman/listinfo/python-list

Re: Supply condition in function call

2015-03-27 Thread Cameron Simpson
On 27Mar2015 21:02, Manuel Graune wrote: Cameron Simpson writes: This passes the local variables inside test1() to "condition" as a single parameter. Now, I grant that vars['i'] is a miracle of tediousness. So consider this elaboration: from collections import namedtu

Re: Supply condition in function call

2015-03-29 Thread Cameron Simpson
t than middle click. The mouse is not your friend. Cheers, Cameron Simpson Unix is user-friendly. It's just picky about who its friends are. -- https://mail.python.org/mailman/listinfo/python-list

Re: Strategy/ Advice for How to Best Attack this Problem?

2015-04-03 Thread Cameron Simpson
ly made ... FileExistsError only came in in Python 3.3, for earlier Pythons catch OSError and check the exception's .errno against errno.EEXIST. Cheers, Cameron Simpson I am a Bear of Very Little Brain and long words Bother Me. - Winnie-the-Pooh -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with pipes, buffering and pseudoterminals

2015-04-05 Thread Cameron Simpson
utput = sys.argv[1:] Then you can call pty.openpty(), and then use the slave file descriptor with subprocess.Popen to invoke command_generating_output. Thus the generating command will be talking to you via a pty instead of a pipe. Cheers, Cameron Simpson It is interesting to think of the great blaze of heaven that we winnow down to animal shapes and kitchen tools.- Don DeLillo -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with pipes, buffering and pseudoterminals

2015-04-06 Thread Cameron Simpson
ites to the master descriptor those data appear for read on the slave file descriptor. Conversely, when the shell writes to its output (the slave file descriptor) it appears for read on the master descriptor (for the xterm to read and display). So the slave descriptor _is_ a perfectly ordinary

Re: Help with pipes, buffering and pseudoterminals

2015-04-07 Thread Cameron Simpson
On 07Apr2015 20:38, Chris Angelico wrote: On Tue, Apr 7, 2015 at 3:48 PM, Cameron Simpson wrote: The operating system arranges the commection of the shell to the terminal. Your usual program has by default a stdin, stdout and stderr. These are _all_ the same file handle, duplicated to each of

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Cameron Simpson
t the base to any arbitrary integer (within reason). [...snip...] In dc also (UNIX's reverse polish arbitrary precision "decimal calculator"). You can set the input and output representation bases, and proceed without leading base indicators. Cheers, Cameron Simpson Hofstadter&#x

Re: Code critique please

2015-04-07 Thread Cameron Simpson
) I tend to write things like this as thought they could become python modules for reuse. (Often they do; why write something twice?) So the base of the script becomes like this: if __name__ == '__main__': EPD_2_Image(EPD_FILENAME, IMAGE_FILENAME) In this way, when you invoke the .py

Re: Get nesting of regex groups

2015-04-08 Thread Cameron Simpson
can inner ever not be a nested group of outer? If he has to ask this question, one might presume that he is not the source of the regexp. Ergo, he may not know the regexp structure ahead of time for whatever reason. I could invent scenarios for that, but perhaps Mattias can describe his situat

Re: try..except with empty exceptions

2015-04-11 Thread Cameron Simpson
Consider this a proof that Python's current meanings for bare except and "except ()" are sensible, using a proof by contradiction. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: try..except with empty exceptions

2015-04-11 Thread Cameron Simpson
ad a common root. Hmm. Can I catch "object"? Sounds awful, but might work. Cheers, Cameron Simpson EMACS: Escape Meta Alt Control Shift -- https://mail.python.org/mailman/listinfo/python-list

Re: try..except with empty exceptions

2015-04-11 Thread Cameron Simpson
On 12Apr2015 07:52, Chris Angelico wrote: On Sun, Apr 12, 2015 at 7:37 AM, Cameron Simpson wrote: On 11Apr2015 21:21, Chris Angelico wrote: But I agree, it would be very nice if Python 3 could have abolished the truly confusing part of this, where "except:" catches everythin

Re: try..except with empty exceptions

2015-04-11 Thread Cameron Simpson
On 12Apr2015 09:21, Chris Angelico wrote: On Sun, Apr 12, 2015 at 9:08 AM, Cameron Simpson wrote: Catching all exceptions isn't terribly common, _except_ in service routines that wrap "unknown" operations. Classic example from my Asynchron class: [...] try: r

Re: try..except with empty exceptions

2015-04-11 Thread Cameron Simpson
On 12Apr2015 16:33, Cameron Simpson wrote: Finally, if we were to expunge support for "except:", one would also need a cast iron guarrentee that no exception could possibly occur which was not a subclass of BaseException. I'd expect that to mean that "raise" of a non-

Re: try..except with empty exceptions

2015-04-11 Thread Cameron Simpson
On 12Apr2015 14:18, Steven D'Aprano wrote: On Sun, 12 Apr 2015 09:08 am, Cameron Simpson wrote: Also, IMO, a bare "except:" syntax is far more pleasing to the eye than "except magic_exception_name_that+gets_everything:". And that is exactly what makes bare excep

Re: try..except with empty exceptions

2015-04-12 Thread Cameron Simpson
On 12Apr2015 17:00, Chris Angelico wrote: On Sun, Apr 12, 2015 at 4:33 PM, Cameron Simpson wrote: [...] That's what try/finally is for. You can do your cleanup without caring exactly what was raised. Hmm, yes. [...] However, my Asynchron class really is a little special. I use Asyn

Re: Regular Expression

2015-04-12 Thread Cameron Simpson
o fetch these items in an array? What you've got is ok. I would point out that as you're processing each line on its own you should not need "re.MULTILINE" in your .compile() call. Cheers, Cameron Simpson The upside of PHP is that it lets non-programmers create complex applications. The downside of PHP is that it lets non-programmers create complex applications. - Elliot Lee -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression

2015-04-12 Thread Cameron Simpson
On 12Apr2015 17:55, Pippo wrote: On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: It looks like it should, unless you have mangled your regular expression. [...] Also note that you can print the regexp's .pattern attribute: print(constraint.pattern) as a check that

Re: Regular Expression

2015-04-12 Thread Cameron Simpson
On 12Apr2015 18:28, Pippo wrote: On Sunday, 12 April 2015 21:21:48 UTC-4, Cameron Simpson wrote: [...] Pippo, please take a moment to trim the less relevant verbiage from the quoted material; it makes replies easier to read because what is left can be taken to be more "on point&quo

Re: installing error in python

2015-04-12 Thread Cameron Simpson
you used to obtain "python for 64 bit"? Cheers, Cameron Simpson There's no need to worry about death, it will not happen in your lifetime. - Raymond Smullyan -- https://mail.python.org/mailman/listinfo/python-list

Re: Importing/migrating Mailman mbox files into Google Groups?

2015-04-17 Thread Cameron Simpson
format is pretty simple. This page: https://developers.google.com/admin-sdk/groups-migration/v1/guides/manage-email-migrations#group_migration_media_upload which is linked to from your link seems to show an example. Cheers, Cameron Simpson Facts do not discourage the conspiracy-minded

Re: Importing/migrating Mailman mbox files into Google Groups?

2015-04-18 Thread Cameron Simpson
On 18Apr2015 07:50, Skip Montanaro wrote: On Fri, Apr 17, 2015 at 7:33 PM, Cameron Simpson wrote: However, before you get very excited see if people can get messages back out of the archive. A major annoyance for me with GGroups versus mailman is that if I join a group I cannot download the

Re: [SciPy-User] Is there existing code to log-with-bells-on for runtime algorithm diagnostics?

2015-04-21 Thread Cameron Simpson
ssing situations. Let me know if you want further information or the code. Cheers, Cameron Simpson If you give me six lines written by the most honest man, I will find something in them to hang him. - Cardinal Richilieu -- https://mail.python.org/mailman/listinfo/python-list

Re: [SciPy-User] Is there existing code to log-with-bells-on for runtime algorithm diagnostics?

2015-04-21 Thread Cameron Simpson
On 22Apr2015 10:50, Chris Angelico wrote: On Wed, Apr 22, 2015 at 10:11 AM, Cameron Simpson wrote: I have a context manager named "Pfx" which I use liberally in my code like this: from cs.logutils import Pfx, info def load(filename): with Pfx("loading %r", filen

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Cameron Simpson
d performance is simply amazing. OFFSET and \n are small details. The only comment I'd make at this point is to consider if you really need a single string at the end. Keeping it as a list of lines may be more flexible. (It will consume more memory.) If you're doing more stuff

Re: Rule of order for dot operators?

2015-05-18 Thread Cameron Simpson
g a new string which is a titlecased version of "slug". "slug.title().replace(...)" is an expression which _operates on_ that new string, _not_ on "slug". In particular, each .foo() need not return a string - it might return anything, and the following .bah() will work on that anything. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: 'NoneType' in contextmanager prevent proper RuntimeError to be raised

2015-05-20 Thread Cameron Simpson
h exactly the exception one might expect. To get "generator didn't yield" you need to actually have a generator. Eg: @contextlib.contextmanager def foo(): if false: yield Untested, though. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Camelot a good tool for me

2015-05-24 Thread Cameron Simpson
skills and/or lack of experience with it. Cheers, Cameron Simpson Ride to not crash. Dress to crash. Live to ride to not crash again. - Lawrence Smith, DoD#i, lawre...@msc.cornell.edu -- https://mail.python.org/mailman/listinfo/python-list

Re: Decoding JSON file using python

2015-05-27 Thread Cameron Simpson
uot;, line 19, in tdetails = data['Message'] TypeError: string indices must be integers, not str That will be because of this line: tdetails = data['Message'] because "data" is just the string from your dict. The JSON structure is valid as shown by http:

Re: assertRaises() help

2015-05-27 Thread Cameron Simpson
. From the docs maybe I should be using a "with" statement​. Unlikely. First, test your test by hand running: to_datetime('2015-02-29', coerce=False) _Does_ it raise ValueError? Cheers, Cameron Simpson Q: How many user support people does it take to change a light bulb?

Re: assertRaises() help

2015-05-27 Thread Cameron Simpson
On 27May2015 17:13, Vincent Davis wrote: On Wed, May 27, 2015 at 4:55 PM, Cameron Simpson wrote: First, test your test by hand running: to_datetime('2015-02-29', coerce=False) _Does_ it raise ValueError? ​Well that was not expected.​ Thanks See? If you'd just believed

Re: Decoding JSON file using python

2015-05-27 Thread Cameron Simpson
. Karthik, please correct the code below. Currently I do not get your exception, I get an exception from the JSON module parsing the "data" string. Code below, Cameron Simpson import json json_input = { "msgType": "0", "tid": "1",

Re: Using Python instead of Bash

2015-05-31 Thread Cameron Simpson
example this isn't a big deal because all the filenames are benign etc, but as a general rule using subprocess and passing explicit command line argument strings is safer. All of which you know, I know. But good to get it said in the thread. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to prevent zombie processes

2015-05-31 Thread Cameron Simpson
d you the programmer to be unaware of them). Anyway, that is simple and effective and immediate. Cheers, Cameron Simpson If everyone is thinking alike, then someone isn't thinking. - Patton -- https://mail.python.org/mailman/listinfo/python-list

Re: What sort of data structure to use?

2015-06-03 Thread Cameron Simpson
I would use a dict keyed on the path, whose values were a set of files. A set is a preprovided data type in Python. Look it up and use it. There are other alternatives, but that would be a first attempt. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Multiple thread program problem

2015-06-03 Thread Cameron Simpson
ode into its own function will (1) get rid of the global variables and (2) force you to consider exactly what you need to pass to "proc", and that will help reveal various logic issues. Cheers, Cameron Simpson How do you blip the throttle and wave? Do you blip it real high, then wave

Re: Find in ipython3

2015-06-03 Thread Cameron Simpson
op of the os.walk() function. Cheers, Cameron Simpson Perl combines all of the worst aspects of BASIC, C and line noise. - Keith Packard -- https://mail.python.org/mailman/listinfo/python-list

Re: Multiple thread program problem

2015-06-03 Thread Cameron Simpson
On 03Jun2015 19:59, M2 wrote: On Wednesday, June 3, 2015 at 7:38:22 PM UTC-5, Cameron Simpson wrote: I would be passing only "line" to proc, not "f" at all. Suggestion: move your main code into its own function. That will make all the variables in it "local". Y

Re: Find in ipython3

2015-06-03 Thread Cameron Simpson
On 04Jun2015 07:09, Cecil Westerhof wrote: Op Thursday 4 Jun 2015 04:54 CEST schreef Cameron Simpson: On 02Jun2015 18:13, Cecil Westerhof wrote: I am thinking about using ipython3 instead of bash. When I want to find a file I can do the following: !find ~ -iname '*python*.pdf' bu

Re: Multiple thread program problem

2015-06-04 Thread Cameron Simpson
On 04Jun2015 10:20, M2 wrote: Awesome Cameron. It works the way I want it to work. Glad to hear it. A few small remarks: Thanks a lot guys. Here is the new code: [...] from thread import start_new_thread You're not using this any more. You may want to tidy this up. def pro

Re: Find in ipython3

2015-06-04 Thread Cameron Simpson
x27;s objective, but I've certainly benefitted from writing my own version of things that already exist. Obviously you can't do that for everything, life is too short, but you can do it for things of interest and as a binus you can end up with a feature not available with the standard tool. C

Re: Find in ipython3

2015-06-04 Thread Cameron Simpson
On 04Jun2015 20:23, Michael Torrie wrote: On 06/04/2015 05:04 PM, Cameron Simpson wrote: On 04Jun2015 13:09, Michael Torrie wrote: Why not use Python for what it's good for and say pipe the results of find into your python script? Reinventing find poorly isn't going to buy yo

Re: Using "import math".

2015-06-06 Thread Cameron Simpson
xample piece of code showing the problem so that others can run it. Please also post the error message; if it is a stack trace, include the full stack trace. Thanks, Cameron Simpson [The Press] had tried to contact usenet but that no one had been available for comment. That's odd, I tho

Re: Find in ipython3

2015-06-07 Thread Cameron Simpson
g for I/O or the CPU will also perturb things). One the topic of multiple runs, have a look at the timeit module, psecificly designed for testing code with multiple runs. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Query regarding sys.stdout.write

2015-06-07 Thread Cameron Simpson
prefix with the new line, and emit only the change. Cheers, Cameron Simpson The worst tyrannies were the ones where a governance required its own logic on every embedded node. - Vernor Vinge -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a mail list like python-list in c?

2015-06-07 Thread Cameron Simpson
ng in c? Well there is the comp.lang.c newsgroup. Not a mailing list, but similar. BTW excuse my bad English. Your English is better than my own poor second language. Cheers, Cameron Simpson We're lost, but we're making good time. -- https://mail.python.org/mailman/listinfo/python-list

Re: Query regarding sys.stdout.write

2015-06-07 Thread Cameron Simpson
erminal. Of course, reaching for the curses module is massive overkill in a sense, but it is the only way to consult terminfo in the Python stdlib. See "man terminfo" for details on what terminal capabilities the terminfo database describes. Cheers, Cameron Simpson But I have to s

Re: Set a flag on the function or a global?

2015-06-16 Thread Cameron Simpson
can import "edir" or "edir_" as dir as they see fit. Besides, apart from the inspect module, which probably shouldn't, who uses dir() programmatically? Directly, perhaps rarely. But I use my O.__str__ method implicitly quite a lot, and it has a similar purpose to your edir.

Re: Catching exceptions with multi-processing

2015-06-19 Thread Cameron Simpson
he queue for logging and other handling. Obviously you might return something more sophisticated that my simple tuple above, but I'm sure you get the idea. Cheers, Cameron Simpson He's silly and he's ignorant, but he's got guts, and guts is enough. - Sgt. Hartmann -- https://mail.python.org/mailman/listinfo/python-list

Re: Readline -- cannot bind to both Ctrl-tab and tab at the same time?

2015-06-29 Thread Cameron Simpson
me-terminal or Konsole probably threw that stuff out as they threw out all the other normal X11 config hooks, and doubtless use their own arcane system. Enjoy. Cheers, Cameron Simpson The top three answers: Yes I *am* going to a fire! Oh! We're using *kilometers*

Re: Python 3 resuma a file download

2015-06-30 Thread Cameron Simpson
e and scroll up you will find example code doing that kind of thing in the examples above. Cheers, Cameron Simpson The British Interplanetary Society? How many planets are members then? - G. Robb -- https://mail.python.org/mailman/listinfo/python-list

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