Search Results

Search found 14486 results on 580 pages for 'python idle'.

Page 25/580 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • exe files and Python

    - by Sorush Rabiee
    i have some questions about python: 1- How to build .exe files from .py files? 2- How to run a program with arguments and receive the result by python code? 3- How to load .NET library in python code (or write python in VS.NET IDE [!?])? 4- is built-in integer of python 3.1 something like a string? it calculates 200! in less than one second and calculates 2^1 to 2^7036 (by a simple recursive algorithm & writing them to a text file) with a 1.75GHz cpu in 4 minuets, so if it is a string, how it can be so fast like this? is there a great difference between memory type and logical calculation of python with c++? 5- what is the best python practice? how can i be an expert?

    Read the article

  • Run another version of Python using virtualenv

    - by mazlor
    I apologize in advance if the question is dummy ,i use Python 3.2.3 on Windows xp ,now i need Python3.3.2 , but i can't remove Python 3.2.3 because i have many codes and packages need to be run by it. I installed virtualenv to run two versions of Python in two different environments , but after that i didn't know what to do to run a code using Python 3.3.2 , here what i did: C:\>virtualenv.exe env1 C:\>env1\Scripts\activate now i don't know what to do after a folder was created its name env1 , i downloaded Python 3.3.2 and installed it in the same folder (env1) , is that correct ? then i try the following: (env1) C:\>python3.3.2 I got the following : 'python3.3.2' is not recognized as an internal or external command, operable program or batch file. also i tried : (env1) C:\>python python33 I got the following: python: can't open file 'python33': [Errno 2] No such file or directory As i mentioned , i stuck at this point , any help will be very appreciated. Thanks

    Read the article

  • Python analog of Unix 'which'

    - by bgbg
    In *nix systems one can use which to find out the full path to a command. For example: $ which python /usr/bin/python or whereis to show all possible locations for a given command $ whereis python python: /bin/python.exe /bin/python2.5-config /usr/bin/python.exe /usr/bin/python2.5-config /lib/python2.4 /lib/python2.5 /usr/lib/python2.4 /usr/lib/python2.5 /usr/include/python2.4 /usr/include/python2.5 /usr/share/man/man1/python.1 Is there an easy way to find out the location of a module in the PYTHONPATH. Something like: >>> which (sys) 'c:\\Python25\Lib\site-packages'

    Read the article

  • Installing GDAL for Python

    - by Nate
    I am trying to install GDAL for python on a Windows XP machine (Python 2.6 currently installed) following the instructions at http://trac.osgeo.org/gdal/wiki/GdalOgrInPython (as is mirrored in a hundred other places). It says I need both the GDAL source (or Windows binary) and the python bindings. The python binding are be downloaded from the python cheeseshop (http://pypi.python.org/pypi/Python_GDAL/1.3.1). I don't see a download link on this page nor can I locate the python binding elsewhere - all instruction I can find seem to point to the same cheeseshop page. This seems like I'm either missing something embarrassingly simple or the bindings file has disappeared. Any thoughts on which it is? Thanks.

    Read the article

  • Stream/string/bytearray transformations in Python 3

    - by Craig McQueen
    Python 3 cleans up Python's handling of Unicode strings. I assume as part of this effort, the codecs in Python 3 have become more restrictive, according to the Python 3 documentation compared to the Python 2 documentation. For example, codecs that conceptually convert a bytestream to a different form of bytestream have been removed: base64_codec bz2_codec hex_codec And codecs that conceptually convert Unicode to a different form of Unicode have also been removed (in Python 2 it actually went between Unicode and bytestream, but conceptually it's really Unicode to Unicode I reckon): rot_13 My main question is, what is the "right way" in Python 3 to do what these removed codecs used to do? They're not codecs in the strict sense, but "transformations". But the interface and implementation would be very similar to codecs. I don't care about rot_13, but I'm interested to know what would be the "best way" to implement a transformation of line ending styles (Unix line endings vs Windows line endings) which should really be a Unicode-to-Unicode transformation done before encoding to byte stream, especially when UTF-16 is being used, as discussed this other SO question.

    Read the article

  • Help with Python structure in *nixes.

    - by user198553
    I came from a Windows background whern it comes to development environments. I'm used to run .exe's from everything I need to run and just forget. I usually code in php, javascript, css, html and python. Now, I have to use Linux at my work, in a non changeable Ubuntu 8.04, with permissions to upgrade my system using company's repositories only. I need to install Python 2.4.3 to start coding in an old legacy system. I had Python 2.5. I downloaded Python 2.4.3 tarballs, ran ./configure make and such. Everything worked out, but now the "default" installation is my system is Python2.4 instead of of Python2.5. I want help from you to change it back, and if possible, some material to read about symlinks, multiple Python installations, virtualenvs and such: everything I need to know before installing/upgrading Python modules. I installed for example the ElementTree package and don't even know in which Python installation it was installed. Thanks in advance!

    Read the article

  • Python interpreter invocation with "-c" and indentation issues

    - by alexander
    I'm trying to invoke Python using the "-c" argument to allow me to run some arbitrary python code easily, like this: python.exe -c "for idx in range(10): print idx" Now this code works fine, from within my batch file, however, I'm running into problems when I want to do anything more than this. Consider the following Python code: foo = 'bar' for idx in range(10): print idx this would then give you 0-9 on the stdout. However, if I collapse this into a single line, using semicolons as delimiters, to get the following: foo = 'bar';for idx in range(10): print idx and try to run it using python.exe -c it get a SyntaxError raised: C:\Python>python.exe -c "foo = 'bar';for idx in range(10): print idx" File "<string>", line 1 foo = 'bar';for idx in range(10): print idx ^ SyntaxError: invalid syntax Anyone know how I can actually use this without switching to a separate .py file?

    Read the article

  • Python modules import error

    - by Choor
    Very strange for me: # uname -a Linux localhost.localdomain 2.6.18-194.3.1.el5 #1 SMP Thu May 13 13:09:10 EDT 2010 i686 i686 i386 GNU/Linux # pwd /root # python Python 2.6.5 (r265:79063, Apr 11 2010, 22:34:44) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 Type "help", "copyright", "credits" or "license" for more information. import dns [3]+ Stopped python # cd /home/user/dev/dns [root@localhost dns]# python Python 2.6.5 (r265:79063, Apr 11 2010, 22:34:44) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 Type "help", "copyright", "credits" or "license" for more information. import dns Traceback (most recent call last): File "", line 1, in File "dns.py", line 1, in import dns.resolver ImportError: No module named resolver [4]+ Stopped python # Summary: I can't import same python module from different path. Any ideas? 0_o P.S. SELINUX=disabled

    Read the article

  • Python extension building with boost

    - by user1544053
    Hey guys I'm fairly new to boost c/c++ library. I downloaded boost library and build the library. I created a very simple python library in c++ using boost interface (actually it is example code given in the documentation). I built it into a dll file. In the documentation it reads that this dll is exposed to python and they just show the import function in python and include the created library. I don't understand how to expose that dll to python and load the library inside in tradition ('import') manner. In case if you wanna look at the code then here it is: #include <boost/python.hpp> char const* greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("greet", greet); } Please help I really want to build applications with c/c++ and python. I simply want to use hello_ext as: >>>import hello_ext >>>print hello_ext.greet() Thank you.

    Read the article

  • VB.Net HTTPWebRequest Speed is slow comparing Python URLOpen

    - by regexhacks
    Hi I am coding a web-crawler which will crawl the websites and selectively parse different sections of a web site. I am a .Net developer so the choice was obvious that I did it in .Net but the speed was very slow which included downloading and parsing of HTMLPages Then I tried to just download the contents first using .Net and then same domains using python but the python was very impressive in downloading data. I have achieved downloading using python but the later part is not that easy to code in python, which obviously i don't want to do. The same batch of domain which took 100 seconds in Python was taking 20 minutes in .Net based crawler I tried http://www.eqlit.com/ to download and in took 8 seconds in Python and same was taking 100 Seconds in .Net crawler Does anyone anyone have any idea why this is slow in .Net but fast in python?

    Read the article

  • Problem running a Python program, error: Name 's' is not defined.

    - by Sergio Tapia
    Here's my code: #This is a game to guess a random number. import random guessTaken = 0 print("Hello! What's your name kid") myName = input() number = random.randint(1,20) print("Well, " + myName + ", I'm thinking of a number between 1 and 20.") while guessTaken < 6: print("Take a guess.") guess = input() guess = int(guess) guessTaken = guessTaken + 1 if guess < number: print("You guessed a little bit too low.") if guess > number: print("You guessed a little too high.") if guess == number: break if guess == number: guessTaken = str(guessTaken) print("Well done " + myName + "! You guessed the number in " + guessTaken + " guesses!") if guess != number: number = str(number) print("No dice kid. I was thinking of this number: " + number) This is the error I get: Name error: Name 's' is not defined. I think the problem may be that I have Python 3 installed, but the program is being interpreted by Python 2.6. I'm using Linux Mint if that can help you guys help me. Using Geany as the IDE and pressing F5 to test it. It may be loading 2.6 by default, but I don't really know. :( Edit: Error 1 is: File "GuessingGame.py", line 8, in <Module> myName = input() Error 2 is: File <string>, line 1, in <Module>

    Read the article

  • Detecting Idle Time with Global Mouse and Keyboard Hooks in WPF

    - by jdanforth
    Years and years ago I wrote this blog post about detecting if the user was idle or active at the keyboard (and mouse) using a global hook. Well that code was for .NET 2.0 and Windows Forms and for some reason I wanted to try the same in WPF and noticed that a few things around the keyboard and mouse hooks didn’t work as expected in the WPF environment. So I had to change a few things and here’s the code for it, working in .NET 4. I took the liberty and refactored a few things while at it and here’s the code now. I’m sure I will need it in the far future as well. using System; using System.Diagnostics; using System.Runtime.InteropServices; namespace Irm.Tim.Snapper.Util { public class ClientIdleHandler : IDisposable { public bool IsActive { get; set; } int _hHookKbd; int _hHookMouse; public delegate int HookProc(int nCode, IntPtr wParam, IntPtr lParam); public event HookProc MouseHookProcedure; public event HookProc KbdHookProcedure; //Use this function to install thread-specific hook. [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId); //Call this function to uninstall the hook. [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern bool UnhookWindowsHookEx(int idHook); //Use this function to pass the hook information to next hook procedure in chain. [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern int CallNextHookEx(int idHook, int nCode, IntPtr wParam, IntPtr lParam); //Use this hook to get the module handle, needed for WPF environment [DllImport("kernel32.dll", CharSet = CharSet.Auto)] public static extern IntPtr GetModuleHandle(string lpModuleName); public enum HookType : int { GlobalKeyboard = 13, GlobalMouse = 14 } public int MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam) { //user is active, at least with the mouse IsActive = true; Debug.Print("Mouse active"); //just return the next hook return CallNextHookEx(_hHookMouse, nCode, wParam, lParam); } public int KbdHookProc(int nCode, IntPtr wParam, IntPtr lParam) { //user is active, at least with the keyboard IsActive = true; Debug.Print("Keyboard active"); //just return the next hook return CallNextHookEx(_hHookKbd, nCode, wParam, lParam); } public void Start() { using (var currentProcess = Process.GetCurrentProcess()) using (var mainModule = currentProcess.MainModule) { if (_hHookMouse == 0) { // Create an instance of HookProc. MouseHookProcedure = new HookProc(MouseHookProc); // Create an instance of HookProc. KbdHookProcedure = new HookProc(KbdHookProc); //register a global hook _hHookMouse = SetWindowsHookEx((int)HookType.GlobalMouse, MouseHookProcedure, GetModuleHandle(mainModule.ModuleName), 0); if (_hHookMouse == 0) { Close(); throw new ApplicationException("SetWindowsHookEx() failed for the mouse"); } } if (_hHookKbd == 0) { //register a global hook _hHookKbd = SetWindowsHookEx((int)HookType.GlobalKeyboard, KbdHookProcedure, GetModuleHandle(mainModule.ModuleName), 0); if (_hHookKbd == 0) { Close(); throw new ApplicationException("SetWindowsHookEx() failed for the keyboard"); } } } } public void Close() { if (_hHookMouse != 0) { bool ret = UnhookWindowsHookEx(_hHookMouse); if (ret == false) { throw new ApplicationException("UnhookWindowsHookEx() failed for the mouse"); } _hHookMouse = 0; } if (_hHookKbd != 0) { bool ret = UnhookWindowsHookEx(_hHookKbd); if (ret == false) { throw new ApplicationException("UnhookWindowsHookEx() failed for the keyboard"); } _hHookKbd = 0; } } #region IDisposable Members public void Dispose() { if (_hHookMouse != 0 || _hHookKbd != 0) Close(); } #endregion } } The way you use it is quite simple, for example in a WPF application with a simple Window and a TextBlock: <Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <TextBlock Name="IdleTextBox"/> </Grid> </Window> And in the code behind we wire up the ClientIdleHandler and a DispatcherTimer that ticks every second: public partial class MainWindow : Window { private DispatcherTimer _dispatcherTimer; private ClientIdleHandler _clientIdleHandler; public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { //start client idle hook _clientIdleHandler = new ClientIdleHandler(); _clientIdleHandler.Start(); //start timer _dispatcherTimer = new DispatcherTimer(); _dispatcherTimer.Tick += TimerTick; _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1); _dispatcherTimer.Start(); } private void TimerTick(object sender, EventArgs e) { if (_clientIdleHandler.IsActive) { IdleTextBox.Text = "Active"; //reset IsActive flag _clientIdleHandler.IsActive = false; } else IdleTextBox.Text = "Idle"; } } Remember to reset the ClientIdleHandle IsActive flag after a check.

    Read the article

  • Programming in python Vs programming in Java

    - by yossale
    I've been writing Java for the last couple of years , and now I've started to write in python (in addition). The problem is that when I look at my Python code it looks like someone tried to hammer Java code into a python format , and it comes out crappy because - well , python ain't Java. Any tips on how to escape this pattern of "Writing Java in Python"? Thanks!

    Read the article

  • What's the meaning of “Monty Python’s Flying Circus” phrase on Python?

    - by Zignd
    I just started studying Python using the Python 3.2 Tutorial and on the introduction is written: By the way, the language is named after the BBC show “Monty Python’s Flying Circus” and has nothing to do with reptiles. Making references to Monty Python skits in documentation is not only allowed, it is encouraged! But I have to say that I did not understood this part: “Monty Python’s Flying Circus”, I'm Brazilian and even Google Translator don't know how to answer it. Can someone explain me this phrase?

    Read the article

  • best way to deal with python pdb flakiness re/stdout?

    - by YGA
    I love python and hate the pdb debugger. For instance, if I have a program where stdout is redirected, my pdb prompts all go to the redirection, because the library was written to write to stdout. Oftentimes this problem is subtle, causing me to think a program is hanging when it's really waiting for input. How do people work around this? (Unfortunately, using other debuggers like winpdb is not an option). Thanks, /YGA

    Read the article

  • Unit testing in python?

    - by yossi.ittach
    Hey - I'm new to python , and I'm having a hard time grasping the concept of Unit testing in python. I'm coming from Java - so unit testing makes sense because - well , there you actually have a unit - A Class. But a Python class is not necessarily the same as a Java class , and the way I use Python - as a scripting language - is more functional then OOP - So what do you "unit test" in Python ? A flow? Thanks!

    Read the article

  • Easiest way to automatically download required modules in Python?

    - by user248237
    I would like to release a python module I wrote which depends on several packages. What's the easiest way to make it so these packages are programmatically downloaded just in case they are not available on the system that's being run? Most of these modules should be available by easy_install or pip or something like that. I simply want to avoid having the user install each module separately. thanks.

    Read the article

  • Where can I find a large body of *Python3* source code?

    - by Ira Baxter
    I'm testing a Python parser. I have Python 2.6/2.7 firmly under control, and some good (large) code samples on which I've tested it. I'm interested in testing my Python3 variant. I've been to various Python open source web sites (e.g., http://pythonsource.com/), which list lots of packages, but they are pretty unclear as whether these are Python 2.x vs 3.x source files. The several samples that I downloaded all turned out to be Python 2.x. Where can I find a number of large Python 3 software source codes? I don't really want 1000 little separate Python3 files; I prefer big applications.

    Read the article

  • How to write a Python 2.6+ script that does gracefully fail with older pyhton?

    - by Sorin Sbarnea
    I'm using the new print from Python 3.x and I observed that the following code does not compile due to the end=' '. from __future__ import print_function import sys if sys.hexversion < 0x02060000: raise Exception("py too old") ... print("x",end=" ") # fails to compile with py24 How can I continue using the new syntax but make the script fails nicely? Is it mandatory to call another script and use only safe syntax in this one?

    Read the article

  • python mock patch : a method of instance is called?

    - by JuanPablo
    In python 2.7, I have this function from slacker import Slacker def post_message(token, channel, message): channel = '#{}'.format(channel) slack = Slacker(token) slack.chat.post_message(channel, message) with mock and patch, I can check that the token is used in Slacker class import unittest from mock import patch from slacker_cli import post_message class TestMessage(unittest.TestCase): @patch('slacker_cli.Slacker') def test_post_message_use_token(self, mock_slacker): token = 'aaa' channel = 'channel_name' message = 'message string' post_message(token, channel, message) mock_slacker.assert_called_with(token) how I can check the string use in post_message ? I try with mock_slacker.chat.post_message.assert_called_with('#channel') but I get AssertionError: Expected call: post_message('#channel') Not called

    Read the article

  • call a python function in another class from a class?

    - by user3527697
    hi i'am begginer in pYthon and openerp , i want to call a function exists in another class for example: i have 2 class : class a: def notif_personne_event(self, cr, uid,ids,context=None): and import a class b: notifier(self, cr, uid,ids,context=None): self.notifiernotif_personne_event() but when i do this an error is displayed telling me that class b have not an attribute notifiernotif_personne_event() someone help me please

    Read the article

  • Install gettext-0.17-1.el5.i386.rpm on CentOS 5.8 i386 gives "/usr/bin/python is needed" error

    - by viji
    I've removed yum by mistake. So, now I'm installing all the dependencies needed by yum manually. One of those is gettext-0.17-1.el5.i386.rpm and when I try to install it gives the following error, error: Failed dependencies: /usr/bin/python is needed by gettext-0.17-1.el5.i386 which is weird since I've installed python 2.6 already in the system. #python -V Python 2.6.8 #which python /usr/local/bin/python So I copied /usr/local/bin/python to /usr/bin/python and even after that I'm getting the same error. Any help is appreciated.

    Read the article

  • How to compile Python scripts for use in FORTRAN?

    - by Vincent Poirier
    Hello, Although I found many answers and discussions about this question, I am unable to find a solution particular to my situation. Here it is: I have a main program written in FORTRAN. I have been given a set of python scripts that are very useful. My goal is to access these python scripts from my main FORTRAN program. Currently, I simply call the scripts from FORTRAN as such: CALL SYSTEM ('python pyexample.py') Data is read from .dat files and written to .dat files. This is how the python scripts and the main FORTRAN program communicate to each other. I am currently running my code on my local machine. I have python installed with numpy, scipy, etc. My problem: The code needs to run on a remote server. For strictly FORTRAN code, I compile the code locally and send the executable to the server where it waits in a queue. However, the server does not have python installed. The server is being used as a number crunching station between universities and industry. Installing python along with the necessary modules on the server is not an option. This means that my “CALL SYSTEM ('python pyexample.py')” strategy no longer works. Solution?: I found some information on a couple of things in thread http://stackoverflow.com/questions/138521/is-it-feasible-to-compile-python-to-machine-code Shedskin, Psyco, Cython, Pypy, Cpython API These “modules”(? Not sure if that's what to call them) seem to compile python script to C code or C++. Apparently not all python features can be translated to C. As well, some of these appear to be experimental. Is it possible to compile my python scripts with my FORTRAN code? There exists f2py which converts FORTRAN code to python, but it doesn't work the other way around. Any help would be greatly appreciated. Thank you for your time. Vincent PS: I'm using python 2.6 on Ubuntu

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >