Search Results

Search found 20677 results on 828 pages for 'python team'.

Page 12/828 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Why do iterators in Python raise an exception?

    - by NullUserException
    Here's the syntax for iterators in Java (somewhat similar syntax in C#): Iterator it = sequence.iterator(); while (it.hasNext()) { System.out.println(it.next()); } Which makes sense. Here's the equivalent syntax in Python: it = iter(sequence) while True: try: value = it.next() except StopIteration: break print(value) I thought Exceptions were supposed to be used only in, well, exceptional circumstances. Why does Python use exceptions to stop iteration?

    Read the article

  • How do i tell ubuntu to only install is asked for and do not bring other dependencies which will break the whole system?

    - by YumYumYum
    How can i only install python-webkit but not other packages? which is showing to install? (no gstreamer*.*, i do not want to have any single files installed in my distro because of GPL license and it slows my machine a lot) $ sudo apt-get install libwebkitgtk-1.0-0 python-webkit Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libgstreamer-plugins-base0.10-0 libgstreamer0.10-0 Suggested packages: gstreamer-codec-install gnome-codec-install gstreamer0.10-tools gstreamer0.10-plugins-base The following NEW packages will be installed: libgstreamer-plugins-base0.10-0 libgstreamer0.10-0 libwebkitgtk-1.0-0 0 upgraded, 3 newly installed, 0 to remove and 333 not upgraded. Need to get 8,231 kB of archives. After this operation, 28.2 MB of additional disk space will be used. Do you want to continue [Y/n]? n Abort.

    Read the article

  • "Bootstrap" python script in the Windows shell without .py / .pyw associations

    - by PabloG
    Sometimes (in customer's PCs) I need a python script to execute in the Windows shell like a .CMD or .BAT, but without having the .py or .pyw extensions associated with PYTHON / PYTHONW. I came out with a pair of 'quick'n dirty' solutions: 1) """ e:\devtool\python\python.exe %0 :: or %PYTHONPATH%\python.exe goto eof: """ # Python test print "[works, but shows shell errors]" 2) @echo off for /f "skip=4 delims=xxx" %%l in (%0) do @echo %%l | e:\devtools\python\python.exe goto :eof ::---------- # Python test print "[works better, but is somewhat messy]" Do you know a better solution? (ie: more concise or elegant)

    Read the article

  • Returning a tuple of multipe objects in Python C API

    - by celil
    I am writing a native function that will return multiple Python objects PyObject *V = PyList_New(0); PyObject *E = PyList_New(0); PyObject *F = PyList_New(0); return Py_BuildValue("ooo", V, E, F); This compiles fine, however, when I call it from a Python program, I get an error: SystemError: bad format char passed to Py_BuildValue How can this be done correctly? EDIT: The following works PyObject *rslt = PyTuple_New(3); PyTuple_SetItem(rslt, 0, V); PyTuple_SetItem(rslt, 1, E); PyTuple_SetItem(rslt, 2, F); return rslt; However, isn't there a shorter way to do this?

    Read the article

  • Python - Check if numbers in list are factors of a number

    - by Zach
    Hey, I have a list of numbers (integers) (say, from 1 to 10). They're not necessarily consecutive, but they are in ascending order. I've prompted the user multiple times to enter a choice of the available numbers. When that number is entered, it is removed from the list along with any of its factors that may be there. I've prevented the user from selecting prime numbers. However, at some point in time, there may be non-prime numbers there, which have no factors remaining. I'm relatively new to Python, so I'm having trouble implementing: Checking if the number selected has no factors remaining (even if it is not prime). Checking if only prime numbers remain, or numbers without factors. I'm thinking of using for statements, but I'm not sure exactly how to implement them. Can anyone offer advice, or code? Thanks in advance... PS. In case anyone's wondering, I'm doing an implementation of the game of Taxman in Python.

    Read the article

  • Browser Detection Python / mod_python?

    - by cka
    I want to keep some statistics about users and locations in a database. For instance, I would like to store "Mozilla","Firefox","Safari","Chrome","IE", etc... as well as the versions, and possibly the operating system. What I am trying to locate from Python is this string; Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.14) Gecko/2009090216 Ubuntu/9.04 (jaunty) Firefox/3.0.14 Is there an efficient way to use Python or mod_python to detect the http user agent/browser?

    Read the article

  • Distribute pre-compiled python extension module with distutils

    - by Toji
    Quick one today: I'm learning the in's and out's of Pythons distutils library, and I would like to include a python extension module (.pyd) with my package. I know of course that the recommended way is to have distutils compile the extension at the time the package is created, but this is a fairly complex extension spanning many source files and referencing several external libs so it's going to take some significant playing to get everything working right. In the meantime I have a known working build of the extension coming out of Visual Studio, and would like to use it in the installer as a temporary solution to allow me to focus on other issues. I can't specify it as a module, however, since those apparently must have an explicit .py extension. How could I indicate in my setup.py that I want to include a pre-compiled extension module? (Python 3.1, if it matters)

    Read the article

  • Error installing gst-python through Homebrew

    - by hrr
    I'm trying to install gst-python and it errors with: brew install gst-python Warning: Your Xcode (4.2.1) is outdated Please install Xcode 4.5.2. ==> Downloading http://gstreamer.freedesktop.org/src/gst-python/gst-python-0.10. Already downloaded: /Library/Caches/Homebrew/gst-python-0.10.22.tar.bz2 ==> ./configure --prefix=/usr/local/Cellar/gst-python/0.10.22 configure: set WARNING_CFLAGS to -Wall -Wdeclaration-after-statement -Wpointer-arith configure: set ERROR_CFLAGS to checking for valgrind... no checking for libraries required to embed python... no configure: error: could not find Python lib This is all after I removed the default OSX python and re-installed it with Homebrew, I've edited /etc/paths and python is working well. I just can't install the package above (gst, pygtk is successfully installed). i was told that I need to install python-devel but I have no idea where from. I'm using OSX Lion 10.7.5 With Python 2.7.3

    Read the article

  • Installing Mapnik 2.2.0 in windows 7 with Python 2.7

    - by Joan Natalie
    I've been trying to install mapnik on my computer for hours but what i always get when I import mapnik is ImportError: DLL load failed: The specified procedure could not be found. I'm using Windows 7. The currently installed software is Geoserver from Opengeo suite. Here is my path %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\Java\jre7\bin;C:\Program Files\Java\jdk1.7.0_45\bin;C:\Python27;C:\mapnik-v2.2.0\lib My python path: C:\Python27;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\Program Files\ArcGIS\bin;C:\\mapnik-v2.2.0\python\2.7\site-packages\;C:\mapnik-v2.2.0\bin\;

    Read the article

  • How to convert a python utc datetime to a local datetime using only python standard library?

    - by Nitro Zark
    I have a python datetime instance that was created using datetime.utcnow() and persisted in database. For display, I would like to convert the datetime instance reloaded from database to local datetime using the default local timezone (e.g. as if the datetime was create using datetime.now()) How can I convert the utc datetime to a local datetime using only python standard library (e.g. no pytz dependency)? It seems one solution would be to use datetime.astimezone( tz ), but how would do you get the default local timezone?

    Read the article

  • Terminate a python script from another python script

    - by Nick
    I've got a long running python script that I want to be able to end from another python script. Ideally what I'm looking for is some way of setting a process ID to the first script and being able to see if it is running or not via that ID from the second. Additionally, I'd like to be able to terminate that long running process. Any cool shortcuts exist to make this happen?

    Read the article

  • Python 2.6 -> Python 3 (ProxyHandler)

    - by blah
    Hallo, I wrote a script that works with a proxy (py2.6x): proxy_support = urllib2.ProxyHandler({'http' : 'http://127.0.0.1:80'}) But in py3.11x there is no urllib2 just a urllib... and that doesnt support the ProxyHandler How can I use a proxy with urllib? Isnt Python 3 newer then Python 2? Why did they remove urllib2 in a newer version?

    Read the article

  • changing Python code in the debugger

    - by max
    Is there any debugger that allows Python code to be changed while debugging? In other words: run-time exception occurs, debugger stops, I change the code any way I like, and tell the program to continue. I am aware of the problems with this approach, such that references to functions would still point to the old definitions if I redefine the function on the fly, and so on. I am ok with that, since I just want to be able to make small fixes in very simple circumstances. On the other hand, I'm also interested in whether it's theoretically possible to allow changes to Python code without running into these problems: i.e., somehow update all the references to the objects that changed, etc. I'm nearly sure the answer to the second question is no, but if I'm wrong, I'd like to know. EDIT: If my goal (changing the code interactively when an exception occurred, and then continuing execution), is achievable without a debugger - that would be good as well. I don't need to use the debugger.

    Read the article

  • Trying to find a match in two strings - Python

    - by Jacob Mammoliti
    I have a user inputting two strings and then I want to check if there are any similar characters and if there is, get the position where the first similarity occurs, without using the find or index function. Below is what I have so far but I doesn't fully work. With what I have so far, I'm able to find the similarities but Im not sure how to find the position of those similarities without using the index function. string_a = "python" string_b = "honbe" same = [] a_len = len(string_a) b_len = len(string_b) for a in string_a: for b in string_b: if a == b: same.append(b) print (same) Right now the output is: ['h', 'o', 'n'] So basically what I am asking is, how can I find the position of those characters without using the Python Index function?

    Read the article

  • installing Python application with Python under windows

    - by mack369
    My application uses many Python libraries (Django, Twisted, xmlrpc). I cannot expect that the end user has the Python installed with all needed libraries. I've created a fancy installer for my application using Inno Setup, but I don't think that it is a good solution to execute 5 other setup programs from my installer. It would be annoying to the user to click "Next" button 15 times. Is there any way to do that quietly?

    Read the article

  • Setuptools Python namespace package in /opt

    - by Samuel Taylor
    I'm trying to get my app to install in /opt/[app_name] using setuptools. My app uses a namespace package. To install I run sudo python setup.py install --prefix=/opt/[app_name]/ --install-lib=/opt/[app_name]/ --install-scripts=/opt/[app_name]/ When I install it this was setuptools does not copy init.py in to my namespace package so when I come to run my app, python does not treat it as a package and I get import errors. if I create the init.py file my app works fine. How do I get setuptool to copy over the init.py file when using --install-lib and --prefix? Thanks Sam

    Read the article

  • How do I install newer python on CentOS with minimal effort?

    - by Sorin Sbarnea
    I would like to install Python 2.6 and mod_python on CentOS 5 (x64). The system is delivered with old python 2.4 and I want the new one with minimal maintenance effort (compiling and having a different installation seams to be suboptimal solution). Is there a solution for this, other than starting to recompile lots of packages? If not should I switch to Ubuntu? Please remember that I'm talking about x64 - I found a repository on net with updated packages but it is not x64.

    Read the article

  • Python install issue on Mac OS X

    - by Michael Waterfall
    I have been using the standard python that comes with OS X Lion (2.7.2) but I wanted to build a UCS-4 version to handle 4-byte unicode characters better. I had already installed pip and packages like pytz, virtualenv and virtualenvwrapper, etc., and these are installed in /Library/Python/2.7/site-packages. My $PATH is /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin. To build a new version of python on the machine (outside of any project specific virtual environments, that will come later), I followed the instructions on this article and managed to build it in /usr/local/bin. The problem is that when I launched a new bash window, I got the following virtualenvwrapper error: Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named virtualenvwrapper.hook_loader virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python and that PATH is set properly. The instructions said to move /usr/local/bin to the top of the /etc/paths file, and since then I've noticed some strange issues. I installed pip into /usr/local/bin and now I have assumed that since I'm working in /usr/local/bin, and the newly installed python's site packages is now located in /usr/local/lib/python2.7/site-packages, when I do pip freeze, it should be empty as nothing is installed there yet. However, pip freeze still reports things installed in the old (OS X) site-packages folder. Here's some info after the build: $ which python /usr/local/bin/python $ which pip /usr/local/bin/pip $ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin When I uninstall a python package with pip, it removes it from the old site-packages folder as expected. When I install it again, instead of installing it in /usr/local/lib/python2.7/site-packages, it installs it in /Library/Python/2.7/site-packages (verified by attempting to install it again and receiving Requirement already satisfied (use --upgrade to upgrade): pytz in /Library/Python/2.7/site-packages ). How is it getting that path for the old site-packages folder? Why won't it install it in the correct location for the python install it's using? I'm getting several other issues since promoting /usr/local/bin but I think if I understand this I'll be able to get somewhere. Can anyone see what's happening? If you need any more info I'll be happy to provide it.

    Read the article

  • Python default version errors

    - by Robus
    For a while I've been getting this error while doing anything apt-get related: Preparing to replace python-cairo 1.4.12-1.2 (using .../python-cairo_1.8.8-1+b1_i386.deb) ... Traceback (most recent call last): [...] File "/usr/share/pycentral-data/pyversions.py", line 172, in default_version raise ValueError, "/usr/bin/python does not match the python default version. It must be reset to point to %s" % debian_default ValueError: /usr/bin/python does not match the python default version. It must be reset to point to python2.6.6 Whereas robus:/# /usr/bin/python -V Python 2.6.6 How do I fix this? I did try fixing symlinks, but then I keep getting 'too many symlink levels' errors.

    Read the article

  • What would cause the "gi" module to be missing from python?

    - by Catalin Dumitru
    After some not so clever editing of the default Python version in Ubuntu, from 2.7 to 3.2, I ended up breaking my entire system. After my computer imploded and everything stopped working, I tried to revert back my changes (by linking /usr/bin/python2.7 to /usr/bin/python and changing the default version in /usr/share/python/debian_defaults back to 2.7) but some things are still broken. For example when I type "import gi" in the python interpreter I get the fallowing message : >>> import gi Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named gi >>> error which appears with some programs too (eg: gnome tweak tool). I have tried re-installing python both from the software center and from sources, but the same error persists. Python -- version now returns : Python 2.7.2 and also some software packages which depend on python 2.7 are now working (for example the software center), but some things are still broken. Is there anything I can do to completely re-install python 2.7 as the default version?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >