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
18,538,170
2013-08-30T17:09:00.000
0
0
0
0
java,c++,python,interface,integration
18,609,443
3
true
1
1
gcj (gcc compiler for java) supports java 1.5 syntax (1.4 is working better on it) and therefore some Java programs may be compiled to native code. gcjh (or javah) can produce headers for java libraries, so you can write C extensions for python. Of course some libraries could not be compiled with gcj (like Apache Commons Logging) because of using com.sun packages. Did not updated from 2009. There is another Java to native compiler, commercial Excelsior Jet (it's another JavaVM, it supports Java 1.6 and soon Java 1.7). They said linux-64bit version of their product will be available in 2013-Q4. But I didn't try it well, I don't know, are headers for compiled library can be produced. There is a lot packages at pypi, like JCC (from PyLucene creator) or Py4J that can use Oracle JavaVM through JNI or sockets.
2
1
0
I implemented most of my projects in C++ and python. However, we recently got a new database interface that I could only use Java to retrieve data. I want to stay with my Python/C++ tools but I am wondering if there is a good solution to integrate Java to my Python application. I heard about Jython, but it is a different python implementation and I am concerned some of my C++ tools will not work well with it. Jpype seems simple but it hasn't been updated since 2011, so a little concerned with the compatiablity with the current python/java. Is there a good solution to this? all opinions are welcomed.
Python Integration with Java / C
1.2
0
0
251
18,538,170
2013-08-30T17:09:00.000
0
0
0
0
java,c++,python,interface,integration
18,538,315
3
false
1
1
One way to do this is to write web services. A web service can accept an HTTP request, marshal it into a data request, pass that to a Java class that get the data out, map the quert results into a response of some kind, and send it back. Any client that can send an HTTP request, accept the response and unmarshal it can interact with that service. They need not know that it's implemented in Java. You pay the price of an extra network roundtrip to get the benefit of language interoperability.
2
1
0
I implemented most of my projects in C++ and python. However, we recently got a new database interface that I could only use Java to retrieve data. I want to stay with my Python/C++ tools but I am wondering if there is a good solution to integrate Java to my Python application. I heard about Jython, but it is a different python implementation and I am concerned some of my C++ tools will not work well with it. Jpype seems simple but it hasn't been updated since 2011, so a little concerned with the compatiablity with the current python/java. Is there a good solution to this? all opinions are welcomed.
Python Integration with Java / C
0
0
0
251
18,540,987
2013-08-30T20:28:00.000
0
1
0
0
python,sqlite,search,flask,typeahead
18,541,075
2
false
1
0
You are looking for "partial matches". I would load all possible names into an array, and sort them. Then I would separately create a (26x26) lookup array that shows the index of the first element in the list of names that corresponds to a combination of the first two letters; you might also have a dict (rather than an exhaustive list) of all possible three letter combinations, which would speed up your search (because it limits it to a much smaller slice of the array). In other words - you would not really be searching at all (for the two and three letter combo's); you would be returning a slice of the array. Once you have a match of more than three, you probably can search the slice (not worth creating tables beyond three characters).
1
0
0
I am developing my first Flask application (with sqlite as a database). It takes a single name from user as a query, and displays information about this name as a response. All working well, but I want to implement typeahead.js to make better user experience. Typeahead.js sends requests to server as user types, and suggests possible names in dropdown. Right now I'm searching the database with select * from table_name where name like 'QUERY%'. But this of course is not so fast as I would like it to be - it works, but with noticable input lag (less or around a second I suppose). In order to speed up things I looked at some memory caching options (like Redis or memcached), but they are key-value store, therefore I think do not fit my needs. I think possible option would be to make list of names (["Jane", "John", "Jack"], around 200k names total), load it into ram and do searches there. But how do I load something in memory in Flask? Anyway, my question is: What is the best way to make such search (by first few letters) faster (in Python/Flask)?
Fastest text search in Python
0
0
0
1,008
18,541,427
2013-08-30T21:02:00.000
0
0
1
1
python,linux,file-extension,file-type
18,541,480
2
false
0
0
Ultimately, there is no absolute way of knowing. For several reasons: Some file format use simple identifiers, but others don't. For those that don't, the only way is analyzing the behavior of a program able to able the format. If the program can successfully open the file, then it belongs to it. But if not, the file could belong to hundreds of formats you don't have a program to open with. I'm afraid you will need to be content with a partial answer like the ones you already have.
1
0
0
I want to check if a given file's extension is correct or not. For example, someone give me a file with an extension .zip but actually it may be an executable. Using mimetypes I could not determine a file's real type. As far as I see, mimetypes needs an extension. I can map the output of unix file command with some extensions. Even if you change the extension, you cannot deceive file command. However, this solution needs a subprocess. I thought, there may be a more pythonic solution of this problem. Does anyone know?
File extension validation with python
0
0
0
1,133
18,543,447
2013-08-31T01:03:00.000
1
0
1
1
python,python-2.7,python-3.x,subprocess,fork
18,543,541
1
false
0
0
Take a look at multiprocess.Process
1
0
0
I have a function dosomething() inside which am doing a os.chroot(). A process running chroot() cannot get out of chroot jail. So i want this dosomething() to run as a child process in the main program and i need to wait till the child process gets over . What is the simplest way to do this ?
How to run a function as a child process in python?
0.197375
0
0
160
18,546,053
2013-08-31T08:14:00.000
0
0
1
0
python,regex
61,012,316
4
false
0
0
The solution I'm currently using to accept http / https only, username:password optionally and host as an IP or domain name is the following: ^(?:https?:\/\/)(?:(\w+)(?::(\w*))@)?([a-zA-Z0-9][a-zA-Z0-9-_]{0,61}[a-zA-Z0-9]{0,1}\.([a-zA-Z]{1,6}|[a-zA-Z0-9-]{1,30}\.[a-zA-Z]{2,3})|((?:\d{1,3})(?:\.\d{1,3}){3}))(?::(\d{1,5}))$ I hope it helps
1
0
0
I need to match both formats like: user:[email protected]:3847 and 111.23.123.78:2938, how do you do that(match valid proxy only)? And by the way, is there such module(validate proxy formats) in python already?
How to perfectly match a proxy with regex?
0
0
1
3,078
18,546,103
2013-08-31T08:21:00.000
-1
0
1
0
python,python-3.x
18,546,144
2
false
0
0
Entering multiple lines: use three quotation marks thusly: """hello this is multiple lines""" count lines... len(text.split()) or len(text.split('\n')) etc
1
1
0
I have to write a code which recognizes a text line by line and reverses each line in the output, I dont know how to enter a text with multiple lines (as "input()" function will take the input after the first "Enter" but I still want to enter more lines? second I don't know how to count the input line by line? whould "split(/n) be an option?
How to show EOF in Python? / how to identify lines?
-0.099668
0
0
105
18,546,876
2013-08-31T10:02:00.000
0
0
0
0
python,tkinter
18,548,116
1
true
0
1
You can't, if you're talking about the native menubar you get when you set the menu attribute of the root window. You can create your own menubar that behaves a little bit like a menubar by using a frame and one or more menubuttons, and place that at the bottom.
1
0
0
I have a program thats like a desktop enviroment with educational games and I was wondering how to put the menubar on the bottom of the window. Thanks In Advance!
tkinter - Change menubar location
1.2
0
0
269
18,547,065
2013-08-31T10:22:00.000
0
0
1
0
python,eclipse,console,pydev
22,821,015
2
false
0
0
Do a ctrl+alt+enter in the coding window (with a console open or not) and you will automatically load the current code for use.
1
1
0
I use Eclipse with pydev for python development. I would like to test my code using pydev's interactive python console. When I make a change in the code, interactive pydev console doesn't notice it, and i have to close the current pydev console and open a new one to reflect the changes. Is there an easier way to get the changes to current active console? maybe a restart button?
How to restart pydev interactive console after a code change?
0
0
0
1,638
18,553,849
2013-08-31T23:44:00.000
14
0
0
0
java,android,python,kivy
18,563,503
2
false
0
1
To complete inclement's answer, pyjnius indeed allows to access a lot of the android api. But it's not perfect, calling existing classes is not always enough, and an android programmer often need to create code that will be called by android to manage events, there are two ways to do that, both used by the android api. The first one is interfaces: you need to create a class that implement an existing java interface, pyjnius can do that, you create a python class and declare which java interface it implements, and have a decorator to declare the methods you have to declare. The second is subclassing, you need to subclass an existing java class and override some methods, and we don't have a way to do that with pyjnius yet, so for these ones, you'd have to create a java class and use it in your program (fortunately you can mix that with kivy/pyjnius, it's just can't be 100% python in that scenario). So it can be worth a look to the api beforehand, to see if the parts of the android api you have to access requires that.
1
21
0
I'm a python developer with little experience creating android apps in java and want to create an app that will access my university web portal, retrieve some data and show on a view. So, after researching Kivy, I have a few questions: 1) Which one is easier and faster to develop android apps? 2) Does Kivy have any android feature limitations? 3) And finally, would an android app developed using kivy run as fast as one developed using java?
Difference between Kivy and Java for android apps
1
0
0
11,995
18,554,799
2013-09-01T03:01:00.000
1
0
1
0
python,json,csv,python-2.7,python-3.x
18,806,638
1
true
0
0
I found the solution. While parsing the string, I converted the string to unicode using the unicode() function: unicode(stringname, errors='replace') and it replaced all the erroneous symbols.
1
0
0
I am trying to convert a csv file to a json file. The whole code runs fine but when I encounter the statement: json.dump(DictName, out_file) I get the following error: UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 15: invalid start byte Would someone please be able to help? TIA.
Want the code to read ' instead of ’
1.2
0
0
61
18,555,139
2013-09-01T04:10:00.000
0
0
0
0
python,node.js,socket.io
18,555,399
1
true
0
0
Assuming your Python objects are simple enough (not instances of classes, say), just send a JSON representation (json.dumps()) of them to the socket.io side. I am assuming you can parse JSON on the client side if needed.
1
0
0
Ok so what I'd like to do is have a game written in python and for all the multiplayer to be handled socket.io just because these are two things I'm fairly familiar with and I wanna keep possibilities for a web version or web app for the game open So what I'm wondering is, how exactly do I do this and would it be better to embed a javascript parser on the client side or contact node.js from python directly
Sending python objects to node.js via socket.io
1.2
0
1
347
18,557,438
2013-09-01T10:20:00.000
4
0
1
0
python
18,557,493
3
false
0
0
I think the biggest issue (and the reason that those implementations require type annotations) is that the Python specification relies heavily on deferring semantic evaluation like function binding to execution time. Even if typing can be fully inferred from the script in some cases, it would be extremely complex to do that for the general case, and code that relies on deferred binding would, as Magnus Hoff points out in the comments, require embedding what amounts to an interpreter in the resulting executable. Edit: I'm answering the implied secondary question about why someone hasn't tackled this problem head-on, not agreeing with the idea that it's somehow impossible. The C++ runtime, for example, does a lot of deferred binding, but my sense is that Python does more and does it later.
2
7
0
Why can't pure Python be fully compiled? Compiled or interpreted is a trait of the implementation, not the language. So shouldn't there be some Python implementation that is fully before-hand compiled to native code? What makes (pure) Python so difficult to compile? I know there are things like PyPy and Cython but as I understand it those are not pure Python and require things like type annotations, etc. thanks Fully compiled meaning compiled before-hand to native code, like C or C++ or Lisp.
Why can't pure Python be fully compiled?
0.26052
0
0
3,504
18,557,438
2013-09-01T10:20:00.000
6
0
1
0
python
18,557,527
3
false
0
0
False premise. Python can be fully compiled, no type annotations or anything of the sort are necessary. Furthermore, PyPy does fully compile Python code into machine code. That this isn’t done ahead of time is irrelevant for the aspect of compilability – it’s just an implementation detail of the JIT architecture.
2
7
0
Why can't pure Python be fully compiled? Compiled or interpreted is a trait of the implementation, not the language. So shouldn't there be some Python implementation that is fully before-hand compiled to native code? What makes (pure) Python so difficult to compile? I know there are things like PyPy and Cython but as I understand it those are not pure Python and require things like type annotations, etc. thanks Fully compiled meaning compiled before-hand to native code, like C or C++ or Lisp.
Why can't pure Python be fully compiled?
1
0
0
3,504
18,560,367
2013-09-01T16:17:00.000
1
0
0
0
android,python-3.x,kivy,sl4a
18,723,415
2
false
0
1
I'm loving kivy. The irony is, that I found this topic here looking for help with python 3. Python 2 works perfectly, but 3 is still being made compatible. Other than that Kivy is great for beginner coders. Especially, because you don't have to code the complex stuff.
2
0
0
I am learning to program (python 3.x) and was wondering what would be best to learn for making android apps/games. I dont know anything about UI really but have heard that kivy? Is on android. Is that worth learning or should i use something else. Thanks Edit: I am using sl4a and py34a on my android device.
kivy or something else for android UI
0.099668
0
0
2,257
18,560,367
2013-09-01T16:17:00.000
2
0
0
0
android,python-3.x,kivy,sl4a
19,018,485
2
false
0
1
Kivy is good, and will run on Android, but you can't make Android apps with it. It has no way of interacting with the Android API. You can run a kivy app on the device, but can not read sensors or anything like that. They have a project called pyjnius, which allows you to access Java classes from Python, but not with Python3, and it's not very easy to use unless you know Java. You have SL4A installed, so you can use web technology to do UIs, including games, which can be rendered on the device using webviews. That said, Kivy is a much more mature and well maintained project.
2
0
0
I am learning to program (python 3.x) and was wondering what would be best to learn for making android apps/games. I dont know anything about UI really but have heard that kivy? Is on android. Is that worth learning or should i use something else. Thanks Edit: I am using sl4a and py34a on my android device.
kivy or something else for android UI
0.197375
0
0
2,257
18,562,006
2013-09-01T19:18:00.000
1
0
0
0
python,flask,web,session,caching
21,949,675
2
false
1
0
Your instinct is correct, it's probably not the way to do it. Session data should only be ephemeral information that is not too troublesome to lose and recreate. For example, the user will just have to login again to restore it. Configuration data or anything else that's necessary on the server and that must survive a logout is not part of the session and should be stored in a DB. Now, if you really need to easily keep this information client-side and it's not too much of a problem if it's lost, then use a session cookie for logged in/out state and a permanent cookie with a long lifespan for the rest of the configuration information. If the information it too much size-wise, then the only option I can think of is to store the data other than the logged in/out state in a DB.
1
7
0
Scenario: Major web app w. Python+Flask Flask login and Flask.session for basic session variables (user-id and session-id) Flask.session and limitations? (Cookies) Cookie based and basically persist only at the client side. For some session variables that will be regularly read (ie, user permissions, custom application config) it feels awkward to carry all that info around in a cookie, at every single page request and response. Database is too much? Since the session can be identified at the server side by introducing unique session id at login, some server-side session variable management can be used. Reading this data at the server side from a database also feels like unnecessary overhead. Question What is the most efficient way to handle the session variables at the server side? Perhaps that could be a memory-based solution, but I am worried that different Flask app requests could be executed at different threads that would not share the memory-stored session data, or cause conflicts in case of simultaneous reading-writing. I am looking for advice and best practice for planning the basic level architecture.
Efficient session variable server-side caching with Python+Flask
0.099668
0
0
2,346
18,563,018
2013-09-01T21:14:00.000
4
0
0
0
python,python-3.x
18,563,064
3
false
0
0
I think I found the proper way, just looking from another perspective: self.data = self.data[Index:] just copying what I need to itself again
1
7
0
I am pretty new to python and sometimes things that seems pretty easy become lot complicated than expected I am currently using a bytes buffer to read from a socket: data = self.socket.recv(size) and then process part of that buffer and need remove it The thing is that I've been looking for a way to do that and didn't find a clue in the whole evening, I am pretty sure that I am not getting any fair results because of the words involved, or maybe it's not possible I tried with "del" but got an error saying that it's not supported Am I doing it the wrong way? Maybe someone could lead me the right way? :)
How to remove a range of bytes from a bytes object in python?
0.26052
0
1
23,868
18,563,715
2013-09-01T22:52:00.000
2
0
0
0
python,qt,qt4,pyqt,pyqt4
18,565,528
1
true
0
1
You can hide a column in a QTableWidget by calling setColumnHidden(int column, bool hide) with the column number, and True for the hide option. A better solution to this would to be to prevent the user interface from ever receiving this information. A Model-View-Controller setup, or the use of a data access layer could ensure that only the relevant information is sent on to the interface and nothing would require hiding.
1
2
0
I need to send a set of information to model widget, QTableView/QTableWidget, Then When user click on a row, can open a new widget with ID of sent by information to QTableView/QTableWidget. I use PyQt I need to send hidden, it means user can't see my hidden id of database on QTableView/QTableWidget Primative Question: How can send data to QTableView/QTableWidget without user can see them in TableModel widget such as id of my database table ?
How to send data to QTableView/QTableWidget (PyQt)
1.2
0
0
1,156
18,565,750
2013-09-02T04:39:00.000
1
0
1
0
python,python-module
18,565,804
1
true
0
0
For Linkedin authentication backend, you should import this way, from social.backends.linkedin import LinkedinOAuth for OAuth2, from social.backends.linkedin import LinkedinOAuth2
1
0
0
I'm running Windows 7 x64. I've installed Python 2.7 32-bit into the default directory (C:/Python27). I used Pip to install a few modules (e.g. social-auth), but when I try to import them, Python says there is no module with that name. For example, "import linkedin" results in an ImportError. Google search suggests that the problem might be with a missing __init__.py, but all the subdirectories have an __init__.py (although I'm not sure what those files are supposed to contain).
Python 2.7 not searching folders inside of site-packages
1.2
0
0
99
18,569,056
2013-09-02T08:49:00.000
2
0
0
0
python,flask,uwsgi
18,570,411
1
true
1
0
you can use the python atexit module or the uwsgi.atexit hook
1
0
0
i am using flask and uwsgi.. At some point i need to know when uwsgi is stopped or when my app (Flask) object is destroyed and when it happens, execute a function. Any ideas ?? Please
How to execute a function when uwsgi is stopped
1.2
0
0
890
18,569,784
2013-09-02T09:27:00.000
0
1
1
0
python,passwords,password-protection,password-encryption
19,035,745
8
false
0
0
To protect data stored on the client machine, you have to encrypt it. Period. If you trust an authorized user, you can use a password-based encryption key (many other answers on Stack Exchange address this), and hope that he is smart enough to protect his computer from malware. If you don't trust the authorized user (a.k.a. DRM) you are just plain out of luck -- find another project.;-)
4
10
0
I am a beginner so if this question sounds stupid, please bear with me. I am wondering that when we write code for username/password check in python, if it is not compiled to exe ie script state, won't people will easily open the file and remove the code potion that is doing the password check? I am assuming that the whole program is entirely written in python, no C or C++. Even if I use a program like py2exe it can be easily decompiled back to source code. So, does that mean it is useless to do a password check? How do professional programmers cope with that?
Python Password Protection
0
0
0
40,722
18,569,784
2013-09-02T09:27:00.000
2
1
1
0
python,passwords,password-protection,password-encryption
18,571,072
8
false
0
0
On a server only server administrators should have the right to change the code. Hence, to change the code you have to have administrator access, and if you do, then you can access everything anyway. :-) The same goes for a client program. If the only security is the password check, you don't need to get around the password check, you can just read the data files directly. In both cases, to prevent people that has access to the files from reading those files a password check is not enough. You have to encrypt the data.
4
10
0
I am a beginner so if this question sounds stupid, please bear with me. I am wondering that when we write code for username/password check in python, if it is not compiled to exe ie script state, won't people will easily open the file and remove the code potion that is doing the password check? I am assuming that the whole program is entirely written in python, no C or C++. Even if I use a program like py2exe it can be easily decompiled back to source code. So, does that mean it is useless to do a password check? How do professional programmers cope with that?
Python Password Protection
0.049958
0
0
40,722
18,569,784
2013-09-02T09:27:00.000
4
1
1
0
python,passwords,password-protection,password-encryption
18,570,957
8
false
0
0
If you are doing the checking on a user's machine, they can edit the code how they like, pretty much no matter what you do. If you need security like this then the code should be run somewhere inaccessible, for instance a server. "Don't trust the client" is an important computer security principle. I think what you want to do is make a server script that can only be accessed by a password being given to it by the client program. This server program will function very much like the example code given in other answers: when a new client is created they send a plaintext password to the server which puts it through a one-way encryption, and stores it. Then, when a client wants to use the code that is the main body of your program, they send a password. The server puts this through the one-way encryption, and sees if it matches any stored, hashed passwords. If it does, it executes the code in the main body of the program, and sends the result back to the user. On a related topic, the other answers suggest using the md5 algorithm. However, this is not the most secure algorithm - while secure enough for many purposes, the hashlib module in the standard library gives other, more secure algorithms, and there is no reason not to use these instead.
4
10
0
I am a beginner so if this question sounds stupid, please bear with me. I am wondering that when we write code for username/password check in python, if it is not compiled to exe ie script state, won't people will easily open the file and remove the code potion that is doing the password check? I am assuming that the whole program is entirely written in python, no C or C++. Even if I use a program like py2exe it can be easily decompiled back to source code. So, does that mean it is useless to do a password check? How do professional programmers cope with that?
Python Password Protection
0.099668
0
0
40,722
18,569,784
2013-09-02T09:27:00.000
0
1
1
0
python,passwords,password-protection,password-encryption
62,569,006
8
false
0
0
One way would be to store the password in a hash form of any algorithm and check if the hash of the password given is equal to the stored password hash. The second way might be to take a password like "cat" and convert them to ascii and and add them up and store the sum. Then you can compare the given password's ascii sum to the one you stored. OR you can combine them both! Maybe also hash the ascii sum and compare the given pass word's ascii sun's hash. These are the three ways I know at least. And you can use chr or ord default function in python to convert to and back repeatedly to ascii. And you can use hashlib to hash.
4
10
0
I am a beginner so if this question sounds stupid, please bear with me. I am wondering that when we write code for username/password check in python, if it is not compiled to exe ie script state, won't people will easily open the file and remove the code potion that is doing the password check? I am assuming that the whole program is entirely written in python, no C or C++. Even if I use a program like py2exe it can be easily decompiled back to source code. So, does that mean it is useless to do a password check? How do professional programmers cope with that?
Python Password Protection
0
0
0
40,722
18,570,143
2013-09-02T09:46:00.000
1
0
0
0
python,linux,excel,shell,xlrd
18,574,653
2
false
0
0
mv file.{xls,csv} It's a csv file, stop treating it as an excel file and things will work a lot better. :) There are nice csv manipulation tools available in most languages. Do you really need the excel library?
1
0
0
I have an excel file whose extension is .xls but his type is Tab Space separated Text. When I try to open the file by MS Excel it tells me that the extension is fake. And So I have to confirm that I trust the file and so I can read it then. But my real problem is that when I try to read my file by the xlrd library it gives me this message : xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record; And so to resolve this problem, I go to Save as in MS Excel and I change the type manually to .xls. But my boss insist that I have to do this by code. I have 3 choices : Shell script under Linux, .bat file under Windows or Python. So, how can I change the type of the excel file from Tab space separated Text to xls file by Shell script (command line), .bat or Python?
How to change automatically the type of the excel file from Tab space separated Text to xls file?
0.099668
1
0
399
18,575,012
2013-09-02T13:59:00.000
11
0
1
0
ipython-notebook
54,837,259
7
false
0
0
Knowing that in jupyter (ipython) notebook markdown cells the title level is identified by the number of # (# for top level headings or h1, ## for h2, ....), I use the following combination of HTML and markdown: # <center>Your centered level h1 title</center> ## <center>Your centered level h2 title</center> etc.. It's straightforward and the easiest to remember but please do comment if there's any disadvantage in doing so. Tested in jupyter version 4.4.0 (not sure about other version but no reason it doesn't work).
4
50
0
I want to customize my notebook, make it more readable and stylish. So for that, I want to start with centering my headers. Is it possible?
Centering Text in IPython notebook markdown/heading cells?
1
0
0
94,911
18,575,012
2013-09-02T13:59:00.000
4
0
1
0
ipython-notebook
67,552,210
7
false
0
0
the easy way for me is just : # <center> some fancy title here it works without closing the tag, so i usually copy "<center>" and past it away in a single step when i finish.
4
50
0
I want to customize my notebook, make it more readable and stylish. So for that, I want to start with centering my headers. Is it possible?
Centering Text in IPython notebook markdown/heading cells?
0.113791
0
0
94,911
18,575,012
2013-09-02T13:59:00.000
-3
0
1
0
ipython-notebook
51,788,944
7
false
0
0
It's quite simple to make your text stylish in Jupyter-notebook as it's syntax are similar to HTML. For example, you can use the following commands to play with your texts: 1.**bold_text** will make your test bold like bold_text. 2.*italic_text* will result in italic text like italic_text 3.***bold_italic_text*** will result in bold and italic text like bold_italic_text 4. You can use <h1> header1 </h1> to make the text as header like header1 You can replace h1 within the angular brackets with any number h2,h3 etc. to get header of different sizes. 5. For text alignment you can use Centered_text to align you text to the center. 6. Use <br> to breakline or if you want the following text to be printed in next line. These are just basic things, you can do many more things.
4
50
0
I want to customize my notebook, make it more readable and stylish. So for that, I want to start with centering my headers. Is it possible?
Centering Text in IPython notebook markdown/heading cells?
-0.085505
0
0
94,911
18,575,012
2013-09-02T13:59:00.000
-3
0
1
0
ipython-notebook
66,083,631
7
false
0
0
if you want to make a header you can easily use # at the beginning of text to make it big size and also bold, ## will also do the same but text size will be smaller, you can reduce the size of the bold text by increasing the #s up to 6.
4
50
0
I want to customize my notebook, make it more readable and stylish. So for that, I want to start with centering my headers. Is it possible?
Centering Text in IPython notebook markdown/heading cells?
-0.085505
0
0
94,911
18,576,492
2013-09-02T15:21:00.000
3
0
1
1
python,python-2.7
18,576,513
2
false
0
0
Specify Python 2.7's executable in the shebang of your scripts. Don't screw with the system Python.
1
0
0
I have access to old linux server(debian) and default Python is 2.6. To start my scripts I need Python 2.7. When I type python to console always 2.6 starts (I have installed 2.7 and when I want to run I use command pythonbrew use 2.7.2) How to avoid to type this and set that Python 2.7 is default?
How to avoid to type this and set that python 2.7 is default instead of python 2.6?
0.291313
0
0
63
18,576,573
2013-09-02T15:26:00.000
4
0
1
0
python,function
18,576,700
3
true
0
0
__init__ is invoked on instantiation. When you call some_instance = SomeClass(a, b), it is called with self, a and b as arguments. Python has the "we are all consenting adults" motto, so yes, you can - but every time you call double-underscored methods you should really know what you are doing and you have to face the consequences if it breaks something. Most classes are not designed to have __init__ called after instantiation, and it would be an odd design; if you are tempted to call some_instance.__init__(*args) in order to recycle an object, just get a new instance calling SomeClass(*args) - calling __init__ is not guaranteed to reset state from an existing instance, gambling on this would be bad design. I'm not aware of any use case for calling __init__ explicitly except for overriding the parent class __init__ using super.
1
0
0
Is it possible to invoke __init__() function explicitly? Or the function is always invoked when an object of the class is instantiated?
Can __init__() function in python be invoked at a different moment than at object creation?
1.2
0
0
89
18,576,838
2013-09-02T15:44:00.000
2
1
0
0
php,python,mysql,mongodb,startup
18,577,154
1
false
1
0
The idea that PHP/MySQL is easier or simpler than say Python/MongoDB is just inconsistent. If you compare for example, Django (the most popular python web framework) with symfony(PHP) you will find that they are almost identical in terms of features and architecture (symfony is actually slightly more complex but also has more very advanced features). For mockups, if I were you, I would use solely HTML/jQuery/CSS. Build your pages just like you would like to have them in your beta version, use jQuery to load sample data written in json. That's all you need. You can even find WYSIWYG application to speed up the process. Later on, you can build the back-end application using either python or php, it won't matter. The integration process will be identical, create your models, create the controllers, and use the HTML you already have as templates. Building your app in php/mysql then convert it to python/mangodb will make you rewrite almost all the code simply because python is so much different from php (easier I would say too, but that's just my opinion) and because mangodb is not a relational database meaning you will have also to rethink partially your architecture.
1
0
0
since about two years ago, I did find my interest in code (Hardware/Sytems/Web) and now, I've found a project which motivates me a lot (It takes all my free time indeed). Starting this point and because my project could soon switch from a free time project to a daily job, I'm currently developing a mockup of this project based on PHP/MySQL and JQuery. Even if I'm a true Python/MongoDB lover and a System Engineer, I did prefer those technologies to build up my mockup because of their simplicity to build a complete functional private stack at home. I'm pretty advanced on my mockup and it seems to work as I want it. Now I'm wondering if, about your point of view, would have been better to start to build my mockup using directly the targeted technologies (Python/MongoDB) rather than to use the easy PHP/MySQL couple to do it? Obviously, because I plan to made this project my daily job, I had to have something visually functionnal to be able to raise a little bit of money, and about me, using an easier stack it's more easy, but I would like to have your feedback on this kind of question.
Startup building and mokup
0.379949
0
0
70
18,577,413
2013-09-02T16:27:00.000
1
1
0
0
c++,python,c
18,577,516
5
false
0
0
Profile your application. If it really is spending time in a couple of places that you can recode in C consider doing so. Don't do this unless profiling tells you you really need to.
3
0
0
Recently I've read that we can code C/C++ and from python call those modules, I know that C/C++ is fast and strongly typed and those things but what advantages I got if I code some module and then call it from python? in what case/scenario/context it would be nice to implement this? Thanks in advance.
What are the advantages of extending Python with C or C++?
0.039979
0
0
437
18,577,413
2013-09-02T16:27:00.000
1
1
0
0
c++,python,c
18,577,711
5
false
0
0
Another reason is there might be a C/C++ library with functionality not available in python. You might write a python extension in C/C++ so that you can access/use that C/C++ library.
3
0
0
Recently I've read that we can code C/C++ and from python call those modules, I know that C/C++ is fast and strongly typed and those things but what advantages I got if I code some module and then call it from python? in what case/scenario/context it would be nice to implement this? Thanks in advance.
What are the advantages of extending Python with C or C++?
0.039979
0
0
437
18,577,413
2013-09-02T16:27:00.000
0
1
0
0
c++,python,c
18,577,861
5
false
0
0
The primary advantage I see is speed. That's the price paid for the generality and flexibility of a dynamic language like Python. The execution model of the language doesn't match the execution model of the processor, by a wide margin, so there must be a translation layer someplace at runtime. There are significant sections of work in many applications that can be encapsulated as strongly-typed functions. FFTs, convolutions, matrix operations and other types of array processing are good examples where a tightly-coded compiled loop can outperform a pure Python solution more than enough to pay for the runtime data copying and "environment switching" overhead. There is also the case for "C as a portable assembler" to gain access to hardware functions for accelerating these functions. The Python library may have a high-level interface that depends on driver code that's not available widely enough to be part of the Python execution model. Multimedia hardware for video and audio processing, and array processing instructions on the CPU or GPU are examples. The costs for a custom hybrid solution are in development and maintenance. There is added complexity in design, coding, building, debugging and deployment of the application. You also need expertise on-staff for two different programming languages.
3
0
0
Recently I've read that we can code C/C++ and from python call those modules, I know that C/C++ is fast and strongly typed and those things but what advantages I got if I code some module and then call it from python? in what case/scenario/context it would be nice to implement this? Thanks in advance.
What are the advantages of extending Python with C or C++?
0
0
0
437
18,579,076
2013-09-02T18:36:00.000
0
0
0
0
java,python,swing,user-interface,toolkit
18,579,176
2
false
0
1
I know QT is for Java (and Python of course). It is well documented and is used by a lot of people around the world.
1
3
0
I've been write window programs with C# + WPF for a while now. It is very good, has alot of rich elements as of .NET 4.5 but I dont really buy the idea of porting window based programs to other operating system like OS X using mono and others. I started working on Java and Python, I haven't written any desktop based program with anyone of them yet as there are war of GUI framework/toolkit out there and everyone is just getting religious about things. I need some clarification hence the following Questions, mind you these questions might be answered before but like I said, Clarifications: What is the different between GUI toolkit and GUI framework For Java programming, I see swing is integrated with Netbeans, from my research, people are speaking of qt's Jambi and GTK for java and python, I have no idea about any of these and I want to know, (1) Which do you use and why? (for Java and python), (2) Visual studio do all the magic for WPF and C#, which IDE can do these magic in java and python. Lastly, I want you all to know that my asking these question is just to know which rich, powerful GUI and cross platform toolkit/framework (Whichever the right term is) is best for java and python with easy learning curve. Constructive criticism are welcome BUT, I will be glad if there are answers.
Best GUI Toolkit/Framework for Java and Python
0
0
0
3,817
18,579,714
2013-09-02T19:30:00.000
2
0
1
0
python-3.x,pydev
18,657,531
1
false
0
0
You must enable the debug perspective. Then, in the PyDev menu use: Manage Python Exception Breakpoints
1
2
0
In Visual Studio, when I run an application, it will pause and enter debug mode when an exception is caught. How do I replicate this behaviour in Pydev?
Pydev, how to pause on exception
0.379949
0
0
333
18,581,117
2013-09-02T21:41:00.000
2
0
0
0
python,django,transactions
18,581,616
1
true
0
0
There is no way to transactionally delete multiple files on normal filesystems (you might be able to find esoteric filesystems where it is, but even if so I doubt that helps you. Apparently your current filesystem doesn't even let you delete a file that's being read, so presumably you're stuck with what you have!). Perhaps you could save in the database not the file contents, but a list of which filenames in the filesystem "really exist". Refer to that list for anything that requires consistency. If file deletion fails, you can mark the file as "not really existing" and requiring future attempts at deletion, then retry whenever seems sensible (maybe an occasional maintenance job, maybe a helper process retrying each failure with exponential backoff to a limit). For this to work either (a) your webserver must refer to the database before serving the file, or else (b) it must be OK for there to be a indefinite period after the file fails to delete, during which it may nevertheless be served. And of course there is also the "natural race condition" that a file that begins to be served before the deletion attempt, will complete its download even after the transaction is complete. [Edit: Ah, it just occurred to me that "i have all the files in a folder for the main entity" might actually be really helpful. In your transaction, rename the directory. That atomically "removes" all the files, from their old names at least, and it will fail (on filesystems that forbid that sort of thing) if any of the files is in use. If the rename succeeds, and nobody else knows the new name, then they won't be accessing the files and you should be able to delete them all without trouble. I think. Of course this doesn't work if you encounter another reason for failing to delete the file, because then you might be able to rename the folder but unable to delete the file.]
1
0
0
I need to do the following Delete many entities from a database, also those entities have a file associated with them saved into the file system, which are accessed also by the web server (images!). The problem: File deletion might fail, I have all the files in a folder for the main entity (its actually a 1-N relation, being each one of the N the file owners). If I try to delete a file when the web server is accessing them, I will get an exception and the process will go in half, some images deleted, and some doesnt, leaving the system inconsistent. Is there a way to to do something similar to a transaction but in the file system (either delete all files or don't delete any)? Or perhaps another approach (the worst plan is to save the files in the database, but it is bad)
Delete files atomically/transactionally in python
1.2
1
0
708
18,581,440
2013-09-02T22:14:00.000
0
0
1
0
python,python-2.7
18,582,055
1
false
0
0
I use Python where I can and C where I must. I can load libraries dynamically on both and I don't see much of a difference. So IMHO no, these are orthogonal concepts. Lines may blurry because you can load binary modules in Python, and you can embed a dynamic interpreter in C (Python being a little big for this, I prefer Lua or scheme). Where being dynamic helps is with fast prototyping and introspection, because you can skip compile cycles and the REPL makes much easier to experiment and inspect live code snippets. Python has wonderful introspection features, so you can load an unknown module on the REPL and inspect all classes and functions - in C you probably would have to read some header file to get the data types and function signatures.
1
1
0
Python is an interpreted language, and it has built-in support for dynamic module loading. Does the former make it easier for the latter? Or the two are unrelated? Some conceptual explanation would be appreciated!
Being interpreted and dynamic module loading
0
0
0
48
18,581,973
2013-09-02T23:19:00.000
1
0
1
1
python,coderunner
21,959,976
1
false
0
0
Coderunner is more useful in testing single python files instead of larger projects, however it can run such projects. A larger project should have a setup.py or a main.py which should be run. Also, what errors are you getting?
1
1
0
I'm brand new to coding. I managed to figure out how to use github and I have been forking projects over to my machine in an attempt to play around with them and learn python. My problem is every single project I fork over, when I run any of the .py files in Coderunner it pops up with errors and doesn't run correctly. Is this because coderunner is not capable of running these programs? Or do I have to run the programs through terminal to get them functioning correctly?
Unable to run any Python program using code runner
0.197375
0
0
605
18,582,698
2013-09-03T01:14:00.000
3
0
1
0
python,multithreading,python-2.7,signals,mutex
18,582,723
1
false
0
0
Python's signal module runs signal handlers on the main interpreter thread exclusively. If your main thread is hung and unable to execute Python code, your signal handlers will not run. Signals will be fired and caught, but if the thread can't execute Python code then nothing will happen. The best way to avoid this situation is to ensure your main thread (the first thread that exists in the Python interpreter upon startup) does not deadlock. This may mean ensuring that nothing important happens on that thread after initialization.
1
0
0
I have a python script with multiple threading-launched threads in which several threads occasionally freeze (apparently simultaneously). In this script, I've registered a signal handler to dump stack traces from all the running threads. When it's frozen, no dumped stacks appear. What could be causing this? A couple of possibilities that come to mind: A thread is not releasing a mutex, freezing any other threads that attempt to acquire it. I would expect the signal handler to work in this case, however. Am I mistaken? I log various things to stdout and stderrr, which are redirected with a bash command line to a log file. Perhaps precisely timed output from 2 threads could be blocking at OS level? This script has been running for months without problems, though there was a kernel update just recently (it's Ubuntu 12.04). If this is the case, the signal is not being ignored, just not producing any output... I have a few global variables that are read and written by the freezing threads. I had thought that python 2.7 has a global thread lock to make this safe, and it's not been a problem before.
What can cause python registered signals to be ignored?
0.53705
0
0
137
18,594,248
2013-09-03T13:58:00.000
0
0
0
0
python,django,request
18,594,433
2
false
1
0
Middleware is very certainly not thread-safe. You should not store anything per-request either on the middleware object, or in the global namespace. The usual way to do this is sort of thing to annotate it onto the request object. Middleware and views have access to this, but to get it anywhere else (eg in the model) you'll need to pass it around.
1
0
0
I have following problem. I want to add to django some kind of setup/teardown for each request. For example at the beginning of per user request I want to collect start data collection and at the end of request dump all data to database (1). What comes to my mind right now, at the start of middleware instantiate an object (like singleton), every other part of the code can import this object, use its methods and then same middleware before returning response will scrap the object. The only concern I have is to be a threadsafe, so maybe create a global dict, and register keys that are build upon url + session_id hash or maybe request object id (internal python object id, maybe is good way to go?). At the end of request key will be scrapped from dict. Any recommendations, thoughts, ideas? (1) Please do not ask me why I cannot access DB directly or anything like this. This is only an example. I'm looking for general idea for something like enter and exit but request-response wise that can be imported in any place in a code and safely used.
Django bootstrap/middleware/enter-exit
0
0
0
216
18,595,099
2013-09-03T14:39:00.000
0
0
0
0
python,opencv
20,780,282
5
false
0
0
these parameters should be integer, or it will raise TypeError
2
14
1
OpenCV2 for python have 2 function [Function 1] Python: cv2.ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) → None [Function 2] Python: cv2.ellipse(img, box, color[, thickness[, lineType]]) → None I want to use [Function 1] But when I use this Code cv2.ellipse(ResultImage, Circle, Size, Angle, 0, 360, Color, 2, cv2.CV_AA, 0) It raise TypeError: ellipse() takes at most 5 arguments (10 given) Could you help me?
How I can use cv2.ellipse?
0
0
0
13,427
18,595,099
2013-09-03T14:39:00.000
7
0
0
0
python,opencv
28,592,694
5
false
0
0
Make sure all the ellipse parameters are int otherwise it raises "TypeError: ellipse() takes at most 5 arguments (10 given)". Had the same problem and casting the parameters to int, fixed it. Please note that in Python, you should round the number first and then use int(), since int function will cut the number: x = 2.7 , int(x) will be 2 not 3
2
14
1
OpenCV2 for python have 2 function [Function 1] Python: cv2.ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) → None [Function 2] Python: cv2.ellipse(img, box, color[, thickness[, lineType]]) → None I want to use [Function 1] But when I use this Code cv2.ellipse(ResultImage, Circle, Size, Angle, 0, 360, Color, 2, cv2.CV_AA, 0) It raise TypeError: ellipse() takes at most 5 arguments (10 given) Could you help me?
How I can use cv2.ellipse?
1
0
0
13,427
18,596,971
2013-09-03T16:16:00.000
0
0
0
0
python,django,namespaces,setuptools
18,644,769
3
true
1
0
The only way I found for now is the following: Do not use the namespace_packages parameter in setuptools.setup() Instead, explicitly define "namespace" packages with this in the __init__.py file: __import__('pkg_resources').declare_namespace(__name__) I have not done a lot of testings as to if this will work if I don't install my libraries in the same order, but at least, I am able to import my django settings (and everything else). EDIT This ended up not being a viable solutions because if librairies are uninstalled and reinstalled, they will delete more than they should, so ending up loosing modules. I ended up using namespace_packages in setuptools.setup() and use a different first level "namespace" for the running django project. EDIT 2 Scrap all this, this namespace thing seems to be a good idea, but ended up just being a nightmare with django. So i reverted everything back to non-namespace code. I'm not happy that I have to do this, but that's the price to work with django.
1
2
0
I was asked to split a big project into some reusable libraries (packages). So the idea was to do this: company-django-shared company-django-shared-dev company-python-shared company-python-shared-dev These are installable with setuptools and namespaces: company company.packagename company.packagename.tests company.util etc... All this works fine. I can start a shell and do any of the import i need. The problem arrives when I now want to use this in a django project. My settings are in: company.foo.settings At this point, since setuptools installed some packages, when I try to $ ./manage.py shell I get the error:: ImportError: Could not import settings 'company.foo.settings' (Is it on sys.path?): No module named foo.settings I really can't figure out how to use namespace within django apps. If I fire up a shell and do: import company company.__path__ The installed paths are found, but not the current directory. What am I missing? EDIT I would like to point out that the problem is Python cannot find any package under company because setuptools-installed packages define company as a namespace. EDIT 2 Django is just unhappy with namespaces. It seems there are no viable solutions.
ImportError: Could not import settings 'company.foo.settings' (Is it on sys.path?): No module named foo.settings
1.2
0
0
1,119
18,600,081
2013-09-03T19:32:00.000
1
0
0
0
python,resize,window,pyqt,pyqt4
29,042,473
5
false
0
1
you could set the maximumSize and minimumSize with the same values, it'll get to dissapear maximise button
1
12
0
I would like to know how to disable the window Maximise button in pyqt4. I am at present using QWidget.setFixedSize (self, QSize) to prevent user window resizing, however the maximise button is still enabled and when pressed causes the application to move to the top left corner of the screen. I am basically wanting to replicate the behaviour of the Windows calculator application, where the maximise icon is greyed out. Does anyone know how to achieve this with PyQt4?
how to disable the window maximize icon using PyQt4?
0.039979
0
0
20,169
18,600,435
2013-09-03T19:55:00.000
3
0
1
0
python
18,600,585
1
false
0
0
Your best bet (besides Googling for help before posting a question on SO) might be to do something like this: Note the time when the program starts. start = datetime.datetime.now() Do your calculations sleep until 100 seconds after start. (start + datetime.timedelta(seconds=100)) Note that this won't be perfect, since there is a little overhead involved with the steps between accessing the "current time" and going to "sleep" (e.g. subtracting "current time" from "wake-up time"). However, if your sleep precision only needs to be in seconds, you should be okay. Repeat as needed. If, after trying it out, you need additional help with the actual implementation of these steps, feel free to come back and post another question on that topic.
1
0
0
I am new to Python so be gentle. I have been trying to write a program that counts or measures events in real time. At the moment I am using the sleep command but this pause event doesn't take into account the time the program takes to run. I have read up on the datetime module and can sort of see how this could be used, but I am a bit stuck in implementing this. In short, I want a program that counts from 0 to 100 in real time seconds and milliseconds.
Real time timer
0.53705
0
0
299
18,603,205
2013-09-03T23:48:00.000
1
0
1
0
python,macos,gcc,cython,kivy
18,794,769
1
true
0
1
Which python are you using, the system python or macports or something else? Make sure you have XCode and gcc installed on your system first. Running which gcc on the command line will help identify where your current version of gcc resides. I assume you already checked this? As an alternative, you can try installing a precompiled version of cython such as the one that comes with anaconda or the enthought python distribution. Unfortunately, there's not enough information here to give a definitive answer.....
1
0
0
I have scowered stack overflow all day today trying to figure out why when I try to install cython unable to execute gcc-4.0: No such file or directory error: command 'gcc-4.0' failed with exit status 1 I am using OSX mountain lion and I am using default python with pygame and easygui and command line tools installed trying to make my first app using kivy and I need cython to make the gui.. Are there any other things I should use instead of Kivy but I am pretty impressed from what I saw online. If anyone has any other tips on installing Kivy? I am very lost doing this sorry for a trivial question!
When I try to install cython I get an error message unable to execute gcc-4.0
1.2
0
0
531
18,603,302
2013-09-03T23:57:00.000
3
0
1
1
python,django,git,virtualenv,virtualenvwrapper
25,869,799
3
false
1
0
Struggled with some variation of this issue not long ago; it ended up being my cluttered .bash_profile file. Make sure you don't have anything that might mess up your virtualenv inside your .bash_profile/.bashrc, such as $VIRTUAL_ENV or $PYTHONHOME or $PYTHONPATH environment variables.
2
11
0
I am attempting to setup a development environment on my new dev machine at home. I have just installed Ubuntu and now I am attempting to clone a remote repo from our web-server and install its dependencies so I can begin work. So far I have manually installed virtualenv and virtualenvwrapper from pypi and edited my bash.rc appropriately to source my virtualenvs when i start my terminal. I then cloned my repo to ~/projects/project-name/websitename.com. Then I used virtualenvwrapper to mkvirtualenv env-name from ~/projects/project-name/websitename.com. This reflects exactly the file-structure/setup of the web-server I am cloning from. So far so good. I logged into the dev server and activate the virtualenv there and use pip freeze -l > req.txt to render a dependencies list and scp to my local machine. I activate the virtualenv on my local machine, navigate to the ~/projects/project-name/websitename.com and execute pip install -r path-to-req.txt and it runs through all of the dependencies as if nothing is wrong. However, when i attempt to manage.py syncdb i get an error about not finding core django packages. What the hell? So i figure somehow Django failed to install, i run pip install Django==1.5.1 and it completes successfully. I got to setup my site again and get another error about no module named django_extensions. Okay, what the hell with it, i just installed all of these packages with pip?! So i pip freeze -l > test.txt and cat test.txt, what does it list? Django==1.5.1, the one package I just manually installed. Why isn't pip installing my dependencies from my specified list into my virtualenv? What am I messing up here? -EDIT------------- Which pip gives me the path to pip in my virtualenv I have only 1 virtualenv and it is activated
Pip doesn't install packages to activated virtualenv, ignores requirements.txt
0.197375
0
0
6,391
18,603,302
2013-09-03T23:57:00.000
2
0
1
1
python,django,git,virtualenv,virtualenvwrapper
32,925,897
3
false
1
0
I know this is an old post, but I just encountered a similar problem. In my case the cause was that I was running the pip install command using sudo. This made the command run globally and the packages install in the global python path. Hope that helps somebody.
2
11
0
I am attempting to setup a development environment on my new dev machine at home. I have just installed Ubuntu and now I am attempting to clone a remote repo from our web-server and install its dependencies so I can begin work. So far I have manually installed virtualenv and virtualenvwrapper from pypi and edited my bash.rc appropriately to source my virtualenvs when i start my terminal. I then cloned my repo to ~/projects/project-name/websitename.com. Then I used virtualenvwrapper to mkvirtualenv env-name from ~/projects/project-name/websitename.com. This reflects exactly the file-structure/setup of the web-server I am cloning from. So far so good. I logged into the dev server and activate the virtualenv there and use pip freeze -l > req.txt to render a dependencies list and scp to my local machine. I activate the virtualenv on my local machine, navigate to the ~/projects/project-name/websitename.com and execute pip install -r path-to-req.txt and it runs through all of the dependencies as if nothing is wrong. However, when i attempt to manage.py syncdb i get an error about not finding core django packages. What the hell? So i figure somehow Django failed to install, i run pip install Django==1.5.1 and it completes successfully. I got to setup my site again and get another error about no module named django_extensions. Okay, what the hell with it, i just installed all of these packages with pip?! So i pip freeze -l > test.txt and cat test.txt, what does it list? Django==1.5.1, the one package I just manually installed. Why isn't pip installing my dependencies from my specified list into my virtualenv? What am I messing up here? -EDIT------------- Which pip gives me the path to pip in my virtualenv I have only 1 virtualenv and it is activated
Pip doesn't install packages to activated virtualenv, ignores requirements.txt
0.132549
0
0
6,391
18,606,097
2013-09-04T05:35:00.000
4
0
1
0
python,save
18,606,314
8
false
0
1
First, don't overthink this. You don't need to use anything complicated. As a preliminary step, research basic file input/output in python. Second, I'm assuming you have a player class in your game? Or possibly an overall class which keeps track of game state. Well have that class store default values for your variables like health, gold etc. Then have a method which can modify this class like def load_stats(player): or def load_stats(game): something. and have it read in from a save file which can have any format you like and modify the variables of your player/game state. First test loading of game files and make sure you can get it so that your player class gets modified. Then all you have to do is add a save game feature that lets you output these variables back to a file in your directory system somewhere. Try doing this and let me know if you need any help afterwards.
1
5
0
I am in the process of making a text based game with Python, and I have the general idea down. But I am going to make the game in depth to the point where, it will take longer than one sitting to finish it. So I want to be able to make the game to where, on exit, it will save a list of variables (player health, gold, room place, etc) to a file. Then if the player wants to load the file, they go to the load menu, and it will load the file. I am currently using version 2.7.5 of Python, and am on Windows.
Python text game: how to make a save feature?
0.099668
0
0
36,232
18,607,233
2013-09-04T06:53:00.000
0
0
1
0
python
18,607,287
3
false
0
0
Even though your file may be only 2GB, the overhead of reading it in may result in far more than 2GB of memory used.
1
0
0
a single file with size greater then 2G. I call open(f, "rb").read() MemoryError. I call open(f, "rb").read(1<<30) OK How can I eliminate the 2G limit? I have enough memory -- 16G
MemoryError when read a file larger than 2G
0
0
0
624
18,611,649
2013-09-04T10:42:00.000
4
0
1
0
python,sublimetext2
19,054,775
2
true
0
0
Have you installed pylint? Ya gotta install pylint separately. HT to hernamesbarbara for actually making my answer useful.
1
3
0
I am trying to configure sublimer for python, when installing pylinter I always get this error: "please define the full path to "lint.py" in the settings. Even tried a full uninstall... By the way, also sublimerope - extract method doesnt work...
Please define the full path to lint.py in the settings
1.2
0
0
3,014
18,613,447
2013-09-04T12:09:00.000
1
0
1
0
python
18,614,455
2
false
0
0
Python can use all of the memory allocated to it. The OS allocates the memory, and usually has limits per process, but there are commands to control those limits. ( 'ulimit' on unix, for example ). But then most OSes use virtual memory, so the OS and it's processes can use more virtual memory than the physical memory available. So its possible for a python program to use more than physical memory. But the OS Virtual memory system controls what pages are in physical memory and what pages are swapped out to disk. So you could be "using" 64 GB of memory, but only a fraction of the most recently used pages are actually in physical memory at any time. And some of that physical memory will hold parts of the OS that run frequently, like those virtual memory allocation functions. Also: the memory allocated to a process is divided and allocated in different ways ( heap vs stack space, for example ). So it's possible to run out of memory for one while there is still lots of unused memory in the other. So it depends on what you mean by "use" as well as (as the other posted said) "how much work you're willing to do" . You can probably get 64GB allocated to you, but it's unlikely you can "use" all of physical memory unless you're running an embedded system where you're running as part of the OS.
2
4
0
If I use python (32 bit version) on a machine with for example 64Gb ram , will it be able to use these 64Gb of ram. Or does this depend on the Operating System ?
How much ram can python use?
0.099668
0
0
6,517
18,613,447
2013-09-04T12:09:00.000
8
0
1
0
python
18,613,543
2
true
0
0
Python does not itself use any mechanisms for extending past the per-process userspace memory limit of the operating system. There are however modules for and means of doing so. So the answer is "depends on how much work you're willing to do".
2
4
0
If I use python (32 bit version) on a machine with for example 64Gb ram , will it be able to use these 64Gb of ram. Or does this depend on the Operating System ?
How much ram can python use?
1.2
0
0
6,517
18,620,311
2013-09-04T17:33:00.000
0
0
0
1
python,xml,google-app-engine
20,461,649
1
false
1
0
Just to clarify, I'm going to assume that you're asking about the Model.to_xml() method, and that by efficient you mean a single method which you can call which will provide you with a model object. As you noted, there is no such method on the Model class for the datastore API. I think the intention is that the purpose of the to XML method is to make the model easily exportable to another application, such as a javascript client or for importing into another database or storage mechanism, similar to using the remote API. It should be possible to create a function or static method of a specific Model class which would generate a new model of a particular type from parsed XML. You will then most likely want to perform a get_or_insert() to write the resulting object. If you're looking for a native Python to Python serialization method, you could consider pickle.
1
4
0
In Google App Engine, I can serialize an object by calling its to_xml() method. There doesnt appear to be an equivalent from_xml() method to deserialize the xml. Is there an efficient way to deserialize back to an object?
How to deserialize xml created by to_xml() in google appengine
0
0
0
190
18,624,934
2013-09-04T22:35:00.000
1
0
1
0
vim,python-3.x
18,626,135
2
false
0
0
You should put customized settings in to ~/.vim/ftplugin/python.vim This will be sourced when vim sees a file with a filetype python. To make sure the settings only affect the current buffer use setlocal. To make sure that mappings only affect the current buffer use noremap <buffer> Just make sure to have filetype plugin indent on in ~/.vimrc
1
0
0
I am new to vim and I want to use it for scripting Python3. anyone knows how to customize vim for editing Python 3 scripts? (mainly for indentations, coloring and tab suggestions... ) Thanks
How to Customize vim for scripting in Python 3 ?
0.099668
0
0
1,096
18,625,446
2013-09-04T23:31:00.000
0
0
0
1
python,google-app-engine,angularjs,routes,webapp2
18,626,669
2
false
1
0
I'm working on the same stack and the way we do it is that we have the main pages (index, login, signup) configured as regular individual pages where we use angular without routing. Any page that anonymous users will access will be such pages which work over server side routing. But once the user login is successful we serve a page which will start serving other views through client side routing.
2
0
0
I'm currently building a web application using AngularJS, Webapp2, and the Python Google App Engine environment. This app is supposed to have all the features of modern social networks (users, posts, likes, comments). I want the page hierarchy to look like this, the main pages are from the server and the sub pages are supposed to be angular routes: Index Learn More Sign up Log in Feed Page Popular Feed Following Feed Profile Interactions Posts Settings Profile Account The problem is that when a user wants to signup I want them to be able to go to /signup and get the index page with the signup route loaded. How can I get the server to preload an angular route from the response
GAE Python Server initiating Angular Routes from Responses
0
0
0
298
18,625,446
2013-09-04T23:31:00.000
0
0
0
1
python,google-app-engine,angularjs,routes,webapp2
21,590,989
2
false
1
0
Make both GAE and Angular understand your routes. You will need to define them for one, why not both? You just have to organise your markup and structure so it can support complete page loading and ajax loading. For example, initial load is done on any route by GAE, then Angular can take over, loading each page "content" as it goes. This has the additional advantage of public pages being crawler friendly while real users get ajax loading (which should reduce bandwidth once you scale). You may need to load user state in via the server, and or force a page reload on log in or out to do so. I have done the above on a few apps, and it works well.
2
0
0
I'm currently building a web application using AngularJS, Webapp2, and the Python Google App Engine environment. This app is supposed to have all the features of modern social networks (users, posts, likes, comments). I want the page hierarchy to look like this, the main pages are from the server and the sub pages are supposed to be angular routes: Index Learn More Sign up Log in Feed Page Popular Feed Following Feed Profile Interactions Posts Settings Profile Account The problem is that when a user wants to signup I want them to be able to go to /signup and get the index page with the signup route loaded. How can I get the server to preload an angular route from the response
GAE Python Server initiating Angular Routes from Responses
0
0
0
298
18,625,601
2013-09-04T23:47:00.000
1
0
0
0
python,django,django-authentication,django-registration,django-1.5
18,625,653
1
true
1
0
When you have it all in one table, then database access is faster. With the old way you had to join on the auxiliary table to get all the information of the user. Usually when you see a One-to-One relation, it would be better just to merge them in one table. But the new custom User model solves also another problem, which is what atributes a User should have? What attributes are essential for your application? Is an email required? Should the email be also the username with which a user logs in? You couldn't do these stuff before this feature was introduced. Regarding your question about where to put additional user information like "hobbies" and such, it really depends on how often you will query/need this attributes. Are they gonna be only on the user's profile page? Well then you could have them in a seperate table and there wouldn't be much problem or performance hit. Otherwise prefer to store them on the same table as the User.
1
0
0
I'm currently using Django 1.5.1 and using a custom user as described in the official documentation. I realized everything is stored under one table, the auth_user one. My question is, why is it better to have everything in one big table, instead of having 2 tables like it used to be prior to 1.5 by using a user_profile table for all additional data? It seems smarter the way it used to be, in case we want to add 20 new fields for information about the user, it is weird to have everything in auth_user. In my case, for now I have class MyUser(AbstractUser) with 2 additional fields gender and date_of_birth, so it's all good with this, but now I would like to have many other information (text fields) like "favorite movies", "favorite books", "hobbies", "5 things I could not live without", etc. etc., to have way more information about my user. So I was just wondering if I should put that under MyUser class, or should I define a UserProfile one? And why? Thanks!
Django custom user VS user profile
1.2
0
0
907
18,626,114
2013-09-05T00:54:00.000
0
0
0
1
python,linux,macos,sqlite
18,629,528
2
false
0
0
To figure out exactly which sqlite3 binaries your system can find type which -a sqlite3. This will list the apps in the order that they are found according to your PATH variable, this also shows what order the thes ystem would use when figuring out which to run if you have multiple versions. Homebrew should normally links binaries into your /usr/local/bin, but as sqlite3 is provided by MAC OS, it is only installed into /usr/local/Cellar/sqlite3, and not linked into /usr/local/bin. As the Cellar path is not in your PATH variable, the system doesn't know that the binaries exist to run. Long story short, you can just run the Homebrew binary directly with /usr/local/Cellar/sqlite/3.8.0/bin/sqlite3.
1
1
0
I have a Mac running OS X 10.6.8, which comes pre-installed with SQLite3 v3.6. I installed v3.8 using homebrew. But when I type "sqlite3" in my terminal it continues to run the old pre-installed version. Any help? Trying to learn SQL as I'm building my first web app. Not sure if PATH variable has anything to do with it, but running echo $PATH results in the following: /usr/local/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin And the NEW version of SQLite3 is in the following directory: /usr/local/Cellar/sqlite I should add that I also downloaded the binary executable to my desktop, and that works if I click from my desktop, but doesn't work from the terminal. Any help would be greatly appreciated?
Running upgraded version of SQLite (3.8) on Mac when Terminal still defaults to old version 3.6
0
1
0
1,449
18,636,019
2013-09-05T12:13:00.000
0
0
0
0
python,maya,pymel
18,669,628
2
true
1
0
We can find the shape from the edge, by simply listing it's immediate connection with the use of node() PYMEL: pm.PyNode(selection[0].node().getParent()) No need to split the string, or re map the array.
1
0
0
Im using Maya to perform a certain task on selected edges. Let's say I save these edges like this: edges = pm.filterExpand(sm=32) From here, I can just select the first edge, and get the object by splitting the unicode string: 'pSphere1.e[274]' Here's how I split it, and it gave me pSphere1, however calling getShape() on that still doesn't work because it's a unicode object. object = edges[0].split('.')[0].getShape() Is there a better way to do this?
Get Shape from selected Edges
1.2
0
0
1,151
18,636,159
2013-09-05T12:20:00.000
0
0
0
0
django,python-2.7,django-1.3
19,995,173
1
false
1
0
I will try to answer why this was happening for us, i worked on it long time ago so will try to recollect as much as i can. We were allowing admins to modify the login id of the user, This would go and change the email id int he partial digest table. A lot of times they would use this to disable an account by changing the login id of that user. Now what would happen is this user who's not able to login as his id is changed did a trial registration with us using the same email id/password as before and hence now the partial digest table will have two entries.
1
0
0
We have digest authentication in our application. For some reason we are seeing for a few users having different id, username as in "auth_user" table but for some reason in the django_digest_partialdigest the user_id is different but the "login" column has the same username. I Am not able find out what scenario would lead to this kind of entry in the db. we allow signup/activation of account/resetting password.
Django 1.3 authentication
0
0
0
31
18,638,461
2013-09-05T14:02:00.000
3
0
0
0
python,hdf5,pytables
18,641,432
1
true
0
0
HDF5 attribute access is notoriously slow. HDF5 is really built for and around the array data structure. Things like groups and attributes are great helpers but they are not optimized. That said while attribute reading is slow, attribute writing is even slower. Therefore, it is always worth the extra effort to do what you suggest. Check if the attribute exists and if it has the desired value before writing it. This should give you a speed boost as compared to just writing it out every time. Luckily, the effect on memory of attributes -- both on disk and in memory -- is minimal. This is because ALL attributes on a node fit into 64 kb of special metadata space. If you try to write more than 64 kb worth of attributes, HDF5 and PyTables will fail. I hope this helps.
1
0
1
I am working a lot with pytables and HDF5 data and I have a question regarding the attributes of nodes (the attributes you access via pytables 'node._v_attrs' property). Assume that I set such an attribute of an hdf5 node. I do that over and over again, setting a particular attribute (1) always to the same value (so overall the value stored in the hdf5file does not change qualitatively) (2) always with a different value How are these operations in terms of speed and memory? What I mean is the following, does setting the attribute really imply deletion of the attribute in the hdf5 file and adding a novel attribute with the same name as before? If so, does that mean every time I reset an existing attribute the size of the hdf5 file is slightly increased and keeps slowly growing until my hard disk is full? If this is true, would it be more beneficial to check before I reset whether I have case (1) [and I should not store at all but compare data to the attribute written on disk] and only reassign if I face case (2) [i.e. the attribute value in the hdf5file is not the one I want to write to the hdf5 file]. Thanks a lot and best regards, Robert
Pytables, HDF5 Attribute setting and deletion,
1.2
0
0
986
18,645,394
2013-09-05T20:30:00.000
1
0
1
0
python,string
18,645,414
4
false
0
0
Enclose the entire string with """ or ''' (you would use ''' if the outermost quotation marks were ") in cases like these to make things simpler. """'"['BOS']"'"""
1
0
0
In Python how would I write the string '"['BOS']"'. I tried entering "\"['BOS']\"" but this gives the output '"[\'BOS\']"' with added backslashes in front of the '.
Multiple Quotes in String
0.049958
0
0
3,846
18,646,039
2013-09-05T21:12:00.000
1
0
1
0
python,enthought
18,647,689
2
false
0
0
Umair, ctrl + n or File > Python File will do what you want. Best, Jonathan
2
0
1
I am using Enthought canopy for data analysis. I didn't find any option to create a .py file to write my code and save it for later use. I tried File> New >IPython Notebook, wrote my code and saved it. But the next time I opened it within Canopy editor, it wasn't editable. I need something like a Python shell where you just open a 'New Window', write all your code and press F5 to execute it. It could be saved for later use as well. Although pandas and numpy work in canopy editor, they are not recognized by Python shell (whenever I write import pandas as pd, it says no module named pandas). Please help.
How to create a .py file within canopy?
0.099668
0
0
1,009
18,646,039
2013-09-05T21:12:00.000
1
0
1
0
python,enthought
19,578,868
2
false
0
0
Let me add that if you need to open the file, even if it's a text file but you want to be able to run it as a Python file (or whatever language format) just look at the bottom of the Canopy window and select the language you want to use. In some cases it may default to just text. Click it and select the language you want. Once you've done that, you'll see that the run button will be active and the command appear in their respective color.
2
0
1
I am using Enthought canopy for data analysis. I didn't find any option to create a .py file to write my code and save it for later use. I tried File> New >IPython Notebook, wrote my code and saved it. But the next time I opened it within Canopy editor, it wasn't editable. I need something like a Python shell where you just open a 'New Window', write all your code and press F5 to execute it. It could be saved for later use as well. Although pandas and numpy work in canopy editor, they are not recognized by Python shell (whenever I write import pandas as pd, it says no module named pandas). Please help.
How to create a .py file within canopy?
0.099668
0
0
1,009
18,646,885
2013-09-05T22:23:00.000
1
0
0
0
python,apple-push-notifications,celery,boto,amazon-sns
22,409,890
2
false
0
0
You should be reusing the SNS connection for best performance. That said, please ensure that you detect and re-establish the connection if it is closed.
1
1
0
I'm using boto and SNS to send push notifications to iOS. I've made a wrapper class, APNS, that keeps a long running boto.SNSConnection as a member variable. I'd like to have an instance of the APNS class as a global variable, so I can use celery to send push notifications in the background. Are there any problems with keeping a long running SNSConnection and re-using it, or should I be creating a new connection every time I want to publish a message?
Is having a long running boto SNSConnection a bad idea?
0.099668
0
0
252
18,647,154
2013-09-05T22:46:00.000
1
0
0
1
python,amazon-web-services,amazon-ec2,websocket
20,952,263
1
false
1
0
This could be caused by to a Chrome Extension.
1
0
0
I have a web socket server running on an Ubuntu 12.04 EC2 Instance. My web socket server is written in Python, I am using Autobahn WebSockets. I have a JavaScript client that uses WebRTC to capture webcam frames and send them to the web socket server. My webserver (where the JavaScript is hosted) is not deployed on EC2. The python web socket server only do video frame processing and is running over TCP and port 9000. My Problem: The JS client can connect to the web socket and the server receives and processes the webcam frames. However, after 5 or 6 minutes the client stops sending the frames and displaying the following message: WebSocket connection to 'ws://x.x.x.x:9000/' failed: Failed to send WebSocket frame. When I print the error data I got "undefined". Of course, this never happens when I run the server on my local testing environment.
JavaScript client failed to send WebSocket frame to WebSocket server on Amazon EC2
0.197375
0
1
1,419
18,647,897
2013-09-06T00:11:00.000
4
0
1
0
python,disassembly
18,663,296
3
true
0
0
The Python bytecode disassembler has no common use aside from curiosity or investigating details of the Python implementations. It's similar to how most C programmers never need to look at assembler, even though they are compiling C code to assembler and using debuggers like gdb. In Python's case, pdb (but also tracebacks and so on) all nicely hide the bytecode from the regular programmer's eyes. Of course, it can be fun to learn about it anyway. It's one way of getting a good idea about how Python really works :-)
2
3
0
I've noticed there is a significant degree of interest in Python disassemblers such as the dis module. However it is surprisingly difficult to find what these disassemblers are generally used for in industry/academia. Outside of satisfying curiosity (a perfectly legitimate endeavour!) or writing Python implementations do they have any common uses?
What are Python disassemblers used for?
1.2
0
0
269
18,647,897
2013-09-06T00:11:00.000
0
0
1
0
python,disassembly
26,515,207
3
false
0
0
If you want to look for a line of code in a machine language program, such as one causing an annoying popup or a piece of malware, a disassembler might help you find the piece of toxic code. Also,as Flornquake says, programs assembled by higher order languages like Python are sometimes not efficient. If you need a high speed program, say to read fast data coming from an outside device, you may well need to go into the assembled code and adjust it for maximum speed. An example might be digitizing a 20KHz music signal.
2
3
0
I've noticed there is a significant degree of interest in Python disassemblers such as the dis module. However it is surprisingly difficult to find what these disassemblers are generally used for in industry/academia. Outside of satisfying curiosity (a perfectly legitimate endeavour!) or writing Python implementations do they have any common uses?
What are Python disassemblers used for?
0
0
0
269
18,647,942
2013-09-06T00:17:00.000
4
0
1
0
python,api,maya,mel,pymel
18,669,643
2
true
0
0
While your answer will work theodox, I did find a much simpler resolution, after some serious digging! Turns out, hiding and not very well documented, was a function ironically called indices(), I did search for this but nothing came up in the docs. Pymel selection[0].indices()[0] The above will give us the integer of the selected edge. Simple and elegant!
1
1
0
Is there's a way to get the indices properly from a Pymel/Maya API function? I know Pymel has a function called getEdges() however according to their docs this get's them from the selected face, however I just need them from the selected edges. Is this possible?
How to get edge indices from selection?
1.2
0
0
2,796
18,650,551
2013-09-06T05:30:00.000
1
0
0
0
javascript,python,django,client-server,tastypie
18,650,699
1
true
1
0
A mobile client doesn't care if the Javascript comes from Django or any other web server. So go ahead and put all your JavaScript and static HTML on another server. If you want your mobile app to see if the user is logged in, it should make an AJAX call to your Django backend (where the request is authenticated). The data returned should indicate if the session is active (user is logged in). Another AJAX call can perform the Django logout function.
1
1
0
I'm using TastyPie and Django to build out my backend for an application that will have browser and mobile (native iOS) clients. I have been through the TastyPie and Django docs, can authenticate successfully either using the TastyPie resources I set up, or using Djangos built in views. I see a lot of examples on including the CSRF token on the page and grabbing it with your JavaScript, and that works, but I don't understand now to actually determine whether a user is logged in on initial page load (from JavaScript). Example: If I want to serve static HTML from a separate, fast web server, and cache my application JavaScript, and only interact with Django through TastyPie views, how do I determine if the user is logged in (and know to render a login form or the app views using JavaScript), and after logout, is there any session information I need to remove from the client browser? If I were to serve up HTML through Django's template engine, I could render the login form through there appropriately, but that seems not ideal if I want to truly decouple my JavaScript app from Django (and behave like a mobile client). Edit: I am using Backbone.js, but I don't think that should matter. UPDATE: I think I figured it out reading through Django's CSRF documentation again. If your view is not rendering a template containing the csrf_token template tag, Django might not set the CSRF token cookie. This is common in cases where forms are dynamically added to the page. To address this case, Django provides a view decorator which forces setting of the cookie: ensure_csrf_cookie(). If I do not want to render Django templates, this reads like I can still use the cookie and pull that into my Backbone or jQuery AJAX methods. I'm not sure if TastyPie ensures the cookie will be sent or how to tie into it. If I use AJAX to logout, will the cookie automatically be removed or does it become invalid? Are these CSRF tokens unique to each user session? I'll have to test some things tomorrow with it. Is it possible to use Django decorators on TastyPie views?
How to properly decouple Django from an AJAX application?
1.2
0
0
275
18,651,617
2013-09-06T06:49:00.000
0
0
0
0
python,django
18,655,003
1
false
1
0
Can't you specify the details of your development database in settings.py? This would connect you to the existing database and remove the need to create a new test instance.
1
0
0
How can I test my app in django, so that it connects to my local database and does NOT require me to create a test database?
Test an app in django and connect to local database
0
0
0
129
18,655,290
2013-09-06T10:12:00.000
0
0
1
0
python,sockets,asyncore
18,655,376
1
false
0
0
You can make one connection per socket at the same time only. But this doesn't mean that you can't do what you want to, however you'll need 2 sockets for 2 connections.
1
0
0
I have a class that implements the asyncore module, it serves as a client that connects to HOST_A. The problem is I need to pass the data received from HOST_A to a HOST_B. So i'm wondering if asyncore can create two socket connections to HOST_A and HOST_B.Is this possible?
Can python asyncore module handle/connect more than one socket?
0
0
1
283
18,657,777
2013-09-06T12:21:00.000
0
0
0
0
python,html
18,658,647
1
true
1
0
Flask. Just use Flask. Honestly you'll finish your project in 20 minutes.
1
0
0
I have a database that can be fetched using mysql query and send the data as response for an ajax jquery request. Which python framework would be best suitable to satisfy this primary need? Thanks in advance.
Light Weight Python Web FrameWork
1.2
0
0
379
18,659,656
2013-09-06T14:00:00.000
2
0
0
1
python,windows,pythonw
18,662,659
2
false
0
0
pythonw supresses the console window that is created when a python script is executed. Its intended for programs that open their own GUI. Without pythonw, a python gui app would have its regular windows plus an extra console floating around. I'm not sure what pythonw does to your stdout, but os.isatty() returns False and I assume stdout/err are just dumped into oblivion. If you run a DOS command like os.system("pause"), Windows creates a new console window for that command only. That's what you see on the screen. If you want to see your script output, you should either run with python.exe and add an input prompt at the end of the script as suggested by @GaryWalker, or use a gui toolkit like tcl/tk, Qt or wxPython.
1
0
0
I've written a script that works great at a command prompt, but it only displays the last line if I double click on the script.py icon on my desktop. The function in the script runs perfectly but once it finds a match it's supposed to display the output on the screen. At the end, I have an os.pause statement and THAT displays when the script is done, but nothing else displays on the screen. I AM executing it using pythonw.exe. What else should I check? Thank you.
Python script displays output in command window but nothing shows in Windows
0.197375
0
0
2,336
18,664,940
2013-09-06T19:11:00.000
-1
0
0
0
python,berkeley-db,bsddb
18,793,657
2
true
0
0
Well, there's no workaround. But you can use two approaches Store the integers as string using str or repr. If the ints are big, you can even use string formatting use cPickle/pickle module to store and retrieve data. This is a good way if you have data types other than basic types. For basics ints and floats this actually is slower and takes more space than just storing strings
1
0
0
I want to use BDB as a time-series data store, and planning to use the microseconds since epoch as the key values. I am using BTREE as the data store type. However, when I try to store integer keys, bsddb3 gives an error saying TypeError: Integer keys only allowed for Recno and Queue DB's. What is the best workaround? I can store them as strings, but that probably will make it unnecessarily slower. Given BDB itself can handle any kind of data, why is there a restriction? can I sorta hack the bsddb3 implementation? has anyone used anyother methods?
Use integer keys in Berkeley DB with python (using bsddb3)
1.2
1
0
689
18,666,243
2013-09-06T20:40:00.000
1
0
0
0
python,django,user-interface,packages
29,824,864
2
false
1
0
Use the bootstrap. I developed the django app too using the bootstrap and it works fine in all smartphone, tablet and desktop devices.
1
4
0
I've made a desktop-friendly django app and would prefer not to have to rewrite all of the html/css to allow proper view on mobile browsers. I'm on django 1.5 and python 2.7 Is there a package or library or quicker way to efficiently create a mobile version of my django (web) app instead of having to re-write a whole new template with html/css ? Thank you!
Convert Web Friendly Django app to a Mobile friendly django app
0.099668
0
0
4,667
18,668,736
2013-09-07T01:23:00.000
1
0
0
0
python,esky
18,676,400
1
true
0
0
Perhaps not possible. However, one can use the Appdata folder on Windows systems, and /etc folder on Linux systems.
1
1
0
I have an ini file that contains the configuration of my app. Esky creates new folders for the updated versions. How can I make sure that configuration file gets copied?
How can I move config file between esky updates?
1.2
0
0
113
18,669,374
2013-09-07T03:25:00.000
1
0
1
0
python,regex
18,669,461
2
false
1
0
I don't see why a collection of regexs wouldn't work. There are a variety of different formats, but there are really only a handful that are most common. With, say, a dozen easy regex, you could probably scrub 90% of the dates out there. Another (partial) approach would be to scan for month names and abbreviations, and then scan the surrounding text for days and year. For numeric-only, the hardest part would be figuring out whether it's month then date or date then month. So will be easy, if the date part is greater than 12, but otherwise there's not really anyway of knowing. You could also look for <time> elements with the datetime attribute, which is supposed to follow an unambiguous format (though not necessarily consistent). Bottom line, I don't think there is any one way to find all the dates in a document, unless you know they all follow the same format, which obviously isn't going to be the case in general. To have a good shot of finding them, you'll just need to employ several different strategies.
1
1
0
For html pages, and news-related pages especially, it would be very helpful and incredibly useful if there were a mechanism for parsing out the publication dates. Unfortunately, there is not one set regex/pattern for dates on the internet. CNN may publish it like MONTH DD, YYYY and HuffingtonPost may publish as MM/DD/YY, and so on. Does anyone have any strategies which are better than just pure regex parsing for extracting publication dates out of html pages? Thank you.
Python: Parsing out publication dates from html pages
0.099668
0
0
506
18,670,974
2013-09-07T07:35:00.000
1
0
0
0
python
18,687,144
2
false
0
0
Generically you can populate your points in two ways: 1) use random to create the coordinates for your points within the outer bounds of the solution. If a given random point falls outside the max or inside the inner limit. 2) You can do it using polar coordinates: generate a random distance between the inner and outer bound and a yaw rotation. In 3d, you'd have to use two rotations, one for yaw and another for pitch. This avoids the need for rejecting points. You can simplify the code for both by generating all the points in a circle (or sphere) around origin (0,0,0) instead of in place. Them move the whole set of points to the correct blue circle location by adding it's position to the position of each point.
1
3
1
I have to generate a various points and its xyz coordinates and then calculate the distance. Lets say I want create random point coordinates from point a away from 2.5 cm in all directions. so that i can calculate the mutual distance and angles form a to all generated point (red) I want to remove the redundant point and all those points which do not satisfy my criteria and also have same position. ![enter image description here][1] for example, I know the coordinates for the two points a (-10, 12, 2) and b (-9, 11, 5). The distance between a and b is 5 cm. The question is: How can I generate the red points' coordinates. I knew how to calculate the distance and angle. So far, I have tried the following calculation: I am not able to define the points randomly. I found a few solutions that don't work. Any help would be appreciated.
How to get a series of random points in a specific range of distances from a reference point and generate xyz coordinates
0.099668
0
0
5,337
18,671,253
2013-09-07T08:11:00.000
5
0
1
1
python,homebrew
18,674,756
9
false
0
0
Alternatively, you probably can just enter "python3" to run your most current version of python3.x and "python" or "python2" to run the latest installed 2.x version.
2
149
0
I need to be able to switch back and forth between Python 2 and 3. How do I do that using Homebrew as I don't want to mess with path and get into trouble. Right now I have 2.7 installed through Homebrew.
How can I use Homebrew to install both Python 2 and 3 on Mac?
0.110656
0
0
81,770
18,671,253
2013-09-07T08:11:00.000
1
0
1
1
python,homebrew
49,878,692
9
false
0
0
I thought I had the same requirement - to move between Python versions - but I achieved all I needed with only Python3.6 by building from source instead of using homebrew. git clone https://git.<theThingYouWantToInstall> Depending on the repo, check if there is MAKE file already setup for this option.
2
149
0
I need to be able to switch back and forth between Python 2 and 3. How do I do that using Homebrew as I don't want to mess with path and get into trouble. Right now I have 2.7 installed through Homebrew.
How can I use Homebrew to install both Python 2 and 3 on Mac?
0.022219
0
0
81,770
18,673,258
2013-09-07T12:21:00.000
2
1
1
0
python,ruby,compiler-construction,compilation,dynamic-languages
18,674,023
2
true
0
0
Yes, it is definitely possible to create compilers for dynamic languages. There are a myriad of examples of compilers for dynamic languages in the wild: CPython is an implementation of the Python programming language which has a Python compiler. PyPy is an implementation of the Python programming language which has a Python compiler. Jython is an implementation of the Python programming language which has a Python compiler. IronPython is an implementation of the Python programming language which has a Python compiler. Pynie is an implementation of the Python programming language which has a Python compiler. YARV is an implementation of the Ruby programming language which has a Ruby compiler. Rubinius is an implementation of the Ruby programming language which has a Ruby compiler. MacRuby is an implementation of the Ruby programming language which has a Ruby compiler. JRuby is an implementation of the Ruby programming language which has a Ruby compiler. IronRuby is an implementation of the Ruby programming language which has a Ruby compiler. MagLev is an implementation of the Ruby programming language which has a Ruby compiler. Quercus is an implementation of the PHP programming language which has a PHP compiler. P8 is an implementation of the PHP programming language which has a PHP compiler. V8 is an implementation of the ECMAScript programming language which has an ECMAScript compiler. In general, every language can be implemented by a compiler, and every language can be implemented by an interpreter. It is also possible to automatically derive a compiler from an interpreter and vice-versa. Most modern language implementations use both interpretation and compilation, sometimes even several compilers. Take Rubinius, for example: first Ruby code is compiled to Rubinius bytecode. Rubinius bytecode is then interpreted by the Rubinius VM. Code which has been interpreted several times is then compiled to Rubinius Compiler IR, which is then compiled to LLVM IR, which is then compiled to "native code" (whatever that is). So, Rubinius has one interpreter and three compilers. V8 is a different example. It actually has no interpreter, but two different compilers: one very fast, very memory-efficient compiler which produces unoptimized, somewhat slow code. Code which has been run multiple times is then thrown away, and compiled again with the second compiler, which produces aggressively optimized code but takes more time and uses more memory during compilation. However, in the end, you cannot run code without an interpreter. A compiler cannot run code. A compiler translates a program from one language into a different language. That's it. You can translate all you want, in the end, something has to run the code, and that thing is an interpreter. It might be implemented in software or in silicon, but it still is an interpreter.
1
3
0
Are there some set of reasons that make it impossible for dynamic languages ​​such as Python or Ruby to be compiled instead of interpreted without losing any of his dynamics characteristics? Of course one the requirements to that hypothetical compiler is that those languages doesn't lose any of his characteristics like metaprogramming, extend objects, add code or modify type system in runtime. Summarizing, it is possible to create a Ruby or Python compiler without losing any of his characteristics as dynamic programming languages?
It is possible to create compilers for dynamic languages without losing his dynamic characteristics?
1.2
0
0
509
18,673,426
2013-09-07T12:41:00.000
0
1
0
0
python,nfc,raspberry-pi,mifare
20,600,986
2
false
0
0
I built an application on the Raspberry Pi to read and write RFid cards. The easiest way to do it is to use the pcscd library and java. There are good examples on the Oracle website and the pcscd library is broadly supported. Be aware though. The usb cardreader I used did not seem to work initially. The cardreader uses to much power for the USB ports of the raspberry. When I used a powered usb hub, things worked smoothly. Fred
1
1
0
So i bought a cheap mifare NFC chip reader from ebay for 5$. I wanted to play around with chips, and ultimately copy some NFC chips i have here. I have a NFC chip that I use to open my locker with on school, but the card we have is really big and inconvient, so I want to copy it on a smaller NFC chip and put it on my keyring. So i hooked it up with my raspberry pi, and first off, there is NOTHING on internet about connecting this card with your raspberry pi. Ohwell, a challange, fun. I found some basic code from a spanish website(im dutch so itwas kinda hard to understand :P) but it can only read the UID of a NFC. So i tried to understand it, and eventually i did, and I added the code to calculateCRC and read some blocks. However, I have no clue how the NFC data structure actually works, all i did was find some arduino code samples that were in C, translated them to python, and I think it works. So i setted it up that it reads block 0 to 8 and prints themn all. On all the NFCs i have I can only read block 0, rest is giving an error. And block 0 consists of one byte, that's a 0x04. If anyone has any clue what is happening, please tell me. And are there any links were NFC data structure is actually explained. I found a bunch of Android stuff, but i dont have a smartphone, and i want to do it with this MFRC522 card. I read somewhere you need to auth a block or something? I saw some code for that too, but how does that work? How do I know the keys? thanks
NFC tag reading in python on raspberry pi
0
0
0
10,270
18,674,630
2013-09-07T15:02:00.000
0
0
0
0
python,persistence
18,674,706
1
false
1
0
Martijn's suggestion could be one of the alternatives. You may consider to store the pickle objects directly in a sqlite database which still can manage from the python standard library. Use a StringIO object to convert between the database column and python object. You didn't mention the size of each object you are pickling now. I guess it should stay well within sqlite's limit.
1
0
0
I have some code that I am working on that scrapes some data from a website, and then extracts certain key information from that website and stores it in an object. I create a couple hundred of these objects each day, each from unique url's. This is working quite well, however, I'm inexperienced in what options are available to me in Python for persistence and what would be best suited for my needs. Currently I am using pickle. To do so, I am keeping all of these webpage objects and appending them in a list as new ones are created, then saving that list to a pickle (then reloading it whenever the list is to be updated). However, as i'm in the order of some GB of data, i'm finding pickle to be somewhat slow. It's not unworkable, but I'm wondering if there is a more well suited alternative. I don't really want to break apart the structure of my objects and store it in a sql type database, as its important for me to keep the methods and the data as a single object. Shelve is one option I've been looking into, as my impression is then that I wouldn't have to unpickle and pickle all the old entries (just the most recent day that needs to be updated), but am unsure if this is how shelve works, and how fast it is. So to avoid rambling on, my question is: what is the preferred persistence method for storing a large number of objects (all of the same type), to keep read/write speed up as the collection grows?
Persistence of a large number of objects
0
1
0
95
18,686,796
2013-09-08T17:51:00.000
1
0
1
1
python,c,pthreads,multiprocessing,named-pipes
22,251,245
1
true
0
0
Answering my own question: I've implemented this (a while back) using option 4. Works good, very stable. Releasing the GIL wasn't happening in my first attempt, because I didn't initialize threading. After that, smooth sailing.
1
0
0
I'd like people's opinion on which direction to choose between different solutions to implement inter-thread named-pipe communication. I'm working on a solution for the following: A 3rd party binary on AIX calls a shared object. I build this shared object using the python 2.7.5 api, so I have a python thread (64 bit). So the stack is: 3rd p binary -> my shared object / dll 'python-bridge' -> python 2.7.5 interpreter (persistent) From custom code inside the 3rd party binary (in a propriatary language), I initialize the python interpreter through the python-bridge, precompile python code blocks through the python-bridge, and execute these bits of code using PyEval_EvalCode in the bridge. The python interpreter stays alive during the session, and is closed just before the session ends. Simple sequential python code works fine, and fast. After the call to the shared object method, python references are all decreased (inside the method) and no garbage remains. The precompiled python module stays in memory, works fine. However, I also need to interact with streaming data of the main executable. That executable (of which I don't have the source code) supports fifo through a named pipe, which I want to use for inter-thread communication. Since the named pipe is blocking, I need a separate thread. I came up with 3 or 4 alternatives (feel free to give more suggestions) Use the multiprocess module within python Make my own C thread, using pthread_create, and use python in there (carefully, I know about the non-threadsafe issues) Make my own C thread, using pthread_create, parse the named pipe from C, and calling the python interpreter main thread from there (maybe possible?) use the simpler Threading module of python (which isn't 'pure' threading), and release the GIL at the end of the API call to the bridge. (haven't dared to do this, need someone with insight here. Simple test with Threading and sleep shows it's working within the python call, but the named pipe Thread does nothing after returning to the main non-python process) What do you suggest? I'm trying option 1 at the moment, with some success, but it 'feels' a bit bloated to spawn a new process just for parsing a named pipe. Thanks for your help, Tijs
Embedded CPython, thread interaction using named pipe
1.2
0
0
157
18,693,208
2013-09-09T07:17:00.000
1
0
1
0
python,watchdog
18,693,572
1
true
0
0
You can add a tag such as an observer name when you create the event. Python events can have almost any type of data added as named members and then access by the handler.
1
0
0
I'm using same event handler for multiple watchdog observers. I need to know, event is generated for which observer when file/dir is created.
Python watchdog. Need to know the observer
1.2
0
0
168
18,700,969
2013-09-09T14:48:00.000
0
0
0
0
python,openerp,restrict
18,828,239
1
false
1
0
For your cases: You can try using Many2Many relation so as to choose the record of users. Use Groups to obtain your desired result. For example: <field name="user_id" groups="your_group" /> By doing this you can provide what fields to be visible to which user based on access rights provided in your GROUPS.
1
0
0
I'm facing a complex problem, at least for me. I have a form called "Task", which contains all the normal info, and I would like to add users to that Task. If I want to add multiple users to that task, I should use the widget one2many, am I right? If so, is it possible to display a dropdown or something and add the users already registered? Because, with the default one2many, I have to register the users (like a Form) and then I can add them..but if they are already in the table, it should appear me a dropdown menu or something.. After the task is created, the users should only see the task with their name, only administrator can view it all. I think that to achieve this I need to create rules, right? If so, do I need to create them by code or could I use the openERP rule menu? And this will be enough: ('user_id', '=', user.id)]? The first column "user_id" is created on "Task" table? I do not need to have a auxiliary table that would contain something like: id, task_id, id_user..and by this I could get which tasks belongs to whichs users?? Thanks guys
openERP restrict users
0
0
0
404
18,701,464
2013-09-09T15:11:00.000
1
0
1
0
python,beautifulsoup,windows-7-x64
18,701,653
3
false
1
0
You just need to add to download it and add it to your python search path directly. (Which is in sys.path, if you need to check it.) From the documentation: Beautiful Soup is licensed under the MIT license, so you can also download the tarball, drop the bs4/ directory into almost any Python application (or into your library path) and start using it immediately. (If you want to do this under Python 3, you will need to manually convert the code using 2to3.)
1
0
0
I wanted to write a program to scrape a website from python. Since there is no built-in possibility to do so, I decided to give the BeautifulSoup module a try. Unfortunately I encountered some problems using pip and ez_install, since I use Windows 7 64 bit and Python 3.3. Is there a way to get the BeautifulSoup module on my Python 3.3 installation with Windows 7 64x without ez_install or easy_install, since I have too much trouble with this, or is there an alternative module which can be easily installed?
BeautifulSoup installation or alternative without easy_install
0.066568
0
0
4,503
18,703,136
2013-09-09T16:49:00.000
19
0
0
0
python,scikit-learn,random-forest
18,719,287
3
true
0
0
We don't implement proximity matrix in Scikit-Learn (yet). However, this could be done by relying on the apply function provided in our implementation of decision trees. That is, for all pairs of samples in your dataset, iterate over the decision trees in the forest (through forest.estimators_) and count the number of times they fall in the same leaf, i.e., the number of times apply give the same node id for both samples in the pair. Hope this helps.
1
14
1
I'm trying to perform clustering in Python using Random Forests. In the R implementation of Random Forests, there is a flag you can set to get the proximity matrix. I can't seem to find anything similar in the python scikit version of Random Forest. Does anyone know if there is an equivalent calculation for the python version?
Proximity Matrix in sklearn.ensemble.RandomForestClassifier
1.2
0
0
6,625
18,704,175
2013-09-09T17:59:00.000
4
0
1
0
ipython,offline
18,708,798
1
false
0
0
Yes, it should work without needing an internet connection. If a browser tab doesn't open automatically, open a browser and go to the URL it gives you in the terminal where you started the notebook (by default, this is http://127.0.0.1:8888/ ). It uses the 'loopback' network interface, which stays within your own computer.
1
3
0
Can ipython notebook be used when not connected to the internet? My installation doesn't open a web browser tab if not online. Thanks!
Using ipython notebook offline
0.664037
0
1
24,898
18,705,107
2013-09-09T19:02:00.000
0
0
0
0
python,django,pycharm
18,716,562
1
true
1
0
OK, I've found solution. If you want to launch many test suits with one test launcher in PyCharm, you should add names of your applications separated by a space to Target field of your Django tests Run/Debug configuration.
1
1
0
I've Django project with two applications with added unit tests (django.test.TestCase). In PyCharm I have created two Django test launchers (one for every app). In this configuration everything works correctly. Now I want to create one test launcher, which will be able to start unit test for both applications at once. Is it possible?
Run unit tests for two Django applications in PyCharm
1.2
0
0
701
18,705,223
2013-09-09T19:09:00.000
0
0
0
0
python,ruby,data-mining,data-analysis
18,712,558
2
true
0
0
Sounds like a classic matrix factorization task to me. With a weighted matrix, instead of a binary one. So some fast algorithms may not be applicable, because they support binary matrixes only. Don't ask for source on Stackoverflow: asking for off-site resources (tools, libraries, ...) is off-topic.
1
0
0
For a music project I want to find what which groups of artists users listens to. I have extracted three columns from the database: the ID of the artist, the ID of the user, and the percentage of all the users stream that is connected to that artist. E.g. Half of the plays from user 15, is of the artist 12. 12 | 15 | 0.5 What I hope to find is a methodology to group clusters of groups together, so e.g. find out that users who tends to listen to artist 12 also listens to 65, 74, and 34. I wonder what kind of methodologies that can be used for this grouping, and if there are any good sources for this approach (Python or Ruby would be great).
Data Mining: grouping based on two text values (IDs) and one numeric (ratio)
1.2
1
0
261
18,706,059
2013-09-09T20:01:00.000
1
0
1
0
ipython-notebook
18,712,352
1
false
0
0
We want to support this in metadata at notebook top level, but nobody has taken time to write a proposal for metadata structure, how to edit it, and how to show it. This would be usefull for view on nbviewer, but also for conversion to LaTeX, and other format. It might just be slightly more complicated that at first thought, as you probably want the Authors to be more that just first name/last name (like a full embeded vcard for example). If you want to work on that you are welcomed, otherwise in the meantime I suggest adding a simple markdown cell at top with those info. This should be easy to do on a buch on notebook at once as they are easy parsable json.
1
3
0
I'd like to pre-pend a simple author and copyright clause the beginning of newly created ipython notebooks. Is this possible? If so how can it be done?
How can I automatically add author and copyright info to newly created ipython notebooks?
0.197375
0
0
1,779
18,711,451
2013-09-10T05:43:00.000
2
0
0
0
python,user-interface,wxpython,pyqt
18,732,393
1
true
0
1
The simple answer is, no. Or, if it is possible, it's certainly not easy. Although there are many similarities in look and function between wxPython and PyQt, under the hood they are essentially different.
1
0
0
I want to use Grid from wxpython and use it in my GUI which is based on PyQt. Is it possible?
Can wxpython and PyQt be used together in same GUI?
1.2
0
0
264
18,711,815
2013-09-10T06:12:00.000
5
0
0
0
python,html,plone
18,714,130
1
true
1
1
You can create a static text portlet in that context you need it: folder, page.
1
0
0
Hi want to add text box and label in plone site but, that plone site does not display text box how can i create text box in plone site thanks!
How to create text box in plone site
1.2
0
0
111
18,715,563
2013-09-10T09:44:00.000
2
0
1
0
python,text-to-speech
21,506,735
1
true
0
0
Yes, neospeech is a language library. By installing it, you can just set the voice of pyttsx and tts Chinese as well.
1
2
0
I want to know how to text-to-speech Chinese using the python package 'pyttsx'. It seems to need some other modules like neospeech.
How to TTS Chinese using pyttsx
1.2
0
0
2,532