Re: make a string a list

2008-05-30 Thread iapain
On May 29, 11:30 pm, Nikhil <[EMAIL PROTECTED]> wrote: > or a string iterable ? How can I do that. I have lots of '\r\n' > characters in the string which I think can be easier if it were made > into a list and I can easily see if the required value (its a numeral) > is present in it or not after so

Re: Python Unicode to String conversion

2007-09-01 Thread iapain
First make sure your DB encoding is UTF-8 not the latin1 > The error I keep having is something like this: > ERREUR: Séquence d'octets invalide pour le codage «UTF8» : 0xe02063 then try this: def smart_str(s, encoding='utf-8', errors='strict'): """ Returns a bytestring version of 's', e

Re: Google spreadsheets

2007-08-31 Thread iapain
On Aug 31, 5:40 pm, Michele Simionato <[EMAIL PROTECTED]> wrote: > I would like to upload a tab-separated file to a Google spreadsheet > from Python. Does anybody > have a recipe handy? TIA, > > Michele Simionato Probably its irrelevant to python. Use should see Google Spreadsheet API and use

Re: JavaScript

2007-08-31 Thread iapain
>python has modules for forms and other things... and for it? Check out httplib and urlib2, it might be useful for you. -- http://mail.python.org/mailman/listinfo/python-list

Re: escaping only double quotes

2007-08-31 Thread iapain
You could write a simple escape function. def escape(html): "Return the given TEXT with ampersands, quotes and carets encoded." return html.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''') -- http://mail.python.org/mailman/listinfo/python-list

Re: escaping only double quotes

2007-08-31 Thread iapain
> string = "Butler's 15\" TV" > s = """my string goes here "%s" """ % string Couldn't find anything wrong in string = "Butler's 15\" TV" s = "my string goes here %s" % string -- http://mail.python.org/mailman/listinfo/python-list

Re: So what exactly is a complex number?

2007-08-31 Thread iapain
> > On Thu, 2007-08-30 at 20:11 -0500, Lamonte Harris wrote: > > > Like in math where you put letters that represent numbers for place > > > holders to try to find the answer type complex numbers? You shouldnt worry about it in python, its pretty large to handle all your calc. -- http://mail.pyt

Re: sorting a list of lists

2007-08-27 Thread iapain
> Taking advantage of stable sorting is totally not a hack. The OP just tried > the two sorting steps in the wrong order. I didnt say not to use stable sorting, but write a generic function and hacky code. It is always better to adopt a generic approach. -- http://mail.python.org/mailman/listin

Re: sorting a list of lists

2007-08-27 Thread iapain
> i would like to sort a list of lists. The list is first sorted on the > second item in the sub-lists (which I can do), then on the third item > (which I can't). Write a comparator instead of dirty hacks mylistoflist.sort(mycomparator) def mycomparator(a, b): #do -- http://mail.python.org/

Re: Python web service ...

2006-08-26 Thread iapain
> My question is how difficult is to set up a web server that can run > python easy ? should I try ZOPE or there is something better in mind ? Just install Apache and run Python as CGI thats the best solution I found for my apps. Thats the best and faster way to move python apps on web. -- http:

Re: Learning Python - Have Question.

2006-08-26 Thread iapain
> I'm just learning Python, and I have a question about os.path.join(dirpath, > name) and its use. Simply put, I haven't figured out how to use it. First thing you have to remember while using python is "everything is an object". os.join.path concatenates one or more path for example os.path.join

Re: Restricted Access

2006-07-12 Thread iapain
uld work. I should try it really quick! Thanks! Best! iapain -- http://mail.python.org/mailman/listinfo/python-list

Re: Restricted Access

2006-07-11 Thread iapain
> Do you have an IBM s/370 running VM/CMS? VM was sort of an OS for > running multiple OSs, so it would be the "restricted environment" I'm having currently working on OS/2 and Linux platform, I've designed a web based ide for python and i wish to restrict some commands and user can only ac

Re: Restricted Access

2006-07-11 Thread iapain
> Brett Cannon is currently trying to come up with a comprehensive spec > and implementation of a sandboxed Python interpreter, for use in > Mozilla as a JavaScript replacement. (look in the python-dev archives > for more) I'm not sure he is working or not, latest i read was he purposed new restri

Re: Restricted Access

2006-07-11 Thread iapain
> The most knowledgeable people have effectively given up, in > regard to Python. I guess now I am up with only one option, i.e hope that user input code wont be evil to the system. **which is rarely possible** -- http://mail.python.org/mailman/listinfo/python-list

Re: Best command for running shell command

2006-07-11 Thread iapain
> where I'm not interested in the output, I only want to make sure that the > command was executed OK. How should I invoke this (in a Unix/linux > environment)? Remember few things about executing program within python 1. Create a subprocess or child process and execute it. 2. You should use "Time

Re: Restricted Access

2006-07-11 Thread iapain
it. And for all of Sun's resources and > talent, security holes are sometimes found even in Java. Does that mean there is no way to implement restricted enviorment? Best! iapain -- http://mail.python.org/mailman/listinfo/python-list

Re: Restricted Access

2006-07-11 Thread iapain
> unless you're willing to build a restricted runtime that runs on top of the > core inter- > preter, you should assume that anyone writing a Python script that's executed > by > your program has access to everything that your Python process has access > to... I think using replacements I can b

Re: Restricted Access

2006-07-11 Thread iapain
bide, wont corrupt system 2. Use some tricks to encrypt the user path and do lots of replacement on user code and o/p. or something else? Best! iapain -- http://mail.python.org/mailman/listinfo/python-list

Re: Restricted Access

2006-07-10 Thread iapain
Tim Chase wrote: > If you're prepared for the massive breakage that will ensue, you can > > chmod go-rwx /usr/lib/python2.3/os.* No, I cant change permission or delete the module, the best would be something to detect 'import os' in user code .. but If i go with chroot jail approch then ever

Restricted Access

2006-07-10 Thread iapain
open(PATH, 'w') # If this PATH is defined then use can access files else he cant .. is there is any way? Regards! iapain -- http://mail.python.org/mailman/listinfo/python-list

Re: Executing a DOS program from within Python

2006-03-16 Thread iapain
Use os.system and if you wanna get rid of console window use subprocess as gary said, you could have better options like killing proc if it hang/stuck using win32api (if you are using windows) else process timeout. ret = os.system('sample.exe') # ret will have return code and os.system execute sam

Re: timeout a process

2006-01-22 Thread iapain
Thanks Tim, Yeah win32api is working normally. -- http://mail.python.org/mailman/listinfo/python-list

Re: import module and execute function at runtime

2006-01-13 Thread iapain
Hi, if you want to import module dynamically, you can use __import__ .. always remember modules are objects .. mStr="sys" mod=__import__(mStr) # Now u can use mod.version .. but cant specify the attribute using other variable, like u did mod.version should read it http://diveintopython.org/funct

timeout a process

2006-01-13 Thread iapain
Hello, I am trying to build and infinite loop handler in python 2.4 on windows platform. The problem is that i want to create a process and forcely kill/timeout after 2 sec to handle infinite loop in a gcc complied exe on cygwin. something like below os.system("mycpp.exe") # this exe is compiled w