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
2,812,520
2010-05-11T16:32:00.000
0
0
1
0
python,pip
56,779,686
25
false
0
0
For windows specifically: \path\to\python.exe -m pip install PackageName works.
4
662
0
Is there any way to make pip play well with multiple versions of Python? For example, I want to use pip to explicitly install things to either my site 2.5 installation or my site 2.6 installation. For example, with easy_install, I use easy_install-2.{5,6}. And, yes — I know about virtualenv, and no — it's not a solution to this particular problem.
Dealing with multiple Python versions and PIP?
0
0
0
806,792
2,812,520
2010-05-11T16:32:00.000
0
0
1
0
python,pip
49,317,258
25
false
0
0
You can go to for example C:\Python2.7\Scripts and then run cmd from that path. After that you can run pip2.7 install yourpackage... That will install package for that version of Python.
4
662
0
Is there any way to make pip play well with multiple versions of Python? For example, I want to use pip to explicitly install things to either my site 2.5 installation or my site 2.6 installation. For example, with easy_install, I use easy_install-2.{5,6}. And, yes — I know about virtualenv, and no — it's not a solution to this particular problem.
Dealing with multiple Python versions and PIP?
0
0
0
806,792
2,812,520
2010-05-11T16:32:00.000
31
0
1
0
python,pip
37,308,766
25
false
0
0
It worked for me in windows this way: I changed the name of python files python.py and pythonw.exe to python3.py pythonw3.py Then I just ran this command in the prompt: python3 -m pip install package
4
662
0
Is there any way to make pip play well with multiple versions of Python? For example, I want to use pip to explicitly install things to either my site 2.5 installation or my site 2.6 installation. For example, with easy_install, I use easy_install-2.{5,6}. And, yes — I know about virtualenv, and no — it's not a solution to this particular problem.
Dealing with multiple Python versions and PIP?
1
0
0
806,792
2,812,520
2010-05-11T16:32:00.000
76
0
1
0
python,pip
2,812,627
25
false
0
0
/path/to/python2.{5,6} /path/to/pip install PackageName doesn't work? For this to work on any python version that doesn't have pip already installed you need to download pip and do python*version* setup.py install. For example python3.3 setup.py install. This resolves the import error in the comments. (As suggested by @hbdgaf)
4
662
0
Is there any way to make pip play well with multiple versions of Python? For example, I want to use pip to explicitly install things to either my site 2.5 installation or my site 2.6 installation. For example, with easy_install, I use easy_install-2.{5,6}. And, yes — I know about virtualenv, and no — it's not a solution to this particular problem.
Dealing with multiple Python versions and PIP?
1
0
0
806,792
2,812,954
2010-05-11T17:27:00.000
4
1
1
0
python,lisp,compilation,dynamic-languages
2,819,922
4
false
0
0
Actually, there isn't anything that stops you from statically compile a Python program, it's just that no-one wrote such a compiler so far (I personally find Python's runtime to be very easy compared to CL's). You could say that the difference lies in details like "how much time was spent on actually writing compilers and does the language have a formal specification of how to write one". Let's address those points: Lisp compilers have been evolving for over 40 years now, with work starting back in 70's if not earlier (I'm not sure of my dates, too lazy too google exact ones). That creates a massive chunk of lore about how to write a compiler. OTOH, Python was nominally designed as "teaching language", and as such compilers weren't that important. Lack of specification - Python doesn't have a single source specifying exact semantics of the language. Sure, you can point to PEP documents, but it still doesn't change the fact that the only real spec is the source of the main implementation, CPython. Which, nota bene, is a simple compiler of sorts (into bytecode). As for whether it is possible - Python uses quite simple structure to deal with symbols etc., namely its dictionaries. You can treat them as symbol table of a program. You can tag the data types to recognize primitive ones and get the rest based on stored naming and internal structure. rest of the language is also quite simple. The only bit missing is actual work to implement it, and make it run correctly.
3
13
0
Why can Lisp with all its dynamic features be statically compiled but Python cannot (without losing all its dynamic features)?
Lisp vs Python -- Static Compilation
0.197375
0
0
2,658
2,812,954
2010-05-11T17:27:00.000
13
1
1
0
python,lisp,compilation,dynamic-languages
2,813,126
4
true
0
0
There is nothing that prevents static compilation of Python. It's a bit less efficient because Python reveals more mutable local scope, also, to retain some of the dynamic properties (e.g. eval) you need to include the compiler with the compiled program but nothing prevents that too. That said, research shows that most Python programs, while dynamic under static analysis, are rather static and monomorphic at runtime. This means that runtime JIT compilation approaches work much better on Python programs. See unladen-swallow, PyPy, Psyco for approaches that do compile Python into machine code. But also IronPython and Jython that use a virtual machines originally intended for a static languages to compile Python into machinecode.
3
13
0
Why can Lisp with all its dynamic features be statically compiled but Python cannot (without losing all its dynamic features)?
Lisp vs Python -- Static Compilation
1.2
0
0
2,658
2,812,954
2010-05-11T17:27:00.000
4
1
1
0
python,lisp,compilation,dynamic-languages
2,854,477
4
false
0
0
Python can be 'compiled', where compilation is seen as a translation from one Turing Complete language (source code) to another (object code). However in Lisp, the object is assembly, something which is theoretically possible with Python (proven) but not feasible. The true reason however is less flattening. Lisp is in many ways a revolutionary language that pioneered in its dialects a lot of the features in programming languages we are used to today. In Lisps however they just 'follow' logically from the basics of the language. Language which are inspired by the raw expressive powers of lisps such as JavaScript, Ruby, Perl and Python are necessarily interpreted because getting those features in a language with an 'Algol-like syntax' is just hard. Lisp gains these features from being 'homo-iconic' there is no essential difference between a lisp program, and a lisp data-structure. Lisp programs are data-structures, they are structural descriptions of a program in such an S-expression if you like, therefore a compiled lisp program effectively 'interprets itself' without the need of a lexer and all that stuff, a lisp program could just be seen as a manual input of parse tree. Which necessitates a syntax which many people find counter-intuitive to work with, therefore there were a lot of attempts to transport the raw expressive power of the paradigm to a more readable syntax, which means that it's infeasible, but not impossible, to compile it towards assembly. Also, compiling Python to assembly would possibly be slower and larger than 'half-interpreting' it on a virtual machine, a lot of features in python depend upon a syntactic analysis. The above though is written by a huge lisp fanboy, keep that conflict of interest in mind.
3
13
0
Why can Lisp with all its dynamic features be statically compiled but Python cannot (without losing all its dynamic features)?
Lisp vs Python -- Static Compilation
0.197375
0
0
2,658
2,815,094
2010-05-11T23:15:00.000
0
0
0
0
python,django,eclipse,ide,pydev
44,662,580
2
false
1
0
Navigate to Window->Preferences->PyDev->Interpreters–>Python Interpreter From Libraries (System PYTHONPATH), make sure ..lib/site-packages is listed. Remove any mention of lib/site-packages/Django
2
4
0
I'm using PyDev with Django. The autocomplete works nicely in the shell - I start typing, and it suggests completions. However, this doesn't work in the main code editor window. How can I fix this? I'm using: Eclipse build #20100218-1602 PyDev 1.5.6 Eclipse IDE for Java Devs 1.2.2
PyDev and Django: Autocomplete not detecting Django?
0
0
0
3,244
2,815,094
2010-05-11T23:15:00.000
8
0
0
0
python,django,eclipse,ide,pydev
2,816,189
2
true
1
0
You might need to set the editor code completion settings. They are under: Window->Preferences->PyDev->Editor->Code Completion You might also need to add the Django install or your Django project to your path. You can set this under: Window->Preferences->PyDev->Interpreter - Python Hope this helps.
2
4
0
I'm using PyDev with Django. The autocomplete works nicely in the shell - I start typing, and it suggests completions. However, this doesn't work in the main code editor window. How can I fix this? I'm using: Eclipse build #20100218-1602 PyDev 1.5.6 Eclipse IDE for Java Devs 1.2.2
PyDev and Django: Autocomplete not detecting Django?
1.2
0
0
3,244
2,819,134
2010-05-12T13:21:00.000
3
0
0
0
asp.net,asp.net-mvc,ironpython,dynamic-language-runtime
2,820,043
1
true
1
0
I've just started using IronPython as extensibility point in my ASP.NET MVC aplication. I have one ipy engine (in static property) and for each request I create new scope and execute the script in that scope. Each scope should be independent on other scopes, no locking is needed. If I run into issues, I'll post it here. However, I don't expect any ;)
1
2
0
I would like to create an ASP.NET MVC web application which has extensible logic that does not require a re-build. I was thinking of creating a filter which had an instance of the IronPython engine. What I would like to know is: how much overhead is there in creating a new engine during each web request, and would it be a better idea to keep a static engine around? However, if I were to keep a single static engine around, what are the issues I might run into as far as locking and script scope? Is it possible to have multiple scopes in the same IropPython engine so I don't get variable collision and security issues between web requests?
Eval IronPython Scripts during ASP.NET Web Request; Static Engine or Not
1.2
0
0
310
2,819,832
2010-05-12T14:41:00.000
6
0
1
0
python,restructuredtext,python-sphinx,docutils
2,837,522
9
false
0
0
vi is very good at this. I was just editing some .rst files right now and it colors the headings, monospaced text, etc. The macros let you very quickly turn text into headings and whatnot.
2
14
0
I'm just learning Sphinx, and I need to edit ReST files. Is there an intelligent editor for it? Like, an editor that gives me code coloration, easy indentation, code completion (hopefully), etc.
Is there an intelligent editor for ReST files?
1
0
0
4,719
2,819,832
2010-05-12T14:41:00.000
1
0
1
0
python,restructuredtext,python-sphinx,docutils
2,991,618
9
false
0
0
jEdit also has ReST highlighting, but no ReST specific auto-completion features (it does support macros though). I would opt for vim or Cream, personally.
2
14
0
I'm just learning Sphinx, and I need to edit ReST files. Is there an intelligent editor for it? Like, an editor that gives me code coloration, easy indentation, code completion (hopefully), etc.
Is there an intelligent editor for ReST files?
0.022219
0
0
4,719
2,820,705
2010-05-12T16:16:00.000
3
0
1
0
python,language-features,language-comparisons
2,820,886
4
false
0
0
Probably the prime reason I use Python is because it's very good at self-documenting. There are lots of other reasons too, but probably the best way to find out is to do something with it. Find a project and see what it takes to do it in Python. It may not be great Python code, but you'll learn more about how it suits you than from an essay. I know the first time I looked at Python, I didn't give it much chance (just looked like Matlab as far as I was concerned), but after using it for a couple of years, I have to say I have no regrets.
1
1
0
Is there any article/paper on what features the Python language has to offer? Why should one go with Python instead of any other language? What are the strong and the weak points of Python?
Python features
0.148885
0
0
714
2,821,702
2010-05-12T18:33:00.000
9
0
0
0
python,django,django-models
2,824,112
7
true
1
0
I just used my own subclass of Site and created a custom admin for it. Basically, when you subclass a model in django it creates FK pointing to parent model and allows to access parent model's fields transparently- the same way you'd access parent class attributes in pyhon. Built in admin won't suffer in any way, but you'll have to un-register Sites ModelAdmin and register your own ModelAdmin.
2
12
0
What is the best approach to extending the Site model in django? Creating a new model and ForeignKey the Site or there another approach that allows me to subclass the Site model? I prefer subclassing, because relationally I'm more comfortable, but I'm concerned for the impact it will have with the built-in Admin.
How do you extend the Site model in django?
1.2
0
0
4,589
2,821,702
2010-05-12T18:33:00.000
3
0
0
0
python,django,django-models
45,414,164
7
false
1
0
You can have another model like SiteProfile which has a OneToOne relation with Site.
2
12
0
What is the best approach to extending the Site model in django? Creating a new model and ForeignKey the Site or there another approach that allows me to subclass the Site model? I prefer subclassing, because relationally I'm more comfortable, but I'm concerned for the impact it will have with the built-in Admin.
How do you extend the Site model in django?
0.085505
0
0
4,589
2,822,677
2010-05-12T20:51:00.000
11
0
1
0
python,multithreading,runtime-error
2,822,737
3
true
0
0
Threads cannot be restarted. You must re-create the Thread in order to start it again.
1
6
0
I have a thread that gets executed when some action occurs. Given the logic of the program, the thread cannot possibly be started while another instance of it is still running. Yet when I call it a second time, I get a "RuntimeError: thread already started" error. I added a check to see if it is actually alive using the Thread.is_alive() function, and it is actually dead. What am I doing wrong? I can provide more details as are needed.
Python Terminated Thread Cannot Restart
1.2
0
0
4,756
2,823,907
2010-05-13T01:22:00.000
-1
0
0
0
python,opengl,graphics
2,826,036
5
false
0
1
I used openGL with C++ a few years back - found it quite low level. I also have used Java3D which seemed to be a bit higher level. If you are not stuck on using python - try Java3D - very simple to get up and running.
1
3
0
I am looking for a graphics library for 3D reconstruction research to develop my specific viewer based on some library. OpenGL seems in a low level and I have to remake the wheel everywhere. And I also tried VTK(visualization toolkit). However, it seems too abstract that I need to master many conceptions before I start. Is there any other graphics library? I prefer to program in python. So I would like the library has a python wrapper. I think something like O3D would be better. But O3D is for javascript and it seems that Google already stops the development.
Is there any graphics library in a higher level than OpenGL
-0.039979
0
0
2,730
2,823,983
2010-05-13T01:45:00.000
6
0
0
0
python,oop
2,824,002
4
true
0
1
I find that the best way to learn a new language is by doing something like this (small project of your own). Python is no different. Everything you wrote can be done in Python, so I can't find any reason not to use it, if you want to learn.
4
2
0
I have a project idea, but unsure if using Python would be a good idea. Firstly, I'm a C++ and C# developer with some SQL experience. My day job is C++. I have a project idea i'd like to create and was considering developing it in a language I don't know. Python seems to be popular and has piqued my interests. I definitely use OOP in programming and I understand Python would work fine with that style. I could be way off on this, I've only read small bits and pieces about the language. The project won't be public or anything, just purely something of my own creation do dabble in at home. So the project would essentially represent a simple game idea I have. The game would consist roughly these things: Data structures to hold specific information (would be strongly typed). A way to output the gamestate for the players. This is completely up in the air, it can be graphical or text based, I don't really care at this point. A way to save off game data for the players in something like a database or file system. A relatively easy way for me to input information and a 'GO' button which processes the changes and obviously creates a new gamestate. The game would function similar to a board game. Really nothing out of the ordinary when I look back at that list. Would this be a fun way to learn Python or should I select another language?
Idea for a small project, should I use Python?
1.2
0
0
823
2,823,983
2010-05-13T01:45:00.000
3
0
0
0
python,oop
2,824,090
4
false
0
1
I've already voted for del-boy's answer, but I would like to go further and say that if your goals are to (1) have fun, (2) learn a new language, and (3) write your own game, then Python is a slam-dunk, no-brainer, awesome choice to achieve all three. The language excels at all the things you seem to be looking for (see Alex Martelli's answer for the caveat on strong typing), and in my opinion is not much of a "stretch" from the C family of languages (I think you will find most things simply easier, rather than strange), compared to other good languages such as Ruby or Lua.
4
2
0
I have a project idea, but unsure if using Python would be a good idea. Firstly, I'm a C++ and C# developer with some SQL experience. My day job is C++. I have a project idea i'd like to create and was considering developing it in a language I don't know. Python seems to be popular and has piqued my interests. I definitely use OOP in programming and I understand Python would work fine with that style. I could be way off on this, I've only read small bits and pieces about the language. The project won't be public or anything, just purely something of my own creation do dabble in at home. So the project would essentially represent a simple game idea I have. The game would consist roughly these things: Data structures to hold specific information (would be strongly typed). A way to output the gamestate for the players. This is completely up in the air, it can be graphical or text based, I don't really care at this point. A way to save off game data for the players in something like a database or file system. A relatively easy way for me to input information and a 'GO' button which processes the changes and obviously creates a new gamestate. The game would function similar to a board game. Really nothing out of the ordinary when I look back at that list. Would this be a fun way to learn Python or should I select another language?
Idea for a small project, should I use Python?
0.148885
0
0
823
2,823,983
2010-05-13T01:45:00.000
1
0
0
0
python,oop
2,824,020
4
false
0
1
Well, if you do C++/C#, I'd say go for it - I personally love C++ because it is (in my opinion) self-intuitive and easy. The 'grammar' of Python doesn't make much sense. Plus, if you already know another language, why learn Python for fun? I mean, if you want to create a simple project for fun, it's really not worth it, and you'll end up working for several weeks at least, before you can begin your game. So yeah, you should definitely use C++. However, if you're just trying to learn a new language, there's nothing wrong with that; Python certainly is pretty popular. Javascript is pretty easy as well, as it uses automatic inference and all that jazz.
4
2
0
I have a project idea, but unsure if using Python would be a good idea. Firstly, I'm a C++ and C# developer with some SQL experience. My day job is C++. I have a project idea i'd like to create and was considering developing it in a language I don't know. Python seems to be popular and has piqued my interests. I definitely use OOP in programming and I understand Python would work fine with that style. I could be way off on this, I've only read small bits and pieces about the language. The project won't be public or anything, just purely something of my own creation do dabble in at home. So the project would essentially represent a simple game idea I have. The game would consist roughly these things: Data structures to hold specific information (would be strongly typed). A way to output the gamestate for the players. This is completely up in the air, it can be graphical or text based, I don't really care at this point. A way to save off game data for the players in something like a database or file system. A relatively easy way for me to input information and a 'GO' button which processes the changes and obviously creates a new gamestate. The game would function similar to a board game. Really nothing out of the ordinary when I look back at that list. Would this be a fun way to learn Python or should I select another language?
Idea for a small project, should I use Python?
0.049958
0
0
823
2,823,983
2010-05-13T01:45:00.000
5
0
0
0
python,oop
2,824,031
4
false
0
1
Python seems very suitable to your purposes (e.g., pygame and other popular third party extensions make it easy to achieve nice graphics, and you can also choose curses for structured textual I/O, etc) with the single exception of what you probably mean by "strongly typed". Python is strongly typed (there is no way you can erroneously use a string for an operation for which an integer is required, and vice versa, for example), but it's dynamic strong typing: each object has a strong type, but names (in the wide sense, including barenames, compound names, items in containers, ...) do not have types -- each name refers to an object, the object has the type, not the name. You can rebind the name to a different object, and that object may have a different (strong;-) type than whatever object was previously bound to that same name. Dynamic languages all have this character, even though many go further than Python in "type laxity" ("confusing" strings and numbers, and different kinds of numbers, while Python distinguishes strings from integers from floating-point numbers, for example) -- Python is quite "type-picky"... in the dynamic sense where names, per se, have no types, though;-).
4
2
0
I have a project idea, but unsure if using Python would be a good idea. Firstly, I'm a C++ and C# developer with some SQL experience. My day job is C++. I have a project idea i'd like to create and was considering developing it in a language I don't know. Python seems to be popular and has piqued my interests. I definitely use OOP in programming and I understand Python would work fine with that style. I could be way off on this, I've only read small bits and pieces about the language. The project won't be public or anything, just purely something of my own creation do dabble in at home. So the project would essentially represent a simple game idea I have. The game would consist roughly these things: Data structures to hold specific information (would be strongly typed). A way to output the gamestate for the players. This is completely up in the air, it can be graphical or text based, I don't really care at this point. A way to save off game data for the players in something like a database or file system. A relatively easy way for me to input information and a 'GO' button which processes the changes and obviously creates a new gamestate. The game would function similar to a board game. Really nothing out of the ordinary when I look back at that list. Would this be a fun way to learn Python or should I select another language?
Idea for a small project, should I use Python?
0.244919
0
0
823
2,824,244
2010-05-13T03:23:00.000
2
0
0
0
python,sql,sqlalchemy
2,828,580
2
true
0
0
"or some kind of parser" I've found MySQL to be a great parser for MySQL dump files :) You said it yourself: "so it has quite a few commands/syntax that sqlite3 does not understand correctly." Clearly then, SQLite is not the tool for this task. As for your particular error: without context (i.e. a traceback) there's nothing I can say about it. Martelli or Skeet could probably reach across time and space and read your interpreter's mind, but me, not so much.
2
5
0
I have a large sql dump file ... with multiple CREATE TABLE and INSERT INTO statements. Is there any way to load these all into a SQLAlchemy sqlite database at once. I plan to use the introspected ORM from sqlsoup after I've created the tables. However, when I use the engine.execute() method it complains: sqlite3.Warning: You can only execute one statement at a time. Is there a way to work around this issue. Perhaps splitting the file with a regexp or some kind of parser, but I don't know enough SQL to get all of the cases for the regexp. Any help would be greatly appreciated. Will EDIT: Since this seems important ... The dump file was created with a MySQL database and so it has quite a few commands/syntax that sqlite3 does not understand correctly.
How can I load a sql "dump" file into sql alchemy
1.2
1
0
3,406
2,824,244
2010-05-13T03:23:00.000
0
0
0
0
python,sql,sqlalchemy
2,828,621
2
false
0
0
The SQL recognized by MySQL and the SQL in SQLite are quite different. I suggest dumping the data of each table individually, then loading the data into equivalent tables in SQLite. Create the tables in SQLite manually, using a subset of the "CREATE TABLE" commands given in your raw-dump file.
2
5
0
I have a large sql dump file ... with multiple CREATE TABLE and INSERT INTO statements. Is there any way to load these all into a SQLAlchemy sqlite database at once. I plan to use the introspected ORM from sqlsoup after I've created the tables. However, when I use the engine.execute() method it complains: sqlite3.Warning: You can only execute one statement at a time. Is there a way to work around this issue. Perhaps splitting the file with a regexp or some kind of parser, but I don't know enough SQL to get all of the cases for the regexp. Any help would be greatly appreciated. Will EDIT: Since this seems important ... The dump file was created with a MySQL database and so it has quite a few commands/syntax that sqlite3 does not understand correctly.
How can I load a sql "dump" file into sql alchemy
0
1
0
3,406
2,824,579
2010-05-13T05:26:00.000
3
1
1
0
c++,python
2,824,708
4
false
0
0
I can't comment on Python, but in C++, structs provide public access by default. The primary reason you want a private part of your class is that, without one, it is impossible to guarantee your invariants are satisfied. If you have a string class, for instance, that is supposed to keep track of the length of the string, you need to be able to track insertions. But if the underlying char* member is public, you can't do that. Anybody can just come along and tack something onto the end, or overwrite your null terminator, or call delete[] on it, or whatever. When you call your length() member, you just have to hope for the best.
3
2
0
In c++ instance variables are private by default,in Python variables are public by default i have two questions regarding the same:- 1: why Python have all the members are public by default? 2: People say you should your member data should be private what if i make my data to be public? what are the disadvantages of this approch? why it is a bad design?
what if i keep my class members are public?
0.148885
0
0
303
2,824,579
2010-05-13T05:26:00.000
1
1
1
0
c++,python
2,824,800
4
false
0
0
It's really a question of language design philosophies. I favour the Python camp so might come down a little heavy handedly on the C++ style but the bottom line is that in C++ it's possible to forcibly prevent users of your class from accessing certain internal parts. In Python, it's a matter of convention and stating that it's internal. Some applications might want to access the internal member for non-malignant purposes (eg. documentation generators). Some users who know what they're doing might want to do the same. People who want to shoot themselves in the foot twiddling with the internal details are not protected from suicide. Like Dennis said "Anybody can just come along and tack something onto the end, or overwrite your null terminator". Python treats the user like an adult and expects her to take care of herself. C++ protects the user as one would a child.
3
2
0
In c++ instance variables are private by default,in Python variables are public by default i have two questions regarding the same:- 1: why Python have all the members are public by default? 2: People say you should your member data should be private what if i make my data to be public? what are the disadvantages of this approch? why it is a bad design?
what if i keep my class members are public?
0.049958
0
0
303
2,824,579
2010-05-13T05:26:00.000
13
1
1
0
c++,python
2,824,654
4
true
0
0
You can use a leading underscore in the name to tell readers of the code that the name in question is an internal detail and they must not rely on it remaining in future versions. Such a convention is really all you need -- why weigh the language down with an enforcement mechanism? Data, just like methods, should be public (named without a leading underscore) if they're part of your class's designed API which you intend to support going forward. In C++, or Java, that's unlikely to happen because if you want to change the data member into an accessor method, you're out of luck -- you'll have to break your API and every single client of the class will have to change. In Python, and other languages supporting a property-like construct, that's not the case -- you can always replace a data member with a property which calls accessor methods transparently, the API does not change, nor does client code. So, in Python and other languages with property-like constructs (I believe .NET languages are like that, at source-code level though not necessarily at bytecode level), you may as well leave your data public when it's part of the API and no accessors are currently needed (you can always add accessor methods to later implementation releases if need be, and not break the API). So it's not really a general OO issue, it's language specific: does a given language support a property-like construct. Python does.
3
2
0
In c++ instance variables are private by default,in Python variables are public by default i have two questions regarding the same:- 1: why Python have all the members are public by default? 2: People say you should your member data should be private what if i make my data to be public? what are the disadvantages of this approch? why it is a bad design?
what if i keep my class members are public?
1.2
0
0
303
2,825,100
2010-05-13T07:38:00.000
1
0
0
1
python
2,825,228
3
false
0
0
As xitrium mentioned, it would be better if you used telnetlib. You can dispense with the whole mess of shell redirection etc. If you do something like telnet foo | process.py, you can read your programs stdin (sys.stdin) to get the output of the telnet program. When you're happy, you can exit and terminate the pipeline. subprocess.Popen would be used if you're trying to open the telnet program as a subprocess of the interpreter. I'm not sure you wanted that. In any case, telnetlib is the right way to go it seems. If you simply want an output text processor, consider perl. It's strengths lean in that direction.
1
1
0
My problem is that i want to do something like this in linux console telnet 192.168.255.28 > process.py i.e i would like to do some transformation with console telnet output using python script. I'm see Popen in python for this case, but i can't understand how can i get input from telnet if it do not stop all time.. Pleas any ideas.
catch output from linux telnet to a python script
0.066568
0
0
1,408
2,826,387
2010-05-13T11:37:00.000
0
0
0
0
python,mysql
2,827,845
4
false
0
0
I'd add a "todelete tinyint(1) not null default 1" column to the table, update it to 0 for those id's which have to be kept, then delete from table where todelete;. It's faster than not in. Or, create a table with the same structure as yours, insert the kept rows there and rename tables. Then, drop the old one.
1
3
0
I want to delete all records in a mysql db except the record id's I have in a list. The length of that list can vary and could easily contain 2000+ id's, ... Currently I convert my list to a string so it fits in something like this: cursor.execute("""delete from table where id not in (%s)""",(list)) Which doesn't feel right and I have no idea how long list is allowed to be, .... What's the most efficient way of doing this from python? Altering the structure of table with an extra field to mark/unmark records for deletion would be great but not an option. Having a dedicated table storing the id's would indeed be helpful then this can just be done through a sql query... but I would really like to avoid these options if possible. Thanks,
delete all records except the id I have in a python list
0
1
0
3,327
2,826,734
2010-05-13T12:32:00.000
0
1
0
0
python,testing,automated-tests,system-testing
6,698,351
3
false
0
0
The TTCN3 is a quite good test framework for black-box testing. The comercial tools are having lot of reporting stuff there. It is not in python.
1
16
0
I am looking for good End to End testing framework under python, where the tests can be written in python and managed in a comfortable way. I know there are many unit testing frameworks, but I am looking for bigger scope, something like test director with support for reports etc,where a whole system is under test.
Good automated system testing framework in python
0
0
0
22,530
2,829,637
2010-05-13T19:21:00.000
-3
0
0
0
c++,python,c,perl,socks
2,829,664
2
false
0
1
VC++ has extensive support if you want to try on Windows. Google "Windows sockets for beginners msdn", great info for windows sockets... If linux, try C sockets by beej... Just google beej's guide for sockets...
1
2
0
How do i add SOCKS support to my application? and where can i get the libs? any help appreciated thanks
SOCKS in C/C++ or another language?
-0.291313
0
0
867
2,829,993
2010-05-13T20:17:00.000
0
0
0
0
python,wxpython
5,441,284
1
false
0
1
Use wx.FindWindowById(wx.ID_FORWARD) this will return a wxWindow object representing the Next button. Call methods on it. e.g. wx.FindWindowById(wx.ID_FORWARD).disable() would disable the Next Button.
1
0
0
I'm using the wxWizard widget in wxPython. Is there any way I could change the text of the next button on a page? Can i change the visibility of the navigation buttons on any page? Can I enable/disable the navigation buttons? I tried looking for answers to these questions on the wxPython site but it doesn't seem to be documented.
Access properties of navigation buttons in wxPython's wxWizard
0
0
0
211
2,830,326
2010-05-13T21:09:00.000
0
1
0
0
python
2,830,485
1
false
0
0
Basically what you need to do is create a raw socket, receive a datagram, and examine the destination address in the header. If that address is a broadcast address for the network adapter the socket is bound to, then you're golden. I don't know how to do this in Python, so I suggest looking for examples of raw sockets and go from there. Bear in mind, you will need root access to use raw sockets, and you had better be real careful if you plan on sending using a raw socket. As you might imagine, this will not be a fun thing to do. I suggest trying to find a way to avoid doing this.
1
0
0
How can I distinguish between a broadcasted message and a direct message for my ip? I'm doing this in python.
Distinguishing between broadcasted messages and direct messages
0
0
1
83
2,830,358
2010-05-13T21:14:00.000
38
1
1
0
python,optimization
2,830,411
4
true
0
0
assert statements are completely eliminated, as are statement blocks of the form if __debug__: ... (so you can put your debug code in such statements blocks and just run with -O to avoid that debug code). With -OO, in addition, docstrings are also eliminated.
1
45
0
I cannot seem to find a good simple explanation of what python does differently when running with the -O or optimize flag.
What are the implications of running python with the optimize flag?
1.2
0
0
17,421
2,830,880
2010-05-13T23:02:00.000
8
0
1
0
python,multithreading,gil
2,830,905
5
false
0
0
The GIL is not held by the Python interpreter when doing network operations. If you are doing work that is network-bound (like a crawler), you can safely ignore the effects of the GIL. On the other hand, you may want to measure your performance if you create lots of threads doing processing (after downloading). Limiting the number of threads there will reduce the effects of the GIL on your performance.
2
10
0
Was looking to write a little web crawler in python. I was starting to investigate writing it as a multithreaded script, one pool of threads downloading and one pool processing results. Due to the GIL would it actually do simultaneous downloading? How does the GIL affect a web crawler? Would each thread pick some data off the socket, then move on to the next thread, let it pick some data off the socket, etc..? Basically I'm asking is doing a multi-threaded crawler in python really going to buy me much performance vs single threaded? thanks!
Does a multithreaded crawler in Python really speed things up?
1
0
1
5,361
2,830,880
2010-05-13T23:02:00.000
1
0
1
0
python,multithreading,gil
2,830,933
5
false
0
0
Another consideration: if you're scraping a single website and the server places limits on the frequency of requests your can send from your IP address, adding multiple threads may make no difference.
2
10
0
Was looking to write a little web crawler in python. I was starting to investigate writing it as a multithreaded script, one pool of threads downloading and one pool processing results. Due to the GIL would it actually do simultaneous downloading? How does the GIL affect a web crawler? Would each thread pick some data off the socket, then move on to the next thread, let it pick some data off the socket, etc..? Basically I'm asking is doing a multi-threaded crawler in python really going to buy me much performance vs single threaded? thanks!
Does a multithreaded crawler in Python really speed things up?
0.039979
0
1
5,361
2,831,212
2010-05-14T00:55:00.000
1
0
1
0
python,list,performance,data-structures,set
50,210,108
10
false
0
0
I would recommend a Set implementation where the use case is limit to referencing or search for existence and Tuple implementation where the use case requires you to perform iteration. A list is a low-level implementation and requires significant memory overhead.
1
238
0
In Python, which data structure is more efficient/speedy? Assuming that order is not important to me and I would be checking for duplicates anyway, is a Python set slower than a Python list?
Python Sets vs Lists
0.019997
0
0
203,899
2,831,779
2010-05-14T04:10:00.000
3
0
0
0
python,gtk,pygtk,gtktreeview
2,835,863
2
true
0
1
There is no way to do that in PyGTK currently. "rows-reordered" is the correct signal, but it is impossible to derive any information from it in PyGTK other than "somehow reordered". In C GTK+ you could use the same signal and get the required information in callback, but not in Python.
1
1
0
I have a simple gtk.TreeView with a gtk.ListStore model and set_reorderable(True), I want to catch the signal/event emited when the user reorder through drag&drop the list, but the documentation does not help much: "The application can listen to these changes by connecting to the model's signals" So I tried to connect the model (ListStore) signals... but surprise! ListStore has no signals, so you are dispatched to TreeModel signals, then I tried to connect with the TreeModel "rows-reordered" signal with no lucky. How should I catch the list reorder performed by the user?
Catch PyGTK TreeView reorder
1.2
0
0
1,654
2,832,064
2010-05-14T05:45:00.000
0
1
1
0
javascript,jquery,python,google-apps
2,832,539
3
false
0
0
If speed is the issue, and you by profiling discover that js is the culprit, then I would look into replacing the jQuery with vanilla javascript, or a more optimized library. As jQuery tries to do 'everything' and trains its users into wrapping everything in $(), its bound to introduce unnecessary method calls (I've seen that a single call to $() can result in upto 100+ method calls).
2
3
0
I want to make my component faster, I am using Javascript and JQuery to build that. I am using JSON object to communicate with component and back-end is python. Is there any suggestion to make component faster?
how to increase Speed of a component made from Javascript or JQuery?
0
0
0
141
2,832,064
2010-05-14T05:45:00.000
1
1
1
0
javascript,jquery,python,google-apps
2,832,159
3
true
0
0
Setup some analysis to see what takes time to process. Then decide if you want to try to optimize the javascript and client code, the communication up/down with the server or the actual speed of the python execution. When you have decided what you want to make faster, you can post samples of that to this site and people will probably be willing to help you.
2
3
0
I want to make my component faster, I am using Javascript and JQuery to build that. I am using JSON object to communicate with component and back-end is python. Is there any suggestion to make component faster?
how to increase Speed of a component made from Javascript or JQuery?
1.2
0
0
141
2,832,915
2010-05-14T09:02:00.000
1
0
0
0
python,templates
2,897,474
5
false
1
0
You don't need a streaming templating engine - I do this all the time, and long before you run into anything vaguely heavy server-side, the browser will start to choke. Rendering a 10000 row table will peg the CPU for several seconds in pretty much any browser; scrolling it will be bothersomely choppy in chrome, and the browser mem usage will rise regardless of browser. What you can do (and I've previously implemented, even though in retrospect it turns out not to be necessary) is use client-side xslt. Printing the xslt processing instruction and the opening and closing tag using strings is easy and fairly safe; then you can stream each individual row as a standalone xml element using whatever xml writer technique you prefer. However - you really don't need this, and likely never will - if ever your html generator gets too slow, the browser will be an order of magnitude more problematic. So, unless you benchmarked this and have determined you really have a problem, don't waste your time. If you do have a problem, you can solve it without fundamentally changing the method - in memory generation can work just fine.
2
4
0
Recently I needed to generate a huge HTML page containing a report with several thousand row table. And, obviously, I did not want to build the whole HTML (or the underlying tree) in memory. As result, I built the page with the old good string interpolation, but I do not like the solution. Thus, I wonder whether there are Python templating engines that can yield resulting page content by parts. UPD 1: I am not interested in listing all available frameworks and templating engines. I am interested in templating solutions that I can use separately from any framework and which can yield content by portions instead of building the whole result in memory. I understand the usability enhancements from partial content loading with client scripting, but that is out of the scope of my current question. Say, I want to generate a huge HTML/XML and stream it into a local file.
Python templates for huge HTML/XML
0.039979
0
1
1,055
2,832,915
2010-05-14T09:02:00.000
2
0
0
0
python,templates
2,832,958
5
false
1
0
It'd be more user-friendly (assuming they have javascript enabled) to build the table via javascript by using e.g. a jQuery plugin which allows automatical loading of contents as soon as you scroll down. Then only few rows are loaded initially and when the user scrolls down more rows are loaded on demand. If that's not a solution, you could use three templates: one for everything before the rows, one for everything after the rows and a third one for the rows. Then you first send the before-rows template, then generate the rows and send them immediately, then the after-rows template. Then you will have only one block/row in memory instead of the whole table.
2
4
0
Recently I needed to generate a huge HTML page containing a report with several thousand row table. And, obviously, I did not want to build the whole HTML (or the underlying tree) in memory. As result, I built the page with the old good string interpolation, but I do not like the solution. Thus, I wonder whether there are Python templating engines that can yield resulting page content by parts. UPD 1: I am not interested in listing all available frameworks and templating engines. I am interested in templating solutions that I can use separately from any framework and which can yield content by portions instead of building the whole result in memory. I understand the usability enhancements from partial content loading with client scripting, but that is out of the scope of my current question. Say, I want to generate a huge HTML/XML and stream it into a local file.
Python templates for huge HTML/XML
0.07983
0
1
1,055
2,833,312
2010-05-14T10:10:00.000
3
1
0
1
php,python,perl,shell,data-munging
2,833,559
3
true
0
0
import data from a file and possibly reformat it Python excels at this. Be sure to read up on the csv module so you don't waste time inventing it yourself. For binary data, you may have to use the struct module. [If you wrote the C++ program that produces the binary data, consider rewriting that program to stop using binary data. Your life will be simpler in the long run. Disk storage is cheaper than your time; highly compressed binary formats are more cost than value.] Import the munged data into a database. Extract data from the database Perform calculations on the data and either insert or update tables in the database. Use the mysqldb module for MySQL. SQLite is built-in to Python. Often, you'll want to use Object-Relational mapping rather than write your own SQL. Look at sqlobject and sqlalchemy for this. Also, before doing too much of this, buy a good book on data warehousing. Your two "task groups" sound like you're starting down the data warehousing road. It's easy to get this all fouled up through poor database design. Learn what a "Star Schema" is before you do anything else.
1
0
0
I need to write some scripts to carry out some tasks on my server (running Ubuntu server 8.04 TLS). The tasks are to be run periodically, so I will be running the scripts as cron jobs. I have divided the tasks into "group A" and "group B" - because (in my mind at least), they are a bit different. Task Group A import data from a file and possibly reformat it - by reformatting, I mean doing things like santizing the data, possibly normalizing it and or running calculations on 'columns' of the data Import the munged data into a database. For now, I am mostly using mySQL for the vast majority of imports - although some files will be imported into a sqlLite database. Note: The files will be mostly text files, although some of the files are in a binary format (my own proprietary format, written by a C++ application I developed). Task Group B Extract data from the database Perform calculations on the data and either insert or update tables in the database. My coding experience is is primarily as a C/C++ developer, although I have been using PHP as well for the last 2 years or so (+ a few other languages which are not relevant for the purpose of this question). I am from a Windows background, so I am still finding my feet in the Linux environment. My question is this - I need to write scripts to perform the tasks I described above. Although I suppose I could write a few C++ applications to be used in the shell scripts, I think it may be better to write them in a scripting language, but this may be a flawed assumption. My thinking is that it would be easier to modify things in a script - no need to rebuild etc for changes to functionality. Additionally, C++ data munging in C++ tends to involve more lines of code than "natural" scripting languages such as Perl, Python etc. Assuming that the majority of people on here agree that scripting is the way to go, herein lies my dilemma. Which scripting language do I use to perform the tasks above (giving my background)? My gut instinct tells me that Perl (shudder) would be the most obvious choice for performing all of the above tasks. BUT (and that is a big BUT). The mere mention of Perl makes my toes curl, as I had a very, very bad experience with it a while back (bought the Perl Camel book + 'data munging with Perl' many years ago, but could still not 'grok' it just felt too alien. The syntax seems quite unnatural to me - despite how many times I have tried to learn it - so if possible, I would really like to give it a miss. PHP (which I already know), also am not sure is a good candidate for scripting on the CLI (I have not seen many examples on how to do this etc - so I may be wrong). The last thing I must mention is that IF I have to learn a new language in order to do this, I cannot afford (time constraint) to spend more than a day, in learning the key commands/features required in order to do this (I can always learn the details of the language later, once I have actually deployed the scripts). So, which scripting language would you recommend (PHP, Python, Perl, [insert your favorite here]) - and most importantly WHY? Or, should I just stick to writing little C++ applications that I call in a shell script? Lastly, if you have suggested a scripting language, can you please show with a FEW lines (Perl mongers - I'm looking in your direction [nothing too cryptic!]) how I can use the language you suggested to do what I am trying to do i.e. load a CSV file into some kind of data structure where you can access data columns easily for data manipulation dump the columnar data into a mySQL table load data from mySQL table into a data structure that allows columns/rows to be accessed in the scripting language Hopefully, the snippets will allow me to quickly spot the languages that will pose the steepest learning curve for me - as well as those that simple, elegant and efficient (hopefully those two criteria [elegance and shallow learning curve] are not orthogonal - though I suspect they might be).
Data munging and data import scripting
1.2
0
0
819
2,835,472
2010-05-14T15:44:00.000
3
0
0
1
java,python,google-app-engine,xmpp
2,836,255
1
true
1
0
No. App Engine apps can only directly handle HTTP requests - you can't run arbitrary servers on App Engine.
1
3
0
Google App Engine has a great XMPP service built in. One of the few limitations it has is that it doesn't support receiving messages from a group chat. That's the one thing I want to do with it. :( Can I run a 3rd party XMPP/Jabber server on App Engine that supports group chat? If so, which one?
Group Chat XMPP with Google App Engine
1.2
0
0
1,577
2,836,838
2010-05-14T19:01:00.000
0
0
0
0
javascript,jquery,python,django,console
2,837,019
4
false
1
0
Why don't you output the data to a HTML file? You could run a cron job to run your script which would in turn spurt out a HTML file which could be accesses from the browser.
1
8
0
I've created a Python script that monitors a logfile for changes (like tail -f) and displays it on a console. I would like to access the output of the Python script in a webbrowser. What would I need to create this? I was thinking about using Django and jQuery. Any tips or examples are greatly appreciated.
tail -f in a webbrowser
0
0
0
12,000
2,837,850
2010-05-14T21:50:00.000
0
0
0
0
python,r,statistics
53,035,704
2
false
0
0
45% of the data have at least one missing value, you say. This is impressive. I would first look if there is no pattern. You say they are missing at random. Have you tested for MAR ? Have you tested for MAR for sub-groups ? Not knowing your data I would first look if there are not cases with many missing values and see if there are theoretical or practical reasons to exclude them. Practical reasons are the production of the data. They might be that they were not well observed, the machine producing the data did not turn all the time, the survey did not cover all countries all the time, etc. For instance, you have survey data on current occupation, but part of the respondents are retired. So they have to be (system-)missing. You can not replace these data with some computed value. Maybe you can cut slices out of the cases with full and look for the conditions of data production.
1
24
1
I have a regression model in which the dependent variable is continuous but ninety percent of the independent variables are categorical(both ordered and unordered) and around thirty percent of the records have missing values(to make matters worse they are missing randomly without any pattern, that is, more that forty five percent of the data hava at least one missing value). There is no a priori theory to choose the specification of the model so one of the key tasks is dimension reduction before running the regression. While I am aware of several methods for dimension reduction for continuous variables I am not aware of a similar statical literature for categorical data (except, perhaps, as a part of correspondence analysis which is basically a variation of principal component analysis on frequency table). Let me also add that the dataset is of moderate size 500000 observations with 200 variables. I have two questions. Is there a good statistical reference out there for dimension reduction for categorical data along with robust imputation (I think the first issue is imputation and then dimension reduction)? This is linked to implementation of above problem. I have used R extensively earlier and tend to use transcan and impute function heavily for continuous variables and use a variation of tree method to impute categorical values. I have a working knowledge of Python so if something is nice out there for this purpose then I will use it. Any implementation pointers in python or R will be of great help. Thank you.
Dimension Reduction in Categorical Data with missing values
0
0
0
16,303
2,838,856
2010-05-15T03:53:00.000
10
0
1
0
javascript,python
2,838,869
6
false
0
0
Depends what you want to do. If you're just interested in learning a programming language, I would recommend Python because: The interactive prompt is great for learning a language It's simple and well-designed, whereas JavaScript has a number of design flaws that can be confusing to newbies There is a particularly high amount of introductory materials for Python. It allows you to do all kinds of programming (server, client, games, etc.), whereas JS will limit you a bit more.
5
5
0
Which language will allow a beginner to get up to speed quicker? Basically which language of the two is easier to learn
Javascript or Python? beginner getting up to speed
1
0
0
16,223
2,838,856
2010-05-15T03:53:00.000
2
0
1
0
javascript,python
2,839,047
6
false
0
0
The two languages are used for two completely different purposes. JavaScript does work in the browser,1 Python does work everywhere else. Pick the language based on which you want; it's useless to learn a language if you can't even use it for your project. If you want to make a website, for example, you'll have to learn both--JavaScript for the client and Python for the server. Regardless, to answer your question, both languages are great but I'd say Python is easier to start with. JavaScript's basics are fine, but it features a lot of advanced concepts that you shouldn't have to deal with when learning your first language, IMO. 1. Yes, I'm aware that you can use JavaScript on the server-side, but those implementations are not mature and certainly not for a beginner. Python is much more suited for that kind of thing.
5
5
0
Which language will allow a beginner to get up to speed quicker? Basically which language of the two is easier to learn
Javascript or Python? beginner getting up to speed
0.066568
0
0
16,223
2,838,856
2010-05-15T03:53:00.000
0
0
1
0
javascript,python
6,636,999
6
false
0
0
I would say JavaScript is easy to learn. I had to learn it to program the Karotz. It only took about 2 months of Youtube tutorials to learn most of it.
5
5
0
Which language will allow a beginner to get up to speed quicker? Basically which language of the two is easier to learn
Javascript or Python? beginner getting up to speed
0
0
0
16,223
2,838,856
2010-05-15T03:53:00.000
4
0
1
0
javascript,python
2,838,867
6
false
0
0
They're both pretty straightforward to learn. They more differ in terms of their typical project space - Javascript is usually utilized more for the client-side portion of web applications, while Python is often utilized for the server side of web applications and also standalone non-web apps. What do you want to make?
5
5
0
Which language will allow a beginner to get up to speed quicker? Basically which language of the two is easier to learn
Javascript or Python? beginner getting up to speed
0.132549
0
0
16,223
2,838,856
2010-05-15T03:53:00.000
1
0
1
0
javascript,python
2,838,956
6
false
0
0
PHP is my thing, but I've played with Python and worked with JS. Being only somewhat skilled in both languages, Python feels nice and clean (although a little wierd) with the forced tabbing conventions and lack of semicolons. JS, on the other hand makes me feel like I need a shower. Especially after debugging in IE. But the only real answer is the question - What do you want to do with it? Want to make websites do cool things in the browser? Go with JS. Something else? Maybe Python is better suited, as @Amber said. Edit: As for getting up to speed, here's how it works. Your first language takes you a longer time to learn. Your second takes much less time, and after that it's not long at all since you're mostly just learning new syntax for similar things. So the solution for getting up to speed faster is to jump in right now.
5
5
0
Which language will allow a beginner to get up to speed quicker? Basically which language of the two is easier to learn
Javascript or Python? beginner getting up to speed
0.033321
0
0
16,223
2,839,130
2010-05-15T06:18:00.000
1
0
1
0
python,performance,algorithm,data-structures,collections
2,841,467
7
false
0
0
If you can really allow O(log n) for pop, dequeue, and insert, then a simple balanced search tree like red-black tree is definitely sufficient. You can optimize this of course by maintaining a direct pointer to the smallest and largest element in the tree, and then updating it when you (1) insert elements into the tree or (2) pop or dequeue, which of course invalidate the resp. pointer. But because the tree is balanced, there's some shuffling going out anyway, and you can update the corr. pointer at the same time. There is also something called min-max heap (see the Wikipedia entry for Binary Heap), which implements exactly a "double-ended priority queue", i.e. a queue where you can pop both from front end and the rear end. However there you can't access the whole list of objects in order, whereas a search tree can be iterated efficiently through in O(n) time. The benefit of a min-max heap however is that the current min and max objects can be read in O(1) time, a search tree requires O(log(n)) just to read the min or max object unless you have the cached pointers as I mentioned above.
2
3
0
I need a collection data-structure that can do the following: Be sorted Allow me to quickly pop values off the front and back of the list O(log n) Remain sorted after I insert a new value Allow a user-specified comparison function, as I will be storing tuples and want to sort on a particular value Thread-safety is not required Optionally allow efficient haskey() lookups (I'm happy to maintain a separate hash-table for this though) My thoughts at this stage are that I need a priority queue and a hash table, although I don't know if I can quickly pop values off both ends of a priority queue. Another possibility is simply maintaining an OrderedDictionary and doing an insertion sort it every-time I add more data to it. Because I'm interested in performance for a moderate number of items (I would estimate less than 200,000), I am unsure about what asymptotic performance I require for these operations. n will not grow infinitely, so a low constant performance k in k * O(n) may be as important O(n). That said, I would prefer that both the insert and pop operations take O(log n) time. Furthermore, are there any particular implementations in Python? I would really like to avoid writing this code myself.
Best data-structure to use for two ended sorted list
0.028564
0
0
1,183
2,839,130
2010-05-15T06:18:00.000
-1
0
1
0
python,performance,algorithm,data-structures,collections
2,839,138
7
false
0
0
If this were Java I'd use a TreeSet with the NavigableSet interface. This is implemented as a Red-Black-Tree.
2
3
0
I need a collection data-structure that can do the following: Be sorted Allow me to quickly pop values off the front and back of the list O(log n) Remain sorted after I insert a new value Allow a user-specified comparison function, as I will be storing tuples and want to sort on a particular value Thread-safety is not required Optionally allow efficient haskey() lookups (I'm happy to maintain a separate hash-table for this though) My thoughts at this stage are that I need a priority queue and a hash table, although I don't know if I can quickly pop values off both ends of a priority queue. Another possibility is simply maintaining an OrderedDictionary and doing an insertion sort it every-time I add more data to it. Because I'm interested in performance for a moderate number of items (I would estimate less than 200,000), I am unsure about what asymptotic performance I require for these operations. n will not grow infinitely, so a low constant performance k in k * O(n) may be as important O(n). That said, I would prefer that both the insert and pop operations take O(log n) time. Furthermore, are there any particular implementations in Python? I would really like to avoid writing this code myself.
Best data-structure to use for two ended sorted list
-0.028564
0
0
1,183
2,839,663
2010-05-15T09:53:00.000
0
1
0
0
php,javascript,python,programming-languages,certificate
2,840,048
5
false
1
0
For linux (implies perl/bash) Comptia+ Red Hat Certified Engineer
3
4
0
I would like to know what are the certificates available for programming, like Zend for PHP SUN Certification for java What are the others? Javascript? C++? Python? etc... Please give me some suggestion for other available certifications.
What are the most valuable certification available for Programming?
0
0
0
3,805
2,839,663
2010-05-15T09:53:00.000
16
1
0
0
php,javascript,python,programming-languages,certificate
2,839,684
5
false
1
0
Most valuable thing for a developer: being able to show you can convert requirements into working and maintainable software. Certifications generally are worth very little, except in a few niches that demand them (or at least ask, until they give up and get someone who puts practice before pieces of paper).
3
4
0
I would like to know what are the certificates available for programming, like Zend for PHP SUN Certification for java What are the others? Javascript? C++? Python? etc... Please give me some suggestion for other available certifications.
What are the most valuable certification available for Programming?
1
0
0
3,805
2,839,663
2010-05-15T09:53:00.000
7
1
0
0
php,javascript,python,programming-languages,certificate
2,839,748
5
false
1
0
Let me be bold and say that your Experience is your best certificate.
3
4
0
I would like to know what are the certificates available for programming, like Zend for PHP SUN Certification for java What are the others? Javascript? C++? Python? etc... Please give me some suggestion for other available certifications.
What are the most valuable certification available for Programming?
1
0
0
3,805
2,840,144
2010-05-15T12:46:00.000
2
0
1
0
python,python-3.x
2,840,151
2
false
0
0
PyUnicodeObject is a subset of PyObject so there shouldn't be any problem passing it.
1
1
0
A value which is a PyUnicodeObject need to be passed to PyObject variable. Is there any conversion method for that? thanks karnol
Is there a method to convert PyUnicodeObject variable to PyObject type?
0.197375
0
0
416
2,840,201
2010-05-15T13:07:00.000
5
1
0
0
python,caching,web2py
2,840,650
2
false
1
0
web2py does cache your code, except for Google App Engine (for speed). That is not the problem. If you you edit code in models, views or controllers, you see the effect immediately. The problem may be modules; if you edit code in modules you will not see the effect immediately, unless you import them with local_import('module', reload=True), or by restarting web2py. Is that is also not your problem, then your browser is caching something. Please bring up this question to the web2py mailing list as we can help more. P.S. If you are using the latest web2py it no longer comes with cherrypy. The built-in web server is called Rocket.
1
5
0
I'm working with web2py and for some reason web2py seems to fail to notice when code has changed in certain cases. I can't really narrow it down, but from time to time changes in the code are not reflected, web2py obviously has the old version cached somewhere. The only thing that helps is quitting web2py and restarting it (i'm using the internal server). Any hints ? Thank you !
Prevent web2py from caching?
0.462117
0
0
1,547
2,840,329
2010-05-15T13:46:00.000
1
0
0
0
python,django
2,840,883
2
true
1
0
I use the middleware because this way I don't have to change the app's code. If I want to migrate my app to other hosting servers, I only need to modify the middleware without affecting other parts. Security is not an issue because on WebFaction you can trust what comes in from the front end server.
1
0
0
I'm trying to develop an app using Django 1.1 on Webfaction. I'd like to get the IP address of the incoming request, but when I use request.META['REMOTE_ADDR'] it returns 127.0.0.1. There seems to be a number of different ways of getting the address, such as using HTTP_X_FORWARDED_FOR or plugging in some middleware called SetRemoteAddrFromForwardedFor. Just wondering what the best approach was?
Django: What's the correct way to get the requesting IP address?
1.2
0
1
748
2,840,932
2010-05-15T16:54:00.000
4
1
0
1
python,c,objective-c,linux,macos
2,840,981
5
false
0
0
It's frequently helpful to learn programming languages in the order they were created. The folks that wrote Objective-C clearly had C and its syntax, peculiarities, and features in mind when they defined the language. It can't hurt you to learn C now. You may have some insight into why Objective-C is structured the way it is later. C has a great, classic book on it, The C Programming Language by Kernighan & Ritchie, which is short and easy to digest if you already have another language under your belt.
4
0
0
I know Ruby right now, however I want to learn a new language. I am running Ubuntu 10.04 right now but I am going to get a Mac later this summer. Anyways I want something more for GUI development. I was wondering if I should learn C on Ubuntu right now, and then learn Objective-C when I get an iMac? Will learning C give me an edge? Or should I just learn Python on Ubuntu and then learn Objective-C when I get a new computer?
If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?
0.158649
0
0
835
2,840,932
2010-05-15T16:54:00.000
1
1
0
1
python,c,objective-c,linux,macos
2,840,961
5
false
0
0
Sure Objective-C is quite easier to learn if you know C and quite a few books on Objective-C even asume you know C. Also consider learning a bit about MacRuby for GUI development ;)
4
0
0
I know Ruby right now, however I want to learn a new language. I am running Ubuntu 10.04 right now but I am going to get a Mac later this summer. Anyways I want something more for GUI development. I was wondering if I should learn C on Ubuntu right now, and then learn Objective-C when I get an iMac? Will learning C give me an edge? Or should I just learn Python on Ubuntu and then learn Objective-C when I get a new computer?
If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?
0.039979
0
0
835
2,840,932
2010-05-15T16:54:00.000
0
1
0
1
python,c,objective-c,linux,macos
2,909,728
5
false
0
0
Learning C will definitely be of help, as Objective C inherits its many properties and adds to it. You could learn Objective C either from 'Learn Objective C on the Mac', this one's really a great book, and then if you plan to learn cocoa, get 'Learn Cocoa on the Mac' or the one by James Davidson, they should give you a fine head start, you can then consider moving to the one by Hillegass, and for a stunner 'Objective C developer handbook' by David Chisnall, this is a keeper, you can read it in a month or two. For the compiler I would point you to clang though a gcc and gnustep combination will work. clang is a better choice if you want to work on Obj C 2.0 features and it is under heavy development.
4
0
0
I know Ruby right now, however I want to learn a new language. I am running Ubuntu 10.04 right now but I am going to get a Mac later this summer. Anyways I want something more for GUI development. I was wondering if I should learn C on Ubuntu right now, and then learn Objective-C when I get an iMac? Will learning C give me an edge? Or should I just learn Python on Ubuntu and then learn Objective-C when I get a new computer?
If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?
0
0
0
835
2,840,932
2010-05-15T16:54:00.000
0
1
0
1
python,c,objective-c,linux,macos
5,783,941
5
false
0
0
Yes. Learn how to program in C.
4
0
0
I know Ruby right now, however I want to learn a new language. I am running Ubuntu 10.04 right now but I am going to get a Mac later this summer. Anyways I want something more for GUI development. I was wondering if I should learn C on Ubuntu right now, and then learn Objective-C when I get an iMac? Will learning C give me an edge? Or should I just learn Python on Ubuntu and then learn Objective-C when I get a new computer?
If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?
0
0
0
835
2,841,863
2010-05-15T21:40:00.000
1
1
1
0
python,git
2,844,342
1
false
0
0
That's the basic algorithm that git uses to track changes to a particular file. That's why "git log -- some/path/to/file.txt" is a comparatively slow operation, compared to many other SCM systems where it would be simple (e.g. in CVS, P4 et al each repo file is a server file with the file's history). It shouldn't take so long to evaluate though: the amount you ever have to keep in memory is quite small. You already mentioned the main point: remember the tree IDs going down to the path to quickly eliminate commits that didn't even touch that subtree. It's rare for tree objects to be very big, just like directories on a filesystem (unsurprisingly). Are you using the pack index? If you're not, then you essentially have to unpack the entire pack to find this out since trees could be at the end of a long delta chain. If you have an index, you'll still have to apply deltas to get your tree objects, but at least you should be able to find them quickly. Keep a cache of applied deltas, since obviously it's very common for trees to reuse the same or similar bases- most tree object changes are just changing 20 bytes from a previous tree object. So if in order to get tree T1, you have to start with object T8 and apply Td7 to get T7, T6.... etc. it's entirely likely that these other trees T2-8 will be referenced again.
1
2
0
I'm writing a simple parser of .git/* files. I covered almost everything, like objects, refs, pack files etc. But I have a problem. Let's say I have a big 300M repository (in a pack file) and I want to find out all the commits which changed /some/deep/inside/file file. What I'm doing now is: fetching last commit finding a file in it by: fetching parent tree finding out a tree inside recursively repeat until I get into the file additionally I'm checking hashes of each subfolders on my way to file. If one of them is the same as in commit before, I assume that file was not changed (because it's parent dir didn't change) then I store the hash of a file and fetch parent commit finding file again and check if hash change occurs if yes then original commit (i.e. one before parent) was changing a file And I repeat it over and over until I reach very first commit. This solution works, but it sucks. In worse case scenario, first search can take even 3 minutes (for 300M pack). Is there any way to speed it up ? I tried to avoid putting so large objects in memory, but right now I don't see any other way. And even that, initial memory load will take forever :( Greets and thanks for any help!
How does git fetches commits associated to a file?
0.197375
0
0
75
2,842,629
2010-05-16T04:52:00.000
0
0
0
0
python,web-crawler,scrapy
2,843,118
3
false
1
0
Set PYTHONPATH environment variable to python26/scripts.
3
2
0
I just downloaded Scrapy (web crawler) on Windows 32 and have just created a new project folder using the "scrapy-ctl.py startproject dmoz" command in dos. I then proceeded to created the first spider using the command: scrapy-ctl.py genspider myspider myspdier-domain.com but it did not work and returns the error: Error running: scrapy-ctl.py genspider, Cannot find project settings module in python path: scrapy_settings. I know I have the path set right (to python26/scripts), but I am having difficulty figuring out what the problem is. I am new to both scrapy and python so there is a good possibility that I have failled to do something important. Also, I have been using eclipse with the Pydev plugin to edit the code if that might cause some problems.
Creating a spider using Scrapy, Spider generation error
0
0
0
2,058
2,842,629
2010-05-16T04:52:00.000
1
0
0
0
python,web-crawler,scrapy
3,312,950
3
false
1
0
use the scrapy-ctl.py in the project's dir. that script will know about that project's settings. the main scrapy-ctl.py doesn't have a clue about that specific project's settings.
3
2
0
I just downloaded Scrapy (web crawler) on Windows 32 and have just created a new project folder using the "scrapy-ctl.py startproject dmoz" command in dos. I then proceeded to created the first spider using the command: scrapy-ctl.py genspider myspider myspdier-domain.com but it did not work and returns the error: Error running: scrapy-ctl.py genspider, Cannot find project settings module in python path: scrapy_settings. I know I have the path set right (to python26/scripts), but I am having difficulty figuring out what the problem is. I am new to both scrapy and python so there is a good possibility that I have failled to do something important. Also, I have been using eclipse with the Pydev plugin to edit the code if that might cause some problems.
Creating a spider using Scrapy, Spider generation error
0.066568
0
0
2,058
2,842,629
2010-05-16T04:52:00.000
2
0
0
0
python,web-crawler,scrapy
2,842,952
3
true
1
0
There is a difference between PATH and PYTHON_PATH. Is your PYTHON_PATH set correctly? This path is where python looks to include packages / modules.
3
2
0
I just downloaded Scrapy (web crawler) on Windows 32 and have just created a new project folder using the "scrapy-ctl.py startproject dmoz" command in dos. I then proceeded to created the first spider using the command: scrapy-ctl.py genspider myspider myspdier-domain.com but it did not work and returns the error: Error running: scrapy-ctl.py genspider, Cannot find project settings module in python path: scrapy_settings. I know I have the path set right (to python26/scripts), but I am having difficulty figuring out what the problem is. I am new to both scrapy and python so there is a good possibility that I have failled to do something important. Also, I have been using eclipse with the Pydev plugin to edit the code if that might cause some problems.
Creating a spider using Scrapy, Spider generation error
1.2
0
0
2,058
2,843,545
2010-05-16T11:32:00.000
0
0
1
0
python,windows,console
51,686,360
4
false
0
0
The way that I do it is i right click the script that I saved from notepad to a .py file, then i click edit with IDLE, This is an editing thingy, but you can also run modules from it
1
10
0
File associations on my machine (winxp home) are such that a python script is directly opened with the python interpreter. If I double click on a python script a console window runs and every thing is fine - as long as there is no syntax error in the script. In that case the console window opens up for a moment but it is closed immediately. Too fast to read the error message. Of course their would be the possibility to manually open a console window and to execute the script by typing python myscript.py but I am sure that there is a more convenient (i.e. "double click based") solution.
Keep Windows Console open after a Python Error
0
0
0
7,295
2,844,105
2010-05-16T14:28:00.000
1
0
0
0
java,python,nlp,hadoop,nltk
2,844,449
4
false
1
0
no actual answers; i'd have put this as a comment but on this site you're forced to only answer if you're still a noob if it's genuinely as parallel as that, and it's only a couple of computers, could you not split the dataset up manually ahead of time? have you confirmed that there isn't going to be a firewall or similar stopping you using something like that anyway? you may only have 1GB of user space, but, if linux, what about /tmp ? (if windows, what about %temp% ? )
3
5
0
I have a large dataset (c. 40G) that I want to use for some NLP (largely embarrassingly parallel) over a couple of computers in the lab, to which i do not have root access, and only 1G of user space. I experimented with hadoop, but of course this was dead in the water-- the data is stored on an external usb hard drive, and i cant load it on to the dfs because of the 1G user space cap. I have been looking into a couple of python based options (as I'd rather use NLTK instead of Java's lingpipe if I can help it), and it seems distributed compute options look like: Ipython DISCO After my hadoop experience, i am trying to make sure i try and make an informed choice -- any help on what might be more appropriate would be greatly appreciated. Amazon's EC2 etc not really an option, as i have next to no budget.
Java or Python distributed compute job (on a student budget)?
0.049958
0
0
334
2,844,105
2010-05-16T14:28:00.000
3
0
0
0
java,python,nlp,hadoop,nltk
2,844,538
4
false
1
0
Speak with the IT dept at your school (especially if you are in college), if it is for an assignment or research I bet they would be more than happy to give you more disk space.
3
5
0
I have a large dataset (c. 40G) that I want to use for some NLP (largely embarrassingly parallel) over a couple of computers in the lab, to which i do not have root access, and only 1G of user space. I experimented with hadoop, but of course this was dead in the water-- the data is stored on an external usb hard drive, and i cant load it on to the dfs because of the 1G user space cap. I have been looking into a couple of python based options (as I'd rather use NLTK instead of Java's lingpipe if I can help it), and it seems distributed compute options look like: Ipython DISCO After my hadoop experience, i am trying to make sure i try and make an informed choice -- any help on what might be more appropriate would be greatly appreciated. Amazon's EC2 etc not really an option, as i have next to no budget.
Java or Python distributed compute job (on a student budget)?
0.148885
0
0
334
2,844,105
2010-05-16T14:28:00.000
0
0
0
0
java,python,nlp,hadoop,nltk
2,847,116
4
false
1
0
If more resources in your computing department are a no go, you're going to have to consider breaking down your data set into manageable chunks before you do any work on it, ad reduce the results down into a meaningful set. More resources from IT would be the way to go. Good luck ! Ben
3
5
0
I have a large dataset (c. 40G) that I want to use for some NLP (largely embarrassingly parallel) over a couple of computers in the lab, to which i do not have root access, and only 1G of user space. I experimented with hadoop, but of course this was dead in the water-- the data is stored on an external usb hard drive, and i cant load it on to the dfs because of the 1G user space cap. I have been looking into a couple of python based options (as I'd rather use NLTK instead of Java's lingpipe if I can help it), and it seems distributed compute options look like: Ipython DISCO After my hadoop experience, i am trying to make sure i try and make an informed choice -- any help on what might be more appropriate would be greatly appreciated. Amazon's EC2 etc not really an option, as i have next to no budget.
Java or Python distributed compute job (on a student budget)?
0
0
0
334
2,844,121
2010-05-16T14:32:00.000
3
0
0
1
python,exception,exception-handling,ctypes,abort
2,844,132
1
true
0
0
You might be able to setup a signal handler on SIGABRT to handle the signal caused by abort(). However, failed assertions might go along with corrupted memory and other bad things - there's usually a reason why an assertion failed. So usually terminating the applications is the best thing you can do (except displaying/logging an error in your handler before terminating).
1
3
0
I am working with some C code called from Python using ctypes. Somewhere in the bowels of the C library, an exception is occurring and/or abort() is being called. Is there any way I can catch this in my Python caller code? (Platform is Linux)
How to catch an exception thrown in ctypes?
1.2
0
0
1,439
2,844,635
2010-05-16T17:06:00.000
5
0
0
1
python,google-app-engine,logging
20,735,387
4
false
1
0
Many of these answers are now outdated. :) In today's devappserver, use --logs_path=LOGS_FILE if you want to log to a file (in its native sqlite database format). Or as suggested in a comment, simply pipe the output if that's too complicated. Since there's a log API, it actually now stores log entries in a file in --storage_path if not set. I have noticed a few bugs myself, though. (I'll assume they don't exist now, it's been a while since I used this.)
1
9
0
GoogleAppEngineLauncher can display the local log file of my app while it is running on my Mac during development. However, I can't change the font size there so I would like to use the tail command to watch the log file myself. It's a shame but I can't find the log files. They are not under /var/log/, ~/Library/Logs or /Library/Logs. Do you know where they are? (Maybe there are no physical files, just the stdout of the python development environment and so the log is only available in the launcher application.)
Where does GoogleAppEngineLauncher keep the local log files?
0.244919
0
0
7,373
2,845,717
2010-05-16T22:21:00.000
4
0
1
0
python,debugging,ide,ipython,pdb
2,845,865
7
false
0
0
Btw, I've seen Spyder (formerly Pydee), and that indeed will have iPython integration in September, but it still lacks a debugger. ::sigh::
1
12
0
Does anyone know of a python IDE that has iPython as the interpreter? Using the standard interpreter just drives me nuts, as I've just grown to love using iPython and all the features it provides. To be honest, I'd rather code with a simple text editor + ipython than an IDE, but I love being able to set breakpoints with a click of a mouse, etc., so I'd like to combine both. Sorry if there's something out there and this is common knowledge. Any information/tips you can provide is GREATLY appreciated. Thanks!
A Python IDE with Debugging and iPython Integration?
0.113791
0
0
8,537
2,846,308
2010-05-17T02:14:00.000
0
0
1
0
python,reference,stdout
2,846,344
5
false
0
0
This can't be done. Pass the desired attribute as a string and use getattr() and setattr().
1
1
0
I am traditionally a Perl and C++ programmer, so apologies in advance if I am misunderstanding something trivial about Python! I would like to create a reference to a reference. Huh? Ok. All objects in Python are actually references to the real object. So, how do I create a reference to this reference? Why do I need/want this? I am overriding sys.stdout and sys.stderr to create a logging library. I would like a (second-level) reference to sys.stdout. If I could create a reference to a reference, then I could create a generic logger class where the init function receives a reference to a file handle reference that will be overrided, e.g., sys.stdout or sys.stderr. Currently, I must hard-code both values. Cheers, Kevin
Python: How do I create a reference to a reference?
0
0
0
382
2,846,431
2010-05-17T03:04:00.000
1
0
1
0
python,list
2,846,492
5
false
0
0
Dicts and sets will be just as fast (and O(N), as you surmise). Lists, which you only mention in your Q's title and never in its text, might be slower, depending what you mean by "merging". Given the json downstream requirements, dicts with values all set to 1 will be fastest overall -- not for the merging, but for the JSON serialization.
2
0
0
I'm working with an app that is cpu-bound more than memory bound, and I'm trying to merge two things whether they be lists or dicts. Now the thing is i can choose either one, but I'm wondering if merging dicts would be faster since it's all in memory? Or is it always going to be O(n), n being the size of the smaller list. The reason I asked about dicts rather than sets is because I can't convert a set to json, because that results in {key1, key2, key3} and json needs a key/value pair, so I am using a dict so json dumps returns {key1:1, key2:1, key3:1}. Yes this is wasteful, but if it proves to be faster then I'm okay with it. Edit: My question is the difference in using dict and list for merging, I originally and mistakenly had dict and set listed. dict1 = {"the" : {"1":1, "3":1, "10":1} dict2 = {"the" : {"11":1, "13":1}} after merging dict3 = {"the" : {"1":1, "3":1, "10":1, "11":1, "13":1}
what's faster: merging lists or dicts in python?
0.039979
0
0
326
2,846,431
2010-05-17T03:04:00.000
0
0
1
0
python,list
2,846,833
5
false
0
0
I'd be more worried about correctness. If you have duplicate keys, the list will duplicate your keys and values. A dictionary will only keep one of the values. Also, a list will keep the order consistent. Which do you prefer? My gut reaction is that if you are searching for keys the dictionary will be faster. But how will you deal with duplication?
2
0
0
I'm working with an app that is cpu-bound more than memory bound, and I'm trying to merge two things whether they be lists or dicts. Now the thing is i can choose either one, but I'm wondering if merging dicts would be faster since it's all in memory? Or is it always going to be O(n), n being the size of the smaller list. The reason I asked about dicts rather than sets is because I can't convert a set to json, because that results in {key1, key2, key3} and json needs a key/value pair, so I am using a dict so json dumps returns {key1:1, key2:1, key3:1}. Yes this is wasteful, but if it proves to be faster then I'm okay with it. Edit: My question is the difference in using dict and list for merging, I originally and mistakenly had dict and set listed. dict1 = {"the" : {"1":1, "3":1, "10":1} dict2 = {"the" : {"11":1, "13":1}} after merging dict3 = {"the" : {"1":1, "3":1, "10":1, "11":1, "13":1}
what's faster: merging lists or dicts in python?
0
0
0
326
2,847,593
2010-05-17T08:31:00.000
2
0
0
0
python,wsgi
2,847,694
6
true
1
0
You can run an django application in 20 mb memory easily. probably a django application will use less memory than 20mb. I want to advise you to check webpy and cherrypy but I'm big fan of django. if you have 20 mb memory to run application, django will give you everythig it has.
1
1
0
I'm looking for some recommendations for a python web application. We have some memory restrictions and we try to keep it small and lean. We thought about using WSGI (and a python webserver) and build the rest ourself. We already have a template engine we'd like to use, but we are open for some suggestions regarding the whole request handling (the controller). The application has to run in a single process and the requests have to be processed with multiple threads. We've looked at django, but we are a not sure if it fits into our memory budget. Your feedback is very welcome! Cheers, Reto
Stack recommendations for small/medium-sized web application in Python
1.2
0
0
368
2,848,098
2010-05-17T10:00:00.000
5
0
0
0
python
2,848,539
1
false
0
0
I don't think it's possible with Python's socket module. UDP is a very minimalistic protocol, and the only way to distinguish between a broadcast and a non-broadcast UDP packet is by looking at the destination address. However, you cannot inspect that part of the packet with the BSD socket API (if I remember it correctly), and the socket module exposes the BSD socket API only. Your best bet would probably be to use the first byte of the message to denote whether it is a broadcast or a unicast message.
1
2
0
Sometimes I have to send a message to a specific IP and sometimes I have to broadcast the message to all the IP's in my network. At the other end I have to distinguish between a broadcast and a normal one, but recvfrom() just returns the address the message came from; there is no difference between them. Can anyone help me distinguish them? UDP is the protocol.
How to identify a broadcasted message?
0.761594
0
1
116
2,848,686
2010-05-17T11:43:00.000
3
0
1
0
python,twisted,twisted.web
2,849,252
1
false
0
0
I'm assuming you want this API in order to save and retrieve per-request state. If not, then you might want to clarify your question. Twisted Web doesn't offer any API along these lines. Since you're in control for the completely lifetime of the request, it's possible for you to store any per-request state yourself: on Resource instances, in locals, in arguments to callbacks, etc. A get_current_context function is sort of the multi-threaded equivalent of using globals to keep track of your state. When you think about it that way, hopefully it's a little more obvious why you might want to consider alternate solutions.
1
6
0
In asynchronous environments, threading.local is not guaranteed to be context-local anymore, because several contexts may coexist within a single thread. Most asynchronous frameworks (gevent, eventlet) provide a get_current_context() functionality to identify the current context. Some offer a way to monkey-patch threading.local so it is local to 'greenthreads' or other framework-specific contexts. I cannot find such a functionality in the twisted documentation. How do I do this?
threading.local equivalent for twisted.web?
0.53705
0
0
263
2,849,118
2010-05-17T12:48:00.000
0
0
0
0
python,django,plugins
2,849,724
1
false
1
0
I would make an app with a very abstract definition of a Task model. The Task model might contain properties for: the input arguments, the function to run, the time that the task was submitted, the time that the task has been actually running, and the result (which would be something like a singleton Task.NotFinished until finished). You could consider using twisted to run the tasks because: twisted has a well designed and tested implementation of asynchronous tasks; and you could run the tasks on other processors or machines.
1
0
0
I am developing a website which is aimed at being a GUI for several image processing algorithms (referred to as 'tasks'). At the moment, only one of these algorithms is finished, but there are more to come (which will have a similar, but not quite the same, workflow) Basically, the algorithm works as follows (not that it matters a lot, but just for the sake of clarity): 1) Enter some parameters and an input image 2) run algorithm part one --algorithm runs-- 3) review an interim result 4) edit the parameters if needed, and go to 2. 5) run algorithm part two --algorithm runs-- 6) review the result 7) adjust some of the interim results if needed, and go to 5 8) all done I expect some of the additional tasks to have a rather similar work flow, though it is perfectly possible that they won't. So, the easy way to implement this would be to create a separate django application for each algorithm. However, I'd like to be able to browse through a sorted list (by time of completion) of completed tasks, and for each of these task display a summary (name, description, start time, thumbnail). Is there anyone that can provide me with some suggestions on how I can implement this? I'd like to keep it as simple as possible, so additional task can be 'plugged' in as easy as possible.
Suggestions for a pluggable task framework in Django
0
0
0
160
2,850,084
2010-05-17T14:56:00.000
4
0
1
0
python,config,filenames,file-extension
2,850,809
3
false
0
0
The docs seem to use .cfg On Windows, many people (such as mercurial) use .ini
3
11
0
I'm creating a config file to hold configuration/properties settings for my project that frequently change, such as file paths. What's the standard name/extension for such a file? (e.g. in Java I've used config.xml, in VB.NET I've used App.config...)
What's the standard config file name and extension in Python?
0.26052
0
0
8,345
2,850,084
2010-05-17T14:56:00.000
12
0
1
0
python,config,filenames,file-extension
2,850,523
3
false
0
0
Ok, I've asked around where I work and researched a little, and this is what I've come up with as suggestions: settings.ini applicationName.config applicationName.cfg If anyone has any other suggestions, feel free to add...
3
11
0
I'm creating a config file to hold configuration/properties settings for my project that frequently change, such as file paths. What's the standard name/extension for such a file? (e.g. in Java I've used config.xml, in VB.NET I've used App.config...)
What's the standard config file name and extension in Python?
1
0
0
8,345
2,850,084
2010-05-17T14:56:00.000
7
0
1
0
python,config,filenames,file-extension
2,850,268
3
true
0
0
First, consider using ConfigParser (configparser in 3.0, so the documentation says). That doesn't solve the naming problem, but it is a readable alternative to xml for most configuration needs. Whatever name you use, make all the parts meaningful. I would probably use something like appName.cfg, where appName identifies your application, or the part of the application the configuration is for.
3
11
0
I'm creating a config file to hold configuration/properties settings for my project that frequently change, such as file paths. What's the standard name/extension for such a file? (e.g. in Java I've used config.xml, in VB.NET I've used App.config...)
What's the standard config file name and extension in Python?
1.2
0
0
8,345
2,850,534
2010-05-17T15:47:00.000
1
0
0
0
python,html,xml,ajax,xslt
2,850,582
4
false
1
0
I would go with the PHP option. The reason being is that when the XML changes your site content "should" automatically change without you having to touch your PHP code. Creating a Python script to generate lots of static pages just seems like a bad idea to me and with javascript you will have your cross-browser headaches (unless you are using a framework maybe). Use the server side languages for these kind of tasks, it is what they were made for.
3
3
0
I have a long document in XML from which I need to produce static HTML pages (for distribution via CD). I know (to varying degrees) JavaScript, PHP and Python. The current options I've considered are listed here: I'm not ruling out JavaScript, so one option would be to use ajax to dynamically load the XML content into HTML pages. Edit: I'd use jQuery for this option. Learn some basic XSLT and produce HTML to the correct spec this way. Produce the site with PHP (for example) and then generate a static site. Write a script (in Python for example) to convert the XML into HTML. This is similar to the XSLT option but without having to learn XSLT. Useful information: The XML will likely change at some point, so I'd like to be able to easily regenerate the site. I'll have to produce some kind of menu for jumping around the document (so I'll need to produce some kind of index of the content). I'd like to know if anyone has any better ideas that I haven't thought of. If not, I'd like you to tell me which of my options seems the most sensible. I think I know what I'm going to do, but I'd like a second opinion. Thanks.
Producing a static HTML site from XML content
0.049958
0
1
1,365
2,850,534
2010-05-17T15:47:00.000
2
0
0
0
python,html,xml,ajax,xslt
2,850,603
4
false
1
0
I would go with the XSLT option, controlled via parameters to generate different pages from the same XML source if needed. It's really the tool made for XML transformations.
3
3
0
I have a long document in XML from which I need to produce static HTML pages (for distribution via CD). I know (to varying degrees) JavaScript, PHP and Python. The current options I've considered are listed here: I'm not ruling out JavaScript, so one option would be to use ajax to dynamically load the XML content into HTML pages. Edit: I'd use jQuery for this option. Learn some basic XSLT and produce HTML to the correct spec this way. Produce the site with PHP (for example) and then generate a static site. Write a script (in Python for example) to convert the XML into HTML. This is similar to the XSLT option but without having to learn XSLT. Useful information: The XML will likely change at some point, so I'd like to be able to easily regenerate the site. I'll have to produce some kind of menu for jumping around the document (so I'll need to produce some kind of index of the content). I'd like to know if anyone has any better ideas that I haven't thought of. If not, I'd like you to tell me which of my options seems the most sensible. I think I know what I'm going to do, but I'd like a second opinion. Thanks.
Producing a static HTML site from XML content
0.099668
0
1
1,365
2,850,534
2010-05-17T15:47:00.000
0
0
0
0
python,html,xml,ajax,xslt
2,850,635
4
false
1
0
Go with what you are most comfortable with. If it's straightforward you could use (for example) php to generate a page and then use a command line script (in python or php) to create cached files for you.
3
3
0
I have a long document in XML from which I need to produce static HTML pages (for distribution via CD). I know (to varying degrees) JavaScript, PHP and Python. The current options I've considered are listed here: I'm not ruling out JavaScript, so one option would be to use ajax to dynamically load the XML content into HTML pages. Edit: I'd use jQuery for this option. Learn some basic XSLT and produce HTML to the correct spec this way. Produce the site with PHP (for example) and then generate a static site. Write a script (in Python for example) to convert the XML into HTML. This is similar to the XSLT option but without having to learn XSLT. Useful information: The XML will likely change at some point, so I'd like to be able to easily regenerate the site. I'll have to produce some kind of menu for jumping around the document (so I'll need to produce some kind of index of the content). I'd like to know if anyone has any better ideas that I haven't thought of. If not, I'd like you to tell me which of my options seems the most sensible. I think I know what I'm going to do, but I'd like a second opinion. Thanks.
Producing a static HTML site from XML content
0
0
1
1,365
2,850,566
2010-05-17T15:50:00.000
0
1
1
0
python,multithreading,smtp,cgi
2,851,122
2
false
0
0
You might want to use threading.enumerate, if you have multiple workers and want to see which one(s) are still running. Other alternatives include using threading.Event---the main thread sets the event to True and starts the worker thread off. The worker thread unsets the event when if finishes work, and the main check whether the event is set/unset to figure out if it can exit.
1
2
0
I'm using Python in a webapp (CGI for testing, FastCGI for production) that needs to send an occasional email (when a user registers or something else important happens). Since communicating with an SMTP server takes a long time, I'd like to spawn a thread for the mail function so that the rest of the app can finish up the request without waiting for the email to finish sending. I tried using thread.start_new(func, (args)), but the Parent return's and exits before the sending is complete, thereby killing the sending process before it does anything useful. Is there anyway to keep the process alive long enough for the child process to finish?
Parent Thread exiting before Child Threads [python]
0
0
0
3,627
2,851,499
2010-05-17T18:03:00.000
7
0
1
0
python
2,854,703
1
true
0
0
Your understanding is correct: "green" threads are not actually threads, they don't get pre-empted at unpredictable points (esp. not "in the middle" of an operation), so you have full control of when execution moves away from one (and can thus get dispatched to another) and can save yourself the trouble/overhead of lock acquire/release operations.
1
4
0
Since Eventlet uses green threading and asynchronous I/O, do I still need to set locks before accessing objects? My understanding is that greenlets are all part of one thread and locking isn't necessary. Can anyone confirm or deny this?
Eventlet and locking
1.2
0
0
1,531
2,851,632
2010-05-17T18:21:00.000
2
0
1
0
python,django,virtualenv
2,851,741
2
true
1
0
If you have easy_install, or better yet pip installed, should be as easy as: easy_install/pip install virtualenv mkdir django1.2 virtualenv django1.2 This will put the python binary in a bin folder inside the django1.2 folder. Just use that python binary, and you've got a nice little self-contained environment. You can then install easy_install/pip into that environment, and then install django 1.2 as well, and hack away.
1
1
0
Since I have Django 1.1x on my Debian setup - how can I use virtualenv or similar and not have it mess up my system's default django version which in turn would break all my sites? Detailed instructions or a great tutorial link would very much be appreciated - please don't offer vague advice since I'm still a noob. Currently I store all my django projects in ~/django-sites and I am using Apache2 + mod_wsgi to deploy.
Using virtualenv to install different versions of same package
1.2
0
0
381
2,852,056
2010-05-17T19:20:00.000
3
0
0
0
python,frameworks
2,852,087
4
false
1
0
Checkout web2py. Seems to be about the simplest python based webserver I can think of. Django might do, it's hefty, but it comes with it's own development server.
2
2
0
Is there any lightweight mvc webframework which is not necessary to install to the server? I need something simple, that i could just copy to the shared hosting. And it must handle urls other that localhost/test.py, something like this localhost/Blog/test
Simple python mvc framework
0.148885
0
0
4,528
2,852,056
2010-05-17T19:20:00.000
2
0
0
0
python,frameworks
2,853,387
4
false
1
0
web2py includes everything (ssl-enabled web server, sqlite sql based transaction safe database, web based Integrated Development Enviroment, web based database interface) in one package. The web2py binaries for windows and mac also include Python itself. web2py does not require configuration or installation and can run off a usb drive. It was originally developed as a teaching tool for MVC.
2
2
0
Is there any lightweight mvc webframework which is not necessary to install to the server? I need something simple, that i could just copy to the shared hosting. And it must handle urls other that localhost/test.py, something like this localhost/Blog/test
Simple python mvc framework
0.099668
0
0
4,528
2,852,301
2010-05-17T19:59:00.000
1
0
1
0
python,netbeans,feedparser
2,856,391
2
true
0
0
Netbeans by default uses Jython, if you go to Tools>Python Platforms and see that Jython is the default. Switch it to Python and so the installed libraries would work. If you already have a project, you should right click on it, choose Python and on the platform choose Python instead of Jython.
1
0
0
I recently downloaded and installed feedparser with python, I tried to run it but Netbeans shouts on import: ImportError: No module named feedparser restarted the Netbeans, still no go.
adding the feedparser module to python
1.2
0
1
1,032
2,852,397
2010-05-17T20:13:00.000
0
1
1
1
python,linux,bash,scripting
2,853,719
4
false
0
0
Certain scripts that I write simply involving looping over a glob in some directories, and then executing some a piped series of commands on them. This kind of thing is much more tedious in python.
3
1
0
I decided to rewrite all our Bash scripts in Python (there are not so many of them) as my first Python project. The reason for it is that although being quite fluent in Bash I feel it's somewhat archaic language and since our system is in the first stages of its developments I think switching to Python now will be the right thing to do. Are there scripts that should always be written in Bash? For example, we have an init.d daemon script - is it OK to use Python for it? We run CentOS. Thanks.
What scripts should not be ported from bash to python?
0
0
0
387
2,852,397
2010-05-17T20:13:00.000
3
1
1
1
python,linux,bash,scripting
2,852,418
4
true
0
0
It is OK in the sense that you can do it. But the scripts in /etc/init.d usually need to load config data and some functions (for example to print the nice green OK on the console) which will be hard to emulate in Python. So try to convert those which make sense (i.e. those which contain complex logic). If you need job control (starting/stopping processes), then bash is better suited than Python.
3
1
0
I decided to rewrite all our Bash scripts in Python (there are not so many of them) as my first Python project. The reason for it is that although being quite fluent in Bash I feel it's somewhat archaic language and since our system is in the first stages of its developments I think switching to Python now will be the right thing to do. Are there scripts that should always be written in Bash? For example, we have an init.d daemon script - is it OK to use Python for it? We run CentOS. Thanks.
What scripts should not be ported from bash to python?
1.2
0
0
387
2,852,397
2010-05-17T20:13:00.000
1
1
1
1
python,linux,bash,scripting
2,853,661
4
false
0
0
Every task has languages that are better suited for it and less so. Replacing the backtick ` quote of sh is pretty ponderous in Python as would be myriad quoting details, just to name a couple. There are likely better projects to cut your teeth on. And all that they said above about Python being relatively heavyweight and not necessarily available when needed.
3
1
0
I decided to rewrite all our Bash scripts in Python (there are not so many of them) as my first Python project. The reason for it is that although being quite fluent in Bash I feel it's somewhat archaic language and since our system is in the first stages of its developments I think switching to Python now will be the right thing to do. Are there scripts that should always be written in Bash? For example, we have an init.d daemon script - is it OK to use Python for it? We run CentOS. Thanks.
What scripts should not be ported from bash to python?
0.049958
0
0
387
2,852,784
2010-05-17T21:01:00.000
60
1
0
0
php,python,language-comparisons
2,852,795
6
true
0
0
Just leave the bracket's empty... Python has the pass word because they don't use brackets to define the body part of classes, function, and other statement. PHP doesn't have this dilemma , and therefore doesn't need something to say that a body statement is empty.
1
28
0
Do you know any PHP statement that works like Python's pass statement?
What is the equivalent in PHP for Python's pass statement?
1.2
0
0
22,582
2,852,912
2010-05-17T21:23:00.000
1
0
1
0
python,arrays,search,string,duplicates
2,852,951
5
true
0
0
Is this array sorted? I think the fastest solution can be a heap sort or quick sort, and after go through the array, and find the duplicates.
4
0
0
how would i search through a list with ~5 mil 128bit (or 256, depending on how you look at it) strings quickly and find the duplicates (in python)? i can turn the strings into numbers, but i don't think that's going to help much. since i haven't learned much information theory, is there anything about this in information theory? and since these are hashes already, there's no point in hashing them again
Searching through large data set
1.2
0
0
1,366
2,852,912
2010-05-17T21:23:00.000
2
0
1
0
python,arrays,search,string,duplicates
2,852,962
5
false
0
0
Load them into memory (5M x 64B = 320MB), sort them, and scan through them finding the duplicates.
4
0
0
how would i search through a list with ~5 mil 128bit (or 256, depending on how you look at it) strings quickly and find the duplicates (in python)? i can turn the strings into numbers, but i don't think that's going to help much. since i haven't learned much information theory, is there anything about this in information theory? and since these are hashes already, there's no point in hashing them again
Searching through large data set
0.07983
0
0
1,366
2,852,912
2010-05-17T21:23:00.000
0
0
1
0
python,arrays,search,string,duplicates
2,853,423
5
false
0
0
You say you have a list of about 5 million strings, and the list may contain duplicates. You don't say (1) what you want to do with the duplicates (log them, delete all but one occurrence, ...) (2) what you want to do with the non-duplicates (3) whether this list is a stand-alone structure or whether the strings are keys to some other data that you haven't mentioned (4) why you haven't deleted duplicates at input time instead building a list containing duplicates. As a Data Structures and Algorithms 101 exercise, the answer you have accepted is a nonsense. If you have enough memory, detecting duplicates using a set should be faster than sorting a list and scanning it. Note that deleting M items from a list of size N is O(MN). The code for each of the various alternatives is short and rather obvious; why don't you try writing them, timing them, and reporting back? If this is a real-world problem that you have, you need to provide much more information if you want a sensible answer.
4
0
0
how would i search through a list with ~5 mil 128bit (or 256, depending on how you look at it) strings quickly and find the duplicates (in python)? i can turn the strings into numbers, but i don't think that's going to help much. since i haven't learned much information theory, is there anything about this in information theory? and since these are hashes already, there's no point in hashing them again
Searching through large data set
0
0
0
1,366
2,852,912
2010-05-17T21:23:00.000
4
0
1
0
python,arrays,search,string,duplicates
2,853,142
5
false
0
0
If it fits into memeory, use set(). I think it will be faster than sort. O(n log n) for 5 million items is going to cost you. If it does not fit into memory, say you've lot more than 5 million record, divide and conquer. Break the records at the mid point like 1 x 2^127. Apply any of the above methods. I guess information theory helps by stating that a good hash function will distribute the keys evenly. So the divide by mid point method should work great. You can also apply divide and conquer even if it fit into memory. Sorting 2 x 2.5 mil records is faster than sorting 5 mil records.
4
0
0
how would i search through a list with ~5 mil 128bit (or 256, depending on how you look at it) strings quickly and find the duplicates (in python)? i can turn the strings into numbers, but i don't think that's going to help much. since i haven't learned much information theory, is there anything about this in information theory? and since these are hashes already, there's no point in hashing them again
Searching through large data set
0.158649
0
0
1,366