Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
15,059,862
2013-02-25T03:58:00.000
0
0
1
0
python,data-scrubbing
15,059,896
2
true
0
0
I would suggest to cleanup/validate phone number formatting using regular expressions.
1
0
0
Python Code Scrubbing and reformatting data is a real world problem in computer science, it is the process of taking in a human input that may be in the incorrect format and cleaning it up to put it in a standard format. How can I write a program that asks someone to enter a phone number and then returns that phone number in a standard format if possible otherwise giving an error. Examples: Please enter a phone number including area code: 607-8675309 (607)867-5309 Please enter a phone number including area code: 16078675309 (607)867-5309 Please enter a phone number including area code: (607) Jenny I got your number, I need to make you mine, Jenny don't change your number, 8675309 (607)867-5309
Data Scrubbing and Reformatting
1.2
0
0
772
15,059,902
2013-02-25T04:04:00.000
0
0
0
0
python,ogg
15,060,046
3
false
0
0
This is just not possible without download the data itself. You could specify the related information as part of the S3 metadata of the related key. So could write to introspect the metadata before actually downloading the data.
1
10
0
How do I get the play length of an ogg file without downloading the whole file? I know this is possible because both the HTML5 tag and VLC can show the entire play length immediately after loading the URL, without downloading the entire file. Is there a header or something I can read. Maybe even the bitrate, which I can divide by the file size to get an approximate play length?
Getting the length of a ogg track from s3 without downloading the whole file
0
0
1
1,333
15,064,952
2013-02-25T10:35:00.000
1
0
1
0
python,py2exe
15,065,107
2
false
0
0
You can construct the path to your data files by using the __file__ variable (which contains the path to the Python file you're currently writing code in). You can extend that to be an absolute path (by using os.path.abspath()), then take just the directory part of that path, and join it with the name of your data file.
1
1
0
I've created an executable Python file through py2exe. If I run this executable in its dist folder, it runs just fine. This program it needs to have access to files that are in the dist folder (txt files with reference data). If I create a shortcut in my desktop to that executable file, the program runs but doesn't work properly. It seems that the program runs as its folder was the folder where the shortcut is, not where the exe is. So, it cannot find these txt files with the reference data. In my code, I call those txt files like this: ref_correction = np.matrix(np.genfromtxt( 'Reference_Data.txt' )) How can I fix this?
Running a Python executable file through a shortcut changes the location where the program is running
0.099668
0
0
528
15,068,698
2013-02-25T13:59:00.000
0
0
0
0
python
15,068,825
3
false
0
0
I know one... If you're using python, you can use dictionary's to simplify the storage... You'll have to check for every prime less than square root of the number. Now, suppose p^k divides your number n, your task, I suppose is to find k. Here's the method: int c = 0; int temp = n; while(temp!=0) { temp /= p; c+= temp; } The above is a C++ code but you'll get the idea... At the end of this loop you'll have c = k And yeah, the link given by will is a perfect python implementation of the same algorithm
1
1
1
I want to represent a number as the product of its factors.The number of factors that are used to represent the number should be from 2 to number of prime factors of the same number(this i s the maximum possible number of factors for a number). for example taking the number 24: representation of the number as two factors multiplication are 2*12, 8*3, 6*4 and so on..., representation of the number as three factors multiplication are 2*2*6, 2*3*4 and so on..., representation of the number as four factors multiplication(prime factors alone) are 2*2*2*3. please help me get some simple and generic algorithm for this
representation of a number as multiplication of its factors
0
0
0
1,491
15,068,887
2013-02-25T14:08:00.000
1
0
0
1
python,linux,bash
15,069,543
4
false
0
0
In deps of internet I found something like this, and it looks like working - but still not perfect solution because it returns much more info than I need and also the number near which is proper value is not constant (it differs in other system): ls -l /dev/pts | fgrep username
1
2
0
I need to check how much time passed since last user input occurence (preffered way - in python) on Linux (lucid - 10.4) I know that this is easy in normal way (just using XScreenSaverQueryInfo), but the tricky part is that I don't have x11/extensions/scrnsaver.h header and I HAVE to do that some other way (even if I install needed package I cannot install packeges on 100 other computers on which it will work - I don't have permission to do that).
User Idle time in Linux
0.049958
0
0
3,300
15,072,005
2013-02-25T16:48:00.000
5
0
0
0
python,pandas
15,107,442
3
false
0
0
If your column names have information that you can filter for, you could use df.filter(regex='name*'). I am using this to filter between my 189 data channels from a1_01 to b3_21 and it works fine.
1
17
1
I know about these column slice methods: df2 = df[["col1", "col2", "col3"]] and df2 = df.ix[:,0:2] but I'm wondering if there is a way to slice columns from the front/middle/end of a dataframe in the same slice without specifically listing each one. For example, a dataframe df with columns: col1, col2, col3, col4, col5 and col6. Is there a way to do something like this? df2 = df.ix[:, [0:2, "col5"]] I'm in the situation where I have hundreds of columns and routinely need to slice specific ones for different requests. I've checked through the documentation and haven't seen something like this. Have I overlooked something?
keep/slice specific columns in pandas
0.321513
0
0
28,966
15,072,062
2013-02-25T16:51:00.000
0
0
0
0
python,url,cherrypy
52,942,169
2
false
0
0
Well, .../a/b/x=y is the wrong way to send a value regardless of whether it is a file name or not. The correct way would be .../a/b?x=y or .../a/b/?x=y which would make x a standard query parameter and cherrypy would treat it as such. Thereafter whether there were slashes in the value of x or not would be moot. They would get through to your code just fine.
1
1
0
In CherryPy how do you pass an argument like file path (i.e. /abc/def/ghi) through a URL? I want to do something like http://...../filepath="abc/def/ghi". Thanks.
Passing file path argument to a CherryPy
0
0
0
252
15,073,210
2013-02-25T17:52:00.000
7
1
0
1
python,terminal,pytest
15,073,287
1
true
0
0
I would suggest trying control-Z. That should suspend it; you can then do kill %1 (or kill -9 %1) to kill it (assuming you don't have anything else running in the background) What I'm guessing is happening (from personal experience) is that one of your tests is running in a try / except that is catching all exceptions (including the keyboard interrupt which control c triggers) and is inside a while loop / ignoring the exception.
1
2
0
I am using pytest to run tests and, during the execution of a test, interrupted with ctrl-C. No matter how many times I ctrl-C to get out of the test session (I've also tried ctrl-D to get out of the environment I'm using), my terminal prompt does not return. I accidentally pressed F as well... test.py ^CF^C Does the F have something to do with my being stuck in the captured stderr section and the prompt not returning? Are there any logic explanations why I'm stuck here, and if so, are there any alternatives to exiting this state without closing the window and force exiting the session?
Unable to exit with ^C
1.2
0
0
1,083
15,076,133
2013-02-25T20:44:00.000
0
0
1
0
python,image,colors,pygame,numerical
28,798,012
2
false
0
1
I assume by image you mean pygame.Surface. You have several options: pygame.Surface.set_at(...) Use a palettized surface. Then change the palette. Based on your use case, this is actually probably what I'd suggest. Use the pygame.PixelArray PyGame module. I don't think it requires NumPy. Just use NumPy. It's really not that huge of a requirement; lots of projects require it and it's simple to set up. You get access to the powerful pygame.surfarray module
1
0
0
I'm making a simple game, whereby I want my characters quite customizable. I want my characters to be able to be fully edited in colours, for example, if a player wants their character to have cyan skin, they just put into the sliders, or what I choose to use, "0,255,255", or purple "255,0,255", or something random "25,125, 156", and have their character be that colour. I haven't even started creating the game, but I've got the basis down and I know exactly what I must do for pretty much every EXCEPT this. I done a search in Google, and it turns out, I need numerical python for this? Well this is a whole new package, and in order for the average player to play, I must change it to EXE form... (or have python, pygame and numerical python installed onto their PC, which will be a problem if they have a later version...). Now, it's already getting complex with just pygame, but with numerical python as well, is there even a tutorial on how to do this? Any suggestions? Thanks!
PYGAME - Edit colours of an image (makes white red at 255,0,0) without numerical python?
0
0
0
2,070
15,077,424
2013-02-25T22:06:00.000
0
0
1
1
python,directory,os.path
15,077,527
5
false
0
0
Most of the time, it is the same. But, path can exist physically whereas path.exists() returns False. This is the case if os.stat() returns False for this file. If path exists physically, then path.isdir() will always return True. This does not depend on platform.
3
81
0
I'm checking to see if a directory exists, but I noticed I'm using os.path.exists instead of os.path.isdir. Both work just fine, but I'm curious as to what the advantages are for using isdir instead of exists.
pros and cons between os.path.exists vs os.path.isdir
0
0
0
120,324
15,077,424
2013-02-25T22:06:00.000
4
0
1
1
python,directory,os.path
56,261,695
5
false
0
0
os.path.isdir() checks if the path exists and is a directory and returns TRUE for the case. Similarly, os.path.isfile() checks if the path exists and is a file and returns TRUE for the case. And, os.path.exists() checks if the path exists and doesn’t care if the path points to a file or a directory and returns TRUE in either of the cases.
3
81
0
I'm checking to see if a directory exists, but I noticed I'm using os.path.exists instead of os.path.isdir. Both work just fine, but I'm curious as to what the advantages are for using isdir instead of exists.
pros and cons between os.path.exists vs os.path.isdir
0.158649
0
0
120,324
15,077,424
2013-02-25T22:06:00.000
6
0
1
1
python,directory,os.path
15,077,442
5
false
0
0
Just like it sounds like: if the path exists, but is a file and not a directory, isdir will return False. Meanwhile, exists will return True in both cases.
3
81
0
I'm checking to see if a directory exists, but I noticed I'm using os.path.exists instead of os.path.isdir. Both work just fine, but I'm curious as to what the advantages are for using isdir instead of exists.
pros and cons between os.path.exists vs os.path.isdir
1
0
0
120,324
15,077,984
2013-02-25T22:44:00.000
0
1
0
0
python,text,fonts,mayavi,mayavi.mlab
19,346,840
1
true
0
0
I've just downloaded, and installed it, and I seem to be having the same problem. On Windows 8 right now. This is probably a bug.
1
6
0
Is there a bug in the Mayavi font rendering that prevents changing the font size? I am using the Mayavi2 GUI to change the font size of the axis labels on a volumetric plot. To get there I go to: Scene -> Scalar Field -> Colors and Legends -> Axes -> Label Text (tab) -> Font Size Changing this number does not affect the size of the fonts in the image. Is this a known bug? I have seen no reference to it on Google. How do you change the text size on your mayavi figures?
Does Mayavi "Font Size" text property work?
1.2
0
0
1,563
15,079,069
2013-02-26T00:15:00.000
4
0
0
0
python,algorithm,cartesian-product
15,079,557
2
false
0
0
There are mn results; the minimum work you have to do is write each result to the output. So you cannot do better than O(mn).
2
2
1
I was asked in an interview to come up with a solution with linear time for cartesian product. I did the iterative manner O(mn) and a recursive solution also which is also O(mn). But I could not reduce the complexity further. Does anyone have ideas on how this complexity can be improved? Also can anyone suggest an efficient recursive approach?
Linear time algorithm to compute cartesian product
0.379949
0
0
1,149
15,079,069
2013-02-26T00:15:00.000
0
0
0
0
python,algorithm,cartesian-product
20,166,514
2
false
0
0
The question that comes to my mind reading this is, "Linear with respect to what?" Remember that in mathematics, all variables must be defined to have meaning. Big-O notation is no exception. Simply saying an algorithm is O(n) is meaningless if n is not defined. Assuming the question was meaningful, and not a mistake, my guess is that they wanted you to ask for clarification. Another possibility is that they wanted to see how you would respond when presented with an impossible situation.
2
2
1
I was asked in an interview to come up with a solution with linear time for cartesian product. I did the iterative manner O(mn) and a recursive solution also which is also O(mn). But I could not reduce the complexity further. Does anyone have ideas on how this complexity can be improved? Also can anyone suggest an efficient recursive approach?
Linear time algorithm to compute cartesian product
0
0
0
1,149
15,081,502
2013-02-26T04:43:00.000
0
0
0
0
python,rest,web-applications,redis
15,084,434
1
true
0
0
More data about your redis setup and the size of the data set would be useful. That said I would venture to guess your Eedis server is configured to persist data to disk (the default). If so you could be seeing your Redis node getting a bit overwhelmed whenit forks off a copy of itself to save the data set to disk. If this is the case and you do need to persist to disk then I would recommend a second instance be stood up and configured to be a shave to the first one and persist to disk. The master you would then configure to not persist to disk. In this configuration you should see the writable node be fully responsive at all times. You could even go so far as to setup a Non-persisting slave for read-only access. But without more details on your configuration, resources, and usage it is merely an educated guess.
1
2
0
Using Redis with our Python WSGI application, we are noticing that at certain intervals, Redis stops responding to requests. After some time, however, we are able to fetch the values stored in it again. After seeing this situation and checking the status of the Redis service, it is still online. If it is of any help, we are using the redis Python package and using StrictRedis as a connection class, with a default ConnectionPool. Any ideas on this will be greatly appreciated. If there is more information which will help better diagnose the problem, let me know and I'll update ASAP. Thanks very much!
Redis server responding intermittently to Python client
1.2
0
1
122
15,081,981
2013-02-26T05:27:00.000
1
0
1
0
python,antlr3
15,169,699
1
true
0
0
One advantage of using tree parsers is that you can organize them into multiple passes. For some translation work I did I was able to use seven passes and separate logical steps into their own pass. One pass did expression analysis, one did control flow analysis, others used that analysis to eliminate dead code or to simplify the translation for special cases. I personally like using tree grammars for the same reason I like using parsers for text grammars. It allows me to use rules to organize the parsing context. It's easy to do things like structure rules to recognize a top-level expression versus a subexpression if you need to distinguish between them for recognition purposes. All of the attribute and context management you use in regular parsers can apply to tree parsers.
1
1
0
I am creating a Domain Specific Language using Antlr3. So far, I have directly translated the parsed objects from inside the parser grammar. Going through the examples of AST and Tree Walker, i came to know that they are normally used to divide the grammar into hierarchical tree and translate objects from the nodes. Currently i am also doing the same sort of action using parser grammar where i translate objects from each sub-rule. I would be more than happy to know the advantages of using AST & Tree walker over just using parser grammars. Thanking you in advanced.
What is the advantage of using AST & Tree walker for translating a DSL instead of directly parsing & translating objects from parser grammar?
1.2
0
0
394
15,082,031
2013-02-26T05:30:00.000
0
0
0
0
python,webkit,history,gtk3
16,125,745
1
false
1
0
The history recording is supposed to be automatic. In this case, there is either no history command, or the appropriate command has not been initialized. You have to set a command to start the clock at a certain point, or else the time will always be 0 from the clock's point of view. I don't know the actual command, but hopefully you will understand the concept.
1
2
0
I'm using GTK3 with python. While accessing the backforward list the get_last_visited_time returns 0.0 The get_last_visited_time is being called in the notify status signal callback on load_status = FINISHED. All the other values like uri, and title are the correct values.
python webkit webview: Why does the history have dates that equal 0.0, and what needs to be fixed?
0
0
0
192
15,087,303
2013-02-26T10:56:00.000
0
0
0
0
python,matplotlib,axes
15,090,586
1
false
0
0
The problem was the sampling. Although the arrays have the same size, the stepsize in the plot is not equal for x and y axis.
1
1
1
I am plotting a contourmap. When first plotting I noticed I had my axes wrong. So I switched the axes and noticed that the structure of both plots is different. On the first plot the axes and assignments are correct, but the structure is messy. On the second plot it is the other way around. Since it's a square matrix I don't see why there should be a sampling issue. Transposing the matrix with z-values or the meshgrid of x and y does not help either. Whatever way I plot x and y correctly it keeps looking messy. Does anybody here know any more ideas which I can try or what might solve it?
contourf result differs when switching axes
0
0
0
50
15,087,499
2013-02-26T11:06:00.000
1
1
0
0
github,ipython,gist
15,089,524
1
true
0
0
It is not possible with the current code, it is not even planned on the Roadmap. Still this could be done as an extension. You can also propose patches to current magic, Pull Request are always welcomed.
1
1
0
In ipython terminal : %pastebin -d "my description" 1-150 returns the url to the gist. However, I want to paste it as a logged in user, into my github account. Additionally, is there a way to create private gist (rather than public) from within ipython.
How to put gist as user (and not anonymous)?
1.2
0
0
472
15,089,915
2013-02-26T13:06:00.000
0
0
1
0
python,ipython
15,090,044
1
false
0
0
Your python code test.py has InteractiveShell object which doesn't have Completer attribute. This is what the error message says. Check the InteractiveShell class and look for the Completer attribute.
1
0
0
I got the error message: AttributeError: 'InteractiveShell' object has no attribute 'Completer' WARNING: Failure executing file: <./test.py> I have windows 7, neurodebian 6.0.2 and ipython 0.10 could you tell me what's wrong?
InteractiveShell attribute
0
0
0
56
15,093,780
2013-02-26T16:06:00.000
1
0
1
1
python,windows,python-2.7,save
15,094,305
1
true
0
0
Does it contain some or all of the current execution state of your program? Yes. Is it in a form that you could easily extract the information in the user-level format you are probably looking for from it? Probably not. It will dump the state of the entire Python interpreter, including the data as represented in memory for the specific Python program that is running. To reconstruct that data, I'm pretty sure you'd need to run the Python interpreter itself in debug mode, then try to reconstruct your data from whatever your C debugger can piece together. If this sounds very difficult or impossible to you, then you probably have some understanding of what it entails.
1
0
0
I have a Python program that had some kind of error that prevents it from saving my data. The program is still running, but I cannot save anything. Unfortunately, I really need to save this data and there seems to be no other way to access it. Does the DMP file created for the process through the task manager contain the data my program collected, and if so, how do I access it? Thanks.
Can you read variable data of an already running Python Script from its DMP file in Windows?
1.2
0
0
165
15,093,865
2013-02-26T16:10:00.000
1
0
1
0
python,macos,py2app
15,098,915
1
false
0
1
The pyc files are stored in a zipfile in the Resources folder. The name of the zip file depends on the Python version, for 2.7 it is .app/Contents/Resources/python2.7/site-packages.zip. That zip file is a regular zipfile that can be manipulated with the usual tools.
1
0
0
Is there anyway the pyc file can be extracted from an Application bundle? I'm referring to an application bundle that was created by using py2app on python code.
extract pyc from Application bundle
0.197375
0
0
171
15,096,090
2013-02-26T18:03:00.000
0
0
1
0
python,multithreading,logging,nfs
51,724,542
3
false
0
0
The simplest way is to using custom handler for logging which will pass all logs with queue from child process to main, and there log it. in such way for example working logging on client application where u have main UI thread and worker threads. Also on POSIX system, u can use logging in append mode. Up to 4kb it would be atomic.
1
20
0
Does Python's logging library provide serialised logging for two (or more) separate python processes logging to the same file? It doesn't seem clear from the docs (which I have read). If so, what about on completely different machines (where the shared log file would exist on an NFS export accessible by both).
Python: separate processes logging to same file?
0
0
0
17,458
15,096,306
2013-02-26T18:15:00.000
3
0
0
1
python,pip,pythonbrew
15,259,856
1
true
0
0
I found a solution. I uninstalled my Python 3.3.0 by issuing pythonbrew uninstall 3.3.0. Then I installed it again with pythonbrew install --configure="--with-zlib" 3.3.0. This allowed pip to install and thus now I can use it to install to this Python version. Maybe somebody else can find this helpful, cheers!
1
2
0
I have started using pythonbrew to manage different Python installs. The main reason I wanted to do this is to install third party modules without affecting my system's Python install. Fore example I thought I would install the requests library using: pip install requests However this causes an error saying: error: could not create '/usr/local/lib/python2.7/dist-packages/requests': Permission denied Obviously I don't want to install it to the system's Python which is Python 2.7.3. I did have to install pip with my package manager and the resultant path is /usr/bin/pip. How can I use pip to install to my pythonbrew installs? (My current pythonbrew Python version is 3.3.0) Am I missing something?
Using pip in pythonbrew
1.2
0
0
2,019
15,098,051
2013-02-26T19:54:00.000
2
0
0
1
python,google-app-engine
15,098,634
2
false
1
0
Don't worry about it. It (IIRC) keeps the whole DB (datastore) in memory using a "emulation" of the real thing. There are lots of other issues that you won't see when deployed. I'd suggest that your hard drive is spinning down and the delay you see is it taking a few seconds to wake back up. If this becomes a problem, develop using the deployed version. It's not so different.
2
2
0
I'm doing a small web application which might need to eventually scale somewhat, and am curious about Google App Engine. However, I am experiencing a problem with the development server (dev_appserver.py): At seemingly random, requests will take 20-30 seconds to complete, even if there is no hard computation or data usage. One request might be really quick, even after changing a script of static file, but the next might be very slow. It seems to occur more systematically if the box has been left for a while without activity, but not always. CPU and disk access is low during the period. There is not allot of data in my application either. Does anyone know what could cause such random slowdowns? I've Google'd and searched here, but need some pointers.. /: I've also tried --clear_datastore and --use_sqlite, but the latter gives an error: DatabaseError('file is encrypted or is not a database',). Looking for the file, it does not seem to exist. I am on Windows 8, python 2.7 and the most recent version of the App Engine SDK.
Google App Engine development server random (?) slowdowns
0.197375
1
0
237
15,098,051
2013-02-26T19:54:00.000
0
0
0
1
python,google-app-engine
15,106,246
2
false
1
0
Does this happen in all web browsers? I had issues like this when viewing a local app engine dev site in several browsers at the same time for cross-browser testing. IE would then struggle, with requests taking about as long as you describe. If this is the issue, I found the problems didn't occur with IETester. Sorry if it's not related, but I thought this was worth mentioning just in case.
2
2
0
I'm doing a small web application which might need to eventually scale somewhat, and am curious about Google App Engine. However, I am experiencing a problem with the development server (dev_appserver.py): At seemingly random, requests will take 20-30 seconds to complete, even if there is no hard computation or data usage. One request might be really quick, even after changing a script of static file, but the next might be very slow. It seems to occur more systematically if the box has been left for a while without activity, but not always. CPU and disk access is low during the period. There is not allot of data in my application either. Does anyone know what could cause such random slowdowns? I've Google'd and searched here, but need some pointers.. /: I've also tried --clear_datastore and --use_sqlite, but the latter gives an error: DatabaseError('file is encrypted or is not a database',). Looking for the file, it does not seem to exist. I am on Windows 8, python 2.7 and the most recent version of the App Engine SDK.
Google App Engine development server random (?) slowdowns
0
1
0
237
15,099,344
2013-02-26T21:11:00.000
3
0
0
1
python,windows,environment-variables
15,099,480
1
true
1
0
If you set an environment variable in the registry (or via the System Properties > Advanced > Environment Variables UI), it will be global and persistent for every process launched from the top level context created after the variable was set. Shells and contexts initialized before your change will not pick up those changes unless you explicitly merge the values from the registry with the existing values in that context though. Each context inherits the environment of its parent, but after that point, changes to the parent or child environments do not propagate in either direction. Contexts created at the top level get their environment from the registry.
1
0
0
Exactly what it says. I can set per-user environment variables, either from Windows > type "Path", or using RegEdit, or even from a Python script. But if I run an application (e.g. from Launchy, or launch it from Chrome), it won't pick up the new variables. I've got to start a new cmd or Windows Explorer (I think) to get the new values. Now, obviously I can set them on a per-use basis, but I want to set them globally for my account, and also for whatever process I happen to be using at the time. Is this possible? And is it possible (or easier) to do from a Python script?
Is it possible to reload (Windows) environment variables?
1.2
0
0
7,103
15,101,770
2013-02-26T23:55:00.000
0
0
0
0
javascript,python,google-chrome,web-applications,tsv
15,101,984
3
true
1
0
The whole point of a web application is that the GUI is written in HTML, CSS, and JavaScript, not Python. However, it talks to a web service, which can be written in Python. For a well-written desktop app, the transition should be pretty easy. If you've already got a clean separation between the GUI part and the engine part of your code, the engine part will only need minor changes (and maybe stick it behind, e.g., a WSGI server). You will have to rewrite the GUI part for the web, but in a complex app, that should be the easy part. However, many desktop GUI apps don't have such a clean separation. For example, if you have button handlers that directly do stuff to your model, there's really no way to make that work without duplicating the model on both sides (the Python web service and the JS client app) and synchronizing the two, which is a lot of work and leads to a bad experience. In that case, you have to decide between rewriting most of your app from scratch, or refactoring it to the point where you can web-service-ify it. If you do choose to go the refactoring route, I'd consider adding a second local interface (maybe using the cmd module to build a CLI, or tkinter for an alternate GUI), because that's much easier to do. Once the same backend code can support your PyQt GUI and your cmd GUI, adding a web interface is much easier.
3
0
0
I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. Can someone give me a practical way to do this? It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? Thanks.
How to setup a web app which can handle local data without uploading the data? Use python
1.2
0
1
218
15,101,770
2013-02-26T23:55:00.000
1
0
0
0
javascript,python,google-chrome,web-applications,tsv
15,101,809
3
false
1
0
No, you cannot run Python code in a web browser.[1] You'd have to port the core of your application to JavaScript to do it all locally. Just do the upload. 20MB isn't all that much data, and if it's stored on the server then they can all look at each others' results, too. [1] There are some tools that try to transpile Python to JavaScript: pyjs compiles directly, and Emscripten is an entire LLVM interpreter in JS that can run CPython itself. I wouldn't really recommend relying on these.
3
0
0
I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. Can someone give me a practical way to do this? It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? Thanks.
How to setup a web app which can handle local data without uploading the data? Use python
0.066568
0
1
218
15,101,770
2013-02-26T23:55:00.000
0
0
0
0
javascript,python,google-chrome,web-applications,tsv
32,979,390
3
false
1
0
If I get your point correctly, you want Web connection, so your python program updated on server, client get it before using it. Data store on local to avoid upload big file. You can write a python program to check a server location to get your latest program if needed. You need a url / server file for program version / created date/time information to determine if you need to update or not. After get latest python program, then start this python program to run locally. With this said, What you need is to update your program to add below features: Access your server, to get latest version information Check against current version to see if you need to download latest program Download latest version and use that to run locally. Does this solve your problem?
3
0
0
I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. Can someone give me a practical way to do this? It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? Thanks.
How to setup a web app which can handle local data without uploading the data? Use python
0
0
1
218
15,102,943
2013-02-27T02:07:00.000
1
0
1
0
python,python-2.7,installation,upgrade,windows-7-x64
15,103,039
4
false
0
0
I have always just installed the new version on top and never had any issues. Do make sure that your path is updated to point to the new version though.
1
141
0
I have version 2.7 installed from early 2012. I can't find any consensus on whether I should completely uninstall and wipe this version before putting on the latest version. "Soft"-removing old versions? Hard-removing/wiping old versions? Installing over top? I've seen somewhere a special install/upgrade process using a "segmenting" method of Python installations, keeping different versions separate and apart, but functional. Not sure if this is the standard, de facto way. I also wonder if Revo gets too overzealous and may cause issues with wiping out still-needed remnants, like environment/PATH variables. (Win7 x64, 32-bit Python)
How to update Python?
0.049958
0
0
495,079
15,104,090
2013-02-27T04:13:00.000
0
0
0
0
python,png
15,104,289
2
false
0
1
Is there a reason why this is a bad idea or should I keep toying with it? This is essentially like encoding file type by file extension. The only bad thing about encoding file metadata in the filename is it's quite limited in space. You can encode much richer metadata if you used proper PNG metadata field or in a separate file. Encoding metadata in the file name is hard to extend with new fields in new version, with optional fields, etc. For example, you might find out that you want miscellaneous sprite sheet where each frame has different size, and so you need to encode the position, size, class name, and serial number for each individual frame. It's fine as long as you don't expect to want to encode many other metadata in the future.
2
0
0
I am making a little game app that allows users to load up textures manually. One such example would be a standard deck of 52 cards. Would it be bad to store the processing info as: Card_79x123_53_53.png Upon getting the filename from a file dialog, I would split the underscores to get the following info: ObjectType : matched to list (w,h) Number of objects expected (in case there's tailing empty space) Extra info (in this case the location of the face-down texture relative to N above) and the dimensions of the image provide the rest, of course. ANY error in processing would of course be raised and the attempt to load textures would be rejected. Is there a reason why this is a bad idea or should I keep toying with it?
Is it a bad idea to use a PNG image's filename to store the info on how to process it?
0
0
0
65
15,104,090
2013-02-27T04:13:00.000
0
0
0
0
python,png
15,104,140
2
true
0
1
Probably it would be better to ask user about how to process image explicitly either by adding extra controls into file dialog, or by showing another dialog after file dialog is submitted. In this case information taken from file name could be used as hints to preliminary fill these extra controls with values, but user will have a chance to correct what is wrong and fill what is missing.
2
0
0
I am making a little game app that allows users to load up textures manually. One such example would be a standard deck of 52 cards. Would it be bad to store the processing info as: Card_79x123_53_53.png Upon getting the filename from a file dialog, I would split the underscores to get the following info: ObjectType : matched to list (w,h) Number of objects expected (in case there's tailing empty space) Extra info (in this case the location of the face-down texture relative to N above) and the dimensions of the image provide the rest, of course. ANY error in processing would of course be raised and the attempt to load textures would be rejected. Is there a reason why this is a bad idea or should I keep toying with it?
Is it a bad idea to use a PNG image's filename to store the info on how to process it?
1.2
0
0
65
15,105,183
2013-02-27T05:56:00.000
1
0
0
0
python,sockets,ssh,paramiko
15,105,597
1
false
0
0
Try switching off Windows firewall. It's a network error, it should not be because of SSH key problems. Error Code 10060: Connection timeout Background: The gateway could not receive a timely response from the website you are trying to access. This might indicate that the network is congested, or that the website is experiencing technical difficulties.
1
0
0
It seems the socket connection through paramiko (v1.10.0) is not stable. I have two computers. The python code is on the PC one. The connection sometime is successful and sometime is not (Same code). When the PC paramiko code fails (socket.error, 10060), I use my Mac via terminal ssh login the server and everything is fine. I use set_missing_host_key_policy in the code. But the Mac has the key I guess. I typed yes when login at the first time. If the unstable connection is caused by the hotkey, how do I get the host key? From the server or somewhere in my local folder (win7)?
python paramiko module socket.error, errno 10060
0.197375
0
1
3,123
15,105,983
2013-02-27T06:57:00.000
0
1
0
0
python,memory,cgi
15,106,075
2
false
0
0
It is very unlikely there is a standard way to do this. If the value is not in the environment, you can not find it programmatically. How is the script run (server, module...)?
1
0
0
Working with large in memory objects and was wondering if there's a way to check how much memory a python CGI process is allocated from within a script?
find memory limit programmatically in cgi python script?
0
0
0
149
15,108,880
2013-02-27T09:47:00.000
5
0
1
0
django,python-2.7,python-3.x
15,109,041
3
false
1
0
The release notes state clearly that Python 3 support in 1.5 is experimental. And yes, third-party apps will be a problem.
3
1
0
Django just release their 1.5 version. It now supports Python 3, my question is quite simple indeed: With this 1.5 Version, should I still use Python 2.7 or Python 3 ? I assume that with Python 3 there will be some issues with 3rd parties app no ? In your case, what would you do ?
Django 1.5 : Python 2.7 or Python 3
0.321513
0
0
292
15,108,880
2013-02-27T09:47:00.000
0
0
1
0
django,python-2.7,python-3.x
15,109,485
3
false
1
0
I would still use python 2.7 because many apps and libraries are not ready for python 3.x PIL is not working correctly with python 3
3
1
0
Django just release their 1.5 version. It now supports Python 3, my question is quite simple indeed: With this 1.5 Version, should I still use Python 2.7 or Python 3 ? I assume that with Python 3 there will be some issues with 3rd parties app no ? In your case, what would you do ?
Django 1.5 : Python 2.7 or Python 3
0
0
0
292
15,108,880
2013-02-27T09:47:00.000
0
0
1
0
django,python-2.7,python-3.x
15,109,147
3
false
1
0
If I was starting a new development which I didn't expect to go live until well after version 1.6 is released (when Python 3 support is supposed to be production ready, and hopefully the 3rd party apps have caught up) , then yes, I would go with Python 3. It is significantly cleaner than Python 2.7. But if you want your site up and running in the near future, stick with 2.7.
3
1
0
Django just release their 1.5 version. It now supports Python 3, my question is quite simple indeed: With this 1.5 Version, should I still use Python 2.7 or Python 3 ? I assume that with Python 3 there will be some issues with 3rd parties app no ? In your case, what would you do ?
Django 1.5 : Python 2.7 or Python 3
0
0
0
292
15,110,982
2013-02-27T11:29:00.000
2
1
0
1
python,unix
15,111,135
2
false
0
0
Consider using ps instead of top as I don't know any reasons why top would be better for this task. You can configure ps output much more flexibly than top one.
1
0
0
I need to extract process details from top command on a few *nix systems I monitor. The details needed are username, command executed, PID, PPID, username and resident memory consumption. If memory usage is greater than a threshold or command is illegal, I need to send a warning to the user at [email protected] I am writing a script to do this in python and get the required data by executing 'top -bc -n 1' and grepping for command keyword. However, I also need to extract username for the illegal processes to send the mail warning. However, top automatically truncates usernames greater than 8 characters. How do I retrieve the full user names?
How to get full user name in the output of 'top' command in *nix?
0.197375
0
0
2,320
15,111,230
2013-02-27T11:42:00.000
7
0
0
0
python,numpy,multidimensional-array
15,111,407
4
false
0
0
There are at least two main reasons for using NumPy arrays: NumPy arrays require less space than Python lists. So you can deal with more data in a NumPy array (in-memory) than you can with Python lists. NumPy arrays have a vast library of functions and methods unavailable to Python lists or Python arrays. Yes, you can not simply convert lists to NumPy arrays and expect your code to continue to work. The methods are different, the bool semantics are different. For the best performance, even the algorithm may need to change. However, if you are looking for a Python replacement for Matlab, you will definitely find uses for NumPy. It is worth learning.
3
5
1
I build a class with some iteration over coming data. The data are in an array form without use of numpy objects. On my code I often use .append to create another array. At some point I changed one of the big array 1000x2000 to numpy.array. Now I have an error after error. I started to convert all of the arrays into ndarray but comments like .append does not work any more. I start to have a problems with pointing to rows, columns or cells. and have to rebuild all code. I try to google an answer to the question: "what is and advantage of using ndarray over normal array" I can't find a sensible answer. Can you write when should I start to use ndarrays and if in your practice do you use both of them or stick to one only. Sorry if the question is a novice level, but I am new to python, just try to move from Matlab and want to understand what are pros and cons. Thanks
what is a reason to use ndarray instead of python array
1
0
0
1,532
15,111,230
2013-02-27T11:42:00.000
8
0
0
0
python,numpy,multidimensional-array
15,111,278
4
true
0
0
NumPy and Python arrays share the property of being efficiently stored in memory. NumPy arrays can be added together, multiplied by a number, you can calculate, say, the sine of all their values in one function call, etc. As HYRY pointed out, they can also have more than one dimension. You cannot do this with Python arrays. On the other hand, Python arrays can indeed be appended to. Note that NumPy arrays can however be concatenated together (hstack(), vstack(),…). That said, NumPy arrays are mostly meant to have a fixed number of elements. It is common to first build a list (or a Python array) of values iteratively and then convert it to a NumPy array (with numpy.array(), or, more efficiently, with numpy.frombuffer(), as HYRY mentioned): this allows mathematical operations on arrays (or matrices) to be performed very conveniently (simple syntax for complex operations). Alternatively, numpy.fromiter() might be used to construct the array from an iterator. Or loadtxt() to construct it from a text file.
3
5
1
I build a class with some iteration over coming data. The data are in an array form without use of numpy objects. On my code I often use .append to create another array. At some point I changed one of the big array 1000x2000 to numpy.array. Now I have an error after error. I started to convert all of the arrays into ndarray but comments like .append does not work any more. I start to have a problems with pointing to rows, columns or cells. and have to rebuild all code. I try to google an answer to the question: "what is and advantage of using ndarray over normal array" I can't find a sensible answer. Can you write when should I start to use ndarrays and if in your practice do you use both of them or stick to one only. Sorry if the question is a novice level, but I am new to python, just try to move from Matlab and want to understand what are pros and cons. Thanks
what is a reason to use ndarray instead of python array
1.2
0
0
1,532
15,111,230
2013-02-27T11:42:00.000
1
0
0
0
python,numpy,multidimensional-array
53,073,528
4
false
0
0
Another great advantage of using NumPy arrays over built-in lists is the fact that NumPy has a C API that allows native C and C++ code to access NumPy arrays directly. Hence, many Python libraries written in low-level languages like C are expecting you to work with NumPy arrays instead of Python lists. Reference: Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython
3
5
1
I build a class with some iteration over coming data. The data are in an array form without use of numpy objects. On my code I often use .append to create another array. At some point I changed one of the big array 1000x2000 to numpy.array. Now I have an error after error. I started to convert all of the arrays into ndarray but comments like .append does not work any more. I start to have a problems with pointing to rows, columns or cells. and have to rebuild all code. I try to google an answer to the question: "what is and advantage of using ndarray over normal array" I can't find a sensible answer. Can you write when should I start to use ndarrays and if in your practice do you use both of them or stick to one only. Sorry if the question is a novice level, but I am new to python, just try to move from Matlab and want to understand what are pros and cons. Thanks
what is a reason to use ndarray instead of python array
0.049958
0
0
1,532
15,114,329
2013-02-27T14:17:00.000
0
0
0
0
python,excel,xlrd
15,114,556
2
false
0
0
It looks like XLRD is used for reading the data, not interfacing with excel. So no, unless you use a different library using python is not the best way to do this, what is wrong with the VBA script?
1
0
0
How do I save an open excel file using python= I currently read the excel workbook using XLRD but I need to save the excel file so any changes the user inputs are read. I have done this using a VBA script from within excel which saves the workbook every x seconds, but this is not ideal.
Save open excel file using python
0
1
0
758
15,117,182
2013-02-27T16:28:00.000
0
0
0
0
python,django,caching,memcached
21,271,795
1
false
1
0
This isn't anything to do with memcache; it sounds like the old compiled python scripts are still being used. Theoretically, restarting apache should do it. If not, deleting all the .pyc files (compiled python files; not .py, which are your source code) and restarting your server should force it to regenerate the .pyc files from the current source.
1
0
0
Please tell some way to completely remove memcached from Django server. Using apache with mod WSGI and have already deleted all caches lines from settings.py but even that file is being cached. Even removing settings.py doesn't stop site from working. This is ridiculous. There is no .pyc being formed which I could delete. Where are the files being cached. I cannot get code changes in .py files to reflect in any way. They sometimes reflect, sometimes the old code comes back from some cache. How can I delete all caching mechanisms from this server ? Regards !
Remove memcached completely from django
0
0
0
440
15,119,751
2013-02-27T18:40:00.000
0
0
0
0
python,multithreading,pyqt
15,119,949
1
false
0
1
Well create a layout (a vertical layout i suppose) and then create as many QProgressbar you need and add them to your layout with addWidget and that's it. If you need scrolling, try using a QScrollArea.
1
0
0
I wanted to create a file copy program in which progress bar indicates progress. Now if I started n copy/paste operations, that many progress bars should be displayed like windows 8 does. The program should be like one window, say "SHOW", is displaying QProgressbar for copy/paste of 1st operation. When 2 copy/paste will start before 1st one finishes, the 2nd QProgressbar will be added in SHOW and hence there will be 2 progressbars in SHOW.
How to add new QProgressbar to an existing window?
0
0
0
104
15,120,746
2013-02-27T19:32:00.000
3
0
0
0
python,button,gtk,radio-button,toggle
15,123,955
3
true
0
1
Use set_active() (or props.active). Alternatively, you can create some Gtk.RadioButton widgets and set draw_indicator property to False. In the latter case you can create radio groups in normal way, without custom handling.
2
3
0
I am using Python 3 with gobject introspection for Gtk. How can I have more than one toggle button linked together so they behave similar to tabs or radiobuttons - e.g. one is selected by default, and when another is clicked the previously active one is de-selected. I have tried using set_sensetive, but that greys out the widget that it is applied on.
How can I link a set of toggle buttons like radio buttons?
1.2
0
0
1,466
15,120,746
2013-02-27T19:32:00.000
1
0
0
0
python,button,gtk,radio-button,toggle
15,135,787
3
false
0
1
You listen to the toggle signals on the toggle button then call set_active() on the other ones. You need to block the toggled signals while calling set_active()so that you don't get into a loop.
2
3
0
I am using Python 3 with gobject introspection for Gtk. How can I have more than one toggle button linked together so they behave similar to tabs or radiobuttons - e.g. one is selected by default, and when another is clicked the previously active one is de-selected. I have tried using set_sensetive, but that greys out the widget that it is applied on.
How can I link a set of toggle buttons like radio buttons?
0.066568
0
0
1,466
15,121,405
2013-02-27T20:10:00.000
2
0
1
1
python,python-3.x
15,121,552
3
true
0
0
If you don't have time to wait for a performance test, you presumably just want guesses. So: There's probably no real advantage to multiprocessing over threading here. There is a disadvantage to multiprocessing in the overhead per task. You can get around that by tuning the batch size, but with threading, you don't have to. So, I'd use threading. However, I'd do it using concurrent.futures.ThreadPoolExecutor, so when you get a bit of time later, you can try the one-liner change to ProcessPoolExecutor and compare performance.
1
0
0
I am writing basically port scanner (not really, but it's close). Pinging machines one by one is just slow, so I definitely need some kind of parallel processing. Bottle neck is definitely network I/O, so I was thinking that threads would suffice (with python's GIL existing), they're easier to use. But would utilization of processes instead bring significant performance increase (15%+)? Sadly, I don't have time to try both approaches and pick better of them based on some measurements or something :/ Thanks :)
threads or processes
1.2
0
0
91
15,121,468
2013-02-27T20:13:00.000
2
1
0
1
python,python-2.6
15,121,639
2
false
0
0
If you really need to check this, Pavel Anossov's answer is the way to do it, and it's pretty much the same as your initial guess. But do you really need to check this? Why not just write a Python script that writes to stdout and/or stderr, and your cron job can just redirect to log files? Or, even better, use the logging module and let it write to syslog or whatever else is appropriate and also write to the terminal if there is one?
1
2
0
I have a Python script that normally runs out of cron. Sometimes, I want to run it myself in a (Unix) shell, and if so, have it write its output to the terminal instead of writing to a log file. What is the pythonic way of determining if a script is running out of cron or in an interactive shell (I mean bash, ksh, etc. not the python shell)? I could check for the existence of the TERM environment variable perhaps? That makes sense but seems deceptively simple... Could os.isatty somehow be used? I'm using Python 2.6 if it makes a difference. Thanks!
How to check if I'm running in a shell (have a terminal) in Python?
0.197375
0
0
206
15,121,519
2013-02-27T20:16:00.000
2
0
0
1
python,heroku,rabbitmq,celery,kombu
15,131,010
2
false
1
0
"One of the biggest differences between IronMQ and RabbitMQ/AMQP is that IronMQ is hosted and managed, so you don't have to host the server yourself and worry about uptime." Currently there are at least two hosted managed RabbitMQ-as-a-service options: Bigwig and CloudAMQP. Celery should work well with both.
1
9
0
I want to upload images to S3 server, but before uploading I want to generate thumbnails of 3 different sizes, and I want it to be done out of request/response cycle hence I am using celery. I have read the docs, here is what I have understood. Please correct me if I am wrong. Celery helps you manage your task queues outside the request response cycle. Then there is something called carrot/kombu - its a django middleware that packages tasks that get created via celery. Then the third layer PyAMQP that facilitates the communication of carrot to a broker. eg. RabbitMQ, AmazonSQS, ironMQ etc. Broker sits on a different server and does stuff for you. Now my understanding is - if multiple users upload image at the same time, celery will queue the resizing, and the resizing will actually happen at the ironMQ server, since it offers a cool addon on heroku. Now the doubts: But what after the image is resized, will ironMQ push it to the S3 server, or will it notify once the process is completed.. i am not clear about it. What is the difference between celery and kombu/carrot, could you explain vividly.
Differentiate celery, kombu, PyAMQP and RabbitMQ/ironMQ
0.197375
0
0
7,047
15,121,714
2013-02-27T20:26:00.000
3
0
1
1
python,notepad
31,030,969
4
false
0
0
okay. 1) i tried turning it off and on again. 2) i uninstalled and reinstalled python still no joy. and then! in windows explorer there's an open with option that sets the default program that windows is pointed toward if you click on the filename or enter it on the command line. change that from notepad or whatever it is if it's not python. change it to python. then presto. no problem-o.
2
5
0
I am having some trouble with opening a .py file. I have a program that calls this .py file (i.e. pathname/example.py file.txt), but instead of running the python program, it opens it in Notepad. How to I get it to run? The program itself takes in a file, and creates an output that is more readable. Edit: The operating system is Windows 7. And the file that is calling the python is a .bat file. Edit 2: It looks like I had to reinstall python for some reason... but it looks like it is finally working. Why reinstalling never comes to mind in the first place... And then I had to change how the file extention was opened. Thanks guys
How do I get a python program to run instead of opening in Notepad?
0.148885
0
0
20,810
15,121,714
2013-02-27T20:26:00.000
6
0
1
1
python,notepad
38,337,893
4
false
0
0
This happened because most probably you have set notepad as the default program to open a .py file. Go to default programs app in windows. Select choose app by extension. Here search for .py files. Change the option from notepad to python. This should solve your problem.
2
5
0
I am having some trouble with opening a .py file. I have a program that calls this .py file (i.e. pathname/example.py file.txt), but instead of running the python program, it opens it in Notepad. How to I get it to run? The program itself takes in a file, and creates an output that is more readable. Edit: The operating system is Windows 7. And the file that is calling the python is a .bat file. Edit 2: It looks like I had to reinstall python for some reason... but it looks like it is finally working. Why reinstalling never comes to mind in the first place... And then I had to change how the file extention was opened. Thanks guys
How do I get a python program to run instead of opening in Notepad?
1
0
0
20,810
15,122,375
2013-02-27T21:04:00.000
3
0
1
0
python,debugging,ipython,pdb
15,125,823
5
false
0
0
Does easy_install readline help?
2
21
0
I have IPython(0.13.1) and ipdb(0.7) installed, I inserted the line import ipdb;ipdb.set_trace() in my script and ran python my_script.py. Now I am in the ipdb prompt and there is some autocompletion (e.g. a bare tab) but it's not the same as the autocompletion I get when I enter IPython. In the ipdb prompt requests. then <tab> (after import) does not give me a list of attributes as in IPython. How do I get that same tab completion as in IPython with ipdb? Btw, when I run python -m ipdb my_script.py the tab completion works just as in IPython but the downside of this is that it starts the debugger from the first line instead of the line I've put import ipdb;ipdb.set_trace().
Get IPython tab completion for ipdb
0.119427
0
0
6,325
15,122,375
2013-02-27T21:04:00.000
3
0
1
0
python,debugging,ipython,pdb
38,924,218
5
false
0
0
I had the same problem on ubuntu 14.04 and got it fixed with: apt-get install libncurses5-dev pip install --upgrade readline
2
21
0
I have IPython(0.13.1) and ipdb(0.7) installed, I inserted the line import ipdb;ipdb.set_trace() in my script and ran python my_script.py. Now I am in the ipdb prompt and there is some autocompletion (e.g. a bare tab) but it's not the same as the autocompletion I get when I enter IPython. In the ipdb prompt requests. then <tab> (after import) does not give me a list of attributes as in IPython. How do I get that same tab completion as in IPython with ipdb? Btw, when I run python -m ipdb my_script.py the tab completion works just as in IPython but the downside of this is that it starts the debugger from the first line instead of the line I've put import ipdb;ipdb.set_trace().
Get IPython tab completion for ipdb
0.119427
0
0
6,325
15,125,583
2013-02-28T01:00:00.000
3
0
1
0
python,macos,matplotlib,pycharm
15,127,409
1
true
0
0
I got it fixed I just moved my modules into opt/bin... and PyCharm seems to be working..
1
1
0
I can't seem to get pycharm to recognize my matplotlib module.. It runs fine from IDLE, yet it cant import from the IDE, anyone have any ideas?
PyCharm + Matplotlib?
1.2
0
0
5,901
15,126,038
2013-02-28T01:47:00.000
0
0
1
0
python,printing,eol
15,126,080
2
false
0
0
You can't end a string with a \ character since you could be asking it to escape the " character. You need to use "\\"
1
1
0
I'm trying to print just a \ using python and it seems like \ is some kind of reserved character or something. The code print "\" returns SyntaxError: EOL while scanning string literal. Any suggestions?
EOL while scanning string literal when trying to print a \ in python
0
0
0
2,894
15,127,383
2013-02-28T04:14:00.000
1
0
1
0
python,audio
15,189,413
2
true
0
0
If you're willing to upload your data to an external server, try using the EchoNest API -- it has good Python bindings and lots of tools for music information retrieval tasks such as this.
1
1
0
I am trying to figure out what the best Python tools would be to add BPM information to a file. The yaafe and LibXtract libraries seem to have Python bindings, but seem to be sparsely documented. How can I go about doing this in Python?
Python: How do I give an bunch of audio files BPM information?
1.2
0
0
176
15,128,404
2013-02-28T05:51:00.000
0
0
0
0
wxpython
15,138,009
3
false
0
1
I'm not sure what you mean. Are you wanting images instead of the actual radio button itself? That is not supported. If you want an image in addition to the radio button, then just use a group of horizontal box sizers or one of the grid sizers. Add the image and then the radio button. And you're done!
2
0
0
I am making a GUI in wxpython. I want to place images next to radio buttons. How should i do that in wxpython?
Adding images next to radio buttons in wxpython
0
0
0
348
15,128,404
2013-02-28T05:51:00.000
1
0
0
0
wxpython
15,145,613
3
false
0
1
I suggest using wx.ToggleButton with bitmap labels if you are using 2.9, or one of the bitmap toggle button classes in wx.lib.buttons if you are still on 2.8. You can then implement the "radio button" functionality yourself by untoggling all other buttons in the group when one of them is toggled. Using the bitmap itself as the radio button will look nicer and will save space.
2
0
0
I am making a GUI in wxpython. I want to place images next to radio buttons. How should i do that in wxpython?
Adding images next to radio buttons in wxpython
0.066568
0
0
348
15,128,411
2013-02-28T05:52:00.000
1
0
1
1
python-3.x
15,133,546
1
false
0
0
python3 should start the correct version for you.
1
1
0
I downloaded and successfully installed Python 3.3 for OSX. After executing "python" in terminal it opened the python terminal window, stating: "Python 2.7.2 (default, June 20 2012...) Is there another update I need to do? Thanks!
Python version in terminal after download Python for OSX
0.197375
0
0
58
15,128,863
2013-02-28T06:24:00.000
0
0
0
0
javascript,jquery,python,mysql,server-sent-events
15,128,905
3
false
0
0
If polling is not an option, you can think about the better technique, WebSockets, if your server supports it (and your target browser!). One way or another, you need a connection opened by the client to the server, though.
2
2
0
I have a web server which I want to send data to the client when the server detects a change in the data base. I want the client to receive the data without polling. What is the best way to achieve this? (I read a bit about SSE - server sent events, but not sure this is the way to go) Thanks
java script server async events
0
0
1
172
15,128,863
2013-02-28T06:24:00.000
1
0
0
0
javascript,jquery,python,mysql,server-sent-events
18,561,947
3
false
0
0
Yes, Server-Sent Events is appropriate technology for listening to changes on the server. If you're only listening, then SSE is better (faster, lightweight, HTTP-compatible) than a 2-way WebSocket.
2
2
0
I have a web server which I want to send data to the client when the server detects a change in the data base. I want the client to receive the data without polling. What is the best way to achieve this? (I read a bit about SSE - server sent events, but not sure this is the way to go) Thanks
java script server async events
0.066568
0
1
172
15,131,690
2013-02-28T09:18:00.000
0
0
0
0
python,pyqt4,system-tray
15,135,837
1
false
0
1
There are .show() and .hide() methods and a .visible property that allows to show or hide a QSystemTrayIcon. Is that what you were looking for?
1
0
0
I have application with QtGui.QSystemTrayIcon and a Qmenu in it. Is there a way to disable and enable it. I want this to disable when my application is launching, so that user have no option to access the menu items.
Disabling System Tray icon in pyqt
0
0
0
798
15,134,201
2013-02-28T11:20:00.000
0
0
0
0
python-2.7,sass,compass-sass
15,987,894
2
false
0
0
You don't need compass with pyScss. Just run "python pyScss -mscss" to watch your workingdir for changes and compile the .scss (or .sass) to .css.
1
0
0
I am with Python 2.7, pyScss 1.15 and Compass 0.12.2, but Compass dosn't work, could someone give an advise how to make it work?
Compass not working with pyScss 1.1.5
0
0
0
312
15,136,264
2013-02-28T13:03:00.000
2
0
0
0
python,xml,svg,file-format,magic-numbers
15,136,487
3
false
0
0
You could try reading the beginning of the file as binary - if you can't find any magic numbers, you read it as a text file and match to any textual patterns you wish. Or vice-versa.
1
14
0
An SVG file is basically an XML file so I could use the string <?xml (or the hex representation: '3c 3f 78 6d 6c') as a magic number but there are a few opposing reason not to do that if for example there are extra white-spaces it could break this check. The other images I need/expect to check are all binaries and have magic numbers. How can I fast check if the file is an SVG format without using the extension eventually using Python?
How can I say a file is SVG without using a magic number?
0.132549
0
1
5,432
15,140,106
2013-02-28T16:04:00.000
1
0
1
0
python,pickle
15,140,422
2
false
0
0
I would evaluate the use of a key/value database like berkeleydb, kyoto cabinet or others. This will give you all the fancy things plus a better handling of disk space. In a filesystem with a block size of 4096B, one million files occupy ~4GB whatever is the size of your objects (as lower bound limit, if the objects are larger than 4096B the the size increase).
1
1
0
I have several million records I want to store, retrieve, delete pretty frequently. Each of these records has a "key", but the "value" is not easily translatable to a dictionary as it is an arbitrary Python object returned from a module method that I didn't write (I understand that a lot of hierarchical data structures like json work better as dictionaries, and not sure if json is the preferred database in any case). I am thinking to pickle each entry in a separate file. Is there a better way?
Python: storing/retrieving/updating a large number of arbitrary objects
0.099668
0
0
770
15,143,253
2013-02-28T18:45:00.000
6
0
1
0
python,numpy,scipy,pandas,scikit-learn
15,143,804
2
false
0
0
AFAIK, here is the dependency tree (numpy is a dependency of everything): numpy scipy scikit-learn pandas
1
3
1
Is there any documentation on the interdependencies and relationship between packages in the the scipy, numpy, pandas, scikit ecosystem?
Is there any documentation on the interdependencies between packages in the scipy, numpy, pandas, scikit ecosystem? Python
1
0
0
198
15,143,323
2013-02-28T18:48:00.000
2
0
0
0
wxpython,paint,gdi
15,146,608
2
true
0
1
It should work with a ScrolledPanel but if you are not going to have other widgets on the panel it is probably not the right answer since it depends on having a sizer to set the virtual size. Try using a wx.ScrolledWindow instead, and see its sample in the demo for some code. Basically you just need to set the virtual size of the window and it will take care of the scrollbars and scrolling for you. You will also need to call PrepareDC in your paint event handler so it will offset the drawing to match the scrolled viewport origin.
1
0
0
I currently have a wxPanel that I draw lines, text etc on to in response to paint events by using a device context from wx.PaintDC. However, my drawing can exceed the size of the panel and it continues off the visible screen. The only way to see more of the drawing is to expand the application window, which is impractical and still may not allow the full drawing to be seen in the case of very large drawings. Ideally, I want to be able to scroll the drawing so that the application window does not need to be resized and large drawings can be seen. Looking around, it seems that I may want to use a wxScrolledPanel instead of a wxPanel. However, i've had no success with using this - would using a wxScrolledPanel only work when using controls (e.g. buttons, text fields) rather than painting on the device context? What is the appropriate way to scroll a panel that has been drawn on?
Scrolling a painted frame in wxPython
1.2
0
0
1,073
15,145,159
2013-02-28T20:36:00.000
7
0
1
0
python,python-2.7,python-3.x
15,145,165
1
false
0
0
When you do from module import name, Python still has to run module, so there is no difference performance-wise. Generally, if you are only using one thing from a module, the using from x import y is fine, but otherwise, using import x and then x.y results in a lower chance of conflicting names. The reason for this is that Python doesn't treat functions and classes specially. When you import from a module, all you are doing is taking objects from that module and using them. This is useful, as it makes modules (as well as classes and functions) extremely flexible, but it does mean that Python has to run the whole script for a module before it can import from it (naturally, module writers can work around this by using the if name == "main": idiom to insert code that shouldn't be run on import).
1
7
0
As a newbie, I've grown fond of importing modules almost by default when I start writing something just because I call on certain functions within them quite a bit (modules like random, time, os, and sys). However, does this impact performance at all? If I only want a specific function in the module, am I better served by asking for it explicitly or should I not care?
Importing Modules - How Much is Too Much?
1
0
0
4,105
15,147,189
2013-02-28T22:50:00.000
0
0
1
0
python,jython
15,147,279
2
false
0
0
self.attr refers to the instance's attribute, and falls back to the class if there is no attribute of the specified name defined on the instance. Usually this is reasonable behavior. Use self.__class__.attr if you specifically want to get the class's attribute. It is rare that anyone will override a method on an instance, this requiring the construction of a special "instance method" object, so self.method() is generally correct (even for methods declared using @classmethod or @staticmethod).
2
0
0
With Class attributes and methods, to reference them within the class, should we use Classname. or self.
Class attr and methods
0
0
0
59
15,147,189
2013-02-28T22:50:00.000
0
0
1
0
python,jython
15,147,199
2
false
0
0
I think both ways work, but it is a bit wierd compared to Java.
2
0
0
With Class attributes and methods, to reference them within the class, should we use Classname. or self.
Class attr and methods
0
0
0
59
15,148,496
2013-03-01T00:45:00.000
4
0
1
0
python,function,pass-by-reference,pass-by-value
15,150,378
13
false
0
0
In Python, every value is a reference (a pointer to an object), just like non-primitives in Java. Also, like Java, Python only has pass by value. So, semantically, they are pretty much the same. Since you mention Java in your question, I would like to see how you achieve what you want in Java. If you can show it in Java, I can show you how to do it exactly equivalently in Python.
3
123
0
How can I pass an integer by reference in Python? I want to modify the value of a variable that I am passing to the function. I have read that everything in Python is pass by value, but there has to be an easy trick. For example, in Java you could pass the reference types of Integer, Long, etc. How can I pass an integer into a function by reference? What are the best practices?
Passing an integer by reference in Python
0.061461
0
0
146,201
15,148,496
2013-03-01T00:45:00.000
9
0
1
0
python,function,pass-by-reference,pass-by-value
15,148,584
13
false
0
0
Really, the best practice is to step back and ask whether you really need to do this. Why do you want to modify the value of a variable that you're passing in to the function? If you need to do it for a quick hack, the quickest way is to pass a list holding the integer, and stick a [0] around every use of it, as mgilson's answer demonstrates. If you need to do it for something more significant, write a class that has an int as an attribute, so you can just set it. Of course this forces you to come up with a good name for the class, and for the attribute—if you can't think of anything, go back and read the sentence again a few times, and then use the list. More generally, if you're trying to port some Java idiom directly to Python, you're doing it wrong. Even when there is something directly corresponding (as with static/@staticmethod), you still don't want to use it in most Python programs just because you'd use it in Java.
3
123
0
How can I pass an integer by reference in Python? I want to modify the value of a variable that I am passing to the function. I have read that everything in Python is pass by value, but there has to be an easy trick. For example, in Java you could pass the reference types of Integer, Long, etc. How can I pass an integer into a function by reference? What are the best practices?
Passing an integer by reference in Python
1
0
0
146,201
15,148,496
2013-03-01T00:45:00.000
0
0
1
0
python,function,pass-by-reference,pass-by-value
15,148,515
13
false
0
0
In Python, everything is passed by value, but if you want to modify some state, you can change the value of an integer inside a list or object that's passed to a method.
3
123
0
How can I pass an integer by reference in Python? I want to modify the value of a variable that I am passing to the function. I have read that everything in Python is pass by value, but there has to be an easy trick. For example, in Java you could pass the reference types of Integer, Long, etc. How can I pass an integer into a function by reference? What are the best practices?
Passing an integer by reference in Python
0
0
0
146,201
15,148,832
2013-03-01T01:22:00.000
3
0
1
0
python,makefile,configure,compiler-flags
15,148,924
1
true
0
0
configure configures the build from scratch (with minimal support for caching certain results). Therefore, you need to supply all the same flags as before. When changing configure flags, it is also recommended to do a make distclean to ensure that everything is rebuilt. This is especially important with --with-pydebug since the basic PyObject layout will change.
1
1
0
I installed Python-2.7.3 with configure --enable-shared, make and install. It so happens that now, I need to reconfigure to include the --with-pydebug option. While running configure again, do I need to include all the flags I had before? (--enable-shared) or is it okay to configure again with just the additional flags?
Reconfiguring python
1.2
0
0
541
15,152,785
2013-03-01T07:34:00.000
1
1
0
0
python,html,css,server-side
15,152,990
4
true
0
0
Give each user a customized installer that has a unique key in it. When it runs, it contacts a server (with the key) and requests the actual program. Server-side, you check if the key is valid and if so, serve the program customized with the key, and mark the key as used. The installer saves the program somewhere the user can access it, and creates a hidden file that contains the key somewhere deep in the bowels of the computer, where the "average user" won't think of looking. When the program is run, the first thing it does is check if the hidden file exists and if it contains the correct key, and refuses to run if not. (I am assuming that unzipping an executable and reading source code is beyond the ability of the "average user" (read: "grandma"), so using py2exe is ok.)
1
0
0
What I want to do is protect a Python program from being stolen by people with no computer knowledge. I accept the inevitability of the program being pirated, all I want to do is protect it from average users. I have come up with two ideas. 1.)Set a time restriction by checking online for the date and time. I.E. 10 days from downloaded time. 2.)Checking the IP or Name of the computer that downloaded it and make the program only runs on that computer. (to prevent friends from simply sharing the file). The problem with both of these is that I'll need to create a .py file "on the fly" and then use something like pytoexe to make it into an .exe so that the user doesn't need to have Python installed. The problem with the second is that to my understanding ip's change and getting the computer name is a security risk and might scare away users. So to sum it up, here are my two questions: 1.) Is there a good way in python to only allow the program to run on that single computer? 2.) What is the best way to implement a "on the fly" creation of the exe? (I was going to host the website on my computer and learn php(?)/servers. I have moderate c/c++ and basic html/css, java, and python experience. Thank you for your time!
How to protect my Python program
1.2
0
0
2,860
15,154,690
2013-03-01T09:44:00.000
3
0
0
0
python,svm,scikit-learn
15,155,284
1
true
0
0
Try using sklearn.svm.LinearSVC. This also has a linear kernel, but the underlying implementation is liblinear, which is known to be faster. With that in mind, your data set isn't very small, so even this classifier might take a while. Edit after first comment: In that I think you have several options, neither of which is perfect: The non-solution option: call it a day and hope that training of svm.sparse.SVC has finished tomorrow morning. If you can, buy a better computer. The cheat option: give up on probabilities. You haven't told us what your problem is, so they may not be essential. The back-against-the-wall option: if you absolutely need probabilities and things must run faster, use a different classifier. Options include sklearn.naive_bayes.*, sklearn.linear_model.LogisticRegression. etc. These will be much faster to train, but the price you pay is somewhat reduced accuracy.
1
2
1
I am trying to train svm.sparse.SVC in scikit-learn. Right now the dimension of the feature vectors is around 0.7 million and the number of feature vectors being used for training is 20k. I am providing input using csr sparse matrices as only around 500 dimensions are non-zero in each feature vector. The code is running since the past 5 hours. Is there any estimate on how much time it will take? Is there any way to do the training faster? Kernel is linear.
svm.sparse.SVC taking a lot of time to get trained
1.2
0
0
1,802
15,156,264
2013-03-01T11:08:00.000
2
0
0
0
python,string,garbage-collection
15,156,807
2
false
1
0
You say: I saw that every new string (with sys.getrefcount) have, at least, 2 references But did you carefully read the description of getrefcount() ? : sys.getrefcount() object) Return the reference count of the object. The count returned is generally one higher than you might expect, because it includes the (temporary) reference as an argument to getrefcount(). . You should explain more about your prohgram. What is the size of the HTML strings it holds ? How are they obtained ? Are you sure to close all file's handler , all socket connexions, ....?
1
2
0
I'm having a problem in a large-runtime script. This script is a multithreaded environment, to perform crawling tasks. In large executions, script's memory consumption become huge, and after profiling memory with guppy hpy, I saw that most of the problem is coming by strings. I'm not storing so many strings: just get content of htmls into memory, to store them in db. After it, string is not used anymore (the variable containing it is assigned to the next string). The problem arised because I saw that every new string (with sys.getrefcount) have, at least, 2 references (1 from my var, and 1 internal). It seems that reassigning another value to my var does not remove the internal reference, so the string stills in memory. What can I do to be sure that strings are garbage collected? Thank you in advance EDIT: 1- I'm using Django ORM 2- I'm obtaining all of that strings from 2 sources: 2.1- Directly from socket (urllib2.urlopen(url).read()) 2.2- Parsing that responses, and extrating new URIs from every html, and feeding system SOLVED Finally, I got the key. The script is part of Django environment, and seems that Django's underground is doing some cache or something similar. I turned off debugging, and all started to work as expected (reused indentifiers seems to delete references to old objects, and that objects become collected by gc). For anyone who uses some kind of framework layer over python, be aware of configuration: seems that some debug configurations with intensive process can lead to memory leaks
Python: how to garbage collect strings
0.197375
0
0
1,633
15,156,945
2013-03-01T11:44:00.000
0
0
0
0
python,cassandra,pycassa
15,175,729
1
false
1
0
I'm working with a system that has both the features you are asking for. We are using HBase (not Cassandra) and we write the URL + date in the key for every counter. Then you can easily get the two reports you are looking for. To get all page views for one URL, scan for keys beginning with and then add the counter values you find with that scan. To get pageviews per day for one URL, scan for the key beginning with + date.
1
0
0
I read and googled a lot but could not find a way to slice n dice a counter data based on a condition. Is there a way in Cassandra to do this? If yes, pl ease help me with it. For example: If I am using a counter to store the total page views, is there any way I can get the count of page views of a particular page url OR get all page views on a particular date? Thanks in advance!
Is slicing and dicing of distributed counter data in cassandra using pycassa possible?
0
0
0
148
15,157,756
2013-03-01T12:25:00.000
-1
0
0
0
python,opencv,image-processing
29,629,579
2
false
0
0
I have the same problem.I think the monocular camera may need a object known the 3D coordinate.That may help .
1
1
1
I'm working with OpenCV and python and would like to obtain the real world translation between two cameras. I'm using a single calibrated camera which is moving. I've already worked through feature matching, calculation of F via RANSAC, and calculation of E. To get the translation between cameras, I think I can use: w, u, vt = cv2.SVDecomp and then my t vector could be: t = u[:,2] An example output is: [[ -1.16399893 9.78967574 1.40910252] [ -7.79802049 -0.26646268 -13.85252956] [ -2.67690676 13.89538682 0.19209676]] t vector: [ 0.81586158 0.0750399 -0.57335756] I think I understand how the translation is not in real world scale so I need to provide that scale somehow if I want a real world translation. If I do know the distance between the cameras, can I just apply it directly to my t vector by multiplication? I think I'm missing something here...
Where do I add a scale factor to the Essential Matrix to produce a real world translation value
-0.099668
0
0
726
15,159,027
2013-03-01T13:33:00.000
0
1
0
0
python,cron,scheduled-tasks
15,159,989
2
false
0
0
Why not run the cron job each friday, but add code to write the last date ran in a file. Check to see if two weeks has passed, rewrite the file, and run the rest of the cron job
1
2
0
I could use cron, but I can't figure out if there's a way to set the right schedule. I can also check the date in Python, running the script via cron everyday, but checking the right date inside my (Python) script (which I assume has more powerful conditions). I thought on limiting one run on fridays between 1 and 7, and the other one on fridays between 15 and 21. But this option would have a problem on months like 3/2013 which have 5 fridays.
How do I run a script on friday, once every two weeks?
0
0
0
2,630
15,161,051
2013-03-01T15:19:00.000
-1
0
0
1
python,django,shell
15,164,238
2
true
1
0
I ended up monkeypatching IPython.frontend.terminal.embed.InteractiveShellEmbed.__call__ to add the definitions I wanted. (I know many people are opposed to monkeypatching but I find it to be a good solution in this case.)
1
2
0
Every time I start a shell using python manage.py shell, I want a few lines to be executed automatically. (In my case it would be a few import lines in the style of import django, my_app.) How do I do this?
Django: Automatically executing statements in `manage.py shell`
1.2
0
0
158
15,165,070
2013-03-01T19:09:00.000
3
0
1
1
python
15,165,112
1
true
0
0
This has nothing to do with py2exe, and everything to do with the machine's setup. You don't have python on your path. You can test this by just running python by itself to open the interactive interpreter. If cmd can't find python, it can't run it. Here are some ways around this: Explicitly use the full path to Python—e.g., if it's C:\Python27\bin\Python.exe, type that instead of just python. Temporarily edit your PATH environment variable in the cmd window. With the above example, this would be set PATH=%PATH%;C:\Python27\bin. You will have to do this again every time you reboot, open a new cmd window, etc. Permanently edit your PATH environment variable. This is done in the Advanced System Settings controls, which I believe are still accessible through the Properties on the context menu for My Computer in Windows 7. Uninstall and reinstall Python, and this time allow it to put itself on your path. Ask for further help at superuser or some other site that's focused on system configuration problems rather than programming problems.
1
0
0
i wrote a python script and installed py2exe 0.6.9 (win32) to a 32bit-Windows7 machine with Python 2.7. I could successfully run "python setup.py py2exe" via cmd. Now I installed py2exe 0.6.9 (win64) to a 2nd PC (Win7, 64bit, Python2.7) and tried the same to exactly the same script: But "python setup.py py2exe" returned this message (hope I translated it correctly into english): "The command 'python' is either written wrong or couldn't be found." Why does this happen? How can I solve this?
py2exe cmd failure
1.2
0
0
125
15,169,015
2013-03-02T00:08:00.000
2
0
1
1
python,llvm,llvm-py
15,175,018
2
false
0
0
You can call external C functions from LLVM JIT-ed code. What else do you need? These external functions will be found in the executing process, meaning that if you link Python into your VM you can call Python's C API functions. The "VM" is probably less magic than you think it is :-) In the end, it's just machine code that gets emitted at runtime into a buffer and executed from there. To the extent that this code has access to other symbols in the process in which it's running, it can do everything any other code in that process can do.
1
6
0
I write a language lexer/parser/compiler in python, that should run in the LLVM JIT-VM (using llvm-py) later. The first two steps are quite straightforward for now, but (even if I didn't start the compile-task yet) I see a problem, when my code wants to call Python-Code (in general), or interact with the Python lexer/parser/compiler (in special) respectively. My main concern is, that the code should be able to dynamically load additional code into the VM at runtime and thus it must trigger the whole lexer/parser/compiler-chain in Python from within the VM. First of all: Is this even possible, or is the VM "unmutable" once it is started? If it is I currently see 3 possible solutions (I am open for other suggestions) "Break out" of the VM and make it possible to call Python functions of the main process directly (maybe by registering it as a LLVM-function, that redirects to the main process somehow). I didn't found anything about this and anyway I am not sure, if this is a good idea (security and such). Compile the runtime (statically or dynamically at runtime) into LLVM-Assembly/-IR. This requires, that the IR-code is able to modify the VM it runs in Compile the runtime (statically) into a library and load it directly into the VM. Again it must be able to add functions (etc) to the VM it runs in.
Call Python code from LLVM JIT
0.197375
0
0
1,071
15,170,013
2013-03-02T02:28:00.000
1
0
0
0
python,django,django-dev-server
15,172,677
1
true
1
0
This is not possible without modifying the source code of Django (which is not recommended). The only validation Django does on start-up is to check if the syntax of your model code is okay or not. It should not take more than 2-3 seconds. So, there are few other initialization are being done during startup which are also taking time. During development, you do not need to restart the server every time you modify the code- especially if you are not touching the definition of the models at all. The Django dev server automatically reloads itself if it detects any change in your code. So, leave it running while you develop and hopefully your experience will improve.
1
1
0
Stage of models validation is most longest in Django dev-server startup. And in my case it mostly waste of time, since my models сhanging infrequently. Is there way to turn off this?
Turning off model validation on Django dev-server
1.2
0
0
827
15,171,157
2013-03-02T05:36:00.000
0
0
1
1
python,cmd
39,730,308
8
false
0
0
Okay, as you said your Python install directory is C:\Python27, open my computer, then open c: drive, if you don't see "Python27" named folder there then try to search it using search option, (in my case i found it in old.window folder, don't know how it moved there) cut and past it in c drive along with folders like, program files, user etc... , now open cmd and type python and hit enter to check if it is working now,
6
11
0
This is a really annoying problem. I've prowled the web for solutions, but all I found was tips about changing the PATH variable, which I did, of course. My Python install directory is C:\Python27. It' a 32 bit version. Whenever I type python in the command prompt, it says that it isn't recognised as an internal or external command. Currently, my PATH variable is set to C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts. Anyone has any ideas? I run Windows 7 by the way (64 bit). I'm pretty desperate. Heck, if nothing works I guess I'll try dual-booting Linux and Windows 7...
python is not recognised as an internal or external command
0
0
0
50,485
15,171,157
2013-03-02T05:36:00.000
1
0
1
1
python,cmd
15,171,325
8
false
0
0
After adding the python folder to the system PATH variable, you should reboot your computer. Another simple solution is: create a shortcut of the python.exe executable (probably it is in C:\Python27\python.exe, or similar) in a place like C:\Windows\system32 (that is, a place that already is listed in the PATH variable). The name of your shortcut should be python (maybe python.exe should work too). I mean, it can't be python - shortcut or similar, for your purposes. To see the contents of the PATH variable, go to the cmd and enter set PATH.
6
11
0
This is a really annoying problem. I've prowled the web for solutions, but all I found was tips about changing the PATH variable, which I did, of course. My Python install directory is C:\Python27. It' a 32 bit version. Whenever I type python in the command prompt, it says that it isn't recognised as an internal or external command. Currently, my PATH variable is set to C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts. Anyone has any ideas? I run Windows 7 by the way (64 bit). I'm pretty desperate. Heck, if nothing works I guess I'll try dual-booting Linux and Windows 7...
python is not recognised as an internal or external command
0.024995
0
0
50,485
15,171,157
2013-03-02T05:36:00.000
0
0
1
1
python,cmd
41,311,109
8
false
0
0
This is only a partial answer, but I found (repeatedly) that I'd have similar issues when I would use the gui installer and not go through the custom setup. Using the custom setup option, then using the same settings, the "install for all users" (that then installs to C://python.version/blah instead of the user based default structure) WOULD allow the installer to setup PATH correctly.
6
11
0
This is a really annoying problem. I've prowled the web for solutions, but all I found was tips about changing the PATH variable, which I did, of course. My Python install directory is C:\Python27. It' a 32 bit version. Whenever I type python in the command prompt, it says that it isn't recognised as an internal or external command. Currently, my PATH variable is set to C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts. Anyone has any ideas? I run Windows 7 by the way (64 bit). I'm pretty desperate. Heck, if nothing works I guess I'll try dual-booting Linux and Windows 7...
python is not recognised as an internal or external command
0
0
0
50,485
15,171,157
2013-03-02T05:36:00.000
4
0
1
1
python,cmd
15,171,259
8
false
0
0
Quick fix: May not be the most elegant or long term fix but if you are really frustrated and just want to get it to run, just copy paste the python.exe file to your current directory. This worked for me.
6
11
0
This is a really annoying problem. I've prowled the web for solutions, but all I found was tips about changing the PATH variable, which I did, of course. My Python install directory is C:\Python27. It' a 32 bit version. Whenever I type python in the command prompt, it says that it isn't recognised as an internal or external command. Currently, my PATH variable is set to C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts. Anyone has any ideas? I run Windows 7 by the way (64 bit). I'm pretty desperate. Heck, if nothing works I guess I'll try dual-booting Linux and Windows 7...
python is not recognised as an internal or external command
0.099668
0
0
50,485
15,171,157
2013-03-02T05:36:00.000
1
0
1
1
python,cmd
15,171,248
8
false
0
0
After changing the PATH variable in windows, you need to reboot your system before it takes effect. Edit: As stated by @tdelaney, only a restart of cmd.exe should be required. This is true atleast for Windows 7 64bit.
6
11
0
This is a really annoying problem. I've prowled the web for solutions, but all I found was tips about changing the PATH variable, which I did, of course. My Python install directory is C:\Python27. It' a 32 bit version. Whenever I type python in the command prompt, it says that it isn't recognised as an internal or external command. Currently, my PATH variable is set to C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts. Anyone has any ideas? I run Windows 7 by the way (64 bit). I'm pretty desperate. Heck, if nothing works I guess I'll try dual-booting Linux and Windows 7...
python is not recognised as an internal or external command
0.024995
0
0
50,485
15,171,157
2013-03-02T05:36:00.000
0
0
1
1
python,cmd
35,899,777
8
false
0
0
When installing, there is a checkbox that is by default not selected, but it asks to add python to the environment variable. Re-install and check that box. I'd rather the installer do it than struggle in the weeds myself.
6
11
0
This is a really annoying problem. I've prowled the web for solutions, but all I found was tips about changing the PATH variable, which I did, of course. My Python install directory is C:\Python27. It' a 32 bit version. Whenever I type python in the command prompt, it says that it isn't recognised as an internal or external command. Currently, my PATH variable is set to C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts. Anyone has any ideas? I run Windows 7 by the way (64 bit). I'm pretty desperate. Heck, if nothing works I guess I'll try dual-booting Linux and Windows 7...
python is not recognised as an internal or external command
0
0
0
50,485
15,171,247
2013-03-02T05:50:00.000
0
0
1
0
python,multithreading,locking
15,171,377
1
false
0
0
It's mostly an issue for course grained locks (you do a lot of work while holding the lock). A thread will hang if it attempts to acquire a Lock more than once. The risk grows as a system gets complex and many functions acquire the lock. Suppose functions f1, f2, ... fn all acquire the lock. If f1 calls f2, it will hang. If f1 calls some other function and that function calls f2, it will hang. You end up implementing two sets of functions - ones that get the lock and ones that implement the functionality. "outies" and "innies". RLocks let you be more relaxed about that.
1
0
0
Can anyone give me the code example when i need to use Rlock instead of simple lock I am not able to find the use case when i need Rlock I have read this but could not get the actual use of that Normal Lock objects cannot be acquired more than once, even by the same thread. This can introduce undesirable side-effects if a lock is accessed by more than one function in the same call chain.
Not able to understand the python when we need Rlocking the thread
0
0
0
57
15,171,378
2013-03-02T06:07:00.000
1
0
0
0
python,image,drag-and-drop,pygame
15,173,810
2
false
0
1
What methods are you using to draw the images? It's hard to answer this question without that. If you aren't already doing this, you could use a class to hold data about your image, such as position and geometry.
2
0
0
I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it?
How to get image position in Pygame
0.099668
0
0
1,791
15,171,378
2013-03-02T06:07:00.000
1
0
0
0
python,image,drag-and-drop,pygame
15,177,879
2
false
0
1
If you derive your classes from pygame.sprite.Sprite , you can get the position by guy.rect. Depending on if you want center, or toplef, or the full rect: guy.rect.topleft or guy.rect.center or guy.rect
2
0
0
I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it?
How to get image position in Pygame
0.099668
0
0
1,791
15,172,826
2013-03-02T09:21:00.000
0
0
0
0
python,css,heroku,responsive-design,flask
15,181,474
1
false
1
0
Bug found. It was a very, very obscure rendering issue with the text-indent css attribute that only seemed to affect the iPhone 5. Additionally, if you ever need to debug Google Chrome for iPhone, clearing the cache won't do anything if you don't delete the app from the multitasking menu too (the bar that comes up when you double tap the home button). That literally took me half an hour to figure out.
1
0
0
First question posted to Stack Overflow but have spent many hours reading answers here :). I'm creating a Heroku Python app and am using responsive design media queries in my css. I deploy my app to Heroku and visit myherokuapp.herokuapp.com. Website looks fine on laptop browser...responsive design elements working as well. Visiting the same url on my iPhone, however, seems to show a page where one of my css files (the media queries) is loading but the other (the main css file) is not. Does Heroku cache css files? I read somewhere that you have to host static files elsewhere if you have a Django app, but not sure if that's applicable to me. I'm also using the Flask function <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">. Does that have anything to do with it? Edit: Does anyone know how to run the equivalent of the Firefox/Google Inspector on mobile? That would really help me figure out what files are there and what aren't.
Heroku Python App - CSS Not Loading On IPhone Only
0
0
0
381
15,174,730
2013-03-02T12:54:00.000
0
0
1
0
python,import,module,package
15,179,690
3
false
0
0
To answer your second question, if your two modules named Class1.py are in fact the same, then you should not copy it to both packages. Place it in a package which will contain only code which is common to both, and then import it. It is absolutely not necessary to copy the file and try to maintain each change in both copies.
1
3
0
I'm currently coding an app which is basically structured that way : main.py + Package1 +--- Class1.py +--- Apps + Package2 +--- Class1.py +--- Apps So I have two questions : First, inside both packages, there are modules needed by all Apps, eg : re. Is there a way I can import a module for the whole package at once, instead of importing it in every file that needs it ? And, as you can see, Class1 is used in both packages. Is there a good way to share it between both packages to avoid code duplication ?
Python : import module once for a whole package
0
0
0
6,074
15,177,002
2013-03-02T16:55:00.000
0
0
0
0
python,django
15,181,386
2
false
1
0
So, I can really only give you some general direction, as I don't know the particulars, but basically you could do something like this: First, I would add an override to the save_model() method of your admin class. This is where you can check to see if your object has a primary key yet. If not, you can set a flag to create the event (not sure if you need to also associate your event to the notification via a foreign key. If you don't need to have an association between your Event and the notification, you could skip setting a flag and just create the notification object whenever you want. Second, create a view that returns JSON for your events. I'm not sure how you would need to filter these objects. Is it only for logged in users, etc, but you would only want to return ones that have not been previously viewed. Third, call the view via ajax on an interval, passing in whatever criteria you need to filter the results and record the notification has been viewed. Hope that gets you going.
1
0
0
We're currently developing a system for a certain organization. One of the requirement is to inform users whenever the admin creates an event. All the site users should be notified not through e-mail but something similar to Facebook notification. How do I implement such feature in Django without using Django-notifications, Django-activity streams, etc. We're newbies to Django and we wanted to implement such feature as simple as it can be. I hope you can help us with this matter. Thank you all!
How do I inform a user if an event has been created by the admin in Django?
0
0
0
542
15,177,490
2013-03-02T17:45:00.000
0
0
0
0
python,opencv,machine-learning,scikit-learn,classification
15,181,340
3
false
0
0
If your images that belong to the same class are results of a transformations to some starting image you can increase your training size by making transofrmations to your labeled examples. For example if you are doing character recognition, afine or elastic transforamtions can be used. P.Simard in Best Practices for Convolutional Neural Networks Applied to Visual Document Analysis describes it in more detail. In the paper he uses Neural Networks but the same applies for SVM.
1
1
1
I have to make comparison between 155 image feature vectors. Every feature vector has got 5 features. My image are divided in 10 classes. Unfortunately i need at least 100 images for class for using support vector machine , There is any alternative?
Alternative to support vector machine classifier in python?
0
0
0
1,430
15,178,533
2013-03-02T19:35:00.000
0
0
0
0
python,django,emoji,tastypie
15,184,591
2
false
1
0
What if you save the JSON dump to a text file and open it with a UTF8 text editor? Will the emoji re-appear? I suspect that, when displaying the JSON in the browser, the browser falls back to Latin-1 encoding, thus ending up with question marks. There might be a setting in your browser to set the encoding. Check the "Content-Type" header that comes from your server. Does it say application/json; encoding=utf-8?
1
0
0
I'm using django and tastypie for my api. the db is MySQL. After a few days of fiddling around i managed to store emoji icons in the db using utf8mb4 character set. When querying the db directly from the console (on a mac), i see the emoji fine, but when pulling them from the api (for example using the browser), the json shows question marks. This leads me to believe the issue is not with the db but with django/tastypie db connection. How do i go about it?
Django Tastypie - serving emoji that are stored in db
0
0
0
579