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 about:

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, though, that

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 be

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 instances:

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: snip Learned my lesson today. Don't assume you know something. Test

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=1346327754, st

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 to

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 The algorithm

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 information.

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 team in

Re: sys.path in python3.3

2012-08-26 Thread Hans Mulder
On 26/08/12 21:21:15, Ned Deily wrote: In article caau18hc7katbonp7a+-a1pye8byysgfac4fhhksd8peeqjl...@mail.gmail.com, Nicholas Cole nicholas.c...@gmail.com wrote: In all previous versions of python, I've been able to install packages into the path:

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 line in file:

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 guillaume.comt...@gmail.com declaimed the following in gmane.comp.python.general: A later follow-up

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 tjre...@udel.edu 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

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

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 rodper...@rodperson.com 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

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 by default. It

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 stdin, line 1, in module TypeError: cannot create

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 of asserts is not a

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'' (11004))

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 be first in with and thou

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 smaran.hari...@gmail.com 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

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() behind the

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 above are equivalent

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-place

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 sense. The += operator cannot

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 python.l...@tim.thechases.com 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

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... Heat death means *lack* of

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 =

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 Luncher

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 steve+comp.lang.pyt...@pearwood.info 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

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 die...@handshake.de 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

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 gor...@panix.com: In mailman.2043.1342102625.4697.python-l...@python.org andrea crotti andrea.crott...@gmail.com writes: Well that's what I thought, but I can't find

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) - Python semantics: function

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 the

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-time,

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 it

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 does not

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 python.org,

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 han...@xs4all.nl 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/bin/python alias H macport_python=/opt/local/bin

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 datetime import

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 constant

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 di...@bigfoot.com 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

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 /should/ still be

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]) plus

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

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 that

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 error in

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 dthoma...@me.com declaimed the following in gmane.comp.python.general: http://www.freeimagehosting.net/ilbqt That's an interesting configuration... pythonw.exe is a

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: SNIP Python is an executable, and is typically located in a bin directory. To find out where it is, type type python at the shell prompt (that's the first prompt you get if you open a Terminal

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:

Re: Doctest documentation?

2012-05-21 Thread Hans Mulder
On 20/05/12 17:55:52, Steven D'Aprano wrote: Is this a bug in the doctest documentation, or is my browser broken? On this page: http://docs.python.org/library/doctest.html#option-flags-and-directives scroll down to the examples showing the doctest directives, e.g: [quote] For

Re: ctype C library call always returns 0 with Python3

2012-05-19 Thread Hans Mulder
On 19/05/12 13:20:24, Nobody wrote: On Sat, 19 May 2012 11:30:46 +0200, Johannes Bauer wrote: import ctypes libc = ctypes.cdll.LoadLibrary(/lib64/libc-2.14.1.so) print(libc.strchr(abcdef, ord(d))) In 3.x, a string will be passed as a wchar_t*, not a char*. IOW, the memory pointed to by

[issue14810] Bug in tarfile

2012-05-15 Thread Hans Werner May
Hans Werner May nc-may...@netcologne.de added the comment: Out of curiosity: where did you get a file that was last modified in 1956? No idea, this was a jpeg file, probably downloaded from internet. Btw, on Linux you can manipulate the creation date with the touch command, so it is possible

[issue14810] Bug in tarfile

2012-05-14 Thread Hans Werner May
New submission from Hans Werner May nc-may...@netcologne.de: Bug in tarfile: In extractall, when a file exists in tarball with changetime older than (I don't know, in my case it was year 1956) tarfile raises an Overflow exception: File /usr/lib64/python2.7/tarfile.py, line 2298, in utime

Re: Create directories and modify files with Python

2012-05-04 Thread Hans Mulder
On 1/05/12 17:34:57, ru...@yahoo.com wrote: from __future__ import print_function #1 #1: Not sure whether you're using Python 2 or 3. I ran this on Python 2.7 and think it will run on Python 3 if you remove this line. You

Re: Bug in Python

2012-04-17 Thread Hans Mulder
On 18/04/12 03:08:08, Kiuhnm wrote: print(1) print(2) print(3) with open('test') as f: data = f.read() with open('test') as f: data = f.read() I get the same result with Pythin 3.3.0a0 on MacOS X 10.6: 93 ./python.exe -m pdb /tmp/script.py /tmp/script.py(1)module() - print(1)

Re: Installing pypi package twice

2012-02-01 Thread Hans Mulder
On 1/02/12 07:04:31, Jason Friedman wrote: My system's default python is 2.6.5. I have also installed python3.2 at /opt/python. I installed a pypi package for 2.6.5 with: $ tar xzf package.tar.gz $ cd package $ python setup.py build $ sudo python setup.py install How can I also install this

Re: Why does this launch an infinite loop of new processes?

2011-12-22 Thread Hans Mulder
On 21/12/11 21:11:03, Andrew Berg wrote: On 12/21/2011 1:29 PM, Ethan Furman wrote: Anything that runs at import time should be protected by the `if __name__ == '__main__'` idiom as the children will import the __main__ module. So the child imports the parent and runs the spawn code again?

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-22 Thread Hans Mulder
On 22/12/11 14:12:57, Steven D'Aprano wrote: On Thu, 22 Dec 2011 06:49:16 -0500, Neal Becker wrote: I agree with the OP that the current syntax is confusing. The issue is, the meaning of * is context-dependent. Here you are complaining about an operator being confusing because it is

Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python.

2011-12-21 Thread Hans Mulder
On 21/12/11 01:03:26, Ian Kelly wrote: As type conversion functions, bool(x) and int(x) should *always* return bools and ints respectively (or raise an exception), no matter what you pass in for x. That doesn't always happen in 2.x: type(int(1e42)) type 'long' This was fixed in 3.0. --

Re: Obtaining user information

2011-12-09 Thread Hans Mulder
On 10/12/11 02:44:48, Tim Chase wrote: Currently I can get the currently-logged-in-userid via getpass.getuser() which would yield something like tchase. Is there a cross-platform way to get the full username (such as from the GECOS field of /etc/passed or via something like NetUserGetInfo on

Re: Single key press

2011-12-06 Thread Hans Mulder
On 6/12/11 09:48:39, Steven D'Aprano wrote: On Tue, 06 Dec 2011 10:19:55 +0430, Sergi Pasoev wrote: Hi. I wonder if it is realistic to get a single key press in Python without ncurses or any similar library. In single key press I mean something like j and k in Gnu less program, you press the

Re: Reading twice from STDIN

2011-12-02 Thread Hans Mulder
On 2/12/11 10:09:17, janedenone wrote: I had tried sys.stdin = open('/dev/tty', 'r') That seems to work for me. This code: import sys if sys.version_info.major == 2: input = raw_input for tp in enumerate(sys.stdin): print(%d: %s % tp) sys.stdin = open('/dev/tty', 'r') answer =

Re: Reading twice from STDIN

2011-12-01 Thread Hans Mulder
On 2/12/11 03:46:10, Dan Stromberg wrote: You can read piped data from sys.stdin normally. Then if you want something from the user, at least on most *ix's, you would open /dev/tty and get user input from there. 'Not sure about OS/X. Reading from /dev/tty works fine on OS/X. -- HansM --

Re: How to insert my own module in front of site eggs?

2011-11-18 Thread Hans Mulder
On 18/11/11 03:58:46, alex23 wrote: On Nov 18, 11:36 am, Roy Smithr...@panix.com wrote: What if the first import of a module is happening inside some code you don't have access to? No import will happen until you import something. That would be the case if you use the '-S' command line

Re: all() is slow?

2011-11-09 Thread Hans Mulder
On 9/11/11 02:30:48, Chris Rebert wrote: Burn him! Witch! Witch! Burn him! His code turned me into a newt! -- Sent nailed to a coconut carried by swallow. Is that a European swallow or an African swallow? -- HansM -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem using execvp

2011-10-27 Thread Hans Mulder
On 27/10/11 10:57:55, faucheuse wrote: I'm trying to launch my python program with another process name than python.exe. Which version of Python are you using? Which version of which operating system? In order to do that I'm trying to use the os.execvp function : os.execvp(./Launch.py,

Re: compare range objects

2011-10-20 Thread Hans Mulder
On 20/10/11 18:22:04, Westley Martínez wrote: On Thu, Oct 20, 2011 at 06:19:40AM -0700, Yingjie Lan wrote: Hi, Is it possible to test if two range objects contain the same sequence of integers by the following algorithm in Python 3.2? 1. standardize the ending bound by letting it be the

tiff/pbm in pyplot (ubuntu)

2011-10-19 Thread Hans Georg Schaathun
and check that the colour channels are equal. I'll be grateful for any pointers, TIA -- :-- Hans Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Python without a tty

2011-10-03 Thread Hans Mulder
On 3/10/11 08:10:57, Hegedüs, Ervin wrote: hello, On Mon, Oct 03, 2011 at 04:37:43AM +, Steven D'Aprano wrote: I wanted to ensure that it would do the right thing when run without a tty, such as from a cron job. If you fork() your process, then it will also loose the tty... Errhm, I

Re: Python without a tty

2011-10-02 Thread Hans Mulder
On 3/10/11 06:37:43, Steven D'Aprano wrote: On Fri, 30 Sep 2011 21:09:54 +0100, Nobody wrote: On Thu, 29 Sep 2011 11:53:12 +0200, Alain Ketterlin wrote: I have a Python script which I would like to test without a tty attached to the process. I could run it as a cron job, but is there an

Re: regexp compilation error

2011-09-30 Thread Hans Mulder
On 30/09/11 11:10:48, Ovidiu Deac wrote: I have the following regexp which fails to compile. Can somebody explain why? re.compile(r^(?: [^y]* )*, re.X) [...] sre_constants.error: nothing to repeat Is this a bug or a feature? A feature: the message explains why this pattern is not allowed.

Re: Python without a tty

2011-09-30 Thread Hans Mulder
On 30/09/11 20:34:37, RJB wrote: You could try the old UNIX nohup ... technique for running a process in the background (the) with no HangUP if you log out: $ nohup python -c import sys,os; print os.isatty(sys.stdout.fileno()) appending output to nohup.out $ cat nohup.out False But that is

Re: Python without a tty

2011-09-29 Thread Hans Mulder
On 29/09/11 11:21:16, Steven D'Aprano wrote: I have a Python script which I would like to test without a tty attached to the process. I could run it as a cron job, but is there an easier way? There is module on Pypi called python-daemon; it implements PEP-3143. This module detaches the process

Re: Python without a tty

2011-09-29 Thread Hans Mulder
On 29/09/11 12:52:22, Steven D'Aprano wrote: [steve@sylar ~]$ python -c import sys,os; print os.isatty(sys.stdout.fileno()) True If I run the same Python command (without the setsid) as a cron job, I get False emailed to me. That's the effect I'm looking for. In that case, all you need to

Re: killing a script

2011-09-09 Thread Hans Mulder
On 9/09/11 11:07:24, Steven D'Aprano wrote: Sure enough, I now have to hit Ctrl-C repeatedly, once per invocation of script.py. While script.py is running, it receives the Ctrl-C, the calling process does not. You misinterpret what you are seeing: the calling process *does* receive the ctrl-C,

Re: One line command line filter

2011-09-06 Thread Hans Mulder
On 6/09/11 01:18:37, Steven D'Aprano wrote: Terry Reedy wrote: The doc says -ccommand Execute the Python code in command. command can be one or more statements separated by newlines, However, I have no idea how to put newlines into a command-line string. I imagine that it depends on the

Re: Python marks an instance of my class undefined

2011-09-06 Thread Hans Mulder
On 6/09/11 16:18:32, Laszlo Nagy wrote: On 2011-09-06 15:42, Kayode Odeyemi wrote: I was able to get this solved by calling class like this: from core.fleet import Fleet f = Fleet() Thanks to a thread from the list titled TypeError: 'module' object is not callable Or you can also do this:

Re: Can't use subprocess.Popen() after os.chroot() - why?

2011-09-04 Thread Hans Mulder
On 4/09/11 17:25:48, Alain Ketterlin wrote: Erikerik.william...@gmail.com writes: import os from subprocess import Popen, PIPE os.chroot(/tmp/my_chroot) p = Popen(/bin/date, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout_val, stderr_val = p.communicate() print stdout_val but the Popen call is

Re: killing a script

2011-08-30 Thread Hans Mulder
On 30/08/11 06:13:41, Steven D'Aprano wrote: On Tue, 30 Aug 2011 08:53 am Arnaud Delobelle wrote: [...] Yes, but if I am not mistaken, that will require me to put a line or two after each os.system call. That's almost like whack-a-mole at the code level rather than the Control-C level. OK, not

Re: how to format long if conditions

2011-08-27 Thread Hans Mulder
On 27/08/11 09:08:20, Arnaud Delobelle wrote: I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to80 colums) Here's an example taken from something I'm writing at the moment and how I've formatted it: if (isinstance(left,

Re: how to format long if conditions

2011-08-27 Thread Hans Mulder
On 27/08/11 11:05:25, Steven D'Aprano wrote: Hans Mulder wrote: [...] It may look ugly, but it's very clear where the condition part ends and the 'then' part begins. Immediately after the colon, surely? On the next line, actually :-) The point is, that this layout makes it very clear

Re: how to format long if conditions

2011-08-27 Thread Hans Mulder
On 27/08/11 17:16:51, Colin J. Williams wrote: What about: cond= isinstance(left, PyCompare) and isinstance(right, PyCompare) and left.complist[-1] is right.complist[0] py_and= PyCompare(left.complist + right.complist[1:])if cond else: py_and = PyBooleanAnd(left, right) Colin

Re: relative speed of incremention syntaxes (or i=i+1 VS i+=1)

2011-08-21 Thread Hans Mulder
On 21/08/11 19:14:19, Irmen de Jong wrote: What the precise difference (semantics and speed) is between the BINARY_ADD and INPLACE_ADD opcodes, I dunno. Look in the Python source code or maybe someone knows it from memory :-) There is a clear difference in semantics: BINARY_ADD always

Re: Wait for a keypress before continuing?

2011-08-17 Thread Hans Mulder
On 17/08/11 10:03:00, peter wrote: Is there an equivalent to msvcrt for Linux users? I haven't found one, and have resorted to some very clumsy code which turns off keyboard excho then reads stdin. Seems such an obvious thing to want to do I am surprised there is not a standard library module

[issue12558] Locale-dependent crash for float width argument to Tkinter widget constructor

2011-07-14 Thread Hans Bering
New submission from Hans Bering hans.ber...@arcor.de: The attached script will crash on a current Ubuntu with Python 3.2 + tcl/tk when using a locale which uses a comma as a decimal separator (e.g., German). It will not crash when using a locale which uses a dot as the decimal separator (e.g

[issue12558] Locale-dependent crash for float width argument to Tkinter widget constructor

2011-07-14 Thread Hans Bering
Hans Bering hans.ber...@arcor.de added the comment: Sorry for the misclassification, and thanks for correcting that. I agree, this issue is most likely related to issue 10647; but at some level I think they must be different, because issue 10647 seems to be specific to Python 3.1 under

[issue10647] scrollbar crash in non-US locale format settings

2011-07-07 Thread Hans Bering
Hans Bering hans.ber...@arcor.de added the comment: Ok, _now_ I have run into the same problem. I have attached a small script similar to the original entry (but shorter) which will reliably crash with Python 3.1.4 on Windows 7 (64bit) when using a locale with a comma decimal fraction marker

[issue10647] scrollbar crash in non-US locale format settings

2011-07-07 Thread Hans Bering
Changes by Hans Bering hans.ber...@arcor.de: Removed file: http://bugs.python.org/file22535/tkinterCrash.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10647

[issue10647] scrollbar crash in non-US locale format settings

2011-07-05 Thread Hans Bering
Hans Bering hans.ber...@arcor.de added the comment: I'm sorry, but it seems the issue described in my previous edit (msg139566) is perhaps not related to the original Scrollbar problem. I had thought they were because of the superficial resemblance (i.e., crashes due to locale-dependent float

[issue10647] scrollbar crash in non-US locale format settings

2011-07-01 Thread Hans Bering
Hans Bering hans.ber...@arcor.de added the comment: I have been able to reproduce this problem with a current Python 3.2 + tcl/tk on Ubuntu. I have attached a script which should crash with the following output stacktrace (you might have to find set a suitable locale depending on your OS

Re: search through this list's email archives

2011-06-23 Thread Hans Mulder
On 23/06/11 18:11:32, Cathy James wrote: I looked through this forum's archives, but I can't find a way to search for a topic through the archive. Am I missing something? One way to search the past contributions to this forum is to go to http://groups.google.com/advanced_search and specify

Re: opening a file

2011-06-20 Thread Hans Mulder
On 20/06/11 08:14:14, Florencio Cano wrote: This works: infile=open('/foo/bar/prog/py_modules/this_is_a_test','r') This doesn't: infile=open('~/prog/py_modules/this_is_a_test','r') Can't I work with files using Unix expressions? You can use the glob module:

Re: Parsing a dictionary from a format string

2011-06-20 Thread Hans Mulder
On 20/06/11 20:14:46, Tim Johnson wrote: Currently using python 2.6, but am serving some systems that have older versions of python (no earlier than. Question 1: With what version of python was str.format() first implemented? That was 2.6, according to the online docs. Take a look at the

Re: Embedding Python in a shell script

2011-06-17 Thread Hans Mulder
On 17/06/11 19:47:50, Timo Lindemann wrote: On Fri, 17 Jun 2011 00:57:25 +, Jason Friedman said: but for various reasons I want a single script. Any alternatives? you can use a here document like this: #! /bin/bash /usr/bin/python2 EOPYTHON def hello(): print(Hello,

Re: installing NLTK

2011-06-17 Thread Hans Mulder
On 17/06/11 21:58:53, Nige Danton wrote: Mac OSX python 2.6.1: I'm trying to install the natural language toolkit and following the instructions here www.NLTK.org/download I've downloaded the PyYAML package and in a terminal window tried to install it. However terminal asks for my password -

Re: installing NLTK

2011-06-17 Thread Hans Mulder
On 17/06/11 22:57:41, Nige Danton wrote: Hans Mulderhan...@xs4all.nl wrote: On 17/06/11 21:58:53, Nige Danton wrote: Mac OSX python 2.6.1: I'm trying to install the natural language toolkit and following the instructions here www.NLTK.org/download I've downloaded the PyYAML package

<    1   2   3   4   5   6   7   >