Re: subprocess.Popen instance hangs

2013-08-29 Thread Tim Johnson
* Tim Johnson [130829 10:51]: > using Python 2.7.1 on OS X 10.7.5 > > I'm managing a process of drush using an instance of subprocess.Popen <...> ## This appears to be what works. def __exec(self,args) : """Run the process with arguments"&q

Re: subprocess.Popen instance hangs

2013-08-30 Thread Tim Johnson
* Nobody [130830 06:55]: > On Thu, 29 Aug 2013 17:00:21 -0800, Tim Johnson wrote: > > > ## This appears to be what works. > > def __exec(self,args) : > > """Run the process with arguments""" > >p = > >s

Re: subprocess.Popen instance hangs

2013-08-30 Thread Tim Johnson
* Jerry Hill [130830 07:48]: > On Fri, Aug 30, 2013 at 11:32 AM, Tim Johnson wrote: > > The objective is to display all output, but to also separate error > > messages from normal output. > > I still think you want to use communicate(). Like this: > > p = s

Re: Encapsulation unpythonic?

2013-08-31 Thread Tim Delaney
ast the Object reference 'a' or use reflection to call methods on it or access it's members (think of it as Python does reflection automatically for you). Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: argparse - specify order of argument parsing?

2013-08-31 Thread Tim Chase
On 2013-08-31 13:11, Eduardo Alvarez wrote: > When using argparse, is there a way to specify in what order > arguments get parsed? I am writing a script whose parameters can be > modified in the following order: > > Defaults -> config file -> command-line switches. > > However, I want to give the

Re: Encapsulation unpythonic?

2013-09-01 Thread Tim Delaney
nk Roy is referring to the fact that attribute access is implemented via __getattr__ / __getattribute__ / __setattr__ / __delattr__. From one point of view, he's absolutely correct - nearly all attributes are accessed via getters/setters in Python. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

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

2013-09-01 Thread Tim Chase
On 2013-09-01 17:03, [email protected] wrote: > Hello everybody > I'm trying to run this: > > > >>> a = 'E:\Dropbox\jjfsdjjsdklfj\sdfjksdfkjslkj\flute.wav' > >>> a.split('\') > > SyntaxError: EOL while scanning string literal > > > I think that the character '\' is the problem, but unfortu

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

2013-09-01 Thread Tim Chase
On 2013-09-02 10:23, Cameron Simpson wrote: > | I also want to know how to mirror a character, in my case this > | one ©, because I'll use the Copyleft > http://en.wikipedia.org/wiki/Copyleft | to distribute my app. > > Isn't that a copyright symbol? I'd have a look at the "uncidoedata" > module,

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

2013-09-01 Thread Tim Roberts
;>> os.path.split(a)[1] 'flute.wav' >>> >I also want to know how to mirror a character, in my case this one ©, >because I'll use the Copyleft http://en.wikipedia.org/wiki/Copyleft >to distribute my app. You can't "mirror" a charac

Re: semicolon at end of python's statements

2013-09-02 Thread Tim Chase
On 2013-09-02 14:20, Grant Edwards wrote: > >> This saves an indent level. > > > > Just out of interest: is saving an indent level a useful thing? > > Perhaps he's worried about the world running out of tabs? > > I heard that most of the tab mines are in China and they're going to > stop exportin

Re: semicolon at end of python's statements

2013-09-02 Thread Tim Chase
On 2013-09-02 10:47, Roy Smith wrote: > > > Perhaps he's worried about the world running out of tabs? > > > > > > I heard that most of the tab mines are in China and they're > > > going to stop exporting... > > > > And buying all that indentation supports terrorists. Conserve > > whitespace or t

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

2013-09-03 Thread Tim Chase
On 2013-09-03 02:06, Steven D'Aprano wrote: >> So the real bug is with the parser. > > It is likely that nobody noticed this bug in the first place > because the current behaviour doesn't matter for regexes, which is > the primary purpose of raw strings. You can't end a regex with an > unescaped b

Re: can't find win32api from embedded pyrun call

2013-09-04 Thread Tim Golden
On 03/09/2013 21:50, David M. Cotter wrote: > I find i'm having this problem, but the solution you found isn't > quite specific enough for me to be able to follow it. > > I'm embedding Python27 in my app. I have users install > ActivePython27 in order to take advantage of python in my app, so the

