Re: PEP8 79 char max

2013-07-31 Thread Tim Chase
On 2013-07-31 16:32, Grant Edwards wrote: > On 2013-07-31, Tim Chase wrote: > > I interpret Grant's statement as wanting the "table" to look like > > > > for name, value, description in ( > > ("cost", 42, "How much it cost&qu

Re: PEP8 79 char max

2013-07-31 Thread Tim Chase
On 2013-07-31 16:32, Grant Edwards wrote: > On 2013-07-31, Tim Chase wrote: > > I interpret Grant's statement as wanting the "table" to look like > > > > for name, value, description in ( > > ("cost", 42, "How much it cost&qu

Re: PEP8 revised: max line lengths

2013-08-01 Thread Tim Chase
On 2013-08-01 15:52, Terry Reedy wrote: > Newly revised this morning: > http://www.python.org/dev/peps/pep-0008/#maximum-line-length > > The diff with all the changes is here > http://hg.python.org/peps/rev/fb24c80e9afb Just a quick spelling fix of s/experimants/experiments/ at http://hg.pyth

Re: Python performance

2013-08-02 Thread Tim Chase
On 2013-08-02 14:00, Schneider wrote: > I have to write a small SMTP-Relay script (+ some statistic infos) > and I'm wondering, if this > can be done in python (in terms of performance, of course not in > terms of possibility ;) ). > > It has to handle around 2000 mails per hour for at least 8hour

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Tim Chase
On 2013-08-08 22:32, Joshua Landau wrote: > On 8 August 2013 21:03, Terry Reedy wrote: > > If .pop were being added today, I would argue against including > > the index parameter. > > 3) There's always deque for deques Unless you have pre-2.4 code, in which case I'm glad .pop() was included (but

Re: Python Basic Doubt

2013-08-10 Thread Tim Chase
On 2013-08-10 21:03, Krishnan Shankar wrote: > >>> a=10 > >>> id(a) > 21665504 > >>> b=a > >>> id(b) > 21665504 > >>> c=10 > >>> id(c) > 21665504 > > I am actually assigning new value to c. But from the value of id() > all three variables take same location. With variables a and b it > is ok. But

Re: .split() Qeustion

2013-08-14 Thread Tim Chase
On 2013-08-14 18:14, Chris Angelico wrote: > On Wed, Aug 14, 2013 at 6:05 PM, wrote: > > On Wed, Aug 14, 2013, at 10:32, wxjmfa...@gmail.com wrote: > >> I'm always and still be suprised by the number of hard coded > >> '\n' one can find in Python code when the portable (here > >> win) > >> > >> >

Re: Python getters and setters

2013-08-17 Thread Tim Chase
On 2013-08-17 17:18, Steven D'Aprano wrote: > # Yes, this is good, consistent design > len(myrecord.field) > len(obj.data) > len(data.value) > len(collection[key]) I would also add that, if the primary goal of your class is to encapsulate the data, you can do class MyClass: def __init__(sel

Re: New VPS Provider needed

2013-08-27 Thread Tim Chase
On 2013-08-27 08:25, Dennis Lee Bieber wrote: > On Tue, 27 Aug 2013 ni...@superhost.gr wrote: > >Actually it is. Frankly, it's not. It's called the Python mailing list because it's for discussing *Python*. Otherwise, it would be called "Python and random irrelevant topics" mailing list. There a

Re: Is there a function that applies list of functions to a value?

2013-08-28 Thread Tim Chase
On 2013-08-28 05:52, AdamKal wrote: > From time to time I have to apply a series of functions to a value > in such a way: > > func4(func3(func2(func1(myval > > I was wondering if there is a function in standard library that > would take a list of functions and a initial value and do the above

Re: Is there a function that applies list of functions to a value?

2013-08-28 Thread Tim Chase
On 2013-08-28 06:23, AdamKal wrote: > Thanks! > > I guess this is as simple as it gets then. I was just looking for > the "one obvious way to do it". When 3 replies from 3 people all arrive within minutes, each suggesting reduce(), I'd figure it's the "one obvious way to do it" :-) -tkc --

Re: String splitting with exceptions

2013-08-28 Thread Tim Chase
On 2013-08-28 13:14, random...@fastmail.us wrote: > On Wed, Aug 28, 2013, at 12:44, John Levine wrote: > > I have a crufty old DNS provisioning system that I'm rewriting > > and I hope improving in python. (It's based on tinydns if you > > know what that is.) > > > > The record formats are, in th

Re: semicolon at end of python's statements

2013-08-28 Thread Tim Chase
On 2013-08-29 04:48, Mohsen Pahlevanzadeh wrote: > I'm C++ programmer and unfortunately put semicolon at end of my > statements in python. > > Quesion: > What's really defferences between putting semicolon and don't put? >From a technical standpoint, nothing (see below). From a "readability on t

Re: semicolon at end of python's statements

2013-08-28 Thread Tim Chase
On 2013-08-29 10:31, Chris Angelico wrote: > but putting semicolons at the ends of Python statements is as > useless as putting lots of (((irritating (((superfluous > (((parentheses) in your C++ code. The parser won't mind, > but subsequent programmers will wonder what these unneces

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: How to split with "\" character, and licence copyleft mirror of ©

2013-09-01 Thread Tim Chase
On 2013-09-01 17:03, materil...@gmail.com 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: 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

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: 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 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: 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, quarantinemi...@gmail.com 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: 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, trip...@gmail.com 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: 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: 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 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 > with a login to it could

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, feedthetr...@gmx.de 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

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: 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: 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: 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: 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: Unlimited canvas painting program

2013-10-24 Thread Tim Chase
On 2013-10-24 12:16, markot...@gmail.com 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: 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: trying to strip out non ascii.. or rather convert non ascii

2013-10-28 Thread Tim Chase
On 2013-10-28 07:01, wxjmfa...@gmail.com 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, wxjmfa...@gmail.com 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: 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,

Re: Testing python command line apps -- Running from within the projects w/o installing

2013-10-31 Thread Tim Chase
On 2013-10-31 22:12, Göktuğ Kayaalp wrote: > My usual practise is to have two entry points to the program as > executable scripts. When I create stand-alone command-line scripts that take arguments, usually they're akin to version-control tools, so I have the form scriptname.py [--global-opts]

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

2013-11-04 Thread Tim Chase
On 2013-11-03 19:40, Mark Janssen wrote: > But you cheated by using a piece of information from "outside the > system": length. A generic compression algorithm doesn't have this > information beforehand. By cheating with outside information, you can perfectly compress any one data-set down to 1 b

Re: How to add a current string into an already existing list

2013-11-05 Thread Tim Chase
On 2013-11-05 17:39, Nick the Gr33k wrote: > >>> data = infile.readlines You're assigning it to the bound function rather than calling the function. Use the "call" operator: data = infile.readlines() -tkc -- https://mail.python.org/mailman/listinfo/python-list

Re: To whoever hacked into my Database

2013-11-06 Thread Tim Chase
On 2013-11-06 22:22, Grant Edwards wrote: > Waving red flags at female bulls is rarely dangerous. ;) though I still wouldn't recommend it if you're COWardly :-) Well, maybe the issue is MOOt. -tkc -- https://mail.python.org/mailman/listinfo/python-list

Re: To whoever hacked into my Database

2013-11-06 Thread Tim Chase
On 2013-11-07 10:57, Chris Angelico wrote: > Waving red flags at female bulls is rarely dangerous. ;) > >>> > >>> though I still wouldn't recommend it if you're COWardly :-) > >>> > >>> Well, maybe the issue is MOOt. > >> > >> Ugh, if only these puns were like CALF-way funny... > > > > I here

Re: Show off your Python chops and compete with others

2013-11-06 Thread Tim Chase
On 2013-11-06 17:31, John Nagle wrote: > >> MetaBright makes skill assessments to measure how talented > >> people are at different skills. And recruiters use MetaBright to > >> find outrageously skilled job candidates. > > With tracking cookies blocked, you get 0 points. And with JavaScript bl

Re: To whoever hacked into my Database

2013-11-07 Thread Tim Chase
On 2013-11-06 23:06, Dennis Lee Bieber wrote: > Waving red flags at female bulls is rarely dangerous. ;) > >>> > >>> though I still wouldn't recommend it if you're COWardly :-) > >>> > >>> Well, maybe the issue is MOOt. > >> > >> Ugh, if only these puns were like CALF-way funny... > > > >I he

Re: Adding 'download' column to existing 'visitors' table (as requested)

2013-11-07 Thread Tim Chase
On 2013-11-07 17:03, Sibylle Koczian wrote: > > Nikos, you are an excellent member of the Greek society. > > Listening to you makes it so much easier to understand the > > problems that your country has. > > Is there any reason at all to insult all other Greek readers of > this newsgroup? Greec

Re: Show off your Python chops and compete with others

2013-11-07 Thread Tim Chase
On 2013-11-07 11:02, jski...@gmail.com wrote: > it's unlikely we'll ever be able to pull out javascript as it > limits interactivity too much. It was mostly in jest as it's one of the things I test when doing web development. That said, the quizzes are mostly just HTML forms where you pick the an

Re: Show off your Python chops and compete with others

2013-11-07 Thread Tim Chase
On 2013-11-07 21:18, Roy Smith wrote: > It's not a shifting goalpost. My original statement was that: > > def foo(): >raise Exception > > defines a function which 1) has no explicit return statement and 2) > does not return None. I stand by that statement. There is no > possible codepath,

Re: chunking a long string?

2013-11-08 Thread Tim Chase
On 2013-11-09 07:53, Chris Angelico wrote: > On the flip side, Python gets really awesome at some other things. > Your operating system probably takes an entire CD to distribute, > maybe even a DVD, so that's either 700MB or 4.7GB, give or take. > Look how efficiently Python can represent it: > >

Re: New user's initial thoughts / criticisms of Python

2013-11-09 Thread Tim Chase
On 2013-11-10 01:27, Chris Angelico wrote: > > Is everyone happy with the way things are? Could anyone recommend > > a good, high level language for CGI work? Not sure if I'm going > > to be happy with Perl (ahhh, get him, he's mentioned Perl and is > > a heretic!) or Python. I would very much valu

Re: New user's initial thoughts / criticisms of Python

2013-11-09 Thread Tim Chase
On 2013-11-09 21:01, Mark Lawrence wrote: > no comma is needed but a comma will be accepted. I find the optional trailing comma particularly useful (and painful in languages that don't accept it) for doing inline lists to produce cleaner version-control diffs. I write most of my code like this

Re: Python Worst Practices

2015-02-27 Thread Tim Chase
On 2015-02-28 12:09, Steven D'Aprano wrote: > > * Make your language have a lot of keywords. Enough to make > > memorizing them ALL unlikely, requiring constant visits to your > > documentation > > Is 33 a lot? > > py> import keyword > py> keyword.kwlist > ['False', 'None', 'True', 'and', 'a

Re: Python Worst Practices

2015-02-28 Thread Tim Chase
On 2015-02-28 17:56, MRAB wrote: > On 2015-02-28 16:03, Cousin Stanley wrote: > > > >> From : Tim Chase > >> > >> A quick google-and-tally for languages > >> and their corresponding number of keywords: > >> > > > >

Re: Python Worst Practices

2015-02-28 Thread Tim Chase
On 2015-02-28 10:13, Ethan Furman wrote: > On 02/28/2015 09:56 AM, MRAB wrote: > > On 2015-02-28 16:03, Cousin Stanley wrote: > >> > >>> From : Tim Chase > >>> > >>> A quick google-and-tally for languages > >>> and their c

Re: Letter class in re

2015-03-09 Thread Tim Chase
On 2015-03-09 11:37, Wolfgang Maier wrote: > On 03/09/2015 11:23 AM, Antoon Pardon wrote: >> Does anyone know what regular expression to use for a sequence of >> letters? There is a class for alphanumerics but I can't find one >> for just letters, which I find odd. > > how about [a-zA-Z] ? That b

Re: Letter class in re

2015-03-09 Thread Tim Chase
On 2015-03-09 13:26, Antoon Pardon wrote: > Op 09-03-15 om 12:17 schreef Tim Chase: >> (?:(?!_|\d)\w) > > So if I understand correctly the following should be a regular > expression for a python3 identifier. > > (?:(?!_|\d)\w)\w+ If you don't have to treat it

Re: Letter class in re

2015-03-09 Thread Tim Chase
On 2015-03-09 15:29, Antoon Pardon wrote: > Op 09-03-15 om 13:50 schreef Tim Chase: > >> (?:(?!_|\d)\w)\w+ > > If you don't have to treat it as an atom, you can simplify that to > > just > > > > (?!_|\d)\w+ > > > > which just means that th

Re: regex help

2015-03-13 Thread Tim Chase
On 2015-03-13 12:05, Larry Martell wrote: > I need to remove all trailing zeros to the right of the decimal > point, but leave one zero if it's whole number. > > But I can't figure out how to get the 5. to be 5.0. > I've been messing with the negative lookbehind, but I haven't fou

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Tim Chase
On 2015-03-18 10:46, Aditya Raj Bhatt wrote: > a = 5 '''a comment''' > > results in a syntax error That's to be expected, and happens with any string, not just triple-quoted: >>> a = 5 "hello" > there are no 'true' multiline comments in python and that all those > 'block' comments are actuall

Re:

2015-03-23 Thread Tim Chase
On 2015-03-23 21:19, Chandra Prashad mishra wrote: > I want to know hint about web development... can any one get me... Use your text editor and deploy your project to a web server. -tkc (you'd need to provide a few more details about what you want to get anything more detailed in response)

Re: Basic Python V3 Search Tool using RE module

2015-03-25 Thread Tim Chase
On 2015-03-25 21:20, Dave Angel wrote: >> pattern="DECRYPT_I" >> regexp=re.compile(pattern) > > That could explain why it's so fast. While I might have missed it in the thread, it also seems that regexpen are overkill for this. Why not just test for if pattern in name: ... -tkc -- http

Re: test1

2015-03-26 Thread Tim Chase
On 2015-03-26 08:33, Tiglath Suriol wrote: > > Mark Lawrence > > I don't remember addressing his guy, HE addressed me FIRST, as all > of you did, Hmmm...To what then has he been replying? *You* posted/broadcast the FIRST message which addressed every member of the list. If you don't want to

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-26 Thread Tim Chase
On 2015-03-27 10:15, Steven D'Aprano wrote: > If that's all it is, why don't you just run the tokenizer over it > and see what it says? > > py> from cStringIO import StringIO > py> code = StringIO('spam = "abcd" "efgh"\n') > py> import tokenize > py> for item in tokenize.generate_tokens(code.readl

Re: How to convert .doc file to .txt in Python

2015-04-09 Thread Tim Chase
On 2015-04-09 03:25, subhabrata.bane...@gmail.com wrote: > You may kindly suggest how to convert from .doc > to .docx/.html/.pdf/.rtf as from them I am being able to convert > to .txt. Use an external tool such as "wv", "antiword", or "catdoc" that has already done the hard work for you. -tkc

Re: xlwt 1.0.0 released!

2015-04-15 Thread Tim Chase
On 2015-04-15 15:21, Gary Herron wrote: > On 04/15/2015 02:51 PM, Chris Withers wrote: > > I'm pleased to announce the release of xlwt 1.0.0. > > What a curiously incomplete announcement. Could you tell us what > xlwt is? I see no hint here. Heh, this and its sibling package, xlrd, are Python p

Re: New to Python - block grouping (spaces)

2015-04-16 Thread Tim Chase
On 2015-04-17 03:10, Steven D'Aprano wrote: > And there there was the time I edited some code written by my boss. > I intended to write a comment: > > # FIXME: this function is a little slow and should be optimized. > > but I hit the wrong key a couple of times and wrote: > > # This is a

<    4   5   6   7   8   9   10   11   12   13   >