Re: python with echo

2009-11-12 Thread Hans Mulder
Steven D'Aprano wrote: On Wed, 11 Nov 2009 17:24:37 -0800, hong zhang wrote: List, I have a question of python using echo. POWER = 14 return_value = os.system('echo 14 /sys/class/net/wlan1/device/tx_power') can assign 14 to tx_power But return_value = os.system('echo $POWER

Re: Perl conversion to python...

2009-11-24 Thread Hans Mulder
J Kenneth King wrote: Benjamin Schollnick bscholln...@gmail.com writes: select(undef, undef, undef, 0.01); # select() is a system call in Perl.. # insert Python equivalent here That would be: time.sleep(0.01) Perl has a sleep() built-in, but it

Re: Python without wrapper script

2009-12-02 Thread Hans Mulder
Ulrich Eckhardt wrote: eric.frederich wrote: Is there a way to set up environment variables in python itself without having a wrapper script. Yes, sure, you can set environment variables... The wrapper script is now something like #!/bin/bash export

Re: Why Can't I Delete a File I Created with Win XP?

2009-12-06 Thread Hans Mulder
J wrote: But that being said, this brings to mind a question about this... in *nix, when I can't do something like delete a file or directory, or unmount a filesystem and cant find the cause, I can do an lsof and grep for references to the file/directory in question, then work from there to

Re: OS independent way to check if a python app is running?

2009-12-22 Thread Hans Mulder
Dan Sommers wrote: On Mon, 14 Dec 2009 14:14:05 -0500, python wrote: Is there an os independent way to check if a python app is running? Goal: I have a server program based on cherrypy that I only want to have running once. If a system administrator accidentally attempts to run this program

Re: Threading change, 2.5.4 - 2.6.1

2010-01-08 Thread Hans Mulder
anon wrote: Gib Bogle wrote: The code below runs with Python 2.5.4, but gives the following error messages with Python 2.6.1. What needs to be done to make it work? Thanks. C:\Summer09\Tutorialspython url_queue.pyw Traceback (most recent call last): File url_queue.pyw, line 3, in module

Re: Terminal application with non-standard print

2010-01-25 Thread Hans Mulder
Grant Edwards wrote: On 2010-01-24, R?mi babedo...@yahoo.fr wrote: I would like to do a Python application that prints data to stdout, but not the common way. I do not want the lines to be printed after each other, but the old lines to be replaced with the new ones, like wget does it for

Re: formatting a number as percentage

2010-02-22 Thread Hans Mulder
Günther Dietrich wrote: vsoler vicente.so...@gmail.com wrote: I'm trying to print .7 as 70% I've tried: print format(.7,'%%') .7.format('%%') but neither works. I don't know what the syntax is... Did you try this: print('%d%%' % (0.7 * 100)) 70% That method will always round down;

Re: regex (?!..) problem

2009-10-06 Thread Hans Mulder
Stefan Behnel wrote: Wolfgang Rohdewald wrote: I want to match a string only if a word (C1 in this example) appears at most once in it. def match(s): if s.count(C1) 1: return None return s If this doesn't fit your requirements, you may want to provide some

Re: del an imported Class at EOF... why?

2009-10-07 Thread Hans Mulder
Ryan wrote: [] It does beg the question for me. Consider the example from his code below from PyQt4 import QtGui class LauncherWidget( QtGui.QWidget ): # A Specialization of QWidget del QtGui Next time python comes across from PyQt4 import QtGui it would have to re-import the

Re: how to build with 2.4 having 2.6 as main python

2010-06-14 Thread Hans Mulder
Benjamin Kaplan wrote: On Mon, Jun 14, 2010 at 3:09 AM, Alexzive zasaconsult...@gmail.com wrote: thanks guys, the solution for me was python2.4 setup.py install --prefix=/usr/local cheers, AZ Don't do that! Like Steven said, you'll kill your system that way. Lots of programs in Linux use

Re: Need instruction on how to use isinstance

2010-06-30 Thread Hans Mulder
alex23 wrote: Stephen Hansen me+list/pyt...@ixokai.io wrote: P.S. The removal of callable is something I don't understand in Python 3: while generally speaking I do really believe and use duck typing, I too have on occassion wanted to dispatch based on 'is callable? do x'. Sometimes its not

Re: Check if a command is valid

2010-07-13 Thread Hans Mulder
Chris Rebert wrote: `where` seems to be a zsh built-in: $ # I'm in UR bash $ nonexistent -bash: nonexistent: command not found $ where bash -bash: where: command not found And not everyone has zsh installed, so... I don't see why one shouldn't use the standard `which` *nix command instead.

Re: cx_Oracle 5.0.4 + Python 3.1.2 + Oracle Instant Client 10.2.04; DLL Load failed on import (Win/NT)

2010-08-13 Thread Hans Mulder
tormod wrote: On Aug 12, 12:30 pm, Alexander Gattin xr...@yandex.ru wrote: Does Windows have anything like LD_LIBRARY_PATH/SHLIB_PATH? Yes and no. Windows uses PATH both for finding execuables and for finding DLLs. So if there's a DLL Windows cannot find, you need to add the folder

Re: bash: syntax error near unexpected token

