Search Results

Search found 13693 results on 548 pages for 'python metaprogramming'.

Page 36/548 | < Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >

  • Use different Python version with virtualenv

    - by Ulf
    I have a Debian system currently running with python 2.5.4. I got virtualenv properly installed, everything is working fine. Is there a possibility that I can use a virtualenv with a different version of Python? I compiled Python 2.6.2 and would like to use it with some virtualenv. Is it enough to overwrite the binary file? Or do I have to change something in respect to the libraries?

    Read the article

  • Python run command line (time)

    - by pns
    Hi, I want to run the 'time' unix command from a Python script, to time the execution of a non Python app. I would use the os.system method. Is there any way to save the output of this in Python? My goal is to run the app several times, save their execution times and then do some statistics on them. Thank You

    Read the article

  • Writing a DBMS in Python

    - by Matt Luongo
    Hey guys, I'm working on a basic DBMS as a pet project and planning to prototype in Python. I figure there's a reason there are only a few Python databases, and my gut agrees that my favorite language will be too slow to act as an honest performing database, but I'm looking forward to using it to learn what I need quickly. Would someone please contradict me? Is Python as ill-suited right now for this sort of thing as I think?

    Read the article

  • Stop execution of python script when parent Bash shell script is killed

    - by jrdioko
    I'm working on a Bash shell script that runs several Python scripts like so: cd ${SCRIPT_PATH} python -u ${SCRIPT_NAME} ${SCRIPT_ARGS} >> $JOBLOG 2>&1 At one point, I killed the shell script (using kill PID), but the Python script continued running, even after the script terminated. I thought these would die as soon as the main script died. What am I misunderstanding about Bash scripting, and what can I do to get the functionality I'm looking for? Thanks in advance!

    Read the article

  • How to Learn Python

    - by Brett Veenstra
    For a beginner's perspective, can you answer the following: Best Tool(s) for Python development (e.g. NotePad, Vim) Best Book to get Started Best Website for Python beginner Best Problem Domain to do a sample project (what is Python-based solutions best suited for?)

    Read the article

  • Installing Python in Windows XP

    - by Sam
    My work PC has restrictions that stop me from adding programs to the start menu so when I try to install Python using the Python 2.6.5 Windows installer it can't complete as it tries to add a shortcut to my start menu. Is there a way around this? I.e another way of installing without the need for a shortcut? Edit: I'll also need to install NumPy which I can't do on the Portable version of Python.

    Read the article

  • Using python code in ASP.NET Web forms app

    - by DotnetDude
    I would like to use some code written in python (it uses built in modules) in a regular ASP.NET/C# web application. I am a newbie in python and have heard of IronPython and how ASP.NET now allows us to create IronPython apps. Any thoughts on which way I should proceed? The python code is the on here

    Read the article

  • module compiled with swig not found by python

    - by openbas
    Hello, I've a problem with SWIG and python. I've a c-class that compiles correctly, but the python script says it can't find the module. I compile with: swig -c++ -python codes/codes.i g++ -c -Wall -O4 -fPIC -pedantic codes/*.cc g++ -I/usr/include/python2.6 -shared codes/codes_wrap.cxx *.o -o _codes.so This gives me a _codes.so file, as I would expect, but then I have this python file: import sys import codes (rest of the code omitted) It gives me: Traceback (most recent call last): File "script.py", line 3, in <module> import codes ImportError: No module named codes According to http://www.swig.org/Doc1.3/Introduction.html#Introduction_nn8 this is all I should have to do... The files are in the same directory, so the path should not be a problem ?

    Read the article

  • Best way to save complex Python data structures across program sessions (pickle, json, xml, database

    - by Malcolm
    Looking for advice on the best technique for saving complex Python data structures across program sessions. Here's a list of techniques I've come up with so far: pickle/cpickle json jsonpickle xml database (like SQLite) Pickle is the easiest and fastest technique, but my understanding is that there is no guarantee that pickle output will work across various versions of Python 2.x/3.x or across 32 and 64 bit implementations of Python. Json only works for simple data structures. Jsonpickle seems to correct this AND seems to be written to work across different versions of Python. Serializing to XML or to a database is possible, but represents extra effort since we would have to do the serialization ourselves manually. Thank you, Malcolm

    Read the article

  • Cross-compiling a Python script on Linux into a Windows executable

    - by Chinmay Kanchi
    I have a Python script that I'd like to compile into a Windows executable. Now, py2exe works fine from Windows, but I'd like to be able to run this from Linux. I do have Windows on my development machine, but Linux is my primary dev platform and I'm getting kind of sick of rebooting into Windows just to create the .exe. Any ideas? PS: I am aware that py2exe doesn't exactly compile the python file as much as package your script with the Python interpreter. But either way, the result is that you don't need Python installed to run the script.

    Read the article

  • Python and Plone help

    - by Grenko
    Im using the plone cms and am having trouble with a python script. I get a name error "the global name 'open' is not defined". When i put the code in a seperate python script it works fine and the information is being passed to the python script becuase i can print the query. Code is below: #Import a standard function, and get the HTML request and response objects. from Products.PythonScripts.standard import html_quote request = container.REQUEST RESPONSE = request.RESPONSE # Insert data that was passed from the form query=request.query #print query f = open("blast_query.txt","w") for i in query: f.write(i) return printed I also have a second question, can i tell python to open a file in in a certain directory for example, If the script is in a certain loaction i.e. home folder, but i want the script to open a file at home/some_directory/some_directory can it be done?

    Read the article

  • can the python wave module accept StringIO object

    - by user368005
    i'm trying to use the wave module to read wav files in python. whats not typical of my applications is that I'm NOT using a file or a filename to read the wav file, but instead i have the wav file in a buffer. And here's what i'm doing import StringIO buffer = StringIO.StringIO() buffer.output(wav_buffer) file = wave.open(buffer, 'r') but i'm getting a EOFError when i run it... File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/wave.py", line 493, in open return Wave_read(f) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/wave.py", line 163, in __init__ self.initfp(f) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/wave.py", line 128, in initfp self._file = Chunk(file, bigendian = 0) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/chunk.py", line 63, in __init__ raise EOFError i know the StringIO stuff works for creation of wav file and i tried the following and it works import StringIO buffer = StringIO.StringIO() audio_out = wave.open(buffer, 'w') audio_out.setframerate(m.getRate()) audio_out.setsampwidth(2) audio_out.setcomptype('NONE', 'not compressed') audio_out.setnchannels(1) audio_out.writeframes(raw_audio) audio_out.close() buffer.flush() # these lines do not work... # buffer.output(wav_buffer) # file = wave.open(buffer, 'r') # this file plays out fine in VLC file = open(FILE_NAME + ".wav", 'w') file.write(buffer.getvalue()) file.close() buffer.close()

    Read the article

  • evaluating buffer in emacs python-mode on remote host

    - by Adrian
    Hello, I'm using emacs23 with tramp to modify python scripts on a remote host. I found that when I start the python shell within emacs it starts up python on the remote host. My problem is that when I then try to call python-send-buffer via C-c C-c it comes up with the error Traceback (most recent call last): File "", line 1, in ? ImportError: No module named emacs Traceback (most recent call last): File "", line 1, in ? NameError: name 'emacs' is not defined Now, I must admit that I don't really know what's going on here. Is there a way for me to configure emacs so that I can evaluate the buffer on the remote host? Many thanks.

    Read the article

  • Learn ASP.NET or Python for web development?

    - by user300371
    I am new to programming and only know html,css,PHP and would like to start learning another new language. I am focused on web development and would just like to get your opinion on ASP.net and python. Which language would serve me best in making sites as to general programming? ASP.NET or django python? I know Python is "easy to learn" and similar to PHP, but ASP.net is also a good language.

    Read the article

  • how to install python-spidermonkey on windows

    - by paul
    Hello all, im making some script with python mechanize, one of problem is it really hard to find which support javascript supported web client scraping or crawler. actually i was found some such as python-spidermonkey and pykhtml and so on. but most of all only support on linux . i want to make my python script with exe file. so definitely i have to install on windows platform. my question is ..are there any method to can install python-spidermonkey or pykhtml on windows platform? i really need to support windows platform. if anyone can hint or help really appreicate! thanks in advance Paul

    Read the article

  • Adjust OSX System Audio Volume in Python

    - by Benson
    I would like to adjust the system audio volume in OSX from a python script. This question about implementing keyboard shortcuts tells me how to do it in applescript, but I'd really like to do it from my python script without using os.system, popen, etc. Ideally I'd like to ramp up the volume slowly with some python code like this: set_volume(0) for i in range(50): set_volume(i*2) time.sleep(1)

    Read the article

  • Suggestions for a Cron like scheduler in Python?

    - by jamesh
    I'm looking for a library in Python which will provide at and cron like functionality. I'd quite like have a pure Python solution, rather than relying on tools installed on the box; this way I run on machines with no cron. For those unfamiliar with cron: you can schedule tasks based upon an expression like: 0 2 * * 7 /usr/bin/run-backup # run the backups at 0200 on Every Sunday 0 9-17/2 * * 1-5 /usr/bin/purge-temps # run the purge temps command, every 2 hours between 9am and 5pm on Mondays to Fridays. The cron time expression syntax is less important, but I would like to have something with this sort of flexibility. If there isn't something that does this for me out-the-box, any suggestions for the building blocks to make something like this would be gratefully received. Edit I'm not interested in launching processes, just "jobs" also written in Python - python functions. By necessity I think this would be a different thread, but not in a different process. To this end, I'm looking for the expressivity of the cron time expression, but in Python. Cron has been around for years, but I'm trying to be as portable as possible. I cannot rely on its presence.

    Read the article

  • Python/MySQL fails under Windows

    - by AP257
    I'm trying to get Python 2.6 to communicate with MySQL Server 5.1, under Windows XP, but I keep getting a strange error, "SystemError: NULL object passed to Py_BuildValue": >>> import MySQLdb as mysql >>> db = mysql.connect(user = "root", passwd="whatever", db="mysql", host="localh ost") >>> cu = db.cursor() >>> cu.execute("show tables") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\dirr\lib\site-packages\MySQLdb\cursors.py", line 173, in execu te self.errorhandler(self, exc, value) File "C:\ dirr\lib\site-packages\MySQLdb\connections.py", line 36, in de faulterrorhandler raise errorclass, errorvalue SystemError: NULL object passed to Py_BuildValue I thought it might be a character set problem, but I've tried setting and setting MySQL as UTF-8, and it hasn't made a difference. I guess there must be a problem with python-mysql. Can anyone help? UPDATE OK, python-mysql under windows is a bit of a nightmare, particularly with Python 2.6 it seems. Rather than installing python-mysql with pip, use this installer instead. That fixed it.

    Read the article

  • Execute a BASH command in Python-- in the same process

    - by Baldur
    I need to execute the command . /home/db2v95/sqllib/db2profile before I can import ibm_db_dbi in Python 2.6. Executing it before I enter Python works: baldurb@gigur:~$ . /home/db2v95/sqllib/db2profile baldurb@gigur:~$ python Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ibm_db_dbi >>> but executing it in Python using os.system(". /home/db2v95/sqllib/db2profile") or subprocess.Popen([". /home/db2v95/sqllib/db2profile"]) results in an error. What am I doing wrong? Edit: this is the error I receive: > Traceback (most recent call last): > File "<file>.py", line 8, in > <module> > subprocess.Popen([". /home/db2v95/sqllib/db2profile"]) > File > "/usr/lib/python2.6/subprocess.py", > line 621, in __init__ > errread, errwrite) File "/usr/lib/python2.6/subprocess.py", > line 1126, in _execute_child > raise child_exception OSError: [Errno 2] No such file or directory

    Read the article

  • datetime command line argument in python 2.4

    - by Ike Walker
    I want to pass a datetime value into my python script on the command line. My first idea was to use optparse and pass the value in as a string, then use datetime.strptime to convert it to a datetime. This works fine on my machine (python 2.6), but I also need to run this script on machines that are running python 2.4, which doesn't have datetime.strptime. How can I pass the datetime value to the script in python 2.4? Here's the code I'm using in 2.6: parser = optparse.OptionParser() parser.add_option("-m", "--max_timestamp", dest="max_timestamp", help="only aggregate items older than MAX_TIMESTAMP", metavar="MAX_TIMESTAMP(YYYY-MM-DD HH24:MM)") options,args = parser.parse_args() if options.max_timestamp: # Try parsing the date argument try: max_timestamp = datetime.datetime.strptime(options.max_timestamp, "%Y-%m-%d %H:%M") except: print "Error parsing date input:",sys.exc_info() sys.exit(1)

    Read the article

  • packaging and distributing Python code as executables

    - by user248237
    How can I compile my python module into an executable, and distribute it in a way that doesn't require the user to download all the external Python packages that the module I wrote uses? Aside from that, is there a general guy on packaging and distributing python code? i.e. going from a script/module to someone that's user-friendly and can be run, ideally cross-platform (at least between unix and mac). thanks.

    Read the article

< Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >