Re: unable to import rlcompleter readline

2014-03-19 Thread Tim Golden
On 19/03/2014 08:55, muru kessan wrote: > hi guys, > i want the python interactive shell to be auto complete and i found that > by adding the following lines in PYTHONSTARTUP file it is possible > > import rlcompleter, readline > readline.parse_and_bind('tab: complete') > > but i get the followin

Re: csv read _csv.Error: line contains NULL byte

2014-03-21 Thread Tim Golden
On 21/03/2014 13:29, chip9m...@gmail.com wrote: > Hi all! > > I am reading from a huge csv file (> 20 Gb), so I have to read line by line: > > for i, row in enumerate(input_reader): > # and I do something on each row > > Everything works fine until i get to a row with some strange symbols

Re: csv read _csv.Error: line contains NULL byte

2014-03-21 Thread Tim Golden
On 21/03/2014 14:46, chip9m...@gmail.com wrote: > I am sorry I do not understand how to get to each row in this way. > > Please could you explain also this: > If I define this function, > how do I change my for loop to get each row? Does this help? #!python3 import csv def unfussy_reader(csv_

Re: Question about Source Control

2014-03-21 Thread Tim Chase
On 2014-03-22 04:23, Chris Angelico wrote: > > The hard thing is I don't really want to know which change most > > recently touched the line of text. I want to know who really > > wrote it. It would be wonderful if hg were smart enough to be > > able to back-track through the change history and i

Re: Question about Source Control

2014-03-21 Thread Tim Chase
On 2014-03-21 12:54, Tim Chase wrote: > A quick "hg -help blame" Sigh. Accidentally hit when I meant to hit with down. That is, of course "hg help blame", formerly written there as "hg -v help blame" and accidentally sent mid-edit. -tkc -- https://mail.p

Re: Question about Source Control

2014-03-22 Thread Tim Chase
On 2014-03-22 17:32, Albert van der Horst wrote: > >I don't know if this is a hg-vs-git way of thinking, but I tend to > >frequently commit things on a private development branch regardless > >of brokenness, but once I get it working, I flatten & clean up > >those changes ("rebase" in git terms, wh

Re: unicode as valid naming symbols

2014-03-25 Thread Tim Chase
On 2014-03-25 14:29, Mark H Harris wrote: > > It's explained in PEP 3131. > > > > Basically, a name should to start with a letter (this has been > > extended to include Chinese characters, etc) or an underscore. > > > > λ is a classified as Lowercase_Letter. > > > > √ is classified as Math_

Re: unicode as valid naming symbols

2014-03-27 Thread Tim Chase
On 2014-03-27 08:10, Rustom Mody wrote: > > I know, for such a reason I would love it if keywords would have > > been written like this: 𝗱𝗲𝗳 (using mathematical bold) instead of > > just like this: def (using plain latin letters). It would mean > > among other things we could just write operator.no

Python language hack for C-style programmers [DO NOT USE!] :-)

2014-03-27 Thread Tim Chase
Multiple times, I've seen someone want something like what C-style languages offer where assignment is done in a test, something like if (m = re.match(some_string)): do_something(m) So when I stumbled upon this horrific atrocity of language abuse and scope leakage, I thought I'd share it.

Re: checking if two things do not equal None

2014-03-29 Thread Tim Chase
On 2014-03-29 17:07, Roy Smith wrote: > > if (a is not None) or (b is not None): > > > > is immediately understandable by everyone? > > I agree with that. But > > > if (a, b) != (None, None): > > seems pretty straight-forward to me too. In fact, if anything, it > seems easier to understan

Re: checking if two things do not equal None

2014-03-29 Thread Tim Chase
On 2014-03-29 18:41, Roy Smith wrote: > On Mar 29, 2014, at 6:36 PM, Tim Chase wrote: > > > And for cases where you have more than one or two things to test > > for None-itude, you could use > > > > if all(x is None for x in [a, b, c, d]): > >do_somethi

Re: checking if two things do not equal None

2014-03-29 Thread Tim Chase
On 2014-03-30 10:17, Chris Angelico wrote: > On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase > wrote: >> Though am I correct that your iteration tests for equality, while >> mine tests for identity? Also, my version bails early in the >> event quitting early is possible. Th

Re: unicode as valid naming symbols

2014-03-31 Thread Tim Chase
On 2014-03-31 11:40, Ian Kelly wrote: > There is nothing useful > you can do with a name that is the U+1F4A9 character that you can't > do just as easily with alphanumeric identifiers like pile_of_poo (or > куча_фекалий if one prefers; that's auto-translated, so don't blame > me if it's a poor tran

Re: converting strings to hex

2014-04-03 Thread Tim Chase
On 2014-04-03 19:10, dave em wrote: > So my first step is to compute the key. I suspect my error below > is because c1 is a float and m1 is a string but I don't know how to > turn the string into a float. For the record, "c1" in your example should be an integer/long It sounds like you want the

Re: Two Questions about Python on Windows

2014-04-05 Thread Tim Roberts
like any other automatically executable program: xxx -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- https://mail.python.org/mailman/listinfo/python-list

Re: How can I parse this correctly?

2014-04-06 Thread Tim Chase
On 2014-04-06 14:21, Ben Finney wrote: > I assume you mean you will be creating ‘datetime.date’ objects. What > will you set as the month and day? > > Alternatively, if you just want to do integer arithmetic on the > year, you don't need the ‘datetime’ module at all. Even if you do the arithmetic

Re: change spacing to two instead of four with pep8 or flake8?

2014-04-08 Thread Tim Chase
On 2014-04-08 09:52, Chris “Kwpolska” Warrick wrote: > On Tue, Apr 8, 2014 at 5:06 AM, Dennis wrote: > > In Pylint you can change the spacing multiplier from 4 spaces to > > two in its pylintrc, but for the life of me I cannot find a way > > to do this with the flake8 / pep8 utilities. > > > > I w

Re: Python 2.3 and ODBC

2014-04-08 Thread Tim Chase
On 2014-04-08 22:18, Gabor Urban wrote: > I am using Python 2.3 on an XP box at my company. (I know it is > quite outdated, but we could not make the management to upgrade.) I > have started a pilot project the last week to show the possibility > of processing incoming XML files and extracting data

Re: "Latching" variables in function

2014-04-09 Thread Tim Chase
On 2014-04-08 16:09, Grawburg wrote: > def button(): >    pushbutton = 0 >   button_value = 0 >    pushbutton=bus.read_byte_data(address,GPIOB) >    if pushbutton > 0: >         button_value = 1 >    return button_value > > I need button_value to become '1' when the button is pressed and to > rema

Re: imaplib: how to specify SSL/TLS protocol version?

2014-04-09 Thread Tim Chase
On 2014-04-09 20:12, Grant Edwards wrote: > File "/usr/lib64/python2.7/imaplib.py", line 1148, in __init__ >IMAP4.__init__(self, host, port) > SSLError: [Errno 1] _ssl.c:1419: error:1408F10B:SSL > routines:SSL3_GET_RECORD:wrong version number > > Experiments show that when calling ssl.wrap_s

Re: imaplib: how to specify SSL/TLS protocol version?

2014-04-09 Thread Tim Chase
On 2014-04-09 20:20, Grant Edwards wrote: > I'm not too keen on this approach, but monkey-patching the open() > method seems to work: > > def my_imap4_ssl_open(self, host = '', port = 993): > self.host = host > self.port = port > self.sock = socket.create_connection((host, port)) >

Re: Python and Unicode

2014-04-10 Thread Tim Chase
On 2014-04-10 04:47, wxjmfa...@gmail.com wrote: > Le mercredi 9 avril 2014 10:53:36 UTC+2, Mark Lawrence a écrit : > > On 09/04/2014 09:07, wxjmfa...@gmail.com wrote: > > > > > Well, there is a (serious) problem somewhere... > > > jmf > > > > Look in a mirror and you'll see it as it'll be staring

Re: Teaching python to non-programmers

2014-04-11 Thread Tim Chase
On 2014-04-11 11:34, Steven D'Aprano wrote: > >> That's equivalent to being told "Don't ever delete any of your > >> code, just comment it out". I don't care who's saying that, it's > >> bad advice. > > > > The correct analogy: "Dont ever delete content from the > > repository" > > No -- the

Re: Interleaved vs. top-posting

2014-04-11 Thread Tim Chase
On 2014-04-11 13:59, Chris Angelico wrote: > I have seen plenty of cultures where people are unaware of the value > of interleaved/bottom posting, but so far, not one where anyone has > actually required it. Not one. The only time I've seen top-posting required (though there was nothing about trim

Re: Simple question

