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

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 cl

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>

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 w

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 let

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 lit

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' w

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 wrote: >> On 12/11/12 16:36:58, jkn wrote: >> >> >> >> >> >> >> >> >> >>> slight followup ... >> >>> I have made some progre

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(

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

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" 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 my_tuple if le

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

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

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 lowe

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(""" INSER

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 SecondNam

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 = u"abcdef" > s2 = u"あいう" # It has same "screen" length as s1's. > print len(s1) # Got 6 > print len(s2) # Got 3, but I w

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 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 statically typed l

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

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 imp

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

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 h

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

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 st

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

2012-12-06 Thread Hans Mulder
On 6/12/12 11:07:51, iMath wrote: > the following code originally from > http://zetcode.com/databases/mysqlpythontutorial/ > within the "Writing images" part . > > > import MySQLdb as mdb > import sys > > try: > fin = open("Chrome_Logo.svg.png",'rb') > img = fin.read() > fin.close()

Re: Confused compare function :)

2012-12-06 Thread Hans Mulder
On 6/12/12 12:55:16, peter wrote: > Is perfectly right to use try catch for a flow control. > Just think in something more complex like this. > >try: > self._conn = MySQLdb.connect(host=host, > user=user, > passwd=passwd, > db=db) >

Re: Confused compare function :)

2012-12-06 Thread Hans Mulder
On 6/12/12 14:58:01, Chris Angelico wrote: > On Fri, Dec 7, 2012 at 12:33 AM, Thomas Rachel > > wrote: >> > Am 06.12.2012 09:49 schrieb Bruno Dupuis: >> > >>> >> The point is Exceptions are made for error handling, not for normal >>> >> workflow. I hate when i read that for example: >>> >> >>> >>

Re: pyodbc utf-8

2012-12-07 Thread Hans Mulder
On 7/12/12 08:41:27, Markus Christen wrote: > good morning > > i am using pyodbc 3.0.6 for win32 python 2.7.3 > i used it to connect with a MsSql db. Now i have a little problem with the > umlaut. > i cant change anything in the db and there are umlauts like "ä", "ö" and "ü" saved. > so i have to

Re: python 3.3 urllib.request

2012-12-07 Thread Hans Mulder
On 7/12/12 13:52:52, Steeve C wrote: > hello, > > I have a python3 script with urllib.request which have a strange > behavior, here is the script : > > + > #!/usr/bin/env python3 > # -*- coding: utf-8 -*- > > import

Re: python 3.3 urllib.request

2012-12-08 Thread Hans Mulder
On 8/12/12 07:20:55, Terry Reedy wrote: > On 12/7/2012 12:27 PM, Hans Mulder wrote: >> On 7/12/12 13:52:52, Steeve C wrote: >>> hello, >>> >>> I have a python3 script with urllib.request which have a stra

Re: regex walktrough

2012-12-08 Thread Hans Mulder
On 8/12/12 18:48:13, rh wrote: > Look through some code I found this and wondered about what it does: > ^(?P[0-9A-Za-z-_.//]+)$ > > Here's my walk through: > > 1) ^ match at start of string > 2) ?P if a match is found it will be accessible in a > variable salsipuedes I wouldn't call it a variab

Re: Issue with seeded map generation

2012-12-08 Thread Hans Mulder
On 8/12/12 22:32:22, Graham Fielding wrote: > Hey, all! > > I've managed to get my project to a semi-playable state (everything > functions, if not precisely the way I'd like it to). One small issue is > that when the player moves from one level to the next, the items and > monsters in the previ

Re: regex walktrough

2012-12-08 Thread Hans Mulder
On 8/12/12 23:19:40, rh wrote: > I reduced the expression too. Now I wonder why re.DEBUG doesn't unroll > category_word. Some other re flag? he category word consists of the '_' character and the characters for which .isalnum() return True. On my system there are 102158 characters matching '\w':

Re: regex walktrough

2012-12-08 Thread Hans Mulder
On 8/12/12 23:57:48, rh wrote: > Not sure if the \w sequence includes the - or the . or the / > I think it does not. You guessed right: >>> [ c for c in 'x-./y' if re.match(r'\w', c) ] ['x', 'y'] >>> So x and y match \w and -, . and / do not. Hope this helps, -- HansM -- http://mail.python

Re: Running a python script under Linux

2012-12-14 Thread Hans Mulder
On 14/12/12 03:45:18, Steven D'Aprano wrote: > I understand this is not exactly a Python question, but it may be of > interest to other Python programmers, so I'm asking it here instead of a > more generic Linux group. > > I have a Centos system which uses Python 2.4 as the system Python, so I

Re: Running a python script under Linux

2012-12-14 Thread Hans Mulder
On 14/12/12 14:38:25, D'Arcy J.M. Cain wrote: > On Fri, 14 Dec 2012 14:18:28 +0100 > Hans Mulder wrote: >> The Pythonic way to get what you want, is to be explicit: >> >> #!/usr/local/bin/python2.7 -V >> >> If you do that, it will even work in situations

Re: Unicode

2012-12-17 Thread Hans Mulder
On 17/12/12 22:09:04, Dave Angel wrote: > print src.decode("utf-8").encode("latin-1", "ignore") > > That says to decode it using utf-8 (because the html declared a utf-8 > encoding), and encode it back to latin-1 (because your terminal is stuck > there), then print. > > > Just realize that once

Re: os.system and subprocess odd behavior

2012-12-18 Thread Hans Mulder
On 18/12/12 06:10:43, photonym...@gmail.com wrote: > I hope I understand the question... but shouldn't you wait for the process to > complete before exiting? > > Something like: > > pid = subprocess.Popen(...) > pid.wait() > > Otherwise, it'll exit before the background process is done. Why w

Re: Delete dict and subdict items of some name

2012-12-18 Thread Hans Mulder
On 18/12/12 06:30:48, Gnarlodious wrote: > This problem is solved, I am so proud of myself for figuring it out! > After reading some of these ideas I discovered the plist is really > lists underneath any "Children" key: > > > from plistlib import readPlist > > def explicate(listDicts): > f

Re: os.system and subprocess odd behavior

2012-12-18 Thread Hans Mulder
On 18/12/12 11:39:56, Dave Angel wrote: > On 12/18/2012 05:27 AM, Hans Mulder wrote: >> On 18/12/12 06:10:43, photonym...@gmail.com wrote: >>> I hope I understand the question... but shouldn't you wait for the process >>> to complete before exiting? >

Re: os.system and subprocess odd behavior

2012-12-18 Thread Hans Mulder
On 17/12/12 21:56:50, py_genetic wrote: > /usr/local/Calpont/mysql/bin/mysql > --defaults-file=/usr/local/Calpont/mysql/my.cnf -u root myDB < > /home/myusr/jobs/APP_JOBS/JOB_XXX.SQL > /home/myusr/jobs/APP_JOBS/JOB_XXX.TXT If you're trying to interact with a MySQL database, then you should really

Re: Why Doesn't This MySQL Statement Execute?

2012-12-18 Thread Hans Mulder
On 18/12/12 22:34:08, Tom Borkin wrote: > Hi; > I have this test code: > > if i_id == "1186": > sql = 'insert into interactions values(Null, %s, "Call Back", > "%s")' % (i_id, date_plus_2) > cursor.execute(sql) > db.commit() > print sql > It prints the sql statement, b

Re: Problem with Threads

2012-12-19 Thread Hans Mulder
On 19/12/12 18:11:37, Kwnstantinos Euaggelidis wrote: > I have this code for Prime Numbers and i want to do it with Threads.. > Any idea.?? Why would you want to do that? It's not going to be any faster, since your code is CPU-bound. You may have several CPUs, but CPython is going to use only one

Re: Virtualenv loses context

2012-12-19 Thread Hans Mulder
On 19/12/12 15:38:01, rhythmicde...@gmail.com wrote: > Just installed a brand new virtualenv along with two packages. Ran this and I > got nothing: > > (venvtest)[swright@localhost venvtest]$ python -m site > (venvtest)[swright@localhost venvtest]$ > > I expected to have at least one path in sys

Re: Why does os.stat() tell me that my file-group has no members?

2012-12-19 Thread Hans Mulder
On 19/12/12 22:40:00, saqib.ali...@gmail.com wrote: > > > I'm using python 2.6.4 on Solaris 5-10. > > I have a file named "myFile". It is owned by someone else, by > I ("myuser") am in the file's group ("mygrp"). Below is my python > code. Why does it tell me that mygrp has no members??? > > >

Re: Python3 + sqlite3: Where's the bug?

2012-12-20 Thread Hans Mulder
On 20/12/12 16:20:13, Johannes Bauer wrote: > On 20.12.2012 16:05, Chris Angelico wrote: >> On Fri, Dec 21, 2012 at 1:52 AM, Johannes Bauer wrote: >>> def fetchmanychks(cursor): >>> cursor.execute("SELECT id FROM foo;") >>> while True: >>> result = cursor.fetchmany(

Re: Strange effect with import

2012-12-20 Thread Hans Mulder
On 20/12/12 23:52:24, Jens Thoms Toerring wrote: > I'm writing a TCP server, based on SocketServer: > > server = SocketServer.TCPServer((192.168.1.10, 12345), ReqHandler) > > where ReqHandler is the name of a class derived from > SocketServer.BaseRequestHandler > > class ReqHandler(SocketServe

Re: Build and runtime dependencies

2012-12-20 Thread Hans Mulder
On 20/12/12 23:11:45, Jack Silver wrote: > I have two Linux From Scratch machine. > > On the first one (the server), I want to build install python 3.3.0 in a > shared filesystem and access it from the second one (the client). These > machines are fairly minimal in term of the number of software i

Re: redirect standard output problem

2012-12-21 Thread Hans Mulder
On 21/12/12 06:23:18, iMath wrote: > redirect standard output problem > > why the result only print A but leave out 888 ? > > import sys > class RedirectStdoutTo: > > def __init__(self, out_new): > self.out_new = out_new > def __enter__(self): > sys.stdout = self.out_new

Re: how to detect the character encoding in a web page ?

2012-12-23 Thread Hans Mulder
On 24/12/12 01:34:47, iMath wrote: > how to detect the character encoding in a web page ? That depends on the site: different sites indicate their encoding differently. > such as this page: http://python.org/ If you download that page and look at the HTML code, you'll find a line: So it's

Re: Forking into the background (Linux)

2012-12-23 Thread Hans Mulder
On 24/12/12 01:50:24, Olive wrote: > My goal is to write a script that 1) write something to stdout; then > fork into the background, closing the stdout (and stderr, stdin) pipe. > > I have found this answer (forking -> setsid -> forking) > http://stackoverflow.com/a/3356154 > > However the stand

Re: need a url that its http response header that cotain 401 status code

2012-12-26 Thread Hans Mulder
On 26/12/12 10:08:41, iMath wrote: > I am going to do a Basic Authentication , > so I need a url > that its http response header that cotain 401 status code. Isn't that backwards? I mean, what's the point of implementing Basic Authentication, unless you already know a site that uses it? if yo

Re: Tarfile and usernames

2012-12-30 Thread Hans Mulder
On 30/12/12 19:57:31, Nicholas Cole wrote: > Dear List, > > I'm hoping to use the tarfile module in the standard library to move > some files between computers. > > I can't see documented anywhere what this library does with userids and > groupids. I can't guarantee that the computers involved

Re: Python lists

2012-12-30 Thread Hans Mulder
On 28/12/12 18:46:45, Alex wrote: > Manatee wrote: > >> On Friday, December 28, 2012 9:14:57 AM UTC-5, Manatee wrote: >>> I read in this: >>> >>> ['C100, C117', 'X7R 0.033uF 10% 25V 0603', '0603-C_L, 0603-C_N', >>> '10', '2', '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D', >>> 'Digi-Key',

Re: Beginner: Trying to get REAL NUMBERS from %d command

2012-12-30 Thread Hans Mulder
Hello, Python does not support REAL numbers. It has float number, which are approximations of real numbers. They behave almost, but not quite, like you might expect. It also has Decimal numbers. They also approximate real numbers, but slightly differently. They might behave more like you'd ex

Re: Python lists

2012-12-30 Thread Hans Mulder
On 30/12/12 23:25:39, Evan Driscoll wrote: > On 12/30/2012 4:19 PM, Hans Mulder wrote: >> If it's okay to modify the original list, you can simply do: >> >> l[0] = split(l[0], ", ") >> >> If modifying the original is not okay, the simple solution wo

Re: New to python, do I need an IDE or is vim still good enough?

2012-12-31 Thread Hans Mulder
On 31/12/12 12:57:59, Adam Tauno Williams wrote: > On Thu, 2012-12-27 at 12:01 -0800, mogul wrote: >> 'Aloha! >> I'm new to python, got 10-20 years perl and C experience, all gained >> on unix alike machines hacking happily in vi, and later on in vim. >> Now it's python, and currently mainly on my

Re: Question about nested loop

2012-12-31 Thread Hans Mulder
On 31/12/12 11:02:56, Isaac Won wrote: > Hi all, > I am a very novice for Python. Currently, I am trying to read continuous > columns repeatedly in the form of array. > my code is like below: > > import numpy as np > > b = [] > c = 4 > f = open("text.file", "r") > > while c < 10: > c =

Re: Missing something obvious with python-requests

2013-01-04 Thread Hans Mulder
On 4/01/13 03:56:47, Chris Angelico wrote: > On Fri, Jan 4, 2013 at 5:53 AM, Ray Cote > wrote: >> proxies = { >> 'https': '192.168.24.25:8443', >> 'http': '192.168.24.25:8443', } >> >> a = requests.get('http://google.com/', proxies=proxies) >> >> >> When I look at the proxy log, I see a GE

Re: Numpy outlier removal

2013-01-06 Thread Hans Mulder
On 6/01/13 20:44:08, Joseph L. Casale wrote: > I have a dataset that consists of a dict with text descriptions and values > that are integers. If > required, I collect the values into a list and create a numpy array running > it through a simple > routine: data[abs(data - mean(data)) < m * std(da

Re: help

2013-01-11 Thread Hans Mulder
On 10/01/13 19:35:40, kwakukwat...@gmail.com wrote: > pls this is a code to show the pay of two people.bt I want each of to be > able to get a different money when they enter their user name,and to use > it for about six people. > database = [ > ['Mac'], > ['Sam'], > ] > pay1 = 1000 > p

Re: please i need explanation

2013-01-11 Thread Hans Mulder
On 11/01/13 16:35:10, kwakukwat...@gmail.com wrote: > def factorial(n): > if n<2: > return 1 > f = 1 > while n>= 2: > f *= n > f -= 1 U think this line should have been: n -= 1 > return f Hope this helps, -- HansM -- http://mail.python.o

Re: urllib2 FTP Weirdness

2013-01-23 Thread Hans Mulder
On 24/01/13 00:58:04, Chris Angelico wrote: > On Thu, Jan 24, 2013 at 7:07 AM, Nick Cash > wrote: >> Python 2.7.3 on linux >> >> This has me fairly stumped. It looks like >> urllib2.urlopen("ftp://some.ftp.site/path";).read() >> will either immediately return '' or hang indefinitely. But >

Re: using split for a string : error

2013-01-25 Thread Hans Mulder
On 25/01/13 15:04:02, Neil Cerutti wrote: > On 2013-01-25, Oscar Benjamin wrote: >> On 24 January 2013 11:35, Chris Angelico wrote: >>> It's usually fine to have int() complain about any >>> non-numerics in the string, but I must confess, I do sometimes >>> yearn for atoi() semantics: atoi("123as

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 sam

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)() -> print(

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.

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

Re: Doctest documentation?

2012-05-20 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]

Re: A simple way to print few line stuck to the same position

2011-06-03 Thread Hans Mulder
On 3/06/11 13:00:22, TheSaint wrote: I'd like to show 4~6 line of report and refreshing periodically all of them, avoiding to scroll down. example: this count 50 Second time 90 following line 110 another line xxx The lines should remain on their position and update their data. The quick and

Re: A simple way to print few line stuck to the same position

2011-06-04 Thread Hans Mulder
On 4/06/11 13:14:05, TheSaint wrote: Hans Mulder wrote: A minimalist solution would be to print the labels ("This count", etc.) only once, and position the cursor after it to update the report. Generally a good point. Similar sequences are working for coloring and formatting te

Re: A simple way to print few line stuck to the same position

2011-06-05 Thread Hans Mulder
On 5/06/11 05:40:17, Sarcar, Shourya C (GE Healthcare) wrote: A way to do this on DOS/Windows console would be: import sys for r in range(0,2**16): line = "Count : %d" % r sys.stdout.write(line) sys.stdout.flush() # do something that consumes time backup =

Re: Help with a piping error

2011-06-10 Thread Hans Mulder
On 10/06/11 22:56:06, virdo wrote: On Jun 10, 4:48 pm, John Gordon wrote: In<6e035898-8938-4a61-91de-7a0ea7ead...@y30g2000yqb.googlegroups.com> virdo writes: My python file is simple print "test". I run it, it works no problem. I pipe the output to a file "run> logfile" and that's the err

Re: Question About Command line arguments

2011-06-10 Thread Hans Mulder
On 10/06/11 20:03:44, Kurt Smith wrote: On Fri, Jun 10, 2011 at 12:58 PM, Mark Phillips wrote: How do I write my script so it picks up argument from the output of commands that pipe input into my script? def main(): import sys print sys.stdin.read() if __name__ == '__main__':

Re: __dict__ is neato torpedo!

2011-06-12 Thread Hans Mulder
On 12/06/11 10:47:01, Steven D'Aprano wrote: On Sat, 11 Jun 2011 21:28:40 -0500, Andrew Berg wrote: On 2011.06.11 09:13 PM, Steven D'Aprano wrote: A second, more subtle risk: not all objects have a __dict__. But if you obey the rule about never updating from arbitrary objects you don't know,

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

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 - I've

Re: installing NLTK

2011-06-17 Thread Hans Mulder
On 17/06/11 22:57:41, Nige Danton wrote: Hans Mulder 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 and in a termi

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: http://docs.python.org/library/glob

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 do

<    1   2   3   4   5   6   >