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
3,265,062
2010-07-16T13:02:00.000
0
1
0
0
python,cookies,selenium,selenium-rc
3,314,427
2
false
0
0
Yes, sure. Look at getCookie, getCookieByName and createCookie methods.
1
2
0
I'm running complex tests that create many cookies for different sections of my web site. Occasionally I have to restart the browser in the middle a long test and since the Selenium server doesn't modify the base Firefox profile, the cookies evaporate. Is there any way I can save all of the cookies to a Python variable before terminating the browser and restore them after starting a new browser instance?
How to save and restore all cookies with Selenium RC?
0
0
1
1,991
3,265,232
2010-07-16T13:22:00.000
0
0
1
0
python,c,api
3,265,387
2
false
0
0
If you don't want to actively check the value of a PyObject in your C code, I think you need to export functions to modify the representation in C. I'm no expert, but I don't think there's an automatic mapping.
1
2
0
I have an embedded python interpreter in my program. I'd like to export a module with values defined in my program and be able to change them from a python script. e.g. in c: int x = 1; in python: import embedded embedded.x = 2 in c: printf("%d",x); output: 2 Is this possible or do I have to export functions to change anything in c?
Changing C variables from python?
0
0
0
220
3,265,357
2010-07-16T13:35:00.000
497
1
1
0
java,python,compiler-construction,programming-languages,interpreter
3,265,602
13
true
0
0
A compiled language is one where the program, once compiled, is expressed in the instructions of the target machine. For example, an addition "+" operation in your source code could be translated directly to the "ADD" instruction in machine code. An interpreted language is one where the instructions are not directly executed by the target machine, but instead read and executed by some other program (which normally is written in the language of the native machine). For example, the same "+" operation would be recognised by the interpreter at run time, which would then call its own "add(a,b)" function with the appropriate arguments, which would then execute the machine code "ADD" instruction. You can do anything that you can do in an interpreted language in a compiled language and vice-versa - they are both Turing complete. Both however have advantages and disadvantages for implementation and use. I'm going to completely generalise (purists forgive me!) but, roughly, here are the advantages of compiled languages: Faster performance by directly using the native code of the target machine Opportunity to apply quite powerful optimisations during the compile stage And here are the advantages of interpreted languages: Easier to implement (writing good compilers is very hard!!) No need to run a compilation stage: can execute code directly "on the fly" Can be more convenient for dynamic languages Note that modern techniques such as bytecode compilation add some extra complexity - what happens here is that the compiler targets a "virtual machine" which is not the same as the underlying hardware. These virtual machine instructions can then be compiled again at a later stage to get native code (e.g. as done by the Java JVM JIT compiler).
10
312
0
I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?
Compiled vs. Interpreted Languages
1.2
0
0
246,100
3,265,357
2010-07-16T13:35:00.000
2
1
1
0
java,python,compiler-construction,programming-languages,interpreter
3,265,475
13
false
0
0
It's rather difficult to give a practical answer because the difference is about the language definition itself. It's possible to build an interpreter for every compiled language, but it's not possible to build an compiler for every interpreted language. It's very much about the formal definition of a language. So that theoretical informatics stuff noboby likes at university.
10
312
0
I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?
Compiled vs. Interpreted Languages
0.03076
0
0
246,100
3,265,357
2010-07-16T13:35:00.000
11
1
1
0
java,python,compiler-construction,programming-languages,interpreter
23,750,310
13
false
0
0
The biggest advantage of interpreted source code over compiled source code is PORTABILITY. If your source code is compiled, you need to compile a different executable for each type of processor and/or platform that you want your program to run on (e.g. one for Windows x86, one for Windows x64, one for Linux x64, and so on). Furthermore, unless your code is completely standards compliant and does not use any platform-specific functions/libraries, you will actually need to write and maintain multiple code bases! If your source code is interpreted, you only need to write it once and it can be interpreted and executed by an appropriate interpreter on any platform! It's portable! Note that an interpreter itself is an executable program that is written and compiled for a specific platform. An advantage of compiled code is that it hides the source code from the end user (which might be intellectual property) because instead of deploying the original human-readable source code, you deploy an obscure binary executable file.
10
312
0
I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?
Compiled vs. Interpreted Languages
1
0
0
246,100
3,265,357
2010-07-16T13:35:00.000
5
1
1
0
java,python,compiler-construction,programming-languages,interpreter
3,265,433
13
false
0
0
First, a clarification, Java is not fully static-compiled and linked in the way C++. It is compiled into bytecode, which is then interpreted by a JVM. The JVM can go and do just-in-time compilation to the native machine language, but doesn't have to do it. More to the point: I think interactivity is the main practical difference. Since everything is interpreted, you can take a small excerpt of code, parse and run it against the current state of the environment. Thus, if you had already executed code that initialized a variable, you would have access to that variable, etc. It really lends itself way to things like the functional style. Interpretation, however, costs a lot, especially when you have a large system with a lot of references and context. By definition, it is wasteful because identical code may have to be interpreted and optimized twice (although most runtimes have some caching and optimizations for that). Still, you pay a runtime cost and often need a runtime environment. You are also less likely to see complex interprocedural optimizations because at present their performance is not sufficiently interactive. Therefore, for large systems that are not going to change much, and for certain languages, it makes more sense to precompile and prelink everything, do all the optimizations that you can do. This ends up with a very lean runtime that is already optimized for the target machine. As for generating executables, that has little to do with it, IMHO. You can often create an executable from a compiled language. But you can also create an executable from an interpreted language, except that the interpreter and runtime is already packaged in the exectuable and hidden from you. This means that you generally still pay the runtime costs (although I am sure that for some language there are ways to translate everything to a tree executable). I disagree that all languages could be made interactive. Certain languages, like C, are so tied to the machine and the entire link structure that I'm not sure you can build a meaningful fully-fledged interactive version
10
312
0
I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?
Compiled vs. Interpreted Languages
0.076772
0
0
246,100
3,265,357
2010-07-16T13:35:00.000
64
1
1
0
java,python,compiler-construction,programming-languages,interpreter
3,266,025
13
false
0
0
Start thinking in terms of a: blast from the past Once upon a time, long long ago, there lived in the land of computing interpreters and compilers. All kinds of fuss ensued over the merits of one over the other. The general opinion at that time was something along the lines of: Interpreter: Fast to develop (edit and run). Slow to execute because each statement had to be interpreted into machine code every time it was executed (think of what this meant for a loop executed thousands of times). Compiler: Slow to develop (edit, compile, link and run. The compile/link steps could take serious time). Fast to execute. The whole program was already in native machine code. A one or two order of magnitude difference in the runtime performance existed between an interpreted program and a compiled program. Other distinguishing points, run-time mutability of the code for example, were also of some interest but the major distinction revolved around the run-time performance issues. Today the landscape has evolved to such an extent that the compiled/interpreted distinction is pretty much irrelevant. Many compiled languages call upon run-time services that are not completely machine code based. Also, most interpreted languages are "compiled" into byte-code before execution. Byte-code interpreters can be very efficient and rival some compiler generated code from an execution speed point of view. The classic difference is that compilers generated native machine code, interpreters read source code and generated machine code on the fly using some sort of run-time system. Today there are very few classic interpreters left - almost all of them compile into byte-code (or some other semi-compiled state) which then runs on a virtual "machine".
10
312
0
I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?
Compiled vs. Interpreted Languages
1
0
0
246,100
3,265,357
2010-07-16T13:35:00.000
103
1
1
0
java,python,compiler-construction,programming-languages,interpreter
3,265,680
13
false
0
0
A language itself is neither compiled nor interpreted, only a specific implementation of a language is. Java is a perfect example. There is a bytecode-based platform (the JVM), a native compiler (gcj) and an interpeter for a superset of Java (bsh). So what is Java now? Bytecode-compiled, native-compiled or interpreted? Other languages, which are compiled as well as interpreted, are Scala, Haskell or Ocaml. Each of these languages has an interactive interpreter, as well as a compiler to byte-code or native machine code. So generally categorizing languages by "compiled" and "interpreted" doesn't make much sense.
10
312
0
I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?
Compiled vs. Interpreted Languages
1
0
0
246,100
3,265,357
2010-07-16T13:35:00.000
1
1
1
0
java,python,compiler-construction,programming-languages,interpreter
45,730,878
13
false
0
0
Compile is the process of creating an executable program from code written in a compiled programming language. Compiling allows the computer to run and understand the program without the need of the programming software used to create it. When a program is compiled it is often compiled for a specific platform (e.g. IBM platform) that works with IBM compatible computers, but not other platforms (e.g. Apple platform). The first compiler was developed by Grace Hopper while working on the Harvard Mark I computer. Today, most high-level languages will include their own compiler or have toolkits available that can be used to compile the program. A good example of a compiler used with Java is Eclipse and an example of a compiler used with C and C++ is the gcc command. Depending on how big the program is it should take a few seconds or minutes to compile and if no errors are encountered while being compiled an executable file is created.check this information
10
312
0
I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?
Compiled vs. Interpreted Languages
0.015383
0
0
246,100
3,265,357
2010-07-16T13:35:00.000
28
1
1
0
java,python,compiler-construction,programming-languages,interpreter
3,265,505
13
false
0
0
The extreme and simple cases: A compiler will produce a binary executable in the target machine's native executable format. This binary file contains all required resources except for system libraries; it's ready to run with no further preparation and processing and it runs like lightning because the code is the native code for the CPU on the target machine. An interpreter will present the user with a prompt in a loop where he can enter statements or code, and upon hitting RUN or the equivalent the interpreter will examine, scan, parse and interpretatively execute each line until the program runs to a stopping point or an error. Because each line is treated on its own and the interpreter doesn't "learn" anything from having seen the line before, the effort of converting human-readable language to machine instructions is incurred every time for every line, so it's dog slow. On the bright side, the user can inspect and otherwise interact with his program in all kinds of ways: Changing variables, changing code, running in trace or debug modes... whatever. With those out of the way, let me explain that life ain't so simple any more. For instance, Many interpreters will pre-compile the code they're given so the translation step doesn't have to be repeated again and again. Some compilers compile not to CPU-specific machine instructions but to bytecode, a kind of artificial machine code for a ficticious machine. This makes the compiled program a bit more portable, but requires a bytecode interpreter on every target system. The bytecode interpreters (I'm looking at Java here) recently tend to re-compile the bytecode they get for the CPU of the target section just before execution (called JIT). To save time, this is often only done for code that runs often (hotspots). Some systems that look and act like interpreters (Clojure, for instance) compile any code they get, immediately, but allow interactive access to the program's environment. That's basically the convenience of interpreters with the speed of binary compilation. Some compilers don't really compile, they just pre-digest and compress code. I heard a while back that's how Perl works. So sometimes the compiler is just doing a bit of the work and most of it is still interpretation. In the end, these days, interpreting vs. compiling is a trade-off, with time spent (once) compiling often being rewarded by better runtime performance, but an interpretative environment giving more opportunities for interaction. Compiling vs. interpreting is mostly a matter of how the work of "understanding" the program is divided up between different processes, and the line is a bit blurry these days as languages and products try to offer the best of both worlds.
10
312
0
I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?
Compiled vs. Interpreted Languages
1
0
0
246,100
3,265,357
2010-07-16T13:35:00.000
8
1
1
0
java,python,compiler-construction,programming-languages,interpreter
3,265,615
13
false
0
0
A compiler and an interpreter do the same job: translating a programming language to another pgoramming language, usually closer to the hardware, often direct executable machine code. Traditionally, "compiled" means that this translation happens all in one go, is done by a developer, and the resulting executable is distributed to users. Pure example: C++. Compilation usually takes pretty long and tries to do lots of expensive optmization so that the resulting executable runs faster. End users don't have the tools and knowledge to compile stuff themselves, and the executable often has to run on a variety of hardware, so you can't do many hardware-specific optimizations. During development, the separate compilation step means a longer feedback cycle. Traditionally, "interpreted" means that the translation happens "on the fly", when the user wants to run the program. Pure example: vanilla PHP. A naive interpreter has to parse and translate every piece of code every time it runs, which makes it very slow. It can't do complex, costly optimizations because they'd take longer than the time saved in execution. But it can fully use the capabilities of the hardware it runs on. The lack of a separrate compilation step reduces feedback time during development. But nowadays "compiled vs. interpreted" is not a black-or-white issue, there are shades in between. Naive, simple interpreters are pretty much extinct. Many languages use a two-step process where the high-level code is translated to a platform-independant bytecode (which is much faster to interpret). Then you have "just in time compilers" which compile code at most once per program run, sometimes cache results, and even intelligently decide to interpret code that's run rarely, and do powerful optimizations for code that runs a lot. During development, debuggers are capable of switching code inside a running program even for traditionally compiled languages.
10
312
0
I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?
Compiled vs. Interpreted Languages
1
0
0
246,100
3,265,357
2010-07-16T13:35:00.000
2
1
1
0
java,python,compiler-construction,programming-languages,interpreter
39,558,017
13
false
0
0
The Python Book © 2015 Imagine Publishing Ltd, simply distunguishes the difference by the following hint mentioned in page 10 as: An interpreted language such as Python is one where the source code is converted to machine code and then executed each time the program runs. This is different from a compiled language such as C, where the source code is only converted to machine code once – the resulting machine code is then executed each time the program runs.
10
312
0
I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?
Compiled vs. Interpreted Languages
0.03076
0
0
246,100
3,266,005
2010-07-16T14:41:00.000
4
0
1
1
python,macos,installation
3,267,460
3
true
0
0
The python.org Python installer for OS X is a meta package with a set of several packages. You can see the packages by clicking on the Customize button during the installation process. The symlinks in /usr/local/bin are installed by the UNIX command-line tools package. For the 2.7 release, that package is no longer selected by default. You can install it and the symlinks by doing a custom install and selecting that package; if you've already installed 2.7, select just that package. EDIT: That said, it is important to recognize that, with OS X Python framework builds, just having /usr/local/bin in your search path is generally not sufficient. The reason for that is that python scripts included in packages are, by default, installed into the bin directory of the Python directory, e.g. /Library/Frameworks/Python.framework/Versions/2.7/bin. This is true of just about anything that uses Distutils defaults or installation tools that wrap Distutils, like easy_install (Distribute or setuptools) or pip. This is why there is another installer package, Shell profile updater, that is enabled by default and attempts to modify your login profile to put the framework bin directory at the front of your shell search path, PATH. If that is done, the symlinks in /usr/local/bin are not required for python2.7 to be invoked.
1
5
0
The Python 2.7 installer disk image for Mac OS X (python-2.7-macosx10.5.dmg) states: The installer puts the applications in "Python 2.7" in your Applications folder, command-line tools in /usr/local/bin and the underlying machinery in /Library/Frameworks/Python.framework. However, after installation there are no Python 2.7 files in /usr/local/bin/. Are others seeing the same behavior? I assume the solution is simply to create the equivalent symbolic links to /usr/local/bin as Python 2.6, or am I overlooking something?
Why aren't the Python 2.7 command-line tools located in `/usr/local/bin` on Mac OS X?
1.2
0
0
7,190
3,266,180
2010-07-16T15:00:00.000
1
0
1
0
python,iterator,generator
30,341,833
16
false
0
0
list(generator()) returns all remaining values for a generator and effectively resets it if it is not looped.
3
159
0
Can I reset an iterator / generator in Python? I am using DictReader and would like to reset it to the beginning of the file.
Can iterators be reset in Python?
0.012499
0
0
123,812
3,266,180
2010-07-16T15:00:00.000
28
0
1
0
python,iterator,generator
3,266,353
16
false
0
0
No. Python's iterator protocol is very simple, and only provides one single method (.next() or __next__()), and no method to reset an iterator in general. The common pattern is to instead create a new iterator using the same procedure again. If you want to "save off" an iterator so that you can go back to its beginning, you may also fork the iterator by using itertools.tee
3
159
0
Can I reset an iterator / generator in Python? I am using DictReader and would like to reset it to the beginning of the file.
Can iterators be reset in Python?
1
0
0
123,812
3,266,180
2010-07-16T15:00:00.000
0
0
1
0
python,iterator,generator
3,266,198
16
false
0
0
Only if the underlying type provides a mechanism for doing so (e.g. fp.seek(0)).
3
159
0
Can I reset an iterator / generator in Python? I am using DictReader and would like to reset it to the beginning of the file.
Can iterators be reset in Python?
0
0
0
123,812
3,266,223
2010-07-16T15:06:00.000
3
1
1
0
javascript,python
3,266,895
12
false
1
0
Python’s a good second language to learn after JavaScript, as they have a reasonable number of similarities, e.g. they’re both memory-managed they have similar data structures — JavaScript’s objects and arrays are much like Python’s dictionaries and arrays they’re both used quite a lot for web-related work — JavaScript in the browser and in server-side contexts like node.js, Python in web frameworks like Django. However, Python’s object-oriented... stuff is quite different to JavaScript’s protoype-based object-oriented stuff. If the only programming you do is manipulating web pages within the web browser, then Python won’t be of any direct use to you (only JavaScript runs in browsers at the moment). But learning another programming language generally gives you new ways to think about the languages you already know. Learning Python could help you write better JavaScript.
9
25
0
I recently learned JavaScript an all of the sudden I hear about Python... Should I go learn Python or just stick with my basic JavaScript knowledge? If you have some "facts" I would love to hear them! Like efficiency, difficultylevel and so on, an so on... Thanks :)
Python over JavaScript? (Facts, please)
0.049958
0
0
65,637
3,266,223
2010-07-16T15:06:00.000
-2
1
1
0
javascript,python
3,266,975
12
false
1
0
If you need to ask, then I would say no since you don't have a need in mind for its usage.
9
25
0
I recently learned JavaScript an all of the sudden I hear about Python... Should I go learn Python or just stick with my basic JavaScript knowledge? If you have some "facts" I would love to hear them! Like efficiency, difficultylevel and so on, an so on... Thanks :)
Python over JavaScript? (Facts, please)
-0.033321
0
0
65,637
3,266,223
2010-07-16T15:06:00.000
0
1
1
0
javascript,python
3,266,781
12
false
1
0
Along with Python generally being server-side and JavaScript client-side, Python was designed to not only be easy to learn, but also easy to read, and to encourage a more productive environment.
9
25
0
I recently learned JavaScript an all of the sudden I hear about Python... Should I go learn Python or just stick with my basic JavaScript knowledge? If you have some "facts" I would love to hear them! Like efficiency, difficultylevel and so on, an so on... Thanks :)
Python over JavaScript? (Facts, please)
0
0
0
65,637
3,266,223
2010-07-16T15:06:00.000
2
1
1
0
javascript,python
3,266,281
12
false
1
0
JavaScript is usually used as a client-side scripting language - that is, it gets downloaded and executed by your browser. Python, however, is usually not coupled to the web. it can be used as a server-side scripting language, and for scripts and applications of any kind. But it is not a client-side language, and is therefore not directly comparable to Javascript, which has an entirely different audience. Looking at the language level, Javascript is terrible and dysfunctional (hard to debug, clumsy object-orientation) while Python is beautiful and expressive. This is, of course, subjective :-)
9
25
0
I recently learned JavaScript an all of the sudden I hear about Python... Should I go learn Python or just stick with my basic JavaScript knowledge? If you have some "facts" I would love to hear them! Like efficiency, difficultylevel and so on, an so on... Thanks :)
Python over JavaScript? (Facts, please)
0.033321
0
0
65,637
3,266,223
2010-07-16T15:06:00.000
0
1
1
0
javascript,python
3,266,294
12
false
1
0
It depends. Do you want to program in a language that specifically targets web browsers? Stick with Javascript Do you want to write... well anything besides for web browsers? Learn Python. Python is an excellent beginner language that's not just a beginner language. Google uses it, NASA uses it, and many, many other organizations use Python.
9
25
0
I recently learned JavaScript an all of the sudden I hear about Python... Should I go learn Python or just stick with my basic JavaScript knowledge? If you have some "facts" I would love to hear them! Like efficiency, difficultylevel and so on, an so on... Thanks :)
Python over JavaScript? (Facts, please)
0
0
0
65,637
3,266,223
2010-07-16T15:06:00.000
1
1
1
0
javascript,python
3,266,271
12
false
1
0
IMO Python may be easier to learn (having taught both to intro classes). Also, one major annoyance of JavaScript is that in runs in your browser. This inherently makes it much harder to debug problems. In terms of a production-level language, Python is more of a general purpose programming language, while JavaScript is targeted at building dynamic web applications. If you want to get into programming, you should definitely learn a more general purpose language such as Java or Python.
9
25
0
I recently learned JavaScript an all of the sudden I hear about Python... Should I go learn Python or just stick with my basic JavaScript knowledge? If you have some "facts" I would love to hear them! Like efficiency, difficultylevel and so on, an so on... Thanks :)
Python over JavaScript? (Facts, please)
0.016665
0
0
65,637
3,266,223
2010-07-16T15:06:00.000
15
1
1
0
javascript,python
3,266,248
12
false
1
0
The two are generally used quite differently. Javascript is primarily used as a client side scripting language vs python which is a server based language. So in a website you could use both. But not sure if this is what you were wondering.
9
25
0
I recently learned JavaScript an all of the sudden I hear about Python... Should I go learn Python or just stick with my basic JavaScript knowledge? If you have some "facts" I would love to hear them! Like efficiency, difficultylevel and so on, an so on... Thanks :)
Python over JavaScript? (Facts, please)
1
0
0
65,637
3,266,223
2010-07-16T15:06:00.000
0
1
1
0
javascript,python
3,266,266
12
false
1
0
JavaScript and Python are both great languages that are geared toward different problems. JavaScript knowledge is invaluable when dealing with the web, writing web pages, and poking around in html DOM. Python is a scripting language that is great for a host of things on any machine.
9
25
0
I recently learned JavaScript an all of the sudden I hear about Python... Should I go learn Python or just stick with my basic JavaScript knowledge? If you have some "facts" I would love to hear them! Like efficiency, difficultylevel and so on, an so on... Thanks :)
Python over JavaScript? (Facts, please)
0
0
0
65,637
3,266,223
2010-07-16T15:06:00.000
1
1
1
0
javascript,python
3,266,275
12
false
1
0
For what purpose? Javascript is king in some circles (web development, for instance). Javascript and Python are not mutually exclusive. Why not learn both?
9
25
0
I recently learned JavaScript an all of the sudden I hear about Python... Should I go learn Python or just stick with my basic JavaScript knowledge? If you have some "facts" I would love to hear them! Like efficiency, difficultylevel and so on, an so on... Thanks :)
Python over JavaScript? (Facts, please)
0.016665
0
0
65,637
3,267,076
2010-07-16T16:40:00.000
3
0
0
0
python,ftp
3,267,124
3
true
0
0
Everything depends on the hosting provider you use for your homepage -- do they offer Python among their services, and, if so, what version, and how do you write server-side scripts to use it (is it CGI-only, or...?) -- if not, or the version / deployment options disappoint, what do they allow in terms of giving you shell access and running long-time processes? It's impossible for us to judge any of these aspects, because every single one of them depends on your hosting provider, and absolutely none of them depends on Python itself!-)
2
1
0
Is it possible to make python run on your homepage? I know, this is a really stupid question but please don't pick on me for my stupidity :) If it is possible, how? Do you have to upload/install the executing part of Python to you website using FTP? or...? Edit: Just found out my provider does not support python and that shell access is completely restricted. Problem solved :)
Rookie Python-questions
1.2
0
0
192
3,267,076
2010-07-16T16:40:00.000
0
0
0
0
python,ftp
44,422,629
3
false
0
0
Python is a scripting language, though it is used gracefully for building back end web applications.
2
1
0
Is it possible to make python run on your homepage? I know, this is a really stupid question but please don't pick on me for my stupidity :) If it is possible, how? Do you have to upload/install the executing part of Python to you website using FTP? or...? Edit: Just found out my provider does not support python and that shell access is completely restricted. Problem solved :)
Rookie Python-questions
0
0
0
192
3,267,081
2010-07-16T16:40:00.000
1
0
0
0
python,django,events,mongodb,tracking
3,267,422
3
false
1
0
If by click, you mean a click on a link that loads a new page (or performs an AJAX request), then what you aim to do is fairly straightforward. Web servers tend to keep plain-text logs about requests - with information about the user, time/date, referrer, the page requested, etc. You could examine these logs and mine the statistics you need. On the other hand, if you have a web application where clicks don't necessarily generate server requests, then collecting click information with javascript is your best bet.
2
7
0
I'm looking into way to track events in a django application (events would generally be clicks tied to a specific unique user id). These events would essentially contain an event type like "click" and then each click event would be assigned to a unique id (many events can go to one id) and each event would have a data set including items like referrer etc... I have tried mixpanel, but for now the data api they are offering seems too limiting as I can't seem to find a way to get all of my data out by a unique id (apart from the event itself). I'm looking into using django-eventracker, but curious about any others thought on the best way to do this. Mongo or CouchDb seem like a great choice here, but the celery/rabbitmq looks really attractive with mongo. Pumping these events into the existing applications db seems limiting at this point. Anyways, this is just a thread to see what others thoughts are on this and how they have implemented something like this... shoot
Recommendation for click/event tracking mechanisms (python, django, celery, mongo etc)
0.066568
0
0
3,366
3,267,081
2010-07-16T16:40:00.000
3
0
0
0
python,django,events,mongodb,tracking
3,267,157
3
false
1
0
I am not familiar with the pre-packaged solutions you mention. Were I to design this from scratch, I'd have a simple JS collecting info on clicks and posting it back to the server via Ajax (using whatever JS framework you're already using), and on the server side I'd simply append that info to a log file for later "offline" processing -- so that would be independent of django or other server-side framework, essentially. Appending to a log file is a very light-weight action, while DBs for web use are generally way optimized for read-intensive (not write-intensive) operation, so I agree with you that force fitting that info (as it trickes in) into the existing app's DB is unlikely to offer good performance.
2
7
0
I'm looking into way to track events in a django application (events would generally be clicks tied to a specific unique user id). These events would essentially contain an event type like "click" and then each click event would be assigned to a unique id (many events can go to one id) and each event would have a data set including items like referrer etc... I have tried mixpanel, but for now the data api they are offering seems too limiting as I can't seem to find a way to get all of my data out by a unique id (apart from the event itself). I'm looking into using django-eventracker, but curious about any others thought on the best way to do this. Mongo or CouchDb seem like a great choice here, but the celery/rabbitmq looks really attractive with mongo. Pumping these events into the existing applications db seems limiting at this point. Anyways, this is just a thread to see what others thoughts are on this and how they have implemented something like this... shoot
Recommendation for click/event tracking mechanisms (python, django, celery, mongo etc)
0.197375
0
0
3,366
3,267,580
2010-07-16T17:54:00.000
2
0
0
0
python,mysql,sqlalchemy,large-query
3,271,153
1
true
0
0
I had a similar problem recently and used the - not very elegant - work-around: First I parsed my.cnf for a value for max_allow_packets, if I can't find it, the maximum is set to a default value. All data items are stored in a list. Next, for each data item I count the approximate byte length (with strings, it's the length of the string in bytes, for other data types I take the maximum bytes used to be safe.) I add them up, committing after I have reached approx. 75% of max_allow_packets (as SQL queries will take up space as well, just to be on the safe side). This approach is not really beautiful, but it worked flawlessly for me.
1
1
0
Due to the nature of my application, I need to support fast inserts of large volumes of data into the database. Using executemany() increases performance, but there's a caveat. For example, MySQL has a configuration parameter called max_allowed_packet, and if the total size of my insert queries exceeds its value, MySQL throws an error. Question #1: Is there a way to tell SQLAlchemy to split the packet into several smaller ones? Question #2: If other RDBS have similar constraints, how should I work around them as well? P.S. I had posted this question earlier but deleted it when I wrongly assumed that likely I will not encounter this problem after all. Sadly, that's not the case.
SQLAlchemy and max_allowed_packet problem
1.2
1
0
2,103
3,267,830
2010-07-16T18:31:00.000
3
0
0
1
python,google-app-engine
3,267,906
3
true
1
0
One alternative would be to have a map of symbolic names to URLs, that way you could redirect to the mapped URL - you could then update your URLs with impunity. Or if you'd rather just execute the code from another handler, I don't know why you couldn't just make a method call - worst case, you could extract a common method from the two handlers and call that.
1
3
0
I just started with Google App Engine using python and I was following a tutorial and writing my own little app to get familiar the webapp framework. Now I just noticed the tutorial does the following self.redirect('/'). So that got me wondering: is there a way to redirect to a handler instead of a hardcoded path? Thought that might be better so that you can change your urls without breaking your app.
Google App Engine: Redirect to RequestHandler
1.2
0
0
1,160
3,267,981
2010-07-16T18:53:00.000
4
0
0
0
python,gtk,svg
3,268,630
2
true
0
0
solved it in a different way: simply created a subpixbuf with the coodinates: cropped_buffer=pixbuf.subpixbuf(x,y,width,height)
1
3
0
I've got a gtk - pixbuf out of an svg and want to crop this to a specific size at specific coordinates. Anyone has an easy possible solution for that ?
How to crop gtk pixbufs
1.2
0
0
1,335
3,268,106
2010-07-16T19:14:00.000
0
0
1
0
python,user-interface,wxpython,objectlistview
3,268,404
2
true
0
1
I seem to have fixed it by using the FastObjectListView class instead...
1
0
0
When I update my objectListView list it flickers/flashes white, is this normal behaviour or can it be prevented. The list gets updated around every 1-5 seconds using the AddObject method if that makes any difference.
ObjectListView Flickers/Flashes when adding a new list object
1.2
0
0
463
3,268,600
2010-07-16T20:24:00.000
1
1
0
0
python,gtk,svg,rsvg
3,948,330
1
true
0
0
I found out to simply use RSVG::Handle::get_dimensions_sub(id)
1
0
0
Hi I want to load the groups of a svg-file into several gtk pixbuffs/subpixbufs therefore I need the coordinates and width and height of them I'm currently just using rsvg and gtk is it possible to get those information with that modules ? Or do I need another module to read out that data from the svg-file? thanks alot
Get the coords and height/width of a svg group into python
1.2
0
0
387
3,269,019
2010-07-16T21:35:00.000
1
0
0
0
python,user-interface,listview,wxpython,background-color
3,269,998
2
true
0
1
You could do it with a wx.Grid or you might look at the new UltimateListCtrl, which is a pure python widget. You can hack it if it doesn't do what you want it to!
1
0
0
Is there a wxpython list widget that displays alternating row colours even when empty the list is empty? or Is there even one that will display a background colour(other than white) when it is empty?
Is there a wxpython list widget that displays alternating row colours even when the list is empty?
1.2
0
0
843
3,269,200
2010-07-16T22:10:00.000
1
1
1
0
python,aac
12,114,371
2
false
0
0
Try using the command exiftool. Of course, if you're using linux. This command shows all the properties of audio files, video and pictures. Exiftool installed, simply use the command: exiftoll your_file_name.extension eg exiftoll music.mp3
1
1
0
What's the easiest Python library to use to extract properties from an AAC audio file (.m4a)? Specifically, I'd like to extract the following properties: Sample rate Channel count (mono or stereo) Length (in seconds)
Extract AAC audio properties using Python?
0.099668
0
0
1,597
3,269,339
2010-07-16T22:44:00.000
2
1
0
0
.net,ironpython,monodevelop,ubuntu-10.04
3,284,054
1
true
0
0
I'm not aware of one. The is a Python addin for MD, but not an IronPython addin. It wouldn't be hard to write an addin for MD - if anyone's interested, ask on the MonoDevelop mailing list and I can give some pointers to get started.
1
3
0
I have installed Iron Python on my Ubuntu 10.4 and Mono Develop, but there is no interaction between them. Is there any Iron Python plug-in for Monodevelop as in VS? If not, which is the best Iron-Python IDE for Ubuntu or Debian?
Is there any Iron Python plug-in for Monodevelop?
1.2
0
0
1,522
3,269,942
2010-07-17T02:05:00.000
0
0
0
0
python,pygtk
3,271,663
1
true
0
1
You can probably use gtk.TextIter.forward_to_tag_toggle(). I.e. loop over all tags you have and for each tags scan the buffer for the position where it is toggled.
1
1
0
So I am trying to write a rich text editor in PyGTK, and originally used the older, third party script InteractivePangoBuffer from Gourmet to do this. While it worked alright, there were still plenty of bugs with it which made it frustrating to use at times, so I decided to write my own utilizing text tags. I have got them displaying and generally working alright, but now I am stuck at trying to figure out how to export them to a file when saving. I've seen that others have had the same problem I've had, though I haven't seen any solutions. I haven't come across any function (built in or otherwise) which comes close to actually getting the starting and ending position of each piece of text with a texttag applied to it so I can use it. I have come up with one idea which should theoretically work, by walking the text by utilizing gtk.TextBuffer.get_iter_at_offset(), gtk.TextIter.get_offset(), gtk.TextIter.begins_tag(), and gtk.TextIter.ends_tag() in order to check each and every character to see if it begins or ends a tag and, if so, put the appropriate code. This would be horribly inefficient and slow, especially on larger documents, however, so I am wondering if anyone has any better solutions?
Saving gtk.TextTags to file?
1.2
0
0
276
3,270,464
2010-07-17T06:11:00.000
2
1
0
1
php,python,perl,compiler-construction,scripting-language
3,270,788
8
false
0
0
There are 3 options of encrypting Perl code: Use PAR to create executable file with PAR::Filter::Obfuscate or PAR::Filter::Crypto Use Filter::Crypto::CryptFile (will require some modules installed on target OS) Turn into module and encrypt into Module::Crypt. Also you can try B::C - it was removed from core Perl distribution and is now available on CPAN.
4
2
0
I am working on a project that requires reading text files, extracting data from them, and then generating reports (text files). Since there are a lot of string parsing, I decided to do it in Perl or Python or PHP (preference in that order). But I don't want to expose the source code to my client. Is there any good compiler for compiling perl/python/php scripts into linux executables? I am not looking for a 100% perfect one, but I am looking for an at least 90% perfect one. By perfect, I mean the compiler doesn't require to write scripts with a limited subset of language features.
Good compilers for compiling perl/python/php scripts into linux executables?
0.049958
0
0
2,889
3,270,464
2010-07-17T06:11:00.000
0
1
0
1
php,python,perl,compiler-construction,scripting-language
3,270,490
8
false
0
0
For Python You can call your code and give the *.pyc file to the client.
4
2
0
I am working on a project that requires reading text files, extracting data from them, and then generating reports (text files). Since there are a lot of string parsing, I decided to do it in Perl or Python or PHP (preference in that order). But I don't want to expose the source code to my client. Is there any good compiler for compiling perl/python/php scripts into linux executables? I am not looking for a 100% perfect one, but I am looking for an at least 90% perfect one. By perfect, I mean the compiler doesn't require to write scripts with a limited subset of language features.
Good compilers for compiling perl/python/php scripts into linux executables?
0
0
0
2,889
3,270,464
2010-07-17T06:11:00.000
4
1
0
1
php,python,perl,compiler-construction,scripting-language
3,270,852
8
false
0
0
I'm sorry, it's simply not worth spending your time on. For any language you choose (from among the ones you listed), for any compiler/obfuscator someone chooses to come up with, I promise you I can get readable source code out of it (within an hour if it's Perl; longer if it's Python or PHP simply because I'm less acquainted with the implementations of those languages, not because it's intrinsically harder with those languages). I think you should take a better look at what your goals are and why you want to work for a client that you're assuming a priori wants to rip you off. And if you still want to go ahead with such a scheme, write in C or Fortran -- certainly not anything starting with "P".
4
2
0
I am working on a project that requires reading text files, extracting data from them, and then generating reports (text files). Since there are a lot of string parsing, I decided to do it in Perl or Python or PHP (preference in that order). But I don't want to expose the source code to my client. Is there any good compiler for compiling perl/python/php scripts into linux executables? I am not looking for a 100% perfect one, but I am looking for an at least 90% perfect one. By perfect, I mean the compiler doesn't require to write scripts with a limited subset of language features.
Good compilers for compiling perl/python/php scripts into linux executables?
0.099668
0
0
2,889
3,270,464
2010-07-17T06:11:00.000
0
1
0
1
php,python,perl,compiler-construction,scripting-language
3,270,518
8
false
0
0
For linux an executable is something which has +x set, so there's no need to compile scripts. To hide your sourcecode you could use an obfuscator. This makes your sourcecode unreadable.
4
2
0
I am working on a project that requires reading text files, extracting data from them, and then generating reports (text files). Since there are a lot of string parsing, I decided to do it in Perl or Python or PHP (preference in that order). But I don't want to expose the source code to my client. Is there any good compiler for compiling perl/python/php scripts into linux executables? I am not looking for a 100% perfect one, but I am looking for an at least 90% perfect one. By perfect, I mean the compiler doesn't require to write scripts with a limited subset of language features.
Good compilers for compiling perl/python/php scripts into linux executables?
0
0
0
2,889
3,270,704
2010-07-17T08:01:00.000
0
0
0
0
python,gtk,rsvg
3,314,937
1
false
0
0
There's nothing built-in but it's fairly simple to code it (walk over pixels, find the transparent ones). Unfortunately walking over pixels in python is probably slow.
1
0
0
I am currently using rsvg in Python to separate Svggroups. I got it working so that rsvg loads a single group ... alas all the transparent space around that still remains. Is there a gtk functionallity to cut away all this space? Thanks for all the answers!
Is it possible to cut away transparent areas of Gtk-pixbuf?
0
0
0
154
3,270,952
2010-07-17T09:38:00.000
2
0
0
0
python,django,sqlite
3,275,298
6
false
1
0
You asked what the create(**dict(zip(fields, row))) line did. I don't know how to reply directly to your comment, so I'll try to answer it here. zip takes multiple lists as args and returns a list of their correspond elements as tuples. zip(list1, list2) => [(list1[0], list2[0]), (list1[1], list2[1]), .... ] dict takes a list of 2-element tuples and returns a dictionary mapping each tuple's first element (key) to its second element (value). create is a function that takes keyword arguments. You can use **some_dictionary to pass that dictionary into a function as keyword arguments. create(**{'name':'john', 'age':5}) => create(name='john', age=5)
1
13
0
I am trying to setup a website in django which allows the user to send queries to a database containing information about their representatives in the European Parliament. I have the data in a comma seperated .txt file with the following format: Parliament, Name, Country, Party_Group, National_Party, Position 7, Marta Andreasen, United Kingdom, Europe of freedom and democracy Group, United Kingdom Independence Party, Member etc.... I want to populate a SQLite3 database with this data, but so far all the tutorials I have found only show how to do this by hand. Since I have 736 observations in the file I dont really want to do this. I suspect this is a simple matter, but I would be very grateful if someone could show me how to do this. Thomas
Populating a SQLite3 database from a .txt file with Python
0.066568
1
0
7,034
3,271,590
2010-07-17T13:10:00.000
7
0
1
1
python,windows,virtualenv
3,274,878
7
false
0
0
easy_install is able to install .exe packages as long as they were built using distutils' bdist_wininst target, which covers many popular packages. However, there are many others that aren't (wxPython is one that I've struggled with)
2
125
0
Virtualenv is great: it lets me keep a number of distinct Python installations so that different projects' dependencies aren't all thrown together into a common pile. But if I want to install a package on Windows that's packaged as a .exe installer, how can I direct it to install into the virtualenv? For example, I have pycuda-0.94rc.win32-py2.6.exe. When I run it, it examines the registry, and finds only one Python26 to install into, the common one that my virtualenv is based off of. How can I direct it to install into the virtualenv?
Can I install Python windows packages into virtualenvs?
1
0
0
32,413
3,271,590
2010-07-17T13:10:00.000
0
0
1
1
python,windows,virtualenv
72,302,027
7
false
0
0
You should type path of your file and write 'python ' before it. Than it will run your python script without any virtual environment. Thanks.
2
125
0
Virtualenv is great: it lets me keep a number of distinct Python installations so that different projects' dependencies aren't all thrown together into a common pile. But if I want to install a package on Windows that's packaged as a .exe installer, how can I direct it to install into the virtualenv? For example, I have pycuda-0.94rc.win32-py2.6.exe. When I run it, it examines the registry, and finds only one Python26 to install into, the common one that my virtualenv is based off of. How can I direct it to install into the virtualenv?
Can I install Python windows packages into virtualenvs?
0
0
0
32,413
3,271,813
2010-07-17T14:13:00.000
7
0
1
0
python
3,271,829
3
true
0
0
It takes time to wrap a raw integer into a Python int.
2
9
0
I'm learning python recently, and is doing many practice with the language. One thing I found interesting is that, when I read from an array, it's almost half of the time slower than list. Does somebody know why? here's my code: from timeit import Timer import array t = 10000 l = range(t) a = array.array('i', l) def LIST(): for i in xrange(t): l[i] def ARRAY(): for i in xrange(t): a[i] print Timer(LIST).timeit(1000); print Timer(ARRAY).timeit(1000); the output is: 0.813191890717 1.16269612312 which indicates that reading array is slower than list. I think array is a fixed size memory, while list is a dynamic structure. So I assumed that array would be faster than list. Does anyone has any explanation?
In python, why is reading from an array slower than reading from list?
1.2
0
0
1,763
3,271,813
2010-07-17T14:13:00.000
1
0
1
0
python
3,271,892
3
false
0
0
The Python lists really resemble some ways normal arrays, they are not Lisp lists, but they have fast random access.
2
9
0
I'm learning python recently, and is doing many practice with the language. One thing I found interesting is that, when I read from an array, it's almost half of the time slower than list. Does somebody know why? here's my code: from timeit import Timer import array t = 10000 l = range(t) a = array.array('i', l) def LIST(): for i in xrange(t): l[i] def ARRAY(): for i in xrange(t): a[i] print Timer(LIST).timeit(1000); print Timer(ARRAY).timeit(1000); the output is: 0.813191890717 1.16269612312 which indicates that reading array is slower than list. I think array is a fixed size memory, while list is a dynamic structure. So I assumed that array would be faster than list. Does anyone has any explanation?
In python, why is reading from an array slower than reading from list?
0.066568
0
0
1,763
3,274,334
2010-07-18T04:39:00.000
3
0
0
0
python,linux
3,274,680
7
false
0
0
Install inotify-tools and write a simple shell script to watch a file.
1
14
0
I would like to invoke my chrome or firefox browser when a file that I specify is modified. How could I "watch" that file to do something when it gets modified? Programmatically it seems the steps are.. basically set a never ending interval every second or so and cache the initial modification date, then compare the date every second, when it changes invoke X.
How can I "watch" a file for modification / change?
0.085505
0
1
27,121
3,274,350
2010-07-18T04:46:00.000
1
0
1
0
python,oop
3,274,356
2
false
0
0
If you mean the attribute, then make it a read-only property. If you mean the list itself, then use a tuple instead since they're immutable.
1
3
0
i have self.some_field = [] in my class Im enquiring is there a way to make this list read-only like a property?
How to make a class field [list] read-only in python?
0.099668
0
0
1,395
3,275,293
2010-07-18T11:17:00.000
6
0
0
0
python,pyqt,pyqt4,py2exe
3,275,651
4
false
0
1
I doubt this has an effect on py2exe, but it's related to the question. To run a python GUI on windows without the terminal, use pythonw.exe instead of python.exe. This should happen automatically if you end the filename with ".pyw".
1
20
0
I have a Python program uses Qt (PyQt4 in fact) and when I launch it from its main.py, I get a console window and the GUI window (on Windows, of course). Then I compile my program with py2exe and main.exe is successfully created. However, if I run main.exe (this is what users of program will do) console window of Python still appears and all my debug text is stdout-ed to that window. I want to hide cmd line window when my application is running and I want just my GUI to be visible to the user when executed from .exe file. Is that possible?
Hiding console window of Python GUI app with py2exe
1
0
0
19,469
3,276,230
2010-07-18T16:07:00.000
7
0
1
0
python,database,data-storage
3,276,336
7
true
0
0
It is never safe to save your database in a text format (or using pickle or whatever). There is a risk that problems while saving the data may cause corruption. Not to mention risks with your data being stolen. As your dataset grows there may be a performance hit. have a look at sqlite (or sqlite3) which is small and easier to manage than mysql. Unless you have a very small dataset that will fit in a text file. P/S: btw, using berkeley db in python is simple, and you don't have to learn all the DB things, just import bsddb
1
4
0
I need to store basic data of customer's and cars that they bought and payment schedule of these cars. These data come from GUI, written in Python. I don't have enough experience to use a database system like sql, so I want to store my data in a file as plain text. And it doesn't have to be online. To be able to search and filter them, first I convert my data (lists of lists) to the string then when I need the data re-convert to the regular Python list syntax. I know it is a very brute-force way, but is it safe to do like that or can you advice me to another way?
Basic data storage with Python
1.2
0
0
29,938
3,277,307
2010-07-18T21:22:00.000
2
0
0
0
python,django
3,278,231
2
false
1
0
Store whatever variables you would want in the session. Then you can access it through the request.
1
0
0
Is it possible to pass more than 1 argument to a context processor in Django? In other words, in addition to the HttpRequest object, I would like to pass 1 or more additional argument?
Possible to pass more than 1 argument to a context processor in Django?
0.197375
0
0
1,249
3,277,376
2010-07-18T21:42:00.000
0
1
0
0
c++,python
3,277,408
4
false
0
1
Python will also have the advantage/disadvantage (depending on what you want) that the source code must be open. (I think delivering only the .pyc file is not really an option as the Python bytecode format is changing in every release.) Otherwise, let's say you are selling to people who don't really know what the difference is between Python/C++: The outcome is the important thing. If your Python plugin runs and feels stable and fast, it is fine. If they have heard about both languages, there really may be a difference. I must admit, if I had a choice between two plugins which do exactly the same and which are perfectly stable from all user reports, I probably would prefer the C++ plugin. It would be my intuition which would tell me that the C++ code is probably slightly more stable and faster. This is also for Unix tools and other stuff.
3
3
0
I'm working on a plugin for some software that I'm planning on selling someday. The software I'm making it for has both a C++ SDK and a Python SDK. The C++ SDK documentation appears incomplete in certain areas and isn't documented that well. The Python SDK docs appear more complete and in general are much easier to work with. So I'm trying to decide if I want to go through the potential trouble of building a C++ plugin instead of a Python plugin to sell. About the only thing that makes me want to do a C++ plugin is that in my mind, a "C++ plugin" might be an easier sell than a "Python plugin". A lot of programmers out there don't even considered writing Python to be real "programming". Do you think that potential customers might say "Why would I pay money for a measly little Python script?"? As opposed to "Oh it was written in C++ so the guy must be a decent programmer"? Writing the Python plugin would be faster. Both plugins would look and behave exactly the same. The C++ plugin might be faster in certain spots, but for the type of plugin this is, that's not a huge deal. So my question is, would a Python plugin be considered not as professional/sellable as a C++ plugin, even if it looks and acts EXACTLY the same as a C++ plugin?
Is Python-based software considered less-professional than C++/compiled software?
0
0
0
815
3,277,376
2010-07-18T21:42:00.000
6
1
0
0
c++,python
3,277,400
4
true
0
1
A lot of programmers out there don't even considered writing Python to be real "programming". A lot of "programmers" out there are incompetent, too. Do you think that potential customers might say "Why would I pay money for a measly little Python script?"? I'm sure it depends on the type of software, but I can tell you that my program's customers have little interest in what we use to develop our product, and I doubt most of them know that the software is written in C++. They just care that it works. So my question is, would a Python plugin be considered not as professional/sellable as a C++ plugin, even if it looks and acts EXACTLY the same as a C++ plugin? No.
3
3
0
I'm working on a plugin for some software that I'm planning on selling someday. The software I'm making it for has both a C++ SDK and a Python SDK. The C++ SDK documentation appears incomplete in certain areas and isn't documented that well. The Python SDK docs appear more complete and in general are much easier to work with. So I'm trying to decide if I want to go through the potential trouble of building a C++ plugin instead of a Python plugin to sell. About the only thing that makes me want to do a C++ plugin is that in my mind, a "C++ plugin" might be an easier sell than a "Python plugin". A lot of programmers out there don't even considered writing Python to be real "programming". Do you think that potential customers might say "Why would I pay money for a measly little Python script?"? As opposed to "Oh it was written in C++ so the guy must be a decent programmer"? Writing the Python plugin would be faster. Both plugins would look and behave exactly the same. The C++ plugin might be faster in certain spots, but for the type of plugin this is, that's not a huge deal. So my question is, would a Python plugin be considered not as professional/sellable as a C++ plugin, even if it looks and acts EXACTLY the same as a C++ plugin?
Is Python-based software considered less-professional than C++/compiled software?
1.2
0
0
815
3,277,376
2010-07-18T21:42:00.000
0
1
0
0
c++,python
3,277,403
4
false
0
1
I think it doesn't matter. It all come down to 'use the right tool for the right job'. Your primary goal should be to make the best plugin you can. So if you feel more at ease with Python use that. It will probably take you less time to write. The client probably doesn't mind it and just want the most stable, reliable, cheapest, easiest to use plugin. So concentrate on that not on the tool.
3
3
0
I'm working on a plugin for some software that I'm planning on selling someday. The software I'm making it for has both a C++ SDK and a Python SDK. The C++ SDK documentation appears incomplete in certain areas and isn't documented that well. The Python SDK docs appear more complete and in general are much easier to work with. So I'm trying to decide if I want to go through the potential trouble of building a C++ plugin instead of a Python plugin to sell. About the only thing that makes me want to do a C++ plugin is that in my mind, a "C++ plugin" might be an easier sell than a "Python plugin". A lot of programmers out there don't even considered writing Python to be real "programming". Do you think that potential customers might say "Why would I pay money for a measly little Python script?"? As opposed to "Oh it was written in C++ so the guy must be a decent programmer"? Writing the Python plugin would be faster. Both plugins would look and behave exactly the same. The C++ plugin might be faster in certain spots, but for the type of plugin this is, that's not a huge deal. So my question is, would a Python plugin be considered not as professional/sellable as a C++ plugin, even if it looks and acts EXACTLY the same as a C++ plugin?
Is Python-based software considered less-professional than C++/compiled software?
0
0
0
815
3,277,946
2010-07-19T01:27:00.000
2
0
0
1
python,macos,subprocess
3,277,996
2
false
0
0
You can try running IDLE with the "-n" option. From the IDLE help: Running without a subprocess: If IDLE is started with the -n command line switch it will run in a single process and will not create the subprocess which runs the RPC Python execution server. This can be useful if Python cannot create the subprocess or the RPC socket interface on your platform. However, in this mode user code is not isolated from IDLE itself. Also, the environment is not restarted when Run/Run Module (F5) is selected. If your code has been modified, you must reload() the affected modules and re-import any specific items (e.g. from foo import baz) if the changes are to take effect. For these reasons, it is preferable to run IDLE with the default subprocess if at all possible.
1
3
0
I'm new to python programming, and want to try to edit scripts in IDLE instead of the OSX command line. However, when I try to start it, it gives me the error "Idle Subprocess didn't make a connection. Either Idle can't start a subprocess or personal firewall software is blocking the connection." I don't have a firewall configured, so what could the problem be?
No IDLE Subprocess connection
0.197375
0
1
13,342
3,278,477
2010-07-19T04:35:00.000
0
0
1
0
php,jquery,python,epub
3,278,535
5
false
1
0
Does it have to be ePub format? Here in Australia the iBookstore is basically completely bare, except for books out of copyright (The illiad, Bible etc) My understanding is that they are still negotiating with the publishers. The guy at the Apple store said to me, oh thats no problem, download the free Kindle app and just buy your books from Amazon, they have a much better range anyway. Would that work for you?
1
10
0
I purchased an iPad hoping to read books on it that've been aging on my desk for months, but it turned out that there're NO programming books available on iBookstore. Are there any (Python, PHP, jQuery) books available in ePub format? Conversion from pdf to epub is not an option because the formatting is lost in the process. Thanks
Programming books in ePub format
0
0
0
10,584
3,278,567
2010-07-19T05:05:00.000
2
1
1
0
python,project,fuse
3,396,712
5
false
0
0
What about a versioned file-system? It has always seemed like a cool idea since I read about the implementation in Plan 9. You wouldn't have to write the versioning part as you could use an off-the-shelf version control like git. The contents of the repository could be exposed as a file hierarchy, older versions could be read-only directories and write access to files in the repository could trigger a commit. The original versions of sshfs used a FUSE frontend that fired shell commands out the back to move around in the target file-system. You could implement something similar quite easily to output git commands and act on the repository.
5
2
0
I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. What I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can share?
interesting project that I can implement with fuse-python
0.07983
0
0
461
3,278,567
2010-07-19T05:05:00.000
0
1
1
0
python,project,fuse
3,278,603
5
false
0
0
I do not know if python is appropriate, but maybe you can provide URL handlers for fuse in Firefox. for example: sshfs://host/path would allow to explore remote ssh host via Firefox browser.
5
2
0
I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. What I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can share?
interesting project that I can implement with fuse-python
0
0
0
461
3,278,567
2010-07-19T05:05:00.000
0
1
1
0
python,project,fuse
3,278,606
5
false
0
0
Maybe a filesystem where files behave like directories, so you can store files in files. Or a filesystem where you can store files with the same name in 1 directory.
5
2
0
I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. What I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can share?
interesting project that I can implement with fuse-python
0
0
0
461
3,278,567
2010-07-19T05:05:00.000
1
1
1
0
python,project,fuse
3,289,412
5
false
0
0
Mounting an xml file as a filesystem, where elements are directories, and their contents is stored as a plain file. The attributes are stored in an "attributes" file as newline separated name: value pairs in each directory. This would allow XML to be modified using the common shell tools. (sed, grep, mkdir, rm, rmdir, cat, vim, etc...) An elegant solution would have to be found for multiple elements with the same name. So it's a bit far field. You never said that it had to be a good idea.
5
2
0
I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. What I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can share?
interesting project that I can implement with fuse-python
0.039979
0
0
461
3,278,567
2010-07-19T05:05:00.000
2
1
1
0
python,project,fuse
3,278,611
5
false
0
0
The typical 'cool' things with FUSE are exposing in a filesystem interface things that aren't files, and usually are stored somewhere else. Existing examples: Gmail filesystem, SSH filesystem. Non existing (that I know of) examples: a Twitter filesystem, that shows tweets as files. Or a Stack Overflow filesystem, questions and answers as files.
5
2
0
I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. What I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can share?
interesting project that I can implement with fuse-python
0.07983
0
0
461
3,278,831
2010-07-19T06:19:00.000
0
0
1
0
python,dictionary
3,278,897
3
false
0
0
dictionary.keys() returns a list of keys you can then use if (3,4) in d.keys()
1
1
0
I need to check if a particular key is present in some dictionary. I can use has_key ?? Is there any other method to compare the items of the list to the key of dictionary. I have a list like...[(3,4),(4,5)..] I need to check if the (3,4) is there in the dictionary.
comparison between the elements of list with keys of dictionary
0
0
0
1,819
3,279,436
2010-07-19T08:22:00.000
0
0
0
0
python,pygame,coordinates,geometry-surface
3,279,476
3
false
0
1
There is no way to move the origin of a surface from 0,0. Implement your own drawing class which transforms all the coordinates passed in into the space of the surface.
1
2
0
What would be the best way to use negative coordinates in pygame? At the moment I have a surface that is 1.5 times the original surface then everything that needs to be drawn is shifted up by a certain amount (to ensure the negative coordinates become positive) and drawn. Is there an easier/alternate way of doing this?
Negative coordinates in pygame
0
0
0
2,454
3,280,391
2010-07-19T10:52:00.000
0
1
0
0
python,urllib2,bandwidth
3,280,448
2
false
0
0
You could download an empty file to measure the delay. You measure more the only the network delay, but the difference should be too big I expect.
1
4
0
I want to make a python script that tests the bandwidth of a connection. I am thinking of downloading/uploading a file of a known size using urllib2, and measuring the time it takes to perform this task. I would also like to measure the delay to a given IP address, such as is given by pinging the IP. Is this possible using urllib2?
Bandwidth test, delay test using urllib2
0
0
1
1,534
3,281,107
2010-07-19T12:46:00.000
1
1
0
0
python,linux,signals,kill
3,281,123
4
false
0
0
If you do not want to execute the kill command with the correct permissions, you can send any other signal to the other script. It is then the other scripts' responsibility to terminate. You cannot force it, unless you have the permissions to do so. This can happen with a network connection, or a 'kill' file whose existence is checked by the other script, or anything else the script is able to listen to.
3
3
0
On a linux box I've got a python script that's always started from predefined user. It may take a while for it to finish so I want to allow other users to stop it from the web. Using kill fails with Operation not permitted. Can I somehow modify my long running python script so that it'll recive a signal from another user? Obviously, that another user is the one that starts a web server. May be there's entirely different way to approach this problem I can't think of right now.
terminate script of another user
0.049958
0
1
332
3,281,107
2010-07-19T12:46:00.000
1
1
0
0
python,linux,signals,kill
3,281,132
4
false
0
0
Off the top of my head, one solution would be threading the script and waiting for a kill signal via some form or another. Or rather than threading, you could have a file that the script checks every N times through a loop - then you just write a kill signal to that file (which of course has write permissions by the web user). I'm not terribly familiar with kill, other than killing my own scripts, so there may be a better solution.
3
3
0
On a linux box I've got a python script that's always started from predefined user. It may take a while for it to finish so I want to allow other users to stop it from the web. Using kill fails with Operation not permitted. Can I somehow modify my long running python script so that it'll recive a signal from another user? Obviously, that another user is the one that starts a web server. May be there's entirely different way to approach this problem I can't think of right now.
terminate script of another user
0.049958
0
1
332
3,281,107
2010-07-19T12:46:00.000
0
1
0
0
python,linux,signals,kill
3,281,121
4
false
0
0
You could use sudo to perform the kill command as root, but that is horrible practice. How about having the long-running script check some condition every x seconds, for example the existence of a file like /tmp/stop-xyz.txt? If that file is found, the script terminates itself immediately. (Or any other means of inter-process communication - it doesn't matter.)
3
3
0
On a linux box I've got a python script that's always started from predefined user. It may take a while for it to finish so I want to allow other users to stop it from the web. Using kill fails with Operation not permitted. Can I somehow modify my long running python script so that it'll recive a signal from another user? Obviously, that another user is the one that starts a web server. May be there's entirely different way to approach this problem I can't think of right now.
terminate script of another user
0
0
1
332
3,282,053
2010-07-19T14:37:00.000
0
0
0
1
python,cocoa,xcode,pyobjc
4,708,176
2
false
0
0
XCode has so called SDKs which can be used to target earlier Max OS X versions from a recent one. Currently installed SDKs can be found in /Developer/SDKs. Additional SDKs may be installed from an XCode DVD. In a project created with XCode, SDK can be selected the following way. Open Get info of a target, find Base SDK setting inside the Architectures section. Select SDK you need and rebuild. For example, Mac OS X 10.5 SDK contains Python versions 2.5 and 2.3 and the Current version points to 2.5.
1
6
0
I'm trying to deploy on 10.5 a PyObjC (or Cocoa-Python) application developed on Xcode 3.2.X (Snow Leopard) which runs perfectly fine on 10.6 systems. The application doesn't launch on 10.5;it crashes at launch giving this error message (found on Crash Report): Dyld Error Message: Library not loaded: /System/Library/Frameworks/Python.framework/Versions/2.6/Python Referenced from: /Users/myuser/Documents/myApp.app/Contents/MacOS/myApp Reason: image not found Seems that somewhere Xcode hardcodes the Versions/2.6 python framework path (instead of setting it as Versions/Current, for example). However, I was not able to find where this link path could be modified to be set to Current (or to 2.5, maybe conditionally)...
Compiling a PyObjC application for 10.5 (Leopard) into xcode 10.6 (Snow Leopard)
0
0
0
400
3,283,178
2010-07-19T16:58:00.000
2
0
1
0
python,self
3,283,196
6
false
0
0
self is this, just you have to explicitly pass it and explicitly use it to refer to class methods/properties. It isn't optional in class methods. You will get a TypeError if you try to define a classmethod without at least one argument (i.e., the self parameter). However, you can call it something other than self, but I have never seen otherwise.
3
6
0
From what I read/understand, the 'self' parameter is similiar to 'this'. Is that true? If its optional, what would you do if self wasnt' passed into the method?
python and using 'self' in methods
0.066568
0
0
1,730
3,283,178
2010-07-19T16:58:00.000
5
0
1
0
python,self
3,283,192
6
false
0
0
Yes, it's used in similar ways. Note that it's a positional parameter and you can call it what you want; however there is a strong convention to call it self (not this or anything else). Some positional parameter must be there for a usable instance method; it is not optional.
3
6
0
From what I read/understand, the 'self' parameter is similiar to 'this'. Is that true? If its optional, what would you do if self wasnt' passed into the method?
python and using 'self' in methods
0.16514
0
0
1,730
3,283,178
2010-07-19T16:58:00.000
0
0
1
0
python,self
3,283,198
6
false
0
0
self refers to the object on which the method was called, much like this in C++. But it is important that self is merely a convention, you can name it as you like and pass instances of subclasses.
3
6
0
From what I read/understand, the 'self' parameter is similiar to 'this'. Is that true? If its optional, what would you do if self wasnt' passed into the method?
python and using 'self' in methods
0
0
0
1,730
3,284,289
2010-07-19T19:24:00.000
0
0
0
0
python,xml
3,284,880
7
false
1
0
If the document is endless why not add end tag (of main element) manually before opening it in parser? I don't know Python but why not add </endtag> to string?
1
5
0
I am working on a application, and my job just is to develop a sample Python interface for the application. The application can provide XML-based document, I can get the document via HTTP Get method, but the problem is the XML-based document is endless which means there will be no end element. I know that the document should be handled by SAX, but how to deal with the endless problem? Any idea, sample code?
python handle endless XML
0
0
1
1,933
3,284,779
2010-07-19T20:27:00.000
1
0
0
0
python,tkinter
3,284,846
2
false
0
1
No. There is no way to do this.
1
0
0
Is there any way to run a python script that utilizes TKinter on a web page such that a user could run the script and interact with the TK windows without having to download the script or have the appropriate python interpreter?
Any way to run python TK scripts on web page?
0.099668
0
0
944
3,285,166
2010-07-19T21:16:00.000
0
0
1
0
python,ide
3,286,180
9
false
0
0
WingIDE if you can fork out some cash will do what you want all bundled up and with little to no configuration effort. Otherwise Eclipse with Aptana's pydev is free, and does exactly that, plus a lot more (ctrl+click pretty much anything for redirection and a lot of other useful things like pyc removal etc.). Navigation problems though are usually symptomatic of more than just lack of tools. A decent structure to your projects and a version control system (even if you work locally and solo) would go a long way helping to address that.
3
3
0
I'm trying to use textmate, but I find it hard to navigate a project with it. I admit I probably just don't know the the IDE well enough. Is it possible to highlight a class or method and jump to its definition?
Python IDE that you can highlight a method/class and jump to its definition
0
0
0
2,656
3,285,166
2010-07-19T21:16:00.000
0
0
1
0
python,ide
3,287,352
9
false
0
0
I'm not sure about what functionality is available in textmate but would a simple search work? i.e. Ctrl+F with the query "def function" including the def part so you find the definition instead of a call?
3
3
0
I'm trying to use textmate, but I find it hard to navigate a project with it. I admit I probably just don't know the the IDE well enough. Is it possible to highlight a class or method and jump to its definition?
Python IDE that you can highlight a method/class and jump to its definition
0
0
0
2,656
3,285,166
2010-07-19T21:16:00.000
0
0
1
0
python,ide
9,350,448
9
false
0
0
Aptana Studio 3.0 The PyDev team is now operating under the auspices of Aptana, which makes Aptana Studio 3 - an Eclipse customisation - preferable to the 2-step process of first downloading Eclipse, and then installing the PyDev extension. Aptana comes pre-configured for Python (and others), and in addition features custom support for Django projects [including JavaScript support]. The product is fast and responsive, and features powerful meta-level functionality such as jumping to the definition of a callable, deducing object fields from init initialisation, module browsing, very good code completion, and more... Thus far, out of Eclipse+PyDev, NetBeans Python Edition and Aptana Studio 3, based on relatively extensive personal testing, AS3 wins hands down.
3
3
0
I'm trying to use textmate, but I find it hard to navigate a project with it. I admit I probably just don't know the the IDE well enough. Is it possible to highlight a class or method and jump to its definition?
Python IDE that you can highlight a method/class and jump to its definition
0
0
0
2,656
3,285,168
2010-07-19T21:17:00.000
0
0
1
0
python,data-structures,caching
3,285,185
3
false
0
0
You're looking for a Map, or an associative array. To get more specific, we'd need to know what language you're trying to use.
2
2
0
I'm implementing something like a cache, which works like this: If a new value for the given key arrives from some external process, store that value, and remember the time when this value arrived. If we are idle, find the oldest entry in the cache, fetch the new value for the key from external source and update the cache. Return the value for the given key when asked. I need a data structure to store key-value pairs which would allow to perform the following operations as fast as possible (in the order of speed priority): Find the key with the lowest (unknown) value. Update a value for the given key or add a new key-value pair if the key does not exist. Other regular hash-table operations, like delete a key, check if a key exists, etc. Are there any data-structures which allow this? The problem here is that to perform the first query quickly I need something value-ordered and to update the values for the given key quickly I need something key-ordered. The best solution I have so far is something like this: Store values an a regular hashtable, and pairs of (value, key) as a value-ordered heap. Finding the key for the lowest value goes like this: Find the key for the lowest value on the heap. Find the value for that key from the hashtable. If the values don't match pop the value from the heap and repeat from step 1. Updating the values goes like this: Store the value in the hashtable. Push the new (value, key) pair to the heap. Deleting a key is more tricky and requires searching for the value in the heap. This gives something like O(log n) performance, but this solution seems to be cumbersome to me. Are there any data structures which combine the properties of a hashtable for keys and a heap for the associated values? I'm programming in Python, so if there are existing implementations in Python, it is a big plus.
Data structure to store key-value pairs and retrive the key for the lowest value quickly
0
0
0
3,079
3,285,168
2010-07-19T21:17:00.000
3
0
1
0
python,data-structures,caching
3,285,262
3
true
0
0
Most heap implementations will get you the lowest key in your collection in O(1) time, but there's no guarantees regarding the speed of random lookups or removal. I'd recommend pairing up two data structures: any simple heap implementation and any out-of-the-box hashtable. Of course, any balanced binary tree can be used as a heap, since the smallest and largest values are on the left-most and right-most leaves respectively. Red-black tree or AVL tree should give you O(lg n) heap and dictionary operations.
2
2
0
I'm implementing something like a cache, which works like this: If a new value for the given key arrives from some external process, store that value, and remember the time when this value arrived. If we are idle, find the oldest entry in the cache, fetch the new value for the key from external source and update the cache. Return the value for the given key when asked. I need a data structure to store key-value pairs which would allow to perform the following operations as fast as possible (in the order of speed priority): Find the key with the lowest (unknown) value. Update a value for the given key or add a new key-value pair if the key does not exist. Other regular hash-table operations, like delete a key, check if a key exists, etc. Are there any data-structures which allow this? The problem here is that to perform the first query quickly I need something value-ordered and to update the values for the given key quickly I need something key-ordered. The best solution I have so far is something like this: Store values an a regular hashtable, and pairs of (value, key) as a value-ordered heap. Finding the key for the lowest value goes like this: Find the key for the lowest value on the heap. Find the value for that key from the hashtable. If the values don't match pop the value from the heap and repeat from step 1. Updating the values goes like this: Store the value in the hashtable. Push the new (value, key) pair to the heap. Deleting a key is more tricky and requires searching for the value in the heap. This gives something like O(log n) performance, but this solution seems to be cumbersome to me. Are there any data structures which combine the properties of a hashtable for keys and a heap for the associated values? I'm programming in Python, so if there are existing implementations in Python, it is a big plus.
Data structure to store key-value pairs and retrive the key for the lowest value quickly
1.2
0
0
3,079
3,285,237
2010-07-19T21:27:00.000
0
0
1
0
python,django,object
3,286,206
3
false
0
0
Nothing prevents you from "resetting" that attrib in the init setting it to None after you init the super (in Python classes inherited and inheriting are super and sub btw, not parent and child). Unless that attrib is created elsewhere and its presence isn't guaranteed, only in that case walking up the inheritance tree, at which point you might have some serious design issues going on :) All that said, these are poor man solutions to the problem, and I agree you might have some design issues to address instead.
1
4
0
How to get an attribute just from the current class and not from possible parent classes? If I use getattr it traverses class hierarchy but I would like to get None if attribute is not defined in the current class (even if it is defined in some parent class).
How to get an attribute just from the current class and not from possible parent classes?
0
0
0
1,552
3,285,631
2010-07-19T22:34:00.000
0
0
0
0
python,mysql,django
3,285,926
3
false
0
0
I tried to solve this one for days myself and finally gave up. I switched to postgres. It works pretty well with django on snow leopard, with one minor problem. For some reason auto_inc pk ids don't get assigned to some models. I solved the problem by randomly assigning an id from a large random range, and relying on the unique column designation to prevent collisions. My production server is linux. Mysql and postgres install fine on it. In fact, many on the #django irc channel recommended running a virtual linux instance on the mac to get around my mysql install problems on it.
1
2
0
I'm having all sorts of trouble trying to instal MySQLdb (1.2.2) on snow leopard. I am running python 2.5.1 and MySQL 5.1 32bit. Python and MySQL are running just fine. I've also installed django 1.2.1, although I don't think thats all that important, but wanted to give an idea of the stack i'm trying to install. I am using python 2.5.x as my webhost only has that version as an option and I want to be as close to my production env as possible. anyway... After following many of the existing articles and tutorials which mention modifying _mysql.c and setup_posix.py etc, I am still running into trouble. Here is my stack trace: xxxxxxx-mbp:MySQL-python-1.2.2 xxxxxxx$ sudo ARCHFLAGS="-arch x86_64" python setup.py build running build running build_py creating build creating build/lib.macosx-10.3-i386-2.5 copying _mysql_exceptions.py -> build/lib.macosx-10.3-i386-2.5 creating build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/init.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb creating build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/init.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants running build_ext building '_mysql' extension creating build/temp.macosx-10.3-i386-2.5 gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/local/mysql-5.1.48-osx10.6-x86/include -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.3-i386-2.5/_mysql.o -g -Os -arch i386 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL In file included from /Developer/SDKs/MacOSX10.4u.sdk/usr/include/wchar.h:112, from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/unicodeobject.h:118, from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:83, from pymemcompat.h:10, from _mysql.c:29: /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory In file included from _mysql.c:35: /usr/local/mysql-5.1.48-osx10.6-x86/include/my_config.h:1062:1: warning: "HAVE_WCSCOLL" redefined In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:8, from pymemcompat.h:10, from _mysql.c:29: /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyconfig.h:724:1: warning: this is the location of the previous definition error: command 'gcc' failed with exit status 1 Does anyone have any ideas?
Installing MySQLdb on Snow Leopard
0
1
0
461
3,286,525
2010-07-20T02:16:00.000
1
0
1
0
python,sql,json
55,329,857
14
false
0
0
If you are using an MSSQL Server 2008 and above, you can perform your SELECT query to return json by using the FOR JSON AUTO clause E.G SELECT name, surname FROM users FOR JSON AUTO Will return Json as [{"name": "Jane","surname": "Doe" }, {"name": "Foo","surname": "Samantha" }, ..., {"name": "John", "surname": "boo" }]
1
54
0
I'm playing around with a little web app in web.py, and am setting up a url to return a JSON object. What's the best way to convert a SQL table to JSON using python?
return SQL table as JSON in python
0.014285
1
0
157,377
3,286,826
2010-07-20T03:36:00.000
0
0
0
0
python,qt4,pyqt,signals
8,453,598
3
false
0
1
Signal handlers do NOT know the emitter (only the signal type) and emitters do NOT know what handlers are connected. Many handlers can connect to the same signal and they are executed in the order of connection. A signal can be emitted from many places.
3
3
0
I'm wanting a paradigm in a Qt4 (PyQt4) program where a component is able to respond to a signal without knowing anything about where it is coming from. My intial reading suggests that I have to explicitly connect signals to slots. But what I want is for any of a number of components to be able to send a signal, and for it to be processed by another component. Comparing with another toolkits, for example, in wxWidgets I would use events. These automatically propogate up from child windows/objects to parents. At each level they can be handled. This means if I have a lot of children which may emit the same event, I don't have to explicitly connect all of them to the handler. I can just put the handler in the parent, or some higher level in the window hierarchy. This means that only the event generator and consumer need to know about the event at all. The consumer doesn't need to know where the source of the event is, how many such sources there are, or anything else about it. Is this possible in Qt - is there another approach? Maybe there is an alternative event mechanism to signals and slots?
How to broadcast a signal in Qt4
0
0
0
1,116
3,286,826
2010-07-20T03:36:00.000
1
0
0
0
python,qt4,pyqt,signals
3,292,687
3
false
0
1
This isn't easily possible - you have to have something that knows about the signaling object and the receiving object to connect the two. Depending on what you need, however, you might be able to set up a class that mediates between the two (so objects with signals tell the class they exist, and have such-and-such a signal, while objects with slots tell the class they exist and have such-and-such a slot to connect to a given signal, and the mediator class tracks both of those, making connections when necessary).
3
3
0
I'm wanting a paradigm in a Qt4 (PyQt4) program where a component is able to respond to a signal without knowing anything about where it is coming from. My intial reading suggests that I have to explicitly connect signals to slots. But what I want is for any of a number of components to be able to send a signal, and for it to be processed by another component. Comparing with another toolkits, for example, in wxWidgets I would use events. These automatically propogate up from child windows/objects to parents. At each level they can be handled. This means if I have a lot of children which may emit the same event, I don't have to explicitly connect all of them to the handler. I can just put the handler in the parent, or some higher level in the window hierarchy. This means that only the event generator and consumer need to know about the event at all. The consumer doesn't need to know where the source of the event is, how many such sources there are, or anything else about it. Is this possible in Qt - is there another approach? Maybe there is an alternative event mechanism to signals and slots?
How to broadcast a signal in Qt4
0.066568
0
0
1,116
3,286,826
2010-07-20T03:36:00.000
0
0
0
0
python,qt4,pyqt,signals
3,300,104
3
false
0
1
Don't you just want a good old fashioned method invocation? The response is just the return value of the method.
3
3
0
I'm wanting a paradigm in a Qt4 (PyQt4) program where a component is able to respond to a signal without knowing anything about where it is coming from. My intial reading suggests that I have to explicitly connect signals to slots. But what I want is for any of a number of components to be able to send a signal, and for it to be processed by another component. Comparing with another toolkits, for example, in wxWidgets I would use events. These automatically propogate up from child windows/objects to parents. At each level they can be handled. This means if I have a lot of children which may emit the same event, I don't have to explicitly connect all of them to the handler. I can just put the handler in the parent, or some higher level in the window hierarchy. This means that only the event generator and consumer need to know about the event at all. The consumer doesn't need to know where the source of the event is, how many such sources there are, or anything else about it. Is this possible in Qt - is there another approach? Maybe there is an alternative event mechanism to signals and slots?
How to broadcast a signal in Qt4
0
0
0
1,116
3,287,455
2010-07-20T06:13:00.000
0
0
0
0
python,wxpython,tags
3,294,064
2
false
1
1
There are a couple of approaches that come to my mind. If it's like a form letter where only specific parts will be replaced, then you can just should that to the user and have some text controls for them to fill in. Something like this: Dear #NAME, Thank you for contacting #COMPANY, blah blah blah And then have a text control for each of the replaceable parts. The other method would be to use the RichTextCtrl's Save As HTML functionality. See the wxPython Demo application for an example.
1
2
0
I am making a html window in wxpython and want to print it. Before that I need to enter user input (such as his name or such things ) in the html page. How to do that nicely? Thanks in advance,
How to insert dynamic string in wxpython html window? (wx.html.htmlwindow)
0
0
0
614
3,288,001
2010-07-20T07:58:00.000
5
0
0
0
python,tkinter,event-binding
3,288,050
3
true
0
0
Look at table 7-1 of the docs. There are events that specify motion while the button is pressed, <B1-Motion>, <B2-Motion> etc. If you're not talking about a press-and-move event, then you can start doing your activity on <Button-1> and stop doing it when you receive <B1-Release>.
2
6
0
I need a command to be executed as long as the left mouse button is being held down.
How do I bind an event to the left mouse button being held down?
1.2
0
0
14,186
3,288,001
2010-07-20T07:58:00.000
1
0
0
0
python,tkinter,event-binding
3,288,017
3
false
0
0
Use the mouse move/motion events and check the modifier flags. The mouse buttons will show up there.
2
6
0
I need a command to be executed as long as the left mouse button is being held down.
How do I bind an event to the left mouse button being held down?
0.066568
0
0
14,186
3,288,047
2010-07-20T08:05:00.000
3
0
0
0
python,tkinter,mouse-position
3,288,196
2
false
0
1
Get the screen coordinates of the mouse move event (x/y_root) and subtract the screen coordinates of the window (window.winfo_rootx()/y()).
1
5
0
I need to get the mouse position relative to the tkinter window.
How do I get mouse position relative to the parent widget in tkinter?
0.291313
0
0
9,025
3,288,289
2010-07-20T08:42:00.000
0
0
0
1
python,windows,process
3,288,296
2
false
0
0
Python has no standard way to examine the executables you can start with the process API. How about you start the external command using cmd.exe? Or create a BAT script in %TEMP% and run that.
2
0
0
I'm looking for a Python function which behaves just like the Windows command interpreter cmd.exe when it comes to waiting for newly launched processes to finish. Right now I'm using os.system() but this function always blocks, even when launching GUI applications (which, in case they were written in C/C++, have a WinMain function and were linked with /SUBSYSTEM:WINDOWS). What code should I be using for launching external processes in case I do want the function to block when launching console applications, but I do not want it to block when launching GUI applications?
How do I launch a function and wait/don't wait on it depending on whether it's a GUI application?
0
0
0
606
3,288,289
2010-07-20T08:42:00.000
2
0
0
1
python,windows,process
3,288,395
2
true
0
0
You could write a small C wrapper/extension that checks for the subsystem (using ImageNtHeader). If all else fails, you can parse the PE headers directly.
2
0
0
I'm looking for a Python function which behaves just like the Windows command interpreter cmd.exe when it comes to waiting for newly launched processes to finish. Right now I'm using os.system() but this function always blocks, even when launching GUI applications (which, in case they were written in C/C++, have a WinMain function and were linked with /SUBSYSTEM:WINDOWS). What code should I be using for launching external processes in case I do want the function to block when launching console applications, but I do not want it to block when launching GUI applications?
How do I launch a function and wait/don't wait on it depending on whether it's a GUI application?
1.2
0
0
606
3,289,330
2010-07-20T11:15:00.000
0
1
0
0
python,cgi
3,289,546
2
false
1
0
Django and Pylons are both frameworks that solve this problem quite nicely, namely by abstracting the DB-frontend integration. They are worth considering.
1
1
0
I have 5 python cgi pages. I can navigate from one page to another. All pages get their data from the same database table just that they use different queries. The problem is that the application as a whole is slow. Though they connect to the same database, each page creates a new handle every time I visit it and handles are not shared by the pages. I want to improve performance. Can I do that by setting up sessions for the user? Suggestions/Advices are welcome. Thanks
Improving performance of cgi
0
1
0
179
3,289,430
2010-07-20T11:30:00.000
31
0
1
0
python,recursion
3,289,437
2
true
0
0
The default is 1000 levels deep and you can change that using the setrecursionlimit function in the sys module. Warning: Beware that some operating systems may start running into problems if you go much higher due to limited stack space.
1
27
0
What's the maximum level of recursion and how do I change it in Python?
Maximum level of recursion in Python
1.2
0
0
9,205
3,289,584
2010-07-20T11:50:00.000
0
0
0
0
python
3,289,731
3
false
1
0
Your task sounds interesting. :-) A scenario that just came into mind: You continuosly scrape the resources with your home-brew scripts, and push the results into your persistent database and a caching system -- like Redis -- simultanously. Your caching system/layer serves as primary data source when serving client requests. Redis f.e. is a high-performant key-value-store that is capable to handle 100k connections per second. Though only the n latest (say f.e. 50k entries) matter the caching system will only hold these entries and let you solely focus on developing the server-side API (handling connections, processing requests, reading from Redis) and the frontend. The communication between frontend and backend-API could be driven by WebSocket connections. A pretty new part of the HTML5 spec. Though, however, already supported by many browser versions released these days. Alternatively you could fallback on some asynchronous Flash Socket-stuff. Websockets basically allow for persistent connections between a client and a server; you can register event listener that are called for every incoming data/-packet -- no endless polling or other stuff.
1
8
0
This is my first questions here, so I hope it will be done correctly ;) I've been assigned the task to give a web interface to some "home made" python script. This script is used to check some web sites/applications availability, via curl commands. A very important aspect of this script is that it gives its results in real-time, writing line by line to the standard output. By giving a web interface to this script, the main goal is that the script can be easily used from anywhere, for example via a smartphone. So the web interface must be quite basic, and work "plugin-free". My problem is that most solutions I thought or found on the web (ajax, django, even a simple post) seem to be needing a full generation of the page before sending it to the browser, losing this important "real-time" aspect. Any idea on how to do this properly ? Thanks in advance.
Web-ifing a python command line script?
0
0
1
3,095
3,289,822
2010-07-20T12:22:00.000
5
0
1
0
python,list,reference,copy
3,289,832
4
true
0
0
Use a slice notation. newlist = oldlist This will assign a second name to the same list newlist = oldlist[:] This will duplicate each element of oldlist into a complete new list called newlist
1
2
0
How do I copy the contents of a list and not just a reference to the list in Python?
lists in python, with references
1.2
0
0
191
3,290,443
2010-07-20T13:31:00.000
0
0
0
0
python,textures,blender
5,252,616
1
false
0
0
What you could do is (if you are using Blender 2.49b) set the image of the Texture object and the uvlayer property of the MTex object.
1
0
0
I'm trying to access UV Layer in Blender from Python and basically API returns UV Layer only as a string. Thing is I want to assign new Image object to current UV Layer ( I use TexFace on the side of material ) and then just bake lighting. All meshes are currently unwrapped, the only thing which is missing is an Image and I have no idea how to add image I will bake lighting to from Python level. Thanks, J
Blender, UV Layer, Image and Python
0
0
0
1,058
3,291,123
2010-07-20T14:41:00.000
1
0
1
0
python,unicode,internationalization,urlencode,utf-8
3,291,276
6
false
0
0
"...".encode("utf-8") transforms the in-memory representation of the string into an UTF-8 -encoded string. url encoder likely expected a bytestring, that is, string representation where each character is represented with a single byte.
3
9
0
I wanted to url encode a python string and got exceptions with hebrew strings. I couldn't fix it and started doing some guess oriented programming. Finally, doing mystr = mystr.encode("utf8") before sending it to the url encoder saved the day. Can somebody explain what happened? What does .encode("utf8") do? My original string was a unicode string anyways (i.e. prefixed by a u).
Python: what does "...".encode("utf8") fix?
0.033321
0
0
9,631
3,291,123
2010-07-20T14:41:00.000
13
0
1
0
python,unicode,internationalization,urlencode,utf-8
3,291,374
6
false
0
0
My original string was a unicode string anyways (i.e. prefixed by a u) ...which is the problem. It wasn't a "string", as such, but a "Unicode object". It contains a sequence of Unicode code points. These code points must, of course, have some internal representation that Python knows about, but whatever that is is abstracted away and they're shown as those \uXXXX entities when you print repr(my_u_str). To get a sequence of bytes that another program can understand, you need to take that sequence of Unicode code points and encode it. You need to decide on the encoding, because there are plenty to choose from. UTF8 and UTF16 are common choices. ASCII could be too, if it fits. u"abc".encode('ascii') works just fine. Do my_u_str = u"\u2119ython" and then type(my_u_str) and type(my_u_str.encode('utf8')) to see the difference in types: The first is <type 'unicode'> and the second is <type 'str'>. (Under Python 2.5 and 2.6, anyway). Things are different in Python 3, but since I rarely use it I'd be talking out of my hat if I tried to say anything authoritative about it.
3
9
0
I wanted to url encode a python string and got exceptions with hebrew strings. I couldn't fix it and started doing some guess oriented programming. Finally, doing mystr = mystr.encode("utf8") before sending it to the url encoder saved the day. Can somebody explain what happened? What does .encode("utf8") do? My original string was a unicode string anyways (i.e. prefixed by a u).
Python: what does "...".encode("utf8") fix?
1
0
0
9,631
3,291,123
2010-07-20T14:41:00.000
0
0
1
0
python,unicode,internationalization,urlencode,utf-8
3,291,277
6
false
0
0
It returns a UTF-8 encoded version of the Unicode string, mystr. It is important to realize that UTF-8 is simply 1 way of encoding Unicode. Python can work with many other encodings (eg. mystr.encode("utf32") or even mystr.encode("ascii")).
3
9
0
I wanted to url encode a python string and got exceptions with hebrew strings. I couldn't fix it and started doing some guess oriented programming. Finally, doing mystr = mystr.encode("utf8") before sending it to the url encoder saved the day. Can somebody explain what happened? What does .encode("utf8") do? My original string was a unicode string anyways (i.e. prefixed by a u).
Python: what does "...".encode("utf8") fix?
0
0
0
9,631