Dealing with \r in CSV fields in Python2.4

2013-09-04 Thread Tim Chase
I've got some old 2.4 code (requires an external lib that hasn't been upgraded) that needs to process a CSV file where some of the values contain \r characters. It appears that in more recent versions (just tested in 2.7; docs suggest this was changed in 2.5), Python does the Right Thing™ and just

Re: Dealing with \r in CSV fields in Python2.4

2013-09-04 Thread Tim Chase
On 2013-09-04 10:20, Skip Montanaro wrote: > > _csv.Error: newline inside string > > How are the lines actually terminated, with \r\n or with just \n? If > it's just \n, what happens if you specify \n as the line terminator? Unfortunately, the customer feed contains DOS newlines ("\r\n"). I'm

Re: Dealing with \r in CSV fields in Python2.4

2013-09-04 Thread Tim Chase
On 2013-09-04 16:31, MRAB wrote: > You could try replacing the '\r' with another character that doesn't > appear elsewhere and then change it back afterwards. > > MARKER = '\x01' > > def cr_to_marker(f): > for line in f: > yield line.replace('\r', MARKER) > > def marker_to_cr(item)

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

2013-09-05 Thread Tim Roberts
ward and backward slashes interchangably. It is only the command interpreter that requires the backslash. -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question related to Boolean in Python

2013-09-05 Thread Tim Roberts
sume (with no evidence) that the "dead" function calls sys.exit, which kills the program. In that case, this makes a little bit of sense. The first time you type "taunt bear", bear_moved is set True and the loop runs again. If you type "taunt bear" a second time, then th

Re: PEP8 79 char max

2013-09-06 Thread Tim Chase
On 2013-09-06 05:09, Skip Montanaro wrote: > And thank goodness for SIGWINCH. :-) BEDEVERE: How do you know she is a SIGWINCH? VILLAGER: She looks like one. CROWD: Right! Yeah! Yeah! :-) I'm just glad it's no longer 40-chars-per-column and purely upper-case like the Apple ][+ on which I cut m

Re: PEP8 79 char max

2013-09-06 Thread Tim Delaney
On 6 September 2013 20:35, Tim Chase wrote: > On 2013-09-06 05:09, Skip Montanaro wrote: > > And thank goodness for SIGWINCH. :-) > > BEDEVERE: How do you know she is a SIGWINCH? > > VILLAGER: She looks like one. > > CROWD: Right! Yeah! Yeah! > > > :-) >

Re: PEP8 79 char max

