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
1,003,376
2009-06-16T19:03:00.000
2
0
0
0
python,video,pyglet
1,003,439
3
false
0
1
Qt (PyQt) has Phonon, which might help out. PyQt is available as GPL or payware. (Qt has LGPL too, but the PyQt wrappers don't)
1
4
0
I'm looking for a Python framework that will enable me to play video as well as draw on that video (for labeling purposes). I've tried Pyglet, but this doesn't seem to work particularly well - when drawing on an existing video, there is flicker (even with double buffering and all of that good stuff), and there doesn't seem to be a way to get the frame index in the video during the per-frame callback (only elapsed time since the last frame).
Python Video Framework
0.132549
0
0
2,361
1,005,187
2009-06-17T04:57:00.000
2
0
0
0
python,django,django-models
1,005,209
2
false
1
0
null=True is used to tell that in DB value can be NULL blank=True is only for django , so django doesn't raise error if field is blank e.g. in admin interface so blank=True has nothing to do with DB NULL requirement will vary from DB to DB, and it is upto you to decide if you want some column NULL or not
1
2
0
Some model fields such as DateTimeField require null=True option when blank=True option is set. I'd like to know which fields require that (maybe dependent on backend DBMS), and there is any way to do this automatically.
How to distinguish field that requires null=True when blank=True is set in Django models?
0.197375
0
0
381
1,005,972
2009-06-17T09:12:00.000
1
1
0
1
python,posix
1,006,030
6
false
0
0
Look at /proc/pid. This exists only of the process is running, and contains lots of information.
1
7
0
In a POSIX system, I want to see if a given process (PID 4356, for example) is running. It would be even better if I could get metadata about that process.
What is the easiest way to see if a process with a given pid exists in Python?
0.033321
0
0
2,206
1,006,169
2009-06-17T10:17:00.000
3
0
1
0
python,introspection
1,006,357
25
false
0
0
pprint and dir together work great
7
339
0
I'm starting to code in various projects using Python (including Django web development and Panda3D game development). To help me understand what's going on, I would like to basically 'look' inside the Python objects to see how they tick - like their methods and properties. So say I have a Python object, what would I need to print out its contents? Is that even possible?
How do I look inside a Python object?
0.023995
0
0
408,654
1,006,169
2009-06-17T10:17:00.000
0
0
1
0
python,introspection
1,006,349
25
false
0
0
In addition if you want to look inside list and dictionaries, you can use pprint()
7
339
0
I'm starting to code in various projects using Python (including Django web development and Panda3D game development). To help me understand what's going on, I would like to basically 'look' inside the Python objects to see how they tick - like their methods and properties. So say I have a Python object, what would I need to print out its contents? Is that even possible?
How do I look inside a Python object?
0
0
0
408,654
1,006,169
2009-06-17T10:17:00.000
4
0
1
0
python,introspection
1,006,576
25
false
0
0
If you want to look at parameters and methods, as others have pointed out you may well use pprint or dir() If you want to see the actual value of the contents, you can do object.__dict__
7
339
0
I'm starting to code in various projects using Python (including Django web development and Panda3D game development). To help me understand what's going on, I would like to basically 'look' inside the Python objects to see how they tick - like their methods and properties. So say I have a Python object, what would I need to print out its contents? Is that even possible?
How do I look inside a Python object?
0.031989
0
0
408,654
1,006,169
2009-06-17T10:17:00.000
1
0
1
0
python,introspection
47,730,505
25
false
0
0
vars(obj) returns the attributes of an object.
7
339
0
I'm starting to code in various projects using Python (including Django web development and Panda3D game development). To help me understand what's going on, I would like to basically 'look' inside the Python objects to see how they tick - like their methods and properties. So say I have a Python object, what would I need to print out its contents? Is that even possible?
How do I look inside a Python object?
0.008
0
0
408,654
1,006,169
2009-06-17T10:17:00.000
208
0
1
0
python,introspection
1,007,121
25
false
0
0
object.__dict__
7
339
0
I'm starting to code in various projects using Python (including Django web development and Panda3D game development). To help me understand what's going on, I would like to basically 'look' inside the Python objects to see how they tick - like their methods and properties. So say I have a Python object, what would I need to print out its contents? Is that even possible?
How do I look inside a Python object?
1
0
0
408,654
1,006,169
2009-06-17T10:17:00.000
67
0
1
0
python,introspection
1,006,176
25
false
0
0
First, read the source. Second, use the dir() function.
7
339
0
I'm starting to code in various projects using Python (including Django web development and Panda3D game development). To help me understand what's going on, I would like to basically 'look' inside the Python objects to see how they tick - like their methods and properties. So say I have a Python object, what would I need to print out its contents? Is that even possible?
How do I look inside a Python object?
1
0
0
408,654
1,006,169
2009-06-17T10:17:00.000
3
0
1
0
python,introspection
50,380,073
25
false
0
0
If you are interested to see the source code of the function corresponding to the object myobj, you can type in iPython or Jupyter Notebook: myobj??
7
339
0
I'm starting to code in various projects using Python (including Django web development and Panda3D game development). To help me understand what's going on, I would like to basically 'look' inside the Python objects to see how they tick - like their methods and properties. So say I have a Python object, what would I need to print out its contents? Is that even possible?
How do I look inside a Python object?
0.023995
0
0
408,654
1,006,189
2009-06-17T10:20:00.000
3
1
1
0
python,testing
1,006,454
5
false
0
0
"every single part of our project has a meaningful test in place" "Part" is undefined. "Meaningful" is undefined. That's okay, however, since it gets better further on. "validates the correctness of every component in our system" "Component" is undefined. But correctness is defined, and we can assign a number of alternatives to component. You only mention Python, so I'll assume the entire project is pure Python. Validates the correctness of every module. Validates the correctness of every class of every module. Validates the correctness of every method of every class of every module. You haven't asked about line of code coverage or logic path coverage, which is a good thing. That way lies madness. "guarantees that when we change something we can spot unintentional changes to other sub-systems" This is regression testing. That's a logical consequence of any unit testing discipline. Here's what you can do. Enumerate every module. Create a unittest for that module that is just a unittest.main(). This should be quick -- a few days at most. Write a nice top-level unittest script that uses a testLoader to all unit tests in your tests directory and runs them through the text runner. At this point, you'll have a lot of files -- one per module -- but no actual test cases. Getting the testloader and the top-level script to work will take a few days. It's important to have this overall harness working. Prioritize your modules. A good rule is "most heavily reused". Another rule is "highest risk from failure". Another rule is "most bugs reported". This takes a few hours. Start at the top of the list. Write a TestCase per class with no real methods or anything. Just a framework. This takes a few days at most. Be sure the docstring for each TestCase positively identifies the Module and Class under test and the status of the test code. You can use these docstrings to determine test coverage. At this point you'll have two parallel tracks. You have to actually design and implement the tests. Depending on the class under test, you may have to build test databases, mock objects, all kinds of supporting material. Testing Rework. Starting with your highest priority untested module, start filling in the TestCases for each class in each module. New Development. For every code change, a unittest.TestCase must be created for the class being changed. The test code follows the same rules as any other code. Everything is checked in at the end of the day. It has to run -- even if the tests don't all pass. Give the test script to the product manager (not the QA manager, the actual product manager who is responsible for shipping product to customers) and make sure they run the script every day and find out why it didn't run or why tests are failing. The actual running of the master test script is not a QA job -- it's everyone's job. Every manager at every level of the organization has to be part of the daily build script output. All of their jobs have to depend on "all tests passed last night". Otherwise, the product manager will simply pull resources away from testing and you'll have nothing.
1
5
0
I manage the testing for a very large financial pricing system. Recently our HQ have insisted that we verify that every single part of our project has a meaningful test in place. At the very least they want a system which guarantees that when we change something we can spot unintentional changes to other sub-systems. Preferably they want something which validates the correctness of every component in our system. That's obviously going to be quite a lot of work! It could take years, but for this kind of project it's worth it. I need to find out which parts of our code are not covered by any of our unit-tests. If I knew which parts of my system were untested then I could set about developing new tests which would eventually approach towards my goal of complete test-coverage. So how can I go about running this kind of analysis. What tools are available to me? I use Python 2.4 on Windows 32bit XP UPDATE0: Just to clarify: We have a very comprehensive unit-test suite (plus a seperate and very comprehensive regtest suite which is outside the scope of this exercise). We also have a very stable continuous integration platform (built with Hudson) which is designed to split-up and run standard python unit-tests across our test facility: Approx 20 PCs built to the company spec. The object of this exercise is to plug any gaps in our python unittest suite (only) suite so that every component has some degree of unittest coverage. Other developers will be taking responsibility for non Python components of the project (which are also outside of scope). "Component" is intentionally vague: Sometime it will be a class, other time an entire module or assembly of modules. It might even refer to a single financial concept (e.g. a single type of financial option or a financial model used by many types of option). This cake can be cut in many ways. "Meaningful" tests (to me) are ones which validate that the function does what the developer originally intended. We do not want to simply reproduce the regtests in pure python. Often the developer's intent is not immediatly obvious, hence the need to research and clarify anything which looks vague and then enshrine this knowledge in a unit-test which makes the original intent quite explicit.
How to do a meaningful code-coverage analysis of my unit-tests?
0.119427
0
0
3,113
1,006,289
2009-06-17T10:41:00.000
29
0
1
0
python,system-information
55,163,569
15
false
0
0
These give you the hyperthreaded CPU count multiprocessing.cpu_count() os.cpu_count() These give you the virtual machine CPU count psutil.cpu_count() numexpr.detect_number_of_cores() Only matters if you works on VMs.
1
716
0
I want to know the number of CPUs on the local machine using Python. The result should be user/real as output by time(1) when called with an optimally scaling userspace-only program.
How to find out the number of CPUs using python
1
0
0
459,493
1,006,450
2009-06-17T11:24:00.000
1
0
1
0
python,unicode,ascii,capitalization
1,006,467
2
false
0
0
capitalize() should Just Work™ for Unicode strings.
1
5
0
How to capitalize words containing non-ASCII characters in Python? Is there a way to tune string's capitalize() method to do that?
Capitalizing non-ASCII words in Python
0.099668
0
0
2,464
1,008,557
2009-06-17T17:45:00.000
9
0
0
1
python,vim
1,008,586
2
true
0
0
Try: !python %
1
2
0
I'm editing a file in ~/Documents. However, my working directory is somewhere else, say ~/Desktop. The file I'm editing is a Python script. I'm interested in doing a command like... :!python without needing to do :!python ~/Documents/script.py Is that possible? If so, what would be the command? Thank you.
Name of file I'm editing
1.2
0
0
191
1,008,686
2009-06-17T18:08:00.000
0
1
0
0
c#,ironpython,monkeypatching
1,040,151
3
false
1
1
You can monkey-patch from IronPython, but IPy is the only environment that will respect your changes; i.e. if you tried to mock out File.Create from IronPython, this would work fine for any IPy code, but if you called a C# method which called File.Create, it would get the real one, not the mock.
2
1
0
Can anyone tell me if its possible to redeclare a C# class in IronPython? If I have a C# class, would I be able to monkey-patch it from IronPython?
Redeclare .net classes in IronPython
0
0
0
324
1,008,686
2009-06-17T18:08:00.000
0
1
0
0
c#,ironpython,monkeypatching
3,155,159
3
true
1
1
You cannot monkey patch from IronPython. IronPython treats all .NET classes just like CPython treats built-in types: they cannot be monkey patched. IronRuby on the other hand does support this.
2
1
0
Can anyone tell me if its possible to redeclare a C# class in IronPython? If I have a C# class, would I be able to monkey-patch it from IronPython?
Redeclare .net classes in IronPython
1.2
0
0
324
1,009,037
2009-06-17T19:20:00.000
3
0
1
0
python,clojure,zip
1,016,876
3
false
0
0
The question has been answered, but there's still interleave, which also handles an arbitrary number of sequences, but does not group the resulting sequence into tuples (but you can use partition for that).
1
8
0
I'm trying to get into the Clojure community. I've been working a lot with Python, and one of the features I make extensive use of is the zip() method, for iterating over pairs of values. Is there a (clever and short) way of achieving the same in Clojure?
Processing pairs of values from two sequences in Clojure
0.197375
0
0
2,263
1,011,168
2009-06-18T06:59:00.000
2
0
1
0
python,silverlight,html,ria
1,011,396
6
true
1
0
You should focus on “HTML5” where “HTML5” is the new “Ajax” buzzword aka. the “Open Web Platform”—not just the HTML 5 spec itself. Flash, Silverlight and JavaFX are all single-vendor plug-in offerings but “HTML5” is a multi-vendor browser-native thing. If you want to an IDE workflow, you can use the Google Web Toolkit to have a Java workflow that targets the browser-native plug-inless feature set. Unfortunately, there’s no GWT-like Python system yet.
2
1
0
I am planning to build a RIA about a year from now (when my current contract ends). What technology would you recommend investing time in? I will need good cross browser/platform support for video, music, and canvas. And ideally I would like to leverage my Python skills. Silverlight looks interesting because I could use Python through .NET. But I'm on Linux so I'd always be a 2nd class citizen. And it has a low install base. Flash on the other hand has a large install base. And I'm not sure about JavaFX because of the Oracle deal. Or should I hold my hopes out for HTML 5? Thanks!
What to learn for RIA
1.2
0
0
2,163
1,011,168
2009-06-18T06:59:00.000
2
0
1
0
python,silverlight,html,ria
1,011,196
6
false
1
0
If you have a year to prepare I recommend that you research all the technologies you can. Build the hello worlds for the different platforms. Then build the SAME simple RIA on each candidate framework to get a good feel for the differences. Obviously you will not uncover every little gotcha, but the gross architectures and styles will be evident.
2
1
0
I am planning to build a RIA about a year from now (when my current contract ends). What technology would you recommend investing time in? I will need good cross browser/platform support for video, music, and canvas. And ideally I would like to leverage my Python skills. Silverlight looks interesting because I could use Python through .NET. But I'm on Linux so I'd always be a 2nd class citizen. And it has a low install base. Flash on the other hand has a large install base. And I'm not sure about JavaFX because of the Oracle deal. Or should I hold my hopes out for HTML 5? Thanks!
What to learn for RIA
0.066568
0
0
2,163
1,011,337
2009-06-18T07:51:00.000
-1
0
1
0
python,reference,packages,relative-path
1,011,435
4
false
0
0
This is a bad idea, because, if your package was installed as zipped egg, then resources can be unavailable. If you use setuptool, don't forget to add zip_safe=False to the setup.py config.
1
18
0
How do I reference a file relatively to a package's directory? My directory structure is: /foo package1/ resources/ __init__.py package2/ resources/ __init__.py script.py script.py imports packages package1 and package2. Although the packages can be imported by any other script on the system. How should I reference resources inside, say, package1 to ensure it would work in case os.path.curdir is arbitrary?
Relative file paths in Python packages
-0.049958
0
0
14,808
1,011,476
2009-06-18T08:31:00.000
0
0
0
0
python,django,sqlalchemy,configure
45,878,579
5
false
1
0
There are many benefits of using SQLAlchemy instead of Django ORM, but consider developing a built-in-Django choice of SQLAlchemy (to have something called a production ready) By the way, Django ORM is going better - in Django 1.11 they added UNION support (a SQL basic operator), so maybe some day there will be no need to change ORM.
1
29
0
How can I configure Django with SQLAlchemy?
Configuring Django to use SQLAlchemy
0
1
0
30,261
1,011,975
2009-06-18T10:32:00.000
2
0
0
0
python,mechanize
1,012,022
2
false
1
0
The Browser object in mechanize has a links method that will retrieve all the links on the page.
1
3
0
I want to use mechanize with python to get all the links of the page, and then open the links.How can I do it?
How to get links on a webpage using mechanize and open those links
0.197375
0
1
8,097
1,013,064
2009-06-18T14:45:00.000
0
1
0
0
python,shell,compilation,sftp
1,013,366
3
true
0
0
Weirdness aside, I was just using import to compile the code. Turning the script into a function seems like an unnecessary complication for this kind of application. Searched for alternate means to compile and found: import py_compile py_compile.compile("ProblemDemo.py") This generated a pyc file that works as intended. So the lesson learned is that import is not a robust way to compile python scripts.
1
3
0
I'm trying to use python to sftp a file, and the code works great in the interactive shell -- even pasting it in all at once. When I try to import the file (just to compile it), the code hangs with no exceptions or obvious errors. How do I get the code to compile, or does someone have working code that accomplishes sftp by some other method? This code hangs right at the ssh.connect() statement: """ ProblemDemo.py Chopped down from the paramiko demo file. This code works in the shell but hangs when I try to import it! """ from time import sleep import os import paramiko sOutputFilename = "redacted.htm" #-- The payload file hostname = "redacted.com" ####-- WARNING! Embedded passwords! Remove ASAP. sUsername = "redacted" sPassword = "redacted" sTargetDir = "redacted" #-- Get host key, if we know one. hostkeytype = None hostkey = None host_keys = {} try: host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts')) except IOError: try: # try ~/ssh/ too, because windows can't have a folder named ~/.ssh/ host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts')) except IOError: print '*** Unable to open host keys file' host_keys = {} if host_keys.has_key(hostname): hostkeytype = host_keys[hostname].keys()[0] hostkey = host_keys[hostname][hostkeytype] print 'Using host key of type %s' % hostkeytype ssh = paramiko.Transport((hostname, 22)) ssh.connect(username=sUsername, password=sPassword, hostkey=hostkey) sftp = paramiko.SFTPClient.from_transport(ssh) sftp.chdir (sTargetDir) sftp.put (sOutputFilename, sOutputFilename) ssh.close()
Why does this python code hang on import/compile but work in the shell?
1.2
0
1
6,518
1,014,239
2009-06-18T17:57:00.000
0
0
0
0
wxpython,wxwidgets
1,021,396
3
false
0
1
from wxPython docs """ longHelpString This string is shown in the statusbar (if any) of the parent frame when the mouse pointer is inside the tool """ so toolbar in notebook doesn't get any statusbar to display long help, so either thru src we should invertigate how it inquires abt status bar and supply a ref to main frame status bar else i think better way is to just override wxToolBar::OnMouseEnter and display help directly on status bar
1
2
0
I have an interface that has two toolbars, one attached to the frame and one embedded in a notebook tab. The one in the frame dutifully shows longHelp strings in the statusbar, the one in the notebook tab does not. How do I tell the one on the notebook tab where to display its help, or do I have to manage enter and leave bindings myself?
wxPython: how to make two toolbars use one statusbar for tooltips?
0
0
0
948
1,014,247
2009-06-18T17:59:00.000
1
0
1
0
python,collections,dictionary,treemap,uses
1,014,274
7
false
0
0
I often use Dict<DateTime, someClassOrValue> when working with industrial process data-- Valve open/close, machinery start/stop, etc. Having the keys sorted is especially useful when I need to compare time intervals between start/stop or open/close events in a decent amount of time. However, since I've been able to use linq in C# I've found that it's often easier to just work with IEnumerables and use the IQueryable extension methods to get the information I need.
4
2
0
I'm developing a 'TreeDict' class in Python. This is a basically a dict that allows you to retrieve its key-value pairs in sorted order, just like the Treemap collection class in Java. I've implemented some functionality based on the way unique indexes in relational databases can be used, e.g. functions to let you retrieve values corresponding to a range of keys, keys greater than, less than or equal to a particular value in sorted order, strings or tuples that have a specific prefix in sorted order, etc. Unfortunately, I can't think of any real life problem that will require a class like this. I suspect that the reason we don't have sorted dicts in Python is that in practice they aren't required often enough to be worth it, but I want to be proved wrong. Can you think of any specific applications of a 'TreeDict'? Any real life problem that would be best solved by this data structure? I just want to know for sure whether this is worth it.
What Can A 'TreeDict' (Or Treemap) Be Used For In Practice?
0.028564
0
0
3,135
1,014,247
2009-06-18T17:59:00.000
2
0
1
0
python,collections,dictionary,treemap,uses
1,014,281
7
false
0
0
The reason for keeping the elements in sorted order is for faster retrieval. Say I wanted all of the values in the dictionary in a sorted range. This is much faster with a TreeDict then with the regular hashmap. It basically allows you to keep everything in the dictionary in sorted order. I know in the application I'm currently working on uses a class like this to basically query the data structure.
4
2
0
I'm developing a 'TreeDict' class in Python. This is a basically a dict that allows you to retrieve its key-value pairs in sorted order, just like the Treemap collection class in Java. I've implemented some functionality based on the way unique indexes in relational databases can be used, e.g. functions to let you retrieve values corresponding to a range of keys, keys greater than, less than or equal to a particular value in sorted order, strings or tuples that have a specific prefix in sorted order, etc. Unfortunately, I can't think of any real life problem that will require a class like this. I suspect that the reason we don't have sorted dicts in Python is that in practice they aren't required often enough to be worth it, but I want to be proved wrong. Can you think of any specific applications of a 'TreeDict'? Any real life problem that would be best solved by this data structure? I just want to know for sure whether this is worth it.
What Can A 'TreeDict' (Or Treemap) Be Used For In Practice?
0.057081
0
0
3,135
1,014,247
2009-06-18T17:59:00.000
0
0
1
0
python,collections,dictionary,treemap,uses
1,014,282
7
false
0
0
They can make various algorithms easier to implement.
4
2
0
I'm developing a 'TreeDict' class in Python. This is a basically a dict that allows you to retrieve its key-value pairs in sorted order, just like the Treemap collection class in Java. I've implemented some functionality based on the way unique indexes in relational databases can be used, e.g. functions to let you retrieve values corresponding to a range of keys, keys greater than, less than or equal to a particular value in sorted order, strings or tuples that have a specific prefix in sorted order, etc. Unfortunately, I can't think of any real life problem that will require a class like this. I suspect that the reason we don't have sorted dicts in Python is that in practice they aren't required often enough to be worth it, but I want to be proved wrong. Can you think of any specific applications of a 'TreeDict'? Any real life problem that would be best solved by this data structure? I just want to know for sure whether this is worth it.
What Can A 'TreeDict' (Or Treemap) Be Used For In Practice?
0
0
0
3,135
1,014,247
2009-06-18T17:59:00.000
2
0
1
0
python,collections,dictionary,treemap,uses
1,014,601
7
true
0
0
It's useful when you need to go through a Dictionary in order of the keys; which comes up on occasion. I've actually found its infinitely more common in certain programming contests then anything else (think ACM, etc). The most useful feature of a TreeMap is when you want to quickly find the min or max key; using a sorted dictionary this is often a single method call; and algorithmically can be done in O(log(n)) time, as opposed to iterating over each key looking for a min/max if the collection is unsorted. Basically, a much friendlier interface. One of the more common times I run into it is when objects are identified by a specific name, and you want to print out the objects ordered according to the name; say a mapping from directory name to number of files in a directory. One other place I've used it is in an excel spreadsheet wrapper; mapping from row number to row object. This lets you quickly find the last row index, without looping through each row. Also, it's useful when you can easily define a comparison relation on keys, but not necessarily a hashing function, as needed for HashMaps. The best (though weak) example I can think of is case insensitive string keys.
4
2
0
I'm developing a 'TreeDict' class in Python. This is a basically a dict that allows you to retrieve its key-value pairs in sorted order, just like the Treemap collection class in Java. I've implemented some functionality based on the way unique indexes in relational databases can be used, e.g. functions to let you retrieve values corresponding to a range of keys, keys greater than, less than or equal to a particular value in sorted order, strings or tuples that have a specific prefix in sorted order, etc. Unfortunately, I can't think of any real life problem that will require a class like this. I suspect that the reason we don't have sorted dicts in Python is that in practice they aren't required often enough to be worth it, but I want to be proved wrong. Can you think of any specific applications of a 'TreeDict'? Any real life problem that would be best solved by this data structure? I just want to know for sure whether this is worth it.
What Can A 'TreeDict' (Or Treemap) Be Used For In Practice?
1.2
0
0
3,135
1,015,816
2009-06-19T00:02:00.000
0
0
0
0
python,xslt
1,016,919
2
false
0
0
Data stored in XML comes out the same way it goes in. So if you store the text in an element, no whitespace and newlines are lost unless you tamper with the data in the XSLT. Enclosing the text in CDATA is unnecessary unless there is some formatting that is invalid in XML (pointy brackets, ampersands, quotes) and you don't want to XML-escape the text under any circumstances. This is up to you, but in any case XML-escaping is completely transparent when the XML is handled with an XML-aware tool chain. To answer your question more specifically, you need to show some input, the essential part of the transformation, and some output.
1
0
0
I have formatted text (with newlines, tabs, etc.) coming in from a Telnet connection. I have a python script that manages the Telnet connection and embeds the Telnet response in XML that then gets passed through an XSLT transform. How do I pass that XML through the transform without losing the original formatting? I have access to the transformation script and the python script but not the transform invocation itself.
Passing Formatted Text Through XSLT
0
0
1
223
1,016,105
2009-06-19T02:29:00.000
-1
0
1
0
python,python-import,relative-path,python-module
1,036,276
3
true
0
0
Put the directory that contains both in your python path... or vice versa.
1
0
0
I have the Python modules a.py and b.py in the same directory. How can I reliably import b.py from a.py, given that a.py may have been imported from another directory or executed directly? This module will be distributed so I can't hardcode a single path. I've been playing around with __file__, sys.path and os.chdir, but it feels messy. And __file__ is not always available.
python importing relative modules
1.2
0
0
708
1,016,301
2009-06-19T04:04:00.000
8
1
1
0
python,chuck,puredata
1,016,318
4
true
0
0
I would say learn them all. While it's true that many languages can do many things, specialised languages are usually more expressive and easier to use for a particular task. Case-in-point is while most languages allow shell interaction and process control very few are as well suited to the task as bash scripts. Plugins and libraries can bridge the gap between general and specialised languages but in my experience this is not always without drawbacks - be they speed, stability or complexity. It isn't uncommon to have to compile additional libraries or apply patches or use untrusted and poorly supported modules. It also isn't uncommon that the resulting interface is still harder to use than the original language. I know about 15 languages well and a few of those very well. I do not use my prefered languages when another is more suitable.
2
6
0
I am learning Python because it appeals to me as a mathematician but also has many useful libraries for scientific computing, image processing, web apps, etc etc. It is frustrating to me that for certain of my interests (eletronic music or installation art) there are very specific programming languages which seem better suited to these purposes, such as Max/MSP, PureData, and ChucK -- all quite fascinating. My question is, how should one approach these different languages? Should I simply learn Python and manage the others by using plugins and Python interpreters in them? Are there good tools for integrating the languages, or is the proper way simply to learn all of them?
Synthesis of general programming language (Python) with tailored language (PureData/MaxMSP/ChucK)
1.2
0
0
1,140
1,016,301
2009-06-19T04:04:00.000
4
1
1
0
python,chuck,puredata
1,716,786
4
false
0
0
This thread is a little old, but I wanted to point out that the majority of the mature audio development environments e.g. supercollider/max-msp/pure data can be controlled via open sound control. You can google up a better description of OSC, but suffice it to say that it allows you to send control data to synths built in these environments similar to how MIDI works, but way more extensive. This does not solve the problem of actually building synths in python per se but it allows you to "drive" these other environments without having to know the ins and outs of the language.
2
6
0
I am learning Python because it appeals to me as a mathematician but also has many useful libraries for scientific computing, image processing, web apps, etc etc. It is frustrating to me that for certain of my interests (eletronic music or installation art) there are very specific programming languages which seem better suited to these purposes, such as Max/MSP, PureData, and ChucK -- all quite fascinating. My question is, how should one approach these different languages? Should I simply learn Python and manage the others by using plugins and Python interpreters in them? Are there good tools for integrating the languages, or is the proper way simply to learn all of them?
Synthesis of general programming language (Python) with tailored language (PureData/MaxMSP/ChucK)
0.197375
0
0
1,140
1,016,814
2009-06-19T07:53:00.000
22
0
1
0
python,indentation
7,499,004
18
false
0
0
Run your code with the -tt option to find out if you are using tabs and spaces inconsistently.
5
157
0
How do I rectify the error "unexpected indent" in Python?
What should I do with "Unexpected indent" in Python?
1
0
0
1,087,970
1,016,814
2009-06-19T07:53:00.000
20
0
1
0
python,indentation
1,017,458
18
false
0
0
Turn on visible whitespace in whatever editor you are using and turn on replace tabs with spaces. While you can use tabs with Python, mixing tabs and space usually leads to the error you are experiencing. Replacing tabs with four spaces is the recommended approach for writing Python code.
5
157
0
How do I rectify the error "unexpected indent" in Python?
What should I do with "Unexpected indent" in Python?
1
0
0
1,087,970
1,016,814
2009-06-19T07:53:00.000
11
0
1
0
python,indentation
1,016,829
18
false
0
0
By using correct indentation. Python is white space aware, so you need to follow its indentation guidelines for blocks or you'll get indentation errors.
5
157
0
How do I rectify the error "unexpected indent" in Python?
What should I do with "Unexpected indent" in Python?
1
0
0
1,087,970
1,016,814
2009-06-19T07:53:00.000
3
0
1
0
python,indentation
1,017,428
18
false
0
0
If the indentation looks ok then have a look to see if your editor has a "View Whitespace" option. Enabling this should allow to find where spaces and tabs are mixed.
5
157
0
How do I rectify the error "unexpected indent" in Python?
What should I do with "Unexpected indent" in Python?
0.033321
0
0
1,087,970
1,016,814
2009-06-19T07:53:00.000
2
0
1
0
python,indentation
67,444,047
18
false
0
0
It depends on the context, but an indentation error is often caused by using tabs instead of spaces. Here are some steps you can take to correct this: Copy the tabs or spaces that are causing the error Do a find and replace in your IDE (usually Ctrl + H). Paste the copied tabs or spaces into the "Find" search bar, and then replace them all with four spaces (assuming that your IDE uses four spaces as a "good" indentation) This error also happens a lot if you are copying and pasting code from external sources into your IDE, because the formatting elsewhere may not match your IDE's definition for what counts as a "good" indentation.
5
157
0
How do I rectify the error "unexpected indent" in Python?
What should I do with "Unexpected indent" in Python?
0.022219
0
0
1,087,970
1,017,399
2009-06-19T11:01:00.000
1
0
0
0
python
1,017,671
4
false
0
0
Django, Twisted, and CherryPy are popular Python "Back-Ends" as far as web applications go, with Twisted likely being the most flexible as far as networking is concerned. SQLite can, as has been previously posted, be directly interfaced with using SQL commands as it has native bindings for Python, or it can be accessed with an Object Relational Manager such as SQLObject (another Python library). As far as performance is concered, SQLite is fairly scalable and should be able to handle most use cases that don't require a seperate database server (nothing enterprise level). An additional benefit of SQLite is that the database is self-contained in a single file allowing for easy backup while remained a common enough format that multiple applications can access the data. A word of advice on using SQLite with Python, however, is that you may run into issues with threading (in the past most of the bindings for SQLite were not thread-safe, although this may have changed over time).
3
0
0
which is the best back end for python applications and what is the advantage of using sqlite ,how it can be connected to python applications
backend for python
0.049958
0
0
2,057
1,017,399
2009-06-19T11:01:00.000
0
0
0
0
python
1,017,523
4
false
0
0
The language you are using at the application layer has little to do with your database choice underneath. You need to examine the advantages of other DB packages to get an idea of what you want. Here are some popular database packages for cheap or free: ms sql server express, pg/sql, mysql
3
0
0
which is the best back end for python applications and what is the advantage of using sqlite ,how it can be connected to python applications
backend for python
0
0
0
2,057
1,017,399
2009-06-19T11:01:00.000
3
0
0
0
python
1,017,414
4
false
0
0
What do you mean with back end? Python apps connect to SQLite just like any other database, you just have to import the correct module and check how to use it. The advantages of using SQLite are: You don't need to setup a database server, it's just a file No configurations needed Cross platform Mainly, desktops applications are the ones that take real advantage of this. For web apps, SQLite is not recommended, since the file containing the data, is easily readable (lacks any kind of encryption), and when the web server lacks special configuration, the file is downloadable by anyone.
3
0
0
which is the best back end for python applications and what is the advantage of using sqlite ,how it can be connected to python applications
backend for python
0.148885
0
0
2,057
1,017,794
2009-06-19T12:48:00.000
3
1
0
0
python,google-groups
1,017,810
1
true
0
0
There isn't an API that I know of, however you can access the XML feed and manipulate it as required.
1
6
0
I'm trying to build some statistics for an email group I participate. Is there any Python API to access the email data on a GoogleGroup? Also, I know some statistics are available on the group's main page. I'm looking for something more complex than what is shown there.
Is there an API to access a Google Group data?
1.2
0
1
1,163
1,018,073
2009-06-19T13:51:00.000
56
0
0
0
python,oracle
1,018,096
2
true
0
0
CLOB is encoding and collation sensitive, BLOB is not. When you write into a CLOB using, say, CL8WIN1251, you write a 0xC0 (which is Cyrillic letter А). When you read data back using AL16UTF16, you get back 0x0410, which is a UTF16 represenation of this letter. If you were reading from a BLOB, you would get same 0xC0 back.
2
39
0
This is mainly just a "check my understanding" type of question. Here's my understanding of CLOBs and BLOBs as they work in Oracle: CLOBs are for text like XML, JSON, etc. You should not assume what encoding the database will store it as (at least in an application) as it will be converted to whatever encoding the database was configured to use. BLOBs are for binary data. You can be reasonably assured that they will be stored how you send them and that you will get them back with exactly the same data as they were sent as. So in other words, say I have some binary data (in this case a pickled python object). I need to be assured that when I send it, it will be stored exactly how I sent it and that when I get it back it will be exactly the same. A BLOB is what I want, correct? Is it really feasible to use a CLOB for this? Or will character encoding cause enough problems that it's not worth it?
Help me understand the difference between CLOBs and BLOBs in Oracle
1.2
1
0
43,567
1,018,073
2009-06-19T13:51:00.000
10
0
0
0
python,oracle
1,018,102
2
false
0
0
Your understanding is correct. Since you mention Python, think of the Python 3 distinction between strings and bytes: CLOBs and BLOBs are quite analogous, with the extra issue that the encoding of CLOBs is not under your app's control.
2
39
0
This is mainly just a "check my understanding" type of question. Here's my understanding of CLOBs and BLOBs as they work in Oracle: CLOBs are for text like XML, JSON, etc. You should not assume what encoding the database will store it as (at least in an application) as it will be converted to whatever encoding the database was configured to use. BLOBs are for binary data. You can be reasonably assured that they will be stored how you send them and that you will get them back with exactly the same data as they were sent as. So in other words, say I have some binary data (in this case a pickled python object). I need to be assured that when I send it, it will be stored exactly how I sent it and that when I get it back it will be exactly the same. A BLOB is what I want, correct? Is it really feasible to use a CLOB for this? Or will character encoding cause enough problems that it's not worth it?
Help me understand the difference between CLOBs and BLOBs in Oracle
1
1
0
43,567
1,019,302
2009-06-19T18:09:00.000
1
0
1
0
python,google-app-engine,set
1,019,428
4
false
0
0
You need to have timestamps in both your database and your CSV file. Timestamp should show the data when the record was updated and you should compare timestamps of the record with same IDs to decide if you need updating it or not As to your idea about intersection... It should be done vise versa! You have to import all data from CSV to the temporary table and do intersection between 2 SQL database tables. If you use Oracle or MS SQL 2008 (not sure for 2005) you will found a very usefull MERGE keyword, so you can write SQL with less efforts then you will spend for merging data in other programming language.
3
0
0
I've got a data source that provides a list of objects and their properties (a CSV file, but that doesn't matter). Each time my program runs, it needs to pull a new copy of the list of objects, compare it to the list of objects (and their properties) stored in the database, and update the database as needed. Dealing with new objects is easy - the data source gives each object a sequential ID number, check the top ID number in the new information against the database, and you're done. I'm looking for suggestions for the other cases - when some of an object's properties have changed, or when an object has been deleted. A naive solution would be to pull all the objects from the database and get the complement of the intersection of the two sets (old and new) and then examine those results, but that seems like it wouldn't be very efficient if the sets get large. Any ideas?
Algorithm for updating a list from a list
0.049958
0
0
424
1,019,302
2009-06-19T18:09:00.000
1
0
1
0
python,google-app-engine,set
1,019,395
4
false
0
0
Is there no way to maintain a "last time modified" field? That's what it sounds like you're really looking for: an incremental backup, based on last time backup was run, compared to last time an object was changed/deleted(/added).
3
0
0
I've got a data source that provides a list of objects and their properties (a CSV file, but that doesn't matter). Each time my program runs, it needs to pull a new copy of the list of objects, compare it to the list of objects (and their properties) stored in the database, and update the database as needed. Dealing with new objects is easy - the data source gives each object a sequential ID number, check the top ID number in the new information against the database, and you're done. I'm looking for suggestions for the other cases - when some of an object's properties have changed, or when an object has been deleted. A naive solution would be to pull all the objects from the database and get the complement of the intersection of the two sets (old and new) and then examine those results, but that seems like it wouldn't be very efficient if the sets get large. Any ideas?
Algorithm for updating a list from a list
0.049958
0
0
424
1,019,302
2009-06-19T18:09:00.000
0
0
1
0
python,google-app-engine,set
1,019,401
4
false
0
0
When you pull the list into your program, iterate over the list doing a query based on a column property in the database table that maps to the same property of the object from list like ObjectName. Or you could load the whole table into a list and compare the list that way. I assuming that you have something unique about the object that exists besides the ID the database assigns. If that object is not found in the table via the query, create a new entry. If it is found like FogleBird mentioned, have a computed hash or CRC stored for that object in the table that you can compare with the object in the list(run computation on the object). If the hashes don't match, update that object with the one on the list.
3
0
0
I've got a data source that provides a list of objects and their properties (a CSV file, but that doesn't matter). Each time my program runs, it needs to pull a new copy of the list of objects, compare it to the list of objects (and their properties) stored in the database, and update the database as needed. Dealing with new objects is easy - the data source gives each object a sequential ID number, check the top ID number in the new information against the database, and you're done. I'm looking for suggestions for the other cases - when some of an object's properties have changed, or when an object has been deleted. A naive solution would be to pull all the objects from the database and get the complement of the intersection of the two sets (old and new) and then examine those results, but that seems like it wouldn't be very efficient if the sets get large. Any ideas?
Algorithm for updating a list from a list
0
0
0
424
1,019,447
2009-06-19T18:37:00.000
0
0
0
0
sharepoint,ironpython
1,166,936
1
false
0
0
What do you mean by embedded in SharePoint? ipy scripts turned into assemblies should behavior properly wherever their C# or VB.Net brethren are used (assuming the IronPython support assemblies are referencable. I personally love using it as a more powerful scripted stsadm solution since it is hard to do Powershell error handling correctly with SharePoint.
1
0
0
I'd like to do SharePoint development with IronPython, but I haven't seen any examples where IronPython is embedded in SharePoint. Does anyone have a working example that would get me started?
Example code that embeds IronPython in SharePoint?
0
0
0
331
1,019,707
2009-06-19T19:35:00.000
0
1
0
1
python,c,linux,security,sandbox
1,029,301
12
false
1
0
I think your solutions must concentrate on analyzing the source code. I don't know any tools, and I think this would be pretty hard with C, but, for example, a Pascal program which doesn't include any modules would be pretty harmless in my opinion.
3
16
0
I want to create a Web app which would allow the user to upload some C code, and see the results of its execution (the code would be compiled on the server). The users are untrusted, which obviously has some huge security implications. So I need to create some kind of sandbox for the apps. At the most basic level, I'd like to restrict access to the file system to some specified directories. I cannot use chroot jails directly, since the web app is not running as a privileged user. I guess a suid executable which sets up the jail would be an option. The uploaded programs would be rather small, so they should execute quickly (a couple of seconds at most). Hence, I can kill the process after a preset timeout, but how do I ensure that it doesn't spawn new processes? Or if I can't, is killing the entire pgid a reliable method? What would be the best way to go about this - other than "don't do it at all"? :) What other glaring security problems have I missed? FWIW, the web app will be written in Python.
Sandboxing in Linux
0
0
0
7,104
1,019,707
2009-06-19T19:35:00.000
-2
1
0
1
python,c,linux,security,sandbox
1,019,986
12
false
1
0
About the only chance you have is running a VirtualMachine and those can have vulnerabilities. If you want your machine hacked in the short term just use permissions and make a special user with access to maybe one directory. If you want to postpone the hacking to some point in the future then run a webserver inside a virtual machine and port forward to that. You'll want to keep a backup of that because you'll probably have that hacked in under an hour and want to restart a fresh copy every few hours. You'll also want to keep an image of the whole machine to just reimage the whole thing once a week or so in order to overcome the weekly hackings. Don't let that machine talk to any other machine on your network. Blacklist it everywhere. I'm talking about the virtual machine and the physical machine IP addresses. Do regular security audits on any other machines on your other machines on the network. Please rename the machines IHaveBeenHacked1 and IHaveBeenHacked2 and prevent access to those in your hosts lists and firewalls. This way you might stave off your level of hackage for a while.
3
16
0
I want to create a Web app which would allow the user to upload some C code, and see the results of its execution (the code would be compiled on the server). The users are untrusted, which obviously has some huge security implications. So I need to create some kind of sandbox for the apps. At the most basic level, I'd like to restrict access to the file system to some specified directories. I cannot use chroot jails directly, since the web app is not running as a privileged user. I guess a suid executable which sets up the jail would be an option. The uploaded programs would be rather small, so they should execute quickly (a couple of seconds at most). Hence, I can kill the process after a preset timeout, but how do I ensure that it doesn't spawn new processes? Or if I can't, is killing the entire pgid a reliable method? What would be the best way to go about this - other than "don't do it at all"? :) What other glaring security problems have I missed? FWIW, the web app will be written in Python.
Sandboxing in Linux
-0.033321
0
0
7,104
1,019,707
2009-06-19T19:35:00.000
0
1
0
1
python,c,linux,security,sandbox
15,609,095
12
false
1
0
Spawning a new VM under KVM or qemu to compile and run the code looks like the way to go. Running the code under jail/LXC can compromise the machine if it exploits the unsecured parts of the OS like networking code. Advantage of running under a VM are obvious. One can only hack the VM but not the machine itself. But the side effect is you need lots of resources (CPU and Memory) to spawn a VM for each request.
3
16
0
I want to create a Web app which would allow the user to upload some C code, and see the results of its execution (the code would be compiled on the server). The users are untrusted, which obviously has some huge security implications. So I need to create some kind of sandbox for the apps. At the most basic level, I'd like to restrict access to the file system to some specified directories. I cannot use chroot jails directly, since the web app is not running as a privileged user. I guess a suid executable which sets up the jail would be an option. The uploaded programs would be rather small, so they should execute quickly (a couple of seconds at most). Hence, I can kill the process after a preset timeout, but how do I ensure that it doesn't spawn new processes? Or if I can't, is killing the entire pgid a reliable method? What would be the best way to go about this - other than "don't do it at all"? :) What other glaring security problems have I missed? FWIW, the web app will be written in Python.
Sandboxing in Linux
0
0
0
7,104
1,020,775
2009-06-20T02:22:00.000
0
0
0
0
python,frame
1,021,195
6
false
1
0
just FYI, for PyQT, the book has a chapter 15 with Databases, It looks good. and the book has something with data and view etc. I have read it and I think it's well worth your time:)
1
9
0
I have been building business database applications such as finance, inventory and other business requirement applications. I am planning to shift to Python. What would be the tools to start with best. I would need to do master, transaction forms, processing (back end), reports and that sort of thing. The database would be postgress or mysql. As I am new to Python I understand that I need besides Python the ORM and also a framework. My application is not a web site related but it could also be need to be done over the web if needed. How to choose the initial setup of tool combinations?
Python database application framework and tools
0
1
0
9,831
1,021,411
2009-06-20T11:01:00.000
0
0
0
0
python,html,google-app-engine,forms
1,021,454
3
false
1
0
AppEngine includes Django's form framework (or a variation thereof), which I find very nice. It also plays well with your ORM (i.e. getting forms for models is very DRY). The only potential problem is the lack of client-side validation.
1
1
0
Is there a well maintained package available in Python for creating and validating HTML forms? I will deploying it finally on Google Appengine.
Package for creating and validating HTML forms in Python? - to be used in Google Appengine
0
0
0
355
1,022,914
2009-06-21T01:00:00.000
2
0
0
0
python,ruby-on-rails,django
1,022,932
5
false
1
0
Python is all that is needed. I think there is a cPanel plugin which allows your users to create and deploy Django applications, so if you have a VPS or Reseller account, or your host is running cPanel, you could simply tell them to install it. If I find the link to the plugin I will post it here.
1
2
0
When finding web hosting for Rails apps, the hoster must have support for ruby on rails -- that is evident. What about hosting for Django? What support does the hoster need to provide? Python, or more than just Python? This might seem like an obvious question, but I'm new to web development frameworks so I must ask :)
Deploying Django
0.07983
0
0
537
1,025,018
2009-06-21T23:31:00.000
1
0
1
0
python,ajax,autocomplete,trie
1,025,027
2
false
1
0
I would use the first option. 'KISS' - (Keep It Simple Stupid). For small amounts of data there shouldn't be much latency. We run the same kind of thing for a name search and results appear pretty quickly on a few thousand rows. Hope that helps, Josh
1
2
0
I'm implementing a "Google Suggest" like autocomplete feature for tag searching using jQuery's autocomplete. I need to provide a web service to jQuery giving it a list of suggestions based on what the user has typed. I see 2 ways of implementing the web service: 1) just store all the tags in a database and search the DB using user input as prefix. This is simple, but I'm concerned about latency. 2) Use an in-process trie to store all the tags and search it for matching results. As everything will be in-process, I expect this to have much lower latency. But there are several difficulties: -What's a good way to initialize the trie on process start up? Presumable I'll store the tag data in a DB and retrieve them and turn them into a trie when I frist start up the process. But I'm not sure how. I'm using Python/Django. -When a new tag is created by a user, I need to insert the new tag into the trie. But let's say I have 5 Django processes and hence 5 tries, how do I tell the other 4 tries that they need to insert a new tag too? -How to make sure the trie is threadsafe as my Django processes will be threaded (I'm using mod_wsgi). Or do I not have to worry about threadsafty because of Python's GIL? -Any way I can store the tag's frequency of use within the trie as well? How do I tell when does the tag's string end and when does the frequency start - eg. if I store apple213 into the trie, is it "apple" with frequency 213 or is it "apple2" with frequency 13?? Any help on the issues above or any suggestions on a different approach would be really appreciated.
What's the best way to implement web service for ajax autocomplete
0.099668
0
0
1,169
1,025,493
2009-06-22T04:49:00.000
0
0
0
0
python,sqlite,python-2.6
1,028,006
2
false
0
0
I'm using 3.4.0 out of inertia (it's what came with the Python 2.* versions I'm using) but there's no real reason (save powerful inertia;-) to avoid upgrading to 3.4.2, which fixes a couple of bugs that could lead to DB corruption and introduces no incompatibilities that I know of. (If you stick with 3.4.0 I'm told the key thing is to avoid VACUUM as it might mangle your data). Python 3.1 comes with SQLite 3.6.11 (which is supposed to work with Python 2.* just as well) and I might one day update to that (or probably to the latest, currently 3.6.15, to pick up a slew of minor bug fixes and enhancements) just to make sure I'm using identical releases on either Python 2 or Python 3 -- I've never observed a compatibility problem, but I doubt there has been thorough testing to support reading and writing the same DB from 3.4.0 and 3.6.11 (or any two releases so far apart from each other!-).
1
2
0
which versions of sqlite may best suite for python 2.6.2?
sqlite version for python26
0
1
0
444
1,025,817
2009-06-22T07:03:00.000
1
0
0
0
python,html,browser
1,025,846
7
false
1
0
If you want an an HTML page to have some sort of server-side programming then you will need a webserver of some sort to do the processing. My suggestion would be to get a web server running on your development box, or try to accomplish what you need to do with a local desktop application or script.
3
2
0
Is there a way to call a program (Python script) from a local HTML page? I have a YUI-colorpicker on that page and need to send its value to a microcontroller via rs232. (There is other stuff than the picker, so I can't code an application instead of an HTML page.) Later, this will migrate to a server, but I need a fast and easy solution now. Thanks.
Call program from within a browser without using a webserver
0.028564
0
0
2,904
1,025,817
2009-06-22T07:03:00.000
0
0
0
0
python,html,browser
1,025,901
7
false
1
0
Try also XML-RPC it gives you a simple way to pass remote procedure calls from YUI towards a simple XMLRPC server and from that towards your rs232 device
3
2
0
Is there a way to call a program (Python script) from a local HTML page? I have a YUI-colorpicker on that page and need to send its value to a microcontroller via rs232. (There is other stuff than the picker, so I can't code an application instead of an HTML page.) Later, this will migrate to a server, but I need a fast and easy solution now. Thanks.
Call program from within a browser without using a webserver
0
0
0
2,904
1,025,817
2009-06-22T07:03:00.000
0
0
0
0
python,html,browser
1,026,086
7
false
1
0
I see no reason why you can't setup a handler for .py/.bat/.vbs files in your browser. This should result in your chosen application running a script when you link to it. This won't work when you migrate to the server but as a testing platform it would work. Just remember to turn it off when you're done or you expose yourself to viruses from other sites.
3
2
0
Is there a way to call a program (Python script) from a local HTML page? I have a YUI-colorpicker on that page and need to send its value to a microcontroller via rs232. (There is other stuff than the picker, so I can't code an application instead of an HTML page.) Later, this will migrate to a server, but I need a fast and easy solution now. Thanks.
Call program from within a browser without using a webserver
0
0
0
2,904
1,026,431
2009-06-22T10:20:00.000
1
0
0
1
python,privileges,admin-rights
1,038,617
5
false
0
0
Administrator group membership (Domain/Local/Enterprise) is one thing.. tailoring your application to not use blanket privilege and setting fine grained rights is a better option especially if the app is being used iinteractively. testing for particular named privileges (se_shutdown se_restore etc), file rights is abetter bet and easier to diagnose.
3
25
0
Is there any cross-platform way to check that my Python script is executed with admin rights? Unfortunately, os.getuid() is UNIX-only and is not available under Windows.
Cross-platform way to check admin rights in a Python script under Windows?
0.039979
0
0
18,741
1,026,431
2009-06-22T10:20:00.000
3
0
0
1
python,privileges,admin-rights
1,026,442
5
false
0
0
Try doing whatever you need admin rights for, and check for failure. This will only work for some things though, what are you trying to do?
3
25
0
Is there any cross-platform way to check that my Python script is executed with admin rights? Unfortunately, os.getuid() is UNIX-only and is not available under Windows.
Cross-platform way to check admin rights in a Python script under Windows?
0.119427
0
0
18,741
1,026,431
2009-06-22T10:20:00.000
3
0
0
1
python,privileges,admin-rights
1,026,516
5
false
0
0
It's better if you check which platform your script is running (using sys.platform) and do a test based on that, e.g. import some hasAdminRights function from another, platform-specific module. On Windows you could check whether Windows\System32 is writable using os.access, but remember to try to retrieve system's actual "Windows" folder path, probably using pywin32. Don't hardcode one.
3
25
0
Is there any cross-platform way to check that my Python script is executed with admin rights? Unfortunately, os.getuid() is UNIX-only and is not available under Windows.
Cross-platform way to check admin rights in a Python script under Windows?
0.119427
0
0
18,741
1,026,925
2009-06-22T12:26:00.000
-11
0
0
0
php,python,extract,analysis,named-entity-recognition
1,026,976
6
false
0
0
I don't really know about NER, but judging from that example, you could make an algorithm that searched for capital letters in the words or something like that. For that I would recommend regex as the most easy to implement solution if you're thinking small. Another option is to compare the texts with a database, wich yould match string pre-identified as Tags of interest. my 5 cents.
1
22
1
I would like to use named entity recognition (NER) to find adequate tags for texts in a database. I know there is a Wikipedia article about this and lots of other pages describing NER, I would preferably hear something about this topic from you: What experiences did you make with the various algorithms? Which algorithm would you recommend? Which algorithm is the easiest to implement (PHP/Python)? How to the algorithms work? Is manual training necessary? Example: "Last year, I was in London where I saw Barack Obama." => Tags: London, Barack Obama I hope you can help me. Thank you very much in advance!
Algorithms for named entity recognition
-1
0
0
9,656
1,026,966
2009-06-22T12:36:00.000
2
1
1
0
python,parsing,code-analysis
1,061,573
5
false
0
0
Others have mentioned tools like PyLint which are pretty good, but the long and the short of it is that it's simply not possible to do 100%. In fact, you might not even want to do it. Part of the benefit to Python's dynamicity is that you can do crazy things like insert names into the local scope through a dictionary access. What it comes down to is that if you want a way to catch type errors at compile time, you shouldn't use Python. A language choice always involves a set of trade-offs. If you choose Python over C, just be aware that you're trading a strong type system for faster development, better string manipulation, etc.
3
14
0
My background is C and C++. I like Python a lot, but there's one aspect of it (and other interpreted languages I guess) that is really hard to work with when you're used to compiled languages. When I've written something in Python and come to the point where I can run it, there's still no guarantee that no language-specific errors remain. For me that means that I can't rely solely on my runtime defense (rigorous testing of input, asserts etc.) to avoid crashes, because in 6 months when some otherwise nice code finally gets run, it might crack due to some stupid typo. Clearly a system should be tested enough to make sure all code has been run, but most of the time I use Python for in-house scripts and small tools, which ofcourse never gets the QA attention they need. Also, some code is so simple that (if your background is C/C++) you know it will work fine as long as it compiles (e.g. getter-methods inside classes, usually a simple return of a member variable). So, my question is the obvious - is there any way (with a special tool or something) I can make sure all the code in my Python script will "compile" and run?
How can I make sure all my Python code "compiles"?
0.07983
0
0
1,051
1,026,966
2009-06-22T12:36:00.000
1
1
1
0
python,parsing,code-analysis
1,026,984
5
false
0
0
I think what you are looking for is code test line coverage. You want to add tests to your script that will make sure all of your lines of code, or as many as you have time to, get tested. Testing is a great deal of work, but if you want the kind of assurance you are asking for, there is no free lunch, sorry :( .
3
14
0
My background is C and C++. I like Python a lot, but there's one aspect of it (and other interpreted languages I guess) that is really hard to work with when you're used to compiled languages. When I've written something in Python and come to the point where I can run it, there's still no guarantee that no language-specific errors remain. For me that means that I can't rely solely on my runtime defense (rigorous testing of input, asserts etc.) to avoid crashes, because in 6 months when some otherwise nice code finally gets run, it might crack due to some stupid typo. Clearly a system should be tested enough to make sure all code has been run, but most of the time I use Python for in-house scripts and small tools, which ofcourse never gets the QA attention they need. Also, some code is so simple that (if your background is C/C++) you know it will work fine as long as it compiles (e.g. getter-methods inside classes, usually a simple return of a member variable). So, my question is the obvious - is there any way (with a special tool or something) I can make sure all the code in my Python script will "compile" and run?
How can I make sure all my Python code "compiles"?
0.039979
0
0
1,051
1,026,966
2009-06-22T12:36:00.000
0
1
1
0
python,parsing,code-analysis
1,027,032
5
false
0
0
Your code actually gets compiled when you run it, the Python runtime will complain if there is a syntax error in the code. Compared to statically compiled languages like C/C++ or Java, it does not check whether variable names and types are correct – for that you need to actually run the code (e.g. with automated tests).
3
14
0
My background is C and C++. I like Python a lot, but there's one aspect of it (and other interpreted languages I guess) that is really hard to work with when you're used to compiled languages. When I've written something in Python and come to the point where I can run it, there's still no guarantee that no language-specific errors remain. For me that means that I can't rely solely on my runtime defense (rigorous testing of input, asserts etc.) to avoid crashes, because in 6 months when some otherwise nice code finally gets run, it might crack due to some stupid typo. Clearly a system should be tested enough to make sure all code has been run, but most of the time I use Python for in-house scripts and small tools, which ofcourse never gets the QA attention they need. Also, some code is so simple that (if your background is C/C++) you know it will work fine as long as it compiles (e.g. getter-methods inside classes, usually a simple return of a member variable). So, my question is the obvious - is there any way (with a special tool or something) I can make sure all the code in my Python script will "compile" and run?
How can I make sure all my Python code "compiles"?
0
0
0
1,051
1,027,714
2009-06-22T15:05:00.000
9
0
1
0
python
20,010,963
12
false
0
0
I am not an expert but this is what I noticed: if your code is mycode.py for instance, and you type just 'import mycode', Python will execute it but it will not make all your variables available to the interpreter. I found that you should type actually 'from mycode import *' if you want to make all variables available to the interpreter.
2
345
0
I'm trying to execute a file with Python commands from within the interpreter. EDIT: I'm trying to use variables and settings from that file, not to invoke a separate process.
How to execute a file within the Python interpreter?
1
0
0
740,389
1,027,714
2009-06-22T15:05:00.000
30
0
1
0
python
1,028,096
12
false
0
0
I'm trying to use variables and settings from that file, not to invoke a separate process. Well, simply importing the file with import filename (minus .py, needs to be in the same directory or on your PYTHONPATH) will run the file, making its variables, functions, classes, etc. available in the filename.variable namespace. So if you have cheddar.py with the variable spam and the function eggs – you can import them with import cheddar, access the variable with cheddar.spam and run the function by calling cheddar.eggs() If you have code in cheddar.py that is outside a function, it will be run immediately, but building applications that runs stuff on import is going to make it hard to reuse your code. If a all possible, put everything inside functions or classes.
2
345
0
I'm trying to execute a file with Python commands from within the interpreter. EDIT: I'm trying to use variables and settings from that file, not to invoke a separate process.
How to execute a file within the Python interpreter?
1
0
0
740,389
1,027,751
2009-06-22T15:11:00.000
1
0
0
0
python,mysql,proxy
1,027,817
3
false
0
0
there are a lot of different possibilities here. the only way you're going to get a definitive answer is to talk to the person that runs the proxy. if this is a web app and the web server and the database serve are both on the other side of a proxy, then you won't need to connect to the mysql server at all since the web app will do it for you.
1
2
0
I'm using the above mentioned Python lib to connect to a MySQL server. So far I've worked locally and all worked fine, until i realized I'll have to use my program in a network where all access goes through a proxy. Does anyone now how I can set the connections managed by that lib to use a proxy? Alternatively: do you know of another Python lib for MySQL that can handle this? I also have no idea if the if the proxy server will allow access to the standard MySQL port or how I can trick it to allow it. Help on this is also welcomed.
MySQLdb through proxy
0.066568
1
0
2,939
1,027,894
2009-06-22T15:38:00.000
5
1
0
0
python,user-interface
1,027,918
3
true
0
0
You could simply launch the gui part, and catch the exception it raises when X (or any other platform dependent graphics system is not available. Make sure you really have an interactive terminal before running the text based part. Your process might have been started without a visible terminal, as is common in graphical user environments like KDE, gnome or windows.
1
6
0
Firstly, what is the best/simplest way to detect if X11 is running and available for a python script. parent process? session leader? X environment variables? other? Secondly, I would like to have a utility (python script) to present a gui if available, otherwise use a command line backed tool. Off the top of my head I thought of this -main python script (detects if gui is available and launches appropriate script) -gui or command line python script starts -both use a generic module to do actual work I am very open to suggestions to simplify this.
Detect if X11 is available (python)
1.2
0
0
3,965
1,029,033
2009-06-22T19:38:00.000
0
0
1
0
python,pyqt,qpixmap
1,116,190
1
false
0
1
It may be worth dumping the image data to a file and checking that you have all the data by loading it into an image viewer. If you get incomplete data, you may still be able to obtain a QImage and create a QPixmap, but it may be invalid.
1
4
0
I have a program that sends and receives images to each other using sockets. The server sends the image data using 'image.tostring()' and the client side receives it and turns it back into an image using 'Image.fromstring', then into a QImage using 'ImageQt.ImageQt(image)', turns it into a QPixmap using 'QPixmap.fromimage(qimage)'then updates my QWidget's QLable's image using 'lable.setPixmap(qpixmap)' Everything works fine with small images, but with images larger than 200x200, python.exe crashes and the console only shows "Process terminated with an exit code of -1073741819" and doesn't tell me what the problem is. I've isolated the problem down to 'setPixmap()' (everything else works as long as I comment out that), but I can't see what the problem is. This only happens on the client side. The server side uses the same steps going from Image to QImage to QPixmap then setPixmap, but that doesn't have any problems. Also tried making it a QBitmap and using setPixmap on the bitmap, which worked (but it's black and white so can't use it). Weird! Any help would be appreciated!
"Python.exe" crashes when PyQt's setPixmap() is called with a Pixmap
0
0
0
1,131
1,029,435
2009-06-22T21:15:00.000
0
1
0
1
php,python,gtk,desktop,pygtk
1,029,459
4
false
0
0
Why would you like to develop a desktop app in php?? Get yourself a descent programming environment (c/java/c#/) instead of abusing php especially with c# and java you get pretty quick very nice results. And both are cross platform (although java is easier for cross platform stuff). C(++) in combination with QT or GTK is also possible, but there the results appear slower
2
8
0
I have quite a few years experience of developing PHP web applications, and have recently started to delve into Python as well. Recently I've been interested in getting into desktop applications as well, but have absolutely no experience in that area. I've seen very little written about PHP-gtk and wonder whether it's really a good area to get stuck in to. What I'm really looking for is something that will allow me to quite quickly develop some decent small/medium sized apps, and be able to deploy them in Linux and Windows. Something in Python or PHP would be great (but I'd be happy to learn something else if it has big advantages). What do you guys recommend? Thanks
PHP desktop applications
0
0
0
1,720
1,029,435
2009-06-22T21:15:00.000
2
1
0
1
php,python,gtk,desktop,pygtk
1,029,486
4
false
0
0
Python and Java are both excellent for working on both Linux and Windows environment. They are generally hassle-free as long as you're not doing any OS specific type of work. Python for creating desktop apps is fairly simple and easy to learn as well if you're coming from a PHP background, especially if you're used to doing object oriented PHP.
2
8
0
I have quite a few years experience of developing PHP web applications, and have recently started to delve into Python as well. Recently I've been interested in getting into desktop applications as well, but have absolutely no experience in that area. I've seen very little written about PHP-gtk and wonder whether it's really a good area to get stuck in to. What I'm really looking for is something that will allow me to quite quickly develop some decent small/medium sized apps, and be able to deploy them in Linux and Windows. Something in Python or PHP would be great (but I'd be happy to learn something else if it has big advantages). What do you guys recommend? Thanks
PHP desktop applications
0.099668
0
0
1,720
1,030,293
2009-06-23T01:58:00.000
1
0
0
1
php,python,google-app-engine
1,030,362
3
false
1
0
You don't write user management and registration and all that, because you use Google's own authentication services. This is all included in the App Engine documentation.
1
17
0
I am newbie in Google App Engine. While I was going through the tutorial, I found several things that we do in php-mysql is not available in GAE. For example in dataStore auto increment feature is not available. Also I am confused about session management in GAE. Over all I am confused and can not visualize the whole thing. Please advise me a simple user management system with user registration, user login, user logout, session (create,manage,destroy) with data Store. Also please advise me where I can get simple but effective examples. Thanks in advance.
Simple User management example for Google App Engine?
0.066568
1
0
7,295
1,030,966
2009-06-23T06:44:00.000
0
0
1
0
python
1,031,138
4
false
0
0
What you are asking is if you can track who made changes to a file. And that's not a Python question, but a question of the operating system. To be able to track who changed a file, you need to have an auditing system installed. If you use Linux, it has an audit subsystem that you can configure to track this information, I think.
2
0
0
Suppose My system login ID is tom2deu. i have one Python program. Now i am going to modified this Python program. My question Can we print my login ID to a seprate notepad or any other file ? means can we print any person detail(login ID) who had logged the system and modified the program.
Login input
0
0
0
432
1,030,966
2009-06-23T06:44:00.000
1
0
1
0
python
1,030,996
4
false
0
0
try these.. import os print os.environ['USERNAME'] or os.getlogin() then save in a variable and use file handling to store it as a text file..
2
0
0
Suppose My system login ID is tom2deu. i have one Python program. Now i am going to modified this Python program. My question Can we print my login ID to a seprate notepad or any other file ? means can we print any person detail(login ID) who had logged the system and modified the program.
Login input
0.049958
0
0
432
1,031,438
2009-06-23T09:01:00.000
14
0
1
0
asp.net,python,django,scalability
1,031,492
4
false
1
0
Almost all the well known frameworks and languages can scale. It doesn't really matter which one you use. Its about how well you structure the code that matters most. On a personal level it is always good to know more than one language. But, you can create perfectly scalable Python, PHP, .NET applications. The quality of the code is the first place scalability will fall down not the language.
4
7
0
I am a .NET developer. I have no experience on Python. Which platform is more scalable? Which platform is more suitable for large-size high-traffic web sites? If you have any experience about scalability on these platforms, please inform us. Thank you.
Python/Django or C#/ASP.NET for web development?
1
0
0
7,667
1,031,438
2009-06-23T09:01:00.000
3
0
1
0
asp.net,python,django,scalability
1,036,254
4
false
1
0
Derek had a great answer, so I won't repeat it. I would like to make one observation, however. While for the most part, the language choice isn't really a big deal these days, if you really need high performance and scalability, the dynamic nature of python might come back to haunt you. For all the benefits that a dynamic language can provide, those benefits do come at the cost of additional overhead. The .NET platform offers fully compiled languages, and offers a variety of ways to tune the performance of compiled code (including ngen support, so you can create natively compiled modules that do not need to be JITted.) I do not know if the performance edge .NET compiled languages have over Python is really enough for your particular application, but given that you are already a .NET developer, going with ASP.NET might be the best option.
4
7
0
I am a .NET developer. I have no experience on Python. Which platform is more scalable? Which platform is more suitable for large-size high-traffic web sites? If you have any experience about scalability on these platforms, please inform us. Thank you.
Python/Django or C#/ASP.NET for web development?
0.148885
0
0
7,667
1,031,438
2009-06-23T09:01:00.000
1
0
1
0
asp.net,python,django,scalability
3,224,766
4
false
1
0
There is a added scalability cost with going with .NET over Python, the cost of Windows Server licenses (at the minimum, you usually add SQL Server to that as well).
4
7
0
I am a .NET developer. I have no experience on Python. Which platform is more scalable? Which platform is more suitable for large-size high-traffic web sites? If you have any experience about scalability on these platforms, please inform us. Thank you.
Python/Django or C#/ASP.NET for web development?
0.049958
0
0
7,667
1,031,438
2009-06-23T09:01:00.000
16
0
1
0
asp.net,python,django,scalability
1,036,216
4
true
1
0
Much as I love Python (and, that's a LOT!-), if you're highly skilled at C# and, as you say, "have no experience on Python", your code will be more scalable and suitable (for the next several months, at least) if you stick with what you know best. For a hypothetical developer extremely skilled at both platforms, scalability would essentially be a wash, and Python would enhance that developer's productivity; but getting really good at any technology takes some months of practice, it doesn't "just happen" magically. So, unless you're trying to broaden your range of skills and job opportunities, or enhance your productivity, but rather are specifically, strictly focused on the scalability of the web apps you're coding right now, I have, in good conscience, to recommend you stick with C#. You should also try IronPython (and get the great "IronPython in Action" book from Mannings -- bias alert, I'm friends with the author and was a tech reviewer of that book;-) for all sorts of non-production supporting code, to get a taste of it and the incredible productivity boost it can give you... but, to deliver best value to your clients or employers, stick with what you REALLY master, C#, for any scalability-critical work you deliver to them!
4
7
0
I am a .NET developer. I have no experience on Python. Which platform is more scalable? Which platform is more suitable for large-size high-traffic web sites? If you have any experience about scalability on these platforms, please inform us. Thank you.
Python/Django or C#/ASP.NET for web development?
1.2
0
0
7,667
1,031,659
2009-06-23T10:03:00.000
7
0
1
0
python,module,ipython
1,031,785
6
true
0
0
You should not be saving the IPython extension stuff (?, !, %run) in files. Ever. Those are interactive tools and they are something you type with your hands but never save to a file. Find the common features among your files. You have exactly four kinds of things that are candidates for this. Imports (import) Function definitions (def) Class definitions (class) Global variable assignments You must remove all IPython interactive features from this code. All of it. Rewrite your scripts so they (1) import your common stuff, (2) do the useful work they're supposed to do. You must remove all IPython interactive features from this code. All of it. Now you can run your scripts and they're do their work like proper Python scripts are supposed. You can still use IPython extension features like !, ? and %run when you're typing, but you should not save these into files.
3
4
0
I have a few IPython scripts which have redundant functionality. I would like to refactor the common functionality into one module and include that modules in the existing script. The problem is it cannot be made a python module as the code uses Ipython's language extensions (!, $ etc). Is it possible to make a module having IPython code and include it in another IPython scripts?
IPython Modules
1.2
0
0
4,260
1,031,659
2009-06-23T10:03:00.000
0
0
1
0
python,module,ipython
1,032,587
6
false
0
0
Have you had a look at the IPython module (pydoc IPython)? maybe you can access IPython's utilities through pure Python code.
3
4
0
I have a few IPython scripts which have redundant functionality. I would like to refactor the common functionality into one module and include that modules in the existing script. The problem is it cannot be made a python module as the code uses Ipython's language extensions (!, $ etc). Is it possible to make a module having IPython code and include it in another IPython scripts?
IPython Modules
0
0
0
4,260
1,031,659
2009-06-23T10:03:00.000
4
0
1
0
python,module,ipython
1,032,956
6
false
0
0
technically if you save a script with the .ipy extension, ipython will see that and use all it's fancy stuff rather than passing directly to the python interpreter. however, i would generally recommend against this, and go the route of S.Lott above.
3
4
0
I have a few IPython scripts which have redundant functionality. I would like to refactor the common functionality into one module and include that modules in the existing script. The problem is it cannot be made a python module as the code uses Ipython's language extensions (!, $ etc). Is it possible to make a module having IPython code and include it in another IPython scripts?
IPython Modules
0.132549
0
0
4,260
1,032,888
2009-06-23T14:24:00.000
0
0
0
0
c#,ironpython
1,034,326
2
false
1
0
Jonathan helped me to figure out that I had not copied the dll file to the location where IronPython can find it. After copying the dll file to the location, usually it s "c:\Program Files\IronPython 2.0\" unless stated otherwise, I did: import clr clr.AddReference('System.Data') clr.AddReferenceToFile('Sql400.dll') from System.Data import Sql400 from System.Data.Sql400 import *
2
0
0
I was just wondering if anybody knows how to add reference to "Ritmo for iSeries" in IronPython. I did it successfully in C# and get it to work (since it is just click click click) And I was trying to do the same in IronPython but it says, "could not add reference to assembly Ritmo for iSeries". I was doing import clr clr.AddReference('Ritmo for iSeries') from Ritmo........ IOError: Could not add reference to assembly Ritmo for iSeries
how to addreference to Ritmo for iSeries in ironpython
0
0
0
438
1,032,888
2009-06-23T14:24:00.000
0
0
0
0
c#,ironpython
1,032,962
2
false
1
0
You need to use the actual name of the assembly (it won't have spaces). In your C# project, what does it list under the 'references' folder once you've added it as a reference? Try putting that. Also, make sure you've copied the dll for the library to where your IronPython script can find it (if it's not in the GAC).
2
0
0
I was just wondering if anybody knows how to add reference to "Ritmo for iSeries" in IronPython. I did it successfully in C# and get it to work (since it is just click click click) And I was trying to do the same in IronPython but it says, "could not add reference to assembly Ritmo for iSeries". I was doing import clr clr.AddReference('Ritmo for iSeries') from Ritmo........ IOError: Could not add reference to assembly Ritmo for iSeries
how to addreference to Ritmo for iSeries in ironpython
0
0
0
438
1,033,367
2009-06-23T15:37:00.000
1
0
1
0
python,pylons
1,033,467
3
false
0
0
I'd say use 2.5 : there is one reason to favor 2.5 over 2.6 : if you need to be compatible with the python given on a linux installation or on Macs (I dont' know what py version mac provide, but you get the idea). Of course, if you need some feature of 2.6, please do it, but if it's not the case why require 2.6 ? Remember that your app will be hosted somewhere where restrictions apply for deployment. If you will distribute your app on opensource, even more so.
1
4
0
Which version of Python is recommended for Pylons, and why?
Pylons - use Python 2.5 or 2.6?
0.066568
0
0
1,058
1,033,897
2009-06-23T17:07:00.000
0
0
1
0
python,svn,version-control,easy-install,pip
1,446,729
4
false
0
0
easy_install accepts a URL for the source tree too. Works at least when the sources are in Subversion.
1
14
0
The simplest way to deal with python package installations, so far, to me, has been to check out the source from the source control system and then add a symbolic link in the python dist-packages folder. Clearly since source control provides the complete control to downgrade, upgrade to any branch, tag, it works very well. Is there a way using one of the Package installers (easy_install or pip or other), one can achieve the same. easy_install obtains the tar.gz and install them using the setup.py install which installs in the dist-packages folder in python2.6. Is there a way to configure it, or pip to use the source version control system (SVN/GIT/Hg/Bzr) instead.
Python package install using pip or easy_install from repos
0
0
0
10,704
1,033,934
2009-06-23T17:16:00.000
2
0
0
0
python,django,transactions
1,121,915
3
false
1
0
I came up with something similar to the Memento pattern, but different enough that I think it bears posting. When a user starts an editing session, I duplicate the target object to a temporary object in the database. All subsequent editing operations affect the duplicate. Instead of saving the object state in a memento at each change, I store operation objects. When I apply an operation to an object, it returns the inverse operation, which I store. Saving operations is much cheaper for me than mementos, since the operations can be described with a few small data items, while the object being edited is much bigger. Also I apply the operations as I go and save the undos, so that the temporary in the db always corresponds to the version in the user's browser. I never have to replay a collection of changes; the temporary is always only one operation away from the next version. To implement "undo," I pop the last undo object off the stack (as it were--by retrieving the latest operation for the temporary object from the db) apply it to the temporary and return the transformed temporary. I could also push the resultant operation onto a redo stack if I cared to implement redo. To implement "save changes," i.e. commit, I de-activate and time-stamp the original object and activate the temporary in it's place. To implement "cancel," i.e. rollback, I do nothing! I could delete the temporary, of course, because there's no way for the user to retrieve it once the editing session is over, but I like to keep the canceled edit sessions so I can run stats on them before clearing them out with a cron job.
1
8
0
I'm making a Django web-app which allows a user to build up a set of changes over a series of GETs/POSTs before committing them to the database (or reverting) with a final POST. I have to keep the updates isolated from any concurrent database users until they are confirmed (this is a configuration front-end), ruling out committing after each POST. My preferred solution is to use a per-session transaction. This keeps all the problems of remembering what's changed (and how it affects subsequent queries), together with implementing commit/rollback, in the database where it belongs. Deadlock and long-held locks are not an issue, as due to external constraints there can only be one user configuring the system at any one time, and they are well-behaved. However, I cannot find documentation on setting up Django's ORM to use this sort of transaction model. I have thrown together a minimal monkey-patch (ew!) to solve the problem, but dislike such a fragile solution. Has anyone else done this before? Have I missed some documentation somewhere? (My version of Django is 1.0.2 Final, and I am using an Oracle database.)
Per-session transactions in Django
0.132549
1
0
2,065
1,034,399
2009-06-23T18:46:00.000
0
0
0
0
python,user-interface,wxpython
5,628,847
3
false
0
1
In the case of a Button, to make a button fill its parent window when the parent window (a frame in my case) changes size, put button.SetSize(parent_window.GetSize()) in the parent window's OnSize event handling routine.
1
4
0
How do I make any wxPython widget (like wx.Panel or wx.Button) automatically expand to fill its parent window?
wxPython: Making something expand
0
0
0
3,216
1,034,846
2009-06-23T20:04:00.000
4
0
1
0
python,arrays,sorting
1,034,949
11
false
0
0
A simple modified quicksort works very well in practice. It has average running time proportional to N (though worst case bad luck running time is O(N^2)). Proceed like a quicksort. Pick a pivot value randomly, then stream through your values and see if they are above or below that pivot value and put them into two bins based on that comparison. In quicksort you'd then recursively sort each of those two bins. But for the N-th highest value computation, you only need to sort ONE of the bins.. the population of each bin tells you which bin holds your n-th highest value. So for example if you want the 125th highest value, and you sort into two bins which have 75 in the "high" bin and 150 in the "low" bin, you can ignore the high bin and just proceed to finding the 125-75=50th highest value in the low bin alone.
5
20
0
Hey. I have a very large array and I want to find the Nth largest value. Trivially I can sort the array and then take the Nth element but I'm only interested in one element so there's probably a better way than sorting the entire array...
Finding Nth item of unsorted list without sorting the list
0.072599
0
0
18,808
1,034,846
2009-06-23T20:04:00.000
3
0
1
0
python,arrays,sorting
2,129,986
11
false
0
0
You could try the Median of Medians method - it's speed is O(N).
5
20
0
Hey. I have a very large array and I want to find the Nth largest value. Trivially I can sort the array and then take the Nth element but I'm only interested in one element so there's probably a better way than sorting the entire array...
Finding Nth item of unsorted list without sorting the list
0.054491
0
0
18,808
1,034,846
2009-06-23T20:04:00.000
0
0
1
0
python,arrays,sorting
35,329,224
11
false
0
0
One thing you should do if this is in production code is test with samples of your data. For example, you might consider 1000 or 10000 elements 'large' arrays, and code up a quickselect method from a recipe. The compiled nature of sorted, and its somewhat hidden and constantly evolving optimizations, make it faster than a python written quickselect method on small to medium sized datasets (< 1,000,000 elements). Also, you might find as you increase the size of the array beyond that amount, memory is more efficiently handled in native code, and the benefit continues. So, even if quickselect is O(n) vs sorted's O(nlogn), that doesn't take into account how many actual machine code instructions processing each n elements will take, any impacts on pipelining, uses of processor caches and other things the creators and maintainers of sorted will bake into the python code.
5
20
0
Hey. I have a very large array and I want to find the Nth largest value. Trivially I can sort the array and then take the Nth element but I'm only interested in one element so there's probably a better way than sorting the entire array...
Finding Nth item of unsorted list without sorting the list
0
0
0
18,808
1,034,846
2009-06-23T20:04:00.000
3
0
1
0
python,arrays,sorting
1,034,864
11
false
0
0
You can iterate the entire sequence maintaining a list of the 5 largest values you find (this will be O(n)). That being said I think it would just be simpler to sort the list.
5
20
0
Hey. I have a very large array and I want to find the Nth largest value. Trivially I can sort the array and then take the Nth element but I'm only interested in one element so there's probably a better way than sorting the entire array...
Finding Nth item of unsorted list without sorting the list
0.054491
0
0
18,808
1,034,846
2009-06-23T20:04:00.000
1
0
1
0
python,arrays,sorting
1,034,863
11
false
0
0
Use heapsort. It only partially orders the list until you draw the elements out.
5
20
0
Hey. I have a very large array and I want to find the Nth largest value. Trivially I can sort the array and then take the Nth element but I'm only interested in one element so there's probably a better way than sorting the entire array...
Finding Nth item of unsorted list without sorting the list
0.01818
0
0
18,808
1,035,825
2009-06-23T23:40:00.000
1
0
0
0
python
1,035,855
5
false
1
0
Like Cobbal stated, this is largely what wget is designed to do. I believe there's some flags/arguments that you can set to make it download the entire page, CSS + all. I suggest just alias-ing into something more convenient to type, or tossing it into a quick script.
1
3
0
I am tired of clicking "File" and then "Save Page As" in Firefox when I want to save some websites. Is there any script to do this in Python? I would like to save the pictures and css files so that when I read it offline, it looks normal.
Any Python Script to Save Websites Like Firefox?
0.039979
0
1
2,633
1,036,660
2009-06-24T06:15:00.000
0
0
0
0
python,html,bots
1,036,758
7
false
1
0
Well obviously python won't interpret the JS for you (though there may be modules out there that can). I suppose you need to convert the JS instructions to equivalent transformations in Python. I suppose ElementTree or BeautifulSoup would be good starting points to interpret the HTML structure.
2
3
0
I am trying to write a Python-based Web Bot that can read and interpret an HTML page, then execute an onClick function and receive the resulting new HTML page. I can already read the HTML page and I can determine the functions to be called by the onClick command, but I have no idea how to execute those functions or how to receive the resulting HTML code. Any ideas?
Python Web-based Bot
0
0
1
6,042
1,036,660
2009-06-24T06:15:00.000
0
0
0
0
python,html,bots
5,873,989
7
false
1
0
Why don't you just sniff what gets sent after the onclick event and replicate that with your bot?
2
3
0
I am trying to write a Python-based Web Bot that can read and interpret an HTML page, then execute an onClick function and receive the resulting new HTML page. I can already read the HTML page and I can determine the functions to be called by the onClick command, but I have no idea how to execute those functions or how to receive the resulting HTML code. Any ideas?
Python Web-based Bot
0
0
1
6,042
1,037,090
2009-06-24T08:30:00.000
1
0
0
0
python,python-imaging-library
1,037,217
1
false
0
0
I don't think there are methods that give you a metric exactly for what you want, but the methods that it has, like RMS, takes you a long way there. To do things with color, you can split the image into one layer per color, and get the RMS on each layer, which tells you some of the things you want to know. You can also convert the image in different ways so that you only retain color information, etc.
1
4
1
I want to process uploaded photos with PIL and determine some "soft" image metrics like: is the image contrastful or dull? colorful or monochrome? bright or dark? is the image warm or cold (regarding light temperature)? is there a dominant hue? the metrics should be measured in a rating-style, e.g. colorful++++ for a very colorful photo, colorful+ for a rather monochrome image. I already noticed PIL's ImageStat Module, that calculates some interesting values for my metrics, e.g. RMS of histogram etc. However, this module is rather poorly documented, so I'm looking for more concrete algorithms to determine these metrics.
Simple Image Metrics with PIL
0.197375
0
0
609
1,037,673
2009-06-24T10:58:00.000
8
0
0
0
python,tkinter,pyqt,pygtk,pyobjc
1,037,851
9
false
0
1
Tkinter is part of the python standard distribution and is installed by default. Expect to find this on all python installs where there is a graphical display in the first place.
6
9
0
Python has a lot of GUI libraries: tkinter, wxWidgets, pyGTK etc. But all these GUIs need to be installed and quite heavyweight, so it's a bit complex to deploy end-user GUI python apps that relay on mentioned GUI libraries. Recently, I have thought about python's built-in ctypes module. Theoretically, it's possible to create a pure python GUI library that will use ctypes on windows ( windll.user32.CreateWindowEx, etc ), native pyObjC on MacOS and pyGTK / pyQt on gnome / kde. Does such a library exist? If not, what do you think is wrong with this idea?
Pure python gui library?
1
0
0
5,803
1,037,673
2009-06-24T10:58:00.000
6
0
0
0
python,tkinter,pyqt,pygtk,pyobjc
1,038,265
9
false
0
1
Notion of "pure python gui library" is wrong because ultimately you will be using system level calls and widgets, may be thru ctypes but that doesn't change the fact that if you start implementing your idea you will eventually become wxPython
6
9
0
Python has a lot of GUI libraries: tkinter, wxWidgets, pyGTK etc. But all these GUIs need to be installed and quite heavyweight, so it's a bit complex to deploy end-user GUI python apps that relay on mentioned GUI libraries. Recently, I have thought about python's built-in ctypes module. Theoretically, it's possible to create a pure python GUI library that will use ctypes on windows ( windll.user32.CreateWindowEx, etc ), native pyObjC on MacOS and pyGTK / pyQt on gnome / kde. Does such a library exist? If not, what do you think is wrong with this idea?
Pure python gui library?
1
0
0
5,803
1,037,673
2009-06-24T10:58:00.000
4
0
0
0
python,tkinter,pyqt,pygtk,pyobjc
1,037,740
9
false
0
1
For one thing, all those libraries use different abstractions, so anything that worked with all of them is likely to wind up supporting a least-common-denominator set of functionality, or doing a LOT of work to use each to its fullest.
6
9
0
Python has a lot of GUI libraries: tkinter, wxWidgets, pyGTK etc. But all these GUIs need to be installed and quite heavyweight, so it's a bit complex to deploy end-user GUI python apps that relay on mentioned GUI libraries. Recently, I have thought about python's built-in ctypes module. Theoretically, it's possible to create a pure python GUI library that will use ctypes on windows ( windll.user32.CreateWindowEx, etc ), native pyObjC on MacOS and pyGTK / pyQt on gnome / kde. Does such a library exist? If not, what do you think is wrong with this idea?
Pure python gui library?
0.088656
0
0
5,803