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
397,337
2008-12-29T08:41:00.000
0
0
0
0
python,scripting,wxpython,wxwidgets,maya
30,247,511
3
false
0
1
The best way to go is creating a QWidget with what you need, and using it from within a MPxCommand thru the C++ API. That way you also have the chance to inject complete custom editors into Maya via scriptedPanels. But if you're bound to Python, pyQt is the way to go.
2
8
0
I develop tools in Autodesk Maya. Many of the tools I build have simple windowed GUIs for the animators and modellers to use. These GUIs often contain what you'd normally expect to see in any basic window; labels, lists, menus, buttons, textfields, etc. However, there are limitations to the complexity of the UIs you can build with the available tools, specifically in the types of available widgets. I'm interested in using some of the more advanced wxPython widgets such as the ListView (grid), Tree, etc. This would involve using a complete wxFrame (window) to display the whole UI, which would essentially mean that window would no longer be tied to Maya. Not a deal breaker, but it means when Maya is minimized, the window won't follow suit. I've tried something like this before with tkinter as a test, but found that it needed a MainLoop to run in its own thread. This is logical, but in my case, it conflicts with Maya's own thread, essentially making Maya hang until the window is closed. This is due to the fact that Maya runs all scripts, be they MEL or Python, in a single thread that the main Maya GUI shares. This is to prevent one script from, say, deleting an object while another script is trying to do work on the same object. wxPython has this same "mainloop" methodolgy. I'm wondering if there's any way around it so that it can work within Maya?
Using external GUI libraries to make user interfaces in Autodesk Maya
0
0
0
3,503
397,337
2008-12-29T08:41:00.000
0
0
0
0
python,scripting,wxpython,wxwidgets,maya
398,469
3
false
0
1
I don't know if there is a way around a mainloop for the gui, since it is needed to handle all event chains and redraw queues. But there are several means of inter-process communication, like pipes or semaphores. Maybe it is an option to split your Maya extension into the actual plugin, being tight into maya, and a separate application for the gui. These two could use such means to communicate and exchange model information between plugin and gui. I'm not sure, however, if I can really recommend this approach because it very much complicates the application. You could have a look at IPython, an interactive Python shell, whose dev team has put some effort into integrating it with wxPython. They have some way of interrupting the event loop and hooking into it to do their own stuff.
2
8
0
I develop tools in Autodesk Maya. Many of the tools I build have simple windowed GUIs for the animators and modellers to use. These GUIs often contain what you'd normally expect to see in any basic window; labels, lists, menus, buttons, textfields, etc. However, there are limitations to the complexity of the UIs you can build with the available tools, specifically in the types of available widgets. I'm interested in using some of the more advanced wxPython widgets such as the ListView (grid), Tree, etc. This would involve using a complete wxFrame (window) to display the whole UI, which would essentially mean that window would no longer be tied to Maya. Not a deal breaker, but it means when Maya is minimized, the window won't follow suit. I've tried something like this before with tkinter as a test, but found that it needed a MainLoop to run in its own thread. This is logical, but in my case, it conflicts with Maya's own thread, essentially making Maya hang until the window is closed. This is due to the fact that Maya runs all scripts, be they MEL or Python, in a single thread that the main Maya GUI shares. This is to prevent one script from, say, deleting an object while another script is trying to do work on the same object. wxPython has this same "mainloop" methodolgy. I'm wondering if there's any way around it so that it can work within Maya?
Using external GUI libraries to make user interfaces in Autodesk Maya
0
0
0
3,503
399,326
2008-12-30T01:57:00.000
0
0
1
0
python,python-3.x,tix
400,066
3
false
0
0
Generally speaking, if you're using third-party modules, you're better off avoiding Python 3.0 for now. If you're working on a third-party module yourself, porting forward to Python 3.0 is a good idea, but for the time being general development in it is just going to be a recipe for pain.
1
0
0
Has anyone seen anything in Tix work under python 3.0? I've tried to work through the examples but when creating anything it states that cnf is unsubscriptable. I also noticed that none of the Dir Select stuff (DirList DirTree) works under 2.6.1. Why doesn't Python either dump Tix or support it? Its got a lot of good stuff to make easy programs.
Tix and Python 3.0
0
0
0
1,490
399,980
2008-12-30T10:48:00.000
3
0
0
0
python,xml,minidom
400,669
3
false
0
0
It should be noted that while HTML looks like XML it is not XML. XHTML is an XML form of HTML.
1
6
0
I am using XML minidom (xml.dom.minidom) in Python, but any error in the XML will kill the parser. Is it possible to ignore them, like a browser for example? I am trying to write a browser in Python, but it just throws an exception if the tags aren't fully compatible.
Ignoring XML errors in Python
0.197375
0
1
4,564
400,050
2008-12-30T11:22:00.000
2
0
1
0
python
400,060
6
false
0
0
If you are receiving an expression as a string you'll need to parse it into its operators and operands and then process the resulting tree. This isn't a python problem per se. but a general issue of how to deal with mathematical expressions delivered as strings. A quick google reveals a bunch of lexical parsers for python.
1
5
0
Using Python, how would I go about reading in (be from a string, file or url) a mathematical expression (1 + 1 is a good start) and executing it? Aside from grabbing a string, file or url I have no idea of where to start with this.
Reading and running a mathematical expression in Python
0.066568
0
0
4,016
401,215
2008-12-30T19:30:00.000
1
0
1
0
python,web-services,rate-limiting
401,826
6
false
1
0
SO I am assuming something simple like import time time.sleep(2) will not work for waiting 2 seconds between requests
3
18
0
I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds specified passes. I understand that the general scenario is the following: an instance of the class makes a request via a method. When it does, the method emits some signal that sets a lock variable somewhere, and begins a countdown timer for the number of seconds in limit. (In all likelihood, the lock is the countdown timer itself.) If another request is made within this time frame, it must be queued until the countdown timer reaches zero and the lock is disengaged; at this point, the oldest request on the queue is sent, and the countdown timer is reset and the lock is re-engaged. Is this a case for threading? Is there another approach I'm not seeing? Should the countdown timer and lock be instance variables, or should they belong to the class, such that all instances of the class hold requests? Also, is this generally a bad idea to provide rate-limiting functionality within a library? I reason since, by default, the countdown is zero seconds, the library still allows developers to use the library and provide their own rate-limiting schemes. Given any developers using the service will need to rate-limit requests anyway, however, I figure that it would be a convenience for the library to provide a means of rate-limiting. Regardless of placing a rate-limiting scheme in the library or not, I'll want to write an application using the library, so suggested techniques will come in handy.
How to limit rate of requests to web services in Python?
0.033321
0
1
17,294
401,215
2008-12-30T19:30:00.000
1
0
1
0
python,web-services,rate-limiting
401,332
6
false
1
0
Your rate limiting scheme should be heavily influenced by the calling conventions of the underlying code (syncronous or async), as well as what scope (thread, process, machine, cluster?) this rate-limiting will operate at. I would suggest keeping all the variables within the instance, so you can easily implement multiple periods/rates of control. Lastly, it sounds like you want to be a middleware component. Don't try to be an application and introduce threads on your own. Just block/sleep if you are synchronous and use the async dispatching framework if you are being called by one of them.
3
18
0
I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds specified passes. I understand that the general scenario is the following: an instance of the class makes a request via a method. When it does, the method emits some signal that sets a lock variable somewhere, and begins a countdown timer for the number of seconds in limit. (In all likelihood, the lock is the countdown timer itself.) If another request is made within this time frame, it must be queued until the countdown timer reaches zero and the lock is disengaged; at this point, the oldest request on the queue is sent, and the countdown timer is reset and the lock is re-engaged. Is this a case for threading? Is there another approach I'm not seeing? Should the countdown timer and lock be instance variables, or should they belong to the class, such that all instances of the class hold requests? Also, is this generally a bad idea to provide rate-limiting functionality within a library? I reason since, by default, the countdown is zero seconds, the library still allows developers to use the library and provide their own rate-limiting schemes. Given any developers using the service will need to rate-limit requests anyway, however, I figure that it would be a convenience for the library to provide a means of rate-limiting. Regardless of placing a rate-limiting scheme in the library or not, I'll want to write an application using the library, so suggested techniques will come in handy.
How to limit rate of requests to web services in Python?
0.033321
0
1
17,294
401,215
2008-12-30T19:30:00.000
2
0
1
0
python,web-services,rate-limiting
401,390
6
false
1
0
Queuing may be overly complicated. A simpler solution is to give your class a variable for the time the service was last called. Whenever the service is called (!1), set waitTime to delay - Now + lastcalltime. delay should be equal to the minimum allowable time between requests. If this number is positive, sleep for that long before making the call (!2). The disadvantage/advantage of this approach is that it treats the web service requests as being synchronous. The advantage is that it is absurdly simple and easy to implement. (!1): Should happen right after receiving a response from the service, inside the wrapper (probably at the bottom of the wrapper). (!2): Should happen when the python wrapper around the web service is called, at the top of the wrapper. S.Lott's solution is more elegant, of course.
3
18
0
I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds specified passes. I understand that the general scenario is the following: an instance of the class makes a request via a method. When it does, the method emits some signal that sets a lock variable somewhere, and begins a countdown timer for the number of seconds in limit. (In all likelihood, the lock is the countdown timer itself.) If another request is made within this time frame, it must be queued until the countdown timer reaches zero and the lock is disengaged; at this point, the oldest request on the queue is sent, and the countdown timer is reset and the lock is re-engaged. Is this a case for threading? Is there another approach I'm not seeing? Should the countdown timer and lock be instance variables, or should they belong to the class, such that all instances of the class hold requests? Also, is this generally a bad idea to provide rate-limiting functionality within a library? I reason since, by default, the countdown is zero seconds, the library still allows developers to use the library and provide their own rate-limiting schemes. Given any developers using the service will need to rate-limit requests anyway, however, I figure that it would be a convenience for the library to provide a means of rate-limiting. Regardless of placing a rate-limiting scheme in the library or not, I'll want to write an application using the library, so suggested techniques will come in handy.
How to limit rate of requests to web services in Python?
0.066568
0
1
17,294
402,217
2008-12-31T03:18:00.000
2
0
0
0
python,django,django-models,orm,persistence
402,387
14
false
1
0
Think it over, and find the commonalities of each data set... then define your model. It may require the use of subclasses or not. Foreign keys representing commonalities aren't to be avoided, but encouraged when they make sense. Stuffing random data into a SQL table is not smart, unless it's truly non-relational data. If that's the case, define your problem and we may be able to help.
1
66
0
I need to store some data in a Django model. These data are not equal to all instances of the model. At first I thought about subclassing the model, but I’m trying to keep the application flexible. If I use subclasses, I’ll need to create a whole class each time I need a new kind of object, and that’s no good. I’ll also end up with a lot of subclasses only to store a pair of extra fields. I really feel that a dictionary would be the best approach, but there’s nothing in the Django documentation about storing a dictionary in a Django model (or I can’t find it). Any clues?
How to store a dictionary on a Django Model?
0.028564
0
0
73,533
402,359
2008-12-31T05:26:00.000
2
0
1
0
python
928,621
12
false
0
0
I just uninstalled a python package, and even though I'm not certain I did so perfectly, I'm reasonably confident. I started by getting a list of all python-related files, ordered by date, on the assumption that all of the files in my package will have more or less the same timestamp, and no other files will. Luckily, I've got python installed under /opt/Python-2.6.1; if I had been using the Python that comes with my Linux distro, I'd have had to scour all of /usr, which would have taken a long time. Then I just examined that list, and noted with relief that all the stuff that I wanted to nuke consisted of one directory, /opt/Python-2.6.1/lib/python2.6/site-packages/module-name/, and one file, /opt/Python-2.6.1/lib/python2.6/site-packages/module-x.x.x_blah-py2.6.egg-info. So I just deleted those. Here's how I got the date-sorted list of files: find "$@" -printf '%T@ ' -ls | sort -n | cut -d\ -f 2- (I think that's got to be GNU "find", by the way; the flavor you get on OS X doesn't know about "-printf '%T@'") I use that all the time.
6
95
0
Can you simply delete the directory from your python installation, or are there any lingering files that you must delete?
How do you uninstall a python package that was installed using distutils?
0.033321
0
0
124,156
402,359
2008-12-31T05:26:00.000
3
0
1
0
python
4,524,074
12
false
0
0
For Windows 7, Control Panel --> Programs --> Uninstall , then choose the python package to remove.
6
95
0
Can you simply delete the directory from your python installation, or are there any lingering files that you must delete?
How do you uninstall a python package that was installed using distutils?
0.049958
0
0
124,156
402,359
2008-12-31T05:26:00.000
-1
0
1
0
python
61,750,221
12
false
0
0
ERROR: flake8 3.7.9 has requirement pycodestyle<2.6.0,>=2.5.0, but you'll have pycodestyle 2.3.1 which is incompatible. ERROR: nuscenes-devkit 1.0.8 has requirement motmetrics<=1.1.3, but you'll have motmetrics 1.2.0 which is incompatible. Installing collected packages: descartes, future, torch, cachetools, torchvision, flake8-import-order, xmltodict, entrypoints, flake8, motmetrics, nuscenes-devkit Attempting uninstall: torch Found existing installation: torch 1.0.0 Uninstalling torch-1.0.0: Successfully uninstalled torch-1.0.0 Attempting uninstall: torchvision Found existing installation: torchvision 0.2.1 Uninstalling torchvision-0.2.1: Successfully uninstalled torchvision-0.2.1 Attempting uninstall: entrypoints Found existing installation: entrypoints 0.2.3 ERROR: Cannot uninstall 'entrypoints'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. Then I type: conda uninstall entrypoints pip install --upgrade pycodestyle pip install nuscenes-devkit Done!
6
95
0
Can you simply delete the directory from your python installation, or are there any lingering files that you must delete?
How do you uninstall a python package that was installed using distutils?
-0.016665
0
0
124,156
402,359
2008-12-31T05:26:00.000
20
0
1
0
python
403,563
12
false
0
0
The three things that get installed that you will need to delete are: Packages/modules Scripts Data files Now on my linux system these live in: /usr/lib/python2.5/site-packages /usr/bin /usr/share But on a windows system they are more likely to be entirely within the Python distribution directory. I have no idea about OSX except it is more likey to follow the linux pattern.
6
95
0
Can you simply delete the directory from your python installation, or are there any lingering files that you must delete?
How do you uninstall a python package that was installed using distutils?
1
0
0
124,156
402,359
2008-12-31T05:26:00.000
9
0
1
0
python
405,406
12
false
0
0
Yes, it is safe to simply delete anything that distutils installed. That goes for installed folders or .egg files. Naturally anything that depends on that code will no longer work. If you want to make it work again, simply re-install. By the way, if you are using distutils also consider using the multi-version feature. It allows you to have multiple versions of any single package installed. That means you do not need to delete an old version of a package if you simply want to install a newer version.
6
95
0
Can you simply delete the directory from your python installation, or are there any lingering files that you must delete?
How do you uninstall a python package that was installed using distutils?
1
0
0
124,156
402,359
2008-12-31T05:26:00.000
14
0
1
0
python
8,471,143
12
false
0
0
Another time stamp based hack: Create an anchor: touch /tmp/ts Reinstall the package to be removed: python setup.py install --prefix=<PREFIX> Remove files what are more recent than the anchor file: find <PREFIX> -cnewer /tmp/ts | xargs rm -r
6
95
0
Can you simply delete the directory from your python installation, or are there any lingering files that you must delete?
How do you uninstall a python package that was installed using distutils?
1
0
0
124,156
402,504
2008-12-31T07:58:00.000
-36
0
1
0
python,types
54,771,749
19
false
0
0
Just do not do it. Asking for something's type is wrong in itself. Instead use polymorphism. Find or if necessary define by yourself the method that does what you want for any possible type of input and just call it without asking about anything. If you need to work with built-in types or types defined by a third-party library, you can always inherit from them and use your own derivatives instead. Or you can wrap them inside your own class. This is the object-oriented way to resolve such problems. If you insist on checking exact type and placing some dirty ifs here and there, you can use __class__ property or type function to do it, but soon you will find yourself updating all these ifs with additional cases every two or three commits. Doing it the OO way prevents that and lets you only define a new class for a new type of input instead.
3
2,000
0
How do I see the type of a variable? (e.g. unsigned 32 bit)
How to determine a Python variable's type?
-1
0
0
3,479,491
402,504
2008-12-31T07:58:00.000
12
0
1
0
python,types
403,093
19
false
0
0
It really depends on what level you mean. In Python 2.x, there are two integer types, int (constrained to sys.maxint) and long (unlimited precision), for historical reasons. In Python code, this shouldn't make a bit of difference because the interpreter automatically converts to long when a number is too large. If you want to know about the actual data types used in the underlying interpreter, that's implementation dependent. (CPython's are located in Objects/intobject.c and Objects/longobject.c.) To find out about the systems types look at cdleary answer for using the struct module.
3
2,000
0
How do I see the type of a variable? (e.g. unsigned 32 bit)
How to determine a Python variable's type?
1
0
0
3,479,491
402,504
2008-12-31T07:58:00.000
17
0
1
0
python,types
402,516
19
false
0
0
Python doesn't have such types as you describe. There are two types used to represent integral values: int, which corresponds to platform's int type in C, and long, which is an arbitrary precision integer (i.e. it grows as needed and doesn't have an upper limit). ints are silently converted to long if an expression produces result which cannot be stored in int.
3
2,000
0
How do I see the type of a variable? (e.g. unsigned 32 bit)
How to determine a Python variable's type?
1
0
0
3,479,491
403,527
2008-12-31T17:20:00.000
0
0
0
0
python,sql
403,848
6
false
0
0
Here is an example of inner joining two tables based on a common field in both tables. SELECT table1.Products FROM table1 INNER JOIN table2 on table1.barcode = table2.barcode WHERE table1.Products is not null
2
0
0
I'm wondering, is it possible to make an sql query that does the same function as 'select products where barcode in table1 = barcode in table2'. I am writing this function in a python program. Once that function is called will the table be joined permanently or just while that function is running? thanks.
Making a SQL Query in two tables
0
1
0
680
403,527
2008-12-31T17:20:00.000
0
0
0
0
python,sql
403,904
6
false
0
0
Here's a way to talk yourself through table design in these cases, based on Object Role Modeling. (Yes, I realize this is only indirectly related to the question.) You have products and barcodes. Products are uniquely identified by Product Code (e.g. 'A2111'; barcodes are uniquely identified by Value (e.g. 1002155061). A Product has a Barcode. Questions: Can a product have no barcode? Can the same product have multiple barcodes? Can multiple products have the same barcode? (If you have any experience with UPC labels, you know the answer to all these is TRUE.) So you can make some assertions: A Product (code) has zero or more Barcode (value). A Barcode (value) has one or more Product (code). -- assumption: we barcodes don't have independent existence if they aren't/haven't been/won't be related to products). Which leads directly (via your ORM model) to a schema with two tables: Product ProductCode(PK) Description etc ProductBarcode ProductCode(FK) BarcodeValue -- with a two-part natural primary key, ProductCode + BarcodeValue and you tie them together as described in the other answers. Similar assertions can be used to determine which fields go into various tables in your design.
2
0
0
I'm wondering, is it possible to make an sql query that does the same function as 'select products where barcode in table1 = barcode in table2'. I am writing this function in a python program. Once that function is called will the table be joined permanently or just while that function is running? thanks.
Making a SQL Query in two tables
0
1
0
680
404,346
2009-01-01T00:55:00.000
5
0
1
0
python,math
404,587
11
false
0
0
Just a footnote on the other answers that used floating point; starting with the largest divisor and iterating downward (toward the reciprocals with largest value) will put off accumulated round-off error as much as possible.
2
8
0
Does anyone know how to write a program in Python that will calculate the addition of the harmonic series. i.e. 1 + 1/2 +1/3 +1/4...
Python program to calculate harmonic series
0.090659
0
0
22,477
404,346
2009-01-01T00:55:00.000
4
0
1
0
python,math
404,364
11
false
0
0
The harmonic series diverges, i.e. its sum is infinity.. edit: Unless you want partial sums, but you weren't really clear about that.
2
8
0
Does anyone know how to write a program in Python that will calculate the addition of the harmonic series. i.e. 1 + 1/2 +1/3 +1/4...
Python program to calculate harmonic series
0.072599
0
0
22,477
405,165
2009-01-01T17:12:00.000
0
1
0
0
python,ruby,lisp
405,577
12
false
1
0
pick the most popular one for your domain so your work gets the most visibility. some might say ruby/rails for web, python for everything else. picking a language just because its like lisp is really not appropriate for a professional.
6
21
0
I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature. Which one is closer to LISP: Python or Ruby? I can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression? PS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python/Django and back.
Please advise on Ruby vs Python, for someone who likes LISP a lot
0
0
0
5,716
405,165
2009-01-01T17:12:00.000
3
1
0
0
python,ruby,lisp
405,382
12
false
1
0
I am a Pythonista; however, based on your requirements, especially the "cool hacks on the language level", I would suggest you work on Ruby. Ruby is more flexible in the Perl way and you can do a lot of hacks; Python is targeted towards readability, which is a very good thing, and generally language hacks are a little frowned upon. Ruby's basic types can be modified in a hackish way that typically prototype languages allow, while Python's basic types are more suited for subclassing. By the way, I would add a minor correction: both Ruby and Python are very, very object-oriented, and neither is intended to be used for quick-and-dirty scripts the Perl way. Among the two, Ruby is syntactically more similar to Perl than Python.
6
21
0
I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature. Which one is closer to LISP: Python or Ruby? I can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression? PS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python/Django and back.
Please advise on Ruby vs Python, for someone who likes LISP a lot
0.049958
0
0
5,716
405,165
2009-01-01T17:12:00.000
1
1
0
0
python,ruby,lisp
405,317
12
false
1
0
If you need Unicode support, remember to check how well supported it is. AFAIK, Python's support for Unicode is better than Ruby's, especially since Python 3.0. On the other hand, Python 3 is still missing some popular packages and 3rd party libraries, so that might play against.
6
21
0
I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature. Which one is closer to LISP: Python or Ruby? I can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression? PS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python/Django and back.
Please advise on Ruby vs Python, for someone who likes LISP a lot
0.016665
0
0
5,716
405,165
2009-01-01T17:12:00.000
0
1
0
0
python,ruby,lisp
405,474
12
false
1
0
I'm a Rubyist who chose the language based on very similar criteria. Python is a good language and I enjoy working with it too, but I think Ruby is somewhat more Lispy in the degree of freedom it gives to the programmer. Python seems to impose its opinions a little bit more (which can be a good thing, but isn't according to our criteria here). Python certainly isn't more Perlish— Ruby is essentially a Smalltalk/Perl mashup (some of its less-used features are pulled directly from Perl), whereas Python is only distantly related to either.
6
21
0
I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature. Which one is closer to LISP: Python or Ruby? I can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression? PS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python/Django and back.
Please advise on Ruby vs Python, for someone who likes LISP a lot
0
0
0
5,716
405,165
2009-01-01T17:12:00.000
8
1
0
0
python,ruby,lisp
405,310
12
false
1
0
Both Ruby and Python are fairly distant from the Lisp traditions of immutable data, programs as data, and macros. But Ruby is very nearly a clone of Smalltalk (and I hope will grow more like Smalltalk as the Perlish cruft is deprecated), and Smalltalk, like Lisp, is a language that takes one idea to extremes. Based on your desire to do cool hacks on the language level I'd go with Ruby, as it inherits a lot of the metaprogramming mindset from Smalltalk, and that mindset is connected to the Lisp tradition.
6
21
0
I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature. Which one is closer to LISP: Python or Ruby? I can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression? PS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python/Django and back.
Please advise on Ruby vs Python, for someone who likes LISP a lot
1
0
0
5,716
405,165
2009-01-01T17:12:00.000
12
1
0
0
python,ruby,lisp
405,228
12
false
1
0
Speaking as a "Rubyist", I'd agree with Kiv. The two languages both grant a nice amount of leeway when it comes to programming paradigms, but are also have benefits/shortcomings. I think that the compromises you make either way are a lot about your own programming style and taste. Personally, I think Ruby can read more like pseudo-code than Python. First, Python has active whitespace, which while elegant in the eyes of many, doesn't tend to enter the equation when writing pseudo-code. Also, Ruby's syntax is quite flexible. That flexibility causes a lot of quirks that can confuse, but also allows code that's quite expressive and pretty to look at. Finally, I'd really say that Ruby feels more Perl-ish to me. That's partly because I'm far more comfortable with it, so I can hack out scripts rather quickly. A lot of Ruby's syntax was borrowed from Perl though, and I haven't seen much Python code that feels similar (though again, I have little experience with Python). Depending on the approach to web programming you'd like to take, I think that the types of web frameworks available in each language could perhaps be a factor in deciding as well. I'd say try them both. You can get a working knowledge of each of them in an afternoon, and while you won't be writing awesome Ruby or Python, you can probably establish a feel for each, and decide which you like more. Update: I think your question should actually be two separate discussions: one with Ruby, one with Python. The comparisons are less important because you start debating the merits of the differences, as opposed to which language will work better for you. If you have questions about Ruby, I'd be more than happy to answer as best I can.
6
21
0
I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature. Which one is closer to LISP: Python or Ruby? I can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression? PS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python/Django and back.
Please advise on Ruby vs Python, for someone who likes LISP a lot
1
0
0
5,716
405,282
2009-01-01T18:47:00.000
8
0
1
0
python,class,object,multiple-instances
405,292
5
false
0
0
Hm, well you normally just stuff all those instances in a list and then iterate over that list if you want to do something with them. If you want to automatically keep track of each instance created you can also make the adding to the list implicit in the class' constructor or create a factory method that keeps track of the created instances.
1
4
0
I am trying to write a life simulation in python with a variety of animals. It is impossible to name each instance of the classes I am going to use because I have no way of knowing how many there will be. So, my question: How can I automatically give a name to an object? I was thinking of creating a "Herd" class which could be all the animals of that type alive at the same time...
Many instances of a class
1
0
0
6,007
408,039
2009-01-02T21:08:00.000
-2
0
0
1
python,windows,subprocess,popen
408,049
2
false
0
0
I don't have a windows box around, so this is untested, but I'd be tempted to try the os.dup and os.dup2 methods; duplicate the file descriptors and use those instead of the parent ones.
1
1
0
Python's subprocess module by default passes all open file descriptors to any child processes it spawns. This means that if the parent process is listening on a port, and is killed, it cannot restart and begin listening again (even using SO_REUSEADDR) because the child is still in possession of that descriptor. I have no control over the child process. The subprocess POpen constructor does accept a close_fds argument, which would close descriptors on the child, just as I want. However, there is a restriction, only on Windows, that prevents it from being used if stdin/stdout are also overridden, which I need to do. Does anyone know of a work-around for this on Windows?
Prevent Python subprocess from passing fds on Windows?
-0.197375
0
0
671
408,334
2009-01-02T23:49:00.000
2
0
0
0
python,windows,winapi,controls
409,110
2
true
0
1
Above answers are completely wrong and don't even know what is a PAS. This has been answered hundreds of times for 20 years on Usenet. You must use IPC of course (RPM) ask on news://comp.os.ms-windows.programmer.win32 for code.
1
1
0
More particularly - I have a window handle of another running application. This application contains a TListControl.UnicodeClass control somewhere (I know this from Winspector). How can I, using the Windows API and that window handle, go through all the items in that list control and get the text from all of the items? You can assume the language is C/C++, though I'll actually be using win32all for python. References to the appropriate API calls would be great.
In Windows, how can I enumerate and get text from another window's controls?
1.2
0
0
1,808
409,677
2009-01-03T19:37:00.000
3
0
0
1
python,macos,wxpython,compatibility
409,702
1
true
0
0
Tiger shipped with Python 2.3.5 and wxPython 2.5.3, Leopard ships with python 2.5.1 and wxPython 2.8.4. wxPython was not shipped with previous versions. OSX Lion has 2.7.1
1
0
0
I'd like to know what versions of Python and wxPython correspond to each version of OSX. I'm interested to know exactly how far back some of my apps will remain compatible on a mac before having to install newer versions of Python and wxPython.
What versions of Python and wxPython correspond to each version of OSX?
1.2
0
0
412
409,949
2009-01-03T21:59:00.000
0
1
0
0
python,mp3,metadata,id3,albumart
1,961,919
5
false
0
0
A nice small CLI tool which helped me a lot with checking what I did while developing id3 stuff is mid3v2 which is the mutagen version of id3v2. It comes bundled with the Python mutagen library. The source of this little tool gave me also lots of answers about how to use mutagen.
1
32
0
I've been using mutagen for reading and writing MP3 tags, but I want to be able to embed album art directly into the file.
How do you embed album art into an MP3 using Python?
0
0
0
21,737
410,183
2009-01-04T00:49:00.000
0
1
0
0
php,python,ruby,artificial-intelligence,recommendation-engine
7,620,095
5
false
1
0
I happen to know a world-class expert in machine learning. He likes Prolog, especially for the higher level logic of the system. Hadn't even heard anyone mention that in a long time. Personally, I like Java. But if you're going to do intensive machine learning, you should be concerned about the speed of math processing. C++ for the math, in my view.
4
0
0
For something like a personal recommendation system, machine learning type of stuff on a website, what language would be best?
Interested in Collective Programming for the web -- Ruby or Python or PHP?
0
0
0
2,360
410,183
2009-01-04T00:49:00.000
-2
1
0
0
php,python,ruby,artificial-intelligence,recommendation-engine
636,664
5
false
1
0
I recently did some research into this for a project at my day job. It was for a recommendation system and the options were php,perl or python. PHP was out almost immediately, there were no good 3rd party open source libraries and the language itself is not as well suited to any kind of complex real programming. Python had a few libraries that i wanted to try out and Perl didn't, so I went with Python. In the end, none of those libraries were useful to me but besides library support I prefer python personally anyway so that was the right decision. Because your question is very vague I can only suggest that you don't use PHP and select the language based on library support for your specific problem area and your comfort in that language. I would say that library support is the biggest factor in your decision and language familiarity/preference is a close second.
4
0
0
For something like a personal recommendation system, machine learning type of stuff on a website, what language would be best?
Interested in Collective Programming for the web -- Ruby or Python or PHP?
-0.07983
0
0
2,360
410,183
2009-01-04T00:49:00.000
0
1
0
0
php,python,ruby,artificial-intelligence,recommendation-engine
636,639
5
false
1
0
All of the points that Bill Karwin have brought up are entirely valid: You should really operate in what you are most comfortable with. If that isn't a factor, I would personally suggest Ruby. It's an incredibly powerful language that draws a lot of commonalities with Lisp and is probably just as good, if not better, for AI programming for all the same reasons Lisp was: it's an extremely dynamic, self-modifiable language. As an added benefit Ruby has a really nice standard library including some great libs like the distributed computed library "dRuby".
4
0
0
For something like a personal recommendation system, machine learning type of stuff on a website, what language would be best?
Interested in Collective Programming for the web -- Ruby or Python or PHP?
0
0
0
2,360
410,183
2009-01-04T00:49:00.000
16
1
0
0
php,python,ruby,artificial-intelligence,recommendation-engine
410,193
5
false
1
0
The language you know best would be best. I mean that half-seriously. Given the brief description of your project, there's no reason to believe any of the languages you list would be any better or worse than the others. Those three languages are adequate for approximately similar tasks, so you should pick the one you are most comfortable with and proceed. Any other recommendations would be advocacy for one language or the other, with no real basis on which to evaluate them. Your description is just too vague.
4
0
0
For something like a personal recommendation system, machine learning type of stuff on a website, what language would be best?
Interested in Collective Programming for the web -- Ruby or Python or PHP?
1
0
0
2,360
412,214
2009-01-05T03:36:00.000
4
0
0
1
python,qt
413,073
3
false
0
1
Check if KWin is configured to prevent focus stealing. There might be nothing wrong with your code -- but we linux people don't like applications bugging us when we work, so stealing focus is kinda frowned upon, and difficult under some window managers.
1
1
0
I would like to force my python app to the front if a condition occurs. I'm using Kubuntu & QT3.1 I've tried setActiveWindow(), but it only flashes the task bar in KDE. I think Windows has a function bringwindowtofront() for VB. Is there something similar for KDE?
How to bring program to front using python
0.26052
0
0
2,418
412,475
2009-01-05T07:17:00.000
2
0
1
0
python
412,555
5
false
0
0
I think what you are interested in is still topic of research. You won't find any module ready that will do that for you. Besides it is not clear what you mean with "notes and octaves"? What information exaclty would you like to extract?
2
2
0
Are there any modules in Python that help us to construct or obtain the musical notes and octaves from a given original song? Thanks for the help
How to construct notes from a given song file?
0.07983
0
0
1,896
412,475
2009-01-05T07:17:00.000
2
0
1
0
python
412,505
5
false
0
0
This question has far too few details to give any kind of meaningful answers. Questions: By song file, do you mean like an MP3? Is it a "song" or a "instrumental"? I would gather trying to decipher notes behind a voice would be harder Is it a simple song, like a single voice played on a simple instrument, like a piano or a flute? Or is it a complex one, like any of the latest hits played on the radio? I would think that trying to get a good output from such a program would be extremely hard for anything but the simplest of things. Having said that, look at the Fast Fourier Transform, it can give you a frequency spectrum of things played, but it'll be hard trying to determine what is what from that.
2
2
0
Are there any modules in Python that help us to construct or obtain the musical notes and octaves from a given original song? Thanks for the help
How to construct notes from a given song file?
0.07983
0
0
1,896
412,482
2009-01-05T07:23:00.000
1
1
1
0
python
412,584
9
false
0
0
Search "Alex Martelli - Python For Programmers" on Google Video. Good introductory (but fast-paced) talk. Related videos are also worth watching.
1
2
0
What are good online resources to learn Python, quickly, for some who can code decently in other languages? edit: It'll help if you could explain why you think that resource is useful.
Resources for moving to Python
0.022219
0
0
5,777
413,228
2009-01-05T14:21:00.000
5
0
0
0
python,postgresql
413,259
5
true
1
0
For what it's worth, django uses psycopg2.
4
13
0
What is the difference between these two apis? Which one faster, reliable using Python DB API? Upd: I see two psql drivers for Django. The first one is psycopg2. What is the second one? pygresql?
PyGreSQL vs psycopg2
1.2
1
0
15,364
413,228
2009-01-05T14:21:00.000
0
0
0
0
python,postgresql
413,508
5
false
1
0
psycopg2 is partly written in C so you can expect a performance gain, but on the other hand, a bit harder to install. PyGreSQL is written in Python only, easy to deployed but slower.
4
13
0
What is the difference between these two apis? Which one faster, reliable using Python DB API? Upd: I see two psql drivers for Django. The first one is psycopg2. What is the second one? pygresql?
PyGreSQL vs psycopg2
0
1
0
15,364
413,228
2009-01-05T14:21:00.000
4
0
0
0
python,postgresql
592,846
5
false
1
0
"PyGreSQL is written in Python only, easy to deployed but slower." PyGreSQL contains a C-coded module, too. I haven't done speed tests, but they're not likely to be much different, as the real work will happen inside the database server.
4
13
0
What is the difference between these two apis? Which one faster, reliable using Python DB API? Upd: I see two psql drivers for Django. The first one is psycopg2. What is the second one? pygresql?
PyGreSQL vs psycopg2
0.158649
1
0
15,364
413,228
2009-01-05T14:21:00.000
2
0
0
0
python,postgresql
413,537
5
false
1
0
Licensing may be an issue for you. PyGreSQL is MIT license. Psycopg2 is GPL license. (as long as you are accessing psycopg2 in normal ways from Python, with no internal API, and no direct C calls, this shouldn't cause you any headaches, and you can release your code under whatever license you like - but I am not a lawyer).
4
13
0
What is the difference between these two apis? Which one faster, reliable using Python DB API? Upd: I see two psql drivers for Django. The first one is psycopg2. What is the second one? pygresql?
PyGreSQL vs psycopg2
0.07983
1
0
15,364
413,446
2009-01-05T15:27:00.000
1
0
0
0
python,django
413,549
3
false
1
0
It depends on how you want to use it. Let's say you have length value and two possible units, cm and mm. If you want only to print the value later, you can always print it as [value]&nbsp;[unit]. However, if you want to do some calculations with the value, for instance, calculate the area, you need to convert the values to the same units. So you have to define unit conversion table anyway. I would convert the units to the same internal unit before I store them in the database, rather than converting them every time I use them. I would add a model for units and physical quantities only if there are too many of them and the conversion is really tricky. Such a model could work as a converter. But for simple cases, like mm⇒cm or inch⇒cm, a static conversion table would suffice.
1
1
0
I need to store some values in the database, distance, weight etc. In my model, I have field that contains quantity of something and IntegerField with choices option, that determines what this quantity means (length, time duration etc). Should I create a model for units and physical quantity or should I use IntegerField that contains the type of unit?
Django and units conversion
0.066568
0
0
3,399
415,015
2009-01-06T00:15:00.000
2
1
0
0
log4net,ironpython,dynamic-language-runtime
417,084
1
true
0
0
I was able to solve the problem by using absolute reference paths rather than relative ones.
1
0
0
I've got an IronPython script that configures log4net, then calls .NET code that uses log4net. log4net is properly configured, as I log a message to indicate that it is initialized. But when I try to use my .NET class, it reports "could not load file or assembly 'log4net, ...'. Some useful facts: log4net is not installed to the GAC the .NET class is correct, I've called it from other .NET code the log4net assembly being loaded in IPY is in the same folder as my .NET assembly. filemon shows that all log4net.dll access is successfully resolved from the expected location fuslogvw doesn't report any binding errors I'm adding both the log4net reference and the .NET assembly references using AddReferenceToFileAndPath( ) What's strange is that the log4net assembly has already been loaded. It must be loading the .NET assembly in another AppDomain. If that's how it works, it would be helpful to know. Any ideas out there? Thanks.
Calling .NET code from IronPython, getting error loading the log4net assembly
1.2
0
0
1,015
415,511
2009-01-06T04:54:00.000
0
0
1
0
python,datetime,time
71,589,047
51
false
0
0
This should work import time now = datetime.now() current_time = now.strftime("%H:%M:%S") print("The current time is", current_time)
1
3,537
0
How do I get the current time?
How do I get the current time?
0
0
0
3,880,994
417,265
2009-01-06T16:44:00.000
-3
0
0
0
python,django,django-templates
417,273
3
false
1
0
It's a bitwise "or". It means escape if the property doesn't exist/is null.
1
8
0
I often see something like that: something.property|escape something is an object, property is it's string property. escape - i don't know :) What does this mean? And what min python version it is used in? EDIT: The question was asked wrongly, it said "What does | mean in Python", so the bitwise or answers are correct, but irrelevant, please do not downvote them
What does "|" sign mean in a Django template?
-0.197375
0
0
4,913
417,584
2009-01-06T18:14:00.000
0
0
0
0
python,google-app-engine
420,416
4
false
0
0
I may be misunderstanding your question, but if you have a list of properties you expect to find, why not just use a standard db.Model, instead of an Expando? You can add additional properties to a Model class, as long as you either provide a default or don't make them required.
1
0
0
I'm creating an app that I want to have an expandable set of properties (each a RatingProperty) I also want to validate that any dynamic properties are of the RatingProperty type. In the Expando documentation it says: Tip: If you want to validate a dynamic property value using a Property class, you can instantiate the Property class and call its validate() method on the value. So if I want to validate a dynamic property I need to know what the class's non-dynamic properties are. How can I ask my class what it's defined properties are? I've considered creating a class method that takes a string and returns true if that string is in a list of property names that I create and maintain, but it seems like a hack. I've searched the Google for tips, but haven't had any luck. Thanks, Pat
How can I tell if an Expando subclass has a property defined?
0
0
0
466
418,835
2009-01-07T01:12:00.000
1
0
0
0
python,python-3.x,plot,graphing,scatter-plot
421,947
5
false
0
0
Maybe you can use Python Imaging Library (PIL). Also have a look at PyX, but this library is meant to output to PDF, ...
1
3
1
As per the title. I am trying to create a simple scater plot, but haven't found any Python 3.0 libraries that can do it. Note, this isn't for a website, so the web ones are a bit useless.
Are there any graph/plotting/anything-like-that libraries for Python 3.0?
0.039979
0
0
1,540
419,010
2009-01-07T02:39:00.000
0
1
1
0
python,versioning
420,029
5
false
0
0
You should be using setuptools: It allows you to lock the dependancies of an application, so even if multiple versions of an egg or package exist on a system only the right one will ever be used. This is a better way of working: Rather than fail if the wrong version of a dependancy is present it is better to ensure that the right version is present. Setuptools provides an installer which guarantees that everything required to run the application is present at install-time. It also gives you the means to select which of the many versions of a package which may be present on your PC is the one that gets loaded when you issue an import statement.
1
4
0
How can you raise an exception when you import a module that is less or greater than a given value for its __version__? There are a lot of different ways you could do it, but I feel like there must be some really simple way that eludes me at the moment. In this case the version number is of the format x.x.x
How to raise an exception on the version number of a module
0
0
0
453
419,197
2009-01-07T04:33:00.000
0
0
0
1
python,google-app-engine,google-apps,gql,gqlquery
426,287
4
false
1
0
Yeah, there's no way to get information about people who haven't logged into your application.
1
1
0
If you have a Google App Engine project you can authenticate based on either a) anyone with a google account or b) a particular google app domain. Since you can connect these two entities I would assume there is some way to query the list of users that can be authenticated. The use case is outputting a roster of all members in an organization to a web page running on Google App Engine. Any thoughts?
How do you query the set of Users in Google App Domain within your Google App Engine project?
0
0
0
1,636
419,260
2009-01-07T05:14:00.000
0
0
0
0
python,c,text,webpage
419,273
8
false
0
0
As long as the layout of the web page your trying to 'scrape' doesnt regularly change, you should be able to parse the html with any modern day programming language.
2
3
0
I would like to write a program that will find bus stop times and update my personal webpage accordingly. If I were to do this manually I would Visit www.calgarytransit.com Enter a stop number. ie) 9510 Click the button "next bus" The results may look like the following: 10:16p Route 154 10:46p Route 154 11:32p Route 154 Once I've grabbed the time and routes then I will update my webpage accordingly. I have no idea where to start. I know diddly squat about web programming but can write some C and Python. What are some topics/libraries I could look into?
Grabbing text from a webpage
0
0
1
24,102
419,260
2009-01-07T05:14:00.000
1
0
0
0
python,c,text,webpage
419,271
8
false
0
0
That site doesnt offer an API for you to be able to get the appropriate data that you need. In that case you'll need to parse the actual HTML page returned by, for example, a CURL request .
2
3
0
I would like to write a program that will find bus stop times and update my personal webpage accordingly. If I were to do this manually I would Visit www.calgarytransit.com Enter a stop number. ie) 9510 Click the button "next bus" The results may look like the following: 10:16p Route 154 10:46p Route 154 11:32p Route 154 Once I've grabbed the time and routes then I will update my webpage accordingly. I have no idea where to start. I know diddly squat about web programming but can write some C and Python. What are some topics/libraries I could look into?
Grabbing text from a webpage
0.024995
0
1
24,102
419,908
2009-01-07T11:05:00.000
0
0
0
0
javascript,python,html,google-app-engine,drop-down-menu
7,284,763
4
false
1
0
The problem with using onchange is that not all users are using a mouse. If you have a combo-box and change the value with the keyboard, you'd never be able to get past the first value without the form submitting. ~Cyrix
1
1
0
How to get the text of selected item from a drop down box element in html forms? (using python) How can I store the value to a variable, when I select one item from the drop down box using mouse? (ie. without using a submit button) This is for a application which I am doing in app engine which only supports Python.
Getting selected value from drop down box in a html form without submit
0
0
1
13,168
423,379
2009-01-08T05:45:00.000
26
0
1
0
python,global-variables,scope
427,818
24
false
0
0
You're not actually storing the global in a local variable, just creating a local reference to the same object that your original global reference refers to. Remember that pretty much everything in Python is a name referring to an object, and nothing gets copied in usual operation. If you didn't have to explicitly specify when an identifier was to refer to a predefined global, then you'd presumably have to explicitly specify when an identifier is a new local variable instead (for example, with something like the 'var' command seen in JavaScript). Since local variables are more common than global variables in any serious and non-trivial system, Python's system makes more sense in most cases. You could have a language which attempted to guess, using a global variable if it existed or creating a local variable if it didn't. However, that would be very error-prone. For example, importing another module could inadvertently introduce a global variable by that name, changing the behaviour of your program.
2
3,667
0
How can I create or use a global variable in a function? If I create a global variable in one function, how can I use that global variable in another function? Do I need to store the global variable in a local variable of the function which needs its access?
Using global variables in a function
1
0
0
3,715,726
423,379
2009-01-08T05:45:00.000
70
0
1
0
python,global-variables,scope
423,641
24
false
0
0
If you want to refer to a global variable in a function, you can use the global keyword to declare which variables are global. You don't have to use it in all cases (as someone here incorrectly claims) - if the name referenced in an expression cannot be found in local scope or scopes in the functions in which this function is defined, it is looked up among global variables. However, if you assign to a new variable not declared as global in the function, it is implicitly declared as local, and it can overshadow any existing global variable with the same name. Also, global variables are useful, contrary to some OOP zealots who claim otherwise - especially for smaller scripts, where OOP is overkill.
2
3,667
0
How can I create or use a global variable in a function? If I create a global variable in one function, how can I use that global variable in another function? Do I need to store the global variable in a local variable of the function which needs its access?
Using global variables in a function
1
0
0
3,715,726
423,404
2009-01-08T06:00:00.000
1
0
0
0
python,ctypes
423,479
3
true
0
0
I'm not sure you can do it without modifying the C code. ctypes seems to have really bad support for long doubles - you can't manipulate them like numbers at all, all you can do is convert them back and forth between the native float Python type. You can't even use a byte array as the return value instead of a c_longdouble, because of the ABI - floating-point values aren't returned in the %eax register or on the stack like normal return values, they're passed through the hardware-specific floating-point registers.
1
9
0
i have a c function which returns a long double. i'd like to call this function from python using ctypes, and it mostly works. setting so.func.restype = c_longdouble does the trick -- except that python's float type is a c_double so if the returned value is larger than a double, but well within the bounds of a long double, python still gets inf as the return value. i'm on a 64 bit processor and sizeof(long double) is 16. any ideas on getting around this (e.g. using the decimal class or numpy) without modifying the c code?
long double returns and ctypes
1.2
0
0
2,877
423,916
2009-01-08T11:12:00.000
0
0
0
0
python,django,content-management-system,joomla
1,062,921
9
false
1
0
Thanks for that. The system has been chosen behind my back by higher management. It's SilverStripe. Slow Admin interface No experienced programmer in the company knowing this product Implemented by a graphic designer who's leaving in about two weeks, but "he can do consulting as he's going to be a freelancer" I'm not happy at all Thanks again.
6
3
0
In my company we are thinking of moving from wiki style intranet to a more bespoke CMS solution. Natural choice would be Joomla, but we have a specific architecture. There is a few hundred people who will use the system. System should be self explainable (easier than wiki). We use a lot of tools web, applications and integrated within 3rd party software. The superior element which is a glue for all of them is API. In example for the intranet tools we do use Django, but it's used without ORM, kind of limited to templates and url - every application has an adequate methods within our API. We do not use the Django admin interface, because it is hardly dependent on ORM. Because of that Joomla may be hard to integrate. Every employee should be able to edit most of the pages, authentication and privileges have to be managed by our API. How hard is it to plug Joomla to use a different authentication process? (extension only - no hacks) If one knows Django better than Joomla, should Django be used?
Which software for intranet CMS - Django or Joomla?
0
0
0
14,680
423,916
2009-01-08T11:12:00.000
0
0
0
0
python,django,content-management-system,joomla
428,028
9
false
1
0
Thank you for all the answers. Plone option cancelled on today's meeting. Using Joomla will involve quite a lot of coding to make it act as the rest of the intranet. I think that writing a CMS in Django (with "stealing" some code from existing cms solutions) will win. Newforms are very interesting and it shouldn't be that hard (I wrote already a CMS system in PHP build on my own framework - used on about 15 sites)
6
3
0
In my company we are thinking of moving from wiki style intranet to a more bespoke CMS solution. Natural choice would be Joomla, but we have a specific architecture. There is a few hundred people who will use the system. System should be self explainable (easier than wiki). We use a lot of tools web, applications and integrated within 3rd party software. The superior element which is a glue for all of them is API. In example for the intranet tools we do use Django, but it's used without ORM, kind of limited to templates and url - every application has an adequate methods within our API. We do not use the Django admin interface, because it is hardly dependent on ORM. Because of that Joomla may be hard to integrate. Every employee should be able to edit most of the pages, authentication and privileges have to be managed by our API. How hard is it to plug Joomla to use a different authentication process? (extension only - no hacks) If one knows Django better than Joomla, should Django be used?
Which software for intranet CMS - Django or Joomla?
0
0
0
14,680
423,916
2009-01-08T11:12:00.000
0
0
0
0
python,django,content-management-system,joomla
424,091
9
false
1
0
Django CMS way of work requires using a built-in ORM model and an admin interface.
6
3
0
In my company we are thinking of moving from wiki style intranet to a more bespoke CMS solution. Natural choice would be Joomla, but we have a specific architecture. There is a few hundred people who will use the system. System should be self explainable (easier than wiki). We use a lot of tools web, applications and integrated within 3rd party software. The superior element which is a glue for all of them is API. In example for the intranet tools we do use Django, but it's used without ORM, kind of limited to templates and url - every application has an adequate methods within our API. We do not use the Django admin interface, because it is hardly dependent on ORM. Because of that Joomla may be hard to integrate. Every employee should be able to edit most of the pages, authentication and privileges have to be managed by our API. How hard is it to plug Joomla to use a different authentication process? (extension only - no hacks) If one knows Django better than Joomla, should Django be used?
Which software for intranet CMS - Django or Joomla?
0
0
0
14,680
423,916
2009-01-08T11:12:00.000
2
0
0
0
python,django,content-management-system,joomla
424,377
9
false
1
0
Joomla! has authentication plugins; you can write your own without hacking the core. When someone attempts to log into your site, it will go through all published authentication plugins (in the order you set) until one returns true. If you only want to use one method, unpublish all of the other plugins except for your custom one. Also, Joomla! already has a plugin for LDAP if your system supports this. The part that may be more difficult would be managing specific privileges through the API. Joomla! currently lacks group level access control; it currently has permission level access control (Editors, Publishers, Administrators, etc...).
6
3
0
In my company we are thinking of moving from wiki style intranet to a more bespoke CMS solution. Natural choice would be Joomla, but we have a specific architecture. There is a few hundred people who will use the system. System should be self explainable (easier than wiki). We use a lot of tools web, applications and integrated within 3rd party software. The superior element which is a glue for all of them is API. In example for the intranet tools we do use Django, but it's used without ORM, kind of limited to templates and url - every application has an adequate methods within our API. We do not use the Django admin interface, because it is hardly dependent on ORM. Because of that Joomla may be hard to integrate. Every employee should be able to edit most of the pages, authentication and privileges have to be managed by our API. How hard is it to plug Joomla to use a different authentication process? (extension only - no hacks) If one knows Django better than Joomla, should Django be used?
Which software for intranet CMS - Django or Joomla?
0.044415
0
0
14,680
423,916
2009-01-08T11:12:00.000
1
0
0
0
python,django,content-management-system,joomla
2,631,681
9
false
1
0
If you use FLEXIcontent and FLEXiaccess you can get granular level permissions on Joomla
6
3
0
In my company we are thinking of moving from wiki style intranet to a more bespoke CMS solution. Natural choice would be Joomla, but we have a specific architecture. There is a few hundred people who will use the system. System should be self explainable (easier than wiki). We use a lot of tools web, applications and integrated within 3rd party software. The superior element which is a glue for all of them is API. In example for the intranet tools we do use Django, but it's used without ORM, kind of limited to templates and url - every application has an adequate methods within our API. We do not use the Django admin interface, because it is hardly dependent on ORM. Because of that Joomla may be hard to integrate. Every employee should be able to edit most of the pages, authentication and privileges have to be managed by our API. How hard is it to plug Joomla to use a different authentication process? (extension only - no hacks) If one knows Django better than Joomla, should Django be used?
Which software for intranet CMS - Django or Joomla?
0.022219
0
0
14,680
423,916
2009-01-08T11:12:00.000
8
0
0
0
python,django,content-management-system,joomla
423,947
9
true
1
0
Django isn't a CMS. If you want to build an application then you'd use Django (by the sound of your post you understand that though). If you just want to be able to edit/store content and have permissions for your users - a CMS would be the way to go. I really don't know anything about Joomla though. It should be easy enough to mock up a hack to do whatever authentication you need - even if that's just a POST directly to the server. Django will take a long time to get up to the point where you're using it for the purposes you mention. The admin interface will need to be used (or you're building a CMS from scratch) - which means creating models to model the content you already own. Then you have to customise each model page, and 'plug in' whatever authentication system you want. Lot of work.
6
3
0
In my company we are thinking of moving from wiki style intranet to a more bespoke CMS solution. Natural choice would be Joomla, but we have a specific architecture. There is a few hundred people who will use the system. System should be self explainable (easier than wiki). We use a lot of tools web, applications and integrated within 3rd party software. The superior element which is a glue for all of them is API. In example for the intranet tools we do use Django, but it's used without ORM, kind of limited to templates and url - every application has an adequate methods within our API. We do not use the Django admin interface, because it is hardly dependent on ORM. Because of that Joomla may be hard to integrate. Every employee should be able to edit most of the pages, authentication and privileges have to be managed by our API. How hard is it to plug Joomla to use a different authentication process? (extension only - no hacks) If one knows Django better than Joomla, should Django be used?
Which software for intranet CMS - Django or Joomla?
1.2
0
0
14,680
425,343
2009-01-08T18:38:00.000
4
0
1
1
python,cross-platform
425,383
4
true
0
0
In general: Be careful with paths. Use os.path wherever possible. Don't assume that HOME points to the user's home/profile directory. Avoid using things like unix-domain sockets, fifos, and other POSIX-specific stuff. More specific stuff: If you're using wxPython, note that there may be differences in things like which thread certain events are generated in. Don't assume that events are generated in a specific thread. If you're calling a method which triggers a GUI-event, don't assume that event-handlers have completed by the time your method returns. (And vice versa, of course.) There are always differences in how a GUI will appear. Layouts are not always implemented in the exact same way.
4
4
0
I am about to start a personal project using python and I will be using it on both Linux(Fedora) and Windows(Vista), Although I might as well make it work on a mac while im at it. I have found an API for the GUI that will work on all 3. The reason I am asking is because I have always heard of small differences that are easily avoided if you know about them before starting. Does anyone have any tips or suggestions that fall along these lines?
Python and different Operating Systems
1.2
0
0
1,173
425,343
2009-01-08T18:38:00.000
1
0
1
1
python,cross-platform
425,403
4
false
0
0
You should take care of the Python version you are developing against. Especially, on a Mac, the default version of Python installed with the OS, is rather old (of course, newer versions can be installed) Don't use the OS specific libraries Take special care of 'special' UI elements, like taskbar icons (windows), ... Use forward slashes when using paths, avoid C:/, /home/..., ... Use os.path to work with paths.
4
4
0
I am about to start a personal project using python and I will be using it on both Linux(Fedora) and Windows(Vista), Although I might as well make it work on a mac while im at it. I have found an API for the GUI that will work on all 3. The reason I am asking is because I have always heard of small differences that are easily avoided if you know about them before starting. Does anyone have any tips or suggestions that fall along these lines?
Python and different Operating Systems
0.049958
0
0
1,173
425,343
2009-01-08T18:38:00.000
3
0
1
1
python,cross-platform
425,409
4
false
0
0
Some things I've noticed in my cross platform development in Python: OSX doesn't have a tray, so application notifications usually happen right in the dock. So if you're building a background notification service you may need a small amount of platform-specific code. os.startfile() apparently only works on Windows. Either that or Python 2.5.1 on Leopard doesn't support it. os.normpath() is something you might want to consider using too, just to keep your paths and volumes using the correct slash notation and volume names. icons are dealt with in fundamentally different ways in Windows and OSX, be sure you provide icons at all the right sizes for both (16x16, 24x24, 32x32, 48x48, 64x64, 128x128 and 256x256) and be sure to read up on setting up icons with wx widgets.
4
4
0
I am about to start a personal project using python and I will be using it on both Linux(Fedora) and Windows(Vista), Although I might as well make it work on a mac while im at it. I have found an API for the GUI that will work on all 3. The reason I am asking is because I have always heard of small differences that are easily avoided if you know about them before starting. Does anyone have any tips or suggestions that fall along these lines?
Python and different Operating Systems
0.148885
0
0
1,173
425,343
2009-01-08T18:38:00.000
0
0
1
1
python,cross-platform
425,465
4
false
0
0
Some filename problems: This.File and this.file are different files on Linux, but point to the same file on Windows. Troublesome if you manage some file repository and access it from both platforms. Less frequent related problem is that of names like NUL or LPT being files on Windows. Binary distribution code (if any) would likely use py2exe on Win, py2app on Mac and wouldn't be present on Linux.
4
4
0
I am about to start a personal project using python and I will be using it on both Linux(Fedora) and Windows(Vista), Although I might as well make it work on a mac while im at it. I have found an API for the GUI that will work on all 3. The reason I am asking is because I have always heard of small differences that are easily avoided if you know about them before starting. Does anyone have any tips or suggestions that fall along these lines?
Python and different Operating Systems
0
0
0
1,173
425,722
2009-01-08T20:17:00.000
4
0
0
0
python,drag-and-drop,wxpython
425,740
1
true
0
1
If you want to graphically represent the drag, one good way to do this is to create a borderless Frame that follows the mouse during a drag. You remove the button from your source Frame, temporarily put it in this "drag Frame", and then, when the user drops, add it to your destination Frame.
1
1
0
Does anyone know of an example where it is shown how to drag a button from one panel to another in wxPython? I have created a bitmap button in a panel, and I would like to be able to drag it to a different panel and drop I there. I haven't found any examples using buttons, just text and files. I am using the latest version of Python and wxPython.
Drag button between panels in wxPython
1.2
0
0
1,052
426,607
2009-01-09T00:16:00.000
3
1
0
0
python,ruby,cocoa,pyobjc,ruby-cocoa
426,733
5
false
1
0
Both are roughly equal, I'd say. Better in some places, worse in others. But I wouldn't recommend learning Cocoa with either. Like Chris said, Cocoa requires some understanding of Objective-C. I like Ruby better than Objective-C, but I still don't recommend using it to learn Cocoa. Once you have a solid foundation (no pun intended) in Cocoa/Objective-C, then the bridges can be useful to you.
3
8
0
I've been wanting to have a play with either Ruby or Python while at the same time I've been wanting to do a bit of Cocoa programming. So I thought the best way to achieve both these goals is to develop something using either a Ruby or Python to Objective-C bridge (PyObjc or RubyCocoa). I know that ideally to get the best learning experience I would learn each techonology independently but I don't have the time. :) So my question is which is a more mature platform, PyObc or RubyCocoa, main things I am looking for: Documentation of API Tutorials Tools Supportive Community Completness of Cocoa API avaialble through the bridge Regarding point 5 I don't expect that the entire Cocoa API will be availble through either bridge but I need to have enough Cocoa APIs available to develop a functioning application.
PyObjc vs RubyCocoa for Mac development: Which is more mature?
0.119427
0
0
2,518
426,607
2009-01-09T00:16:00.000
12
1
0
0
python,ruby,cocoa,pyobjc,ruby-cocoa
426,703
5
false
1
0
While you say you "don't have time" to learn technologies independently the fastest route to learning Cocoa will still be to learn it in its native language: Objective-C. Once you understand Objective-C and have gotten over the initial learning curve of the Cocoa frameworks you'll have a much easier time picking up either PyObjC or RubyCocoa.
3
8
0
I've been wanting to have a play with either Ruby or Python while at the same time I've been wanting to do a bit of Cocoa programming. So I thought the best way to achieve both these goals is to develop something using either a Ruby or Python to Objective-C bridge (PyObjc or RubyCocoa). I know that ideally to get the best learning experience I would learn each techonology independently but I don't have the time. :) So my question is which is a more mature platform, PyObc or RubyCocoa, main things I am looking for: Documentation of API Tutorials Tools Supportive Community Completness of Cocoa API avaialble through the bridge Regarding point 5 I don't expect that the entire Cocoa API will be availble through either bridge but I need to have enough Cocoa APIs available to develop a functioning application.
PyObjc vs RubyCocoa for Mac development: Which is more mature?
1
0
0
2,518
426,607
2009-01-09T00:16:00.000
1
1
0
0
python,ruby,cocoa,pyobjc,ruby-cocoa
3,930,584
5
false
1
0
ObjectiveC is nowhere near as much fun or as productive as either Python or Ruby. That is why people want to pick a python or ruby with good Objective C access. Advising them to learn Objective C first misses the point imo. I have really good things to say about pyobjc. Its ability to interoperate painlessly with Objective C frameworks is superb. I have less experience with Ruby Cocoa and that was partly because when I last looked it didn't seem to have as clean and relatively painless interoperability. I feel hesitant about MacRuby because it seems to go too far. In pyobjc you can write plain python and only subclass/use Foundation and Cocoa objects when you really want/mean to. From what I understand of MacRuby it is a Ruby on top of Cocoa. So a string is always an NSString. I am less happy with that. YMMV.
3
8
0
I've been wanting to have a play with either Ruby or Python while at the same time I've been wanting to do a bit of Cocoa programming. So I thought the best way to achieve both these goals is to develop something using either a Ruby or Python to Objective-C bridge (PyObjc or RubyCocoa). I know that ideally to get the best learning experience I would learn each techonology independently but I don't have the time. :) So my question is which is a more mature platform, PyObc or RubyCocoa, main things I am looking for: Documentation of API Tutorials Tools Supportive Community Completness of Cocoa API avaialble through the bridge Regarding point 5 I don't expect that the entire Cocoa API will be availble through either bridge but I need to have enough Cocoa APIs available to develop a functioning application.
PyObjc vs RubyCocoa for Mac development: Which is more mature?
0.039979
0
0
2,518
428,308
2009-01-09T14:46:00.000
0
0
0
0
java,python,image,ms-word
430,717
4
false
0
0
You want to do this in Java or Python. Try OpenOffice. In OpenOffice, you can insert Java or Python code as a "Makro". I'm sure there will be a possibility to change the image URLs.
1
1
0
I have a set of word documents that contains a lot of non-embedded images in them. The url that the images point to no longer exist. I would like to programmatically change the domain name of the url to something else. How can I go about doing this in Java or Python ?
How to programmatically change urls of images in word documents
0
0
1
1,351
428,704
2009-01-09T16:19:00.000
1
1
0
0
python,html,css,browser,cgi
428,832
2
false
1
0
with that much html to render I would also consider the speed of the computer. you can test this by saving the html file and opening it from your local hard drive :)
2
2
0
I use python cgi for our intranet application. When I measure time, the script takes 4s to finish. But after that, it still takes another 11s to show the screen in the browser. The screen is build with tables (size: 10 KB, 91 KB uncompressed) and has a large css file (5 KB, 58 KB uncompressed). I used YSlow and did as much optimization as suggested. Gzipping etc. Firebug Net says: 11s for the file. How do I measure where these last 11 seconds are needed for? Is it just the size of the HTML, or the table structure? Anyone more ideas for tweaking?
Measure load time for python cgi script?
0.099668
0
0
653
428,704
2009-01-09T16:19:00.000
1
1
0
0
python,html,css,browser,cgi
428,767
2
false
1
0
I think I'd grab a copy of Ethereal and watch the TCP connection between the browser and the script, if I were concerned about whether the server is not getting its job done in an acceptable amount of time. If you see the TCP socket close before that 11s gap, you know that your issue is entirely on the browser side. If the TCP close comes well into the 11s gap, then you're going to have to do some debugging on the http server side. I think that Ethereal has changed it's name to WireShark. Whatever it is calling itself recently, it's a must-have tool for this sort of work. I was using it just the other day to find out why I couldn't connect to my virtualized http server.
2
2
0
I use python cgi for our intranet application. When I measure time, the script takes 4s to finish. But after that, it still takes another 11s to show the screen in the browser. The screen is build with tables (size: 10 KB, 91 KB uncompressed) and has a large css file (5 KB, 58 KB uncompressed). I used YSlow and did as much optimization as suggested. Gzipping etc. Firebug Net says: 11s for the file. How do I measure where these last 11 seconds are needed for? Is it just the size of the HTML, or the table structure? Anyone more ideas for tweaking?
Measure load time for python cgi script?
0.099668
0
0
653
428,895
2009-01-09T17:11:00.000
6
0
0
0
python,http
431,411
6
false
0
0
Take into account that 'last-modified' may not be present: >>> from urllib import urlopen >>> f=urlopen('http://google.com/') >>> i=f.info() >>> i.keys() ['set-cookie', 'expires', 'server', 'connection', 'cache-control', 'date', 'content-type'] >>> i.getdate('date') (2009, 1, 10, 16, 17, 8, 0, 1, 0) >>> i.getheader('date') 'Sat, 10 Jan 2009 16:17:08 GMT' >>> i.getdate('last-modified') >>> Now you can compare: if (i.getdate('last-modified') or i.getheader('date')) > current_file_date: open('file', 'w').write(f.read())
2
3
0
I have a python application that relies on a file that is downloaded by a client from a website. The website is not under my control and has no API to check for a "latest version" of the file. Is there a simple way to access the file (in python) via a URL and check it's date (or size) without having to download it to the clients machine each time? update: Thanks to those who mentioned the"last-modified" date. This is the correct parameter to look at. I guess I didn't state the question well enough. How do I do this from a python script? I want to application to check the file and then download it if (last-modified date < current file date).
How can I get the created date of a file on the web (with Python)?
1
0
1
12,198
428,895
2009-01-09T17:11:00.000
7
0
0
0
python,http
428,951
6
false
0
0
There is no reliable way to do this. For all you know, the file can be created on the fly by the web server and the question "how old is this file" is not meaningful. The webserver may choose to provide Last-Modified header, but it could tell you whatever it wants.
2
3
0
I have a python application that relies on a file that is downloaded by a client from a website. The website is not under my control and has no API to check for a "latest version" of the file. Is there a simple way to access the file (in python) via a URL and check it's date (or size) without having to download it to the clients machine each time? update: Thanks to those who mentioned the"last-modified" date. This is the correct parameter to look at. I guess I didn't state the question well enough. How do I do this from a python script? I want to application to check the file and then download it if (last-modified date < current file date).
How can I get the created date of a file on the web (with Python)?
1
0
1
12,198
429,162
2009-01-09T18:29:00.000
2
0
0
1
python,command-line,streaming,yaml
429,305
2
false
0
0
All of the references to stream in the the documentation seem to be referring to a stream of documents... I've never tried to use it in the way you describe, but it seems like chunking the data into such a stream of documents is a reasonable approach.
1
6
0
I have a command line app the continuously outputs YAML data in the form: - col0: datum0 col1: datum1 col2: datum2 - col0: datum0 col1: datum1 col2: datum2 ... It does this for all of eternity. I would like to write a Python script that continuously reads each of these records. The PyYAML library seems best at taking fully loaded strings and interpreting those as a complete YAML document. Is there a way to put PyYAML into a "streaming" mode? Or is my only option to chunk the data myself and feed it bit by bit into PyYAML?
How to process a YAML stream in Python
0.197375
0
0
2,564
429,443
2009-01-09T19:49:00.000
1
0
0
0
python,django,google-apps,monkeypatching
605,174
4
false
1
0
Have you considered subclassing the User model? This may create a different set of problems, and is only available with newer releases (not sure when the change went in, I'm on trunk).
3
1
0
I am writing a Django app, and I would like an account to be created on our Google Apps hosted email using the Provisioning API whenever an account is created locally. I would solely use signals, but since I would like the passwords to be synchronized across sites, I have monkeypatched User.objects.create_user and User.set_password using wrappers to create Google accounts and update passwords respectively. Monkeypatching seems to be frowned upon, so I would to know, is there a better way to accomplish this?
Syncing Django users with Google Apps without monkeypatching
0.049958
0
0
428
429,443
2009-01-09T19:49:00.000
0
0
0
0
python,django,google-apps,monkeypatching
959,044
4
false
1
0
Monkeypatching is definitely bad. Hard to say anything since you've given so little code/information. But I assume you have the password in cleartext at some point (in a view, in a form) so why not sync manually then?
3
1
0
I am writing a Django app, and I would like an account to be created on our Google Apps hosted email using the Provisioning API whenever an account is created locally. I would solely use signals, but since I would like the passwords to be synchronized across sites, I have monkeypatched User.objects.create_user and User.set_password using wrappers to create Google accounts and update passwords respectively. Monkeypatching seems to be frowned upon, so I would to know, is there a better way to accomplish this?
Syncing Django users with Google Apps without monkeypatching
0
0
0
428
429,443
2009-01-09T19:49:00.000
0
0
0
0
python,django,google-apps,monkeypatching
749,860
4
false
1
0
Subclassing seems the best route, as long as you can change all of your code to use the new class. I think that's supported in the latest release of Django.
3
1
0
I am writing a Django app, and I would like an account to be created on our Google Apps hosted email using the Provisioning API whenever an account is created locally. I would solely use signals, but since I would like the passwords to be synchronized across sites, I have monkeypatched User.objects.create_user and User.set_password using wrappers to create Google accounts and update passwords respectively. Monkeypatching seems to be frowned upon, so I would to know, is there a better way to accomplish this?
Syncing Django users with Google Apps without monkeypatching
0
0
0
428
430,226
2009-01-10T00:10:00.000
0
1
0
0
python,twitter,polling
430,245
2
false
0
0
You should have a page that is like a Ping or Heartbeat page. The you have another process that "tickles" or hits that page, usually you can do this in your Control Panel of your web host, or use a cron if you have a local access. Then this script can keep statistics of how often it has polled in a database or some data store and then you poll the service as often as you really need to, of course limiting it to whatever the providers limit is. You definitely don't want to (and certainly don't want to rely) on a python scrip that "doesn't end." :)
1
5
0
I need to poll a web service, in this case twitter's API, and I'm wondering what the conventional wisdom is on this topic. I'm not sure whether this is important, but I've always found feedback useful in the past. A couple scenarios I've come up with: The querying process starts every X seconds, eg a cron job runs a python script A process continually loops and queries at each iteration, eg ... well, here is where I enter unfamiliar territory. Do I just run a python script that doesn't end? Thanks for your advice. ps - regarding the particulars of twitter: I know that it sends emails for following and direct messages, but sometimes one might want the flexibility of parsing @replies. In those cases, I believe polling is as good as it gets. pps - twitter limits bots to 100 requests per 60 minutes. I don't know if this also limits web scraping or rss feed reading. Anyone know how easy or hard it is to be whitelisted? Thanks again.
Best way to poll a web service (eg, for a twitter app)
0
0
1
5,380
430,379
2009-01-10T02:00:00.000
0
0
0
0
python,python-imaging-library,rounded-corners
430,410
2
false
0
1
Might it not be a better idea (assuming HTML is the output) to use HTML and CSS to put some rounded borders on those pictures? That way, if you want to change the look of your site, you don't have to do any image reprocessing, and you don't have to do any image processing in the first place.
1
0
0
My site is full of rounded corners on every box and picture, except for the thumbnails of user uploaded photos. How can I use the Python Imaging Library to 'draw' white or transparent rounded corners onto each thumbnail?
Draw rounded corners on photo with PIL
0
0
0
3,944
431,432
2009-01-10T17:56:00.000
0
0
1
0
python,interpreter
431,685
5
false
0
0
If you know in advance the modules, classes, functions, variables, etc... in use, you could pickle them to disk and reload. I'm not sure off the top of my head the best way to tackle the issue if your environment contains many unknowns. Though, it may suffice to pickle globals and locals.
4
7
0
I have a python interpreter embedded inside an application. The application takes a long time to start up and I have no ability to restart the interpreter without restarting the whole application. What I would like to do is to essentially save the state of the interpreter and return to that state easily. I started by storing the names of all modules in sys.modules that the python interpreter started with and then deleting all new modules from sys.modules when requested. This appears to make the interpreter prepared to re-import the same modules even though it has already imported them before. However, this doesn't seem to work in all situations, such as using singleton classes and static methods, etc. I'd rather not embed another interpreter inside this interpreter if it can be avoided, as the ease of being able to use the applications API will be lost (as well as including a slight speed hit I imagine). So, does anyone know of a way I could store the interpreter's state and then return to this so that it can cope with all situations? Thanks, Dan
Restarting a Python Interpreter Quietly
0
0
0
6,441
431,432
2009-01-10T17:56:00.000
1
0
1
0
python,interpreter
432,034
5
false
0
0
storing the names of all modules in sys.modules that the python interpreter started with and then deleting all new modules from sys.modules when requested. This appears to make the interpreter prepared to re-import the same modules even though it has already imported them before. The module-reload-forcing approach can be made to work in some circumstances but it's a bit hairy. In summary: You need to make sure that all modules that have dependencies on each other are all reloaded at once. So any module 'x' that does 'import y' or 'from y import ...' must be deleted from sys.modules at the same time as module 'y'. This process will need protecting with a lock if your app or any other active module is using threads. Any module that leaves hooks pointing to itself in other modules cannot usefully be reloaded as references to the old module will remain in unreloaded/unreloadable code. This includes stuff like exception hooks, signals, warnings filters, encodings, monkey-patches and so on. If you start blithely reloading modules containing other people's code you might be surprised how often they do stuff like that, potentially resulting in subtle and curious errors. So to get it to work you need to have well-defined boundaries between interdependent modules - "was it imported at initial start-up time" probably isn't quite good enough - and to make sure they're nicely encapsulated without unexpected dependencies like monkey-patching. This can be based on folder, so for example anything in /home/me/myapp/lib could be reloaded as a unit, whilst leaving other modules alone - especially the contents of the stdlib in eg. /usr/lib/python2.x/ which is in general not reliable to reload. I've got code for this in an as-yet-unreleased webapp reloading wrapper, if you need. Finally: You need to know a little bit about the internals of sys.modules, specifically that it leaves a bunch of 'None' values to signify failed relative imports. If you don't delete them at the same time as you delete your other module values, the subsequent attempt to import a module can (sometimes) end up importing 'None', leading to confusing errors. This is a nasty implementation detail which might change and break your app in some future Python version, but that is the price for playing with sys.modules in unsupported ways.
4
7
0
I have a python interpreter embedded inside an application. The application takes a long time to start up and I have no ability to restart the interpreter without restarting the whole application. What I would like to do is to essentially save the state of the interpreter and return to that state easily. I started by storing the names of all modules in sys.modules that the python interpreter started with and then deleting all new modules from sys.modules when requested. This appears to make the interpreter prepared to re-import the same modules even though it has already imported them before. However, this doesn't seem to work in all situations, such as using singleton classes and static methods, etc. I'd rather not embed another interpreter inside this interpreter if it can be avoided, as the ease of being able to use the applications API will be lost (as well as including a slight speed hit I imagine). So, does anyone know of a way I could store the interpreter's state and then return to this so that it can cope with all situations? Thanks, Dan
Restarting a Python Interpreter Quietly
0.039979
0
0
6,441
431,432
2009-01-10T17:56:00.000
1
0
1
0
python,interpreter
431,829
5
false
0
0
I'd suggest tackling the root cause problem. "The application takes a long time to start up and I have no ability to restart the interpreter without restarting the whole application" I doubt this is actually 100% true. If the overall application is the result of an act of Congress, okay, it can't be changed. But if the overall application was written by real people, then finding and moving the code to restart the Python interpreter should be possible. It's cheaper, simpler and more reliable than anything else you might do to hack around the problem.
4
7
0
I have a python interpreter embedded inside an application. The application takes a long time to start up and I have no ability to restart the interpreter without restarting the whole application. What I would like to do is to essentially save the state of the interpreter and return to that state easily. I started by storing the names of all modules in sys.modules that the python interpreter started with and then deleting all new modules from sys.modules when requested. This appears to make the interpreter prepared to re-import the same modules even though it has already imported them before. However, this doesn't seem to work in all situations, such as using singleton classes and static methods, etc. I'd rather not embed another interpreter inside this interpreter if it can be avoided, as the ease of being able to use the applications API will be lost (as well as including a slight speed hit I imagine). So, does anyone know of a way I could store the interpreter's state and then return to this so that it can cope with all situations? Thanks, Dan
Restarting a Python Interpreter Quietly
0.039979
0
0
6,441
431,432
2009-01-10T17:56:00.000
0
0
1
0
python,interpreter
431,460
5
false
0
0
One very hacky and bug prone approach might be a c module that simply copies the memory to a file so it can be loaded back the next time. But since I can't imagine that this would always work properly, would pickling be an alternative? If you are able to make all of your modules pickleable than you should be able to pickle everything in globals() so it can be reloaded again.
4
7
0
I have a python interpreter embedded inside an application. The application takes a long time to start up and I have no ability to restart the interpreter without restarting the whole application. What I would like to do is to essentially save the state of the interpreter and return to that state easily. I started by storing the names of all modules in sys.modules that the python interpreter started with and then deleting all new modules from sys.modules when requested. This appears to make the interpreter prepared to re-import the same modules even though it has already imported them before. However, this doesn't seem to work in all situations, such as using singleton classes and static methods, etc. I'd rather not embed another interpreter inside this interpreter if it can be avoided, as the ease of being able to use the applications API will be lost (as well as including a slight speed hit I imagine). So, does anyone know of a way I could store the interpreter's state and then return to this so that it can cope with all situations? Thanks, Dan
Restarting a Python Interpreter Quietly
0
0
0
6,441
431,684
2009-01-10T20:28:00.000
4
0
0
1
python,cd
39,964,190
14
false
0
0
If You would like to perform something like "cd.." option, just type: os.chdir("..") it is the same as in Windows cmd: cd.. Of course import os is neccessary (e.g type it as 1st line of your code)
3
797
0
cd is the shell command to change the working directory. How do I change the current working directory in Python?
Equivalent of shell 'cd' command to change the working directory?
0.057081
0
0
1,317,026
431,684
2009-01-10T20:28:00.000
12
0
0
1
python,cd
431,694
14
false
0
0
os.chdir() is the Pythonic version of cd.
3
797
0
cd is the shell command to change the working directory. How do I change the current working directory in Python?
Equivalent of shell 'cd' command to change the working directory?
1
0
0
1,317,026
431,684
2009-01-10T20:28:00.000
12
0
0
1
python,cd
431,695
14
false
0
0
os.chdir() is the right way.
3
797
0
cd is the shell command to change the working directory. How do I change the current working directory in Python?
Equivalent of shell 'cd' command to change the working directory?
1
0
0
1,317,026
431,996
2009-01-10T23:57:00.000
1
0
1
0
python,data-structures,sudoku
432,008
8
false
0
0
The simplest way to do it is to represent the board by a 2D 9x9 array. You'll want to have references to each row, column and 3x3 box as a separate object, so storing each cell in a String makes more sense (in Java) than using a primitive. With a String you can keep references to the same object in multiple containers.
5
0
0
I'm trying to create a sudoku solver program in Java (maybe Python). I'm just wondering how I should go about structuring this... Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? Thanks.
Programming Design Help - How to Structure a Sudoku Solver program?
0.024995
0
0
10,048
431,996
2009-01-10T23:57:00.000
0
0
1
0
python,data-structures,sudoku
432,001
8
false
0
0
Maybe a design that had a box per square, and another class to represent the puzzle itself that would have a collection of boxes, contain all the rules for box interactions, and control the overall game would be a good design.
5
0
0
I'm trying to create a sudoku solver program in Java (maybe Python). I'm just wondering how I should go about structuring this... Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? Thanks.
Programming Design Help - How to Structure a Sudoku Solver program?
0
0
0
10,048
431,996
2009-01-10T23:57:00.000
2
0
1
0
python,data-structures,sudoku
432,003
8
false
0
0
Well, I would use one class for the sudoku itself, with a 9 x 9 array and all the functionality to add numbers and detect errors in the pattern. Another class will be used to solve the puzzle.
5
0
0
I'm trying to create a sudoku solver program in Java (maybe Python). I'm just wondering how I should go about structuring this... Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? Thanks.
Programming Design Help - How to Structure a Sudoku Solver program?
0.049958
0
0
10,048
431,996
2009-01-10T23:57:00.000
0
0
1
0
python,data-structures,sudoku
432,052
8
false
0
0
First, it looks like there are two kinds of cells. Known calls; those with a fixed value, no choices. Unknown cells; those with a set of candidate values that reduces down to a single final value. Second, there are several groups of cells. Horizontal rows and Vertical columns which must have one cell of each value. That constraint is used to remove values from various cells in the row or column. 3x3 blocks which must have one cell of each value. That constraint is used to remove values from various cells in the block. Finally, there's the overall grid. This has several complementary views. It's 81 cells. The cells are also collected into a 3x3 grid of 3x3 blocks. The cells are also collected into 9 columns. The cells are also collected into 9 rows. And you have a solver strategy object. Each Unknown cell it set to having set( range(1,10) ) as the candidate values. For each row, column and 3x3 block (27 different collections): a. For each cell: If it has definite value (Known cells and Unknown cells implement this differently): remove that value from all other cells in this grouping. The above must be iterated until no changes are found. At this point, you either have it solved (all cells report a definite value), or, you have some cells with multiple values. Now you have to engage in a sophisticated back-tracking solver to find a combination of the remaining values that "works".
5
0
0
I'm trying to create a sudoku solver program in Java (maybe Python). I'm just wondering how I should go about structuring this... Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? Thanks.
Programming Design Help - How to Structure a Sudoku Solver program?
0
0
0
10,048
431,996
2009-01-10T23:57:00.000
12
0
1
0
python,data-structures,sudoku
432,000
8
false
0
0
Don't over-engineer it. It's a 2-D array or maybe a Board class that represents a 2-D array at best. Have functions that calculate a given row/column and functions that let you access each square. Additional methods can be used validate that each sub-3x3 and row/column don't violate the required constraints.
5
0
0
I'm trying to create a sudoku solver program in Java (maybe Python). I'm just wondering how I should go about structuring this... Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? Thanks.
Programming Design Help - How to Structure a Sudoku Solver program?
1
0
0
10,048
432,115
2009-01-11T01:23:00.000
1
0
0
0
python,session
432,200
3
false
1
0
A cron job to clean up any expired session data in the database is a good thing. Depending on how long your sessions last, and how big your database is, you might want to cleanup more often than once per day. But one cleanup pass per day is usually fine.
3
1
0
I'm writing a webapp that will only be used by authenticated users. Some temporary databases and log files will be created during each user session. I'd like to erase all these temp files when the session is finished. Obviously, a logout or window close event would be sufficient to close the session, but in some cases the user may keep the browser open long after he's finished. Another approach would be to time user sessions or delete the temp files during routine maintenance. How do you go about it?
when to delete user's session
0.066568
0
0
988
432,115
2009-01-11T01:23:00.000
1
0
0
0
python,session
432,126
3
true
1
0
User sessions should have a timeout value and should be closed when the timeout expires or the user logs out. Log out is an obvious time to do this and the time out needs to be there in case the user navigates away from your application without logging out.
3
1
0
I'm writing a webapp that will only be used by authenticated users. Some temporary databases and log files will be created during each user session. I'd like to erase all these temp files when the session is finished. Obviously, a logout or window close event would be sufficient to close the session, but in some cases the user may keep the browser open long after he's finished. Another approach would be to time user sessions or delete the temp files during routine maintenance. How do you go about it?
when to delete user's session
1.2
0
0
988
432,115
2009-01-11T01:23:00.000
0
0
0
0
python,session
432,170
3
false
1
0
Delete User's Session during: 1) Logout 2) Automatic timeout (the length of the timeout can be set through the web.config) 3) As part of any other routine maintenance methods you already have running by deleting any session information which hasn't been accessed for some defined period of time (likely shorter than your automatic timeout length because if it was the same length it should already be taken care of)
3
1
0
I'm writing a webapp that will only be used by authenticated users. Some temporary databases and log files will be created during each user session. I'd like to erase all these temp files when the session is finished. Obviously, a logout or window close event would be sufficient to close the session, but in some cases the user may keep the browser open long after he's finished. Another approach would be to time user sessions or delete the temp files during routine maintenance. How do you go about it?
when to delete user's session
0
0
0
988
433,945
2009-01-11T23:03:00.000
4
0
1
0
java,python,jfilechooser
433,967
6
false
0
1
wxPython (www.wxpython.org) provides the wx.FileDialog class which will give you a native file selection dialog on any of the supported platforms (Mac, Linux or Windows).
2
4
0
I was wondering if there is something similar to Java's JFileChooser for Python? JFileChooser is a graphical front end to choose a file. Preferably something that is already with Python. Maybe with Tkinter.
JFileChooser for Python?
0.132549
0
0
2,182