2013-09-06 Thread Tim Chase
On 2013-09-06 20:47, Tim Delaney wrote: > On 6 September 2013 20:35, Tim Chase wrote: > > I'm just glad it's no longer 40-chars-per-column and purely > > upper-case like the Apple ][+ on which I cut my programming teeth. > > Couldn't you switch the ][+ into hig

Re: Tryign to send mail via a python script by using the local MTA

2013-09-16 Thread Tim Chase
On 2013-09-17 00:15, Ferrous Cranus wrote: >>> X-AntiAbuse: This header was added to track abuse, please include >>> it with any abuse report X-AntiAbuse: Primary Hostname - >>> my.superhost.gr >>> X-AntiAbuse: Original Domain - superhost.gr >>> X-AntiAbuse: Originator/Caller UID/GID - [500 501] /

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Tim Chase
On 2013-09-17 16:21, Ferrous Cranus wrote: > I just want to say tot he program that > > that only run the for statement if and only if person=='George' > > I dont see nay reason as to why this fails > > perhaps like: > > for times in range(0, 5) if person=='George': > > but that fails too... >

Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Tim Chase
On 2013-09-20 02:58, Aseem Bansal wrote: > I started Python 4 months ago. Largely self-study with use of > Python documentation, stackoverflow and google. I was thinking what > is the minimum that I must know before I can say that I know Python? It's a fuzzy line. A good while back, there was a t

Re: Print statement not printing as it suppose to

2013-09-20 Thread Tim Delaney
red is %s" % (total,)) which will produce the same output on both Python 2 and Python 3. Note the double space before %s - that matches your print statement (there would be soft-space inserted in your print statement, which is another reason not to rely on print for anything other th

Re: What's the best way to extract 2 values from a CSV file from each row systematically?

2013-09-23 Thread Tim Chase
On 2013-09-23 10:10, [email protected] wrote: > based on two values I want to extract from a CSV file. The > CSV has at least 1000 rows, an example: > > 0,0,KGD,0,DME,0,,0,0 [snip] > I'd like to automatically go through each row in the CSV file from > beginning to end to extract the two va

Re: removing BOM prepended by codecs?

2013-09-24 Thread Tim Golden
On 24/09/2013 14:01, J. Bagg wrote: > I'm using: > > outputfile = codecs.open (fn, 'w+', 'utf-8', errors='strict') Well for the life of me I can't make that produce a BOM on 2.7 or 3.4. In other words: import codecs with codecs.open("temp.txt", "w+", "utf-8", errors="strict") as f: f.write("a

Re: Referrer key missing form os.environ dictionary?

2013-09-25 Thread Tim Chase
On 2013-09-25 14:18, John Gordon wrote: > However, if the user did not arrive from another page, then > HTTP_REFERER will be missing. This happens when the user types the > web address directly into their browser, or clicks on a bookmark, > or many other ways. > > Also, obviously, it's up to the

Re: Referrer key missing form os.environ dictionary?

2013-09-25 Thread Tim Chase
On 2013-09-25 18:02, Νίκος wrote: > This indeed works now: > > ref = os.environ.get('HTTP_REFERER', 'Άγνωστο Ref') > > but iam wondering why this doesnt work also: > > ref = os.environ('HTTP_REFERER') > > Shouldnt both work? No...that calls os.environ. You likely *mean* ref = os.environ['H

Re: Referrer key missing form os.environ dictionary?

2013-09-25 Thread Tim Chase
On 2013-09-25 18:16, Νίκος wrote: > how caom the http_referer thing works ok now but when i just print > all the key listing of .os.environ ket the http_referer key isnt > inside? Well, first off, it's entirely possible (based on reading that paragraph) that you typed something wrong. That said,

Re: Convert namedtuple to dictionary

2013-09-25 Thread Tim Chase
On 2013-09-25 15:45, [email protected] wrote: > Say, I have a namedtuple like this: > > {'a': brucelee(x=123, y=321), 'b': brucelee('x'=123, 'y'=321) > > I need to convert it to: > > {'a': {'x':123, 'y': 321},'b': {'x':123, 'y': 321}} While it uses the "private" member-variable "_fields", you c

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Tim Golden
On 26/09/2013 09:41, Chris Angelico wrote: > On Thu, Sep 26, 2013 at 6:12 PM, Jussi Piitulainen > wrote: >> Do you know that you can ask for help({}.get) or help(dict.get) or >> even help(os.environ.get) during such an interactive Python session, >> and Python (unlike Macbeth's spirits from the va

Re: Convert namedtuple to dictionary

2013-09-26 Thread Tim Chase
On 2013-09-26 01:08, Steven D'Aprano wrote: > On Wed, 25 Sep 2013 18:41:25 -0500, Tim Chase wrote about > namedtuple: > > > While it uses the "private" member-variable "_fields", you can do > > It's not actually private! > > namedtup

Re: Convert namedtuple to dictionary

2013-09-26 Thread Tim Chase
On 2013-09-26 16:42, Virendra Tripathi wrote: > Thx Tim. Your solution works. After Steven's reply, I recommend dict((k,v._asdict()) for k,v in d.iteritems()) which simplifies matters. -tkc -- https://mail.python.org/mailman/listinfo/python-list

walking a heapq nondestructively without duplicating?

2013-09-27 Thread Tim Chase
I've got a large heapq'ified list and want to walk it in-order without altering it. I get the "unsorted" heap'ish results if I just do from heapq import heappush, heappop, nlargest, nsmallest my_heap = [] for thing in lots_of_items(): heappush(thing) for item in my_heap: ... To g

Re: replace only full words

2013-09-28 Thread Tim Chase
On 2013-09-28 09:11, cerr wrote: > I have a list of sentences and a list of words. Every full word > that appears within sentence shall be extended by i.e. "I > drink in the house." Would become "I in the ." (and > not "I in the .") This is a good place to reach for regular expressions. It com

Re: replace only full words

2013-09-28 Thread Tim Chase
[mercy, you could have trimmed down that reply] On 2013-09-28 10:43, cerr wrote: > On Saturday, September 28, 2013 4:54:35 PM UTC, Tim Chase wrote: >> import re > > Great, only I don't have the re module on my system :( Um, it's a standard Python library. You

Re: card dealer

2013-09-28 Thread Tim Roberts
gt;disaster. That's exactly the problem. Because the number of permutations is limited, once you know the first 28 cards, you can uniquely identify the permutation you started with, and that's enough to get the entire sequence. Now, it's going to take a hell of a lot of memory to s

Re: Do I really need a web framework?

2013-09-30 Thread Tim Delaney
ct? > > What do you suggest, keeping in mind that I am a newbie and that my > website project would be very simple and very small? > There is no *need* to use a web framework. But a web framework can make things a lot easier for you. Have a look at webapp2: http://webapp-impro

Re: Functional Programming and python

2013-09-30 Thread Tim Chase
On 2013-09-30 19:04, Franck Ditter wrote: > two points make me crazy : > 1. Tail recursion is not optimized. We are in 2013, why ? This is > known technology (since 1960). And don't answer with "good > programmers don't use recursion", I seem to recall hearing that the primary reason it hadn't bee

Re: JUST GOT HACKED

2013-10-01 Thread Tim Chase
Daniel, I'm sorry your initial interactions with the list were tainted by this experience. Modulo these degenerative threads (usually started by Nikos), it *really* is a helpful and friendly place. On 2013-10-02 00:24, Daniel Stojanov wrote: > 2) I just signed up the this mailing list. To the re

Re: JUST GOT HACKED

2013-10-01 Thread Tim Delaney
I'm not going to risk it by going there to check myself ... Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: JUST GOT HACKED

2013-10-01 Thread Tim Delaney
abase. And of course your database is so well locked down that no attacker with a login to it could then execute arbitrary code on your system. And there's also zero chance that your personal account login details are also available in plaintext somewhere that you're unaware of. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: JUST GOT HACKED

2013-10-01 Thread Tim Chase
On 2013-10-02 09:48, Tim Delaney wrote: > Because there's no chance with the brilliance you display that > there could be any possibility of login details being kept in > plaintext in your database. > > And of course your database is so well locked down that no attacker > w

Re: Killing threads with TB (was: Can arbitrary code run in a server if someone's know just the MySQL password?)

2013-10-02 Thread Tim Chase
On 2013-10-02 05:38, [email protected] wrote: > (Hey Thunderbird has a very useful new feature. Ignore thread.) Unfortunately, as of when I last tested it, it only works in the newsgroup part of TB, not the mail portion of TB. Sadly, Claws-Mail (my current mailer) doesn't have a native kill-thr

Re: JUST GOT HACKED

2013-10-02 Thread Tim Chase
On 2013-10-02 13:43, Νίκος wrote: > 2. Still feel that that the solution provided to me doesn't meet my > needs and should have been re-written in a different way. This is part of the trouble people had recently in the IP-address/default-value thread. Python has what folks here call a "pythonic"

Re: feature requests

2013-10-03 Thread Tim Chase
On 2013-10-04 02:21, Chris Angelico wrote: > > workers = [] > > for params in whatever: > > thread = threading.Thread(params) > > thread.start() > > workers.append(thread) > > You could shorten this by iterating twice, if that helps: > > worke

Re: how to read list from file

2013-10-05 Thread Tim Chase
On 2013-10-05 18:08, Harvey Greenberg wrote: > I am looping as for L in file.readlines(), where file is csv. > > L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that > the first item is a dir and 2nd is a list, so parsing with split > doesn't work. Is there a way to convert L, whic

Re: Goodbye: was JUST GOT HACKED

2013-10-07 Thread Tim Chase
On 2013-10-07 12:26, Walter Hurry wrote: > The 'Goodbye' post was made in rather a fit of pique, for which I > apologise. If I am allowed a second chance, there is actually > something puzzling me at the moment. It's a UnicodeDecodeError, but > I shall start a separate thread about it. Indeed, th

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Tim Chase
On 2013-10-08 15:36, Denis McMahon wrote: > On Tue, 08 Oct 2013 08:33:48 -0400, Roy Smith wrote: > > In the old days, it used to be /usr/dict/words. Port Python to > > v6, and save another 6 characters :-) > > Doesn't matter where it is, a link to it exists at "/w" now ;) You prodigal...wasting

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Tim Chase
On 2013-10-08 17:17, Chris Angelico wrote: > Who's up for some fun? Implement an XKCD-936-compliant password > generator in Python 3, in less code than this: > > print(*__import__("random").sample(open("/usr/share/dict/words").read().split("\n"),4)) > > Second challenge: Use it for generating all

Re: Cookie gets changed when hit comes from a referrer

2013-10-09 Thread Tim Chase
On 2013-10-09 19:28, Mark Lawrence wrote: > On 09/10/2013 19:06, Denis McMahon wrote: >> Find the relevant forums and ask in them. > > Why am I thinking of this > http://en.wikipedia.org/wiki/There%27s_a_Hole_in_My_Bucket ? There's a bug in my program, dear newsgroup, dear newsgroup, There's a b

Learning about HTTP [was: Cookie gets changed when hit comes from a referrer]

2013-10-10 Thread Tim Golden
On 10/10/2013 00:48, Steven D'Aprano wrote: > So, for the benefit of anyone, not just Nikos, who wants to learn about > how browsers connect to web sites and how to run a web server, does > anyone have any recommendation for tutorials, mailing lists, web forums > or books which are suitable? Pre

Re: I am never going to complain about Python again

2013-10-10 Thread Tim Chase
On 2013-10-10 12:10, MRAB wrote: > Re "==", this page: > > http://php.net/manual/en/language.operators.comparison.php > > states: > > """If you compare a number with a string or the *comparison involves > numerical strings*, then each string is converted to a number and > the comparison per

Re: Consolidate several lines of a CSV file with firewall rules

2013-10-11 Thread Tim Chase
On 2013-10-11 08:01, Starriol wrote: > NO.;NAME;SOURCE;DESTINATION;VPN  ;SERVICE;ACTION;TRACK;INSTALL > ON;TIME;COMMENT > 1;;fwxcluster;mcast_vrrp;;vrrp;accept;Log;fwxcluster;Any;"VRRP;;*Comment > suppressed* ;igmp**; > 2;;fwxcluster;fwxcluster;;FireWall;accept;Log;fwxcluster;Any;"Managemen

Re: Consolidate several lines of a CSV file with firewall rules [PS]

2013-10-11 Thread Tim Chase
On 2013-10-11 15:40, Tim Chase wrote: > the dangling open-quotes on #1 that cause most CSV parsers to read > until the subsequent line is read. And by "subsequent line", I mean "subsequent closing-quote" of course. :-) -tkc -- https://mail.python.org/mailman/listinfo/python-list

Re: converting letters to numbers

2013-10-13 Thread Tim Roberts
% Process i1 = (c1 + c2) % 26 % Encode return chr(i1+65) Or, as a one-liner: A = ord('A') def add(c1, c2): return chr((ord(c1)-A + ord(c2)-A) % 26 + A) -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- https://mail.python.org/mailman/listinfo/python-list

Re: Query on Python Compiled source--Urgent

2013-10-14 Thread Tim Golden
On 14/10/2013 06:41, chandan kumar wrote: > I'm working on a python project for protocol testing.I need to provide > only python compiled source to our customer. > > Here are the steps followed to take python compiled from actual source. > 1.There are 5 different test suites under the project > 2.

Re: Query on Python Compiled source--Urgent

2013-10-14 Thread Tim Golden
[Please post your answer below the previous reply, not above] [... snip most of original traceback ...] > File "C:\Python27\lib\site-packages\pyExcelerator\CompoundDoc.py", > line 554, in save > f = file(filename, 'wb') > IOError: [Errno 22] invalid mode ('wb') or filename: > '.\\TestResults

Re: Python was designed (was Re: Multi-threading in Python vs Java)

2013-10-15 Thread Tim Chase
On 2013-10-16 06:09, Chris Angelico wrote: > > "xyz" - "abc"; > (1) Result: "xyz" > > "cba" - "abc"; > (2) Result: "cba" > > "abcdabc" - "abc"; > (3) Result: "d" > > Every instance of the subtracted-out string is removed. It's > something like x.remove(y) in many other languages. Or as one

Re: urllib2 timeout issue

2013-10-16 Thread Tim Chase
On 2013-10-16 13:22, Peter Otten wrote: > The problem might be ipv6-related. I second this as the likely culprit -- I've had to disable IPv6 on my Debian laptop since my AT&T router is brain-dead and doesn't seem to support it, so I would often get timeouts similar to what is the OP describes and

Re: Sexism in the Ruby community: how does the Python community manage it?

2013-10-17 Thread Tim Delaney
laims to prefer an language named after a fish :-) > That would be https://en.wikipedia.org/wiki/Monty_Python not https://en.wikipedia.org/wiki/Pythonidae. The snake has been adopted as a mascot (see the Python icon) but is not the inspiration. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: Error Testing

2013-10-19 Thread Tim Chase
On 2013-10-19 14:08, David Robinow wrote: > On Sat, Oct 19, 2013 at 9:01 AM, Chris Angelico wrote: >> You can try all these out in the interactive interpreter (you >> probably have IDLE installed, which on Windows is rather nicer to >> work with than the default interactive mode). > > IDLE is cr

Re: Changing the terminal title bar with Python

2013-10-19 Thread Tim Roberts
installed py32win, which virtually every Windows Python user does: import win32console win32console.SetConsoleTitle(msg) -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- https://mail.python.org/mailman/listinfo/python-list

Re: converting letters to numbers

2013-10-19 Thread Tim Roberts
Steven D'Aprano wrote: >On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote: > >> def add(c1, c2): >> % Decode >>... >Python uses # for comments, not %, as I'm sure you know. What language >were you thinking off when you wrote the above? Pss

Re: What's wrong with Windows Command Prompt (was Re: Error Testing)

2013-10-21 Thread Tim Chase
On 2013-10-21 15:55, David Robinow wrote: > I wasn't aware that the interactive interpreter on Linux had > features that the Windows version didn't. I'm curious what those > features might be. It's mostly the benefits that come from being built with the readline library, meaning you get - command

Re: Will Python 3.x ever become the actual standard?

2013-10-23 Thread Tim Golden
On 23/10/2013 14:05, Colin J. Williams wrote: > On 23/10/2013 8:35 AM, Mark Lawrence wrote: >> On 23/10/2013 12:57, [email protected] wrote: >>> Years have passed, and a LARGE number of Python programmers has not >>> even bothered learning version 3.x. >> >> The changes aren't large enough to worry

Re: Will Python 3.x ever become the actual standard?

2013-10-23 Thread Tim Golden
On 23/10/2013 14:52, Skip Montanaro wrote: >> Thankfully I am. I confess I don't understand how *nix people endure having >> to compile code instead of having a binary install. To me it's like going >> to the garage to buy a new car, being shown the parts and the tool kit and >> being told to get

Re: Will Python 3.x ever become the actual standard?

2013-10-23 Thread Tim Golden
On 23/10/2013 15:34, Skip Montanaro wrote: > Tim: > >> Disregarding Mark's tongue-in-cheek rhetoric for now... perhaps you >> didn't realise that, on Windows, you can't pip install a binary > > Mark: > >> Which on Windows often ends up telling you

Reading From stdin After Command Line Redirection

2013-10-23 Thread Tim Daneliuk
I have a program that runs like this: foo.py https://mail.python.org/mailman/listinfo/python-list

Re: Reading From stdin After Command Line Redirection

2013-10-23 Thread Tim Daneliuk
ws up as a handle to the file and there is no way to retrieve/reset it its default association with the tty/pty. Since python is layered on top of this, I expect the same would be the case here as well. -- ----

Re: Reading From stdin After Command Line Redirection

2013-10-23 Thread Tim Daneliuk
elist ... -- ---- Tim Daneliuk [email protected] PGP Key: http://www.tundraware.com/PGP/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Reading From stdin After Command Line Redirection

2013-10-23 Thread Tim Daneliuk
elist ... -- ---- Tim Daneliuk [email protected] PGP Key: http://www.tundraware.com/PGP/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Reading From stdin After Command Line Redirection

2013-10-24 Thread Tim Chase
On 2013-10-24 14:53, Ben Finney wrote: > I think the request is incoherent: If you want to allow the user to > primarily interact with the program, this is incompatible with also > wanting to redirect standard input. As a counter-example, might I suggest one I use regularly: gimme_stuff_on_stdo

Re: Reading From stdin After Command Line Redirection

2013-10-24 Thread Tim Daneliuk
On 10/23/2013 11:54 PM, Ben Finney wrote: we don't welcome ableist (nor sexist) behaviour. Well now I just feel so very awful ... -- ---- Tim Daneliuk [email protected] PGP Key: http://www.tundrawar

Re: Reading From stdin After Command Line Redirection

2013-10-24 Thread Tim Daneliuk
On 10/24/2013 07:10 AM, Oscar Benjamin wrote: On 24 October 2013 12:58, Tim Daneliuk wrote: On 10/23/2013 11:54 PM, Ben Finney wrote: we don't welcome ableist (nor sexist) behaviour. Well now I just feel so very awful ... Please end this line of discussion. Ben is right: your commen

Re: Reading From stdin After Command Line Redirection

2013-10-24 Thread Tim Daneliuk
On 10/24/2013 09:36 AM, [email protected] wrote: Am Donnerstag, 24. Oktober 2013 15:41:52 UTC+2 schrieb Tim Daneliuk: On 10/24/2013 07:10 AM, Oscar Benjamin wrote: On 24 October 2013 12:58, Tim Daneliuk wrote: On 10/23/2013 11:54 PM, Ben Finney wrote: we don't welcome ableist (nor s

Re: Unlimited canvas painting program

2013-10-24 Thread Tim Chase
On 2013-10-24 12:16, [email protected] wrote: > How to create a program similar to paint, but the difference would > be that the cursor would be always in the middle and the canvas > moves or the camera is always fixed on the cursor as it moves > around the canvas. And the canvas should be infini

Re: Unlimited canvas painting program

2013-10-24 Thread Tim Chase
On 2013-10-24 21:51, Grant Edwards wrote: > > To hold an (effectively) infinite *bitmap* canvas, you'd > > (effectively) need an (effectively) infinite amount of memory. > > Sparse arrays allow it to be sort-of implemented as long as most of > the bitmap is "empty". Fair enough. Raw bitmap can

decorators and mangled names for "private" methods

2013-10-25 Thread Tim Chase
Given the following example 2.7 code: from functools import wraps class require_keys: def __init__(self, *keys): self.keys = keys def __call__(decorator_self, fn): @wraps(fn) def result_fn(method_self, *args, **kwargs): # import pdb; pdb.set_trace() req = method_self.__

Re: Python Front-end to GCC

2013-10-25 Thread Tim Delaney
as I'm now starting to suspect, possibly a bot, but I'll give him (it?) this one chance to show the capability to read and learn. http://en.wikipedia.org/wiki/Hexspeak Search for 0xBAADF00D; 0xBADDCAFE; and (in particular) OxDEADBEEF. These are historical examples of this techniqu

Re: Python Front-end to GCC

2013-10-25 Thread Tim Delaney
after 4 hours sleep - my apologies to the list). Anyway, not going to get sucked into this bottomless hole. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: Obfuscated factorial

2013-10-26 Thread Tim Chase
On 2013-10-27 00:26, Chris Angelico wrote: > On Sat, Oct 26, 2013 at 11:50 PM, Vito De Tullio > wrote: > > you miss a FactoryFactory and a couple of *Manager. > > > > Oh, and it should be xml-config-driven. > > Or a metaclass and a few decorators. They're inherently Pythonic, > right? You are de

Re: decorators and mangled names for "private" methods

2013-10-26 Thread Tim Chase
On 2013-10-25 22:01, Peter Otten wrote: > > from functools import wraps > > class require_keys: > > def __init__(self, *keys): > > self.keys = keys > > def __call__(decorator_self, fn): > > @wraps(fn) > > def result_fn(method_self, *args, **kwargs): > > # import pdb; pdb.set_t

Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-26 Thread Tim Chase
On 2013-10-26 22:24, Steven D'Aprano wrote: > Why on earth would you want to throw away perfectly good > information? The main reason I've needed to do it in the past is for normalization of search queries. When a user wants to find something containing "pingüino", I want to have those results c

Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-26 Thread Tim Chase
On 2013-10-26 21:54, Roy Smith wrote: > In article , > Tim Chase wrote: >> I'd be just as happy if Python provided a "sloppy string compare" >> that ignored case, diacritical marks, and the like. > > The problem with putting fuzzy matching in the core

Re: Check if this basic Python script is coded right

2013-10-27 Thread Tim Delaney
en 0-201" (inclusive) then whoever fixes it might naively just add one to the existing code, giving an incorrect result. Obviously I'm ignoring the possibility of appropriate unit tests to prevent this - just looking at the code itself. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-28 Thread Tim Chase
On 2013-10-28 07:01, [email protected] wrote: >> Simply ignoring diactrics won't get you very far. > > Right. As an example, these four French words : > cote, côte, coté, côté . Distinct words with distinct meanings, sure. But when a naïve (naive? ☺) person or one without the easy ability to e

Re: How do I update a virtualenv?

2013-10-28 Thread Tim Chase
On 2013-10-29 11:42, Ben Finney wrote: > You are keeping your virtualenv separate from your working tree, > right? This was one of the key bits I missed in most of the virtualenv{,wrapper} documentation and only figured out after asking several questions here on c.l.p Once I had that understandin

Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-29 Thread Tim Chase
On 2013-10-29 08:38, [email protected] wrote: > >>> import timeit > >>> timeit.timeit("a = 'hundred'; 'x' in a") > 0.12621293837694095 > >>> timeit.timeit("a = 'hundreij'; 'x' in a") > 0.26411553466961735 That reads to me as "If things were purely UCS4 internally, Python would normally take 0

stacked decorators and consolidating

2013-10-29 Thread Tim Chase
I've got some decorators that work fine as such: @dec1(args1) @dec2(args2) @dec3(args3) def myfun(...): pass However, I used that sequence quite a bit, so I figured I could do something like dec_all = dec1(args1)(dec2(args2)(dec3(args3))) to consolidate the whole mess down to @

Re: stacked decorators and consolidating

2013-10-29 Thread Tim Chase
On 2013-10-29 17:42, MRAB wrote: > If you apply the stacked decorators you get: > > myfun = dec1(args1)(dec2(args2)(dec3(args3)(myfun))) > > If you apply dec_all you get: > > myfun = dec1(args1)(dec2(args2)(dec3(args3)))(myfun) > > See the difference? You need the lambda to fix that.

Re: RELEASED: Python 2.6.9 final

2013-10-29 Thread Tim Chase
On 2013-10-29 13:48, Barry Warsaw wrote: > All maintenance of Python 2.6, including for security issues, has > now ended. > > So too has my latest stint as Python Release Manager. I'm sorry to see you step down, but am thankful for your many years of solid work. Wishing you the best, -tkc -

Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Tim Roberts
ke it part of the syntax? That way, you don't accidentally have the indentation not match the syntax. -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- https://mail.python.org/mailman/listinfo/python-list

Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Tim Delaney
o this on truly random data, you're probably wrong - either your data is has patterns the algorithm can exploit, or you've simply been lucky with the randomness of your data so far. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: personal library

2013-10-30 Thread Tim Delaney
extensively used the top two contenders (Git and Mercurial) I would strongly advise you to use Mercurial. What it comes down to for me is that Mercurial usage fits in my head and I rarely have to go to the docs, whereas with Git I have to constantly go to the docs for anything but the most tri

Re: personal library

2013-10-30 Thread Tim Delaney
On 31 October 2013 08:31, Chris Angelico wrote: > On Thu, Oct 31, 2013 at 7:19 AM, Tim Delaney > wrote: > > What it comes down to for me is that Mercurial usage fits in my head and > I > > rarely have to go to the docs, whereas with Git I have to constantly go > to >

Re: personal library

2013-10-30 Thread Tim Delaney
On 31 October 2013 08:43, Tim Delaney wrote: > On 31 October 2013 08:31, Chris Angelico wrote: > >> On Thu, Oct 31, 2013 at 7:19 AM, Tim Delaney >> wrote: >> > What it comes down to for me is that Mercurial usage fits in my head >> and I >> > rarely

Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Tim Chase
On 2013-10-30 21:30, Joshua Landau wrote: > started talking about compressing *random data* If it's truly random bytes, as long as you don't need *the same* random data, you can compress it quite easily. Lossy compression is acceptable for images, so why not random files? :-) import os inn

Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-31 Thread Tim Chase
On 2013-10-30 19:28, Roy Smith wrote: > For example, it's reasonable to consider any vowel (or string of > vowels, for that matter) to be closer to another vowel than to a > consonant. A great example is the word, "bureaucrat". As far as > I'm concerned, it's spelled {b, vowels, r, vowels, c, r,

<    19   20   21   22   23   24   25   26   27   28   >