Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
1,353,715
2009-08-30T11:49:00.000
14
1
1
0
python,performance
1,353,722
10
true
0
0
My answer to that would be : We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. (Quoting Knuth, Donald. Structured Programming with go to Statements, ACM Journal Computing Surveys, Vol 6, No. 4, Dec. 1974. p.268) If your application is doing anything like a query to the database, that one query will take more time than anything you can gain with those kind of small optimizations, anyway... And if running after performances like that, why not code in assembly language, afterall ? Because Python is easier/faster to write and maintain ? Well, if so, you are right :-) The most important thing is that your code is easy to maintain ; not a couple micro-seconds of CPU-time ! Well, maybe except if you have thousands of servers -- but is it your case ?
7
5
0
I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++. Things like: In an if statement with an or always put the condition most likely to fail first, so the second will not be checked. Use the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings. Call as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates. I say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python. What's your view of the matter?
Should I optimise my python code like C++? Does it matter?
1.2
0
0
805
1,354,204
2009-08-30T16:17:00.000
0
0
1
0
python,multiprocessing,priority-queue
1,359,108
6
false
0
0
Depending on your requirements you could use the operating system and the file system in a number of ways. How large will the queue grow and how fast does it have to be? If the queue may be big but you are willing to open a couple files for every queue access you could use a BTree implementation to store the queue and file locking to enforce exclusive access. Slowish but robust. If the queue will remain relatively small and you need it to be fast you might be able to use shared memory on some operating systems... If the queue will be small (1000s of entries) and you don't need it to be really fast you could use something as simple as a directory with files containing the data with file locking. This would be my preference if small and slow is okay. If the queue can be large and you want it to be fast on average, then you probably should use a dedicated server process like Alex suggests. This is a pain in the neck however. What are your performance and size requirements?
2
6
0
Anybody familiar with how I can implement a multiprocessing priority queue in python?
How to implement a multiprocessing priority queue in Python?
0
0
0
5,791
1,354,204
2009-08-30T16:17:00.000
1
0
1
0
python,multiprocessing,priority-queue
1,750,166
6
false
0
0
I had the same use case. But with a finite number of priorities. What I am ending up doing is creating one Queue per priority, and my Process workers will try to get the items from those queues, starting with the most important queue to the less important one (moving from one queue to the other is done when the queue is empty)
2
6
0
Anybody familiar with how I can implement a multiprocessing priority queue in python?
How to implement a multiprocessing priority queue in Python?
0.033321
0
0
5,791
1,354,520
2009-08-30T18:24:00.000
0
0
1
0
python,file,hashtable
1,354,632
7
false
0
0
Let's see where the bottleneck is. When you're going to read a file, the hard drive has to turn enough to be able to read from it; then it reads a big block and caches the results. So you want some method that will guess exactly what position in file you're going to read from and then do it exactly once. I'm pretty much sure standard DB modules will work for you, but you can do it yourself -- just open the file in binary mode for reading/writing and store your values as, say, 30-digits (=100-bit = 13-byte) numbers. Then use standard file methods .
1
4
0
Hey. I have a function I want to memoize, however, it has too many possible values. Is there any convenient way to store the values in a text file and make it read from them? For example, something like storing a pre-computed list of primes up to 10^9 in a text file? I know it's slow to read from a text file but there's no other option if the amount of data is really huge. Thanks!
Storing huge hash table in a file in Python
0
0
0
5,436
1,355,285
2009-08-31T00:11:00.000
5
0
0
0
python,django,utf-8,character-encoding
1,355,303
1
true
1
0
Judging from the \xf3 code for 'ó', it does look like the data is encoded in ISO-8859-1 (or some close relative). So body.decode('iso-8859-1') should be a valid Unicode string (you don't specify what "without solution" means -- what error message do you get, and where?); if what you need is a utf-8 encoded bytestring instead, body.decode('iso-8859-1').encode('utf-8') should give you one!
1
1
0
I have a problem reading a txt file to insert in the mysql db table, te sniped of this code: file contains the in first line: "aclaración" archivo = open('file.txt',"r") for line in archivo.readlines(): ....body = body + line model = MyModel(body=body) model.save() i get a DjangoUnicodeDecodeError: 'utf8' codec can't decode bytes in position 8: invalid data. You passed in 'aclaraci\xf3n' (type 'str') Unicode error hint The string that could not be encoded/decoded was: araci�n. I tried to body.decode('utf-8'), body.decode('latin-1'), body.decode('iso-8859-1') without solution. Can you help me please? Any hint is apreciated :)
Latin letters with acute : DjangoUnicodeDecodeError
1.2
1
0
3,312
1,355,918
2009-08-31T05:25:00.000
2
0
1
0
python,linux,user-interface,gtk,pygtk
1,355,948
5
false
0
1
Each desktop environment uses a specific toolkit to build it's components. For example, KDE uses Qt and GNOME uses Gtk. Your use of a toolkit will be dependent upon what type of desktop environment you're targeting at, and if you want to target a wide range of desktops then use a toolkit which will work on many desktop environments, like Wx widgets which will work on Linux, Mac OS and Windows. For building simple GUI applications, Tkinter will do.
1
14
0
Quick question. I'm using Linux and I want to try making a GUI with Python. I've heard about something like Qt, GTK+ and PyGTK but I don't know what they are exactly and what the difference between them is. Is there any difference on how they work with different DEs like GNOME, KDE, XFCE etc.? Is there any IDE that allows you to create GUI like Microsoft Visual Studio does (for C#, C, Visual Basic etc.)? Or should I maybe use another language other than Python to make GUI applications?
Creating GUI with Python in Linux
0.07983
0
0
48,034
1,356,240
2009-08-31T07:29:00.000
0
1
0
1
python,filesystems,performance-testing
1,356,966
4
false
0
0
You might be inetersting in looking at tools like caollectd and iotop. Then again, yopu mightalso by interested in just using them instead of reinventing the wheel - as far as I see, such performance analysis is not learned in a day, and these guys invested significant amounts of time and knowledge in building these tools.
1
1
0
I am writing a python script that will perform performance test in linux file system. so besides deadlocks, race conditions and time takes to perform an action (delete, read, write and create) what other variables/parameters should the test contain?
file system performance testing
0
0
0
1,679
1,356,255
2009-08-31T07:32:00.000
-1
0
0
0
python,tkinter
1,356,882
2
false
0
1
For displaying jpgs in Python check out PIL
1
5
0
I am creating a simple tool to add album cover images to mp3 files in python. So far I am just working on sending a request to amazon with artist and album title, and get the resulting list, as well as finding the actual images for each result. What I want to do is to display a simple frame with a button/link for each image, and a skip/cancel button. I have done some googling, but I can't find examples that I can use as a base. I want to display the images directly from the web. Ie. using urllib to open and read the bytes into memory, rather than go via a file on disk I want to display the images as buttons preferably All examples seems to focus on working on files on disk, rather with just a buffer. The TK documentation in the python standard library doesn't seem to cover the basic Button widget. This seems like an easy task, I have just not had any luck in finding the proper documentation yet.
Display jpg images in python
-0.099668
0
0
7,084
1,358,084
2009-08-31T15:47:00.000
6
1
0
0
python,enterprise,banking,onlinebanking
1,358,743
10
false
0
0
Of course you can implement mission-critical software (whatever that is in your case) using Python. At the end of the day the success of your application is going to weigh more on its capabilities than whether it is written in Python. Some all .NET companies will even bring in Python applications provided that there is a way to talk to the system from .NET. I would not market your application as being a Python application. This is going to cause you trouble down the road because you will run into roadblocks. This often happens when you satisfy a business customer and he speaks to their IT guy who says "whoa we can't support that" without a full analysis of the cost/benefit to the business. This is the place that references to use of Python in mission-critical systems will arise. Try to avoid this area. With Python you can always target the popular platforms if you build your application under certain constraints. IronPython runs on .NET and Jython runs on Java. Being able to fire back with info on how to run your application on these platforms might be helpful.
3
22
0
I have been exploring and developing an application in Python for mission critical work in the commercial banking arena. Banks are way conservative in selecting new applications. I need real proof of stability and others using. Have looked at the Python site but now I'm hoping this crowd can tell me more. So far I don't have a development bank partner which I will need next stage, so I'm gathering proof and pitch info. All help and comments appreciated.
Python in the enterprise: Pros and cons
1
0
0
16,188
1,358,084
2009-08-31T15:47:00.000
-5
1
0
0
python,enterprise,banking,onlinebanking
1,358,385
10
false
0
0
Python doesn't have anywhere close to as much money backing it as MSFT or Redhat etc. If Guido gets hit by a bus, Python is in trouble. I <3 python for a lot of things, but a financial transaction system probably wants a real, trusted, stable company backing it. Edit: this isn't flame bait; this is a major lesson learned from watching a colleague push a platform backed by a small company, and the resulting 'business-strategic' nightmare that ended with his project getting dropped in favor of someone using a far crappier project with lots of money. There's more to project success than the technical bit.
3
22
0
I have been exploring and developing an application in Python for mission critical work in the commercial banking arena. Banks are way conservative in selecting new applications. I need real proof of stability and others using. Have looked at the Python site but now I'm hoping this crowd can tell me more. So far I don't have a development bank partner which I will need next stage, so I'm gathering proof and pitch info. All help and comments appreciated.
Python in the enterprise: Pros and cons
-1
0
0
16,188
1,358,084
2009-08-31T15:47:00.000
0
1
0
0
python,enterprise,banking,onlinebanking
7,913,484
10
false
0
0
i know topic is rather old, but anyway. if we talk about mission critical. Python is widly used in Thales software provided with is hardware encryption solutions. and in PayShield application for example, which i believe really mission critical. Although Java is being used there more than Python.
3
22
0
I have been exploring and developing an application in Python for mission critical work in the commercial banking arena. Banks are way conservative in selecting new applications. I need real proof of stability and others using. Have looked at the Python site but now I'm hoping this crowd can tell me more. So far I don't have a development bank partner which I will need next stage, so I'm gathering proof and pitch info. All help and comments appreciated.
Python in the enterprise: Pros and cons
0
0
0
16,188
1,359,090
2009-08-31T19:46:00.000
7
0
1
0
python
1,359,101
2
false
0
0
If the filename changes, there must still be a link to the file somewhere (otherwise nobody would ever guess the filename). A typical approach is to get the HTML page that contains a link to the file, search through that looking for the link target, and then send a second request to get the actual file you're after. Web servers do not generally implement such a "wildcard" facility as you describe, so you must use other techniques.
1
1
0
How can I download files from a website using wildacrds in Python? I have a site that I need to download file from periodically. The problem is the filenames change each time. A portion of the file stays the same though. How can I use a wildcard to specify the unknown portion of the file in a URL?
Wildcard Downloads with Python
1
0
1
1,403
1,359,227
2009-08-31T20:19:00.000
18
0
1
0
python,cocoa,xcode,osx-snow-leopard,pyobjc
1,359,605
6
true
0
1
Allow me to echo what has already been said. I too am a student who just started a Cocoa development project, and at the beginning I thought "Well, I already know Python, I'll just use PyObjC and save myself from having to learn Objective-C, which looks beyond my grasp." I learned quickly that it can't be done. You can develop for OS X without learning Objective-C, but not without learning the Cocoa libraries, which constitute 99% of what you need to learn to write a Cocoa app in Objective-C. Objective-C itself isn't that hard; it's the Cocoa libraries that you need to invest in learning. PyObjC basically uses Cocoa libraries and Python syntax. I gave up with it quickly and decided that if I was going to have to learn Cocoa, I may as well use Objective-C. If you're looking to learn, Aaron Hillegass's book is a good place to start. Good luck!
4
12
0
I am about to start my A-Level Computing project (High School Level) which will hopefully be a point-of-sale application for Mac OS. Unfortunately, Objective-C is a little out of my league at the moment and should I get stuck with it in the project I have no one to help out so I would fail the section of the course and not get into University. So this is quite important to me. I want to use Python to develop a Cocoa app. I know that I need PyObjc, however all details on the net seem to assume it is pre-installed. Apparently this is the case with Leopard and Snow Leopard but I don't seem to have it on Snow Leopard and never noticed it on Leopard. Also, I have tried installing the latest beta of PyObjc by following the instructions on the Sourceforge page, but with no luck. I would really appreciate it if anyone could shed some light on what needs to be installed, how, and links to any resources or tutorials that could help me. Thanks in advance for the help! Update: I see that this is a popular question, I just got the 'Notable Question' badge for it so I thought I would update anyone coming to this page on what I did after getting the answers. Unfortunately, I wasn't able to use Python to create a Mac application. This was rather disappointing at the time, but probably a good thing. I made a Windows app in C# for my project, it was a tool for creating and running Assembly apps in a simulated environment. My course teacher has now started to use my tool to teach the course instead of his own! I got a very high score on the computing project (over 90%) and this contributed to me getting an A* in my computing A-Level (the highest grade available) and I consequently got in to Southampton University to study Computer Science. This summer, I decided to make an iPad app (soon to be released) and I am glad to say that I know think I could make a Mac OS application in Objective-C as I feel I have learnt enough. I am glad that I took the time to learn it, it is a great language and really useful with iOS becoming so popular. Sorry for all the boasting, but I am really happy about it. What I really want to say is, if you are coming to this page hoping to use PyObjc to create Mac apps easily, don't bother. It takes some time and some effort, but once you have learnt Objective-C, it is really satisfying to create apps with it. Good Luck!
PyObjc and Cocoa on Snow Leopard
1.2
0
0
4,914
1,359,227
2009-08-31T20:19:00.000
4
0
1
0
python,cocoa,xcode,osx-snow-leopard,pyobjc
1,359,575
6
false
0
1
And as one of the Checkout developers I'll weigh in too (hi Quinn!). From what we've seen PyObjC runs fairly well on Snow Leopard. We've built one of the latest SVN revisions 2.2b with some customizations on Leopard and just moved over the site-packages folder. Theoretically you should be able to use the built in Python/PyObjC (just do import objc, Foundation, AppKit) but as we ship/work with custom versions of both Python and PyObjC I'm not sure what the status exactly is. The mailing list doesn't mention a lot of people having issues (just a few) so that could be a good sign. Good luck with the project, and if you have specific POS questions shoot me an email ;-)
4
12
0
I am about to start my A-Level Computing project (High School Level) which will hopefully be a point-of-sale application for Mac OS. Unfortunately, Objective-C is a little out of my league at the moment and should I get stuck with it in the project I have no one to help out so I would fail the section of the course and not get into University. So this is quite important to me. I want to use Python to develop a Cocoa app. I know that I need PyObjc, however all details on the net seem to assume it is pre-installed. Apparently this is the case with Leopard and Snow Leopard but I don't seem to have it on Snow Leopard and never noticed it on Leopard. Also, I have tried installing the latest beta of PyObjc by following the instructions on the Sourceforge page, but with no luck. I would really appreciate it if anyone could shed some light on what needs to be installed, how, and links to any resources or tutorials that could help me. Thanks in advance for the help! Update: I see that this is a popular question, I just got the 'Notable Question' badge for it so I thought I would update anyone coming to this page on what I did after getting the answers. Unfortunately, I wasn't able to use Python to create a Mac application. This was rather disappointing at the time, but probably a good thing. I made a Windows app in C# for my project, it was a tool for creating and running Assembly apps in a simulated environment. My course teacher has now started to use my tool to teach the course instead of his own! I got a very high score on the computing project (over 90%) and this contributed to me getting an A* in my computing A-Level (the highest grade available) and I consequently got in to Southampton University to study Computer Science. This summer, I decided to make an iPad app (soon to be released) and I am glad to say that I know think I could make a Mac OS application in Objective-C as I feel I have learnt enough. I am glad that I took the time to learn it, it is a great language and really useful with iOS becoming so popular. Sorry for all the boasting, but I am really happy about it. What I really want to say is, if you are coming to this page hoping to use PyObjc to create Mac apps easily, don't bother. It takes some time and some effort, but once you have learnt Objective-C, it is really satisfying to create apps with it. Good Luck!
PyObjc and Cocoa on Snow Leopard
0.132549
0
0
4,914
1,359,227
2009-08-31T20:19:00.000
3
0
1
0
python,cocoa,xcode,osx-snow-leopard,pyobjc
1,905,283
6
false
0
1
I'm a long time python developer who's been doing iPhone apps for awhile now (and only using my python knowledge to package up build files for the apps in run scripts), then who started making some PyObjC apps. I'd have to say, PyObjC is pretty much STILL having to learn objective C (which I already know via iPhone dev), however you get several pretty cool benefits if you use it instead Easy use of python libraries you know (faster for you) Option to drop it and go to wxPython if styimied by Cocoa Somewhat faster development time (you're writing less code, and the translation between the two languages is pretty darn easy to get used to). Additionally, interface builder is a little tricky to get used to comparatively speaking, but if you're a python dev, it's not like you're exactly used to a functional gui builder anyhow :oP
4
12
0
I am about to start my A-Level Computing project (High School Level) which will hopefully be a point-of-sale application for Mac OS. Unfortunately, Objective-C is a little out of my league at the moment and should I get stuck with it in the project I have no one to help out so I would fail the section of the course and not get into University. So this is quite important to me. I want to use Python to develop a Cocoa app. I know that I need PyObjc, however all details on the net seem to assume it is pre-installed. Apparently this is the case with Leopard and Snow Leopard but I don't seem to have it on Snow Leopard and never noticed it on Leopard. Also, I have tried installing the latest beta of PyObjc by following the instructions on the Sourceforge page, but with no luck. I would really appreciate it if anyone could shed some light on what needs to be installed, how, and links to any resources or tutorials that could help me. Thanks in advance for the help! Update: I see that this is a popular question, I just got the 'Notable Question' badge for it so I thought I would update anyone coming to this page on what I did after getting the answers. Unfortunately, I wasn't able to use Python to create a Mac application. This was rather disappointing at the time, but probably a good thing. I made a Windows app in C# for my project, it was a tool for creating and running Assembly apps in a simulated environment. My course teacher has now started to use my tool to teach the course instead of his own! I got a very high score on the computing project (over 90%) and this contributed to me getting an A* in my computing A-Level (the highest grade available) and I consequently got in to Southampton University to study Computer Science. This summer, I decided to make an iPad app (soon to be released) and I am glad to say that I know think I could make a Mac OS application in Objective-C as I feel I have learnt enough. I am glad that I took the time to learn it, it is a great language and really useful with iOS becoming so popular. Sorry for all the boasting, but I am really happy about it. What I really want to say is, if you are coming to this page hoping to use PyObjc to create Mac apps easily, don't bother. It takes some time and some effort, but once you have learnt Objective-C, it is really satisfying to create apps with it. Good Luck!
PyObjc and Cocoa on Snow Leopard
0.099668
0
0
4,914
1,359,227
2009-08-31T20:19:00.000
3
0
1
0
python,cocoa,xcode,osx-snow-leopard,pyobjc
1,359,428
6
false
0
1
I hardly use PyObjC myself, but I believe you need to run the Xcode installer on the Snow Leopard DVD in order to use PyObjC. Also, as Quinn said, you will need to understand at least some Objective-C in order to use a Cocoa bridge like PyObjC without tearing your hair out. It just doesn't insulate you that completely.
4
12
0
I am about to start my A-Level Computing project (High School Level) which will hopefully be a point-of-sale application for Mac OS. Unfortunately, Objective-C is a little out of my league at the moment and should I get stuck with it in the project I have no one to help out so I would fail the section of the course and not get into University. So this is quite important to me. I want to use Python to develop a Cocoa app. I know that I need PyObjc, however all details on the net seem to assume it is pre-installed. Apparently this is the case with Leopard and Snow Leopard but I don't seem to have it on Snow Leopard and never noticed it on Leopard. Also, I have tried installing the latest beta of PyObjc by following the instructions on the Sourceforge page, but with no luck. I would really appreciate it if anyone could shed some light on what needs to be installed, how, and links to any resources or tutorials that could help me. Thanks in advance for the help! Update: I see that this is a popular question, I just got the 'Notable Question' badge for it so I thought I would update anyone coming to this page on what I did after getting the answers. Unfortunately, I wasn't able to use Python to create a Mac application. This was rather disappointing at the time, but probably a good thing. I made a Windows app in C# for my project, it was a tool for creating and running Assembly apps in a simulated environment. My course teacher has now started to use my tool to teach the course instead of his own! I got a very high score on the computing project (over 90%) and this contributed to me getting an A* in my computing A-Level (the highest grade available) and I consequently got in to Southampton University to study Computer Science. This summer, I decided to make an iPad app (soon to be released) and I am glad to say that I know think I could make a Mac OS application in Objective-C as I feel I have learnt enough. I am glad that I took the time to learn it, it is a great language and really useful with iOS becoming so popular. Sorry for all the boasting, but I am really happy about it. What I really want to say is, if you are coming to this page hoping to use PyObjc to create Mac apps easily, don't bother. It takes some time and some effort, but once you have learnt Objective-C, it is really satisfying to create apps with it. Good Luck!
PyObjc and Cocoa on Snow Leopard
0.099668
0
0
4,914
1,359,449
2009-08-31T21:10:00.000
4
0
0
0
python,django,mod-wsgi
2,978,457
4
false
1
0
I just had this problem. It went away when I added sys.path.append('/path/to/project') to my .wsgi file.
4
3
0
I have fecora 11, set django with mod_wsgi2.5 and apache2.2. And I can run "python manage.py runserver" at local. It works fine. I got error when i test from remote browser. Thanks for any suggestion and help!
django : ImportError No module named myapp.views.hometest
0.197375
0
0
7,581
1,359,449
2009-08-31T21:10:00.000
1
0
0
0
python,django,mod-wsgi
1,360,370
4
false
1
0
All required env variables should be set in django.wsgi. You could compare the env declared in django.wsgi and the env of executing ./manage runserver and make sure they are same. Furthermore, if there is another myapp package which could be found through PYTHONPATH before /usr/local/django/myapp, ImportError may be raised.
4
3
0
I have fecora 11, set django with mod_wsgi2.5 and apache2.2. And I can run "python manage.py runserver" at local. It works fine. I got error when i test from remote browser. Thanks for any suggestion and help!
django : ImportError No module named myapp.views.hometest
0.049958
0
0
7,581
1,359,449
2009-08-31T21:10:00.000
2
0
0
0
python,django,mod-wsgi
1,359,482
4
false
1
0
Is the application containing your Django project in your $PYTHONPATH (when Python is invoked in a server context)? For example, if your Django project is at /home/wwwuser/web/myproj, then /home/wwwuser/web should be in your $PYTHONPATH. You should set this in the script that loads the project when invoked from the web server.
4
3
0
I have fecora 11, set django with mod_wsgi2.5 and apache2.2. And I can run "python manage.py runserver" at local. It works fine. I got error when i test from remote browser. Thanks for any suggestion and help!
django : ImportError No module named myapp.views.hometest
0.099668
0
0
7,581
1,359,449
2009-08-31T21:10:00.000
1
0
0
0
python,django,mod-wsgi
1,359,494
4
false
1
0
Just a guess, but unless you've explicitly made sure that your app is on PYTHONPATH, you should be specifying views in urls.py as myproject.myapp.views.functionname. Otherwise: check if you're setting PYTHONPATH, or what to. Your project directory should be in there. if you enable the django admin (by uncommenting the lines that are there by default in urls.py), does that work?
4
3
0
I have fecora 11, set django with mod_wsgi2.5 and apache2.2. And I can run "python manage.py runserver" at local. It works fine. I got error when i test from remote browser. Thanks for any suggestion and help!
django : ImportError No module named myapp.views.hometest
0.049958
0
0
7,581
1,360,507
2009-09-01T04:17:00.000
0
0
1
0
python-3.x,python
1,360,566
3
false
0
0
a list out of the second element of each inner list that sounds like [sl[1] for sl in dict1['a']] -- so what's the QUESTION?!-)
1
2
0
I have a dictionary dict1['a'] = [ [1,2], [3,4] ] and need to generate a list out of it as l1 = [2, 4]. That is, a list out of the second element of each inner list. It can be a separate list or even the dictionary can be modified as dict1['a'] = [2,4].
Generating a list from complex dictionary
0
0
0
261
1,363,413
2009-09-01T16:27:00.000
2
0
1
0
python,performance,list,lambda,map-function
1,363,489
9
false
0
0
Several of the other respondents have reasonable implementations of the algorithm you asked for, but I'm unclear on exactly what problem it is you're really trying to solve. Unless the numbers being stored are very large (i.e., overflow an integer and require bignums), your list of diffs won't gain you any efficiency -- an integer is an integer from the Python runtime POV, so your example "diff" list of [-1, -1, 1, 2] will consume just as much memory as the original list [1005, 1004, 1003, 1004, 1006].
1
3
0
I need to store a big list of integers in Bigtable(db). For efficiency I am storing them as diff between 2 consecutive items. for eg: original_list = [1005, 1004, 1003, 1004, 1006] Storing the above list(which actually contains more than 1000k items) as start = 1005 diff = [-1, -1, 1, 2] The closest I could manage is, ltp = [start] map(lambda x: ltp.append(ltp[-1] + x), tick) I am looking for an efficient way to convert it back into original list.
Efficient way to use python's lambda, map
0.044415
0
0
7,607
1,364,173
2009-09-01T19:17:00.000
10
0
0
0
python
48,303,184
12
false
0
0
On Mac press Ctrl+\ to quit a python process attached to a terminal.
7
142
0
I have a python script that uses threads and makes lots of HTTP requests. I think what's happening is that while a HTTP request (using urllib2) is reading, it's blocking and not responding to CtrlC to stop the program. Is there any way around this?
Stopping python using ctrl+c
1
0
1
234,195
1,364,173
2009-09-01T19:17:00.000
24
0
0
0
python
40,704,008
12
false
0
0
This post is old but I recently ran into the same problem of Ctrl+C not terminating Python scripts on Linux. I used Ctrl+\ (SIGQUIT).
7
142
0
I have a python script that uses threads and makes lots of HTTP requests. I think what's happening is that while a HTTP request (using urllib2) is reading, it's blocking and not responding to CtrlC to stop the program. Is there any way around this?
Stopping python using ctrl+c
1
0
1
234,195
1,364,173
2009-09-01T19:17:00.000
3
0
0
0
python
42,792,308
12
false
0
0
On a mac / in Terminal: Show Inspector (right click within the terminal window or Shell >Show Inspector) click the Settings icon above "running processes" choose from the list of options under "Signal Process Group" (Kill, terminate, interrupt, etc).
7
142
0
I have a python script that uses threads and makes lots of HTTP requests. I think what's happening is that while a HTTP request (using urllib2) is reading, it's blocking and not responding to CtrlC to stop the program. Is there any way around this?
Stopping python using ctrl+c
0.049958
0
1
234,195
1,364,173
2009-09-01T19:17:00.000
1
0
0
0
python
52,672,359
12
false
0
0
Forcing the program to close using Alt+F4 (shuts down current program) Spamming the X button on CMD for e.x. Taskmanager (first Windows+R and then "taskmgr") and then end the task. Those may help.
7
142
0
I have a python script that uses threads and makes lots of HTTP requests. I think what's happening is that while a HTTP request (using urllib2) is reading, it's blocking and not responding to CtrlC to stop the program. Is there any way around this?
Stopping python using ctrl+c
0.016665
0
1
234,195
1,364,173
2009-09-01T19:17:00.000
57
0
0
0
python
1,364,179
12
false
0
0
If it is running in the Python shell use Ctrl + Z, otherwise locate the python process and kill it.
7
142
0
I have a python script that uses threads and makes lots of HTTP requests. I think what's happening is that while a HTTP request (using urllib2) is reading, it's blocking and not responding to CtrlC to stop the program. Is there any way around this?
Stopping python using ctrl+c
1
0
1
234,195
1,364,173
2009-09-01T19:17:00.000
1
0
0
0
python
54,316,333
12
false
0
0
For the record, what killed the process on my Raspberry 3B+ (running raspbian) was Ctrl+'. On my French AZERTY keyboard, the touch ' is also number 4.
7
142
0
I have a python script that uses threads and makes lots of HTTP requests. I think what's happening is that while a HTTP request (using urllib2) is reading, it's blocking and not responding to CtrlC to stop the program. Is there any way around this?
Stopping python using ctrl+c
0.016665
0
1
234,195
1,364,173
2009-09-01T19:17:00.000
206
0
0
0
python
1,364,199
12
true
0
0
On Windows, the only sure way is to use CtrlBreak. Stops every python script instantly! (Note that on some keyboards, "Break" is labeled as "Pause".)
7
142
0
I have a python script that uses threads and makes lots of HTTP requests. I think what's happening is that while a HTTP request (using urllib2) is reading, it's blocking and not responding to CtrlC to stop the program. Is there any way around this?
Stopping python using ctrl+c
1.2
0
1
234,195
1,364,733
2009-09-01T21:26:00.000
17
0
0
1
python,google-app-engine,redirect
1,364,875
5
true
1
0
You can check if os.environ['HTTP_HOST'].endswith('.appspot.com') -- if so, then you're serving from something.appspot.com and can send a redirect, or otherwise alter your behavior as desired. You could deploy this check-and-redirect-if-needed (or other behavior alteration of your choice) in any of various ways (decorators, WSGI middleware, inheritance from an intermediate base class of yours that subclasses webapp.RequestHandler [[or whatever other base handler class you're currently using]] and method names different than get and post in your application-level handler classes, and others yet) but I think that the key idea here is that os.environ is set by the app engine framework according to CGI standards and so you can rely on those standards (similarly WSGI builds its own environment based on the values it picks up from os.environ).
1
14
0
How can I prevent a user from accessing my app at example.appspot.com and force them to access it at example.com? I already have example.com working, but I don't want users to be able to access the appspot domain. I'm using python.
Block requests from *.appspot.com and force custom domain in Google App Engine
1.2
0
0
5,133
1,365,164
2009-09-01T23:32:00.000
5
0
0
0
python,database,settings
1,365,175
4
false
0
0
One caveat might depend on where the user is using the application from. For example, if they use two computers with different screen resolutions, and 'selected zoom/text size' is one of the things you associate with the user, it might not always be suitable. It depends what kind of settings you intend to allow the user to customize. My workplace still has some users trapped on tiny LCD screens with a max res of 800x600, and we have to account for those when developing.
4
2
0
I'm building a fairly large enterprise application made in python that on its first version will require network connection. I've been thinking in keeping some user settings stored on the database, instead of a file in the users home folder. Some of the advantages I've thought of are: the user can change computers keeping all its settings settings can be backed up along with the rest of the systems data (not a big concern) What would be some of the caveats of this approach?
Is storing user configuration settings on database OK?
0.244919
1
0
650
1,365,164
2009-09-01T23:32:00.000
3
0
0
0
python,database,settings
1,365,176
4
false
0
0
Do you need the database to run any part of the application? If that's the case there are no reasons not to store the config inside the DB. You already mentioned the benefits and there are no downsides.
4
2
0
I'm building a fairly large enterprise application made in python that on its first version will require network connection. I've been thinking in keeping some user settings stored on the database, instead of a file in the users home folder. Some of the advantages I've thought of are: the user can change computers keeping all its settings settings can be backed up along with the rest of the systems data (not a big concern) What would be some of the caveats of this approach?
Is storing user configuration settings on database OK?
0.148885
1
0
650
1,365,164
2009-09-01T23:32:00.000
3
0
0
0
python,database,settings
1,365,183
4
false
0
0
It's perfectly reasonable to keep user settings in the database, as long as the settings pertain to the application independent of user location. One possible advantage of a file in the user's home folder is that users can send settings to one another. You may of course regard this as an advantage or a disadvantage :-)
4
2
0
I'm building a fairly large enterprise application made in python that on its first version will require network connection. I've been thinking in keeping some user settings stored on the database, instead of a file in the users home folder. Some of the advantages I've thought of are: the user can change computers keeping all its settings settings can be backed up along with the rest of the systems data (not a big concern) What would be some of the caveats of this approach?
Is storing user configuration settings on database OK?
0.148885
1
0
650
1,365,164
2009-09-01T23:32:00.000
8
0
0
0
python,database,settings
1,365,178
4
true
0
0
This is pretty standard. Go for it. The caveat is that when you take the database down for maintenance, no one can use the app because their profile is inaccessible. You can either solve that by making a 100%-on db solution, or, more easily, through some form of caching of profiles locally (an "offline" mode of operations). That would allow your app to function whether the user or the db are off the network.
4
2
0
I'm building a fairly large enterprise application made in python that on its first version will require network connection. I've been thinking in keeping some user settings stored on the database, instead of a file in the users home folder. Some of the advantages I've thought of are: the user can change computers keeping all its settings settings can be backed up along with the rest of the systems data (not a big concern) What would be some of the caveats of this approach?
Is storing user configuration settings on database OK?
1.2
1
0
650
1,365,254
2009-09-02T00:03:00.000
1
1
0
1
python,security,design-patterns,authentication,cracking
1,365,394
2
false
0
0
Possibly: The user enters their credentials into the desktop client. The client says to the server: "Hi, my name username and my password is password". The server checks these. The server says to the client: "Hi, username. Here is your secret token: ..." Subsequently the client uses the secret token together with the username to "sign" communications with the server.
2
2
0
I'm building a centralized desktop application using Python/wxPython. One of the requirements is User authentication, which I'm trying to implement using LDAP (although this is not mandatory). Users of the system will be mechanical and electrical engineers making budgets, and the biggest problem would be industrial espionage. Its a common problem that leaks occur commonly from the bottom on informal ways, and this could pose problems. The system is set up in such a way that every user has access to all and only the information it needs, so that no one person but the people on top has monetary information on the whole project. The problem is that, for every way I can think to implement the authentication system, Python's openness makes me think of at least one way of bypassing/getting sensible information from the system, because "compiling" with py2exe is the closest I can get to obfuscation of the code on Windows. I'm not really trying to hide the code, but rather make the authentication routine secure by itself, make it in such a way that access to the code doesn't mean capability to access the application. One thing I wanted to add, was some sort of code signing to the access routine, so the user can be sure that he is not running a modified client app. One of the ways I've thought to avoid this is making a C module for the authentication, but I would rather not have to do that. Of course this question is changing now and is not just "Could anyone point me in the right direction as to how to build a secure authentication system running on Python? Does something like this already exist?", but "How do you harden an scripting (Python) against wrongful modification?"
How to deal with user authentication and wrongful modification in scripting languages?
0.099668
0
0
272
1,365,254
2009-09-02T00:03:00.000
3
1
0
1
python,security,design-patterns,authentication,cracking
1,365,422
2
true
0
0
How malicious are your users? Really. Exactly how malicious? If your users are evil sociopaths and can't be trusted with a desktop solution, then don't build a desktop solution. Build a web site. If your users are ordinary users, they'll screw the environment up by installing viruses, malware and keyloggers from porn sites before they try to (a) learn Python (b) learn how your security works and (c) make a sincere effort at breaking it. If you actually have desktop security issues (i.e., public safety, military, etc.) then rethink using the desktop. Otherwise, relax, do the right thing, and don't worry about "scripting". C++ programs are easier to hack because people are lazy and permit SQL injection.
2
2
0
I'm building a centralized desktop application using Python/wxPython. One of the requirements is User authentication, which I'm trying to implement using LDAP (although this is not mandatory). Users of the system will be mechanical and electrical engineers making budgets, and the biggest problem would be industrial espionage. Its a common problem that leaks occur commonly from the bottom on informal ways, and this could pose problems. The system is set up in such a way that every user has access to all and only the information it needs, so that no one person but the people on top has monetary information on the whole project. The problem is that, for every way I can think to implement the authentication system, Python's openness makes me think of at least one way of bypassing/getting sensible information from the system, because "compiling" with py2exe is the closest I can get to obfuscation of the code on Windows. I'm not really trying to hide the code, but rather make the authentication routine secure by itself, make it in such a way that access to the code doesn't mean capability to access the application. One thing I wanted to add, was some sort of code signing to the access routine, so the user can be sure that he is not running a modified client app. One of the ways I've thought to avoid this is making a C module for the authentication, but I would rather not have to do that. Of course this question is changing now and is not just "Could anyone point me in the right direction as to how to build a secure authentication system running on Python? Does something like this already exist?", but "How do you harden an scripting (Python) against wrongful modification?"
How to deal with user authentication and wrongful modification in scripting languages?
1.2
0
0
272
1,365,265
2009-09-02T00:07:00.000
47
0
0
1
python,sockets,ipc,port
1,365,281
5
false
0
0
Bind the socket to port 0. A random free port from 1024 to 65535 will be selected. You may retrieve the selected port with getsockname() right after bind().
2
189
0
I'm trying to play with inter-process communication and since I could not figure out how to use named pipes under Windows I thought I'll use network sockets. Everything happens locally. The server is able to launch slaves in a separate process and listens on some port. The slaves do their work and submit the result to the master. How do I figure out which port is available? I assume I cannot listen on port 80 or 21? I'm using Python, if that cuts the choices down.
On localhost, how do I pick a free port number?
1
0
1
154,753
1,365,265
2009-09-02T00:07:00.000
4
0
0
1
python,sockets,ipc,port
1,365,283
5
false
0
0
You can listen on whatever port you want; generally, user applications should listen to ports 1024 and above (through 65535). The main thing if you have a variable number of listeners is to allocate a range to your app - say 20000-21000, and CATCH EXCEPTIONS. That is how you will know if a port is unusable (used by another process, in other words) on your computer. However, in your case, you shouldn't have a problem using a single hard-coded port for your listener, as long as you print an error message if the bind fails. Note also that most of your sockets (for the slaves) do not need to be explicitly bound to specific port numbers - only sockets that wait for incoming connections (like your master here) will need to be made a listener and bound to a port. If a port is not specified for a socket before it is used, the OS will assign a useable port to the socket. When the master wants to respond to a slave that sends it data, the address of the sender is accessible when the listener receives data. I presume you will be using UDP for this?
2
189
0
I'm trying to play with inter-process communication and since I could not figure out how to use named pipes under Windows I thought I'll use network sockets. Everything happens locally. The server is able to launch slaves in a separate process and listens on some port. The slaves do their work and submit the result to the master. How do I figure out which port is available? I assume I cannot listen on port 80 or 21? I'm using Python, if that cuts the choices down.
On localhost, how do I pick a free port number?
0.158649
0
1
154,753
1,365,737
2009-09-02T03:45:00.000
4
0
0
1
python,twisted
1,408,498
3
true
0
0
The best option is really just to do the obvious thing here. Don't have a loop, or a repeating timed call; just have handlers that do the right thing. Keep a central connection-management object around, and make event-handling methods feed it the information it needs to keep going. When it starts, make 5 outgoing connections. Keep track of how many are in progress, maintain a list with them in it. When a connection succeeds (in connectionMade) update the list to remember the connection's new state. When a connection completes (in connectionLost) tell the connection manager; its response should be to remove that connection and make a new connection somewhere else. In the middle, it should be fairly obvious how to fire off a request for the names you need and stuff them into a database (waiting for the database insert to complete before dropping your IRC connection, most likely, by waiting for the Deferred to come back from adbapi).
1
6
0
I'm trying to use Twisted in a sort of spidering program that manages multiple client connections. I'd like to maintain of a pool of about 5 clients working at one time. The functionality of each client is to connect to a specified IRC server that it gets from a list, enter a specific channel, and then save the list of the users in that channel to a database. The problem I'm having is more architectural than anything. I'm fairly new to Twisted and I don't know what options are available for managing multiple clients. I'm assuming the easiest way is to simply have each ClientCreator instance die off once it's completed its work and have a central loop that can check to see if there's room to add a new client. I would think this isn't a particularly unusual problem so I'm hoping to glean some information from other peoples' experiences.
Managing multiple Twisted client connections
1.2
0
1
4,725
1,365,797
2009-09-02T04:15:00.000
9
0
0
1
python,windows,python-2.x
1,365,827
6
false
0
0
In order to use the \\?\ prefix (as already proposed), you also need to make sure you use Unicode strings as filenames, not regular (byte) strings.
1
13
0
I write Python script to copy files; unfortunately it keeps failing because filename is too long(>256). Is there anyway to deal with that problem? I'm using Python 2.5.4 and Windows XP. Cheers,
Python long filename support broken in Windows
1
0
0
8,165
1,367,189
2009-09-02T11:39:00.000
5
0
0
0
python,download,webpage,wget,web-crawler
1,367,209
2
true
1
0
Write a bash script that uses wget and put it in your crontab to run every 5 minutes. (*/5 * * * *) If you need to keep a history of all these web pages, set a variable at the beginning of your script with the current unixtime and append it to the output filenames.
1
1
0
I want to download a list of web pages. I know wget can do this. However downloading every URL in every five minutes and save them to a folder seems beyond the capability of wget. Does anyone knows some tools either in java or python or Perl which accomplishes the task? Thanks in advance.
How to download a webpage in every five minutes?
1.2
0
1
2,545
1,367,453
2009-09-02T12:39:00.000
1
0
0
0
python,web-services,sockets
1,372,289
4
false
0
0
The furthest I came was using modified asynchttp, that codeape suggested. I have tried to use both asyncore/asynchat and asynchttp, with lots of pain. It took me far too long to try to fix all the bugs in it (there's a method handle_read, nearly copied from asyncore, only badly indented and was giving me headaches with chunked encoding). Also, asyncore and asynchat are best not used according to some hints I got on google. I have settled with twisted, but that's obviously out of the question for you. It might also depend what are you trying to do with your application and why you want async requests, if threads are an option or not, if you're doing GUI programming or something else so if you could shed some more inforation, that's always good. If not, I'd vote for threaded version suggested above, it offers much more readability and maintainability.
1
7
0
I would like to read a website asynchronously, which isnt possible with urllib as far as I know. Now I tried reading with with plain sockets, but HTTP is giving me hell. I run into all kind of funky encodings, for example transfer-encoding: chunked, have to parse all that stuff manually, and I feel like coding C, not python at the moment. Isnt there a nicer way like URLLib, asynchronously? I dont really feel like re-implementing the whole HTTP specification, when it's all been done before. Twisted isnt an option currently. Greetings, Tom
Reading a website with asyncore
0.049958
0
1
2,352
1,368,261
2009-09-02T15:03:00.000
6
0
1
0
python,io,buffer
1,368,274
2
false
0
0
I think you might be looking for StringIO.
1
17
0
I've written a buffer class that provides a File-like interface with read, write, seek, tell, flush methods to a simple string in memory. Of course it is incomplete (e.g. I didn't write readline). It's purpose is to be filled by a background thread from some external data source, but let a user treat it like a file. I'd expect it to contain a relatively small amount of data (maybe 50K max) Is there a better way to do this instead of writing it from scratch?
python file-like buffer object
1
0
0
14,219
1,369,086
2009-09-02T17:27:00.000
5
0
0
0
wxpython,textctrl
1,370,281
7
true
0
1
IntCtrl, Masked Edit Control, and NumCtrl are all designed to do just this, with different levels of control. Checkout the wx demo under "More Windows/Controls" to see how they work. (Or, if you're instead really looking forward to doing this directly with a raw TextCtrl, I think you'd want to catch EVT_CHAR events, test the characters, and call evt.Skip() if it was an allowed character.)
2
10
0
I want to have a text control that only accepts numbers. (Just integer values like 45 or 366) What is the best way to do this?
Is it possible to limit TextCtrl to accept numbers only in wxPython?
1.2
0
0
11,475
1,369,086
2009-09-02T17:27:00.000
-1
0
0
0
wxpython,textctrl
23,052,986
7
false
0
1
Please check "Validator.py" script in wxpython demo. it is exactly what you need
2
10
0
I want to have a text control that only accepts numbers. (Just integer values like 45 or 366) What is the best way to do this?
Is it possible to limit TextCtrl to accept numbers only in wxPython?
-0.028564
0
0
11,475
1,369,167
2009-09-02T17:47:00.000
2
0
1
0
python,open-source,platform
1,371,057
3
false
0
0
I already set up my own server. Solace seems great.
2
6
0
Has anyone tried Solace yet? "Solace is a fully open-sourced multilingual support and knowledge exchange platform written in Python." Just wanted to know your experience. Are there any other such platforms available in open source?
Anyone tried Solace? Solace - a multilingual support platform
0.132549
0
0
1,060
1,369,167
2009-09-02T17:47:00.000
2
0
1
0
python,open-source,platform
2,694,946
3
false
0
0
We just started using it at our company. You get what you pay for. Feels like a weekender project. Gets the job done, but lacks the polish of Stack Overflow. The documentation is weak. I find it ironic that Plurk doesn't run an instance of Solace to field support questions for Solace. If they do they don't advertise it.
2
6
0
Has anyone tried Solace yet? "Solace is a fully open-sourced multilingual support and knowledge exchange platform written in Python." Just wanted to know your experience. Are there any other such platforms available in open source?
Anyone tried Solace? Solace - a multilingual support platform
0.132549
0
0
1,060
1,369,861
2009-09-02T20:10:00.000
2
0
0
1
python,api,google-app-engine,picasa,urlfetch
1,369,908
1
true
1
0
Your question is a little off, since the Data API is exposed through RESTful URLs, so both methods are ultimately a "URL Fetch". The Data API works quite well, though. It gives you access to nearly all the functionality of Picasa, and responses are sent back and forth in well-formed, well-documented XML. Google's documentation for the API is very good. If you only need access to limited publicly available content (like a photostream) then you can do this at a very basic level by just fetching the feed url and parsing that... but even for that you can get the same data with more configuration options via the Data API URLs. I'm not sure what code samples you'd like... it really depends what you actually want to do with Picasa.
1
0
0
How would you query Picasa from a Google App Engine app? Data API or Url Fetch? What are the pros and cons of using either method? [Edit] I would like to be able to query a specific album in Picasa and list all the photos in it. Code examples to do this in python are much appreciated.
How would you query Picasa from a Google App Engine app? Data API or Url Fetch?
1.2
0
0
1,248
1,371,994
2009-09-03T07:50:00.000
3
1
1
0
python,import,ironpython
67,905,932
3
false
0
1
If you have installed IronPython from NuGet packages and you want modules from the CPython Standard Library then the best way to do it is by installing the IronPython.StdLib NuGet package which is from the same authors of IronPython.
1
20
0
I'm currently working on an application written in C#, which I'm embedding IronPython in. I generally have no problems about it, but there's one thing that I don't know how to deal with. I want to import an external module into the script. How can I do that? Simple import ext_lib doesn't work. Should I add a path to the lib to sys.path? Maybe it is possible to copy the lib's .py file into app directory and import from there? EDIT: I finally chosen another solution - compiled my script with py2exe and I'm just running it from main C# app with Process (without using IronPython). Anyway, thanks for help ;)
Importing external module in IronPython
0.197375
0
0
34,961
1,372,531
2009-09-03T10:02:00.000
1
0
1
0
c#,java,c++,python,algorithm
1,372,627
4
false
0
0
You could build an index which maps words to phrases and do something like: let matched = set of all phrases for each word in the searched phrase let wordMatch = all phrases containing the current word let matched = intersection of matched and wordMatch After this, matched would contain all phrases matching all words in the target phrase. It could be pretty well optimized by initializing matched to the set of all phrases containing only words[0], and then only iterating over words[1..words.length]. Filtering phrases which are too short to match the target phrase may improve performance, too. Unless I'm mistaken, a simple implementation has a worst case complexity (when the search phrase matches all phrases) of O(n·m), where n is the number of words in the search phrase, and m is the number of phrases.
2
1
1
Given a set of phrases, i would like to filter the set of all phrases that contain any of the other phrases. Contained here means that if a phrase contains all the words of another phrase it should be filtered out. Order of the words within the phrase does not matter. What i have so far is this: Sort the set by the number of words in each phrase. For each phrase X in the set: For each phrase Y in the rest of the set: If all the words in X are in Y then X is contained in Y, discard Y. This is slow given a list of about 10k phrases. Any better options?
Algorithm to filter a set of all phrases containing in other phrase
0.049958
0
0
709
1,372,531
2009-09-03T10:02:00.000
0
0
1
0
c#,java,c++,python,algorithm
1,372,585
4
false
0
0
sort phrases by their contents, i.e., 'Z A' -> 'A Z', then eliminating phrases is easy going from shortest to longer ones.
2
1
1
Given a set of phrases, i would like to filter the set of all phrases that contain any of the other phrases. Contained here means that if a phrase contains all the words of another phrase it should be filtered out. Order of the words within the phrase does not matter. What i have so far is this: Sort the set by the number of words in each phrase. For each phrase X in the set: For each phrase Y in the rest of the set: If all the words in X are in Y then X is contained in Y, discard Y. This is slow given a list of about 10k phrases. Any better options?
Algorithm to filter a set of all phrases containing in other phrase
0
0
0
709
1,376,835
2009-09-04T01:40:00.000
0
0
1
0
python,regex
1,376,880
5
false
0
0
First of all, you'll need some conventions. Is 3.55 five minutes to four hours, five milliseconds to four seconds, or 3 and 55/100 of a minute/hour/second? The same applies to 3:55. At least have a distinction between dot and colon, specifying that a dot means a fraction and a colon, a separator of hour/minute/second. Although you haven't specified what "time" is (since or o'clock?), you'll need that too. Then, it's simple a matter of having a final representation of a time that you want to work with, and keep converting the input until your final representation is achieved. Let's say you decide that ultimately time should be represented as MM:SS (two digits for minutes, a colon, two digits for seconds), you'll need to search the string for allowed occurrences of characters, and act accordingly. For example, having a colon and a dot at the same time is not allowed. If there's a single colon, you have a fraction, therefore you'll treat the second part as a fraction of 60. Keep doing this until you have your final representation, and then just do what you gotta do with said "time". I don't know on what constraints you're working with, but the problem could be narrowed if instead of a single "time" input, you had two: The first, where people type the hours, and the second, where they type the minutes. Of course, that would only work if you can divide the input...
3
0
0
I need to calculate (using python) how much time a user has inputed, whether they input something like 3:30 or 3.5. I'm not really sure what the best way to go about this is and I thought I'd ask for advice from the experts. === Edit ================== To specify more clearly, I want the user to input hours and minutes or just minutes. I want them to be able to input the time in two formats, either in hh:mm (3:30 or 03:30) or as a float (3.5) hours. The overall goal is to keep track of the time they have worked. So, I will be adding the time they enter up to get a total.
calculate user inputed time with Python
0
0
0
2,254
1,376,835
2009-09-04T01:40:00.000
0
0
1
0
python,regex
1,376,843
5
false
0
0
There are a few possible solutions, but at some point you're gonna run into ambiguous cases that will result in arbitrary conversions. Overall I'd suggest taking any input and parsing the separators (whether : or . or something else) and then converting to seconds based on some schema of units you've defined. Alternatively you could do a series of try/except statements to test it against different time formatting schemes to see if it matches. I'm not sure what will be best in your case...
3
0
0
I need to calculate (using python) how much time a user has inputed, whether they input something like 3:30 or 3.5. I'm not really sure what the best way to go about this is and I thought I'd ask for advice from the experts. === Edit ================== To specify more clearly, I want the user to input hours and minutes or just minutes. I want them to be able to input the time in two formats, either in hh:mm (3:30 or 03:30) or as a float (3.5) hours. The overall goal is to keep track of the time they have worked. So, I will be adding the time they enter up to get a total.
calculate user inputed time with Python
0
0
0
2,254
1,376,835
2009-09-04T01:40:00.000
0
0
1
0
python,regex
1,377,036
5
false
0
0
Can you do this with a GUI and restrict the user input? Processing the text seems super error prone otherwise (on the part of the user, not to mention the programmer), and for hours worked... you sort-of want to get that right.
3
0
0
I need to calculate (using python) how much time a user has inputed, whether they input something like 3:30 or 3.5. I'm not really sure what the best way to go about this is and I thought I'd ask for advice from the experts. === Edit ================== To specify more clearly, I want the user to input hours and minutes or just minutes. I want them to be able to input the time in two formats, either in hh:mm (3:30 or 03:30) or as a float (3.5) hours. The overall goal is to keep track of the time they have worked. So, I will be adding the time they enter up to get a total.
calculate user inputed time with Python
0
0
0
2,254
1,377,130
2009-09-04T03:44:00.000
4
0
0
0
python,numpy,data-analysis
11,086,822
4
false
0
0
If you are willing to consider a library, pandas (http://pandas.pydata.org/) is a library built on top of numpy which amongst many other things provides: Intelligent data alignment and integrated handling of missing data: gain automatic label-based alignment in computations and easily manipulate messy data into an orderly form I've been using it for almost one year in the financial industry where missing and badly aligned data is the norm and it really made my life easier.
1
11
1
One of the things I deal with most in data cleaning is missing values. R deals with this well using its "NA" missing data label. In python, it appears that I'll have to deal with masked arrays which seem to be a major pain to set up and don't seem to be well documented. Any suggestions on making this process easier in Python? This is becoming a deal-breaker in moving into Python for data analysis. Thanks Update It's obviously been a while since I've looked at the methods in the numpy.ma module. It appears that at least the basic analysis functions are available for masked arrays, and the examples provided helped me understand how to create masked arrays (thanks to the authors). I would like to see if some of the newer statistical methods in Python (being developed in this year's GSoC) incorporates this aspect, and at least does the complete case analysis.
How do you deal with missing data using numpy/scipy?
0.197375
0
0
10,010
1,377,548
2009-09-04T06:28:00.000
0
1
1
0
.net,python,ironpython
1,383,258
5
false
0
0
You can also consider using Eclipse with PyDev which has support for IronPython
3
0
0
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good option, but can I run IronPython from it, and can I link to .NET assemblies from it? What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
0
0
0
210
1,377,548
2009-09-04T06:28:00.000
0
1
1
0
.net,python,ironpython
1,378,519
5
false
0
0
FWIW, Frood himself uses Wing IDE. But, if its on Windows, why not VS?
3
0
0
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good option, but can I run IronPython from it, and can I link to .NET assemblies from it? What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
0
0
0
210
1,377,548
2009-09-04T06:28:00.000
0
1
1
0
.net,python,ironpython
1,389,592
5
false
0
0
You can use Visual Studio. I use IronPython Studio integrated with VS2008. But I feel that it has very poor intellisense for Python.
3
0
0
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good option, but can I run IronPython from it, and can I link to .NET assemblies from it? What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
0
0
0
210
1,380,079
2009-09-04T15:52:00.000
7
0
0
0
python,ruby-on-rails,django,web2py
1,380,536
10
false
1
0
Web2py is a good one to learn. If this is going to be deployed to a server, double check it supports wsgi. Sometimes php is the way to go because you know it's supported almost anywhere.
5
15
0
Given the size of web2py and the lack of resources and corporate support, do you think it would be advisable to learn web2py as the only web development framework I know. I'm considersing learning Ruby on Rails or web2py for a website I need to create for as a school project.
web2py in the future?
1
0
0
9,030
1,380,079
2009-09-04T15:52:00.000
1
0
0
0
python,ruby-on-rails,django,web2py
10,003,970
10
false
1
0
I've already used Java EE and Django. The web2py learning curve is so fast! It's incredible! Things that I was getting a time to develop in three days using java, I can do fastly using web2py. Of course, Web2py has not the same ready plugins that RoR, but, doubtless, we can do these things fastly using web2py. Therefore, is a good opportunity to start learning = )
5
15
0
Given the size of web2py and the lack of resources and corporate support, do you think it would be advisable to learn web2py as the only web development framework I know. I'm considersing learning Ruby on Rails or web2py for a website I need to create for as a school project.
web2py in the future?
0.019997
0
0
9,030
1,380,079
2009-09-04T15:52:00.000
1
0
0
0
python,ruby-on-rails,django,web2py
3,646,728
10
false
1
0
Glad I found this thread! Cause some outdated pages and broken external links on Web2Py's website almost scared me off. But at least now I know there's a pretty good community around Web2Py. I've just been looking through a load of Python web frameworks, and Web2Py's description sounded enticing and managed to make Django sound overly laborious. Pretty sure there are some tangible benefits to Django's design decisions avoiding "too much magic" when it comes to larger projects. But to just throw something up on the web with err "sane defaults" sounds perfectly good to me. Instead of throwaway scripts, we can make throwaway websites to handle some temporary thing... There should be room for an appliance style framework with no installation... Interesting possibilities for some projects. I saw someone already got a python framework + server to work on android phones :)) For me, thanks to this thread, I will just learn both. Another thought; if Web2Py is open source and you like what it does you might not even mind being the only user at some point in the future, since you can add features to it yourself? Mind you, I have not used either yet, just read the docs. I think the Web2Py people should put up a blurb on their website to differentiate themselves from Django in more detail, I haven't been able to check off all my question marks for choosing the right one.
5
15
0
Given the size of web2py and the lack of resources and corporate support, do you think it would be advisable to learn web2py as the only web development framework I know. I'm considersing learning Ruby on Rails or web2py for a website I need to create for as a school project.
web2py in the future?
0.019997
0
0
9,030
1,380,079
2009-09-04T15:52:00.000
3
0
0
0
python,ruby-on-rails,django,web2py
1,381,094
10
false
1
0
Ask yourself what you are looking to gain from the experience. Ie, is it more important to just get the application built and running with a minimum of time and effort, or are you trying to learn about web stack architecture? If you're just looking for results, obviously you'll have more code and documentation to borrow from if you stick with a more commonly used framework. If you grit your teeth and accept Django's view of the world, you can build very functional applications very quickly. If you can find some pre-made reusable Django apps that handle part of your problem, it'll be even faster. But if you want to make sure you have a very solid understanding of everything in the request cycle from HTTP request handling to database access and abstraction to form generation and processing and HTML templating, you'll be bettered served with a minimal framework that forces you to think more about the architecture and has a small enough codebase that you can just read it all top to bottom and not really need documentation beyond that. In that case though, I'd advise going even deeper and building your own framework on top of a WSGI library (you don't actually want to waste time learning the intricacies of working around browser quirks if you can help it). Once you've built your own and seen where things get complicated and where the tradeoffs are, you'll be in an excellent position to judge other frameworks and decide if there's one that does things the way you want to work.
5
15
0
Given the size of web2py and the lack of resources and corporate support, do you think it would be advisable to learn web2py as the only web development framework I know. I'm considersing learning Ruby on Rails or web2py for a website I need to create for as a school project.
web2py in the future?
0.059928
0
0
9,030
1,380,079
2009-09-04T15:52:00.000
12
0
0
0
python,ruby-on-rails,django,web2py
1,380,121
10
false
1
0
Learning is good. Learning something (that eventually goes away) is no loss at all. The basic skills of web development (HTML, CSS, URL-parsing, GET vs. POST) don't ever change. Frameworks come and go. Learn as many as you can. Learn how to manage your learning so that you (a) get to the important stuff first and (b) leave the other framework stuff behind when tackling a new framework. Every framework has it's bias (or focus). Once you figure this out, you can make use of them without all the "compare and contrast" that slows some people down. Once you've learned web2py, you have to be careful learning Django that you start fresh, with no translation from old concepts to new.
5
15
0
Given the size of web2py and the lack of resources and corporate support, do you think it would be advisable to learn web2py as the only web development framework I know. I'm considersing learning Ruby on Rails or web2py for a website I need to create for as a school project.
web2py in the future?
1
0
0
9,030
1,380,592
2009-09-04T17:35:00.000
4
1
1
0
python,matlab,console
1,380,716
4
true
0
0
I really like Safari's Web Inspector Javascript console. Specifically: Collapsible interactive object hierarchies sprintf-style logging Pretty-printing of closures, allowing you to peer into the internals of anonymous functions Auto-complete / hinting of object properties on the command-line
2
3
0
Many languages of REPL consoles with additional features like autocomplete and intellisense. For instance, iPython, Mathematica, and PyCrust all make some effort to go beyond a basic read eval loop. REPLs are particularly useful in languages where interactive exploration is very important, such as Matlab or R. I'm looking for inspiration. What application provides the slickest REPL? Or what features do you always wish existed in your REPL of choice?
Slickest REPL console in any language
1.2
0
0
352
1,380,592
2009-09-04T17:35:00.000
5
1
1
0
python,matlab,console
1,380,870
4
false
0
0
Common Lisp and emacs with SLIME. All you could really want, think of, dream of, and then some.
2
3
0
Many languages of REPL consoles with additional features like autocomplete and intellisense. For instance, iPython, Mathematica, and PyCrust all make some effort to go beyond a basic read eval loop. REPLs are particularly useful in languages where interactive exploration is very important, such as Matlab or R. I'm looking for inspiration. What application provides the slickest REPL? Or what features do you always wish existed in your REPL of choice?
Slickest REPL console in any language
0.244919
0
0
352
1,380,784
2009-09-04T18:18:00.000
2
0
0
1
python,ubuntu,gtk,pygtk,window-management
1,380,909
6
false
0
0
I really don't know how to check if a window is a GTK one. But if you want to check how many windows are currently open try "wmctrl -l". Install it first of course.
1
10
0
How to get list opened windows in PyGTK or GTK or other programming language? in Ubuntu? edit: i want get list paths opened directories on desktop!
How to get list opened windows in PyGTK or GTK in Ubuntu?
0.066568
0
0
9,460
1,380,852
2009-09-04T18:34:00.000
2
0
1
1
python,ruby,executable
1,381,231
4
false
0
0
py2exe is great, I've used it before and it works just fine for encapsulating a program so it can run on other computers, even those lacking python. Like Alex said, it can be disassembled, but then so can C++ binaries. It's just a question of how much work the person is has to put into it. If someone has physical access to a the computer where data is stored, they have access to the data (And there's no difference between code and data). Compress it, encrypt it, compile it, those will only slow the determined. Realistically, if you want to make the source code to your program as inaccessible as possible, you probably shouldn't look at Python or Ruby. C++ and some of the others are far more difficult to decompile, thereby providing more obscurity. You can practice the fine art of obfuscation, but even that won't stop someone trying to steal it (It's not like you have to understand the code to put it up on the Pirate Bay).
2
0
0
What happens when you package a script as an executable? Is this a good way to distribute commercial applications? I remember I read something a long time ago that when you package scripts as executables, at runtime the exe decompresses the scripts to a temporary directory where they get ran. If it's like that, than I don't think this can be viewed as a good solution, because a skilled user could find out where that directory is located and find the source code. I'm interested in Python & Ruby.
Is packaging scripts as executables a solution for comercial applications?
0.099668
0
0
260
1,380,852
2009-09-04T18:34:00.000
3
0
1
1
python,ruby,executable
1,381,289
4
false
0
0
Creating an application and creating a commercial software business are two distinct things. At my job we have a commercial application developed in Ruby on Rails that is installed at client sites; no obfuscation or encryption applied. There is just so much more going on at a business level: support, customization, training that it's almost ludicrous to think that they'd do something with the source code. Most sites are lucky if they can spare the cycles to manage the application, much less start wallowing in someone else's codebase. Now that being said, we aren't publicly distributing the code or anything, just that we've made the choice to invest in making the application better and doing better by our customers than to burn the time trying to restrict access to our application.
2
0
0
What happens when you package a script as an executable? Is this a good way to distribute commercial applications? I remember I read something a long time ago that when you package scripts as executables, at runtime the exe decompresses the scripts to a temporary directory where they get ran. If it's like that, than I don't think this can be viewed as a good solution, because a skilled user could find out where that directory is located and find the source code. I'm interested in Python & Ruby.
Is packaging scripts as executables a solution for comercial applications?
0.148885
0
0
260
1,380,860
2009-09-04T18:36:00.000
9
0
1
0
python,tuples
1,381,304
8
false
0
0
" once the info is added to the DB, should I delete the tuple? i mean i dont need the tuple anymore." No. Generally, there's no reason to delete anything. There are some special cases for deleting, but they're very, very rare. Simply define a narrow scope (i.e., a function definition or a method function in a class) and the objects will be garbage collected at the end of the scope. Don't worry about deleting anything. [Note. I worked with a guy who -- in addition to trying to delete objects -- was always writing "reset" methods to clear them out. Like he was going to save them and reuse them. Also a silly conceit. Just ignore the objects you're no longer using. If you define your functions in small-enough blocks of code, you have nothing more to think about.]
1
353
0
I am learning Python and creating a database connection. While trying to add to the DB, I am thinking of creating tuples out of information and then add them to the DB. What I am Doing: I am taking information from the user and store it in variables. Can I add these variables into a tuple? Can you please help me with the syntax? Also if there is an efficient way of doing this, please share... EDIT Let me edit this question a bit...I only need the tuple to enter info into the DB. Once the information is added to the DB, should I delete the tuple? I mean I don't need the tuple anymore.
Add Variables to Tuple
1
1
0
728,594
1,380,985
2009-09-04T19:01:00.000
7
0
1
0
python,multithreading,logging
1,381,468
1
false
0
0
Not entirely sure what you mean by "one thread fails", but if by "fail" you mean that an exception propagates all the way up to the top function of the thread, then you can wrap every thread's top function (e.g. in a decorator) to catch any exception, log whatever you wish, and re-raise. The logging module should ensure thread-safety of logging actions without further precautions being needed on your part on that score.
1
3
0
I was thinking of using the logging module to log all events to one file. The number of threads should be constant from start to finish, but if one thread fails, I'd like to just log that and continue on. What's a simple way of accomplishing this? Thanks!
Logging multithreaded processes in python
1
0
0
1,671
1,381,346
2009-09-04T20:16:00.000
0
0
0
0
python,django,django-models,django-orm
1,381,517
5
false
1
0
I'd like to have a Python program which is run using a cronjob instead of manually visiting the correct URL to update the information. A simplistic alternative: write a cronjob to automatically "visit the correct URL to update the information" -- could be as simple as a curl or wget, after all. This doesn't answer the question in the title, but given the way you explain your real underlying problem it just might be the simplest and most immediate approach to solve it.
1
3
0
I have a website which fetches information from RSS feeds periodically (well, currently manually, and this is my problem). This is currently implemented as a normal Django view, which isn't very nice in my opinion. I'd like to have a Python program which is run using a cronjob instead of manually visiting the correct URL to update the information. What is the easiest way to make a Python program have access to my particular Django application and the Django ORM?
Easiest way to write a Python program with access to Django database functionality
0
0
0
3,911
1,381,741
2009-09-04T22:04:00.000
0
0
1
1
python,latex
1,381,791
7
false
0
0
You're going to need to use LaTeX to process to string. The process of rendering LaTex/TeX is very involved (it generally takes a 100+MB package to do the work), you're just not going to be able toss in a little python module to get the work done.
1
26
0
I have a function I am consuming that returns a string of latex code. I need to generate an image from this. Most of the methods I have seen for doing so suggest calling an external application via say the subprocess module which will generate the image for me. However, management is not keen on this as it will require external users to install additional software in addition to our own which, with our user base, is not something we can assume to be a simple task. So are there any python libraries that will accomplish the task of taking latex into a format (such as an image file) which is displayable in a GUI?
Converting latex code to Images (or other displayble format) with Python
0
0
0
19,039
1,382,252
2009-09-05T02:14:00.000
0
0
1
0
python,ruby,cocoa,xcode,pyobjc
1,448,482
5
false
1
0
The above coments were all good and helpful but didn't really help. Easiest thing I could find is to create an empty python/ruby project in xcode 3.1, then make copies of this project folder for every new project you work on. When you open the new/blank project, 3.2 has a new feature that lets you rename the project so you can have proper names for eacn new project.
1
6
0
Under xcode 3.2 my ObjectiveC + Python/Ruby projects can still be opened updated and compiled, but you cannot create new projects. Given that all traces of ruby and python are missing from xcode 3.2 (ie create project and add new ruby/python file), is there an easy way to get the templates installed again? I found some info about copying them into a folder somewhere, but I cant seem to get it to work, I suspect the folder location has changed for 3.2.
XCode 3.2 Ruby and Python templates
0
0
0
11,625
1,382,648
2009-09-05T06:43:00.000
1
1
1
0
python,pep
21,502,630
7
false
0
0
I'd also recommend PEPs 8 and 257. I know this deviates slightly from the original question, but I'd like to point out that PyCharm (probably the best Python IDE around in my opinion) automatically checks if you're following some of the most important PEP 8 guidelines, just in case anyone's interested...
2
70
0
I'm a fairly strong Python coder, but too much of my style is a little haphazard, and I'm sure there are more Pythonic solutions to many problems than the ones I come up with. Which PEPs are essential for any well versed Pythonista to read?
Which PEP's are must reads?
0.028564
0
0
7,197
1,382,648
2009-09-05T06:43:00.000
8
1
1
0
python,pep
1,382,662
7
false
0
0
I found that reading the declined ones can give some good insights into what's Pythonic and what isn't. This was a while ago so I don't have any specific examples.
2
70
0
I'm a fairly strong Python coder, but too much of my style is a little haphazard, and I'm sure there are more Pythonic solutions to many problems than the ones I come up with. Which PEPs are essential for any well versed Pythonista to read?
Which PEP's are must reads?
1
0
0
7,197
1,383,239
2009-09-05T12:33:00.000
2
0
1
0
python,global-variables,module,packages,init
1,383,549
4
false
0
0
You can define global variables from anywhere, but it is a really bad idea. import the __builtin__ module and modify or add attributes to this modules, and suddenly you have new builtin constants or functions. In fact, when my application installs gettext, I get the _() function in all my modules, without importing anything. So this is possible, but of course only for Application-type projects, not for reusable packages or modules. And I guess no one would recommend this practice anyway. What's wrong with a namespace? Said application has the version module, so that I have "global" variables available like version.VERSION, version.PACKAGE_NAME etc.
1
165
0
I want to define a constant that should be available in all of the submodules of a package. I've thought that the best place would be in in the __init__.py file of the root package. But I don't know how to do this. Suppose I have a few subpackages and each with several modules. How can I access that variable from these modules? Of course, if this is totally wrong, and there is a better alternative, I'd like to know it.
Can I use __init__.py to define global variables?
0.099668
0
0
111,923
1,383,590
2009-09-05T15:25:00.000
0
1
1
0
python,code-organization
1,383,613
6
false
0
0
Put them in the Path class, and document that they are "obscure" either with comments or docstrings. Separate them at the end if you like.
6
2
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
Code organization in Python: Where is a good place to put obscure methods?
0
0
0
328
1,383,590
2009-09-05T15:25:00.000
4
1
1
0
python,code-organization
1,383,607
6
false
0
0
If the method is relevant to the Path - no matter how obscure - I think it should reside within the class itself. If you have multiple places where you have path-related functionality, it leads to problems. For example, if you want to check if some functionality already exists, how will a new programmer know to check the other, less obvious places? I think a good practice might be to order functions by importance. As you may have heard, some suggest putting public members of classes first, and private/protected ones after. You could consider putting the common methods in your class higher than the obscure ones.
6
2
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
Code organization in Python: Where is a good place to put obscure methods?
0.132549
0
0
328
1,383,590
2009-09-05T15:25:00.000
0
1
1
0
python,code-organization
1,383,601
6
false
0
0
I would just prepend the names with an underscore _, to show that the reader shouldn't bother about them. It's conventionally the same thing as private members in other languages.
6
2
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
Code organization in Python: Where is a good place to put obscure methods?
0
0
0
328
1,383,590
2009-09-05T15:25:00.000
0
1
1
0
python,code-organization
1,383,639
6
false
0
0
Oh wait, I thought of something -- I can just define them in the Path.py module, where every obscure method will be a one-liner that will call the function from the separate module that currently exists. With this compromise, the obscure methods will comprise of maybe 10 lines in the end of the file instead of 50% of its bulk.
6
2
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
Code organization in Python: Where is a good place to put obscure methods?
0
0
0
328
1,383,590
2009-09-05T15:25:00.000
2
1
1
0
python,code-organization
1,383,623
6
true
0
0
If you're keen to put those methods in a different source file at any cost, AND keen to have them at methods at any cost, you can achieve both goals by using the different source file to define a mixin class and having your Path class import that method and multiply-inherit from that mixin. So, technically, it's quite feasible. However, I would not recommend this course of action: it's worth using "the big guns" (such as multiple inheritance) only to serve important goals (such as reuse and removing repetition), and separating methods out in this way is not really a particularly crucial goal. If those "obscure methods" played no role you would not be implementing them, so they must have SOME importance, after all; so I'd just clarify in docstrings and comments what they're for, maybe explicitly mention that they're rarely needed, and leave it at that.
6
2
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
Code organization in Python: Where is a good place to put obscure methods?
1.2
0
0
328
1,383,590
2009-09-05T15:25:00.000
0
1
1
0
python,code-organization
8,028,755
6
false
0
0
I suggest making them accessible from a property of the Path class called something like "Utilties". For example: Path.Utilities.RazzleDazzle. This will help with auto-completion tools and general maintenance.
6
2
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
Code organization in Python: Where is a good place to put obscure methods?
0
0
0
328
1,383,663
2009-09-05T16:01:00.000
-1
0
0
0
python,gtk,pygtk
1,507,847
2
false
0
1
I don't think the EventBox can send button events like "activated" and "clicked".
1
0
0
I would like to remove border on a gtk.Button and also set its size fixed. How can I accomplish that? My button looks like that: b = gtk.Button() b.set_relief(gtk.RELIEF_NONE) Thanks! p.d: I'm using pygtk
remove inner border on gtk.Button
-0.099668
0
0
2,081
1,383,863
2009-09-05T17:40:00.000
0
0
1
1
python,macos,path,multiple-versions
1,384,223
2
false
0
0
I just noticed/encountered this issue on my Mac. I have Python 2.5.4, 2.6.2, and 3.1.1 on my machine, and was looking for a way to easily change between them at will. That is when I noticed all the symlinks for the executables, which I found in both '/usr/bin' and '/usr/local/bin'. I ripped all the non-version specific symlinks out, leaving python2.5, python2.6, etc, and wrote a bash shell script that I can run as root to change one symlink I use to direct the path to the version of my choice '/Library/Frameworks/Python.framework/Versions/Current' The only bad thing about ripping the symlinks out, is if some other application needed them for some reason. My opinion as to why these symlinks are created is similar to Alex's assessment, the installer is trying to cover all of the bases. All of my versions have been installed by an installer, though I've been trying to compile my own to enable full 64-bit support, and when compiling and installing your own you can choose to not have the symlinks created or the PATH modified during installation.
2
5
0
If you install multiple versions of python (I currently have the default 2.5, installed 3.0.1 and now installed 2.6.2), it automatically puts stuff in /usr/local, and it also adjusts the path to include the /Library/Frameworks/Python/Versions/theVersion/bin, but whats the point of that when /usr/local is already on the PATH, and all installed versions (except the default 2.5, which is in /usr/bin) are in there? I removed the python framework paths from my PATH in .bash_profile, and I can still type "python -V" => "Python 2.5.1", "python2.6 -V" => "Python 2.6.2","python3 -V" => "Python 3.0.1". Just wondering why it puts it in /usr/local, and also changes the PATH. And is what I did fine? Thanks. Also, the 2.6 installation made it the 'current' one, having .../Python.framework/Versions/Current point to 2.6., So plain 'python' things in /usr/local/bin point to 2.6, but it doesn't matter because usr/bin comes first and things with the same name in there point to 2.5 stuff.. Anyway, 2.5 comes with leopard, I installed 3.0.1 just to have the latest version (that has a dmg file), and now I installed 2.6.2 for use with pygame. EDIT: OK, here's how I understand it. When you install, say, Python 2.6.2: A bunch of symlinks are added to /usr/local/bin, so when there's a #! /usr/local/bin/python shebang in a python script, it will run, and in /Applications/Python 2.6, the Python Launcher is made default application to run .py files, which uses /usr/local/bin/pythonw, and /Library/Frameworks/Python.framework/Versions/2.6/bin is created and added to the front of the path, so which python will get the python in there, and also #! /usr/bin/env python shebang's will run correctly.
OS X - multiple python versions, PATH and /usr/local
0
0
0
4,778
1,383,863
2009-09-05T17:40:00.000
5
0
1
1
python,macos,path,multiple-versions
1,383,891
2
true
0
0
There's no a priori guarantee that /usr/local/bin will stay on the PATH (especially it will not necessarily stay "in front of" /usr/bin!-), so it's perfectly reasonable for an installer to ensure the specifically needed /Library/.../bin directory does get on the PATH. Plus, it may be the case that the /Library/.../bin has supplementary stuff that doesn't get symlinked into /usr/local/bin, although I believe that's not currently the case with recent Mac standard distributions of Python. If you know that the way you'll arrange your path, and the exact set of executables you'll be using, are entirely satisfied from /usr/local/bin, then it's quite OK for you to remove the /Library/etc directories from your own path, of course.
2
5
0
If you install multiple versions of python (I currently have the default 2.5, installed 3.0.1 and now installed 2.6.2), it automatically puts stuff in /usr/local, and it also adjusts the path to include the /Library/Frameworks/Python/Versions/theVersion/bin, but whats the point of that when /usr/local is already on the PATH, and all installed versions (except the default 2.5, which is in /usr/bin) are in there? I removed the python framework paths from my PATH in .bash_profile, and I can still type "python -V" => "Python 2.5.1", "python2.6 -V" => "Python 2.6.2","python3 -V" => "Python 3.0.1". Just wondering why it puts it in /usr/local, and also changes the PATH. And is what I did fine? Thanks. Also, the 2.6 installation made it the 'current' one, having .../Python.framework/Versions/Current point to 2.6., So plain 'python' things in /usr/local/bin point to 2.6, but it doesn't matter because usr/bin comes first and things with the same name in there point to 2.5 stuff.. Anyway, 2.5 comes with leopard, I installed 3.0.1 just to have the latest version (that has a dmg file), and now I installed 2.6.2 for use with pygame. EDIT: OK, here's how I understand it. When you install, say, Python 2.6.2: A bunch of symlinks are added to /usr/local/bin, so when there's a #! /usr/local/bin/python shebang in a python script, it will run, and in /Applications/Python 2.6, the Python Launcher is made default application to run .py files, which uses /usr/local/bin/pythonw, and /Library/Frameworks/Python.framework/Versions/2.6/bin is created and added to the front of the path, so which python will get the python in there, and also #! /usr/bin/env python shebang's will run correctly.
OS X - multiple python versions, PATH and /usr/local
1.2
0
0
4,778
1,384,634
2009-09-06T01:11:00.000
0
1
0
0
python,template-engine,mako,genshi
1,384,847
5
false
0
0
You could discipline yourself to not inject any Python code within the template unless it's really the last resort to get the job done. I have faced a similar issue with Django's template where I have to do some serious CSS gymnastics to display my content. If I could have used some Python code in the template, it would have been better.
3
7
0
I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako. I've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe? Wouldn't templating JUST suffice without having embedded Python code?
Should I use Mako for Templating?
0
0
0
6,454
1,384,634
2009-09-06T01:11:00.000
2
1
0
0
python,template-engine,mako,genshi
1,384,671
5
false
0
0
This seems to be a bit of a religious issue. Django templates take a hard line: no code in templates. They do this because of their history as a system used in shops where there's a clear separation between those who write code and those who create pages. Others (perhaps you) don't make such a clear distinction, and would feel more comfortable having a more flexible line between layout and logic. It really comes down to a matter of taste.
3
7
0
I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako. I've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe? Wouldn't templating JUST suffice without having embedded Python code?
Should I use Mako for Templating?
0.07983
0
0
6,454
1,384,634
2009-09-06T01:11:00.000
16
1
0
0
python,template-engine,mako,genshi
1,391,510
5
false
0
0
Wouldn't templating JUST suffice without having embedded Python code? Only if your templating language has enough logical functionality that it is essentially a scripting language in itself. At which point, you might just as well have used Python. More involved sites often need complex presentation logic and non-trivial templated structures like sections repeated in different places/pages and recursive trees. This is no fun if your templating language ties your hands behind your back because it takes the religious position that "code in template are BAD". Then you just end up writing presentation helper functions in your Python business logic, which is a worse blending of presentation and application logic than you had to start with. Languages that take power away from you because they don't trust you to use it tastefully are lame.
3
7
0
I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako. I've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe? Wouldn't templating JUST suffice without having embedded Python code?
Should I use Mako for Templating?
1
0
0
6,454
1,385,722
2009-09-06T13:51:00.000
8
0
0
0
python,rich-internet-application
1,385,927
2
true
0
0
Inventing our own language was a miniscule part of the problem. What was important was developing the right framework, which is now available as Cappuccino (cappuccino.org). You ask what platform/language you could use to develop something similar? I assume you already know that the answer to what platform is the web. 280 Slides is web based, and that is an integral part of the experience. And when it comes to the web, you realistically have one development choice: JavaScript. Fortunately, once you accept that, there are a lot of things you can do, including targeting JavaScript with other languages (like Java with GWT). Objective-J is a pretty thin layer on top of JavaScript, so if it's the only thing keeping you from trying Cappuccino, I strongly recommend giving it a shot. As far as the server is concerned, there's nothing remarkable going on. Almost all the magic is happening in the browser.
1
3
0
I have seen 280slides.com and it is really impresive. But its developers had to create their own language. Which platform or language would you use to have an as similar as possible functionality? Is it possible to do something similar in python? Could you give any working examples?
How to get 280slides.com functionality?
1.2
0
0
335
1,386,093
2009-09-06T16:43:00.000
6
0
0
0
python,datetime,sqlite,sqlalchemy,pysqlite
1,386,154
4
false
0
0
Julian Day is handy for all sorts of date calculations, but it can's store the time part decently (with precise hours, minutes, and seconds). In the past I've used both Julian Day fields (for dates), and seconds-from-the-Epoch (for datetime instances), but only when I had specific needs for computation (of dates and respectively of times). The simplicity of ISO formatted dates and datetimes, I think, should make them the preferred choice, say about 97% of the time.
2
8
0
SQLite docs specifies that the preferred format for storing datetime values in the DB is to use Julian Day (using built-in functions). However, all frameworks I saw in python (pysqlite, SQLAlchemy) store the datetime.datetime values as ISO formatted strings. Why are they doing so? I'm usually trying to adapt the frameworks to storing datetime as julianday, and it's quite painful. I started to doubt that is worth the efforts. Please share your experience in this field with me. Does sticking with julianday make sense?
Shall I bother with storing DateTime data as julianday in SQLite?
1
1
0
1,707
1,386,093
2009-09-06T16:43:00.000
0
0
0
0
python,datetime,sqlite,sqlalchemy,pysqlite
3,089,486
4
false
0
0
Because 2010-06-22 00:45:56 is far easier for a human to read than 2455369.5318981484. Text dates are great for doing ad-hoc queries in SQLiteSpy or SQLite Manager. The main drawback, of course, is that text dates require 19 bytes instead of 8.
2
8
0
SQLite docs specifies that the preferred format for storing datetime values in the DB is to use Julian Day (using built-in functions). However, all frameworks I saw in python (pysqlite, SQLAlchemy) store the datetime.datetime values as ISO formatted strings. Why are they doing so? I'm usually trying to adapt the frameworks to storing datetime as julianday, and it's quite painful. I started to doubt that is worth the efforts. Please share your experience in this field with me. Does sticking with julianday make sense?
Shall I bother with storing DateTime data as julianday in SQLite?
0
1
0
1,707
1,386,210
2009-09-06T17:35:00.000
2
0
0
0
python,properties,initialization
1,386,258
3
false
0
0
I agree that attribute access and everything that looks like it (i.e. properties in the Python context) should be fairly trivial. If a property is going to perform a potentially costly operation, use a method to make this explicit. I recommend a name like "fetch_XYZ" or "retrieve_XYZ", since "get_XYZ" is used in some languages (e.g. Java) as a convention for simple attribute access, is quite generic, and does not sound "costly" either. A good guideline is: If your property could throw an exception that is not due to a programming error, it should be a method. For example, throwing a (hypothetical) DatabaseConnectionError from a property is bad, while throwing an ObjectStateError would be okay. Also, when I understood you correctly, you want to return the next key, whenever the next_key property is accessed. I recommend strongly against having side-effects (apart from caching, cheap lazy initialization, etc.) in your properties. Properties (and attributes for that matter) should be idempotent.
2
2
0
I have an object that is basically a Python implementation of an Oracle sequence. For a variety of reasons, we have to get the nextval of an Oracle sequence, count up manually when determining primary keys, then update the sequence once the records have been inserted. So here's the steps my object does: Construct an object, with a key_generator attribute initially set to None. Get the first value from the database, passing it to an itertools.count. Return keys from that generator using a property next_key. I'm a little bit unsure about where to do step 2. I can think of three possibilities: Skip step 1 and do step 2 in the constructor. I find this evil because I tend to dislike doing this kind of initialization in a constructor. Make next_key get the starting key from the database the first time it is called. I find this evil because properties are typically assumed to be trivial. Make next_key into a get_next_key method. I dislike this because properties just seem more natural here. Which is the lesser of 3 evils? I'm leaning towards #2, because only the first call to this property will result in a database query.
Should properties do nontrivial initialization?
0.132549
1
0
190
1,386,210
2009-09-06T17:35:00.000
0
0
0
0
python,properties,initialization
1,389,673
3
false
0
0
I've decided that the key smell in the solution I'm proposing is that the property I was creating contained the word "next" in it. Thus, instead of making a next_key property, I've decided to turn my DatabaseIntrospector class into a KeyCounter class and implemented the iterator protocol (ie making a plain old next method that returns the next key).
2
2
0
I have an object that is basically a Python implementation of an Oracle sequence. For a variety of reasons, we have to get the nextval of an Oracle sequence, count up manually when determining primary keys, then update the sequence once the records have been inserted. So here's the steps my object does: Construct an object, with a key_generator attribute initially set to None. Get the first value from the database, passing it to an itertools.count. Return keys from that generator using a property next_key. I'm a little bit unsure about where to do step 2. I can think of three possibilities: Skip step 1 and do step 2 in the constructor. I find this evil because I tend to dislike doing this kind of initialization in a constructor. Make next_key get the starting key from the database the first time it is called. I find this evil because properties are typically assumed to be trivial. Make next_key into a get_next_key method. I dislike this because properties just seem more natural here. Which is the lesser of 3 evils? I'm leaning towards #2, because only the first call to this property will result in a database query.
Should properties do nontrivial initialization?
0
1
0
190
1,386,604
2009-09-06T20:13:00.000
3
0
1
0
python,algorithm
1,398,808
5
false
0
0
As already pointed out, Python can handle numbers as big as your memory will allow. I would just like to add that as the numbers grow bigger, the cost of all operations on them increases. This is not just for printing/converting to string (although that's the slowest), adding two large numbers (larger that what your hardware can natively handle) is no longer O(1). I'm just mentioning this to point out that although Python neatly hides the details of working with big numbers, you still have to keep in mind that these big numbers operations are not always like those on ordinary ints.
2
9
0
I'm working on a programming problem where I need to handle a number involving 100000 digits. Can python handle numbers like this?
Handling big numbers in code
0.119427
0
0
30,496
1,386,604
2009-09-06T20:13:00.000
7
0
1
0
python,algorithm
1,386,629
5
false
0
0
Yes; Python 2.x has two types of integers, int of limited size and long of unlimited size. However all calculations will automatically convert to long if needed. Handling big numbers works fine, but one of the slower things will be if you try to print the 100000 digits to output, or even try to create a string from it. If you need arbitrary decimal fixed-point precision as well, there is the decimal module.
2
9
0
I'm working on a programming problem where I need to handle a number involving 100000 digits. Can python handle numbers like this?
Handling big numbers in code
1
0
0
30,496
1,387,222
2009-09-07T01:29:00.000
16
0
1
1
python,windows,platform-detection
1,387,226
6
false
0
0
On my Windows box, platform.system() returns 'Windows'. However, I'm not sure why you'd bother. If you want to limit the platform it runs on technologically, I'd use a white-list rather than a black-list. In fact, I wouldn't do it technologically at all since perhaps the next release of Python may have Win32/Win64 instead of Windows (for black-listing) and *nix instead of Linux (for white-listing). My advice is to simply state what the requirements are and, if the user chooses to ignore that, that's their problem. If they ring up saying they got an error message stating "Cannot find FHS" and they admit they're running on Windows, gently point out to them that it's not a supported configuration. Maybe your customers are smart enough to get FHS running under Windows so that your code will work. They're unlikely to appreciate what they would then consider an arbitrary limitation of your software. This is a problem faced by software developers every day. Even huge organizations can't support every single platform and configuration out there.
1
64
0
I'm working on a couple of Linux tools and need to prevent installation on Windows, since it depends on FHS and is thus rendered useless on that platform. The platform.platform function comes close but only returns a string. Unfortunately I don't know what to search for in that string for it to yield a reliable result. Does anyone know what to search for or does anyone know of another function that I'm missing here?
Reliably detect Windows in Python
1
0
0
34,871
1,387,906
2009-09-07T06:56:00.000
24
0
1
0
python,c++,dll,embed
1,387,977
4
true
0
1
In addition to pythonxy.dll, you also need the entire Python library, i.e. the contents of the lib folder, plus the extension modules, i.e. the contents of the DLLs folder. Without the standard library, Python won't even start, since it tries to find os.py (in 3.x; string.py in 2.x). On startup, it imports a number of modules, in particular site.py. There are various locations where it searches for the standard library; in your cases, it eventually finds it in the registry. Before, uses the executable name (as set through Py_SetProgramName) trying to find the landmark; it also checks for a file python31.zip which should be a zipped copy of the standard library. It also checks for a environment variable PYTHONHOME. You are free to strip the library from stuff that you don't need; there are various tools that compute dependencies statically (modulefinder in particular). If you want to minimize the number of files, you can link all extension modules statically into your pythonxy.dll, or even link pythonxy.dll statically into your application use the freeze tool; this will allow linking the byte code of the standard library into your pythonxy.dll. (alternatively to 2.) use pythonxy.zip for the standard library.
2
23
0
I'm developing on Windows, and I've searched everywhere without finding anyone talking about this kind of thing. I made a C++ app on my desktop that embedded Python 3.1 using MSVC. I linked python31.lib and included python31.dll in the app's run folder alongside the executable. It works great. My extension and embedding code definitely works and there are no crashes. I sent the run folder to my friend who doesn't have Python installed, and the app crashes for him during the scripting setup phase. A few hours ago, I tried the app on my laptop that has Python 2.6 installed. I got the same crash behavior as my friend, and through debugging found that it was the Py_Initialize() call that fails. I installed Python 3.1 on my laptop without changing the app code. I ran it and it runs perfectly. I uninstalled Python 3.1 and the app crashes again. I put in code in my app to dynamically link from the local python31.dll, to ensure that it was using it, but I still get the crash. I don't know if the interpreter needs more than the DLL to start up or what. I haven't been able to find any resources on this. The Python documentation and other guides do not seem to ever address how to distribute your C/C++ applications that use Python embedding without having the users install Python locally. I know it's more of an issue on Windows than on Unix, but I've seen a number of Windows C/C++ applications that embed Python locally and I'm not sure how they do it. What else do I need other than the DLL? Why does it work when I install Python and then stop working when I uninstall it? It sounds like it should be so trivial; maybe that's why nobody really talks about it. Nevertheless, I can't really explain how to deal with this crash issue. Thank you very much in advance.
C++ with Python embedding: crash if Python not installed
1.2
0
0
11,259
1,387,906
2009-09-07T06:56:00.000
6
0
1
0
python,c++,dll,embed
9,115,925
4
false
0
1
A zip of the Python standard library worked for me with Python27. I zipped the contents of Lib and dll, and made sure there was no additional python27-subfolder or Lib or dll subfolder. i.e. just a zip named python27.zip containing all the files. I copied that zip and the python27.dll alongside the executable.
2
23
0
I'm developing on Windows, and I've searched everywhere without finding anyone talking about this kind of thing. I made a C++ app on my desktop that embedded Python 3.1 using MSVC. I linked python31.lib and included python31.dll in the app's run folder alongside the executable. It works great. My extension and embedding code definitely works and there are no crashes. I sent the run folder to my friend who doesn't have Python installed, and the app crashes for him during the scripting setup phase. A few hours ago, I tried the app on my laptop that has Python 2.6 installed. I got the same crash behavior as my friend, and through debugging found that it was the Py_Initialize() call that fails. I installed Python 3.1 on my laptop without changing the app code. I ran it and it runs perfectly. I uninstalled Python 3.1 and the app crashes again. I put in code in my app to dynamically link from the local python31.dll, to ensure that it was using it, but I still get the crash. I don't know if the interpreter needs more than the DLL to start up or what. I haven't been able to find any resources on this. The Python documentation and other guides do not seem to ever address how to distribute your C/C++ applications that use Python embedding without having the users install Python locally. I know it's more of an issue on Windows than on Unix, but I've seen a number of Windows C/C++ applications that embed Python locally and I'm not sure how they do it. What else do I need other than the DLL? Why does it work when I install Python and then stop working when I uninstall it? It sounds like it should be so trivial; maybe that's why nobody really talks about it. Nevertheless, I can't really explain how to deal with this crash issue. Thank you very much in advance.
C++ with Python embedding: crash if Python not installed
1
0
0
11,259
1,387,937
2009-09-07T07:08:00.000
1
0
0
0
python,django,caching,mutex,semaphore
1,388,111
2
false
1
0
What about using a different process to handle scraping, and a queue for the communication between it and Django? This way you would be able to easily change the number of concurrent requests, and it would also automatically keep track of the requests, without blocking the caller. Most of all, I think it would help lowering the complexity of the main application (in Django).
1
4
0
Many of my views fetch external resources. I want to make sure that under heavy load I don't blow up the remote sites (and/or get banned). I only have 1 crawler so having a central lock will work fine. So the details: I want to allow at most 3 queries to a host per second, and have the rest block for a maximum of 15 seconds. How could I do this (easily)? Some thoughts : Use django cache Seems to only have 1 second resolution Use a file based semaphore Easy to do locks for concurrency. Not sure how to make sure only 3 fetches happen a second. Use some shared memory state I'd rather not install more things, but will if I have to.
Django: Simple rate limiting
0.099668
0
0
1,777
1,388,464
2009-09-07T09:36:00.000
6
0
1
1
python,linux
1,388,552
3
false
0
0
The safest way to upgrading Python is to install it to a different location (away from the default system path). To do this, download the source of python and do a ./configure --prefix=/opt (Assuming you want to install it to /opt which is where most install non system dependant stuff to) The reason why I say this is because some other system libraries may depend on the current version of python. Another reason is that as you are doing your own custom development, it is much better to have control over what version of the libraries (or interpreters) you are using rather than have a operating system patch break something that was working before. A controlled upgrade is better than having the application break on you all of a sudden.
2
2
0
I have a linux VPS that uses an older version of python (2.4.3). This version doesn't include the UUID module, but I need it for a project. My options are to upgrade to python2.6 or find a way to make uuid work with the older version. I am a complete linux newbie. I don't know how to upgrade python safely or how I could get the UUID modules working with the already installed version. What is a better option and how would I go about doing it?
Upgrade python in linux
1
0
0
25,211