2010-08-17 Thread Hans Mulder
Benjamin Kaplan wrote: On Mon, Aug 16, 2010 at 11:33 PM, kreglet kreg...@gmail.com wrote: desktop:~/bin$ modtest.py desktop:~/bin$ evenodd(45) bash: syntax error near unexpected token `45' And this is what's supposed to happen any time you try this in any shell. When you call evenodd, bash

Re: import antigravity

2010-03-16 Thread Hans Mulder
Ulrich Eckhardt wrote: Chris Rebert wrote: You're a bit behind the times. If my calculations are right, that comic is over 2 years old. import timetravel I think you mean: from __future__ import timetravel -- HansM -- http://mail.python.org/mailman/listinfo/python-list

Re: A 'foolproof' way to query inheritance tree? numbers.Real in 2.6)

2010-04-13 Thread Hans Mulder
Steven D'Aprano wrote: Given a class C, is there some way to find out what classes issubclass(C, X) will return true for? Obviously you can get a partial list, by walking the MRO, but is there a list somewhere of which ABCs consider C a subclass? Presumably the general answer is No, because

Re: Striving for PEP-8 compliance

2010-04-14 Thread Hans Mulder
Grant Edwards wrote: On 2010-04-09, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message 4bbf6eb8$0$1670$742ec...@news.sonic.net, John Nagle wrote: Lawrence D'Oliveiro wrote: In message mailman.1610.1270655932.23598.python-l...@python.org, Gabriel Genellina wrote: If

Re: Cross-platform way to retrieve the current (Operative system) DNS server IP address in python

2010-04-30 Thread Hans Mulder
joamag wrote: It's not my ip address that I want to discover... I want to discover my default dns server ip address. This ip is stored in an operative system basis. Dos anyone know how to get it ? You asked for a cross-platform solution; there probably isn't one. The code below works on

Re: Fast Efficient way to transfer an object to another list

2010-05-02 Thread Hans Mulder
Francesco Bochicchio wrote: Anyway i think that list.extract( old_list, predicate ) - new_list would be a nice addition to the standard library You could use filter( predicate, old_list ) - new_list -- HansM -- http://mail.python.org/mailman/listinfo/python-list

Re: Python + vim + spaces vs tab

2010-06-07 Thread Hans Mulder
Jean-Michel Pichavant wrote: Hello, Does anyone knows a way to configure vim so it automatically select to correct expandtab value depending on the current buffer 'way of doing' ? I need to edit different files, some are using spaces, others tabs. Those belong to different projects, and

Re: Using property() to extend Tkinter classes but Tkinter classes are old-style classes?

2010-11-30 Thread Hans Mulder
Giacomo Boffi wrote: Terry Reedy tjre...@udel.edu writes: On 11/28/2010 3:47 PM, pyt...@bdurham.com wrote: I had planned on subclassing Tkinter.Toplevel() using property() to wrap access to properties like a window's title. After much head scratching and a peek at the Tkinter.py source, I

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: 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: 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: 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 ros...@gmail.com wrote: On Fri, Sep 7, 2012 at 10:53 PM, Ramyasri Dodla ramyasr...@gmail.com wrote: I am brand new to python. checking over basic stuff. I came across the problem while doing so. If any

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

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 Terminal

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 overhaalsgang_24_...@me.com 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

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

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 textfile. this

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

Re: splitting numpy array unevenly

2012-09-19 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 59

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 dav...@invtools.com 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 ==

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 wlfr...@ix.netcom.com: 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

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 han...@xs4all.nl: 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 process if you try to run it.. Not necessarily: It's quite

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 sys;

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) for +: 'int' and 'str' I

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 error

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 ian.g.ke...@gmail.com 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)

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 gelon...@gmail.com wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under

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 ? This

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

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 han...@xs4all.nl 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). It runs fine and creates the disk file

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 sulfur...@gmail.com 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? It isn't

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

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 wlfr...@ix.netcom.com 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

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 -p%s -h

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 wlfr...@ix.netcom.com wrote: On Thu, 27 Sep 2012 22:25:39 + (UTC), John Gordon gor...@panix.com declaimed the following in gmane.comp.python.general: Isn't terminal output line-buffered? I don't understand why there

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 ian.g.ke...@gmail.com 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),

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 ge...@python.org 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

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 reasons

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 mailman.1677.1349019431.27098.python-l...@python.org, Chris Angelico ros...@gmail.com 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

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 support web

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 be

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 rustompm...@gmail.com 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:

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 my_table

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

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 tries

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((User :)

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 parentheses

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 html.py.

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 charleshi...@earthlink.net wrote: If I run the following code in the same module, it works correctly, but if I import it I get the message: Exception

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

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 with

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 call last):

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

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 han...@xs4all.nl wrote: On 5/09/12 15:19:47, Franck Ditter wrote: - I should have said that I work with Python 3. Does

Re: is implemented with id ?

2012-11-04 Thread Hans Mulder
On 4/11/12 06:09:24, Aahz wrote: In article mailman.3250.1351999198.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Sun, Nov 4, 2012 at 2:10 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: /* Shortcut for empty or interned objects */ if (v == u) {

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]] Or

Re: Base class and Derived class question

2012-11-06 Thread Hans Mulder
On 6/11/12 14:47:03, cyberira...@gmail.com wrote: Hey guys, I'm trying to understand how is working base class and derived class. So, I have to files baseClass.py and derivedClass.py. baseClass.py : [CODE]class baseClass(): def bFunction(self): print We are in a base

Re: Right solution to unicode error?

2012-11-08 Thread Hans Mulder
On 8/11/12 00:53:49, Steven D'Aprano wrote: This error confuses me. Is that an exact copy and paste of the error, or have you edited it or reconstructed it? Because it seems to me that if task.subject is a unicode string, as it appears to be, calling print on it should succeed: py s =

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-08 Thread Hans Mulder
On 8/11/12 19:05:11, jkn wrote: Hi All i am trying to build up a set of subprocess.Ponen calls to replicate the effect of a horribly long shell command. I'm not clear how I can do one part of this and wonder if anyone can advise. I'm on Linux, fairly obviously. I have a command which

Re: Obnoxious postings from Google Groups

2012-11-09 Thread Hans Mulder
On 6/11/12 23:50:59, Steven D'Aprano wrote: On Tue, 06 Nov 2012 17:16:44 +, Prasad, Ramit wrote: To enter the newline, I typed Ctrl-Q to tell bash to treat the next character as a literal, and then typed Ctrl-J to get a newline. That sounds complicated, my version of bash lets me type

Re: Obnoxious postings from Google Groups

2012-11-09 Thread Hans Mulder
On 7/11/12 01:13:47, Steven D'Aprano wrote: On Tue, 06 Nov 2012 23:08:11 +, Prasad, Ramit wrote: Steven D'Aprano wrote: On Tue, 06 Nov 2012 17:16:44 +, Prasad, Ramit wrote: To enter the newline, I typed Ctrl-Q to tell bash to treat the next character as a literal, and then typed

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-12 Thread Hans Mulder
On 12/11/12 16:36:58, jkn wrote: slight followup ... I have made some progress; for now I'm using subprocess.communicate to read the output from the first subprocess, then writing it into the secodn subprocess. This way I at least get to see what is happening ... The reason 'we' weren't

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-12 Thread Hans Mulder
On 12/11/12 18:22:44, jkn wrote: Hi Hans On Nov 12, 4:36 pm, Hans Mulder han...@xs4all.nl wrote: On 12/11/12 16:36:58, jkn wrote: slight followup ... I have made some progress; for now I'm using subprocess.communicate to read the output from the first subprocess, then writing

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-14 Thread Hans Mulder
On 13/11/12 22:36:47, Thomas Rachel wrote: Am 12.11.2012 19:30 schrieb Hans Mulder: This will break if there are spaces in the file name, or other characters meaningful to the shell. If you change if to xargsproc.append(test -f '%s/{}' md5sum '%s

Re: Detect file is locked - windows

2012-11-14 Thread Hans Mulder
On 14/11/12 02:14:59, Mark Lawrence wrote: On 14/11/2012 00:33, Ali Akhavan wrote: I am trying to open a file in 'w' mode open('file', 'wb'). open() will throw with IOError with errno 13 if the file is locked by another application or if user does not have permission to open/write to the

Re: Detect file is locked - windows

2012-11-14 Thread Hans Mulder
On 14/11/12 11:02:45, Tim Golden wrote: On 14/11/2012 00:33, Ali Akhavan wrote: I am trying to open a file in 'w' mode open('file', 'wb'). open() will throw with IOError with errno 13 if the file is locked by another application or if user does not have permission to open/write to the file.

Re: Unpaking Tuple

2012-11-18 Thread Hans Mulder
On 9/10/12 08:07:32, Bob Martin wrote: in 682592 20121008 232126 Prasad, Ramit ramit.pra...@jpmorgan.com wrote: Thomas Bach wrote:=0D=0A Hi there,=0D=0A =0D=0A On Sat, Oct 06, 2012 at = 03:08:38PM +, Steven D'Aprano wrote:=0D=0A =0D=0A my_tuple =3D my_= tuple[:4]=0D=0A a,b,c,d =3D

Re: Premature end of script headers: wsgihandler.py on usage of BytesIO()

2012-11-19 Thread Hans Mulder
On 19/11/12 14:29:13, Yasir Saleem wrote: Hi all, I am generating graphs using cairo plot in web2py project. Here I am using BytesIO() stream for generating graphs. Everything runs fine when I run on localhost but when I deploy it on apache server and then run from different machines OR

Re: 10 sec poll - please reply!

2012-11-21 Thread Hans Mulder
On 21/11/12 02:17:26, Steven D'Aprano wrote: On Tue, 20 Nov 2012 18:00:59 -0600, Tim Chase wrote: On 11/20/12 06:18, Michael Herrmann wrote: am having difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in

Re: Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-21 Thread Hans Mulder
On 21/11/12 17:59:05, Alister wrote: On Wed, 21 Nov 2012 04:43:57 -0800, Giacomo Alzetta wrote: I just came across this: 'spam'.find('', 5) -1 Now, reading find's documentation: print(str.find.__doc__) S.find(sub [,start [,end]]) - int Return the lowest index in S where substring

Re: mysql insert with tuple

2012-11-21 Thread Hans Mulder
On 21/11/12 18:19:15, Christian wrote: Hi , my purpose is a generic insert via tuple , because the number of fields and can differ. But I'm stucking . ilist=['hello',None,7,None,None] #This version works, but all varchar fields are in extra '' enclosed. con.execute( INSERT INTO {}

Re: Print value from array

2012-11-23 Thread Hans Mulder
On 22/11/12 19:44:02, Mike wrote: Hello, I am noob en python programing, i wrote a perl script for read from csv but now i wish print value but the value must be within double quote and I can not do this. For example now the output is: ma user@domain displayName Name SecondName

Re: How to get a screen length of a multibyte string?

2012-11-25 Thread Hans Mulder
On 25/11/12 11:19:18, kobayashi wrote: Hello, Under platform that has fixed pitch font, I want to get a screen length of a multibyte string --- sample --- s1 = uabcdef s2 = uあいう # It has same screen length as s1's. print len(s1) # Got 6 print len(s2) # Got 3, but I want get 6.

Re: How to pass class instance to a method?

2012-11-26 Thread Hans Mulder
On 27/11/12 00:07:10, Ian Kelly wrote: On Mon, Nov 26, 2012 at 2:58 PM, Dave Angel d...@davea.name wrote: Not how I would put it. In a statically typed language, the valid types are directly implied by the function parameter declarations, As alluded to in my previous post, not all

Re: Getting a seeded value from a list

2012-11-26 Thread Hans Mulder
On 26/11/12 21:17:40, Prasad, Ramit wrote: Chris Angelico wrote: On Sat, Nov 24, 2012 at 3:27 AM, Prasad, Ramit ramit.pra...@jpmorgan.com wrote: Steven D'Aprano wrote: On Wed, 21 Nov 2012 14:41:24 +1100, Chris Angelico wrote: However, this still means that the player will see the exact

Re: Weird import failure with nosetests --processes=1

2012-11-29 Thread Hans Mulder
On 29/11/12 04:13:57, Roy Smith wrote: I've got a minimal test script: - $ cat test_foo.py import pyza.models print pyza.models def test_foo(): pass - pyza.models is a package. Under normal conditions, I can import it

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Hans Mulder
On 2/12/12 18:25:22, Roy Smith wrote: This is kind of weird (Python 2.7.3): try: print hello except foo: print foo prints hello. The problem (IMHO) is that apparently the except clause doesn't get evaluated until after some exception is caught. Which means it never notices

Re: Conversion of List of Tuples

2012-12-04 Thread Hans Mulder
On 4/12/12 10:44:32, Alexander Blinne wrote: Am 03.12.2012 20:58, schrieb subhabangal...@gmail.com: Dear Group, I have a tuple of list as, tup_list=[(1,2), (3,4)] Now if I want to covert as a simple list, list=[1,2,3,4] how may I do that? Another approach that has not yet been

Re: mini browser with python

2012-12-05 Thread Hans Mulder
On 5/12/12 20:36:04, inq1ltd wrote: Python help. ?This is not a Python question. I can connect to and download a web page, html code, and save it to a file. If connected to the web, I can use KWrite to open the file and navigate the page. I want to view the html file without using

Re: mini browser with python

2012-12-05 Thread Hans Mulder
On 5/12/12 22:44:21, inq1ltd wrote: I can connect to and download a web page, html code, and save it to a file. If connected to the web, I can change the settings on KWrite to open the file and navigate the page, (just like a browser does). I want to view the html file without using a

Re: Installing packages on Mac OS X 10.7.5

2012-12-05 Thread Hans Mulder
On 6/12/12 00:56:55, Irmen de Jong wrote: On 6-12-2012 0:12, John Dildy wrote: I have python v2.7.1 and I am trying to install packages on the Mac OS X v10.7.5 I am trying to install: Distribute Nose virtualenv If anyone can help me that would be great Avoid changing stuff on the

  1   2   3   >