Search Results

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

Page 57/548 | < Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >

  • catch output from linux telnet to a python script

    - by sandra
    Hello. My problem is that i want to do something like this in linux console telnet 192.168.255.28 process.py i.e i would like to do some transformation with console telnet output using python script. I'm see Popen in python for this case, but i can't understand how can i get input from telnet if it do not stop all time.. Pleas any ideas.

    Read the article

  • Is it possible to use os.walk over SSH?

    - by LeoB
    I'm new to Python so forgive me if this is basic, I've searched but can't find an answer. I'm trying to convert a Perl script into Python (3.x) which connects to a remote server and copies the files in a given directory to the local machine. Integrity of the transfer is paramount and there are several steps built-in to ensure a complete and accurate transfer. The first step is to get a complete listing of the files to be passed to rsync. The Perl script has the following lines to accomplish this: @dir_list = `ssh user@host 'find $remote_dir -type f -exec /bin/dirname {} \\;'`; @file_list = `ssh user@host 'find $remote_dir -type f -exec /bin/basename {} \\;'`; The two lists are then joined to create $full_list. Rather than open two separate ssh instances I'd like to open one and use os.walk to get the information using: for remdirname, remdirnames, remfilesnames in os.walk(remotedir): for remfilename in remfilesnames: remfulllist.append(os.path.join(remdirname, remfilename)) Thank you for any help you can provide.

    Read the article

  • XSD editor with the ability to write plugins in Python

    - by Tomasz Zielinski
    I'm writing a Python module for parsing XSD for very specific purpose. Currently it's a console program, but ideally I would see it plugged inside some XSD editor - not only for convenience of end users, but also for fetching XSD parsed into Python objects - this would save me days or weeks of work. Is there any such editor on the market?

    Read the article

  • Python and MySQL

    - by omfgroflmao
    Is there an easy way (without downloading any plugins) to connect to a MySQL database in Python? Also, what would be the difference from calling a PHP script to retrieve the data from the database and hand it over to Python and importing one of these third-parties plugins that requires some additional software in the server.

    Read the article

  • Python/Ruby IDE (Windows)?

    - by Lee Tang
    Are there any Windows IDEs that support both Ruby and Python? I'm talking about the type of IDE that has syntax suggestions (auto-completion feature). I've tried Netbeans but it only seems to support Ruby (maybe there's a way to add Python support?)

    Read the article

  • Why is i++++++++i valid in python?

    - by SysAdmin
    I "accidentally" came across this weird but valid syntax i=3 print i+++i #outputs 6 print i+++++i #outputs 6 print i+-+i #outputs 0 print i+--+i #outputs 6 (for every even no: of minus symbol, it outputs 6 else 0, why?) Does this do anything useful? Update (Don't take it the wrong way..I love python): One of Python's principle says There should be one-- and preferably only one --obvious way to do it. It seems there are infinite ways to do i+1

    Read the article

  • C++ Arrays manipulations (python-like operations)

    - by Linai
    Hi Guys, I'm trying to figure out the best C++ library/package for array manipulations in a manner of python. Basically I need a simplicity like this: values = numpy.array(inp.data) idx1 = numpy.where(values > -2.14) idx2 = numpy.where(values < 2.0) res1 = (values[idx1] - diff1)/1000 res1 = (values[idx2] - diff2)*1000 In python it's just 5 lines, but the simplest way in C++ i can think of is quite a number of nested loops. Pls advise..

    Read the article

  • importing class and its function from another file [Python]

    - by user343934
    Hi everyone, I am having little bit problem in importing classes in python. My work flow goes like this -index.py ---class template: ------def header(): ------def body(): ------def footer(): -display.py I want to call function header(), body() and footer () in my display.py page. Will anyone make me clear about this issue in python. Thanks for your concern.

    Read the article

  • Why is Python so slow?

    - by Riemannliness
    Why is Python such a slow language, on average, compared to C/C++? I learned Python as my first programming language, but I've only just started with C and already I can feel and see the difference.

    Read the article

  • python copytree with negated ignore pattern

    - by Chris H
    I'm trying to use python to copy a tree of files/directories. is it possible to use copytree to copy everything that ends in foo? There is an ignore_patterns patterns function, can I give it a negated regular expression? Are they supported in python? eg. copytree(src, dest, False, ignore_pattern('!*.foo')) Where ! means NOT anything that ends in foo. thanks.

    Read the article

  • Python/Django tests running only one test at a time

    - by user2876296
    I have a unittest for my view class TestFromAllAdd(TestCase): fixtures = ['staging_accounts_user.json', 'staging_main_category.json', 'staging_main_dashboard.json', 'staging_main_location.json', 'staging_main_product.json', 'staging_main_shoppinglist.json'] def setUp(self): self.factory = RequestFactory() self.c = Client() self.c.login(username='admin', password='admin') def from_all_products_html404_test(self): request = self.factory.post('main/adding_from_all_products', {'product_id': ''}) request.user = User.objects.get(username= 'admin') response = adding_from_all_products(request) self.assertEqual(response.status_code, 404) But I have a few more classes with tests and I cant run them all at the same time: python manage.py test main doesnt run tests, but if i run; python manage.py test main.TestFromAllAdd.from_all_products_html404_test , runs one test;

    Read the article

  • Persistent Hashing of Strings in Python

    - by Chris S
    How would you convert an arbitrary string into a unique integer, which would be the same across Python sessions and platforms? For example hash('my string') wouldn't work because a different value is returned for each Python session and platform.

    Read the article

  • What makes C faster than Python?

    - by Chris
    I know this is probably a very obvious answer and that I'm exposing myself to less-than-helpful snarky comments, but I don't know the answer so here goes. If Python compiles to bytecode at runtime, is it just that initial compiling step that takes longer? If that's the case wouldn't that just be a small upfront cost in the code (ie if the code is running over a long period of time, do the differences between C and python diminish?)

    Read the article

  • MySQL-python 1.2.3 and OS X 10.5: 64- or 32-bit?

    - by Dave Everitt
    I've been happily using Django and MySQL in development on an existing machine running OS X 10.4 Tiger, and have set up a similar environment in 10.5 Leopard on a new 64-bit MacBook, with a working MySQL and Python 2.6.4. However, now I want them to communicate, easy_install MySQL-python gave ld warnings that the file is not of the required architecture, which led me to test my Python 2.4.6 install (from the Mac OS X disc image): >>> import sys >>> sys.maxint 2147483647 Ah. So my Python install appears to be 32-bit and (I think?) won't install MySQL-python for my 64-bit MySQL. There are lots of hacks out there for MySQL-python on OS X (mostly 1.2.2), but - after hours of reading - I'm pretty sure they won't fix this architecture mismatch. So I'm stuck because I can't decide whether to: give up, remove the 64-bit MySQL install (thorough methods, please?) and use the 32-bit MySQL disc image instead; re-install Python in 64-bit mode from the tarball, --with-universal archs-64-bit and --enable-universalsdk= as detailed in Python.org's 2.6 news. So my questions for anyone who has encountered this issue are: Is installing 64-bit Python on OS X 10.5 worth bothering with? If so, (naive, lazy question!) how are the two required arguments combined? If I just skip along in 32-bit (as on my working setup) what am I missing? I'm after a hassle-free install that's easy to reproduce on other machines (possible student use) so I'd really welcome your opinions, please!

    Read the article

  • Python Newbie: Sphinx on App Engine - too much at a time?

    - by Pekka
    Following up on my last year's question on documentation, I now want to get started and try out Python-based Sphinx for putting together the developer documentation for a PHP CMS I've been working on. Instead of setting up Python locally on my workstation, I would like to run it on a publicly accessible web server from the start. All the web hosting packages I have access to run on the LAMP stack, and I'm reluctant to buy Python-based hosting. I am very interested in the Google App Engine, the free quotas they provide will do for me a hundred times over, and even if not, their pricing looks very reasonable. Now I have zero knowledge of Python - getting Sphinx to work would be my first contact with it - and very little time. As far as I understand, the platform and python libraries the App Engine provides are very compatible to a standard Python library but not identical. So my question is: Can Sphinx run on App Engine at all? Is installing Sphinx on the App Engine as straightforward as if I would install it on top of a normal Python installation? Or will the App Engine's environment require tweaking of the source code that I can't perform in reasonable time with my current level of Python? Should I be installing Sphinx on a local server and a "normal" Python stack instead first? Does anybody know any helpful How-to's, tutorials or other resources for this?

    Read the article

  • How can I change the Python that my Django project is using?

    - by Burak
    I have 2 versions installed in my server. I used virtualenv to install Python 2.7. I am using WSGI to deploy my project. WSGIPythonPath /home/ENV/lib/python2.7/site-packages WSGIScriptAlias / /var/www/html/my_project/wsgi.py My http.conf is like that. python -V gives Python 2.7.3 But in my projects Debug window, it says Django is using 2.6.8. Where am I wrong? UPDATE: Here is my wsgi file import os import sys sys.path.append('/var/www/html') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application() Python Version: 2.6.8 Python Path: ['/home/ENV/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/home/ENV/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/home/ENV/lib/python2.7/site-packages/Django-1.4-py2.7.egg', '/home/ENV/lib/python2.7/site-packages', '/usr/lib/python2.6/site-packages/pip-1.1-py2.6.egg', '/usr/lib/python2.6/site-packages/django_transmeta-0.6.7-py2.6.egg', '/usr/lib/python2.6/site-packages/ipython-0.13-py2.6.egg', '/usr/lib/python2.6/site-packages/virtualenv-1.7.2-py2.6.egg', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info', '/var/www/html'] In my error_log of httpd: [Tue Jul 10 20:51:29 2012] [error] python_init: Python version mismatch, expected '2.6.7', found '2.6.8'. [Tue Jul 10 20:51:29 2012] [error] python_init: Python executable found '/usr/bin/python'. [Tue Jul 10 20:51:29 2012] [error] python_init: Python path being used '/usr/lib64/python26.zip:/usr/lib64/python2.6/:/usr/lib64/python2.6/plat-linux2:/usr/lib64/python2.6/lib-tk:/usr/lib64/python2.6/lib-old:/usr/lib64/python2.6/lib-dynload'.

    Read the article

  • python sqlite3 won't execute a join, but sqlite3 alone will

    - by Francis Davey
    Using the sqlite3 standard library in python 2.6.4, the following query works fine on sqlite3 command line: select segmentid, node_t, start, number,title from ((segments inner join position using (segmentid)) left outer join titles using (legid, segmentid)) left outer join numbers using (start, legid, version); But If I execute it via the sqlite3 library in python I get an error: >>> conn=sqlite3.connect('data/test.db') >>> conn.execute('''select segmentid, node_t, start, number,title from ((segments inner join position using (segmentid)) left outer join titles using (legid, segmentid)) left outer join numbers using (start, legid, version)''') Traceback (most recent call last): File "<stdin>", line 1, in <module> sqlite3.OperationalError: cannot join using column start - column not present in both tables The (computed) table on the left hand side of the join appears to have the relevant column because if I check it by itself I get: >>> conn.execute('''select * from ((segments inner join position using (segmentid)) left outer join titles using (legid, segmentid)) limit 20''').description (('segmentid', None, None, None, None, None, None), ('html', None, None, None, None, None, None), ('node_t', None, None, None, None, None, None), ('legid', None, None, None, None, None, None), ('version', None, None, None, None, None, None), ('start', None, None, None, None, None, None), ('title', None, None, None, None, None, None)) My schema is: CREATE TABLE leg (legid integer primary key, t char(16), year char(16), no char(16)); CREATE TABLE numbers ( number char(16), legid integer, version integer, start integer, end integer, prev integer, prev_number char(16), next integer, next_number char(16), primary key (number, legid, version)); CREATE TABLE position ( segmentid integer, legid integer, version integer, start integer, primary key (segmentid, legid, version)); CREATE TABLE 'segments' (segmentid integer primary key, html text, node_t integer); CREATE TABLE titles (legid integer, segmentid integer, title text, primary key (legid, segmentid)); CREATE TABLE versions (legid integer, version integer, primary key (legid, version)); CREATE INDEX idx_numbers_start on numbers (legid, version, start); I am baffled as to what I am doing wrong. I have tried quitting/restarting both the python and sqlite command lines and can't see what I'm doing wrong. It may be completely obvious.

    Read the article

  • "Pretty" Continuous Integration for Python

    - by dbr
    This is a slightly.. vain question, but BuildBot's output isn't particularly nice to look at.. For example, compared to.. phpUnderControl Hudson CruiseControl.rb ..and others, BuildBot looks rather.. archaic I'm currently playing with Hudson, but it is very Java-centric (although with this guide, I found it easier to setup than BuildBot, and produced more info) Basically: is there any Continuous Integration systems aimed at python, that produce lots of shiney graphs and the likes? Update: After trying a few alternatives, I think I'll stick with Hudson. Integrity was nice and simple, but quite limited. I think Buildbot is better suited to having numerous build-slaves, rather than everything running on a single machine like I was using it. Setting Hudson up for a Python project was pretty simple: Download Hudson from https://hudson.dev.java.net/ Run it with java -jar hudson.war Open the web interface on the default address of http://localhost:8080 Go to Manage Hudson, Plugins, click "Update" or similar Install the Git plugin (I had to set the git path in the Hudson global preferences) Create a new project, enter the repository, SCM polling intervals and so on Install nosetests via easy_install if it's not already In the a build step, add nosetests --with-xunit --verbose Check "Publish JUnit test result report" and set "Test report XMLs" to **/nosetests.xml That's all that's required. You can setup email notifications, and the plugins are worth a look. A few I'm currently using for Python projects: SLOCCount plugin to count lines of code (and graph it!) - you need to install sloccount separately Violations to parse the PyLint output (you can setup warning thresholds, graph the number of violations over each build) Cobertura can parse the coverage.py output. Nosetest can gather coverage while running your tests, using nosetests --with-coverage (this writes the output to **/coverage.xml)

    Read the article

  • Python: some newbie questions on sys.stderr and using function as argument

    - by Cawas
    I'm just starting on Python and maybe I'm worrying too much too soon, but anyways... log = "/tmp/trefnoc.log" def logThis (text, display=""): msg = str(now.strftime("%Y-%m-%d %H:%M")) + " TREfNOC: " + text if display != None: print msg + display logfile = open(log, "a") logfile.write(msg + "\n") logfile.close() return msg def logThisAndExit (text, display=""): msg = logThis(text, display=None) sys.exit(msg + display) That is working, but I don't like how it looks. Is there a better way to write this (maybe with just 1 function) and is there any other thing I should be concerned under exiting? Now to some background... Sometimes I will call logThis just to log and display. Other times I want to call it and exit. Initially I was doing this: logThis ("ERROR. EXITING") sys.exit() Then I figured that wouldn't properly set the stderr, thus the current code shown on the top. My first idea was actually passing "sys.exit" as an argument, and defining just logThis ("ERROR. EXITING", call=sys.exit) defined as following (showing just the relevant differenced part): def logThis (text, display="", call=print): msg = str(now.strftime("%Y-%m-%d %H:%M")) + " TREfNOC: " + text call msg + display But that obviously didn't work. I think Python doesn't store functions inside variables. I couldn't (quickly) find anywhere if Python can have variables taking functions or not! Maybe using an eval function? I really always try to avoid them, tho. Sure I thought of using if instead of another def, but that wouldn't be any better or worst. Anyway, any thoughts?

    Read the article

< Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >