Search Results

Search found 13534 results on 542 pages for 'python'.

Page 17/542 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • updater stuck on downloading python files

    - by Tim
    However i am a java programmer is consider myself as a linux noob. So i could use a little help here... I am trying to update my ubuntu from version 10.04 to 12.04.1 (LTS). The downloading start and runs at around 10MB/s untill i am somewhere near 26% and the speed just drops to 0. I figured i could use the command "do-release-update" so i could see what it was doing. Again the same occured: the downloading stucked on 26% at "http://nl.archive.ubuntu.com/ubunutu/ precise/main python-qt4 1386 4.9.1-2ubuntu1". It says it downloaded 41% of that file/package. It also tries another wget on the same file every X seconds. Help? Greetings Tim, Holland.

    Read the article

  • Project Euler 3: (Iron)Python

    - by Ben Griswold
    In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 3.  As always, any feedback is welcome. # Euler 3 # http://projecteuler.net/index.php?section=problems&id=3 # The prime factors of 13195 are 5, 7, 13 and 29. # What is the largest prime factor of the number # 600851475143? import time start = time.time() def largest_prime_factor(n): max = n divisor = 2 while (n >= divisor ** 2): if n % divisor == 0: max, n = n, n / divisor else: divisor += 1 return max print largest_prime_factor(600851475143) print "Elapsed Time:", (time.time() - start) * 1000, "millisecs" a=raw_input('Press return to continue')

    Read the article

  • Project Euler 1: (Iron)Python

    - by Ben Griswold
    In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 1.  As always, any feedback is welcome. # Euler 1 # http://projecteuler.net/index.php?section=problems&amp;id=1 # If we list all the natural numbers below 10 that are # multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of # these multiples is 23. Find the sum of all the multiples # of 3 or 5 below 1000. import time start = time.time() print sum([x for x in range(1000) if x % 3== 0 or x % 5== 0]) print "Elapsed Time:", (time.time() - start) * 1000, "millisecs" a=raw_input('Press return to continue') # Also cool def constraint(x): return x % 3 == 0 or x % 5 == 0 print sum(filter(constraint, range(1000)))

    Read the article

  • How can I share my python scripts with my less python-savvy business person partner?

    - by Alex
    I'm taking financial mathematics as an elective, and I'm working with real life finance industry worker type people. It's actually kind of fun. When I pulled out a macbook at one of our meetings, I had four lifelong windows users look at me like I had three heads. Anyway, I'm helping with design and simulation of our trading strategy, and I wrote a little thing using matplotlib to visualize historical stock data. However, these guys don't know how to use git, or install python, or deal with path-related package management things. I need to be able to send my scripts to them to use, and I need to do it with absolutely minimal effort on their part. I was thinking something on the lines of py2exe, but I'd like to hear some advice before I go ahead.

    Read the article

  • Connect to MySQL on remote server from inside python script (DB API)

    - by Atul Kakrana
    Very recently I have started to write python scripts that need to connect few databases on mySQL server. The problem is that when I work from office my script works fine but running a script from my home while on office VPN generates connection error. I also noticed the mySQL client Squirrel also cannot connect from my home but works fine on Office computer. I think both are giving problem for the same reason. Do I need to create a ssh tunnel and forward the port? If yes how do I do it? mySQL is installed on server I have ssh access. Please help me on this AK

    Read the article

  • How to reduce errors in dynamic language such as python, and improve my code quality

    - by Martin Luo
    I post the origin question in stackoverflow, some people suggest me to post here I've always have trouble with dynamic language like Python. Several problems: Typo error, I can use pylint to reduce some of these errors. But there's still some errors that pylint can not figure out. Object type error, I often forgot what type of the parameter is, int? str? some object? Also, forgot the type of some object in my code. Unit test might help me sometimes, but I'm not always have enough time to do UT. When I need a script to do a small job, the line of code are 100 - 200 lines, not big, but I don't have time to do the unit test, because I need to use the script as soon as possible. So, many errors appear. So, any idea on how to reduce the number of these problems?

    Read the article

  • How to create an auto-grader in and for Python

    - by recluze
    I'm trying to create an auto-grader for one of my beginning programming courses for python. From my online search, I've come to know that it is effectively a unit test framework that tests the student's code rather than production code but I'm not really sure how to structure the flow of the program. Can anyone please provide a strategy for submission of code by students and automating the whole process of marking? For instance, how would the student code be submitted and then stored/structured on disk, how would the grades be stored/reported? I'm only looking for a broad strategy and will try on my own to fill in the blanks. (I asked this on stockoverflow.com initially but it's considered as off-topic and I was suggested to ask here.)

    Read the article

  • Python Multiprocessing with Queue vs ZeroMQ IPC

    - by Imraan
    I am busy writing a Python application using ZeroMQ and implementing a variation of the Majordomo pattern as described in the ZGuide. I have a broker as an intermediary between a set of workers and clients. I want to do some extensive logging for every request that comes in, but I do not want the broker to waste time doing that. The broker should pass that logging request to something else. I have thought of two ways :- Create workers that are only for logging and use the ZeroMQ IPC transport Use Multiprocessing with a Queue I am not sure which one is better or faster for that matter. The first option does allow me to use the current worker base classes that I already use for normal workers, but the second option seems quicker to implement. I would like some advice or comments on the above or possibly a different solution.

    Read the article

  • Quickly and Python Twisted

    - by Aaron
    I am creating a Quickly application that makes use of Python Twisted. When the user launches a window, I want to start the Twisted server I wrote. However, when I do this, it freezes the GUI, because the reactor.run method is constantly running after it is started. I need a way to start the Twisted reactor in its own thread, so that the GUI will continue to operate while the reactor is running. I have read about using Twisted with pyGTK in the Twisted documentation, but I am not sure how I would accomplish this with a Quickly application. What is the best way to start my Twisted server when a window opens without freezing the GUI? Update: My if __name__ == '__main__' statement at the end of my dialog file is: print 'Preparing GLib' GLib.idle_add(before_running) print 'Staring Reactor' from twisted.internet import reactor reactor.run()` I have imported and installed twisted.gtk3reactor earlier on in the file. The before_running method contains dialog = ClientDialog() and dialog.show, as well as the rest of the code I want to run when the dialog opens.

    Read the article

  • Python lower_case_with_underscores style convention: underscores not popular?

    - by squirrel
    PEP8 recommends using lowercase, with words separated by underscores as necessary to improve readability for variable and function names. I've seen this interpreted as lower_case_with_underscores by most people, although in practice and in Python's native methods it seems like lowercasewithoutunderscores is more popular. It seems like following PEP8 strictly would be awkward since it seems to suggest mixing both lower_case_with_underscores and lowercasewithoutunderscores, which would be inconsistent. What is your interpretation of PEP8's variable names, and what do you actually use in practice? (Personally, I like lowerCamelCase as a compromise between readability and ease of typing.)

    Read the article

  • Checking whether the user input is a str in Python [migrated]

    - by Sahil Babbar
    I checked various questions on Stack Overflow but one thing every logic lacks. Let me demonstrate using Python: while True: user_input = raw_input() if type(user_input) == str: print 'ERROR' else: print 'BINGO' Also, we cannot use input() in place of raw_input() as it gives the error:Traceback (most recent call last): File ".\test.py", line 3, in <module> user_input = int(input()) File "<string>", line 1, in <module> NameError: name 'asdf' is not defined The problem here is that raw_input converts the user input into string so it always prints 'ERROR' and if I change the second line to user_input = int(raw_input) then, it gives an error: Traceback (most recent call last): File ".\test.py", line 3, in <module> user_input = int(raw_input()) ValueError: invalid literal for int() with base 10: 'asdf' I tried this with try and except but it shall work fine to check integer but not a string. I feel that this question may be marked as a duplicate but I think that this query is important, if logically taken.

    Read the article

  • What to choose for beginner: PHP/Python/Ruby

    - by Nai
    I'm a beginner teaching myself to code but I would like he insight of the PSE community and helping choose where to start. My main objective is to be able to create a basic website to first test my business idea and from there iterate on it quickly to minimise my learning time. The most important criteria for me is speed. An example of speed would be pre-built components available open source and not having to write one from scratch. From my research, this seems to be a death match between the following languages and frameworks: PHP and CakePHP Python and Django Ruby and Rails Assumptions: I am going to be equally good (or bad) in all 3. It is going to be equally easy to find competent developers in either language. I know this to be false already by lets assume that it is. This question is not meant to karma whore as I've seen how passionate some of these standoff questions have been and I'll be happy to turn it into a community wiki.

    Read the article

  • Next steps for Asp.Net C# developer (RoR vs Python Django vs PhP Drupal)

    - by ProfessorB
    A majority of my web development experience has been on the .Net stack (mainly Asp.net C#). I am looking to learn something new in my spare time, for the use of personal projects and possibly for use professionally (as an ISV). I know some Python, done some scripting with it in the past, nothing on the web though. Php has been around for a long time and RoR has gained a lot of popularity. Are there any developers from the .NET world that have migrated over to one or more of the other platforms? If so, which do you prefer and why? Which would you suggest and why?

    Read the article

  • Problem using python QPID and gevent together [closed]

    - by William Payne
    I have a python script that pulls messages from an Apache QPID queue, and then uses gevent to perform (IO-bound) tasks on those messages in parallel. The queue that this script pulls from was recently changed: I suspect the version of the C++ QPID broker changed, although I cannot verify this at the present time. Now, my process deadlocks and hangs upon QPID queue creation. I strongly suspect that this is a result of an incompatibility with gevent, although I have not done the work yet to produce a minimal example to demonstrate the problem. (Next on my list). Does anybody else have experience of getting gevent and QPID to work together? or Has anybody else seen the same issues?

    Read the article

  • Check validity Partition in python

    - by fadhil
    I have a question, I really don't understand about partition of set. There are 3 definition that we have to know, and I don't know how to implement the definition into python language. In my case, I have a set of RegionsCode which is set(['Sub-Saharan Africa', 'East Asia & Pacific\n', 'Region\n', 'Middle East & North Africa\n', 'North America\n', 'Latin America & Caribbean\n', 'South Asia\n', 'Sub-Saharan Africa\n', 'Europe & Central Asia\n']) And the question is: Determine if RegionCodes is a valid partition of ?????????????????????? n ??????????????????. There are three steps to showing that a partition is valid, all three steps need to be included here. Output the result of each step to the terminal. I would really appreciate if there is someone helps me.. thank you

    Read the article

  • Python simulation-scripts architecture

    - by Beastcraft
    Situation: I've some scripts that simulate user-activity on desktop. Therefore I've defined a few cases (workflows) and implemented them in Python. I've also written some classes for interacting with the users' software (e.g. web browser etc.). Problem: I'm a total beginner in software design / architecture (coding isn't a problem). How could I structure what I described above? Providing a library which contains all the workflows as functions, or a separate class/module etc. for each workflow? I want to keep the the workflows simple. The complexity should be hidden in the classes for interacting with the users' software. Are there any papers / books I could read about this, or could you provide some tips? Kind regards, B

    Read the article

  • Python GUI and MVC - get variable from other module

    - by lyvic
    I am trying to split my code in different layers: GUI, reading the GUI, creating input, calculating the model, interpreting data, creating view, sending the view to the GUI. I got the idea of the MVC and would like to try to build my program that way. But I'm a little confused about how to exchange information between those modules. I'm running into problems with undefined global names and so forth. Example code how I'm trying to get out of this can be found here: http://stackoverflow.com/questions/17385373/setup-a-mvc-mvw-system-in-python-with-tkinter

    Read the article

  • Factory for arrays of objects in python

    - by Vorac
    Ok, the title might be a little misleading. I have a Window class that draws widgets inside itself in the constructor. The widgets are all of the same type. So I pass a list of dictionaries, which contain the parameters for each widget. This works quite nicely, but I am worried that the interface to callers is obfuscated. That is, in order to use Window, one has to study the class, construct a correct list of dictionaries, and then call the constructor with only one parameter - widgets_params. Is this good or bad design? What alternatives does the python syntax provide?

    Read the article

  • Handling large integers in python [migrated]

    - by Sushma Palimar
    I had written a program in python to find b such that a prime number p divides b^2-8. The range for b is [1, (p+1)/2]. For small integers it works, say only up to 7 digits. But not for large integers, say for p = 140737471578113. I get the error message for i in range (2,p1,1): MemoryError I wrote the program as #!/usr/bin/python3 p=long(raw_input('enter the prime number:')) p1=long((p+1)/2) for i in range (2,p1,1): s = long((i*i)-8) if (s%p==0): print i

    Read the article

  • Improving python code

    - by cobie
    I just answered the question on project euler about finding circular primes below 1 million using python. My solution is below. I was able to reduce the running time of the solution from 9 seconds to about 3 seconds. I would like to see what else can be done to the code to reduce its running time further. This is strictly for educational purposes and for fun. import math import time def getPrimes(n): """returns set of all primes below n""" non_primes = [j for j in range(4, n, 2)] # 2 covers all even numbers for i in range(3, n, 2): non_primes.extend([j for j in range(i*2, n, i)]) return set([i for i in range(2, n)]) - set(non_primes) def getCircularPrimes(n): primes = getPrimes(n) is_circ = [] for prime in primes: prime_str = str(prime) iter_count = len(prime_str) - 1 rotated_num = [] while iter_count > 0: prime_str = prime_str[1:] + prime_str[:1] rotated_num.append(int(prime_str)) iter_count -= 1 if primes >= set(rotated_num): is_circ.append(prime) return len(is_circ)

    Read the article

  • issues changing default version when updating Python on Mac

    - by Emma
    I have a MacBook that came with Python 2.5 installed. I need use a newer version, so I downloaded 3.1 and installed it, then ran the "Update Profile Script" that came with it, which is supposed to change the default version of Python to the one I downloaded. It appeared to run fine and said process completed, but it didn't work. When I type "python" into the terminal it displays version 2.5, and I still can't install pygame, which requires at least Python 2.6. When I do vi .profile I get this: export PATH=.:/opt/local/bin:/opt/local/sbin:$PATH export MANPATH=/opt/local/man:$MANPATH Setting PATH for Python 3.1 The orginal version is saved in .profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.1/bin:${PATH}" export PATH ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ".profile" 6L, 251C So it looks like the script did do something, but I don't know enough bash script to understand what. Does anyone know what the issue could be or how to fix it? Thanks a lot!

    Read the article

  • How to find out which python script is using resources?

    - by Jesse the Wind Wanderer
    Can someone tell me how to find out which python script is using lots of system resources? I can see with the 'top' command that a process called "python" is always near the top of the list. 2603 jesse 20 0 159m 27m 13m S 6 1.4 1:47.74 python Can someone tell me how to find this specific python script's name? I could go through the arduous process of disabling startup apps/processes until I finally found the one that starts this python process but there must be a better way of determining what exactly this python process is, yes? Doing a ps -AH doesn't yield anything useful. ps -AH 1 ? 00:00:00 init ... 1325 ? 00:00:00 lightdm 1382 tty7 00:01:57 Xorg 2265 ? 00:00:00 lightdm 2510 ? 00:00:00 gnome-session 2546 ? 00:00:00 ssh-agent 2560 ? 00:00:02 gnome-settings- 2582 ? 00:00:01 syndaemon 2578 ? 00:00:49 compiz 3009 ? 00:00:00 sh 3010 ? 00:00:01 gtk-window-deco 2590 ? 00:00:00 nm-applet 2591 ? 00:00:00 bluetooth-apple 2592 ? 00:00:00 indicator-ubunt 2593 ? 00:00:00 gnome-fallback- 2600 ? 00:00:05 nautilus 2601 ? 00:00:00 everpad 2603 ? 00:02:24 python

    Read the article

  • Import error ft2font from matplotlib (python, macosx)

    - by Tomas K
    I was installing matplotlib to use basemap today when I had to install a lot of stuff to make it work. After installing matplotlib and be able to import it I installed basemap but I can't import basemap because of this error: from mpl_toolkits.basemap import Basemap Traceback (most recent call last): File "", line 1, in File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/mpl_toolkits/basemap/init.py", line 36, in from matplotlib.collections import LineCollection File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib/collections.py", line 22, in import matplotlib.backend_bases as backend_bases File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 38, in import matplotlib.widgets as widgets File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib/widgets.py", line 16, in from lines import Line2D File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib/lines.py", line 23, in from matplotlib.font_manager import FontProperties File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib/font_manager.py", line 52, in from matplotlib import ft2font ImportError: dlopen(/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib/ft2font.so, 2): Symbol not found: _FT_Attach_File Referenced from: /usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib/ft2font.so Expected in: dynamic lookup So when I tried to import ft2font in python by: from matplotlib import ft2font I got this error: Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dlopen(/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib/ft2font.so, 2): Symbol not found: _FT_Attach_File Referenced from: /usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib/ft2font.so Expected in: dynamic lookup Any idea what to do? I'm using Mac OSX 10.6 and python 2.7.2 installed by homebrew.

    Read the article

  • Debian packaging of a Python package.

    - by chrisdew
    I need to write (or find) a script to create a Debian package (using python-support) from a Python package. The Python package will be pure Python (no C extensions). The Python package (for testing purposes) will just be a directory with an empty __init__.py file and a single Python module, package_test.py. The packaging script must use python-support to provide the correct bytecode for possible multiple installations of Python on a target platform. (i.e. v2.5 and v2.6 on Ubuntu Jaunty.) Most advice I find while googling are just examples nasty hacks that don't even use python-support or python-central. I have so far spent hours researching this, and the best I can come up with is to hack around the script from an existing open source project - but I don't know which bits are required for what I'm doing. Has anyone here made a Debian package out of a Python package in a reasonably non-hacky way? I'm starting to think that it will take me more than a week to go from no knowledge of Debian packaging and python-support to getting a working script. How long has it taken others? Any advice? Chris.

    Read the article

  • Online scoreboard in Python?

    - by CorundumGames
    So my friend and I are working on an arcade-style game in Python and Pygame. We're beginning to look at the feasibility of an online leaderboard, given our current programming backgrounds. Such a leaderboard would have the following requirements/features; The ability to search through demographics like region, country, platform, game mode, recentness ("best scores this month") and difficulty. (e.g. to make it possible for someone to say "I'm the best player in Italy!" or "I'm the best Linux player in South America!") Our game will not have online multiplayer, so no need to worry about that. We don't expect the game to be a million-dollar hit. We want the scores to be accessible both from in-game and the website. We would like some semblance of security to make sure no one plugs fake scores into the system. This is our present situation; Neither I nor my friend have any network programming background. All I really know is that sockets are low-level, HTTP is high-level. I happen to know that the Google App Engine might be useful for something like this, and I'm really thinking about going with that. We're not sure how we would store all the high score data. Our game will be free and open source (though we might keep the components that submit the high scores closed-source). Aside from all of this, we don't really have any idea where to begin. Any thoughts?

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >