Re: Jython and PYTHONSTARTUP

2012-06-22 Thread Hans Mulder
On 21/06/12 02:26:41, Steven D'Aprano wrote: > There used to be a page describing the differences between Jython and > CPython here: > > http://www.jython.org/docs/differences.html > > but it appears to have been eaten by the 404 Monster. It has been moved to: http://www.jython.org/archive/21/

Re: Frustrating circular bytes issue

2012-06-26 Thread Hans Mulder
On 26/06/12 18:30:15, J wrote: > This is driving me batty... more enjoyment with the Python3 > "Everything must be bytes" thing... sigh... > I have a file that contains a class used by other scripts. The class > is fed either a file, or a stream of output from another command, then > interprets th

Re: Executing Python Scripts on Mac using Python Launcher

2012-06-26 Thread Hans Mulder
On 26/06/12 20:11:51, David Thomas wrote: > On Monday, June 25, 2012 7:19:54 PM UTC+1, David Thomas wrote: >> Hello, >> This is my first post so go easy on me. I am just beginning to program >> using Python on Mac. When I try to execute a file using Python Launcher my >> code seems to cause an

Re: Executing Python Scripts on Mac using Python Launcher

2012-06-26 Thread Hans Mulder
On 26/06/12 21:51:41, Dennis Lee Bieber wrote: > On Tue, 26 Jun 2012 10:19:45 -0700 (PDT), David Thomas > declaimed the following in gmane.comp.python.general: > > >> http://www.freeimagehosting.net/ilbqt > > That's an interesting configuration... > > "pythonw.exe" is a version of

Re: Executing Python Scripts on Mac using Python Launcher

2012-06-26 Thread Hans Mulder
On 26/06/12 22:41:59, Dave Angel wrote: > On 06/26/2012 03:16 PM, Hans Mulder wrote: >> >> >> Python is an executable, and is >> typically located in a "bin" directory. To find out where >> it is, type >> >> type python >> &

Re: Executing Python Scripts on Mac using Python Launcher

2012-06-27 Thread Hans Mulder
On 27/06/12 19:05:44, David Thomas wrote: > Is this why I keep getting an error using launcher? No. Yesterday your problem was that you tried this: input("\n\nPress the enter key to exit") That works fine in Pyhton3, but you are using python2 and in python2, the you must do this instead:

Re: Executing Python Scripts on Mac using Python Launcher

2012-06-27 Thread Hans Mulder
On 27/06/12 22:45:47, David Thomas wrote: > Thank you ever so much raw_input works fine. > Do you think I should stick with Python 2 before I go to 3? I think so. The differences are not that big, but big enough to confuse a beginner. Once you know pyhton2, read http://docs.python.org/py3k/what

Re: how can I implement "cd" like shell in Python?

2012-06-28 Thread Hans Mulder
On 28/06/12 13:09:14, Sergi Pasoev wrote: > Do you mean to implement the cd command ? To what extent do you want to > implement it ? if what you want is just to have a script to change the > current working directory, it is as easy as this: > > > import sys > import os > os.chdir(sys.argv[1]) >

Re: 2 + 2 = 5

2012-07-05 Thread Hans Mulder
On 5/07/12 07:32:48, Steven D'Aprano wrote: > On Wed, 04 Jul 2012 23:38:17 -0400, Terry Reedy wrote: > >> If I run the script in 3.3 Idle, I get the same output you got. If I >> then enter '5-2' interactively, I still get 3. Maybe the constant folder >> is always on now. > > Yes, I believe consta

Re: Creating an instance when the argument is already an instance.

2012-07-05 Thread Hans Mulder
On 5/07/12 12:47:52, Chris Angelico wrote: > On Thu, Jul 5, 2012 at 8:29 PM, Olive wrote: >> I am creating a new class: package (to analyse the packages database in >> some linux distros). I have created a class package such that >> package("string") give me an instance of package if string is a c

Re: 2 + 2 = 5

2012-07-05 Thread Hans Mulder
On 5/07/12 19:03:57, Alexander Blinne wrote: > On 05.07.2012 16:34, Laszlo Nagy wrote: > five.contents[five.contents[:].index(5)] = 4 > 5 >> 4 > 5 is 4 >> True > That's surprising, because even after changing 5 to 4 both objects still > have different id()s (tested on Py2.7), so 5 is 4

Re: Confusing datetime.datetime

2012-07-06 Thread Hans Mulder
On 6/07/12 00:55:48, Damjan wrote: > On 05.07.2012 16:10, Damjan wrote: >> I've been struggling with an app that uses >> Postgresql/Psycopg2/SQLAlchemy and I've come to this confusing >> behaviour of datetime.datetime. > > > Also this: > > #! /usr/bin/python2 > # retardations in python's dateti

Re: git_revision issues with scipy/numpy/matplotlib

2012-07-07 Thread Hans Mulder
On 7/07/12 07:47:56, Stephen Webb wrote: > I installed py27-numpy / scipy / matplotlib using macports, and it ran > without failing. > > When I run Python I get the following error: > > $>> which python > > /Library/Frameworks/Python.framework/Versions/2.7/bin/python That's a python from pytho

Re: git_revision issues with scipy/numpy/matplotlib

2012-07-07 Thread Hans Mulder
On 7/07/12 14:09:56, Ousmane Wilane wrote: >>>>>> "H" == Hans Mulder writes: > > H> Or you can explicitly type the full path of the python you want. > > H> Or you can define aliases, for example: > > H> alias apple_python=/usr/

Re: lambda in list comprehension acting funny

2012-07-11 Thread Hans Mulder
On 11/07/12 20:38:18, woooee wrote: > You should not be using lambda in this case > .for x in [2, 3]: > .funcs = [x**ctr for ctr in range( 5 )] > .for p in range(5): > .print x, funcs[p] > .print The list is called "funcs" because it is meant to contain functions. Your code doe

Re: How to safely maintain a status file

2012-07-12 Thread Hans Mulder
On 12/07/12 14:30:41, Laszlo Nagy wrote: >> You are contradicting yourself. Either the OS is providing a fully >> atomic rename or it doesn't. All POSIX compatible OS provide an atomic >> rename functionality that renames the file atomically or fails without >> loosing the target side. On POSIX OS

Re: adding a simulation mode

2012-07-13 Thread Hans Mulder
On 13/07/12 04:16:53, Steven D'Aprano wrote: > On Thu, 12 Jul 2012 16:37:42 +0100, andrea crotti wrote: > >> 2012/7/12 John Gordon : >>> In andrea crotti >>> writes: >>> Well that's what I thought, but I can't find any explicit exit anywhere in shutil, so what's going on there? >>> >>>

Re: lambda in list comprehension acting funny

2012-07-13 Thread Hans Mulder
On 13/07/12 18:12:40, Prasad, Ramit wrote: >> VERBOSE = True >> >> def function(arg): >> if VERBOSE: >>print("calling function with arg %r" % arg) >> process(arg) >> >> def caller(): >> VERBOSE = False >> function(1) >> >> - >> Pyt

Re: [Python] RE: How to safely maintain a status file

2012-07-13 Thread Hans Mulder
On 13/07/12 19:59:59, Prasad, Ramit wrote: > I lean slightly towards the POSIX handling with the addition that > any additional write should throw an error. You are now saving to > a file that will not exist the moment you close it and that is > probably not expected. I'd say: it depends. If t

Re: lambda in list comprehension acting funny

2012-07-13 Thread Hans Mulder
On 13/07/12 20:54:02, Ian Kelly wrote: > I've also seen the distinction described as "early" vs. "late" binding > on this list, but I'm not sure how precise that is -- I believe that > terminology more accurately describes whether method and attribute > names are looked up at compile-time or at run

Re: howto do a robust simple cross platform beep

2012-07-14 Thread Hans Mulder
On 14/07/12 20:49:11, Chris Angelico wrote: > On Sun, Jul 15, 2012 at 3:54 AM, Dieter Maurer wrote: >> I, too, would find it useful -- for me (although I do not hate myself). >> >> Surely, you know an alarm clock. Usually, it gives an audible signal >> when it is time to do something. A computer c

Re: lambda in list comprehension acting funny

2012-07-15 Thread Hans Mulder
On 15/07/12 10:44:09, Chris Angelico wrote: > On Sun, Jul 15, 2012 at 6:32 PM, Steven D'Aprano > wrote: >> At compile time, Python parses the source code and turns it into byte- >> code. Class and function definitions are executed at run time, the same >> as any other statement. > > Between the p

Re: Python 2.6 on Mac 10.7 doesn't work

2012-07-17 Thread Hans Mulder
On 17/07/12 15:47:05, Naser Nikandish wrote: > Hi, > > I am trying to install Python 2.6 on Mac OS Lion. Here is what I did: > > 1- Download Mac Installer disk image (2.6) (sig) from >http://www.python.org/getit/releases/2.6/ > > 2- Install it > > 3- Run Python Luncher, go to Python Lunch

Re: Odd csv column-name truncation with only one column

2012-07-19 Thread Hans Mulder
On 19/07/12 13:21:58, Tim Chase wrote: > tim@laptop:~/tmp$ python > Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information. import csv from cStringIO import StringIO s = StringIO('Email\n...@exa

Re: Odd csv column-name truncation with only one column

2012-07-20 Thread Hans Mulder
On 19/07/12 23:10:04, Dennis Lee Bieber wrote: > On Thu, 19 Jul 2012 13:01:37 -0500, Tim Chase > declaimed the following in > gmane.comp.python.general: > >> It just seems unfortunate that the sniffer would ever consider >> [a-zA-Z0-9] as a valid delimiter. +1 > I'd suspect the sniffer l

Re: Encapsulation, inheritance and polymorphism

2012-07-20 Thread Hans Mulder
On 20/07/12 11:05:09, Virgil Stokes wrote: > On 20-Jul-2012 10:27, Steven D'Aprano wrote: >> On Fri, 20 Jul 2012 08:20:57 +1000, Chris Angelico wrote: >> >Since the current evidence indicates the universe will just > keep > expanding, it's more of a "deep freeze death..." H

Re: no data exclution and unique combination.

2012-08-10 Thread Hans Mulder
On 9/08/12 23:33:58, Terry Reedy wrote: > On 8/9/2012 4:06 PM, giuseppe.amatu...@gmail.com wrote: [...] >> unique=dict() >> for row in array2D : >> row = tuple(row) >> if row in unique: >> unique[row] += 1 >> else: >> unique[row] = 1 > > I believe the 4 lines abov

Re: [c-api]Transmutation of an extension object into a read-only buffer adding an integer in-place.

2012-08-10 Thread Hans Mulder
On 10/08/12 10:20:00, Giacomo Alzetta wrote: > I'm trying to implement a c-extension which defines a new class(ModPolynomial > on the python side, ModPoly on the C-side). > At the moment I'm writing the in-place addition, but I get a *really* strange > behaviour. > > Here's the code for the in-p

Re: [c-api]Transmutation of an extension object into a read-only buffer adding an integer in-place.

2012-08-10 Thread Hans Mulder
On 10/08/12 11:25:36, Giacomo Alzetta wrote: > Il giorno venerdì 10 agosto 2012 11:22:13 UTC+2, Hans Mulder ha scritto: [...] > Yes, you're right. I didn't thought the combined operator would do a Py_DECREF > if the iadd operation was implemented, but it obviosuly makes sens

Re: Unable to execute the script

2012-08-11 Thread Hans Mulder
On 11/08/12 00:48:38, Dennis Lee Bieber wrote: > On Fri, 10 Aug 2012 12:35:06 -0700, Smaran Harihar > declaimed the following in > gmane.comp.python.general: > >> Hi Tim, >> >> this is the output for the ls -lsF filename >> >> 8 -rwxr-xr-x 1 root root 5227 Jul 30 13:54 iplantgeo_cgi.py* >> >

Re: [Newbie] How to wait for asyncronous input

2012-08-11 Thread Hans Mulder
On 11/08/12 09:07:51, pozz wrote: > Il 11/08/2012 01:12, Dennis Lee Bieber ha scritto: >> What you apparently missed is that serial.read() BLOCKs until data >> is available (unless the port was opened with a read timeout set). >> [...] >> >> serial.read() may, there for, be using select() b

Re: Arithmetic with Boolean values

2012-08-14 Thread Hans Mulder
On 12/08/12 22:13:20, Alister wrote: > On Sun, 12 Aug 2012 19:20:26 +0100, Mark Lawrence wrote: > >> On 12/08/2012 17:59, Paul Rubin wrote: which can be simplified to: for x in range(len(L)//2 + len(L)%2): >>> >>> for x in range(sum(divmod(len(L), 2))): ... >>> >>> >> So who's going to b

Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host

2012-08-15 Thread Hans Mulder
On 15/08/12 15:30:26, nepaul wrote: > The code: > import MySQLDB > strCmd = "user = 'root', passwd = '123456', db = 'test', host = 'localhost'" > > > > _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host 'user = > 'root', > passwd = '123456', db = 'test', host = 'localhost'' (

Re: dbf.py API question concerning Index.index_search()

2012-08-16 Thread Hans Mulder
On 16/08/12 01:26:09, Ethan Furman wrote: > Indexes have a new method (rebirth of an old one, really): > > .index_search( > match, > start=None, > stop=None, > nearest=False, > partial=False ) > > The defaults are to search the entire index for exact matches and raise >

type(None)()

2012-08-16 Thread Hans Mulder
On 8/08/12 04:14:01, Steven D'Aprano wrote: > NoneType raises an error if you try to create a second instance. bool > just returns one of the two singletons (doubletons?) again. > > py> type(None)() > Traceback (most recent call last): > File "", line 1, in > TypeError: cannot create 'NoneType'

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Hans Mulder
On 16/08/12 14:52:30, Thomas Bach wrote: > On Thu, Aug 16, 2012 at 12:16:03AM +, Steven D'Aprano wrote: >> > Some comments: >> > >> > 1) What you show are not "use cases", but "examples". A use-case is a >> > description of an actual real-world problem that needs to be solved. A >> > couple

Re: [ANNC] pybotwar-0.8

2012-08-17 Thread Hans Mulder
On 16/08/12 23:34:25, Walter Hurry wrote: > On Thu, 16 Aug 2012 17:20:29 -0400, Terry Reedy wrote: > >> On 8/16/2012 11:40 AM, Ramchandra Apte wrote: >> >>> Look you are the only person complaining about top-posting. >> >> No he is not. Recheck all the the responses. >> >>> GMail uses top-posting

Re: How to set the socket type and the protocol of a socket using create_connection?

2012-08-20 Thread Hans Mulder
On 20/08/12 14:36:58, Guillaume Comte wrote: > In fact, socket.create_connection is for TCP only so I cannot use it for a > ping implementation. Why are you trying to reimplement ping? All OS'es I am aware of come with a working ping implementation. > Does anyone have an idea about how to be a

Re: [CGI] Basic newbie error or server configuration error?

2012-08-20 Thread Hans Mulder
On 20/08/12 15:50:43, Gilles wrote: > On Mon, 20 Aug 2012 07:59:39 -0400, Rod Person > wrote: >> Check the Apache error log, there should be more information there. > > It's a shared account, so I only have access to what's in cPanel, > which didn't display anything. Most such panels have a butt

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Hans Mulder
On 22/08/12 08:21:47, Santosh Kumar wrote: > Here is the script I am using: > > from os import linesep > from string import punctuation > from sys import argv > > script, givenfile = argv > > with open(givenfile) as file: > # List to store the capitalised lines. > lines = [] > for li

Re: How to set the socket type and the protocol of a socket using create_connection?

2012-08-22 Thread Hans Mulder
On 22/08/12 09:29:37, Guillaume Comte wrote: > Le mercredi 22 août 2012 04:10:43 UTC+2, Dennis Lee Bieber a écrit : >> On Tue, 21 Aug 2012 10:00:28 -0700 (PDT), Guillaume Comte >> declaimed the following in >> gmane.comp.python.general: >> A later follow-up >>> Unfortunately, my_socket.bind

Re: How do I display unicode value stored in a string variable using ord()

2012-08-22 Thread Hans Mulder
On 19/08/12 19:48:06, Paul Rubin wrote: > Terry Reedy writes: >> py> s = chr(0x + 1) >> py> a, b = s > That looks like a 3.2- narrow build. Such which treat unicode strings > as sequences of code units rather than sequences of codepoints. Not an > implementation bug, but compromise d

Re: Built-in open() with buffering > 1

2012-08-26 Thread Hans Mulder
On 24/08/12 06:35:27, Marco wrote: > Please, can anyone explain me the meaning of the > "buffering > 1" in the built-in open()? > The doc says: "...and an integer > 1 to indicate the size > of a fixed-size chunk buffer." > So I thought this size was the number of bytes or chars, but > it is not Th

Re: help with simple print statement!

2012-08-26 Thread Hans Mulder
On 24/08/12 21:59:12, Prasad, Ramit wrote: > Also, print doesn't work inside a class. It works for me: > python3 Python 3.3.0a1 (v3.3.0a1:f1a9a6505731, Mar 4 2012, 12:26:12) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more informati

Re: Computing win/loss records in Python

2012-08-26 Thread Hans Mulder
On 26/08/12 04:42:59, Steven W. Orr wrote: > On 8/25/2012 10:20 PM, Christopher McComas wrote: >> Greetings, >> >> I have code that I run via Django that grabs the results from various >> sports from formatted text files. The script iterates over every line >> in the formatted text files, finds the

Re: sys.path in python3.3

2012-08-26 Thread Hans Mulder
On 26/08/12 21:21:15, Ned Deily wrote: > In article > , > Nicholas Cole wrote: >> In all previous versions of python, I've been able to install packages >> into the path: >> >> ~/Library/Python/$py_version_short/site-packages >> >> but in the rc builds of python 3.3 this is no longer part of sys

Re: sys.path in python3.3

2012-08-27 Thread Hans Mulder
On 26/08/12 20:47:34, Nicholas Cole wrote: > Dear List, > > In all previous versions of python, I've been able to install packages > into the path: > > ~/Library/Python/$py_version_short/site-packages > > but in the rc builds of python 3.3 this is no longer part of sys.path. It has been changed

Re: class object's attribute is also the instance's attribute?

2012-08-30 Thread Hans Mulder
On 30/08/12 14:34:51, Marco Nawijn wrote: > Note that if you change 'd' it will change for all instances! That depends on how you change it. bobj = A() bobj.d > 'my attribute' > A.d = 'oops...attribute changed' Here you change the attribute on the class. That will affect all ins

Re: class object's attribute is also the instance's attribute?

2012-08-30 Thread Hans Mulder
On 30/08/12 16:48:24, Marco Nawijn wrote: > On Thursday, August 30, 2012 4:30:59 PM UTC+2, Dave Angel wrote: >> On 08/30/2012 10:11 AM, Marco Nawijn wrote: >>> On Thursday, August 30, 2012 3:25:52 PM UTC+2, Hans Mulder wrote: >>>> >>> Learned my lesson

Re: Beginners question

2012-08-30 Thread Hans Mulder
On 30/08/12 14:49:54, Ulrich Eckhardt wrote: > Am 30.08.2012 13:54, schrieb boltar2003@boltar.world: > s = os.stat(".") > print s >> posix.stat_result(st_mode=16877, st_ino=2278764L, st_dev=2053L, >> st_nlink=2, st_u >> id=1000, st_gid=100, st_size=4096L, st_atime=1346327745, >> st_mtime=13

Re: is implemented with id ?

2012-09-05 Thread Hans Mulder
On 5/09/12 15:19:47, Franck Ditter wrote: > Thanks to all, but : > - I should have said that I work with Python 3. Does that matter ? > - May I reformulate the queston : "a is b" and "id(a) == id(b)" > both mean : "a et b share the same physical address". Is that True ? Yes. Keep in mind, thoug

Re: is implemented with id ?

2012-09-05 Thread Hans Mulder
On 5/09/12 17:09:30, Dave Angel wrote: > But by claiming that id() really means address, and that those addresses > might move during the lifetime of an object, then the fact that the id() > functions are not called simultaneously implies that one object might > move to where the other one used to

Re: How to print something only if it exists?

2012-09-07 Thread Hans Mulder
On 6/09/12 19:59:05, tinn...@isbd.co.uk wrote: > I want to print a series of list elements some of which may not exist, > e.g. I have a line:- > > print day, fld[1], balance, fld[2] > > fld[2] doesn't always exist (fld is the result of a split) so the > print fails when it isn't set. How ab

Re: Division help in python

2012-09-08 Thread Hans Mulder
On 8/09/12 09:03:12, garabik-news-2005...@kassiopeia.juls.savba.sk wrote: > Chris Angelico wrote: >> On Fri, Sep 7, 2012 at 10:53 PM, Ramyasri Dodla wrote: >>> I am brand new to python. checking over basic stuff. I came across the >>> problem while doing so. If any body aware of the problem, kind

Re: set and dict iteration

2012-09-08 Thread Hans Mulder
On 8/09/12 22:06:08, Thomas Rachel wrote: > Am 19.08.2012 00:14 schrieb MRAB: > >>> Can someone who is more familiar with the cycle detector and cycle >>> breaker, help prove or disprove the above? >>> >> In simple terms, when you create an immutable object it can contain >> only references to pre

Re: Newbie: where's the new python gone?

2012-09-09 Thread Hans Mulder
On 9/09/12 16:28:55, BobAalsma wrote: > I think I've installed Python 2.7.3 according to the instructions in the > README, and now want to use that version. > However, when typing "python" in Terminal, I get "Python 2.6.4 (r264:75821M, > Oct 27 2009, 19:48:32) ". Was that a freshly opened Termi

Re: Newbie: where's the new python gone?

2012-09-10 Thread Hans Mulder
On 10/09/12 15:04:24, William R. Wing (Bill Wing) wrote: > On Sep 9, 2012, at 10:28 AM, BobAalsma wrote: > >> I think I've installed Python 2.7.3 according to the instructions in the >> README, and now want to use that version. >> However, when typing "python" in Terminal, I get "Python 2.6.4 (

Re: subprocess call is not waiting.

2012-09-14 Thread Hans Mulder
On 13/09/12 19:24:46, woo...@gmail.com wrote: > It possibly requires a "shell=True", That's almost always a bad idea, and wouldn't affect waiting anyway. > but without any code or any way to test, we can not say. That's very true. -- HansM -- http://mail.python.org/mailman/listinfo/python-list

Re: Moving folders with content

2012-09-15 Thread Hans Mulder
On 15/09/12 10:00:16, Nobody wrote: > On Sat, 15 Sep 2012 04:36:00 +, jyoung79 wrote: > >> I am working in both OS X Snow Leopard and Lion (10.6.8 and 10.7.4). >> I'm simply wanting to move folders (with their content) from various >> servers to the hard drive and then back to different dir

Re: using text file to get ip address from hostname

2012-09-15 Thread Hans Mulder
On 15/09/12 18:20:42, Dan Katorza wrote: > בתאריך יום רביעי, 12 בספטמבר 2012 17:24:50 UTC+3, מאת Dan Katorza: >> hello , >> >> >> >> i'm new to Python and i searched the web and could not find an answer for my >> issue. >> >> >> >> i need to get an ip address from list of hostnames which are in a

Re: Moving folders with content

2012-09-16 Thread Hans Mulder
On 16/09/12 10:02:09, jyoun...@kc.rr.com wrote: > Thank you "Nobody" and Hans! You're welcome! >> You may want to use the subprocess module to run 'ditto'. If >> the destination folder does not exist, then ditto will copy MacOS >> specific aspects such as resource forks, ACLs and HFS meta-data.

Re: splitting numpy array unevenly

2012-09-18 Thread Hans Mulder
On 18/09/12 16:02:02, Wanderer wrote: > On Monday, September 17, 2012 7:43:06 PM UTC-4, Martin De Kauwe wrote: >> On Tuesday, September 18, 2012 8:31:09 AM UTC+10, Wanderer wrote: >>> I need to divide a 512x512 image array with the first horizontal >>> and vertical division 49 pixels in. Then every

Re: 'indent'ing Python in windows bat

2012-09-19 Thread Hans Mulder
On 18/09/12 05:01:14, Ian Kelly wrote: > On Mon, Sep 17, 2012 at 7:08 PM, David Smith wrote: >> How do I "indent" if I have something like: >> if (sR=='Cope'): sys.exit(1) elif (sR=='Perform') sys.exit(2) else >> sys.exit(3) > > How about: > > if sR == 'Cope': > sys.exit(1) > elif sR == 'Per

Re: subprocess call is not waiting.

2012-09-19 Thread Hans Mulder
On 19/09/12 12:26:30, andrea crotti wrote: > 2012/9/18 Dennis Lee Bieber : >> >> Unless you have a really massive result set from that "ls", that >> command probably ran so fast that it is blocked waiting for someone to >> read the PIPE. > > I tried also with "ls -lR /" and that definitive

Re: subprocess call is not waiting.

2012-09-19 Thread Hans Mulder
On 19/09/12 18:34:58, andrea crotti wrote: > 2012/9/19 Hans Mulder : >> Yes: using "top" is an observation problem. >> >> "Top", as the name suggests, shows only the most active processes. > > Sure but "ls -lR /" is a very active proces

Re: 'indent'ing Python in windows bat

2012-09-19 Thread Hans Mulder
On 19/09/12 19:51:44, Albert Hopkins wrote: > On Tue, 2012-09-18 at 22:12 -0600, Jason Friedman wrote: >>> I'm converting windows bat files little by little to Python 3 as I find time >>> and learn Python. >>> The most efficient method for some lines is to call Python like: >>> python -c "import sy

Re: sum works in sequences (Python 3)

2012-09-19 Thread Hans Mulder
On 19/09/12 17:07:04, Alister wrote: > On Wed, 19 Sep 2012 16:41:20 +0200, Franck Ditter wrote: > >> Hello, >> I wonder why sum does not work on the string sequence in Python 3 : >> > sum((8,5,9,3)) >> 25 > sum([5,8,3,9,2]) >> 27 > sum('rtarze') >> TypeError: unsupported operand type(s

Re: Installing Pip onto a mac os x system

2012-09-20 Thread Hans Mulder
On 20/09/12 03:32:40, John Mordecai Dildy wrote: > Does anyone know how to install Pip onto a mac os x ver 10.7.4? > > Ive tried easy_instal pip but it brings up this message (but it doesn't help > with my problem): > > error: can't create or remove files in install directory > > The following

Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-20 Thread Hans Mulder
On 20/09/12 05:11:11, Chris Angelico wrote: > On Thu, Sep 20, 2012 at 7:09 AM, Ian Kelly wrote: >> You could do: >> >> os.listdir("/proc/%d/fd" % os.getpid()) >> >> This should work on Linux, AIX, and Solaris, but obviously not on Windows. On MacOS X, you can use os.listdir("/dev/fd") This

Re: portable way of locating an executable (like which)

2012-09-21 Thread Hans Mulder
On 21/09/12 04:31:17, Dave Angel wrote: > On 09/20/2012 06:04 PM, Jason Swails wrote: >> On Thu, Sep 20, 2012 at 5:06 PM, Gelonida N wrote: >> >>> I'd like to implement the equivalent functionality of the unix command >>> /usr/bin/which >>> >>> The function should work under Linux and under window

Re: Reading a file in IDLE 3 on Mac-Lion

2012-09-21 Thread Hans Mulder
On 21/09/12 16:29:55, Franck Ditter wrote: > I create a text file utf-8 encoded in Python 3 with IDLE (Mac Lion). > It runs fine and creates the disk file, visible with > TextWrangler or another. > But I can't open it with IDLE (its name is greyed). > IDLE is supposed to read utf-8 files, no ? > Th

Re: Exact integer-valued floats

2012-09-21 Thread Hans Mulder
On 21/09/12 22:26:26, Dennis Lee Bieber wrote: > On 21 Sep 2012 17:29:13 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > >> >> The question is, what is the largest integer number N such that every >> whole number between -N and N inclusive can be represented as a

Re: Reading a file in IDLE 3 on Mac-Lion

2012-09-22 Thread Hans Mulder
On 22/09/12 09:30:57, Franck Ditter wrote: > In article <505ccdc5$0$6919$e4fe5...@news2.news.xs4all.nl>, > Hans Mulder wrote: > >> On 21/09/12 16:29:55, Franck Ditter wrote: >>> I create a text file utf-8 encoded in Python 3 with IDLE (Mac Lion). >>>

Re: how to do draw pattern with python?

2012-09-22 Thread Hans Mulder
On 21/09/12 19:32:20, Ian Kelly wrote: > On Fri, Sep 21, 2012 at 10:50 AM, Ismael Farfán wrote: >> 2012/9/21 Peter Otten <__pete...@web.de>: >>> echo.hp...@gmail.com wrote: >>> >>> print "\x1b[2J\x1b[0;0H" # optional >> >> Nice code : ) >> >> Could you dissect that weird string for us? >> >> I

Re: Redirecting STDOUT to a Python Variable

2012-09-23 Thread Hans Mulder
On 22/09/12 23:57:52, ross.mars...@gmail.com wrote: > To capture the traceback, so to put it in a log, I use this > > import traceback > > def get_traceback(): # obtain and return the traceback > exc_type, exc_value, exc_traceback = sys.exc_info() > return ''.join(traceback.format_excepti

Re: Exact integer-valued floats

2012-09-23 Thread Hans Mulder
On 23/09/12 01:06:08, Dave Angel wrote: > On 09/22/2012 05:05 PM, Tim Roberts wrote: >> Dennis Lee Bieber wrote: >>> On 22 Sep 2012 01:36:59 GMT, Steven D'Aprano wrote: For non IEEE 754 floating point systems, there is no telling how bad the implementation could be :( >>> Let's see

Re: Need to archive a MySQL database using a python script

2012-09-26 Thread Hans Mulder
On 26/09/12 01:17:24, bruceg113...@gmail.com wrote: > Python Users Group, > > I need to archive a MySQL database using a python script. > I found a good example at: https://gist.github.com/3175221 > > The following line executes however, the archive file is empty. > > os.popen("mysqldump -u %s -

Re: Reducing cache/buffer for faster display

2012-09-29 Thread Hans Mulder
On 29/09/12 02:20:50, Rikishi42 wrote: > On 2012-09-28, Dennis Lee Bieber wrote: >> On Thu, 27 Sep 2012 22:25:39 + (UTC), John Gordon >> declaimed the following in gmane.comp.python.general: >> >>> >>> Isn't terminal output line-buffered? I don't understand why there would >>> be an output d

Re: howto handle nested for

2012-09-29 Thread Hans Mulder
On 29/09/12 03:15:24, Peter Pearson wrote: > On Fri, 28 Sep 2012 09:49:36 -0600, Ian Kelly wrote: >> >> levels = 6 >> for combination in itertools.product(xrange(n_syms), levels): >> # do stuff > n_syms = 3 levels = 6 for combination in itertools.product(xrange(n_syms), levels)

Re: [Python-Dev] [RELEASED] Python 3.3.0

2012-09-29 Thread Hans Mulder
On 29/09/12 14:23:49, Amit Saha wrote: > On Sat, Sep 29, 2012 at 10:18 PM, Georg Brandl wrote: >> On behalf of the Python development team, I'm delighted to announce the >> Python 3.3.0 final release. Thank you!!! >> For a more extensive list of changes in 3.3.0, see >> >> http://docs.pytho

Re: Can't import modules

2012-09-30 Thread Hans Mulder
On 30/09/12 21:42:37, Peter Farrell wrote: > I'm still new to Python, so here's another easy one. After I save something > I've done as a .py file, how do I import it into something else I work on? > Every time I try to import something other than turtle or math, I get this > error message: > > '

Re: parse an environment file

2012-10-01 Thread Hans Mulder
On 1/10/12 16:12:50, Jason Friedman wrote: >> I want my python 3.2.2 script, called via cron, to know what those >> additional variables are. How? > > Thank you for the feedback. A crontab line of > > * * * * * . /path/to/export_file && /path/to/script.py > > does indeed work, but for various

Re: Can somebody give me an advice about what to learn?

2012-10-03 Thread Hans Mulder
On 1/10/12 00:14:29, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> you can't, for instance, retain a "socket connection object" across >> that sort of reload. > > Yeah, that's a problem. There's nothing fundamental about a TCP > connection endpoint which precludes it being ser

Re: How to create a login screen using core python language without using any framework

2012-10-05 Thread Hans Mulder
On 5/10/12 10:03:56, shivakrsh...@gmail.com wrote: > I need to develop a simple login page using Python language with > two fields and a button, like: > > Username, Password, Login > > I know there are some beautiful Python frameworks like > > Django, Grok, WebPy, TurboGears > > which su

Re: error bluetooth

2012-10-05 Thread Hans Mulder
On 5/10/12 10:51:42, Luca Sanna wrote: > from bluetooth import * [..] > luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py When you say "from bluetooth import *", Python will find a file name "bluetooth.py" and import stuff from that file. Since your script happens to

Re: Insert item before each element of a list

2012-10-11 Thread Hans Mulder
On 9/10/12 04:39:28, rusi wrote: > On Oct 9, 7:34 am, rusi wrote: >> How about a 2-paren version? >> > x = [1,2,3] > reduce(operator.add, [['insert', a] for a in x]) >> >> ['insert', 1, 'insert', 2, 'insert', 3] > > Or if one prefers the different parens on the other side: > reduce

Re: cx_Oracle clause IN using a variable

2012-10-16 Thread Hans Mulder
On 16/10/12 15:41:58, Beppe wrote: > Hi all, > I don't know if it is the correct place to set this question, however, > I'm using cx_Oracle to query an Oracle database. > I've a problem to use the IN clause with a variable. > My statement is > > sql = "SELECT field1,field2,field3 > FROM m

Re: list comprehension question

2012-10-17 Thread Hans Mulder
On 17/10/12 09:13:57, rusi wrote: > On Oct 17, 10:22 am, Terry Reedy wrote: >> On 10/16/2012 9:54 PM, Kevin Anthony wrote: >> >>> I've been teaching myself list comprehension, and i've run across >>> something i'm not able to convert. >> >> list comprehensions specifically abbreviate the code that

Re: bad httplib latency due to IPv6 use

2012-10-17 Thread Hans Mulder
On 17/10/12 09:55:13, Ulrich Eckhardt wrote: > Hi! > > I noticed yesterday that a single HTTP request to localhost takes > roughly 1s, regardless of the actually served data, which is way too > long. After some digging, I found that the problem lies in > socket.create_connection(), which first tri

Re: Index in a list

2012-10-17 Thread Hans Mulder
On 17/10/12 12:10:56, Anatoli Hristov wrote: > I'm trying to index a text in a list as I'm importing a log file and > each line is a list. > > What I'm trying to do is find the right line which contains the text > User : and take the username right after the text "User :", but the > list.index("(U

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Hans Mulder
On 18/10/12 08:31:51, Steven D'Aprano wrote: > On Thu, 18 Oct 2012 02:06:19 -0400, Zero Piraeus wrote: >> 3. Say "well, at least it's not a backslash" and break the line using >> > parentheses. > I mostly do this. Since most lines include a bracket of some sort, I > rarely need to add outer parent

Re: error executing "import html.parser" from a script

2012-10-19 Thread Hans Mulder
On 19/10/12 11:15:45, Paul Volkov wrote: > What is this madness? That's because your script is called "html.py". If you import html.parser, Python first imports html, then checks that it's a package and contains a module named "parser". When Python imports html, it searches for a file named "htm

Re: 'generator ignored GeneratorExit''

2012-10-20 Thread Hans Mulder
On 21/10/12 01:41:37, Charles Hixson wrote: > On 10/20/2012 04:28 PM, Ian Kelly wrote: >> On Sat, Oct 20, 2012 at 2:03 PM, Charles Hixson >> wrote: >>> If I run the following code in the same module, it works correctly, >>> but if I >>> import it I get the message: >>> Exception RuntimeError: 'ge

Re: resume execution after catching with an excepthook?

2012-10-25 Thread Hans Mulder
On 24/10/12 14:51:30, andrea crotti wrote: > So I would like to be able to ask for confirmation when I receive a C-c, > and continue if the answer is "N/n". > > I'm already using an exception handler set with sys.excepthook, but I > can't make it work with the confirm_exit, because it's going to q

Re: Error compiling python3.2.3: architecture of input file is incompatible

2012-10-27 Thread Hans Mulder
On 27/10/12 16:11:48, Tobias Marquardt wrote: > Hello, > > I am trying to compile Python 3.2.3. > On my 64 bit Ubuntu machine I have no problems but using Ubuntu 32 but I > get the following error: > > /usr/bin/ld: i386:x86-64 architecture of input file > `Parser/tokenizer_pgen.o' is incompatible

Re: sort order for strings of digits

2012-10-31 Thread Hans Mulder
On 31/10/12 16:17:14, djc wrote: > Python 3.2.3 (default, Oct 19 2012, 19:53:16) > sorted(n+s) > ['1', '10', '101', '13', '1a', '2', '2000', '222 bb', '3', '31', '40', > 'a', 'a1', 'ab', 'acd', 'b a 4', 'bcd'] > sorted(int(x) if x.isdigit() else x for x in n+s) > Traceback (most recent

Re: csv read clean up and write out to csv

2012-11-02 Thread Hans Mulder
On 2/11/12 18:25:09, Sacha Rook wrote: > I have a problem with a csv file from a supplier, so they export data to csv > however the last column in the record is a description which is marked up > with html. > > trying to automate the processing of this csv to upload elsewhere in a > useable format

Re: is implemented with id ?

2012-11-03 Thread Hans Mulder
On 3/11/12 20:41:28, Aahz wrote: > [got some free time, catching up to threads two months old] > > In article <50475822$0$6867$e4fe5...@news2.news.xs4all.nl>, > Hans Mulder wrote: >> On 5/09/12 15:19:47, Franck Ditter wrote: >>> >>> - I should have

Re: is implemented with id ?

2012-11-04 Thread Hans Mulder
On 4/11/12 06:09:24, Aahz wrote: > In article , > Chris Angelico wrote: >> On Sun, Nov 4, 2012 at 2:10 PM, Steven D'Aprano >> wrote: >>> >>> /* Shortcut for empty or interned objects */ >>> if (v == u) { >>> Py_DECREF(u); >>> Py_DECREF(v); >>> return 0; >>> } >>> result = unicode_com

Re: Multi-dimensional list initialization

2012-11-05 Thread Hans Mulder
On 5/11/12 07:27:52, Demian Brecht wrote: > So, here I was thinking "oh, this is a nice, easy way to initialize a 4D > matrix" > (running 2.7.3, non-core libs not allowed): > > m = [[None] * 4] * 4 > > The way to get what I was after was: > > m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]]

  1   2   3   >