2014-04-15 Thread Tim Chase
On 2014-04-15 19:18, Phil Dobbin wrote: > I'm confused as to this part: > > '>>> 0.1 + 0.1 + 0.1 - 0.3 > 5.55111.' > > What I'm wondering is why the first calculation that arrives at > '5.55111...' is so far out? You omit one key detail in your "", the "e-17" which means that is 5.55111

Re: Why Python 3?

2014-04-20 Thread Tim Chase
On 2014-04-20 09:43, Steven D'Aprano wrote: > So really the advice comes down to: > > - if you can, use the latest version of Python, which is 3.4; > > - if you must, use the version of Python provided by your operating > system, which could be anything from Python 2.3 to 3.3; > > - if you hav

Re: how to string format when string have {

2014-04-20 Thread Tim Chase
On 2014-04-20 15:34, Mariano DAngelo wrote: > I have the following string: ... > but since the string have { i can't. > Is there a way to solve this? I second Chris Angelico's suggestion about using the older percent formatting: nginx_conf = ''' server { listen 80; server_name dev

Re: symple programming task

2014-04-21 Thread Tim Chase
On 2014-04-21 06:21, Ivan Ivanivich wrote: > > Find the sum of all the multiples of 3 or 5 below 1000. > my new version of script: > > total = 0 > div1 = 3 > div2 = 5 > for basis in range(0, 1000): > mod = basis % div1 > if mod == 0: > total = total + basis >

Re: which book to read next??

2014-04-21 Thread Tim Chase
On 2014-04-21 22:13, lee wrote: > Hi, I have read the book 'a byte of python' and now I want to read > another book. But I just get confused about which one to read next. > There is a book list below: 1, pro python > 2, python algorithms > 3, python cookbook > 4, the python standard library by exam

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Tim Golden
On 22/04/2014 11:29, Antoon Pardon wrote: > I am workin on a solaris 11 machine. The python version is 2.7.6 > path to python is /opt/local/bin/python. > > These are the 15 first lines of the script: > > #! /opt/local/bin/python > > class vslice(object): > > def __init__(self, fun): >

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Tim Chase
On 2014-04-22 22:52, Chris Angelico wrote: > I'm pretty sure the POSIX standard stipulates that a space there is > optional. Should be no difference between "#!/" and "#! /" on any > compliant OS. (But I can't right now find a citation for that, so I > may be wrong.) I wondered this too, so went r

Moving to an OOP model from an classically imperitive one

2014-04-23 Thread tim . thelion
sm. I asked on IRC and it was sugested that I use multiple classes, however I see no logical way to separate a SubuserProgram object into multiple classes. So I thought I would seek your advice. Tim -- https://mail.python.org/mailman/listinfo/python-list

Re: Moving to an OOP model from an classically imperitive one

2014-04-24 Thread tim . thelion
the repository name, that is, if I were to create a "unique-program-name" string which was of the format repo+"-"+programName then the repo name could not have the "-" symbol in it. Tim -- https://mail.python.org/mailman/listinfo/python-list

Re: Moving to an OOP model from an classically imperitive one

2014-04-24 Thread tim . thelion
ier to manage a todo list when one knows which files have been processed already/what needs to be processed. This is especially true if the refactor will take several days or be done by several people. Tim -- https://mail.python.org/mailman/listinfo/python-list

Re: Moving to an OOP model from an classically imperitive one

2014-04-24 Thread tim . thelion
s use OOP), so I'm not yet sure how this will turn out. Tim -- https://mail.python.org/mailman/listinfo/python-list

Re: how to split this kind of text into sections

2014-04-25 Thread Tim Chase
On 2014-04-25 23:31, Chris Angelico wrote: > On Fri, Apr 25, 2014 at 11:07 PM, oyster > wrote: > > the above text should be splitted as a LIST with 3 items, and I > > also need to know the KEY for LIST is ['I am section', 'let's > > continue', 'I am using']: > > It's not perfectly clear, but I th

Re: Proper deletion of selected items during map iteration in for loop

2014-04-25 Thread Tim Chase
On 2014-04-25 14:50, Terry Reedy wrote: > If you expect to delete more than half the keys *and* if there are > no other references to the dict, such that you need the particular > object mutated, this might be better. If that's your precondition, then it might be better to do something like kee

Re: how to split this kind of text into sections

2014-04-26 Thread Tim Chase
On 2014-04-26 23:53, oyster wrote: > I will try to explain my situation to my best, but English is not my > native language, I don't know whether I can make it clear at last. Your follow-up reply made much more sense and your written English is far better than many native speakers'. :-) > Every S

Re: Proper deletion of selected items during map iteration in for loop: Thanks to all

2014-04-26 Thread Tim Chase
On 2014-04-26 12:25, Charles Hixson wrote: > I expect that I'll be deleting around 1/3 during > each iteration of the process...and then adding new ones back in. > There shouldn't be a really huge number of deletions on any > particular pass, but it will be looped through many times... If you have

Re: Unicode 7

2014-04-29 Thread Tim Chase
On 2014-04-29 10:37, wxjmfa...@gmail.com wrote: > >>> timeit.repeat("(x*1000 + y)[:-1]", setup="x = 'abc'; y = 'z'") > [1.4027834829454946, 1.38714224331963, 1.3822586635296261] > >>> timeit.repeat("(x*1000 + y)[:-1]", setup="x = 'abc'; y = > >>> '\u0fce'") > [5.462776291480395, 5.4479432055423

Re: Unicode 7

2014-04-30 Thread Tim Chase
On 2014-04-30 00:06, wxjmfa...@gmail.com wrote: > @ Time Chase > > I'm perfectly aware about what I'm doing. Apparently, you're quite adept at appending superfluous characters to sensible strings...did you benchmark your email composition, too? ;-) -tkc (aka "Ti

Re: Unicode 7

2014-05-02 Thread Tim Chase
On 2014-05-02 19:08, Chris Angelico wrote: > This is another area where Unicode has given us "a great improvement > over the old method of giving satisfaction". Back in the 1990s on > OS/2, DOS, and Windows, a missing glyph might be (a) blank, (b) a > simple square with no information, or (c) copie

Re: Add "Received:" header to email msg in correct position?

2014-05-05 Thread Tim Chase
On 2014-05-05 20:58, Grant Edwards wrote: > On 2014-05-05, Ethan Furman wrote: > > On 05/05/2014 12:51 PM, Grant Edwards wrote: > >> I'd like to do the polite thing and add a "Received:" header, > >> but I can't figure out how to get Python's email module to add > >> it in the correct place. It a

Re: Add "Received:" header to email msg in correct position?

2014-05-08 Thread Tim Chase
On 2014-05-08 18:39, Grant Edwards wrote: > > Looks like a Zippy the Pinhead quote to me... > > Yep. I'm kinda disappointed having the curtain pulled back like that. I'd just assumed it was some nifty tool that turned a GPG/PGP signature into MadLibs™-style fill-in-the-blank and then flowed in

Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-09 Thread Tim Chase
On 2014-05-09 12:51, scottca...@gmail.com wrote: > here is a snippet of code that opens a file (fn contains the > path\name) and first tried to replace all endash, emdash etc > characters with simple dash characters, before doing a search. But > the replaces are not having any effect. Obviously a

Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-10 Thread Tim Golden
On 10/05/2014 08:11, wxjmfa...@gmail.com wrote: Anyway, as Python may fail as soon as one uses an EM DASH or an EM DASH, I think it's not worth the effort to spend to much time with it. Nope -- seems all right to me. (Hopefully helping the OP out as well as rebutting a rather foolish assertion

Re: PEP 8 : Maximum line Length :

2014-05-13 Thread Tim Chase
On 2014-05-13 22:26, Ben Finney wrote: > Changing the name on the first line doesn't entail changing any > other line:: > > proc = Subprocess.Popen( > shlex.split(cmd), > stdout=subprocess.PIPE, > stderr=subprocess.PIPE) > > special_process_map[this_pro

Re: PEP 8 : Maximum line Length :

2014-05-17 Thread Tim Chase
On 2014-05-17 12:52, Albert van der Horst wrote: > Now translate E=mc^2 into Java. I suspect it would be something like public class Einstein { private double mass=0, energy=0; public class Relativity implements IEquation { Relativity(double mass) { set_mass(mass); } public

Re: bz2.decompress as file handle

2014-05-18 Thread Tim Chase
L.bz2', 'rb') as handle: > cel_data = decompress(handle.read()) When I try (without the Bio.Affy which isn't part of the stdlib), I get correct bytes from this: tim@bigbox:~$ echo hello world > test.txt tim@bigbox:~$ bzip2 -9 test.txt tim@bigbox:~$ python3 Python 3.2.3

Re: Python and Math

2014-05-19 Thread Tim Golden
On 19/05/2014 11:15, Fabien wrote: > Hi everyone, > > I am new on this forum (I come from IDL and am starting to learn python) > > This thread perfectly illustrates why Python is so scary to newcomers: > one question, three answers: yes, no, maybe. Welcome to the Python world, Fabien. But I'm s

Re: Python and Math

2014-05-19 Thread Tim Golden
On 19/05/2014 20:07, wxjmfa...@gmail.com wrote: Yesterday, I spent one hour attemepting to install IPython for Py3.3 (win 7), I failed. I do not even succeed to understand how. Pip, setuptools, whl or manualy with from the zip... completely lost. There is always something not working.

Re: Python CGI

2014-05-19 Thread Tim Chase
On 2014-05-19 20:32, Christian wrote: > I'd like to use Python for CGI-Scripts. Is there a manual how to > setup Python with Fast-CGI? I'd like to make sure that Python > scripts aren't executed by www-user, but the user who wrote the > script. While Burak addressed your (Fast-)CGI issues, once yo

Re: Psycopg2 : error message.

2014-05-19 Thread Tim Roberts
onnect("dbname=busard_test user=laurent host=localhost password=cactus") or do this: conn=psycopg2.connect(database='busard_test', user='laurent', host='localhost', password='cactus'") -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- https://mail.python.org/mailman/listinfo/python-list

Re: Need help with executing DB query in two different places in a test

2014-05-19 Thread Tim Roberts
st fetch all of the record for the session after each transaction, and make sure the contents match what you expect. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and Math

2014-05-20 Thread Tim Golden
On 20/05/2014 10:19, wxjmfa...@gmail.com wrote: > Le lundi 19 mai 2014 21:18:54 UTC+2, Tim Golden a écrit : >> On 19/05/2014 20:07, wxjmfa...@gmail.com wrote: >> >>>>> Yesterday, I spent one hour attemepting to install IPython >>>>> for Py3.

Re: Python and Math

2014-05-20 Thread Tim Golden
On 20/05/2014 12:20, Rustom Mody wrote: > On Tuesday, May 20, 2014 3:43:45 PM UTC+5:30, Tim Golden wrote: >> If it's possible, download get-pip.py from here: >> >> https://bootstrap.pypa.io/get-pip.py > > Gives me secure connection failed error (in firefox) >

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Tim Chase
On 2014-05-22 12:47, Adam Funk wrote: > I'm using Python 3.3 and the sqlite3 module in the standard library. > I'm processing a lot of strings from input files (among other > things, values of headers in e-mail & news messages) and suppressing > duplicates using a table of seen strings in the datab

Re: Loop thru the dictionary with tuples

2014-05-25 Thread Tim Chase
On 2014-05-25 05:59, Paul Rubin wrote: > Igor Korot writes: > > for (key,value) in my_dict: > > #Do some stuff > > > > but I'm getting an error "Too many values to unpack". > > Use > for (key,value) in mydict.iteritems(): ... You can even use for ((k1,k2,k3), value) in mydict.iterite

Re: Shared web hosting where python is *not* a second class citizen

2014-05-25 Thread Tim Golden
On 25/05/2014 18:25, memilanuk wrote: Right now we have a fairly basic shared hosting plan via bluehost.com, running WordPress for a club web site. I've looked at setting up python on this account, but the default is the version of python that comes with the OS (CentOS 5.x currently). There are

Re: How keep Python 3 moving forward

2014-05-25 Thread Tim Chase
On 2014-05-25 18:17, Steven D'Aprano wrote: > On Sun, 25 May 2014 10:38:42 -0700, Rustom Mody wrote: > > Your unicode is mojibaked Ethan! Voil�. You are hereby > > banished to a lonely island with python 1.5 and jmf for company :D > > Nope, it's you. Ethan's post is fine. He correctly quotes JM

Re: win32serviceutil: ImportError: DLL load failed: The specified module could not be found

2014-05-26 Thread Tim Golden
On 26/05/2014 14:24, Nagy László Zsolt wrote: Strange thing is that win32serviceutil.py is part of the pywin32 distribution, so I guess I should be able to import it, right? Make sure you have a pywin32 that matches ???. Matching includes python version and bitness. In addition, c:\python

Re: Python box (home-use smart router)

2014-05-27 Thread Tim Chase
On 2014-05-27 15:33, animalize81 wrote: > Home-use smart router is more and more popular. > > If embeds Python into such router, and > develops a framework that has the following features: > > 1, allow power-down at any time > 2, dynamic domain name > 3, local storage support (SD cards or Hard

Re: python

2014-05-27 Thread Tim Chase
On 2014-05-27 08:43, himanshul...@gmail.com wrote: > Need of python in embedded systems??? Define "embedded". I've got a couple small low-powered devices here (a Digi ConnectPort, a Raspberry Pi, a low-end 32-bit system with 32MB of RAM) all of which run Python. It might be trickier if you're ta

Re: Command prompt not shown when running Python script with subprocess on Windows

2014-05-27 Thread Tim Golden
On 28/05/2014 00:01, ps16thypresenceisfullnessof...@gmail.com wrote: I want users to be able to enter paths in the XML file exactly the way they would be entered in a Windows shortcut. Since it is possible to make a Windows shortcut for path-to-script.py without the python.exe in front of it and

Re: Command prompt not shown when running Python script with subprocess on Windows

2014-05-28 Thread Tim Golden
On 28/05/2014 06:08, Tim Golden wrote: On 28/05/2014 00:01, ps16thypresenceisfullnessof...@gmail.com wrote: I want users to be able to enter paths in the XML file exactly the way they would be entered in a Windows shortcut. Since it is possible to make a Windows shortcut for path-to-script.py

Re: Python alternative to Google Groups

2014-05-28 Thread Tim Golden
On 28/05/2014 22:54, Steven Clift wrote: If you are looking for an open source alternative between Google Groups and Mailman, I wanted to share: http://groupserver.org It has recent release and new design. Aargh. I hate it when someone does that: posts something so interesting that I wa

Re: Python alternative to Google Groups

2014-05-29 Thread Tim Golden
On 29/05/2014 11:57, Mark Lawrence wrote: > On 29/05/2014 06:06, Tim Golden wrote: >> On a more serious note, it does look interesting and it would be great >> to have a credible alternative to promote for people who tend towards >> GG. Needs to someone to do the setup / confi

Re: Command prompt not shown when running Python script with subprocess on Windows

2014-05-29 Thread Tim Golden
On 28/05/2014 21:46, ps16thypresenceisfullnessof...@gmail.com wrote: > > Thank you for your replies. I tried what you suggested in your second > post and it worked. > > That was actually a mistake in the app_list.xml file. As you said: > > %ProgramFiles%\LibreOffice > 4\program\swriter.exe "C:\U

Re: Command prompt not shown when running Python script with subprocess on Windows

2014-06-01 Thread Tim Golden
29/05/2014 20:21, ps16thypresenceisfullnessof...@gmail.com wrote: That's interesting, now I learned something else too. As I said before, though, I want users to be able to enter paths in the XML file exactly the way they would be entered in a Windows shortcut. [...] Since in a Windows shortc

Re: Python 3.2 has some deadly infection

2014-06-01 Thread Tim Delaney
efault would be the most sensible option (effectively treating everything as bytes), with the option for another encoding if/when more information is known (e.g. there's often a call to return the encoding, and the output of that call is guaranteed to be ASCII). Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.2 has some deadly infection

2014-06-01 Thread Tim Delaney
On 2 June 2014 11:14, Steven D'Aprano wrote: > On Mon, 02 Jun 2014 08:54:33 +1000, Tim Delaney wrote: > > I'm currently working on a product that interacts with lots of other > > products. These other products can be using any encoding - but most of > > the f

Re: IDE for python

2014-06-02 Thread Tim Golden
On 02/06/2014 08:28, Wolfgang Maier wrote: > gmail.com> writes: > >> >> Amen. >> Ite missa est. >> > > Oh, why all the lamenting about python's unicode support, when your latin is > so superbe ! Elegant solution to all your problems :) After all, if you can't use Latin-1 for Latin, what can yo

Re: Python 3.2 has some deadly infection

2014-06-02 Thread Tim Delaney
On 2 June 2014 17:45, Wolfgang Maier < wolfgang.ma...@biologie.uni-freiburg.de> wrote: > Tim Delaney gmail.com> writes: > > > For some purposes, there needs to be a way to treat an arbitrary stream > of > bytes as an arbitrary stream of 8-bit characters. iso-latin-1

Re: IDE for python

2014-06-02 Thread Tim Golden
On 02/06/2014 10:15, Chris Angelico wrote: > On Mon, Jun 2, 2014 at 7:02 PM, Mark Lawrence wrote: >> >> What is the Latin for "resident unicode expert go home"? > > Google Translate says: > > Eusebius, et revertatur in domum perito resident. > > ChrisA > Try: Perite domestice unicodicis: vad

Re: Obfuscated Python hack

2014-06-02 Thread Tim Chase
On 2014-06-02 12:11, Steven D'Aprano wrote: > Kids, don't try this at home! > > In Python 2.7, run this: > > exec((lambda *fs: reduce(lambda f, g: lambda x: f(g(x)), > fs))(*([lambda s: > s[1::2]+s[-2::-2]]*54))('motcye;cye._n8fo_drs(d4+)vle=5 ua.8) > (isedamr.ticspt spt rpi')) > > > Then run

Re: Unicode and Python - how often do you index strings?

2014-06-03 Thread Tim Chase
On 2014-06-04 10:39, Chris Angelico wrote: > A current discussion regarding Python's Unicode support centres (or > centers, depending on how close you are to the cent[er]{2} of the > universe) around one critical question: Is string indexing common? > > Python strings can be indexed with integers

Re: Unicode and Python - how often do you index strings?

2014-06-03 Thread Tim Chase
On 2014-06-04 12:16, Chris Angelico wrote: > On Wed, Jun 4, 2014 at 11:11 AM, Tim Chase > wrote: > > I then take row 2 and use it to make a mapping of header-name to a > > slice-object for slicing the subsequent strings: > > > > slice(i.start(), i.end()) > &

Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-04 Thread Tim Chase
On 2014-06-04 00:58, Paul Rubin wrote: > Steven D'Aprano writes: > >> Maybe there's a use-case for a microcontroller that works in > >> ISO-8859-5 natively, thus using only eight bits per character, > > That won't even make the Russians happy, since in Russia there > > are multiple incompatible l

Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-04 Thread Tim Chase
On 2014-06-04 12:53, Robin Becker wrote: > > If you use UTF-8 for everything, then you end up in a world where > > string-indexing (see ChrisA's other side thread on this topic) is > > no longer an O(1) operation, but an O(N) operation. Some of us > > slice strings for a living. ;-) > > I

Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-04 Thread Tim Chase
On 2014-06-04 14:57, Marko Rauhamaa wrote: > > If you use UTF-8 for everything, then you end up in a world where > > string-indexing (see ChrisA's other side thread on this topic) is > > no longer an O(1) operation, but an O(N) operation. > > Most string operations are O(N) anyway. Besides, you

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: Fast conversion of numbers to numerator/denominator pairs

2013-08-24 Thread Tim Delaney
he multiply and add takes about 55% of the time. The exponentiation takes about 10% of the time. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast conversion of numbers to numerator/denominator pairs

2013-08-24 Thread Tim Delaney
On 25 August 2013 07:59, Tim Delaney wrote: > Breakdown of the above (for 19 digits): > > d.as_tuple() takes about 35% of the time. > > The multiply and add takes about 55% of the time. > > The exponentiation takes about 10% of the time. > Bah - sent before complete. Si

Re: New VPS Provider needed

2013-08-27 Thread Tim Delaney
PS provider's end. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

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

subprocess.Popen instance hangs

2013-08-29 Thread Tim Johnson
=subprocess.STDOUT,stdout=subprocess.PIPE) ## wait() is 'forever' if '--verbose' used exit_status = p.wait() output = p.stdout.read() ## done I 'suspect' that using a tempfile may be the solution, if so, I could use some examples. thanks -- Tim tim at tee jay forty nine dot com

Re: Why is str(None) == 'None' and not an empty string?

2013-08-29 Thread Tim Delaney
; not None else '') instead. Not a major inconvenience, but enough to > make me wonder if there could be a better way. > There is. def format(value): if value is None: return '' return str(value) print(format(value)) This also allows you to format other types differently e.g. only output 2 decimal places for non-integer numeric types. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.Popen instance hangs

2013-08-29 Thread Tim Johnson
* MRAB [130829 11:04]: > On 29/08/2013 19:34, Tim Johnson wrote: > >could use some examples. > > > The subprocess will terminate when it has finished writing its output, > but because you're not consuming any of the output (you're waiting for > it to finish),

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