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,394,054
2010-03-06T20:48:00.000
0
0
0
1
python,windows,django,iis,executable
2,395,623
1
false
1
0
Might be a permissions issue. when you run from the shell, you're using the user that run the python manage.py shell command. When serving requests from the IIS you're using its user (IUSR or something like that). Try giving execution permission on the executable file to the Everyone group just to see if it helps.
1
1
0
I have a Python / Django application which is supposed to call an external windows binary and get its output at some point. And it does so when tested via 'python manage.py shell'. But when it is run from within the web browser, which is served by IIS, the external application is not executed. Is IIS blocking something on the way? Can this be avoided? Any help is much appreciated. oMat
Calling an executable from within Python / Django web application running on IIS
0
0
0
1,622
2,394,235
2010-03-06T21:55:00.000
0
1
1
0
python,date,bank
70,469,423
6
false
0
0
I should caution contributors from thinking this is all solvable by an algorithm. Three examples: most Islamic holidays are lunar. The moon is predictable, some countries do this, but others explicitly require that the new moon be actually sighted in the country. Some even post people to the tops of tall mountains, tasked to try to spot the new moon. If the night is cloudy, the new moon may not be sighted, so the following day is not a holiday. a committee in China meets around November each year to decide on the number of holidays that will be given for Chinese New Year in mainland China the following February. As an added complication, because there are so many public holidays given for Chinese New Year, the Chinese Government sometimes nominates weekends after the holiday as working days, to boost economic activity. stock exchanges in India sometimes have a very short trading period at a weekend for auspicious religious reasons. For this reason, there are companies that do this research, get the updates, and publish holidays via an API, for a fee. Users typically query that API every day in case new holidays are announced.
1
30
0
What's the simplest way to determine if a date is a U.S. bank holiday in Python? There seem to be various calendars and webservices listing holidays for various countries, but I haven't found anything specific to banks in the U.S.
Detecting a US Holiday
0
0
0
35,484
2,394,870
2010-03-07T01:54:00.000
0
0
0
0
python,mysql,database,search,indexing
2,395,473
4
false
0
0
If you are trying to search for the names through any development Language, you can use the Regular expression package in Java. Some thing like java.util.regex.*;
1
3
0
They will also search part of their name. Not only words with spaces. If they type "Matt", I expect to retrieve "Matthew" too.
Suppose I have 400 rows of people's names in a database. What's the best way to do a search for their names?
0
1
0
291
2,394,903
2010-03-07T02:09:00.000
0
0
0
1
python,macos
2,394,908
4
false
1
0
The only thing that I can think of is that maybe it's not on your path. Seems unlikely, but I would check that anyways.
2
3
0
I'm very new to Python development, and am having a problem with one of my apps in OSX. Technologies being used in this project python 2.6 django google app engine rpx (openid) When loading up the site on my windows app, there are no issues, but when trying to same app on OSX 10.6, I get the following issue: ImportError at /rpx/rpx/login/ No module named _ctypes Here's where the error is happening: /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/init.py in # """create and manipulate C data types in Python""" import os as _os, sys as _sys version = "1.1.0" from _ctypes import Union, Structure, Array Any ideas? Thanks!
Python _ctypes import error on OSX 10.6
0
0
0
2,937
2,394,903
2010-03-07T02:09:00.000
3
0
0
1
python,macos
4,802,082
4
false
1
0
I don't have enough rep to comment so I will make this a post. The accepted answer is correct in that all you need to do is set the Python Path in the GAE preferences to /usr/bin/python2.5. There is no need to download python 2.5 via macports or from the official python website. python 2.5 is still installed in OSX 10.6, it is just not the default python interpreter. For this reason you need to tell GAE explicitly to use version 2.5. FWIW I'm using GAE Launcher 1.4.1
2
3
0
I'm very new to Python development, and am having a problem with one of my apps in OSX. Technologies being used in this project python 2.6 django google app engine rpx (openid) When loading up the site on my windows app, there are no issues, but when trying to same app on OSX 10.6, I get the following issue: ImportError at /rpx/rpx/login/ No module named _ctypes Here's where the error is happening: /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/init.py in # """create and manipulate C data types in Python""" import os as _os, sys as _sys version = "1.1.0" from _ctypes import Union, Structure, Array Any ideas? Thanks!
Python _ctypes import error on OSX 10.6
0.148885
0
0
2,937
2,395,157
2010-03-07T04:16:00.000
1
1
1
0
php,python,ruby
2,433,699
2
true
0
0
If you're just getting started in python, chances are the standard python distribution will work just fine. Once you get into the guts of your project, changing to IronPython (etc) is not a big deal. I think the most important part is the "getting started" piece. Start writing python and you'll never look back.
2
1
0
I have no knowledge of Python. I started with .NET and than learned PHP. Someone later asked me to learn Ruby as well. I started learning it. Since last few months I am seeing many libraries and drivers written in Python. I want to know what are the advantages of Python over PHP/Ruby? What type of language it is and is there a need to learn Python as well? Which is the purest version of Python? I could see many variants there like IronPython etc.
Python Libraries and drivers
1.2
0
0
98
2,395,157
2010-03-07T04:16:00.000
1
1
1
0
php,python,ruby
2,395,204
2
false
0
0
Nobody can tell you the exact answer because everybody has their own "holy grail". You will just have to find out for yourself which one suits you best for the task you want to perform. Case closed.
2
1
0
I have no knowledge of Python. I started with .NET and than learned PHP. Someone later asked me to learn Ruby as well. I started learning it. Since last few months I am seeing many libraries and drivers written in Python. I want to know what are the advantages of Python over PHP/Ruby? What type of language it is and is there a need to learn Python as well? Which is the purest version of Python? I could see many variants there like IronPython etc.
Python Libraries and drivers
0.099668
0
0
98
2,396,294
2010-03-07T12:57:00.000
1
0
0
0
python,django,frameworks,migrate
2,396,341
2
false
1
0
Your database queries(and object models), url config, and templates to say the least will all be specific to django. That said - if you understand what you're doing, recreating them in another package shouldn't take too long if you really need to at some later time. edit: this is all assuming you dont integrate third party projects such as sqlalchemy and mako. Django plays nice with the builtins it ships with so it's often more trouble than its worth to use said modules.
1
0
0
I'm having trouble deciding which python framework to use for my website. So I've decided to bite the bullet and use Django. My question is how easy (or difficult) will it be to migrate to a different framework in future if I have issues with Django ?
migrating from one framework to another in python
0.099668
0
0
149
2,396,938
2010-03-07T16:18:00.000
9
0
0
0
python,css,django,mobile,templates
2,396,949
6
true
1
0
Have two sets of templates, one for mobile, one for desktop. Store the filenames in a pair of dictionaries, and use the User-agent header to detect which set should be used. Also allow manual selection of which site to use via a session entry.
2
5
0
I'd like everything to function correctly, except when it's mobile, the entire site will used a set of specific templates. Also, I'd like to autodetect if it's mobile. If so, then use that set of templates throughout the entire site.
In Django, what is the best way to manage both a mobile and desktop site?
1.2
0
0
1,531
2,396,938
2010-03-07T16:18:00.000
1
0
0
0
python,css,django,mobile,templates
2,397,185
6
false
1
0
If you place a class on your body (Django uses something similar to specify what column style to use), you could use the same templates but simply use different stylesheets. I'm not sure what main differences you are using separate templates for, but this might allow you to cut down on re-coding the templates multiple times.
2
5
0
I'd like everything to function correctly, except when it's mobile, the entire site will used a set of specific templates. Also, I'd like to autodetect if it's mobile. If so, then use that set of templates throughout the entire site.
In Django, what is the best way to manage both a mobile and desktop site?
0.033321
0
0
1,531
2,397,295
2010-03-07T18:07:00.000
1
0
0
0
python,firefox,webkit,web-scraping
2,397,311
10
false
1
0
Well, WebKit is open source so you could use its own parser (in the WebCore component), if any language is acceptable
1
9
0
I'm currently trying to scrape a website that has fairly poorly-formatted HTML (often missing closing tags, no use of classes or ids so it's incredibly difficult to go straight to the element you want, etc.). I've been using BeautifulSoup with some success so far but every once and a while (though quite rarely), I run into a page where BeautifulSoup creates the HTML tree a bit differently from (for example) Firefox or Webkit. While this is understandable as the formatting of the HTML leaves this ambiguous, if I were able to get the same parse tree as Firefox or Webkit produces I would be able to parse things much more easily. The problems are usually something like the site opens a <b> tag twice and when BeautifulSoup sees the second <b> tag, it immediately closes the first while Firefox and Webkit nest the <b> tags. Is there a web scraping library for Python (or even any other language (I'm getting desperate)) that can reproduce the parse tree generated by Firefox or WebKit (or at least get closer than BeautifulSoup in cases of ambiguity).
Web scraping with Python
0.019997
0
1
4,506
2,397,576
2010-03-07T19:22:00.000
4
0
1
0
python,concurrency
2,397,580
2
true
0
0
Have you considered using the multiprocessing module to coordinate between the running programs in a thread-like manner? See in particular the queue interface; you can place each completed work item on a queue when completed, and have a single process reading off the queue and writing to your output file. Alternately, you can have each subprocess maintain a separate pipe to a parent process which does a select() call from all of them, and copies data to the output file when appropriate. Of course, this can be done "by hand" (without the multiprocessing module) as well as with it. Alternately, if the reason you're avoiding threads is to avoid the global interpreter lock, you might consider a non-CPython implementation (such as Jython or IronPython).
2
4
0
I've got multiple python processes (typically 1 per core) transforming large volumes of data that they are each reading from dedicated sources, and writing to a single output file that each opened in append mode. Is this a safe way for these programs to work? Because of the tight performance requirements and large data volumes I don't think that I can have each process repeatedly open & close the file. Another option is to have each write to a dedicated output file and a single process concatenate them together once they're all done. But I'd prefer to avoid that. Thanks in advance for any & all answers and suggestions.
How to have multiple python programs append rows to the same file?
1.2
0
0
2,659
2,397,576
2010-03-07T19:22:00.000
4
0
1
0
python,concurrency
2,397,607
2
false
0
0
Your procedure is "safe" in that no crashes will result, but data coming (with very unlucky timing) from different processes could get mixed up -- e.g., process 1 is appending a long string of as, process 2 a long string of b, you could end up in the file with lots of as then the bs then more as (or other combinations / mixings). Problem is, .write is not guaranteed to be atomic for sufficiently long string arguments. If you have a tight boundary on the arguments, less than your fs/os's blocksize, you might be lucky. Otherwise, try using the logging module, which does take more precautions (but perhaps those precautions might slow you down... you'll need to benchmark) exactly because it targets "log files" that are often being appended to by multiple programs.
2
4
0
I've got multiple python processes (typically 1 per core) transforming large volumes of data that they are each reading from dedicated sources, and writing to a single output file that each opened in append mode. Is this a safe way for these programs to work? Because of the tight performance requirements and large data volumes I don't think that I can have each process repeatedly open & close the file. Another option is to have each write to a dedicated output file and a single process concatenate them together once they're all done. But I'd prefer to avoid that. Thanks in advance for any & all answers and suggestions.
How to have multiple python programs append rows to the same file?
0.379949
0
0
2,659
2,398,800
2010-03-08T01:27:00.000
3
0
0
0
python,user-interface,qt,pyqt,qt-designer
54,119,368
12
false
0
1
in pyqt5 to convert from a ui file to .py file pyuic5.exe youruifile.ui -o outputpyfile.py -x
2
83
0
So if I go into QtDesigner and build a UI, it'll be saved as a .ui file. How can I make this as a python file or use this in python?
Linking a qtDesigner .ui file to python/pyqt?
0.049958
0
0
135,115
2,398,800
2010-03-08T01:27:00.000
0
0
0
0
python,user-interface,qt,pyqt,qt-designer
52,304,139
12
false
0
1
Using Anaconda3 (September 2018) and QT designer 5.9.5. In QT designer, save your file as ui. Open Anaconda prompt. Search for your file: cd C:.... (copy/paste the access path of your file). Then write: pyuic5 -x helloworld.ui -o helloworld.py (helloworld = name of your file). Enter. Launch Spyder. Open your file .py.
2
83
0
So if I go into QtDesigner and build a UI, it'll be saved as a .ui file. How can I make this as a python file or use this in python?
Linking a qtDesigner .ui file to python/pyqt?
0
0
0
135,115
2,399,643
2010-03-08T06:25:00.000
4
0
0
0
python,berkeley-db,bsddb,okvs
2,399,691
2
true
0
0
You have to pick one "column" as the key (must be unique; I imagine that would be "username" in your case) -- the only way searches will ever possibly happen. The other columns can be made to be the single string value of that key by any way you like, from pickling to simple joining with a character that's guaranteed to never occur in any of the columns, such as `\0' for many kind of "readable text strings". If you need to be able to search by different keys you'll need other, supplementary and separate bsddb databases set up as "indices" into your main table -- it's lots of work, and there's lots of literature on the subject. (Alternatively, you move to a higher-abstraction technology, such as sqlite, which handles the indexing neatly on your behalf;-).
1
1
0
Say I have a simple table that contains username, firstname, lastname. How do I express this in berkeley Db? I'm currently using bsddb as the interface. Cheers.
Expressing multiple columns in berkeley db in python?
1.2
1
0
1,199
2,399,812
2010-03-08T07:12:00.000
0
0
0
0
python,wxpython,mode,kiosk
2,399,853
2
false
0
1
wxPython alone cannot be done with that. You need to do Low Level Keyboard Hook with C/C++ or with equivalent ctypes, for Windows keys, alt-tab, alt-f4, but Ctrl-Alt-Del, I don't think so for Windows XP and above.
1
0
0
Is there a way to create a 'kiosk mode' in wxpython under Windows (98 - 7) where the application disables you from breaking out of the app using Windows keys, alt-tab, alt-f4, and ctrl+alt+delete?
Kiosk mode in wxpython?
0
0
0
753
2,400,088
2010-03-08T08:37:00.000
0
1
1
0
python,vim
2,401,864
2
true
0
0
If you want json/simplejson to produce unicode output instead of str output with Unicode escapes then you need to pass ensure_ascii=False to dump()/dumps(), then either encode before saving or use a file-like from codecs.
1
1
0
I would like to do the following: 1) Serialize my class 2) Also manually edit the serialization dump file to remove certain objects of my class which I find unnecessary. I am currently using python with simplejson. As you know, simplejson converts all characters to unicde. As a result, when I dump a particular object with simplejson, the unicode characters becomes something like that "\u00bd" for 好. I am interested to manually edit the simplejson file for convenience. Anyone here know a work around for me to do this? My requirements for this serialization format: 1) Easy to use (just dump and load - done) 2) Allows me to edit them manually without much hassle. 3) Able to display chinese character I use vim. Does anyone know a way to conver "\u00bd" to 好 in vim?
Python: getting \\u00bd correctly in editor
1.2
0
0
600
2,400,276
2010-03-08T09:22:00.000
1
0
1
0
python,linux,inotify
2,400,337
2
false
0
0
It's always a good idea to release resources (e.g. free memory, close file descriptors, waitpid(2) on child processes, etc) whenever you're done using them. Being lazy and letting the operating system take care of it for you when you exit is a sure way to cause bugs in the future.
2
3
0
With python inotifyx, do I have to remove watch and close opened system file descriptor if I need them until program exit? E.g. is there some possible problems if I create one (file descriptor + watch) with each run and don't close it?
Is closing file descriptor and removing inotify watch really necessary?
0.099668
0
0
1,568
2,400,276
2010-03-08T09:22:00.000
0
0
1
0
python,linux,inotify
2,400,290
2
true
0
0
The kernel stores watches as full paths, so closing the watch is preferable, it also takes unnecessary work off of VFS. As for the file descriptor, that would depend on how many others you had opened. Kind of like a phone call, its nice to tell the other party that you have stopped listening, hanging up the phone is optional, but conventional. If you need it for something, keep it.
2
3
0
With python inotifyx, do I have to remove watch and close opened system file descriptor if I need them until program exit? E.g. is there some possible problems if I create one (file descriptor + watch) with each run and don't close it?
Is closing file descriptor and removing inotify watch really necessary?
1.2
0
0
1,568
2,400,605
2010-03-08T10:26:00.000
6
1
0
0
php,python,ruby,delphi
2,401,097
10
false
0
0
Why should an answer be different if the question was asked by a Delphi programmer, than a programmer from any other platform? Any decent language should be fun to learn, regardless of the tool you are using right now. That said, I myself walked a way from Borland Pascal and Delphi (quite some time ago), over PHP and ASP.NET (using C#). Right now I am working almost exclusively on Ruby (and occasionally Rails) and I am perfectly happy with it. But, then again, it's matter of personal preference: I really enjoy Ruby's pure object-orientation and functional capabilities, as well as dynamical nature of a scripting language. So, it's all up to you and your personal preferences. Although, one thing I can surely recommend is to stick with one of the major web-players, for pragmatic reasons: PHP, Python, Ruby, ASP.NET or possibly Java. I'm sorry to say that, but I don't think Pascaloid languages have any future anymore.
3
5
0
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want to deploy the application to shared hosting, specially Linux. so as Delphi developer, what do you choose to develop web application?
Best web application language for Delphi Developers
1
0
0
2,367
2,400,605
2010-03-08T10:26:00.000
1
1
0
0
php,python,ruby,delphi
2,401,646
10
false
0
0
PHP is a pretty simple answer. One reason is there is both Delphi4PHP (the rather cryptic IDE licensed by Embarcadero which in my estimation is really only for Web Apps (not for doing whole site)s) and PHP4Delphi (the pretty awesome Delphi Component that lets you compile your Delphi code to PHP Extensions).
3
5
0
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want to deploy the application to shared hosting, specially Linux. so as Delphi developer, what do you choose to develop web application?
Best web application language for Delphi Developers
0.019997
0
0
2,367
2,400,605
2010-03-08T10:26:00.000
0
1
0
0
php,python,ruby,delphi
2,401,428
10
false
0
0
I have done a fairly large (4-5 FTE) project based on webhub (www.href.com). I can certainly advise this if it is a webapp for internal use.
3
5
0
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want to deploy the application to shared hosting, specially Linux. so as Delphi developer, what do you choose to develop web application?
Best web application language for Delphi Developers
0
0
0
2,367
2,400,619
2010-03-08T10:30:00.000
1
0
1
0
python,python-idle
2,400,666
2
false
0
0
I assume you are asking about how to enable debugging in Idle? In the Python Shell window, choose Debugger from the Debug menu, then open foo.py and use the Run Model command. A Debug Control window opens, allowing you to step through the execution of foo.py; when execution is over, the prompt is still available for you to manually call functions, interact with objects or otherwise tinker with your application (and you will be still debugging the script).
1
3
0
I love the IDLE. However, sometimes I have 100-200 line scripts and I want to sort of interactively debug/play with say, functions defined in foo.py instead of just calling python foo.py. Is there a way I can trigger IDLE in the context of my foo.py?
How can I interact with rather long python scripts?
0.099668
0
0
291
2,400,643
2010-03-08T10:34:00.000
2
1
1
0
python,json,large-files
2,400,780
11
true
0
0
Update See the other answers for advice. Original answer from 2010, now outdated Short answer: no. Properly dividing a json file would take intimate knowledge of the json object graph to get right. However, if you have this knowledge, then you could implement a file-like object that wraps the json file and spits out proper chunks. For instance, if you know that your json file is a single array of objects, you could create a generator that wraps the json file and returns chunks of the array. You would have to do some string content parsing to get the chunking of the json file right. I don't know what generates your json content. If possible, I would consider generating a number of managable files, instead of one huge file.
4
86
0
I have some json files with 500MB. If I use the "trivial" json.load() to load its content all at once, it will consume a lot of memory. Is there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.
Is there a memory efficient and fast way to load big JSON files?
1.2
0
0
70,067
2,400,643
2010-03-08T10:34:00.000
3
1
1
0
python,json,large-files
2,402,371
11
false
0
0
On your mention of running out of memory I must question if you're actually managing memory. Are you using the "del" keyword to remove your old object before trying to read a new one? Python should never silently retain something in memory if you remove it.
4
86
0
I have some json files with 500MB. If I use the "trivial" json.load() to load its content all at once, it will consume a lot of memory. Is there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.
Is there a memory efficient and fast way to load big JSON files?
0.054491
0
0
70,067
2,400,643
2010-03-08T10:34:00.000
1
1
1
0
python,json,large-files
2,402,407
11
false
0
0
in addition to @codeape I would try writing a custom json parser to help you figure out the structure of the JSON blob you are dealing with. Print out the key names only, etc. Make a hierarchical tree and decide (yourself) how you can chunk it. This way you can do what @codeape suggests - break the file up into smaller chunks, etc
4
86
0
I have some json files with 500MB. If I use the "trivial" json.load() to load its content all at once, it will consume a lot of memory. Is there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.
Is there a memory efficient and fast way to load big JSON files?
0.01818
0
0
70,067
2,400,643
2010-03-08T10:34:00.000
3
1
1
0
python,json,large-files
2,406,386
11
false
0
0
"the garbage collector should free the memory" Correct. Since it doesn't, something else is wrong. Generally, the problem with infinite memory growth is global variables. Remove all global variables. Make all module-level code into smaller functions.
4
86
0
I have some json files with 500MB. If I use the "trivial" json.load() to load its content all at once, it will consume a lot of memory. Is there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.
Is there a memory efficient and fast way to load big JSON files?
0.054491
0
0
70,067
2,400,827
2010-03-08T11:12:00.000
3
0
1
0
python,filesystems
2,400,870
3
false
0
0
Or you could append the current system time to make unique filenames...
1
6
0
I want my program to be able to write files in a sequential format, ie: file1.txt, file2.txt, file3.txt. It is only meant to write a single file upon execution of the code. It can't overwrite any existing files, and it MUST be created. I'm stumped.
Python: How do I create sequential file names?
0.197375
0
0
10,921
2,401,508
2010-03-08T13:18:00.000
1
0
0
0
python,mysql,database,regex,search
2,401,635
2
true
0
0
This is very hard for us to determine without knowing: the amount of text to search the load and configuration on the database server the load and configuration on on the webserver etc etc ... With that said i would conceptually definitely go for the first scenario. It should be lightening-fast when searching only 500 rows.
1
0
0
Suppose I have 500 rows of data, each with a paragraph of text (like this paragraph). That's it.I want to do a search that matches part of words. (%LIKE%, not FULL_TEXT) What would be faster? SELECT * FROM ...WHERE LIKE "%query%"; This would put load on the database server. Select all. Then, go through each one and do .find >= 0 This would put load on the web server. This is a website, and people will be searching frequently.
What would be the most efficient way to do this search (mysql or text)?
1.2
1
0
105
2,401,599
2010-03-08T13:34:00.000
0
0
1
0
python,c,cross-platform,packaging,cross-compiling
2,467,317
6
false
0
1
For casual gaming I would recommend Flash
1
6
0
Some friends and I wanted to develop a game. Any language will do. I've been programming in C for years, but never wrote a game before. One of us knows SDL a little bit. It would also be a nice excuse to learn Python+pygame. We wish our game to be 'standalone'. By standalone, I mean most users (at least Linux, Mac and Windows) will not have to manually download and install anything else apart from a package. It is ok if the installation automatically handles missing dependencies. If the packages contain binaries, we wish to be able to generate them using cross-compilation from Linux. How should we package and structure the project, and what language is best suited?
Game cross-compiling and packaging
0
0
0
1,603
2,401,602
2010-03-08T13:34:00.000
0
1
0
0
python,apache,unix
2,401,607
3
false
0
0
This should be on ServerFault. By the way, mod_python is deprecated, use WSGI instead.
1
2
0
I have mod_python installed on my server, but if I want to acceses a python script - let's say httü://site.com/something.py the script doesn't run, the download box "pops up" Any solutions?
How to run python scripts on your server?
0
0
0
280
2,401,789
2010-03-08T14:03:00.000
0
1
0
0
python,unit-testing,aop
2,402,152
3
false
1
0
Well... let's see. In my opinion you are testing three different things here (sorry for the "Java AOP jargon"): the features implemented by the interceptors (i.e. the methods that implement the functions activated at the cutpoints) the coverage of the filters (i.e. whether the intended cutpoints are activated correctly or not) the interaction between the cutpoints and the interceptors (with the side effects) You are unit testing (strictly speaking) if you can handle these three layers separatedly. You can actually unit test the first; you can use a coverage tool and some skeleton crew application with mock objects to test the second; but the third is not exactly unit testing, so you may have to setup a test environment, design an end-to-end test and write some scripts to input data in your application and gather the results (if it was a web app you could use Selenium, for example).
2
4
0
I'd like to know what would you propose as the best way to unit test aspect-oriented application features (well, perhaps that's not the best name, but it's the best I was able to come up with :-) ) such as logging or security? These things are sort of omni-present in the application, so how to test them properly? E.g. say that I'm writing a Cherrypy web server in Python. I can use a decorator to check whether the logged-in user has the permission to access a given page. But then I'd need to write a test for every page to see whether it works oK (or more like to see that I had not forgotten to check security perms for that page). This could maybe (emphasis on maybe) be bearable if logging and/or security were implemented during the web server "normal business implementation". However, security and logging usually tend to be added to the app as an afterthough (or maybe that's just my experience, I'm usually given a server and then asked to implement security model :-) ). Any thoughts on this are very welcome. I have currently 'solved' this issue by, well - not testing this at all. Thanks.
Unit testing aspect-oriented features
0
0
0
258
2,401,789
2010-03-08T14:03:00.000
1
1
0
0
python,unit-testing,aop
2,796,926
3
false
1
0
IMHO, the way of testing users permissions to the pages depends on the design of your app and design of the framework you're using. Generally, it's probably enough to cover your permission checker decorator with unit tests to make sure it always works as expected and then write a test that cycles through your 'views' (or whatever term cherrypy uses, haven't used it for a very long time) and just check if these functions are decorated with appropriate decorator. As for logging it's not quite clear what you want test specifically. Anyway, why isn't it possible to stub the logging functionality and check what's going on there?
2
4
0
I'd like to know what would you propose as the best way to unit test aspect-oriented application features (well, perhaps that's not the best name, but it's the best I was able to come up with :-) ) such as logging or security? These things are sort of omni-present in the application, so how to test them properly? E.g. say that I'm writing a Cherrypy web server in Python. I can use a decorator to check whether the logged-in user has the permission to access a given page. But then I'd need to write a test for every page to see whether it works oK (or more like to see that I had not forgotten to check security perms for that page). This could maybe (emphasis on maybe) be bearable if logging and/or security were implemented during the web server "normal business implementation". However, security and logging usually tend to be added to the app as an afterthough (or maybe that's just my experience, I'm usually given a server and then asked to implement security model :-) ). Any thoughts on this are very welcome. I have currently 'solved' this issue by, well - not testing this at all. Thanks.
Unit testing aspect-oriented features
0.066568
0
0
258
2,402,128
2010-03-08T14:52:00.000
3
0
0
0
python,user-interface,google-app-engine
2,404,551
3
false
1
1
There is no difference in the amount of built in widgets available to the python and java sides of app engine. Neither side has any! App Engine is primarily a back end technology. It allows you to use pretty much whatever web framework you want for your presentation layer, subject to constraints that Alex mentions. GWT is completely unrelated to App Engine, besides being developed by Google. It is a client side toolkit, and can be used just fine with any web app as a backend, whether created in java, python or [your favorite language]. (Admittedly, you get a few bonus features if your backend is in java.)
1
5
0
Are there any UI widgets available to the python side of Google App Engine? I'd like something like the collapsed/expanded views of Google Groups threads. Are these type things limited to the GWT side?
Google App Engine UI Widgets
0.197375
0
0
2,260
2,403,041
2010-03-08T16:59:00.000
4
0
0
0
python,powerpoint,jpeg
2,403,104
3
false
1
0
Off the top of my head, the way I'd do it: Use OpenOffice.org to convert the .ppt file into a PDF. (OO.o has a very rich Java API. Rich and bloody difficult to use, mind, but once you figure out how to get it to do the task you need, you're all set. Dunno if you can do anything useful with it via Python; not my language.) Use ImageMagick to convert the PDF into .jpg files. (Though I've been told converting the PDF into a PS file before turning it into images gives better results.) (IM's command line interface is damn near a language unto itself -- though again, once you figure out how to get it to do what you want, you're all set.) Dunno if that's the most efficient/reliable way to do it. But fundamentally, I'd be on Google trolling for open-source third party tools that do all the dirty work for me.
1
4
0
I'm creating a "slideshow room" web page. The user will upload a PowerPoint file that my server will use to generate a set of .jpg image files representing the slides to present in a custom "gallery viewer". I'm an experienced Python developer but I cannot find anything useful. How can I do that?
How do I create a set of image files from a PowerPoint file file?
0.26052
0
0
2,977
2,406,082
2010-03-09T01:38:00.000
0
0
0
1
python,google-app-engine,screen-scraping
2,660,349
4
false
1
0
I have used BeautifulSoup with great success parsing HTML. Problem is that's all BeautifulSoup does, is parse the HTML. I ended up writing all the http interactions using urlfetch. To web-scrape my target I need a full fledged code driven browser that can execute javascript on my target site's pages. I think I'm having to dump the python app and go java so I can use HTMLUnit - prototyping underway. - mattb
2
3
0
I am looking to setup a automated screen scraper that will run on Google app engine using python. I want it to scrape the site and put the specified results into a Entity in app engine. I am looking for some directions on what to use. I have seen beautifulsoup but wonder if people could recommend anything else that could run on Google App engine.
Setting up a python screen scraper that could work on Google App engine
0
0
0
2,539
2,406,082
2010-03-09T01:38:00.000
0
0
0
1
python,google-app-engine,screen-scraping
2,406,093
4
false
1
0
The other choice is lxml, but it uses C code and so does not work on GAE.
2
3
0
I am looking to setup a automated screen scraper that will run on Google app engine using python. I want it to scrape the site and put the specified results into a Entity in app engine. I am looking for some directions on what to use. I have seen beautifulsoup but wonder if people could recommend anything else that could run on Google App engine.
Setting up a python screen scraper that could work on Google App engine
0
0
0
2,539
2,407,212
2010-03-09T07:10:00.000
3
0
0
0
python,sikuli
3,884,131
4
false
0
1
If you are using Sikuli IDE click image miniature, for which you want to change sensitivity. You will be presented screenshot of your desktop with and occurrences of pattern(your image). Below there is a slider witch changes sensitivity. While changing it you will notice that highlighted occurrences of the pattern increase or decrease accordingly. This method assumes that you have your game on screen (so windowed mode, not fullscreen), but even if you don't you still can adjust sensitivity, just you won't see 'live' results of search. If you call sikuli from Java code, you have to use Pattern(image.png).similar(y.xx) where the argument of simmilar is something between 0.00 and 1.00. I haven't used second method so you may need to experiment with it.
2
5
0
I've been using sikuli for awhile, however I have an issue with it... It's not sensitive enough. I'm trying to match something on the screen that is -EXACT-, and there are a few other items on the screen that look similar enough that sikuli is mistaking them for what I'm actually looking for, so I need to make it look for ONLY this item with no variances at all. How can I do this? Oh and to explain my issue a bit further, I am writing a loop for a game, once a progress bar has reached 100% - it needs to allow the loop to finish (And start over again), however the progress bar is just a plain bar - so when sikuli looks for it on the screen, it finds the partially complete bar (Since apparently it matches different lengths/widths/sizes of the image it is looking for), and triggers.
Change Sikuli's sensitivity?
0.148885
0
0
6,449
2,407,212
2010-03-09T07:10:00.000
7
0
0
0
python,sikuli
3,885,229
4
true
0
1
You can do the following in the Sikuli IDE: Click on the image In Pattern Settings > Matching Preview, drag the Similarity bar to 1.0 (all the way to the right) Click OK
2
5
0
I've been using sikuli for awhile, however I have an issue with it... It's not sensitive enough. I'm trying to match something on the screen that is -EXACT-, and there are a few other items on the screen that look similar enough that sikuli is mistaking them for what I'm actually looking for, so I need to make it look for ONLY this item with no variances at all. How can I do this? Oh and to explain my issue a bit further, I am writing a loop for a game, once a progress bar has reached 100% - it needs to allow the loop to finish (And start over again), however the progress bar is just a plain bar - so when sikuli looks for it on the screen, it finds the partially complete bar (Since apparently it matches different lengths/widths/sizes of the image it is looking for), and triggers.
Change Sikuli's sensitivity?
1.2
0
0
6,449
2,407,589
2010-03-09T08:38:00.000
33
0
0
0
python,api,blocking
2,407,601
2
false
0
0
"Blocking" means that the caller waits until the callee finishes its processing. For instance, a "blocking read" from a socket waits until there is data to return; a "non-blocking" read does not, it just returns an indication (usually a count) of whether there was something read. You hear the term mostly around APIs that access resources that don't necessarily require CPU attention -- I/O, for instance. You also hear it in multi-threading: A call from Thread A to Thread B might be designed to "block" (hold up Thread A) until Thread B achieves the relevant state to process or at least accept the request. (The most obvious example there being "join", which usually means "I, Thread A, want to wait until Thread B has terminated" -- you use that when exiting a multi-threaded program.)
2
28
0
Could someone provide a layman definition and use case?
What does the term "blocking" mean in programming?
1
0
0
14,970
2,407,589
2010-03-09T08:38:00.000
5
0
0
0
python,api,blocking
2,407,604
2
false
0
0
In simple words: If you call a function that stops the program from continuing to run until the user has performed some action (or some other action that your program is not controlling), this call is called a blocking call.
2
28
0
Could someone provide a layman definition and use case?
What does the term "blocking" mean in programming?
0.462117
0
0
14,970
2,408,560
2010-03-09T11:17:00.000
2
0
0
0
python,windows,input
53,794,715
14
false
0
0
I'd do what Mickey Chan said, but I'd use unicurses instead of normal curses. Unicurses is universal (works on all or at least almost all operating systems)
1
73
0
I am trying to make a simple IRC client in Python (as kind of a project while I learn the language). I have a loop that I use to receive and parse what the IRC server sends me, but if I use raw_input to input stuff, it stops the loop dead in its tracks until I input something (obviously). How can I input something without the loop stopping? (I don't think I need to post the code, I just want to input something without the while 1: loop stopping.) I'm on Windows.
Non-blocking console input?
0.028564
0
1
93,857
2,408,882
2010-03-09T12:18:00.000
3
0
1
0
python,events,multithreading
2,408,923
2
true
0
0
Yes, you're missing next sentence in documentation which writes: Changed in version 2.7: Previously, the method always returned None.
1
1
0
import threading event = threading.Event() event.set() print event.wait(1) None event.clear() print event.wait(1) None So it basically returns None both when condition was True and False. How can I distinguish the case of timeouting from the one with no waiting at all? Meanwile, the docs say This method returns the internal flag on exit, so it will always return True except if a timeout is given and the operation times out. Am I missing something?
How can I tell if waiting on Event has timed out?
1.2
0
0
2,128
2,409,168
2010-03-09T13:04:00.000
2
0
1
1
python
2,409,213
2
false
0
0
You could write a installer (using NSIS or something) that does two things : install LateX (or make sure there is an installation of latex available), potentially by calling another installer then install your python script (which can assume latex is now available)
1
1
0
I wanted to know how can I make standalone application in python. Basically what I am doing right now is I have a template.tex file and my script generate the pdf by giving some input values. So I have to make exe file for windows and same for linux. I can use cx_freeze for creating exe file. But my problem is most of people do not contain latex on their computer. SO how can I make latex get install when I first run my exe. Basically how to make make file. Thanks
standalone application in python
0.197375
0
0
467
2,409,200
2010-03-09T13:12:00.000
1
0
0
1
python,terminal-services,citrix
2,410,065
2
true
0
0
The various instances of your application need some way to communicate with one another. When an instance starts up, it asks the question, 'how many are already running?'. If there are more than the allowed n, it chooses not to start up. One implementation approach might be to make n files to lock for the n instances of your application you allow to run at the same time. Then, the application tries to get a lock on one of those files; if it can't, it exits immediately. Release the lock when you're done, but presumably the OS would release the lock for you if you crash. Another approach would be to register some per-process unique piece of information (a PID?) in a central location (some database) when you start. Yet a third might be to use a host-only network server where either a dedicated server program or one of the instances coordinates communications with the other instances. If the host exits, one of the other instances can self-promote to being the server.
2
3
0
I'm looking for simple ways to monitor and limit the number of instances of our application under Terminal Server (2003 and 2008). The purpose of this restriction is to make sure we don't overload our servers. This is an internal administrative requirement - I am not looking for a licensing solution. The application in question is written in Python 2.6 (32-bit) but I'm happy to receive development tool agnostic answers. Although we are not using Citrix, I am happy to receive Citrix related ideas with the hope that I can use a similar technique with Terminal Server.
Technique to limit number of instances of our application under Terminal Server
1.2
0
0
702
2,409,200
2010-03-09T13:12:00.000
1
0
0
1
python,terminal-services,citrix
2,431,193
2
false
0
0
Based on feedback on the Python Win32 API mailing list I'm also considering one of the following techniques: Using Windows Semaphores Using a pool of Mutexes (offer better recoverability than semaphores) Using a range of ports
2
3
0
I'm looking for simple ways to monitor and limit the number of instances of our application under Terminal Server (2003 and 2008). The purpose of this restriction is to make sure we don't overload our servers. This is an internal administrative requirement - I am not looking for a licensing solution. The application in question is written in Python 2.6 (32-bit) but I'm happy to receive development tool agnostic answers. Although we are not using Citrix, I am happy to receive Citrix related ideas with the hope that I can use a similar technique with Terminal Server.
Technique to limit number of instances of our application under Terminal Server
0.099668
0
0
702
2,409,812
2010-03-09T14:42:00.000
0
1
0
0
php,python,pylons
6,481,796
4
false
0
0
Many many times have we had this discussion at my job. We use PHP and everyone here would love to switch to python. Even for our new web projects PHP delivers, and since we use it every day that is what we use. Many things in PHP irk me, and I love python, that said Im a big fan of "use the best tool for the job". Good code is possible in PHP (and horrible horrible code too), so use what is the best tool for you, and for this job. If however this webapp is a hobby and/or not mission-critical software I would fully recommend python if only to learn a new language.
4
4
0
My friend and I are planning on building a sort of a forum type of webapp. We've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all. What would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?
Should we use Pylons or PHP for our webapp?
0
0
0
675
2,409,812
2010-03-09T14:42:00.000
5
1
0
0
php,python,pylons
2,409,917
4
false
0
0
Don't be scared off by imports in python. They're much more common when coding in python than PHP in general, and this is good because your namespace never gets polluted with stuff you aren't expecting, unless you do from foo import * (so don't do that). I think you'll find that the structure pylons gives you will be invaluable. There are frameworks in PHP as well, but if you want to learn python anyway, I see no reason you shouldn't dive in with Pylons.
4
4
0
My friend and I are planning on building a sort of a forum type of webapp. We've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all. What would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?
Should we use Pylons or PHP for our webapp?
0.244919
0
0
675
2,409,812
2010-03-09T14:42:00.000
9
1
0
0
php,python,pylons
2,409,852
4
false
0
0
Decide what you want to put your focus on, being productive or learning a new language: If you want to learn Pylons and Python, use Pylon and Python. If you want to deliver a stable forum software, use PHP, because that's what you're competent at. Note: I should add that this is not meant to imply that you cannot be productive with Python or Pylon in general. All I'm saying is, in your case, you will be more productive with PHP, because you know it.
4
4
0
My friend and I are planning on building a sort of a forum type of webapp. We've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all. What would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?
Should we use Pylons or PHP for our webapp?
1
0
0
675
2,409,812
2010-03-09T14:42:00.000
4
1
0
0
php,python,pylons
2,409,860
4
false
0
0
I don't know about Pylons but I've been in a similar situation and built a site using Django. I learned enough about Python in an environment that I was familiar with (web apps) that I now go to Python as my first choice.
4
4
0
My friend and I are planning on building a sort of a forum type of webapp. We've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all. What would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?
Should we use Pylons or PHP for our webapp?
0.197375
0
0
675
2,411,306
2010-03-09T18:01:00.000
0
0
1
0
python,multithreading
2,411,865
2
true
0
0
If I had this problem (and "polling", i.e. trying each queue alternately with short timeouts, was unacceptable -- it usually is, being very wasteful of CPU time etc), I would tackle it by designing a "multiqueue" object -- one with multiple condition variables, one per "subqueue" and an overall one. A put to any subqueue would signal that subqueue's specific condition variable as well as the overall one; a get from a specific subqueue would only wait on its specific condition variable, but there would also be a "get from any subqueue" which waits on the overall condition variable instead. (If more combinations than "get from this specific subqueue" or "get from any subqueue" need to be supported, just as many condition variables as combinations to support would be needed). It would be much simpler to code if get and put were reduced to their bare bones (no timeouts, no no-waits, etc) and all subqueues used a single overall mutex (very small overhead wrt many mutexes, and much easier to code in a deadlock-free way;-). The subqueues could be exposed as "simplified queue-like duckies" to existing code which assumes it's dealing with a plain old queue (e.g. the multiqueue could support indexing to return proxy objects for the purpose). With these assumptions, it wouldn't be much code, though it would be exceedingly tricky to write and inspect for correctness (alas, testing is of limited use when very subtle threading code is in play) -- I can't take the time for that right now, though I'd be glad to give it a try tonight (8 hours from now or so) if the assumptions are roughly correct and no other preferable answer has surfaced.
2
0
0
Say there are two empty Queues. Is there a way to get an item from the queue that gets it first? So I have a queue of high anonymous proxies, queues of anonymous and transparent ones. Some threads may need only high anon. proxies, while others may accept both high anon. and just anon. proxies. That's why I can't put them all to a single queue.
How to get an item from a set of Queues?
1.2
0
1
119
2,411,306
2010-03-09T18:01:00.000
0
0
1
0
python,multithreading
2,411,355
2
false
0
0
You could check both queues in turn, each time using a short timeout. That way you would most likely read from the first queue that receives data. However, this solution is prone to race conditions if you will be getting many items on a regular basis. If that is the case, do you have a good reason for not just writing data to one queue?
2
0
0
Say there are two empty Queues. Is there a way to get an item from the queue that gets it first? So I have a queue of high anonymous proxies, queues of anonymous and transparent ones. Some threads may need only high anon. proxies, while others may accept both high anon. and just anon. proxies. That's why I can't put them all to a single queue.
How to get an item from a set of Queues?
0
0
1
119
2,411,886
2010-03-09T19:21:00.000
0
0
0
0
python,user-interface,python-3.x
29,502,724
4
false
0
1
I use exclusively Tkinter, and though it's somewhat limited in terms of images, it's remarkably easy to work with and follows the standard easy-to-read Python syntax very nicely. I'm not familiar with other GUI options, but Tkinter is great from my experience.
1
4
0
I was wondering what options are available for Python 3.x? I know Tkinter is available as well as qt, but what about the other libraries? Any word on when some of them may be ported over to 3.x?
GUI options with python 3.x
0
0
0
968
2,414,616
2010-03-10T04:56:00.000
1
0
1
1
c#,c++,python
2,414,677
5
false
0
0
The first solution would be to fix your EXE, so it does not crash. If you can not fix it now, you probably need to add exception handling, so you can catch the exception, and not close the EXE. Second solution is to write simple guard programm that will start your simple .exe and will monitor specific process handle. It will restart your program when it closes.
1
0
0
I have a simple .exe that needs to be running continuously. Unfortunately, sometimes it crashes unexpectedly, and there's nothing that can be done for this. I'm thinking of like a C# program that scans the running application tree on a timer and if the process stops running it re-launches it... ? Not sure how to do that though.... Any other ideas?
How to make script/program to make it so an application is always running?
0.039979
0
0
221
2,414,667
2010-03-10T05:08:00.000
29
0
1
0
python,string
13,345,099
8
false
0
0
I have used the code of Oliver Crow (link given by Andrew Hare) and adapted it a bit to tailor Python 2.7.3. (by using timeit package). I ran on my personal computer, Lenovo T61, 6GB RAM, Debian GNU/Linux 6.0.6 (squeeze). Here is the result for 10,000 iterations: method1: 0.0538418292999 secs process size 4800 kb method2: 0.22602891922 secs process size 4960 kb method3: 0.0605459213257 secs process size 4980 kb method4: 0.0544030666351 secs process size 5536 kb method5: 0.0551080703735 secs process size 5272 kb method6: 0.0542731285095 secs process size 5512 kb and for 5,000,000 iterations (method 2 was ignored because it ran tooo slowly, like forever): method1: 5.88603997231 secs process size 37976 kb method3: 8.40748500824 secs process size 38024 kb method4: 7.96380496025 secs process size 321968 kb method5: 8.03666186333 secs process size 71720 kb method6: 6.68192911148 secs process size 38240 kb It is quite obvious that Python guys have done pretty great job to optimize string concatenation, and as Hoare said: "premature optimization is the root of all evil" :-)
3
161
0
Is there some string class in Python like StringBuilder in C#?
Python string class like StringBuilder in C#?
1
0
0
173,157
2,414,667
2010-03-10T05:08:00.000
0
0
1
0
python,string
48,364,553
8
false
0
0
There is no explicit analogue - i think you are expected to use string concatenations(likely optimized as said before) or third-party class(i doubt that they are a lot more efficient - lists in python are dynamic-typed so no fast-working char[] for buffer as i assume). Stringbuilder-like classes are not premature optimization because of innate feature of strings in many languages(immutability) - that allows many optimizations(for example, referencing same buffer for slices/substrings). Stringbuilder/stringbuffer/stringstream-like classes work a lot faster than concatenating strings(producing many small temporary objects that still need allocations and garbage collection) and even string formatting printf-like tools, not needing of interpreting formatting pattern overhead that is pretty consuming for a lot of format calls.
3
161
0
Is there some string class in Python like StringBuilder in C#?
Python string class like StringBuilder in C#?
0
0
0
173,157
2,414,667
2010-03-10T05:08:00.000
22
0
1
0
python,string
2,414,916
8
false
0
0
Python has several things that fulfill similar purposes: One common way to build large strings from pieces is to grow a list of strings and join it when you are done. This is a frequently-used Python idiom. To build strings incorporating data with formatting, you would do the formatting separately. For insertion and deletion at a character level, you would keep a list of length-one strings. (To make this from a string, you'd call list(your_string). You could also use a UserString.MutableString for this. (c)StringIO.StringIO is useful for things that would otherwise take a file, but less so for general string building.
3
161
0
Is there some string class in Python like StringBuilder in C#?
Python string class like StringBuilder in C#?
1
0
0
173,157
2,414,915
2010-03-10T06:21:00.000
9
0
1
0
python,multithreading,r,concurrency,hadoop
2,415,028
2
true
0
0
While languages and associated technologies/frameworks are important for scaling, they tend to pale in comparison to the importance of the algorithms, data structure, and architectures. Forget threads: the number of cores you can exploit that way is just too limited -- you want separate processes exchanging messages, so you can scale up at least to a small cluster of servers on a fast LAN (and ideally a large cluster as well!-). Relational databases may be an exception to "technologies pale" -- they can really clamp you down when you're trying to scale up a few orders of magnitude. Is that your situation -- are you worried about mere dozens or at most hundreds of servers, or are you starting to think about thousands or myriads? In the former case, you can still stretch relational technology (e.g. by horizontal and vertical sharding) to support you -- in the latter, you're at the breaking point, or well past it, and must start thinking in terms of key/value stores. Back to algorithms -- "data analysis" cover a wide range... most of my work for Google over the last few years falls in that range, e.g. in cluster management software, and currently in business intelligence. Do you need deterministic analysis (e.g. for accounting purposes, where you can't possibly overlook a single penny out of 8-digit figures), or can you stand some non-determinism? Most "data mining" applications fall into the second category -- you don't need total precision and determinism, just a good estimate of the range that your results can be proven to fall within, with, say, 95% probability. This is particularly crucial if you ever need to do "real-near-time" data analysis -- near-real-time and 100% accuracy constraints on the same computation do not a happy camper make. But even in bulk/batch off-line data mining, if you can deliver results that are 95% guaranteed orders of magnitude faster than it would take for 99.99% (I don't know if data mining can ever be 100.00%!-), that may be a wonderful tradeoff. The work I've been doing over the last few years has had a few requirements for "near-real-time" and many more requirements for off-line, "batch" analysis -- and only a very few cases where absolute accuracy is an absolute must. Gradually-refined sampling (when full guaranteed accuracy is not required), especially coupled with stratified sampling (designed closely with a domain expert!!!), has proven, over and over, to be a great approach; if you don't understand this terminology, and still want to scale up, beyond the terabytes, to exabytes and petabytes' worth of processing, you desperately need a good refresher course in Stats 201, or whatever course covers these concepts in your part of the woods (or on iTunes University, or the YouTube offerings in university channels, or blip.tv's, or whatever). Python, R, C++, whatever, only come into play after you've mastered these algorithmic issues, the architectural issues that go with them (can you design a computation architecture to "statistically survive" the death of a couple of servers out of your myriad, recovering to within statistically significant accuracy without a lot of rework...?), and the supporting design and storage-technology choices.
2
5
0
I'd like to begin thinking about how I can scale up my algorithms that I write for data analysis so that they can be applied to arbitrarily large sets of data. I wonder what are the relevant concepts (threads, concurrency, immutable data structures, recursion) and tools (Hadoop/MapReduce, Terracota, and Eucalyptus) to make this happen, and how specifically these concepts and tools are related to each other. I have a rudimentary background in R, Python, and bash scripting and also C and Fortran programming, though I'm familiar with some basic functional programming concepts also. Do I need to change the way that I program, use a different language (Clojure, Haskell, etc.), or simply (or not so simply!) adapt something like R/Hadoop (HRIPE)... or write wrappers for Python to enable multi-threading or Hadoop access? I understand this would might involve requirements for additional hardware and I would like some basic idea of what the requirements/options available might be. My apologies for this rather large and yet vague question, but just trying to get started - thanks in advance!
Concepts and tools required to scale up algorithms
1.2
0
0
453
2,414,915
2010-03-10T06:21:00.000
3
0
1
0
python,multithreading,r,concurrency,hadoop
2,414,986
2
false
0
0
The main thing for scaling up to large data is to avoid situations where you're reading huge datasets into memory at once. In pythonic terms this generally means using iterators to consume the dataset in manageable pieces.
2
5
0
I'd like to begin thinking about how I can scale up my algorithms that I write for data analysis so that they can be applied to arbitrarily large sets of data. I wonder what are the relevant concepts (threads, concurrency, immutable data structures, recursion) and tools (Hadoop/MapReduce, Terracota, and Eucalyptus) to make this happen, and how specifically these concepts and tools are related to each other. I have a rudimentary background in R, Python, and bash scripting and also C and Fortran programming, though I'm familiar with some basic functional programming concepts also. Do I need to change the way that I program, use a different language (Clojure, Haskell, etc.), or simply (or not so simply!) adapt something like R/Hadoop (HRIPE)... or write wrappers for Python to enable multi-threading or Hadoop access? I understand this would might involve requirements for additional hardware and I would like some basic idea of what the requirements/options available might be. My apologies for this rather large and yet vague question, but just trying to get started - thanks in advance!
Concepts and tools required to scale up algorithms
0.291313
0
0
453
2,414,917
2010-03-10T06:21:00.000
1
1
0
1
python,linux,shell
2,414,931
4
false
0
0
Folder size is still the total size of the folder contents. You may try to call du -s foldername from python
2
2
0
What will be the fastest way to check whether a folder size is beyond a specific size say 10 MB, 1 Gb , 10 GB etc, without actually calculating the folder size. Something like quota. A Pythonic solution will be great, but standard UNIX utilities also welcome
What is the fastest way to check whether a folder size is greater than a specific size?
0.049958
0
0
1,806
2,414,917
2010-03-10T06:21:00.000
2
1
0
1
python,linux,shell
2,414,949
4
false
0
0
I'd have to say it's impossible. I don't believe any filesystems cache folder sizes. Whatever you do is going to have to walk the tree in some fashion or another. Using du is probably the fastest method since it's all going to be happening in C. If you know the maximum filesize expected or supported you could perhaps optimise a little by counting the enties in each folder rather than the sizes and short-cutting in the case where there aren't enough files to meet the limit.
2
2
0
What will be the fastest way to check whether a folder size is beyond a specific size say 10 MB, 1 Gb , 10 GB etc, without actually calculating the folder size. Something like quota. A Pythonic solution will be great, but standard UNIX utilities also welcome
What is the fastest way to check whether a folder size is greater than a specific size?
0.099668
0
0
1,806
2,415,014
2010-03-10T06:45:00.000
2
0
0
0
python,autocomplete,pythonpath
2,415,055
1
true
1
0
Have you tried adding Additional import directories in Edit/Preferences/ under Languages/Python in Komodo? Edit: I think you can also add a .pth file in [komodo-install-dir]/lib/mozilla/python/ or C:\[PythonVersion]\Lib\site-packages\ containing all other path you might want to be available. Not sure wich way is more appropriate in your case.
1
1
0
I have 2 hard-drives, C:\ and D:\ Django imports correctly (which is in my C drive), but my application is on my D drive. I can't move it to the C drive because of some back-up software I'm running/ I'm trying to get auto-complete to work in Komodo Edit 5 which works fine for Django, but not for my application. There are a few other reasons for wanting this as well (one of them being my rampant OCD). I have added D:\dev\projects to my PYTHONPATH and my application is a couple folders deep from there. I included a ; between variables but not at the end, and I left off the trailing slash. I'm on Win XP. Here's my exact PYTHONPATH in my settings: C:\Python26\Lib\site-packages\django-trunk;D:\dev\projects and here is my Python path as a list output by os.environ['PYTHONPATH'].split(os.pathsep) ['C:\\Python26\\Lib\\site-packages\\django-trunk', 'D:\\dev\\projects'] Why doesn't this work? Django runs OK for my app that is there, but I understand that Django sets an environment variable dynamically in manage.py. I don't get it. I've restarted my computer, and now I'm pulling out my hair.
Add directory to PYTHONPATH ( multiple drives ), for auto-complete
1.2
0
0
1,976
2,416,677
2010-03-10T12:08:00.000
0
0
0
0
python,django,django-templates
2,416,776
3
false
1
0
Django doesn't strip out javascript, because it is client side agnostic. How are you inserting javascript into your website? If you are trying to put it into database (like ) it will escaped.
2
0
0
Very newbie question, but please be gentle with me. Our site uses Django CMS and we're trying to insert some javascript into particular stories, but it appears Django is stripping out any javascript or iframes we put in there as soon as we save the story. How do we allow javascript to be used in stories? Is it being deliberately excluded, or do we need to code this function into the site? Any help would be incredibly appreciated.
stop django from taking out javascript/frames?
0
0
0
200
2,416,677
2010-03-10T12:08:00.000
2
0
0
0
python,django,django-templates
2,416,764
3
false
1
0
Django is probably automatically escaping the content the javascript / html as the template renders the content. It does this for security purposes. The solution depends on which version of django you're running, whether you'll be rendering any content from untrusted sources, how the templates are put together and perhaps the view that prepares the content for the template.
2
0
0
Very newbie question, but please be gentle with me. Our site uses Django CMS and we're trying to insert some javascript into particular stories, but it appears Django is stripping out any javascript or iframes we put in there as soon as we save the story. How do we allow javascript to be used in stories? Is it being deliberately excluded, or do we need to code this function into the site? Any help would be incredibly appreciated.
stop django from taking out javascript/frames?
0.132549
0
0
200
2,416,819
2010-03-10T12:31:00.000
2
0
0
0
python,mysql,database,multithreading,insert
2,417,080
1
true
1
0
This is not caused by multithreading, but because there are more than one object in database, that satisfies your query. You must select exactly one object from the database using get, otherwise it will raise an exception.
1
1
0
Django's get_or_create function always cause "get() returned more than one Model name" error in a multi-threaded program. I even tried to put get_or_create statement inside a lock.acquire() and lock.release() block but still didn't work. The program only works when I set thread_count=1 The database is on InnoDB engine. How to fix this kind of problem?
Django and "get() returned more than one Model name" error in multi-threaded program
1.2
0
0
4,232
2,417,705
2010-03-10T14:39:00.000
1
0
0
0
python,gtk,pygtk,mplayer
2,944,206
2
false
0
1
You need to tell mplayer to zoom video according to window size. This can be done either in command line (-zoom) or in the configuration file (zoom = 1).
1
0
0
I've wrote a piece of code in python and pygtk for an embeded mplayer in a gui. I assume I use GtkSocket and the slave mode of mplayer with the -wid option. But I've got an issue, when the size of my GTK window is smaller than my stream, the stream appears to be cropped. And when the size of my window is bigger than my stream, the stream appear centred inside the widget which embed MPlayer. (a gtk.Frame but I've also try with a gtk.DrawingArea) I would like to know how I can get my stream resize dynamically depending on the window's size. I don't want to use Glade or any GUI builder. Thanks in advance for any help, and please excuse my poor english.
Dynamic resize with MPlayer and PyGTK
0.099668
0
0
1,512
2,419,662
2010-03-10T18:54:00.000
1
0
1
0
ironpython,visual-studio-2010
2,804,148
4
false
0
0
Asking MS at PyCon 2009, they were investigating IPy for VS 'next plus 1' - which hasn't been released yet. For VS2010, you can use IronPython Tools for Visual Studio 2010 - www.ironpython.net.
4
11
0
IronPython has been out for a while now, so when I installed Visual Studio 2010 RC1 "Ultimate" this morning I was surprised to find that it couldn't be selected from the installer. Instead, one still has to go out to Codeplex. Does anybody know why it hasn't been included?
Why can't IronPython be installed with Visual Studio 2010?
0.049958
0
0
2,563
2,419,662
2010-03-10T18:54:00.000
3
0
1
0
ironpython,visual-studio-2010
2,423,719
4
true
0
0
This is what I have picked up from the IP mailing list... Ironpython is on a different release cycle to Visual Studio and developed by a separate team. The MS G.O. team development process is far more responsive and agile than a 2 year release cycle. Given the changing nature of CPython (+other implementations) with frequent releases and the continuing need to improve compatibility with third party libraries (large code base), it makes sense to keep it apart. Visual Studio support is currently in a restricted developer preview. As it is an add-in, this too will be free of a 2 year cycle and hopefully be more frequently improved.
4
11
0
IronPython has been out for a while now, so when I installed Visual Studio 2010 RC1 "Ultimate" this morning I was surprised to find that it couldn't be selected from the installer. Instead, one still has to go out to Codeplex. Does anybody know why it hasn't been included?
Why can't IronPython be installed with Visual Studio 2010?
1.2
0
0
2,563
2,419,662
2010-03-10T18:54:00.000
3
0
1
0
ironpython,visual-studio-2010
2,419,685
4
false
0
0
They accept user submitted code, because of this there are patent issues and infringing code possibilities, John Lam talked about this in a podcast with dotnetrocks. What would happen if this code violated something? Microsoft would have to take Visual Studio off the shelves until they fixed it
4
11
0
IronPython has been out for a while now, so when I installed Visual Studio 2010 RC1 "Ultimate" this morning I was surprised to find that it couldn't be selected from the installer. Instead, one still has to go out to Codeplex. Does anybody know why it hasn't been included?
Why can't IronPython be installed with Visual Studio 2010?
0.148885
0
0
2,563
2,419,662
2010-03-10T18:54:00.000
-1
0
1
0
ironpython,visual-studio-2010
2,419,681
4
false
0
0
May be because it is not an "official" language?
4
11
0
IronPython has been out for a while now, so when I installed Visual Studio 2010 RC1 "Ultimate" this morning I was surprised to find that it couldn't be selected from the installer. Instead, one still has to go out to Codeplex. Does anybody know why it hasn't been included?
Why can't IronPython be installed with Visual Studio 2010?
-0.049958
0
0
2,563
2,419,770
2010-03-10T19:11:00.000
76
0
1
0
python,generator
2,421,288
6
false
0
0
In Python <= 2.5, use gen.next(). This will work for all Python 2.x versions, but not Python 3.x In Python >= 2.6, use next(gen). This is a built in function, and is clearer. It will also work in Python 3. Both of these end up calling a specially named function, next(), which can be overridden by subclassing. In Python 3, however, this function has been renamed to __next__(), to be consistent with other special functions.
4
143
0
Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?
How to get one value at a time from a generator function in Python?
1
0
0
99,132
2,419,770
2010-03-10T19:11:00.000
5
0
1
0
python,generator
60,391,726
6
false
0
0
To get the value associated with a generator object in python 3 and above use next(<your generator object>). subsequent calls to next() produces successive object values in the queue.
4
143
0
Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?
How to get one value at a time from a generator function in Python?
0.16514
0
0
99,132
2,419,770
2010-03-10T19:11:00.000
189
0
1
0
python,generator
2,419,782
6
true
0
0
Yes, or next(gen) in 2.6+.
4
143
0
Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?
How to get one value at a time from a generator function in Python?
1.2
0
0
99,132
2,419,770
2010-03-10T19:11:00.000
1
0
1
0
python,generator
37,890,506
6
false
0
0
In python 3 you don't have gen.next(), but you still can use next(gen). A bit bizarre if you ask me but that's how it is.
4
143
0
Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?
How to get one value at a time from a generator function in Python?
0.033321
0
0
99,132
2,420,219
2010-03-10T20:11:00.000
5
0
1
0
python,memory,data-structures,matrix,swap
2,420,257
4
false
0
0
You need a database, if the data will exceed memory. The indexing of dictionaries isn't designed for good performance when a dictionary is bigger than memory.
2
4
0
I have a python program that is going to eat a lot of memory, primarily in a dict. This dict will be responsible for assigning a unique integer value to a very large set of keys. As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations are complete, I need to map the values back to the original keys). I believe this amount will eventually surpass available memory. I am wondering how this will be handled with regards to swap space. Perhaps there is a better data structure for this purpose.
How does OS handle a python dict that's larger than memory?
0.244919
0
0
1,227
2,420,219
2010-03-10T20:11:00.000
1
0
1
0
python,memory,data-structures,matrix,swap
2,420,260
4
true
0
0
It will just end up in swap trashing, because a hash table has very much randomized memory access patterns. If you know that the map exceeds the size of the physical memory, you could consider using a data structure on the disk in the first place. This especially if you don't need the data structure during the computation. When the hash table triggers swapping, it creates problems also outside the hash table itself.
2
4
0
I have a python program that is going to eat a lot of memory, primarily in a dict. This dict will be responsible for assigning a unique integer value to a very large set of keys. As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations are complete, I need to map the values back to the original keys). I believe this amount will eventually surpass available memory. I am wondering how this will be handled with regards to swap space. Perhaps there is a better data structure for this purpose.
How does OS handle a python dict that's larger than memory?
1.2
0
0
1,227
2,420,671
2010-03-10T21:19:00.000
8
0
1
0
python,serial-port,escaping
3,219,355
2
true
0
0
There is no such thing as an "escape sequence" for the ESC key on a VT-100 (or other terminals that used escape sequences). The escape character, ASCII 27, was used to indicate that the following sequences of characters had special meaning. This usually put the terminal into a simple state machine. In general the rule was to swallow the incoming characters until an alphabetic or symbolic character was seen, inclusively, although some special cases such as symbols which might grab one additional character, e.g. ESC # 6 to double-width characters. For instance on a H-19 / VT-52 terminal, ESC H meant home, ESC E meant clear screen and home, ESC J meant clear to end of screen, etc. The VT-100 series used ESC [ H for home, and ESC [ 2 J for clear to end of screen. What was really going on was that the open square bracket (there was no close bracket) said that a list of arguments, usually numeric, was coming. The '2' in the ESC [ 2 J meant both from the cursor to the top (zero), and from the cursor to the end (one). Switch the J to a K, and now it would clear the line, rather than the screen, the same way. They weren't arbitrary. Even ESC [ row ; col H would take a numerical row/col, e.g. ESC [ 12; 34 H would go to row 12, column 34. Not providing them took default values. In theory the server should never throw you a meaningless orphaned ESC character as the terminal would sit there and wait for a sequence. When you pressed a function key, the terminal would send an ESC character followed by some pre-canned sequence for a function key, arrow, or action. For instance ESC [ 21 ~ was F10. This then left the very real problem of how to send a literal orphaned ESC. There were two ways. One, send the ESC and then delay for some amount. The host would have the responsibility of watching not just what came in, but when. And, working under the assumption that a terminal would send a block of characters in its buffer immediately, it would internally time out and take ESC to mean just ESC. The delay did not have to be long. Two, require the user to press ESC twice for every literal ESC desired. As no escape sequence ever consisted of a double escape character, it signaled a special condition. It exactly the same thing we do when quoting backslash characters in strings, a "\" really means a "\" because we have to satisfy the compiler's lexical phase. In this case, it's the host server. Remember, in the days of serial ports, which was when these terminals were in use, when a character was pressed, it was sent immediately. Only years later did we start emulating terminals and thus rose the need to emulate their escape sequences rather than taking the behaviors out of the content stream. Of course, an 'invalid' ESC sequence meant the ESC was literal, but this required seeing what the following bytes were before you could act on them (hence the timeout solution). The problem is sometimes those characters caused side effects to an application, nasty ones, and interesting cases could arrive where trying to naively fake out the system could get you into trouble. e.g., use ESC Space to force the escape through, the ESC cancels one prompt, but the space unintendedly acknowledges the next. The third solution to the problem was to simply have the host ignore special function keys altogether and take the incoming byte stream as literal. For instance, the TECO editor would display a dollar sign to the user each time the ESC was pressed, as it used this for a command separator the same way one might use a semicolon in coding today.
2
5
0
I'm writing a script to navigate a text-based menu system, using python's telnetlib to access a serial connection. I can happily press the F-keys, using the escape codes. e.g. F9 = "\033OX", where "\033" is the escape sequence. How do I encode the "esc" keyboard key? I would have expected just "\033", but that doesn't seem to work.
What's the VT100 escape code for the "esc" keyboard key itself
1.2
0
0
4,218
2,420,671
2010-03-10T21:19:00.000
6
0
1
0
python,serial-port,escaping
2,420,715
2
false
0
0
Put a small delay, say 1.5s, after sending the escape so that the other side realizes that it's an isolated escape and not part of a longer sequence.
2
5
0
I'm writing a script to navigate a text-based menu system, using python's telnetlib to access a serial connection. I can happily press the F-keys, using the escape codes. e.g. F9 = "\033OX", where "\033" is the escape sequence. How do I encode the "esc" keyboard key? I would have expected just "\033", but that doesn't seem to work.
What's the VT100 escape code for the "esc" keyboard key itself
1
0
0
4,218
2,421,007
2010-03-10T22:10:00.000
4
1
0
0
python,rest,web-services,apache2
2,421,023
6
false
0
0
If you just want to run web apps then use mod_wsgi. If you need to write a handler for the rest of httpd's request/response phases then use mod_python.
5
5
0
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS, can be supported out of the box. 4. No strong dependency on version.( I see that wsgi requires python 2.6) 5. All python libraries will work out of the box. 6. Scalable in the future. 7. Future upgrade don't cause any issues. With my limited experience, I want these features. There might be some I might be missing. Thanks Bala Update I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?
Apache2: mod_wsgi or mod_python, which one is better?
0.132549
0
0
5,895
2,421,007
2010-03-10T22:10:00.000
0
1
0
0
python,rest,web-services,apache2
2,422,260
6
false
0
0
Bug will be fixed periodically. Unless you're paying money, you cannot have any idea about this. Chosen by most developers. mod_wsgi Additional features like authentication tokens like AWS, can be supported out of the box. True for every framework. No strong dependency on version.( I see that wsgi requires python 2.6) What? Everything depends on compatible versions. Everything. Every single piece of software. All python libraries will work out of the box. "All?" What about the poorly-written ones? Scalable in the future. Sure. We always hope for this. There's no guarantee. Future upgrade don't cause any issues. That's funny. "I want these features." We all do. Realistically, you can get #2. The rest don't make sense or cannot every be assured.
5
5
0
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS, can be supported out of the box. 4. No strong dependency on version.( I see that wsgi requires python 2.6) 5. All python libraries will work out of the box. 6. Scalable in the future. 7. Future upgrade don't cause any issues. With my limited experience, I want these features. There might be some I might be missing. Thanks Bala Update I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?
Apache2: mod_wsgi or mod_python, which one is better?
0
0
0
5,895
2,421,007
2010-03-10T22:10:00.000
1
1
0
0
python,rest,web-services,apache2
2,422,564
6
false
0
0
mod_wsgi is much more actively maintained than mod_python at this point. It also has a good bit of momentum, as it was somewhat recently adopted as the preferred deployment method on apache2 by Django. The author is also actively engaged with the Python community in regards to the future evolution of WSGI.
5
5
0
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS, can be supported out of the box. 4. No strong dependency on version.( I see that wsgi requires python 2.6) 5. All python libraries will work out of the box. 6. Scalable in the future. 7. Future upgrade don't cause any issues. With my limited experience, I want these features. There might be some I might be missing. Thanks Bala Update I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?
Apache2: mod_wsgi or mod_python, which one is better?
0.033321
0
0
5,895
2,421,007
2010-03-10T22:10:00.000
5
1
0
0
python,rest,web-services,apache2
2,421,104
6
false
0
0
Don't confuse what WSGI and mod_wsgi are. WSGI is an interface specification for hosting Python web applications on a server. The mod_wsgi module is an implementation of the WSGI specification using Apache as the underlying web server. Thus, Python and WSGI are not choices exactly, WSGI is just one way of being able to communicate between a Python web service/application and the web server. The mod_wsgi package is one implementation of that interface. So, WSGI is a means to an end, not a solution in itself. Personally, I'd very much suggest you just use a minimal Python framework/non framework and as Alex suggests, Werkzeug is a good choice.
5
5
0
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS, can be supported out of the box. 4. No strong dependency on version.( I see that wsgi requires python 2.6) 5. All python libraries will work out of the box. 6. Scalable in the future. 7. Future upgrade don't cause any issues. With my limited experience, I want these features. There might be some I might be missing. Thanks Bala Update I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?
Apache2: mod_wsgi or mod_python, which one is better?
0.16514
0
0
5,895
2,421,007
2010-03-10T22:10:00.000
3
1
0
0
python,rest,web-services,apache2
2,421,190
6
false
0
0
mod_wsgi is specifically tuned to run Python web apps that use WSGI in Apache. mod_python is for any kind of Python web app, including WSGI apps. mod_wsgi also has a lower memory footprint than mod_python.
5
5
0
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS, can be supported out of the box. 4. No strong dependency on version.( I see that wsgi requires python 2.6) 5. All python libraries will work out of the box. 6. Scalable in the future. 7. Future upgrade don't cause any issues. With my limited experience, I want these features. There might be some I might be missing. Thanks Bala Update I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?
Apache2: mod_wsgi or mod_python, which one is better?
0.099668
0
0
5,895
2,421,586
2010-03-10T23:54:00.000
179
1
0
1
python,bash,language-comparisons
2,421,592
2
true
0
0
You can use : for this.
2
125
0
Is there a Bash equivalent to the Python's pass statement?
What is the Bash equivalent of Python's pass statement
1.2
0
0
36,506
2,421,586
2010-03-10T23:54:00.000
45
1
0
1
python,bash,language-comparisons
2,421,637
2
false
0
0
true is a command that successfully does nothing. (false would, in a way, be the opposite: it doesn't do anything, but claims that a failure occurred.)
2
125
0
Is there a Bash equivalent to the Python's pass statement?
What is the Bash equivalent of Python's pass statement
1
0
0
36,506
2,425,656
2010-03-11T14:24:00.000
-2
0
1
0
python,overriding,final
2,428,648
4
false
0
0
Yes there is, don't do it. I should add to this after the down-vote. Such protection mechanisms are seen by some to go against the ethos of Python, that "we are all consenting adults here".Who do you want to protect such functions from? And if a comment will not suffice why would something 'stronger'? I would document your expectations and expect other programmers to act responsibly.
2
41
0
Is there a way to make a class function unoverriddable? something like java's final keyword. i.e, any overriding class cannot override that method.
How to prevent a function from being overridden in python
-0.099668
0
0
18,512
2,425,656
2010-03-11T14:24:00.000
1
0
1
0
python,overriding,final
51,879,567
4
false
0
0
Using a double underscore before a method in a class is not just a naming convention. By doing so the method name is mangled with classname(_classname__methodname()). By inheriting a class with a method having double underscores in front of it;for the child class it becomes difficult to override the above specified method. This practice is almost equivalent to final in java.
2
41
0
Is there a way to make a class function unoverriddable? something like java's final keyword. i.e, any overriding class cannot override that method.
How to prevent a function from being overridden in python
0.049958
0
0
18,512
2,428,077
2010-03-11T19:38:00.000
0
0
0
0
php,python,ruby-on-rails,programming-languages,saas
2,430,572
3
false
1
0
If you wan't to run a version of the server on desktops, your best options would be Python, Rails, or Java servlets, all of which can be easily packaged into small self contained servers with no dependencies. My recommendation for the desktop would be HTML 5 local storage. The standard hasn't been finalized, but there is experimental support in Google Chrome. If you can force your users to use a specific browser version, you should be OK, until it is finalized. I would recommend looking at Django and Rails before any other framework. They have different design philosophies, so one of them might be better suited for your application. Another framework to consider is Grails, which is essentially a clone of Rails in the groovy language.
3
1
0
I have an idea for a product that I want to be web-based. But because I live in a part of the world where the internet is not always available, there needs to be a client desktop component that is available for when the internet is down. Also, I have been a SQL programmer, a desktop application programmer using dBase, VB and Pascal, and I have created simple websites using HTML and website creation tools, such as Frontpage. So from my research, I think I have the following options; PHP, Ruby on Rails, Python or .NET for the programming side. MySQL for the DB. And Apache, or possibly IIS, for the webserver. I will probably start with a local ISP provider for the cloud servce. But then maybe move to something more "robust" and universal in the future, ie. Amazon, or Azure, or something along that line. My question then is this. What would you recommend for something like this? I'm sure that I have not listed all of the possibilities, but the ones I have researched and thought of. Thanks everyone, Craig
Old desktop programmer wants to create S+S project
0
1
0
174
2,428,077
2010-03-11T19:38:00.000
0
0
0
0
php,python,ruby-on-rails,programming-languages,saas
2,429,484
3
false
1
0
The languages you list are all serverside components. The big question is whether you can sensibly build a thick client - effectively you could develop a multi-tier application where the webserver sits on the client and uses a webservice as a datafeed if/when its available but the solution is not very portable. You could build a purely ajax driven website in javascript then deploy it to the client as signed javascripts on the local filesystem (they need to be signed to get around the restriction that javscripts can only connect back to the server where they served from normally). Another approach would be to use Google Gears - but that would be a single browser solution. C.
3
1
0
I have an idea for a product that I want to be web-based. But because I live in a part of the world where the internet is not always available, there needs to be a client desktop component that is available for when the internet is down. Also, I have been a SQL programmer, a desktop application programmer using dBase, VB and Pascal, and I have created simple websites using HTML and website creation tools, such as Frontpage. So from my research, I think I have the following options; PHP, Ruby on Rails, Python or .NET for the programming side. MySQL for the DB. And Apache, or possibly IIS, for the webserver. I will probably start with a local ISP provider for the cloud servce. But then maybe move to something more "robust" and universal in the future, ie. Amazon, or Azure, or something along that line. My question then is this. What would you recommend for something like this? I'm sure that I have not listed all of the possibilities, but the ones I have researched and thought of. Thanks everyone, Craig
Old desktop programmer wants to create S+S project
0
1
0
174
2,428,077
2010-03-11T19:38:00.000
0
0
0
0
php,python,ruby-on-rails,programming-languages,saas
2,428,452
3
false
1
0
If you want a 'desktop component' that is available for you to do development on whenever your internet is out, you could really choose any of those technologies. You can always have a local server (like apache) running on your machine, as well as a local sql database, though if your database contains a large amount of data you may need to scale it down. Ruby on Rails may be the easiest for you to get started with, though, since it comes packaged with WEBrick (a ruby library that provides HTTP services), and SQLite, a lightweight SQL database management system. Ruby on Rails is configured by default to use these.
3
1
0
I have an idea for a product that I want to be web-based. But because I live in a part of the world where the internet is not always available, there needs to be a client desktop component that is available for when the internet is down. Also, I have been a SQL programmer, a desktop application programmer using dBase, VB and Pascal, and I have created simple websites using HTML and website creation tools, such as Frontpage. So from my research, I think I have the following options; PHP, Ruby on Rails, Python or .NET for the programming side. MySQL for the DB. And Apache, or possibly IIS, for the webserver. I will probably start with a local ISP provider for the cloud servce. But then maybe move to something more "robust" and universal in the future, ie. Amazon, or Azure, or something along that line. My question then is this. What would you recommend for something like this? I'm sure that I have not listed all of the possibilities, but the ones I have researched and thought of. Thanks everyone, Craig
Old desktop programmer wants to create S+S project
0
1
0
174
2,428,301
2010-03-11T20:11:00.000
7
0
1
0
python
2,428,363
6
false
0
0
Circular references are a normal thing to do, so I don't see a reason to be worried about them. Many tree algorithms require that each node have links to its children and its parent. They're also required to implement something like a doubly linked list.
2
43
0
Suppose I have code that maintains a parent/children structure. In such a structure I get circular references, where a child points to a parent and a parent points to a child. Should I worry about them? I'm using Python 2.5. I am concerned that they will not be garbage collected and the application will eventually consume all memory.
Should I worry about circular references in Python?
1
0
0
26,532
2,428,301
2010-03-11T20:11:00.000
12
0
1
0
python
2,428,360
6
false
0
0
Python will detect the cycle and release the memory when there are no outside references.
2
43
0
Suppose I have code that maintains a parent/children structure. In such a structure I get circular references, where a child points to a parent and a parent points to a child. Should I worry about them? I'm using Python 2.5. I am concerned that they will not be garbage collected and the application will eventually consume all memory.
Should I worry about circular references in Python?
1
0
0
26,532
2,428,391
2010-03-11T20:20:00.000
0
0
1
0
python
2,428,430
4
false
0
0
If you're creating a class that should act sort of like an array or dictionary, these are very useful so that your syntax looks familiar. For example, if you wanted to create an ordered dictionary, you could use all of the functions you mentioned so that you could interchange that with a regular dictionary.
2
1
0
I know that classes can implement various special methods, such as __iter__, __setitem__, __len__, __setattr__, and many others. But when should I use them? Can anyone describe typical scenarios when I would want to implement them and they would simplify programming in Python? Thanks, Boda Cydo.
When to use Python special methods?
0
0
0
292
2,428,391
2010-03-11T20:20:00.000
0
0
1
0
python
12,573,111
4
false
0
0
getattr and setattr are useful when you want to implement an interface by delegating to an instance member instead of straight inheritance. You map them to the getattr and setattr of the member.
2
1
0
I know that classes can implement various special methods, such as __iter__, __setitem__, __len__, __setattr__, and many others. But when should I use them? Can anyone describe typical scenarios when I would want to implement them and they would simplify programming in Python? Thanks, Boda Cydo.
When to use Python special methods?
0
0
0
292
2,429,039
2010-03-11T22:07:00.000
1
0
1
0
python
2,429,057
5
false
0
0
There have been several proposals for a compose operation, but none have been formalized. In the meantime it is possible to use a list comprehension or a generator expression to apply complex transformations to a sequence.
1
2
0
Haskell provides the feature something like f = f1 . f2 How can I mimic that with Python? For example, if I have to do the 'map' operation two times, is there any way to do something like map . map in Python? x = ['1','2','3'] x = map(int,x) x = map(lambda i:i+1, x)
Mimic Haskell with Python
0.039979
0
0
203
2,429,073
2010-03-11T22:11:00.000
0
0
1
0
python
2,429,139
5
false
0
0
for i, v in enumerate(buff): if i != v - 1: print "MISSING OR DUPLICATE"
1
1
0
testGroupList is a list of integer. I need to check the numbers in testGroupList is sequential and not duplicate numbers. Ignore the negative integer. For example, [1,2,-1,2,3,4] is an error as 2 is duplicated, but [-1,3,2,4,1,5] is OK. I implemented it as follows, and it's pretty ugly. Is there any clever way to do this? buff = filter(lambda x: x > 0, testGroupList) maxval = max(buff) for i in range(maxval): id = i+1 val = buff.count(id) if val == 1: print id, elif val >= 2: print "(Test Group %d duplicated %d times)" % (id, val), elif val == 0: print "(Test Group %d missing)" % id,
Check if the integer in a list is not duplicated, and sequential
0
0
0
1,080
2,430,423
2010-03-12T04:02:00.000
4
0
0
0
python,xml
2,430,575
4
false
0
0
I find xml.etree essentially sufficient for everything, except for BeautifulSoup if I ever need to parse broken XML (not a common problem, differently from broken HTML, which BeautifulSoup also helps with and is everywhere): it has reasonable support for reading entire XML docs in memory, navigating them, creating them, incrementally-parsing large docs. lxml supports the same interface, and is generally faster -- useful to push performance when you can afford to install third party Python extensions (e.g. on App Engine you can't -- but xml.etree is still there, so you can run exactly the same code). lxml also has more features, and offers BeautifulSoup too. The other libs you mention mimic APIs designed for very different languages, and in general I see no reason to contort Python into those gyrations. If you have very specific needs such as support for xslt, various kinds of validations, etc, it may be worth looking around for other libraries yet, but I haven't had such needs in a long time so I'm not current wrt the offerings for them.
3
8
0
A search for "python" and "xml" returns a variety of libraries for combining the two. This list probably faulty: xml.dom xml.etree xml.sax xml.parsers.expat PyXML beautifulsoup? HTMLParser htmllib sgmllib Be nice if someone can offer a quick summary of when to use which, and why.
Which XML library for what purposes?
0.197375
0
1
803
2,430,423
2010-03-12T04:02:00.000
6
0
0
0
python,xml
2,430,541
4
true
0
0
The DOM/SAX divide is a basic one. It applies not just to python since DOM and SAX are cross-language. DOM: read the whole document into memory and manipulate it. Good for: complex relationships across tags in the markup small intricate XML documents Cautions: Easy to use excessive memory SAX: parse the document while you read it. Good for: Long documents or open ended streams places where memory is a constraint Cautions: You'll need to code a stateful parser, which can be tricky beautifulsoup: Great for HTML or not-quite-well-formed markup. Easy to use and fast. Good for screen scraping, etc. It can work with markup where the XML based ones would just through an error saying the markup is incorrect. Most of the rest I haven't used, but I don't think there's hard and fast rules about when to use which. Just your standard considerations: who is going to maintain the code, which APIs do you find most easy to use, how well do they work, etc. In general, for basic needs, it's nice to use the standard library modules since they are "standard" and thus available and well known. However, if you need to dig deep into something, almost always there are newer nonstandard modules with superior functionality outside of the standard library.
3
8
0
A search for "python" and "xml" returns a variety of libraries for combining the two. This list probably faulty: xml.dom xml.etree xml.sax xml.parsers.expat PyXML beautifulsoup? HTMLParser htmllib sgmllib Be nice if someone can offer a quick summary of when to use which, and why.
Which XML library for what purposes?
1.2
0
1
803
2,430,423
2010-03-12T04:02:00.000
1
0
0
0
python,xml
2,430,695
4
false
0
0
For many problems you can get by with the xml. It has the major advantage of being part of the standard library. This means that it is pre-installed on almost every system and that the interface will be static. It is not the best, or the fastest, but it is there. For everything else there is lxml. Specically, lxml is best for parsing broken HTML, xHTML, or suspect feeds. It uses libxml2 and libxslt to handle XPath, XSLT, and EXSLT. The tutorial is clear and the interface is simplistically straight-forward. The rest of the libraries mentioned exist because lxml was not available in its current form. This is my opinion.
3
8
0
A search for "python" and "xml" returns a variety of libraries for combining the two. This list probably faulty: xml.dom xml.etree xml.sax xml.parsers.expat PyXML beautifulsoup? HTMLParser htmllib sgmllib Be nice if someone can offer a quick summary of when to use which, and why.
Which XML library for what purposes?
0.049958
0
1
803