Errors and some bugs

2021-08-09 Thread Himanshu Gupta
While running some pip command to install spacy package for ver3.9 I always face trouble can you provide a solution -- https://mail.python.org/mailman/listinfo/python-list

Dictionary

2019-02-24 Thread Himanshu Yadav
fibs={0:0,1:1} def rfib(n): global fibs if not fibs.get(n): fibs[n]=rfib(n-2)+rfib(n-1) return fibs[n] Why it is gives error?? -- https://mail.python.org/mailman/listinfo/python-list

Re: Excute script only from another file

2013-11-25 Thread Himanshu Garg
I was also thinking to add a sys argument when invoking script and check it. My motive is "I will give scripts to somebody else and he should not run the script directly without running the parent script". -- https://mail.python.org/mailman/listinfo/python-list

Excute script only from another file

2013-11-24 Thread Himanshu Garg
I want that a script should only be executed when it is called from another script and should not be directly executable through linux command line. Like, I have two scripts "scrip1.py" and "script2.py" and there is a line in "script1.py" to call "script2.py" as subprocess.call(["python", "scri

Re: Help me to print to screen as well as log

2013-11-23 Thread Himanshu Garg
I have simply opened file in append mode in linux. script 1 : file = open("output.log", "a") file.write() file.flush() script 2: file = open("output.log", "a") file.write() file.flush() It writes properly to the file. -- https://mail.python.org/mailman/listinfo/python-list

Re: Help me to print to screen as well as log

2013-11-23 Thread Himanshu Garg
How can I write to the same file from two different scripts opened at same time? -- https://mail.python.org/mailman/listinfo/python-list

Re: Showing Progress Bar

2013-11-23 Thread Himanshu Garg
Thanks a lot Frank! Its superb. I got what I wanted. Thanks Again! -- https://mail.python.org/mailman/listinfo/python-list

Re: Showing Progress Bar

2013-11-23 Thread Himanshu Garg
for i in range(10): sys.stdout.write(".") sys.stdout.flush() time.sleep(1) sys.stdout.write("\n") shutil.copytree("pack", "/lxc/pack") But Here, the loop will first print the progress dots and then it will copy the directory. But I want that these two tasks should r

Showing Progress Bar

2013-11-23 Thread Himanshu Garg
I want to show simple dots while my program copies the files. I have found the code like: for i in range(10): print '.', time.sleep(1) But this will execute ten times as it is predefined and the task to copy will execute after or before this loop based on the location I have placed my

Help me to print to screen as well as log

2013-11-22 Thread Himanshu Garg
I want that print "hello" should appear on screen as well as get saved in a log file. How can I accomplish this? -- https://mail.python.org/mailman/listinfo/python-list

Re: Cannot connect to Mysql database

2013-11-18 Thread Himanshu Garg
I did: import MySQLdb as mdb from MySQLdb import * from MySQLdb.constants import * and now it works. Thanks! again -- https://mail.python.org/mailman/listinfo/python-list

Cannot connect to Mysql database

2013-11-18 Thread Himanshu Garg
I have written the script as: import os import MySQLdb as mdb os.chroot("/lxc/rootfs") os.chdir("/") con = mdb.connect(host="192.168.1.7", user="root", passwd="password") print "opened" con.close() But when I execute, I get the following error: "File "/usr/lib/python2.7/dist-packages/MySQLdb/__

Best approach to edit linux configuration file

2013-11-15 Thread Himanshu Garg
I have to setup the DNS server. For this I have to edit the configuration files. For this I have to search if the lines(block of text) already exist in the file and if not, I have to add them to the file. So, I want to know what is the best way to accomplish this. -- https://mail.python.org/m

Re: chroot to install packages

2013-11-14 Thread Himanshu Garg
> os.chdir("/") immediately afterwards. In any case, it's worth a try. > ChrisA Very thanks. the trick worked. -- https://mail.python.org/mailman/listinfo/python-list

Re: chroot to install packages

2013-11-14 Thread Himanshu Garg
I have done it but having a problem. I have written a script os.chroot("/lxc/test_container/rootfs") subprocess.call(["apt-key", "add", "/root/package.key"]) subprocess.call(["apt-get", "update"]) os._exit(0) Now, this script is working properly, entering the chroot jail and adding the apt key

Re: chroot to install packages

2013-11-13 Thread Himanshu Garg
On Thursday, November 14, 2013 5:10:20 AM UTC+5:30, Chris Angelico wrote: > On Thu, Nov 14, 2013 at 1:31 AM, Himanshu Garg wrote: > > > I am writing a python script to run chroot command to chroot to a linux > > distro and then run commands. How can I do this, as af

chroot to install packages

2013-11-13 Thread Himanshu Garg
I am writing a python script to run chroot command to chroot to a linux distro and then run commands. How can I do this, as after chrooting, the script runs the commands relative to the outside not inside the chrooted env? -- https://mail.python.org/mailman/listinfo/python-list

Re: Running a python script from interactive mode

2009-11-17 Thread Himanshu
2009/11/18 ashwini yal : > Hi, > > I am trying to run a python script from interactive mode ,but i am not able > to know how to run it? Is it possible? if yes please let me how to run the > script? > a) If you want to debug it then see http://docs.python.org/library/pdb.html b) If you want to acce

Re: Code for finding the 1000th prime

2009-11-17 Thread Himanshu
2009/11/15 mrholtsr : > I am absolutely new to python and barely past beginner in programming. > Also I am not a mathematician. Can some one give me pointers for > finding the 1000th. prime for a course I am taking over the internet > on Introduction to Computer Science and Programming. Thanks, Ray

Re: Help with database planning

2009-11-14 Thread Himanshu
2009/11/14 Juliano : > Hello, everybody. > > I'm a linguist with practical skills on computers/programming. > > We've been working with an ontology at my department, and now I need > to create a GUI viewer for the flat file we have. > I tried to write an Ontology class which manages the data read a

Re: Error in Windmill

2009-11-12 Thread Himanshu
2009/11/12 Raji Seetharaman : > > Hi > > Im learning Web scraping with Python from here > http://www.packtpub.com/article/web-scraping-with-python-part-2 > > From the above link, the complete code is here http://pastebin.com/m10046dc6 > > When i run the program in the terminal i receive following e

Re: query regarding file handling.

2009-11-12 Thread Himanshu
2009/11/12 ankita dutta : > hi all, > > i have a file of 3x3 matrix of decimal numbers(tab separated). like this : > > 0.02    0.38    0.01 > 0.04    0.32    0.00 > 0.03    0.40    0.02 > > now i want to read 1 row and get the sum of a particular row. but when i am > trying with the following code,

Re: python with echo

2009-11-11 Thread Himanshu
2009/11/12 hong zhang : > 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 > /sys/class/net/wlan1/device/tx_power') > > return_v