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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4,219,134 | 2010-11-18T20:15:00.000 | 4 | 1 | 1 | 0 | python,multithreading,download,urllib2 | 4,219,434 | 3 | true | 0 | 0 | 9 women can't combine to make a baby in one month. If you have 10 threads, they each have only 10% the bandwidth of a single thread, and there is the additional overhead for context switching, etc. | 2 | 0 | 0 | i am working on a project that requires me to create multiple threads to download a large remote file. I have done this already but i cannot understand while it takes a longer amount of time to download a the file with multiple threads compared to using just a single thread. I used my xampp localhost to carry out the time elapsed test. I would like to know if its a normal behaviour or is it because i have not tried downloading from a real server.
Thanks
Kennedy | Python/Urllib2/Threading: Single download thread faster than multiple download threads. Why? | 1.2 | 0 | 1 | 1,871 |
4,219,134 | 2010-11-18T20:15:00.000 | 1 | 1 | 1 | 0 | python,multithreading,download,urllib2 | 4,222,497 | 3 | false | 0 | 0 | Twisted uses non-blocking I/O, that means if data is not available on socket right now, doesn't block the entire thread, so you can handle many socket connections waiting for I/O in one thread simultaneous. But if doing something different than I/O (parsing large amounts of data) you still block the thread.
When you're using stdlib's socket module it does blocking I/O, that means when you're call socket.read and data is not available at the moment — it will block entire thread, so you need one thread per connection to handle concurrent download.
These are two approaches to concurrency:
Fork new thread for new connection (threading + socket from stdlib).
Multiplex I/O and handle may connections in one thread (Twisted). | 2 | 0 | 0 | i am working on a project that requires me to create multiple threads to download a large remote file. I have done this already but i cannot understand while it takes a longer amount of time to download a the file with multiple threads compared to using just a single thread. I used my xampp localhost to carry out the time elapsed test. I would like to know if its a normal behaviour or is it because i have not tried downloading from a real server.
Thanks
Kennedy | Python/Urllib2/Threading: Single download thread faster than multiple download threads. Why? | 0.066568 | 0 | 1 | 1,871 |
4,220,244 | 2010-11-18T22:24:00.000 | 0 | 1 | 0 | 0 | python,tornado | 4,220,282 | 6 | false | 1 | 0 | Tornado comes with a good number of examples and the source is well documented with a few code snipits as well. | 1 | 13 | 0 | Can someone recommend a project skeleton for python tornado? I suppose it's easy enough to roll my own but I'm curious what else is out there since (obviously) others have been down this road before. | Defacto Project Template for Python Tornado | 0 | 0 | 0 | 3,298 |
4,220,295 | 2010-11-18T22:31:00.000 | 32 | 0 | 0 | 0 | python,tkinter | 4,221,002 | 2 | true | 0 | 1 | You use the winfo_width method of the widget to get the actual width. You can use winfo_reqwidth to get the size that the widget is requesting, which may be different.
Note that if you call this before the window appears on the screen, you won't get the answer you expect. Tkinter needs to have actually drawn the window before it can know the size. A simple fix if you're trying to get the window size before your program starts is to call the update method on the window before trying to get the size. | 2 | 22 | 0 | How do I get the width and height of a Tkinter window? | Get Tkinter Window Size | 1.2 | 0 | 0 | 22,438 |
4,220,295 | 2010-11-18T22:31:00.000 | 1 | 0 | 0 | 0 | python,tkinter | 71,922,330 | 2 | false | 0 | 1 | to create an exact window size you can simple do:
window.geometry("400x400") as an example but you have to make sure it is like a string otherwise it wont work like I have experience | 2 | 22 | 0 | How do I get the width and height of a Tkinter window? | Get Tkinter Window Size | 0.099668 | 0 | 0 | 22,438 |
4,220,441 | 2010-11-18T22:49:00.000 | 2 | 0 | 0 | 0 | python,menu,tkinter | 4,220,839 | 2 | true | 0 | 1 | You need to bind to the <<MenuSelect>> event. | 1 | 0 | 0 | Wondering if there's a menu event I can bind to that's related to the currently selected menu item? By menu item I mean the items that show up in a popup menu like New, Open, Save, etc.
Use case: I would like to update a statusbar area of our application with a description of the currently selected menu item.
Any ideas appreciated.
Thank you,
Malcolm | Python/Tkinter: bind to event related to currently selected menu item | 1.2 | 0 | 0 | 1,525 |
4,223,130 | 2010-11-19T08:07:00.000 | 1 | 0 | 1 | 0 | python,nlp | 4,223,431 | 2 | false | 0 | 0 | I'm not sure what your words point to, but I guess they're quite big structures, if memory is an issue.
I did solve a Python MemoryError problem once by switching from Python 32 bits to Python 64 bits. In fact, some Python structures had become to large for the 4 GB address space. You might want to try that, as a simple potential solution to your problem. | 1 | 1 | 0 | I have huge dictionaries that I manipulate. More than 10 Million words are hashed. Its is too slow and some time it goes out of memory.
Is there a better way to handle these huge data structure ? | How to handle Out of memory with Python | 0.099668 | 0 | 0 | 1,643 |
4,224,400 | 2010-11-19T11:11:00.000 | 2 | 0 | 0 | 0 | python,postgresql | 4,226,375 | 2 | false | 0 | 0 | Note that you can make \ stop being an escape character by setting standard_conforming_strings to on. | 1 | 0 | 0 | i have a noob question.
I have a record in a table that looks like '\1abc'
I then use this string as a regex replacement in re.sub("([0-9])",thereplacement,"2")
I'm a little confused with the backslashes. The string i got back was "\\1abc" | regarding backslash from postgresql | 0.197375 | 1 | 0 | 191 |
4,224,527 | 2010-11-19T11:29:00.000 | 0 | 0 | 0 | 1 | python,ldap,acl | 4,243,802 | 3 | false | 0 | 0 | I think I will try the "test" approch, if its too slow maybe with some caching.
The reason why I want to keep the ACL definition only on the ldap server is that there are other ways to interact with the server (there will be cli tools, and also the standard ldap tools), so I'd like to keepall those interfaces in sync ACL wise, with just one place to define ACLs | 1 | 2 | 0 | I am writing a web frontend (django) for an LDAP server. There are different kinds of people with different kinds of privileges, so I set up LDAP ACL to control who gets to see or edit a specific attribute.
Now its easy to determine if a specific user has read access - try to read, and you will see what you get.
But I don't see an elegant way to distinguish between read and write access before I actually try to write some changes. That is, I would like to make it clear in the interface, if the logged in user has write access, or can only read. So that users won't try to edit an attribute which they can not.
The only thing that came to my mind was to try to temporarily write some sort of dummy into an attribute, and see if that was successful. If so, the original value would be restored, and I know that this user has write access. I can then display this attribute as editable.
The problem with this is that if the server crashes after the dummy has been written and before the original value has been restored, I am left with dummy values in my LDAP server.
What I would need is some way to query the ACLs, in a way similar that I can query schema definitions. But maybe that is "forbidden" by LDAP?
Any ideas?
Isaac | check ldap access rights with python | 0 | 0 | 0 | 1,976 |
4,224,661 | 2010-11-19T11:50:00.000 | 0 | 0 | 0 | 0 | python,django | 4,365,743 | 1 | true | 1 | 0 | I worked out and got my answer that if we want to put any extra validations, then they should be inserted before the save method of the form. Its the correct place to perform the task.
Hope this would help a beginner like me. | 1 | 0 | 0 | I just wanted to know that I am using the predefined registration module and it I am not able to validate the registration form. my registration_form.html look like this
{% extends "registration_base.html" %}
2 {% block title %} Registration Form {% endblock %}
3 {% block external %}
4
5 .error{
6 color: red;
7 font-size: 14px;
8 }
9
1 {% extends "registration_base.html" %}
2 {% block title %} Registration Form {% endblock %}
3 {% block external %}
4
5 .error{
6 color: red;
7 font-size: 14px;
8 }
9
10 {% endblock %}
11 {% block heading1 %} Sign up for an account {% endblock %}
12 {% block content %}
13 Use the form below to register for your new account; all fields are required.
14 {% csrf_token %}
15 {% if form.non_field_errors %}
16 {{ form.non_field_errors|join:"," }}
17 {% endif%}
18 {% if form.username.errors %}
19 {{ form.username.errors|join:"," }}
20 {% endif %}
21
22 Username: {{ form.username }}
23
24 {% if form.email.errors %}
25 {{ form.emails.errors|join:"," }}
26 {% endif %}
27
28 Your e-mail address:
29 {{ form.email }}
30
31 {% if form.password1.errors %}
32 {{ form.password1.errors|join:"," }}
33 {% endif %}
34
35 Password:
36 {{ form.password1 }}
37
38 {% if form.password2.errors %}
39 {{ form.password2.errors|join:"," }}
40 {% endif %}
41
42 ReType Password:
43 {{ form.password2 }}
44
45
46
47 {% endblock %}
Plese help me to figure out the problem.
Thanks in advance............. | Form validations in a template if using a readymade module for registration | 1.2 | 0 | 0 | 140 |
4,226,580 | 2010-11-19T15:42:00.000 | 6 | 0 | 1 | 0 | python,shelve | 4,226,726 | 1 | true | 0 | 0 | If safety of your persistent objects is of high importance in your project, using shelve is not a good idea. Neither is pickling objects and manually writing them into files.
Consider that real databases invest huge resources (brainpower and code) to be safe in case of failures. So keep your data in a real DB. The simplest would be sqlite, as it comes bundled with Python. sqlite is quite safe and has a lot of smarts in it about keeping your data in some valid state even in case of system failures (like when someone trips on your PC's power cable). | 1 | 4 | 0 | How should I prevent corruption in a shelve file? Should the shelve be closed most of the time and then opened only when I need to read or edit a value? | Prevent python shelve corruption | 1.2 | 0 | 0 | 1,094 |
4,227,269 | 2010-11-19T16:45:00.000 | 4 | 0 | 1 | 0 | java,python,multithreading,jvm,jython | 4,230,164 | 3 | false | 0 | 0 | Accessing variables is one of those "hidden" bottlenecks. If all threads access some shared datastructure(s) there will be synchronization between the threads.
Jython tries hard to achieve language compatibility with CPython. One thing that the GIL ensures is that access to local/global variables, object members, dict elements (technically locals, globals and object members are also dict elements) or even list elements are atomic. To avoid surprises for users Jython uses a concurrent hash map to implement dicts. This means that there is some synchronization going on when accessing any kind of dict elements in Jython. This sycnhronization is striped to support access to the dict from multiple threads without blocking them, but if multiple threads access the same variable they are going to hit the same lock.
The best way to achieve scalability in Jython, and any other language, is to make sure that the data you are accessing in each thread is not accessed from other threads as well. | 1 | 5 | 0 | What are some common hidden things that can bottleneck multithreading/parallelism in Jython? I have some parallel code (using Python's threading library) that won't scale past 3-4 CPUs, and I'm sure it's not because of any of these obvious pitfalls:
Explicit locks
Calling library code that requires synchronization (The algorithm I'm trying to parallelize is basically written from scratch and doesn't use any libraries.)
Basically all the algorithm does is a bunch of string processing, list and dictionary lookups and math. My understanding is that, unlike CPython, Jython does not have a GIL. | Hidden Multithreading Bottlenecks in Jython? | 0.26052 | 0 | 0 | 975 |
4,227,418 | 2010-11-19T16:58:00.000 | 1 | 0 | 1 | 0 | python,class,import | 4,228,010 | 4 | false | 0 | 0 | This simply isn't possible, because Python has no way of knowing what subclasses exist until it has already seen them (at which point they'll be in the base class's subclasses attribute).
Why don't you tell us what you really want to achieve? That way, we can help you find a solution. | 3 | 0 | 0 | I'd like to know if it is possible to automatically import all subclasses of a class in python without writing import subclassxy for every subclass. | How to automatically Import all subclasses of a root class in Python? | 0.049958 | 0 | 0 | 3,942 |
4,227,418 | 2010-11-19T16:58:00.000 | 1 | 0 | 1 | 0 | python,class,import | 4,227,479 | 4 | false | 0 | 0 | You can make a module that does the import subclassxy for every subclass (perhaps auto-generated) and from module import * it. | 3 | 0 | 0 | I'd like to know if it is possible to automatically import all subclasses of a class in python without writing import subclassxy for every subclass. | How to automatically Import all subclasses of a root class in Python? | 0.049958 | 0 | 0 | 3,942 |
4,227,418 | 2010-11-19T16:58:00.000 | 3 | 0 | 1 | 0 | python,class,import | 4,227,450 | 4 | false | 0 | 0 | You cannot, in general. The interpreter has no way of knowing whether or not a specific package defines a subclass of your class of interest. In principle, you can write a new package or module tomorrow defining a new subclass. It will now need to get imported. For the interpreter to keep track of all of this would be very burdensome.
You can construct a package that imports all subclasses of interest. | 3 | 0 | 0 | I'd like to know if it is possible to automatically import all subclasses of a class in python without writing import subclassxy for every subclass. | How to automatically Import all subclasses of a root class in Python? | 0.148885 | 0 | 0 | 3,942 |
4,228,757 | 2010-11-19T19:43:00.000 | 0 | 0 | 1 | 0 | python,validation,parameters | 4,228,788 | 8 | false | 0 | 0 | You can cast the argument and try... except the ValueError.
If you are using sys.argv, also investigate argparse. | 1 | 12 | 0 | I want to write a python script that takes 3 parameters. The first parameter is a string, the second is an integer, and the third is also an integer.
I want to put conditional checks at the start to ensure that the proper number of arguments are provided, and they are the right type before proceeding.
I know we can use sys.argv to get the argument list, but I don't know how to test that a parameter is an integer before assigning it to my local variable for use.
Any help would be greatly appreciated. | Python: Test if an argument is an integer | 0 | 0 | 0 | 27,532 |
4,229,287 | 2010-11-19T20:56:00.000 | 1 | 0 | 1 | 0 | python,decorator | 4,229,365 | 2 | false | 0 | 0 | You do know that prepending a definition with @spam class|def name just means "define name as written here, then bind name to spam(name)"?
Decorators are very often applied to functions rather than classes. Sure, you could make a callable class and subclass that... you could also implement your own integer type. Neither is viable.
In quite a few cases, you propably could do something very similar by subclassing... except that decorators are defined once and can be applied to several classes, as opposed to writing a new subclass yourself in every case. Every solution to this inevitably would end up being equivalent to or very similar to decorators.
As robert points out in a comment, if you had an example, the answers could be more specific... | 2 | 3 | 0 | I was trying to wrap my brain around Decorators in python but can't understand why we cannot achieve the same thing by using sub classes? | What is the difference between using decorators and extending a sub class by inheritance? | 0.099668 | 0 | 0 | 757 |
4,229,287 | 2010-11-19T20:56:00.000 | 4 | 0 | 1 | 0 | python,decorator | 4,229,317 | 2 | true | 0 | 0 | You can achieve the same thing using subclasses, and in fact you don't even need subclasses - you can also achieve the same thing simply by wrapping a method in another method and reassigning it. There was a lot of discussion about whether or not the decorator syntax should be added to the language as it doesn't allow you to do anything new and requires programmers to learn one more new thing.
What the syntax dooes is formalize a pattern that many people were already using, and make it to a standard syntax that has a name and guidelines of how to use. It is not necessary for you to use decorators - you can achieve the same effect in other ways - but using the officially supported standard approach with a concise, easy-to-read syntax makes life a bit easier. | 2 | 3 | 0 | I was trying to wrap my brain around Decorators in python but can't understand why we cannot achieve the same thing by using sub classes? | What is the difference between using decorators and extending a sub class by inheritance? | 1.2 | 0 | 0 | 757 |
4,229,394 | 2010-11-19T21:10:00.000 | 4 | 1 | 0 | 0 | php,python,django | 4,229,417 | 1 | true | 1 | 0 | PHP is a popular language for web development with tons of libraries and examples online.
Python is a modern, well-design programming language where everything is an object. It works well in many environments, including web programming, although it wasn't originally designed for that environment.
If you want a general purpose scripting language that can also be used for web development then learning Python would be a good idea. If you only plan to do web development and your main concern is to get a job, experience in PHP will make you attractive to a large number of potential employers who are already using this technology. | 1 | 0 | 0 | Just wondering, as I think about learning either PHP or Django (I have previous Python knowledge), what advantages do Python and Django have over PHP, what disadvantages etc.
I don't want to know which one is better, surely neither is better, both have their good sides as well as bad sides and I will probably learn both at some point. I don't want to start a flame war or anything, but please tell me some advantages and disadvantages for both to help me choose which one to learn first.
Thanks in advance! | Python (with Django) and PHP | 1.2 | 0 | 0 | 1,897 |
4,232,228 | 2010-11-20T10:16:00.000 | 1 | 0 | 0 | 0 | python,cocoa,qt4,pyqt | 4,365,030 | 1 | true | 0 | 1 | I switched from Fink to Macports, and I got the nice widgets. | 1 | 0 | 0 | The widgets in my application are the old style mac widgets. How do I make them become the new style ones. I am using pyqt 4.6.3-1 with python 2.7 on os x 10.6. Everything was installed using fink and I installed both qt4-mac and qt4-x11. Not sure which is being used or how to select one or the other. | getting pyqt to use cocoa widgets | 1.2 | 0 | 0 | 475 |
4,232,923 | 2010-11-20T13:21:00.000 | 71 | 0 | 1 | 0 | python,ipython,bpython | 4,233,430 | 2 | true | 0 | 0 | If you just want an interactive interpreter, bpython should be fine. Just use it until you miss some feature you liked about IPython.
There are lots of features that IPython offers over bpython:
Special threading options. I like -gthread for experimenting with PyGTK and -pylab for matplotlib.
direct invocation of shell commands. cd in IPython is quite useful.
Full readline library support -- I can use the keyboard shortcuts I am used to.
Module reload facility - You can do a deep reload of a module after you have changed your code. This is very useful for testing and debugging.
Run functions in the background in a separate task with %bg.
A whole parallel programming environment (not really a feature you expect from an interactive Python shell, but IPython offers it).
This list could be nearly arbitrarily continued. And of course there will be lots of features in bpython lacking from IPython, but you did not ask for those.
So just use the one that works for you! | 1 | 99 | 0 | What does ipython have that bpython lacks and vice versa? How do the two differ? | What are the differences between ipython and bpython? | 1.2 | 0 | 0 | 28,782 |
4,233,923 | 2010-11-20T17:09:00.000 | 0 | 0 | 1 | 0 | python | 4,233,969 | 3 | false | 0 | 0 | File IO is expensive in terms of CPU cycles. So my first thoughts would be in favor of a database.
However, you could also split your "English dictionary" across multiple files so that (say) each file holds words that start with a specific letter of the alphabet (therefore, you'll have 26 files).
Now, when you say I want to create a very very large dictionary, do you mean a python dict or an English dictionary with words and their definitions, stored in a dict (with words as keys and definitions as values)? The second can be easily implemented with cPickle, as you pointed out.
Again, if memory is your main concern, then you'll need to recheck the number of files you want to use, because, if you're pickling dicts into each file, then you want the dicts to not get too big
Perhaps a usable solution for you would be to do this (I am going to assume that all the English words are sorted):
Get all the words in the English language into one file.
Count how many such words there are and split them into as many files as you see fit, depending on how large the files get.
Now, these smaller files contain the words and their meanings
This is how this solution is useful:
Say that your problem is to lookup the definition of a particular word. Now, at runtime, you can read the first word in each file, and determine if the word that you are looking for is in the previous file that you read (you will need a loop counter to check if you are at the last file). Once you have determined which file the word you are looking for is in, then you can open that file and load the contents of that file into the dict.
It's a little difficult to offer a solution without knowing more details about the problem at hand. | 1 | 1 | 0 | I want to create a very very large dictionary, and I'd like to store it on disk so as not to kill my memory. Basically, my needs are a cross between cPickle and the dict class, in that it's a class that Python treats like a dictionary, but happens to live on the disk.
My first thought was to create some sort of wrapper around a simple MySQL table, but I have to store types in the entries of the structure that MySQL can't even hope to support out of the box. | I need a class that creates a dictionary file that lives on disk | 0 | 0 | 0 | 146 |
4,234,275 | 2010-11-20T18:26:00.000 | 0 | 0 | 1 | 0 | python,linux | 4,234,325 | 2 | false | 0 | 0 | Should be fine. X64 processors run x32 code natively. My dev PC is x64 but it has run a 32 bit OS and code with no problems whatsoever for 4 or so years.
Similarly, it should run 16 bit (8086) code and operating systems just fine! | 1 | 2 | 0 | on 64bit processors.
with 32bit operating system
all programs works fine ?
like suppose all python 32bit installation programs works fine ? or there are any issues found?
a program or software developed on 32bit operating system & 32bit processor
installed on 32bit operating system and 64bit processor
does it work well or any issues?
why i am asking this, bec these days on market all 64bit processor os computers coming and mostly sold. there is no choice also for us..if i want to buy a i5processor computer.. | 64bit prcessor with 32bit operating system program compatibilities? | 0 | 0 | 0 | 270 |
4,234,697 | 2010-11-20T19:56:00.000 | 0 | 0 | 1 | 0 | python,py2exe | 4,234,727 | 3 | false | 0 | 1 | Oops! I found out the answer! sys.executable should do the trick. It returns the path and filename of the currently running exe, although I must test to see that it works with py2exe. | 1 | 0 | 0 | I am writing a little gui application with Tkinter, which requires me to have a path to icon files. I am planning on embedding the file into the exe that I make with py2exe, and then retrieving it from there. The only problem is that I need to know where that file is. Does anyone know a way of getting the currently running exe file/path? Thanks for the help in advance! | Get path to exe file on py2exe | 0 | 0 | 0 | 1,490 |
4,235,821 | 2010-11-21T00:39:00.000 | 1 | 1 | 1 | 0 | python,textmate,simplejson | 4,235,847 | 2 | false | 0 | 0 | What doesn't work? You should provide more information like error messages and what-not. However, I assume that the version of python is different, and simplejson isn't on your PYTHONPATH when launched from textmate. | 1 | 0 | 0 | I'm using simplejson to get data from the New York Time API. It works when I run the file through the terminal with the command "python test.py" but not when I run through TextMate using command + R. I'm running the exact same file. Why is this?
I am running Snow Leopard 10.6.4, TextMate 1.5.10, and Python 2.6.4.
Edit: Sorry for forgetting to include this: by "doesn't work," I mean it says "No module named simplejson". I also noticed that this happens for PyMongo as well ("No module named pymongo"). | Why does simplejson work in Terminal and not TextMate? | 0.099668 | 0 | 0 | 300 |
4,236,243 | 2010-11-21T03:14:00.000 | 1 | 0 | 1 | 0 | python,regex | 4,239,369 | 5 | false | 0 | 0 | ... the advantage of using the regex approach here might be that it prevents doing substitutions when the source text doesn't have matching pairs of [[ and ]].
Maybe important, maybe not. | 1 | 0 | 0 | I have a string.
"This is an [[example]] sentence. It is [[awesome]]."
I want to replace all instances of [[.]] with <b>.</b> preserving the wildcard text matched by .
The result should be:
"This is an <b>example</b> sentence. It is <b>awesome</b>."
I could go in and manually replace [[ with <b> and ]] with </b>, but it makes more sense to just do it at once and preserve the text between tags.
How do I do this?
Note: This is for taking source from a database and converting it to HTML. It's supposed to mimic wiki-style syntax. In this case, [[x]] results in a bold typeface. | Python: Replace tags but preserve inner text? | 0.039979 | 0 | 0 | 2,964 |
4,237,164 | 2010-11-21T09:18:00.000 | 3 | 1 | 0 | 0 | python,login,screen-scraping,screen,mechanize | 4,238,162 | 2 | false | 0 | 0 | lxml.html provides form handling facilities and supports Python 3. | 1 | 10 | 0 | is there any way how to use Mechanize with Python 3.x?
Or is there any substitute which works in Python 3.x?
I've been searching for hours, but I didn't find anything :(
I'm looking for way how to login to the site with Python, but the site uses javascript.
Thanks in advance,
Adam. | Mechanize for Python 3.x | 0.291313 | 0 | 0 | 3,776 |
4,238,537 | 2010-11-21T15:07:00.000 | 3 | 0 | 1 | 0 | python,string,null | 4,238,573 | 4 | false | 0 | 0 | Since C doesn't have a string type, it represents character strings as pointers to char, where the last byte (assuming ASCII, not wide-characters) is \0. It's a representation. By the way, this default implementation has the deficiency that \0 can't be part of such a string. If that's needed, a different representation is required (such as representing a string as a pointer + a length integer).
Python, OTOH has a string type, and it's opaque to the user how this type is represented. Therefore, a "C-style string" is a meaningless concept in Python. | 1 | 1 | 0 | A very popular question is how to reverse a C-Style string. The C-Style string by definition is a string that is terminated by a null('\0'). Using C(or maybe C++), it is possible to use pointers to manipulate the string to reverse its contents in-place.
If somebody asks the question, "How do you reverse a C-style string in Python?", what would some of the possible answers be?
Thanks | 'C-style' strings in Python | 0.148885 | 0 | 0 | 3,653 |
4,239,666 | 2010-11-21T19:01:00.000 | 1 | 0 | 1 | 0 | python,unicode,byte | 4,239,944 | 6 | false | 0 | 0 | Dirty hack: repr(u'\u4132') will return "u'\\u4132'" | 2 | 11 | 0 | I have an 16bit big endian unicode string represented as u'\u4132',
how can I split it into integers 41 and 32 in python ? | getting bytes from unicode string in python | 0.033321 | 0 | 0 | 51,078 |
4,239,666 | 2010-11-21T19:01:00.000 | 4 | 0 | 1 | 0 | python,unicode,byte | 4,239,720 | 6 | false | 0 | 0 | Java: "\u4132".getBytes("UTF-16BE")
Python 2: u'\u4132'.encode('utf-16be')
Python 3: '\u4132'.encode('utf-16be')
These methods return a byte array, which you can convert to an int array easily. But note that code points above U+FFFF will be encoded using two code units (so with UTF-16BE this means 32 bits or 4 bytes). | 2 | 11 | 0 | I have an 16bit big endian unicode string represented as u'\u4132',
how can I split it into integers 41 and 32 in python ? | getting bytes from unicode string in python | 0.132549 | 0 | 0 | 51,078 |
4,239,896 | 2010-11-21T19:36:00.000 | 1 | 0 | 0 | 0 | python,wxpython | 4,240,158 | 1 | false | 0 | 1 | HI,
I did an R&D on wx.Event(GetEventObject) and found out that i can get object details.
SO i solved my problem using this. | 1 | 0 | 0 | I am creating a series of buttons(Or windows) etc on RUN time.
Now how do i identify when user clicks on these buttons? | How to Identify Dynamically created window/buttons in wxpython? | 0.197375 | 0 | 0 | 77 |
4,240,673 | 2010-11-21T22:09:00.000 | 0 | 0 | 0 | 0 | python,ruby-on-rails,pylons | 4,241,121 | 8 | false | 1 | 0 | I wrote a few websites in Pylons over the years and I like it a lot. The great things about Pylons is that it consists mostly of third party libraries. That means that you're learning many useful libraries that can be used in you other projects, for example SQLAlchemy, WebOb, FormEncode, Beaker, Mako and so on ... Especially SQLAlchemy and Beaker are extremely useful in pretty much any context. | 3 | 2 | 0 | I have no background in web applications, but have a fairly experience background in C++, and a quick learner.
I have spent some time learning Python and reading through SQLAlchemy. I kind of like the idea of coding in pure Python OO, and then use a nice SQLAlchemy mapper to persist everything. I like this decoupled approach (using pure Python classes along a mapper function to talk to DB) better than the ActiveRecord idea of Rails. I think eventually I would have more control over connecting the DB to the app. (I need to work with a DB that is updated by a background process. Something like a web crawler that fills the DB.)
At the same time, some stuff makes me think again about Rails. Like streamlined Email and Ajax handling in Rails.
Am I thinking the right way, that Rails is less flexible for Form Validation Manipulations, and working with DB? And is it harder in Pylons to handle Email (notifications), RSS, Ajax?
What would you suggest?
Thanks | Rails or Pylons -- Any good framework for Python? | 0 | 0 | 0 | 3,321 |
4,240,673 | 2010-11-21T22:09:00.000 | 1 | 0 | 0 | 0 | python,ruby-on-rails,pylons | 4,240,821 | 8 | false | 1 | 0 | Rails is written in Ruby, not Python. If you have your heart set on Python, then go with Django. But please give Rails a fair shake; ActiveRecord is not the only ORM available either. I use DataMapper for some apps too. I may be biased, but I'm inclined to think the Rails ecosystem is bigger than that of Django too. | 3 | 2 | 0 | I have no background in web applications, but have a fairly experience background in C++, and a quick learner.
I have spent some time learning Python and reading through SQLAlchemy. I kind of like the idea of coding in pure Python OO, and then use a nice SQLAlchemy mapper to persist everything. I like this decoupled approach (using pure Python classes along a mapper function to talk to DB) better than the ActiveRecord idea of Rails. I think eventually I would have more control over connecting the DB to the app. (I need to work with a DB that is updated by a background process. Something like a web crawler that fills the DB.)
At the same time, some stuff makes me think again about Rails. Like streamlined Email and Ajax handling in Rails.
Am I thinking the right way, that Rails is less flexible for Form Validation Manipulations, and working with DB? And is it harder in Pylons to handle Email (notifications), RSS, Ajax?
What would you suggest?
Thanks | Rails or Pylons -- Any good framework for Python? | 0.024995 | 0 | 0 | 3,321 |
4,240,673 | 2010-11-21T22:09:00.000 | 0 | 0 | 0 | 0 | python,ruby-on-rails,pylons | 18,227,975 | 8 | false | 1 | 0 | I used Web2Py for many small projects, including many goodies such as the "Workers" & Scheduler concepts, some event-driven updates in web page through the short tornado example in websocket_messaging.py. If you're looking for a small but powerful development framework that includes a small DB and display tables, it's just amazing. You even do not need to write a single HTML line. I do not see any competitor in this area. In my opinion it's far easier and faster than django, but django might provide much freedom in complex apps. | 3 | 2 | 0 | I have no background in web applications, but have a fairly experience background in C++, and a quick learner.
I have spent some time learning Python and reading through SQLAlchemy. I kind of like the idea of coding in pure Python OO, and then use a nice SQLAlchemy mapper to persist everything. I like this decoupled approach (using pure Python classes along a mapper function to talk to DB) better than the ActiveRecord idea of Rails. I think eventually I would have more control over connecting the DB to the app. (I need to work with a DB that is updated by a background process. Something like a web crawler that fills the DB.)
At the same time, some stuff makes me think again about Rails. Like streamlined Email and Ajax handling in Rails.
Am I thinking the right way, that Rails is less flexible for Form Validation Manipulations, and working with DB? And is it harder in Pylons to handle Email (notifications), RSS, Ajax?
What would you suggest?
Thanks | Rails or Pylons -- Any good framework for Python? | 0 | 0 | 0 | 3,321 |
4,241,033 | 2010-11-21T23:23:00.000 | 1 | 0 | 0 | 0 | javascript,python,video,html,html5-video | 4,241,072 | 4 | false | 1 | 0 | I wouldn't use any of those: Browsers can't handle the weight of an application like that, python would take ages to render. If you want to make the frontends in python and/or HTML/JS feel free but you will need a compiled (Preferably C/C++) application to handle the heavy lifting in the background (For HTML, especially if you plan on making it actually have a working preview)
You'd have more luck with flash than with HTML for this... | 2 | 0 | 0 | I need to make a light-weight application for video editing and viewing.
I was thinking of either writing an executable program written in Python, or a light-weight web app using JavaScript and HTML5. Flash, as a third option, is pretty much out of the question, since it's too fat and has many security flaws.
EDIT: The video serving itself (read: the "heavy-weight stuff") will be done by a dedicated fast library or service. Thus, the Python/Web-app questions is pretty much related only to the GUI and some very basic video manipulation, like jumping to a specific frame and such.
What is the preferable platform, considering speed and ease of use (for the user)? Should I just use Python, or maybe just build a small web-app for my task?
Thanks in advace,
Ory | Preferable platform for video-editing and viewing - Executable program / Web-based? | 0.049958 | 0 | 0 | 2,041 |
4,241,033 | 2010-11-21T23:23:00.000 | 1 | 0 | 0 | 0 | javascript,python,video,html,html5-video | 4,943,803 | 4 | true | 1 | 0 | I eventually developed a web-app - HTML5 & CSS. Developing a GUI in HTML is a breeze. And the Chromium (Open-source Google Chrome) handles HTML5 pretty well.
Unlike what people have said here, it is not heavy. | 2 | 0 | 0 | I need to make a light-weight application for video editing and viewing.
I was thinking of either writing an executable program written in Python, or a light-weight web app using JavaScript and HTML5. Flash, as a third option, is pretty much out of the question, since it's too fat and has many security flaws.
EDIT: The video serving itself (read: the "heavy-weight stuff") will be done by a dedicated fast library or service. Thus, the Python/Web-app questions is pretty much related only to the GUI and some very basic video manipulation, like jumping to a specific frame and such.
What is the preferable platform, considering speed and ease of use (for the user)? Should I just use Python, or maybe just build a small web-app for my task?
Thanks in advace,
Ory | Preferable platform for video-editing and viewing - Executable program / Web-based? | 1.2 | 0 | 0 | 2,041 |
4,241,227 | 2010-11-22T00:13:00.000 | 0 | 0 | 0 | 0 | python,mysql,django-south,django-database | 4,242,733 | 2 | false | 1 | 0 | +1 to South, but...
We need more information! Are you doing radical changes to your Models, or just adding or removing fields here or there?
South can handle some pretty radical migrations, but you'll have to write some custom migration code. Personally, I use South if I'm adding a new field, but not for this kind of more radical stuff.
If it's a big Schema change, completely re-organizing your site, then I'd just write your own script to read the old objects, and create the new ones. Make a copy of your production database (via pg_dump, mysqldump, etc.) and load it on to your local machine, where you can test and debug the custom conversion script. Make sure your "old models" and "new models" have different names, and keep everything in your settings.py so that you can always read & write everything.
Write & test the migration script, and after that works, you can create another changelist to delete all the old objects, and then remove their corresponding source code if you want. | 1 | 0 | 0 | I have a live Django site that already has registered users. I am trying to update the site with a new version that is different from the original site -similar idea but different models.
How can I keep the current users on the new site?
I have heard South may be a good solution, but the old site doesn't have it installed. Is it possible to use South in this case?
Thanks for the help! | How do you maintain user data when updating a Django site? | 0 | 0 | 0 | 104 |
4,241,234 | 2010-11-22T00:13:00.000 | 0 | 0 | 1 | 0 | python,multithreading,console,interactive | 4,241,314 | 2 | false | 0 | 0 | Either single-threaded or multi-threaded will do, but if you choose not to use threads, you will need to use polling (in C this may be done using poll(2), for example) and check for whether the console and/or the TCP connections have input ready. | 1 | 3 | 0 | I would like to have an interactive console in a single-threaded script that has several TCP connections open. This means I can't just have a standard input blocking the thread.
Is there an easy way to do this? Or should I just put the console in its own thread and be done with it? | Having a console in a single-threaded Python script | 0 | 0 | 0 | 2,155 |
4,241,632 | 2010-11-22T02:02:00.000 | 4 | 0 | 1 | 0 | python,collision,pythonpath,setting | 4,241,662 | 1 | true | 0 | 0 | The PYTHONPATH environment variable is parsed at startup and inserted into sys.path. If you need to adjust the path from within your Python code, manipulate sys.path, not PYTHONPATH. | 1 | 2 | 0 | I am running a script that explicitly sets the PYTHONPATH to avoid naming collisions. However, even if I say os.environ['PYTHONPATH'] = '', it looks as though the system is still able to find my old path that "lives" outside the script.
How is my system able to see the old PYTHONPATH even after I explicitly set it to a new one? | Why is my system using my old PYTHONPATH after explicitly setting? | 1.2 | 0 | 0 | 206 |
4,241,757 | 2010-11-22T02:30:00.000 | 1 | 0 | 0 | 0 | python,django,string | 4,241,776 | 6 | false | 1 | 0 | "electric guitar".split() will give you ['electric', 'guitar']. So will "electric \tguitar". | 1 | 25 | 0 | I'm building a website with Python/Django. Users submit tags. Each tag can contain multiple words. Each tag has an ID number. I want to make sure tags that are formatted slightly differently are still being recognized as the same tag.
For example, if one user submitted the tag "electric guitar" and the other submitted "electric guitar" (2 white spaces between the 2 words) I want to be able to recognize they are the same tag.
How to I remove all the extra white spaces and tabs in this case? Thanks. | Python/Django: How to remove extra white spaces & tabs from a string? | 0.033321 | 0 | 0 | 28,671 |
4,242,205 | 2010-11-22T04:09:00.000 | 1 | 0 | 0 | 1 | python,architecture,task,celery,task-queue | 18,987,208 | 2 | false | 1 | 0 | I handle this by structuring my app to write the multi-megabyte results into files, which I them memmap into memory so they are shared among all processes that use that data... This totally finesses the question of how to get the results to another machine, but if the results are that large, it sounds like the these tasks are internal tasks coordinate between server processes. | 1 | 7 | 0 | What's the best way to handle tasks executed in Celery where the result is large? I'm thinking of things like table dumps and the like, where I might be returning data in the hundreds of megabytes.
I'm thinking that the naive approach of cramming the message into the result database is not going to serve me here, much less if I use AMQP for my result backend. However, I have some of these where latency is an issue; depending on the particular instance of the export, sometimes I have to block until it returns and directly emit the export data from the task client (an HTTP request came in for the export content, it doesn't exist, but must be provided in the response to that request ... no matter how long that takes)
So, what's the best way to write tasks for this? | How should I use Celery when task results are large? | 0.099668 | 0 | 0 | 1,893 |
4,242,540 | 2010-11-22T05:28:00.000 | 2 | 1 | 0 | 0 | python,linux,email | 4,242,804 | 1 | true | 0 | 0 | POP3 does not have push ability. Like a regular ol' post office you need to actually go to check your e-mail. IMAP does have functionality similar to (but not exactly the same as) mail pushing. I'd suggest taking a look at it. | 1 | 0 | 0 | I am developing an email parsing application using python POP3 library on a linux server using Dovecot email server. I have parsed the emails to get the contents and the attachments etc. using POP3 library.
Now the issue is how to notify a user or actually the application that a new email has arrived? I guess there should be some notification system on email server itself which I am missing or something on linux which we can use to implement the same.
Please suggest.
Thanks in advance. | Linux email server, how to know a new email has arrived | 1.2 | 0 | 0 | 240 |
4,242,555 | 2010-11-22T05:31:00.000 | 2 | 0 | 1 | 0 | python,regex | 4,242,569 | 3 | true | 0 | 0 | Very simple: \w+\(\)\w+ | 2 | 0 | 0 | I am working with regular expression in python, need an expression which will check for bracket "()" and after the characters.That means it will catch only "test()abc" not "test()".
Thanks | Regular Expression for first bracket checking | 1.2 | 0 | 0 | 308 |
4,242,555 | 2010-11-22T05:31:00.000 | 1 | 0 | 1 | 0 | python,regex | 4,243,606 | 3 | false | 0 | 0 | If you just need to check if the brackets are there, you can use '\w\(\)\w' as Chris Morgan said.
If you want to get a match just on the () (for example, for re.sub), you can either use non-consuming groups, or use word boundaries.
'(?<=\w)\(\)(?=\w)' will match just the () but only if it is preceded and followed by a alphanum.
'\b\(\)\b' will match just the () but only if it preceded and followed by a word boundary (since both ( and ) would break up the word). Note that if you had to match alphanumeric characters in the middle of a word, you'd have to use \B instead. For example, '\Babc\B'. | 2 | 0 | 0 | I am working with regular expression in python, need an expression which will check for bracket "()" and after the characters.That means it will catch only "test()abc" not "test()".
Thanks | Regular Expression for first bracket checking | 0.066568 | 0 | 0 | 308 |
4,243,550 | 2010-11-22T08:23:00.000 | 0 | 0 | 0 | 1 | python,django,ubuntu,apache2 | 4,244,324 | 2 | false | 1 | 0 | Run simple network analysis first,
tracert
ping
wireshark (for network analysis)
Check your firewall and proxy settings on the server and make sure the correct ports, routes and permissions are fine. | 1 | 2 | 0 | Whenever i try to make a HTTP request to some url through my django application which is running on top of apache mod_python (Machine: Ubuntu 10.04 server edition, 64-bits), it gives a timeout error.
The strange thing is that it works fine on Ubuntu 10.04 server edition, 32-bits.
I feel there could be some proxy connection issue. But i am not sure how to resolve it, if that is the case.
What could be the issue? Can anyone please throw some light on this.
Thanks in Advance. | URLError: urlopen error timed out | 0 | 0 | 0 | 14,600 |
4,245,438 | 2010-11-22T12:36:00.000 | 0 | 0 | 0 | 0 | python,database,caching,sqlite,nosql | 15,588,028 | 3 | false | 0 | 0 | Something trivial but workable, if you are looking storage backed up key value data structure use pickled dictionary. Use cPickle for better performance if needed. | 1 | 49 | 0 | Short Question:
Is there any nosql flat-file database available as sqlite?
Explanation:
Flat file database can be opened in different processes to read, and keep one process to write. I think its perfect for read cache if there's no strict consistent needed. Say 1-2 secs write to the file or even memory block and the readers get updated data after that.
So I almost choose to use sqlite, as my python server read cache. But there's still one problem. I don't like to rewrite sqls again in another place and construct another copy of my data tables in sqlite just as the same as I did in PostgreSql which used as back-end database.
so is there any other choice?thanks! | Is there any nosql flat file database just as sqlite? | 0 | 1 | 0 | 28,380 |
4,246,939 | 2010-11-22T15:22:00.000 | 2 | 0 | 1 | 0 | python,netbeans | 4,318,713 | 2 | true | 0 | 0 | Check:
/home/username/netbeans-6.9.1/php/update/download
I tested it with the php plugin so you should check the python directory. Or if you are using windows you may find somewhere similar.
If no .nbm file there, you may try:
Uninstall python plugin from the other computer, and reinstall it. Don't restart NetBeans immediately, check the directory, and copy all the files. | 1 | 1 | 0 | I have a latest windows netbeans version (6.9.1) and i want to instal a python plugin for it. I have no problems on a computer that has internet connection, it's just tools->plugins->Available. But i have another computer that don't have internet connection available :(. Is it possible to install python addin for it? Where i can download the .nbm file? | Offline python plugin installation for Netbeans? | 1.2 | 0 | 0 | 3,370 |
4,247,248 | 2010-11-22T15:47:00.000 | 3 | 1 | 0 | 0 | python,stream,audio-streaming,radio | 13,279,976 | 6 | false | 0 | 0 | I am aware this is a year old, but this is still a viable question, which I have recently been fiddling with.
Most internet radio stations will give you an option of type of download, I choose the MP3 version, then read the info from a raw socket and write it to a file. The trick is figuring out how fast your download is compared to playing the song so you can create a balance on the read/write size. This would be in your buffer def.
Now that you have the file, it is fine to simply leave it on your drive (record), but most players will delete from file the already played chunk and clear the file out off the drive and ram when streaming is stopped.
I have used some code snippets from a file archive without compression app to handle a lot of the file file handling, playing, buffering magic. It's very similar in how the process flows. If you write up some sudo-code (which I highly recommend) you can see the similarities. | 1 | 12 | 0 | I am looking for a python snippet to read an internet radio stream(.asx, .pls etc) and save it to a file.
The final project is cron'ed script that will record an hour or two of internet radio and then transfer it to my phone for playback during my commute. (3g is kind of spotty along my commute)
any snippits or pointers are welcome. | Record streaming and saving internet radio in python | 0.099668 | 0 | 1 | 16,163 |
4,248,700 | 2010-11-22T18:12:00.000 | 0 | 0 | 1 | 0 | python,editor,coda | 12,906,505 | 2 | true | 0 | 0 | As of October 2012, the answer to this question is "no". | 2 | 3 | 0 | Is there any way to integrate PythonTidy-like functionality directly in Coda? | PythonTidy Integration in Coda? | 1.2 | 0 | 0 | 283 |
4,248,700 | 2010-11-22T18:12:00.000 | -1 | 0 | 1 | 0 | python,editor,coda | 5,706,730 | 2 | false | 0 | 0 | Python code is tidy by default, you just need to indent code blocks comparing with languages that have curly braces, and which need to be beautified if programmer don't like to write code by defined conventions. | 2 | 3 | 0 | Is there any way to integrate PythonTidy-like functionality directly in Coda? | PythonTidy Integration in Coda? | -0.099668 | 0 | 0 | 283 |
4,249,684 | 2010-11-22T20:02:00.000 | 1 | 1 | 0 | 0 | python,twitter,python-twitter | 4,250,479 | 3 | false | 0 | 0 | I did a similar project analyzing data from tweets. If you're just going at this from a pure data collection/analysis angle, you can just scrape any of the better sites that collect these tweets for various reasons. Many sites allow you to search by hashtag, so throw in a popular enough hashtag and you've got thousands of results. I just scraped a few of these sites for popular hashtags, collected these into a large list, queried that list against the site, and scraped all of the usable information from the results. Some sites also allow you to export the data directly, making this task even easier. You'll get a lot of garbage results that you'll probably need to filter (spam, foreign language, etc), but this was the quickest way that worked for our project. Twitter will probably not grant you whitelisted status, so I definitely wouldn't count on that. | 1 | 5 | 0 | For a research project, I am collecting tweets using Python-Twitter. However, when running our program nonstop on a single computer for a week we manage to collect about only 20 MB of data per week. I am only running this program on one machine so that we do not collect the same tweets twice.
Our program runs a loop that calls getPublicTimeline() every 60 seconds. I tried to improve this by calling getUserTimeline() on some of the users that appeared in the public timeline. However, this consistently got me banned from collecting tweets at all for about half an hour each time. Even without the ban, it seemed that there was very little speed-up by adding this code.
I know about Twitter's "whitelisting" that allows a user to submit more requests per hour. I applied for this about three weeks ago, and have not hear back since, so I am looking for alternatives that will allow our program to collect tweets more efficiently without going over the standard rate limit. Does anyone know of a faster way to collect public tweets from Twitter? We'd like to get about 100 MB per week.
Thanks. | How to Collect Tweets More Quickly Using Twitter API in Python? | 0.066568 | 0 | 1 | 5,951 |
4,251,553 | 2010-11-23T00:14:00.000 | 2 | 0 | 0 | 1 | python,bash,r,matlab | 4,251,568 | 3 | false | 0 | 0 | This isn't really a feature of a programming language but of an implementation of that programming language. For example, there exist C interpreters and Lisp Compilers. This is normaly called an REPL (Read-Eval-Print-Loop) and is generally a feature of interpreted implementations. | 1 | 2 | 0 | Is it possible to define a function in commandline window of Matlab? Looks no to me.
But for R, it is possible to do so. I was wondering why there is this difference and if there is more to say behind this kind of feature of a programming language, or can I say just interpretive language (such as Python, Bash,...)?
Thanks! | possible to define a function in commandline window of a programming language? | 0.132549 | 0 | 0 | 1,865 |
4,251,964 | 2010-11-23T01:41:00.000 | 18 | 0 | 1 | 0 | python,compiler-construction,translate,pypy,rpython | 4,253,643 | 1 | true | 0 | 1 | Yes, PyPy can produce standalone executables from RPython code. That means, you need to follow all the awkward RPython rules when it comes to writing code. Your Python code is completely unlikely to function out of the box and porting existing Python code is usually not fun. It won't make executables as small as C, but for example rpystone target (from pypy/translator/goal) using boehm GC is 80k on 64bit after stripping. | 1 | 27 | 0 | (Or, "Can PyPy/RPython be used to compile/translate Python to C/C++ without requiring the Python runtime?")
I have tried to comprehend PyPy with its RPython and its Python, its running and its compiling and its translating, and have somewhat failed.
I have a hypothetical Python project (for Windows); I would like to keep its size down, in the order of a hundred kilobytes (O.N.O.) rather than the several megabytes that using py2exe entails (after UPX). Can I use PyPy1 in any way to produce a standalone executable which does not depend on Python26.dll? If I can, does it need to follow the RPython restrictions like for only working on builtin types, or is it full Python syntax?
I do realise that if this can be done I almost certainly couldn't use C modules from Python directly.
1 (Since the time of asking, the situation has become clearer, and this part of the toolchain is more clearly branded as RPython rather than PyPy; it wasn't so in 2010.) | Can PyPy/RPython be used to produce a small standalone executable? | 1.2 | 0 | 0 | 6,144 |
4,252,725 | 2010-11-23T04:16:00.000 | 1 | 0 | 1 | 1 | c#,python,process,whitelist | 4,255,403 | 2 | false | 0 | 0 | How do I block ALL other processes from starting?
Deep, mysterious OS API magic. After all, you're interfering with how the OS works. You must, therefore patch or hook into the OS itself.
Is this possible in .Net? What about python?
It doesn't involve time-travel, anti-gravity or perpetual motion. It can be done.
It's a matter of figuring out (1) which OS API calls are required to put your new hook into the OS, and (2) implementing a call from the OS to your code.
Is really hard.
Is really easy. | 1 | 1 | 0 | Playing around with project ideas that I might actually use, figured I might try to write my own simple version of Bit9 Parity, in either C# or Python. My question is what is the best way to go about doing this. I've googled .Net functionality for prevent processes from executing, but I havn't really found what I'm looking for. What I'd like to do is monitory the system memory as a whole, and deny any process or application from starting unless specifically identified in a list. ProcessWatcher caught my eye, but is that not for a specific process ID. How do I block ALL other processes from starting? Is this possible in .Net? What about python? | Looking to write my own 'Application Whitelisting Tool' Something like Bit9? | 0.099668 | 0 | 0 | 611 |
4,253,557 | 2010-11-23T07:04:00.000 | 0 | 0 | 0 | 1 | python | 4,255,361 | 3 | false | 0 | 0 | Here's an approach.
Write an "agent" in Python. The agent is installed on the various computers. It does whatever processing your need locally. It uses urllib2 to make RESTful HTTP requests of the server. It either posts data or requests work to do or whatever is supposed to go on.
Write a "server" in Python. The server is installed on one computer. This is written using wsgiref and is a simple WSGI-based server that serves requests from the various agents scattered around campus.
While this requires agent installation, it's very, very simple. It can be made very, very secure (use HTTP Digest Authentication). And the agent's privileges define the level of vulnerability. If the agent is running in an account with relatively few privileges, it's quite safe. The agent shouldn't run as root and the agent's account should not be allowed to su or sudo. | 1 | 4 | 0 | Question: Where is a good starting point for learning to write server applications?
Info:
I'm looking in to writing a distributed computing system to harvest the idle cycles of the couple hundred computers sitting idle around my college's campus. There are systems that come close, but don't quite meet all the requirements I need. (most notable all transactions have to be made through SSH because the network blocks everything else) So I've decided to write my own application. partly to get exactly what I want, but also for experience.
Important features:
Written in python
All transaction made through ssh(this is solved through the simple use of pexpect)
Server needs to be able to take potentially hundreds of hits. I'll optimize later, the point being simulation sessions.
I feel like those aren't to ridiculous of things to try and accomplish. But with the last one I'm not certain where to even start. I've actually already accomplished the first 2 and written a program that will log into my server, and then print ls -l to a file locally. so that isn't hard. but how do i attach several clients asking the server for simulation data to crunch all at the same time? obviously it feels like threading comes in to play here, but more than that I'm sure.
This is where my problem is. Where does one even start researching how to write server applications? Am I even using the right wording? What information is there freely available on the internet and/or what books are there on such? again, specifically python, but a step in the right direction is one more than where i am now.
p.s. this seeemed more fitting for stackoverflow than serverfault. Correct me if I am wrong. | where to start programing a server application | 0 | 0 | 1 | 186 |
4,253,903 | 2010-11-23T08:02:00.000 | 1 | 0 | 1 | 0 | python | 4,254,446 | 6 | true | 0 | 0 | It depends on what you want to learn out of the book.
Let me guess that you are a newbie. If you are not new to programming (probably you are not, you are in SO), then the 2.4 cookbook will be fine. There would be a few changes in the later versions to catch up with, the ones that simplify code and introduce new idioms and help you do things in a better/cleaner way, but you can pick them up later on.
If you are new to programming, then may be you should pick up something more recent. It is important to pick up clean coding habits and know your community's idioms. | 3 | 1 | 0 | Python Cookbook 2nd edition is updated for Python 2.4. Is it still ok to study the book using Python version 2.5 or 2.6? | Python Cookbook is for Python 2.4 | 1.2 | 0 | 0 | 378 |
4,253,903 | 2010-11-23T08:02:00.000 | 1 | 0 | 1 | 0 | python | 4,253,919 | 6 | false | 0 | 0 | I would say yes. There have been a few big changes since 2.4, but most if not all of the Cookbook will still apply. It also gives you a good idea of idiomatic python. | 3 | 1 | 0 | Python Cookbook 2nd edition is updated for Python 2.4. Is it still ok to study the book using Python version 2.5 or 2.6? | Python Cookbook is for Python 2.4 | 0.033321 | 0 | 0 | 378 |
4,253,903 | 2010-11-23T08:02:00.000 | 0 | 0 | 1 | 0 | python | 4,254,271 | 6 | false | 0 | 0 | Well you can always start with Byte of Python OpenSource Doument Small Precise and to the Point Description. here the link :
Regards | 3 | 1 | 0 | Python Cookbook 2nd edition is updated for Python 2.4. Is it still ok to study the book using Python version 2.5 or 2.6? | Python Cookbook is for Python 2.4 | 0 | 0 | 0 | 378 |
4,256,767 | 2010-11-23T14:05:00.000 | 2 | 0 | 0 | 1 | python,google-app-engine | 4,262,449 | 2 | false | 1 | 0 | You should change the design of your application.
Instead of making requests to Twitter from App Engine for every user request:
Do the request in the user's browser with JavaScript if possible.
After a urlfetch, store Twitter's response in the datastore, since a call to the datastore is faster on the next request. If you can cache something in memcache, even better.
Update the stored data regularly with the help of cron jobs and task queue. | 1 | 2 | 0 | Hey. I'm quite new to App Engine. I created a web-based Twitter app which is now running on App Engine and I'm constantly hitting my CPU Over Quota limits. I did a little profiling and I found out that every request consists of two urlfetch queries, each one of which takes up to 2 CPU seconds. That time is probably spent waiting, all the rest of the code is done in under 200 ms (including work with the Datastore). The Quota is for 6.5 hours per day and every request of mine takes approx. 4 CPU seconds. I ran out of the free quota this morning in only a few hours.
What is the way around this? I can't make Twitter respond to my API calls quicker, and I cannot cache the results, since every request is for a different Twitter profile.
Any help is appreciated,
Thanks! | App Engine: CPU Over Quota on urlfetch() | 0.197375 | 0 | 0 | 454 |
4,257,038 | 2010-11-23T14:33:00.000 | 0 | 0 | 0 | 0 | java,python,windows,ipc,ssl-certificate | 4,257,229 | 2 | true | 0 | 0 | The most simple approach is to use cookie-based access control. Have a file in the user's profile/homedirectory which contains the cookie. Have the Java server generate and save the cookie, and have the Python client scripts send the cookie as the first piece of data on any TCP connection.
This is secure as long as an adversary cannot get the cookie, which then should be protected by file system ACLs. | 2 | 0 | 0 | We have a Rest API that requires client certificate authentication. The API is used by this collection of python scripts that a user can run. To make it so that the user doesn't have to enter their password for their client certificate every time they run one of the scripts, we've created this broker process in java that a user can startup and run in the background which holds the user's certificate password in memory (we just have the javax.net.ssl.keyStorePassword property set in the JVM). The scripts communicate with this process and the process just forwards the Rest API calls to the server (adding the certificate credentials).
To do the IPC between the scripts and the broker process we're just using a socket. The problem is that the socket opens up a security risk in that someone could use the Rest API using another person's certificate by communicating through the broker process port on the other person's machine. We've mitigated the risk somewhat by using java security to only allow connections to the port from localhost. I think though someone in theory could still do it by remotely connecting to the machine and then using the port. Is there a way to further limit the use of the port to the current windows user? Or maybe is there another form of IPC I could use that can do authorization using the current windows user?
We're using Java for the broker process just because everyone on our team is much more familiar with Java than python but it could be rewritten in python if that would help.
Edit: Just remembered the other reason for using java for the broker process is that we are stuck with using python v2.6 and at this version https with client certificates doesn't appear to be supported (at least not without using a 3rd party library). | IPC on Windows between Java and Python secured to the current user | 1.2 | 0 | 1 | 521 |
4,257,038 | 2010-11-23T14:33:00.000 | 0 | 0 | 0 | 0 | java,python,windows,ipc,ssl-certificate | 4,271,608 | 2 | false | 0 | 0 | I think I've come up with a solution inspired by Martin's post above. When the broker process starts up I'll create an mini http server listening on the IPC port. Also during startup I'll write a file containing a randomly generated password (that's different every startup) to the user's home directory so that only the user can read the file (or an administrator but I don't think I need to worry about that). Then I'll lock down the IPC port by requiring all http requests sent there to use the password. It's a bit Rube Goldberg-esque but I think it will work. | 2 | 0 | 0 | We have a Rest API that requires client certificate authentication. The API is used by this collection of python scripts that a user can run. To make it so that the user doesn't have to enter their password for their client certificate every time they run one of the scripts, we've created this broker process in java that a user can startup and run in the background which holds the user's certificate password in memory (we just have the javax.net.ssl.keyStorePassword property set in the JVM). The scripts communicate with this process and the process just forwards the Rest API calls to the server (adding the certificate credentials).
To do the IPC between the scripts and the broker process we're just using a socket. The problem is that the socket opens up a security risk in that someone could use the Rest API using another person's certificate by communicating through the broker process port on the other person's machine. We've mitigated the risk somewhat by using java security to only allow connections to the port from localhost. I think though someone in theory could still do it by remotely connecting to the machine and then using the port. Is there a way to further limit the use of the port to the current windows user? Or maybe is there another form of IPC I could use that can do authorization using the current windows user?
We're using Java for the broker process just because everyone on our team is much more familiar with Java than python but it could be rewritten in python if that would help.
Edit: Just remembered the other reason for using java for the broker process is that we are stuck with using python v2.6 and at this version https with client certificates doesn't appear to be supported (at least not without using a 3rd party library). | IPC on Windows between Java and Python secured to the current user | 0 | 0 | 1 | 521 |
4,257,771 | 2010-11-23T15:36:00.000 | 1 | 0 | 0 | 0 | python,excel,excel-2007,openpyxl | 4,258,896 | 8 | false | 0 | 0 | If you are on Windows and have Excel 2007+ installed, you should be able to use pywin32 and COM to write XLSX files using almost the same code as you would would to write XLS files ... just change the "save as ...." part at the end.
Probably, you can also write XLSX files using Excel 2003 with the freely downloadable add-on kit but the number of rows per sheet would be limited to 64K. | 1 | 14 | 0 | Is there a Python module that writes Excel 2007+ files?
I'm interested in writing a file longer than 65535 lines and only Excel 2007+ supports it. | Python: Writing to Excel 2007+ files (.xlsx files) | 0.024995 | 1 | 0 | 21,620 |
4,258,278 | 2010-11-23T16:25:00.000 | 0 | 1 | 0 | 0 | python,authentication,cookies,cookielib | 4,258,354 | 1 | false | 0 | 0 | You can't set cookies for another domain - browsers will not allow it. | 1 | 2 | 0 | I'm using python with urllib2 & cookielib and such to open a url. This url set's one cookie in it's header and two more in the page with some javascript. It then redirects to a different page.
I can parse out all the relevant info for the cookies being set with the javascript, but I can't for the life of me figure out how to get them into the cookie-jar as cookies.
Essentially, when I follow to the site being redirected too, those two cookies have to be accessible by that site.
To be very specific, I'm trying to login in to gomtv.net by using their "login in with a Twitter account" feature in python.
Anyone? | How do I manually put cookies in a jar? | 0 | 0 | 1 | 255 |
4,258,624 | 2010-11-23T16:56:00.000 | 0 | 1 | 0 | 0 | python,reporting | 4,258,672 | 1 | false | 1 | 0 | Sure. Write it. Make it open source and give us a git repo to have a little look... Honestly if the problem exists solve it. | 1 | 1 | 0 | Can you guys please tell if building my own birtviewer like reporting tool but using python is a crazy idea. The company I'm working now, we are using birtviewer to generate reports for the clients, but I'm already getting frustrated tweaking the code to suit our client needs and it's written on massive java code which I don't have any experience at all. And they don't want to mavenize birtviewer, so every new releases I have to manually update my local copy and mavenize it. And the fact that it is really owned by a private company worries me about the future of birtviewer. What do you guys think? | python reporting tool, similar to birtviewer | 0 | 0 | 0 | 280 |
4,258,771 | 2010-11-23T17:10:00.000 | 0 | 0 | 0 | 0 | python,pygtk | 65,870,271 | 2 | false | 0 | 1 | Maybe using destroy() could save some RAM:
menu.foreach(lambda child: child.destroy()) | 1 | 8 | 0 | I have created a gtkMenu using gtk.Menu(), appended a couple of items and now I want to remove some menu items. How can I do that? | How to remove an item from a gtkMenu? | 0 | 0 | 0 | 3,084 |
4,259,352 | 2010-11-23T18:14:00.000 | 1 | 0 | 0 | 0 | python,django | 4,259,726 | 3 | false | 1 | 0 | Even with an IDE you will just be editing text. Once you get comfortable with the framework, as long as you have debug turned on in your settings, you can do it from any old text editor.
I develop websites using the Eclipse IDE with the Pydev plug-in. The html/css plugin i have installed always seems to break when theres too many Django template tags in the template, so i just use the built in text editor. | 3 | 2 | 0 | Apologies if my question is misleading. Here's what I mean. In Visual Studio 2010 for example, you could visually design a website or a web application as well as add C# code here and there. How would I design my website without an IDE, just by using Python IDLE and Django platform.
Would I need to use something like Dreamweaver to design the front-end part and then link it with Django? And if that is so, how difficult is the linking process of front-end with back-end? | How to design a website on Django platform? | 0.066568 | 0 | 0 | 1,428 |
4,259,352 | 2010-11-23T18:14:00.000 | 8 | 0 | 0 | 0 | python,django | 4,259,392 | 3 | true | 1 | 0 | Django source code is usually edited in a non-GUI application. So, unless you use the code tab, Dreamweaver will be useless.
That is, unless you create a static HTML file first then populate it with dynamic code and separate it into bits. | 3 | 2 | 0 | Apologies if my question is misleading. Here's what I mean. In Visual Studio 2010 for example, you could visually design a website or a web application as well as add C# code here and there. How would I design my website without an IDE, just by using Python IDLE and Django platform.
Would I need to use something like Dreamweaver to design the front-end part and then link it with Django? And if that is so, how difficult is the linking process of front-end with back-end? | How to design a website on Django platform? | 1.2 | 0 | 0 | 1,428 |
4,259,352 | 2010-11-23T18:14:00.000 | 2 | 0 | 0 | 0 | python,django | 4,259,555 | 3 | false | 1 | 0 | just by using Python IDLE and Django platform.
Start the webserver
Make a model, a controller, and a view.
Add data to the db (maybe with the admin model)
Load up the page in your browser.
Repeat as necessary
But I would recommend a more powerful text editor than idle if you are really going to do develop a whole site. | 3 | 2 | 0 | Apologies if my question is misleading. Here's what I mean. In Visual Studio 2010 for example, you could visually design a website or a web application as well as add C# code here and there. How would I design my website without an IDE, just by using Python IDLE and Django platform.
Would I need to use something like Dreamweaver to design the front-end part and then link it with Django? And if that is so, how difficult is the linking process of front-end with back-end? | How to design a website on Django platform? | 0.132549 | 0 | 0 | 1,428 |
4,259,553 | 2010-11-23T18:44:00.000 | 1 | 0 | 1 | 0 | python,django,visual-studio-2010,ironpython,pycharm | 4,259,631 | 2 | true | 1 | 0 | Since MS is no longer officially working on IronPython, you may consider PyCharm. I come from Asp.net and recently moved to Django and happen to use PyCharm and overall am happy with it. Especially because I can work on the same code from my PC or Mac with it. There were some gotches that got me for a bit with it, like it didn't come with Django it's a separate install (it's documented) just surprised me coming from VS. | 1 | 3 | 0 | I have just checked JetBrains products page and noticed they have a new product - PyCharm that supports Django out of the box for Python development.
Is there a plug-in or a native support for Django in Visual Studio 2010 with IronPython? | Django with IronPython and VS2010? | 1.2 | 0 | 0 | 1,115 |
4,259,792 | 2010-11-23T19:08:00.000 | 0 | 0 | 1 | 0 | python,exception | 4,259,846 | 3 | false | 0 | 0 | Python isn't like C++. Exceptions produce useful backtraces. If you're taking user input, catch appropriate exceptions (like EOFError) but otherwise, you don't have to do anything special to be exception safe. If a program does something unexpected and throws an exception, use the resulting stack dump to debug your problem. If you're going for extremely high availability, you might want to wrap your top level with a try/except in a loop with a log and restart. | 1 | 3 | 0 | I know about the with statement for Python resource handling. What other concerns are there for exception safe code in Python?
EDIT: The concern here is with opening files and such. For instance, suppose an init function raises an exception. What is the state of the object being initialized? | What is the state of exception safety in Python? | 0 | 0 | 0 | 1,174 |
4,260,324 | 2010-11-23T20:01:00.000 | 2 | 0 | 0 | 0 | python | 4,261,259 | 6 | false | 1 | 0 | I'm using Flask (a very minimal web framework) and SQLAlchemy as my ORM. I'm exceedingly happy with it. Disclaimer: I'm only using this for personal projects at the moment, though I do plan to launch a web app in the next 6 months using this setup. | 1 | 3 | 0 | I'm a C/C++ developer and I also have experience developing web apps with C#, ASP.NET MVC and fluent nhibernate. I'm looking for non-MS alternatives for web development and I'm really interested in python so I went out after Django but I've been told that Django makes it difficult for me to personalize my HTML (not sure if this is accurate).
What I'm looking for is a Python web development framework that is integrated with an ORM, is able to generate the interfaces BUT provides an easy way for me to customize the interface to create an AJAX intensive app | I need a good web development framework for Python | 0.066568 | 0 | 0 | 1,308 |
4,261,129 | 2010-11-23T21:26:00.000 | 0 | 0 | 0 | 0 | python,mongodb | 8,654,689 | 5 | false | 0 | 0 | If you can generate auto-incrementing unique numbers, there's absolutely no need to use ObjectId for _id. Doing this in a distributed environment will most likely be more expensive than using ObjectId. That's your tradeoff. | 2 | 14 | 0 | I've built a number of python driven sites that utilize mongodb as a database backend and am very happy with it's ObjectId system, however, I'd love to be able encode the ids in a shorter fashion without building a mapping collection or utilizing a url-shortener service.
Suggestions? Success stories? | How can one shorten mongo ids for better use in URLs? | 0 | 1 | 0 | 4,165 |
4,261,129 | 2010-11-23T21:26:00.000 | 1 | 0 | 0 | 0 | python,mongodb | 4,261,319 | 5 | false | 0 | 0 | If you are attempting to retain the original value then there really is not a good way. You could encode it, but the likeliness of it being smaller is minimal. You could hash it, but then it's not reversible.
If this is a REQUIREMENT, I'd probably recommend creating a lookup table or collection where a small incremental number references entries in a Mongo Collection. | 2 | 14 | 0 | I've built a number of python driven sites that utilize mongodb as a database backend and am very happy with it's ObjectId system, however, I'd love to be able encode the ids in a shorter fashion without building a mapping collection or utilizing a url-shortener service.
Suggestions? Success stories? | How can one shorten mongo ids for better use in URLs? | 0.039979 | 1 | 0 | 4,165 |
4,262,903 | 2010-11-24T02:08:00.000 | 2 | 0 | 0 | 0 | python,parsing,ms-word,xml-serialization | 6,130,059 | 5 | true | 0 | 0 | Used a very inefficient conditional search in VBA to literally copy the document into a second document. The second document was then saved with a .xml extension. Got the job done, but its ugly. | 2 | 12 | 0 | I receive word documents with specified formating corresponding to the data that is in them. For example, all headers have the exact same formating (Times New Roman-Font 14-Bold).
What is the best way to process such MS Word documents (.doc or .docx) into xml documents? Language is not an issue (I'll use Lisp/Boost.Spirit if I have to!). | Best Way to Process a Word Document | 1.2 | 0 | 0 | 30,861 |
4,262,903 | 2010-11-24T02:08:00.000 | 0 | 0 | 0 | 0 | python,parsing,ms-word,xml-serialization | 4,272,743 | 5 | false | 0 | 0 | It really depends on exactly what you are trying to do.
The simplest approach would be to save the document as Flat OPC XML (in Word, "Save as.." XML), and then apply an XSLT.
This approach is simplest, since it gives you the entire docx as a single XML file, so you don't have to unzip it etc.
If your requirements are more complex, for example, analyzing the formatting or styles, or doing something with hyperlinks, then an object model such as docx4j (Java) or Open XML SDK (C#) - and no doubt there are others - may help. | 2 | 12 | 0 | I receive word documents with specified formating corresponding to the data that is in them. For example, all headers have the exact same formating (Times New Roman-Font 14-Bold).
What is the best way to process such MS Word documents (.doc or .docx) into xml documents? Language is not an issue (I'll use Lisp/Boost.Spirit if I have to!). | Best Way to Process a Word Document | 0 | 0 | 0 | 30,861 |
4,262,984 | 2010-11-24T02:31:00.000 | 0 | 1 | 0 | 0 | python,r,data-analysis,solid-state-drive | 4,263,022 | 5 | false | 0 | 0 | The read and write times for SSDs are significantly higher than standard 7200 RPM disks (it's still worth it with a 10k RPM disk, not sure how much of an improvement it is over a 15k). So, yes, you'd get much faster times on data access.
The performance improvement is undeniable. Then, it's a question of economics. 2TB 7200 RPM disks are $170 a piece, and 100GB SSDS cost $210. So if you have a lot of data, you may run into a problem.
If you read/write a lot of data, get an SSD. If the application is CPU intensive, however, you'd benefit much more from getting a better processor. | 2 | 12 | 1 | Does anyone have any experience using r/python with data stored in Solid State Drives. If you are doing mostly reads, in theory this should significantly improve the load times of large datasets. I want to find out if this is true and if it is worth investing in SSDs for improving the IO rates in data intensive applications. | Data analysis using R/python and SSDs | 0 | 0 | 0 | 4,485 |
4,262,984 | 2010-11-24T02:31:00.000 | 2 | 1 | 0 | 0 | python,r,data-analysis,solid-state-drive | 4,264,161 | 5 | false | 0 | 0 | I have to second John's suggestion to profile your application. My experience is that it isn't the actual data reads that are the slow part, it's the overhead of creating the programming objects to contain the data, casting from strings, memory allocation, etc.
I would strongly suggest you profile your code first, and consider using alternative libraries (like numpy) to see what improvements you can get before you invest in hardware. | 2 | 12 | 1 | Does anyone have any experience using r/python with data stored in Solid State Drives. If you are doing mostly reads, in theory this should significantly improve the load times of large datasets. I want to find out if this is true and if it is worth investing in SSDs for improving the IO rates in data intensive applications. | Data analysis using R/python and SSDs | 0.07983 | 0 | 0 | 4,485 |
4,263,059 | 2010-11-24T02:50:00.000 | 11 | 0 | 1 | 1 | python,asynchronous,erlang,nonblocking,python-stackless | 9,762,122 | 3 | false | 0 | 0 | You are almost right when comparing Stackless
to Greenlet. The missing thing is:
Stackless per se does not add something. Instead, Greenlet, invented 5 years after Stackless, removes certain things. It is written simple enough to be built as an extension module instead of a replacement interpreter.
This is really funny—Stackless has many more features, is about 10 times more efficient on switching, and provides pickling of execution state.
Greenlet still wins, probably only due to ease of use as an extension module. So I'm thinking about reverting the process by extending Greenlet with pickling. Maybe that would change the picture, again :-) | 1 | 30 | 0 | My incomplete understanding is that Twisted, Stackless, Greenlet, Eventlet, Coroutines all make use of async network IO and userland threads that are very lightweight and quick to switch. But I'm not sure what are the differences between them.
Also they sound very similar to Erlang processes. Are they pretty much the same thing?
Anyone who could help me understand this topic more would be greatly appreciated. | Python/Erlang: What's the difference between Twisted, Stackless, Greenlet, Eventlet, Coroutines? Are they similar to Erlang processes? | 1 | 0 | 0 | 7,391 |
4,264,076 | 2010-11-24T06:35:00.000 | 0 | 0 | 0 | 0 | javascript,python,parsing,url,dynamically-generated | 4,264,223 | 2 | false | 1 | 0 | I you want generated source you'll need a browser, I don't think you can with only python. | 2 | 2 | 0 | I have some url to parse, and they used some javascript to create it dynamicly. So if i want to parse the result generated page with python... how can i do that ?
Firefox do that well with web developer... so i think it possible ... but i don't know where to start...
Thx for help
lo | How to see generated source from an URL page with python script and not anly source? | 0 | 0 | 1 | 212 |
4,264,076 | 2010-11-24T06:35:00.000 | 2 | 0 | 0 | 0 | javascript,python,parsing,url,dynamically-generated | 4,264,239 | 2 | true | 1 | 0 | I've done this by doing a POST of document.body.innerHTML, after the page is loaded, to a CGI script in Python.
For the parsing, BeautifulSoup is a good choice. | 2 | 2 | 0 | I have some url to parse, and they used some javascript to create it dynamicly. So if i want to parse the result generated page with python... how can i do that ?
Firefox do that well with web developer... so i think it possible ... but i don't know where to start...
Thx for help
lo | How to see generated source from an URL page with python script and not anly source? | 1.2 | 0 | 1 | 212 |
4,265,580 | 2010-11-24T10:09:00.000 | 1 | 0 | 0 | 0 | python,browser,search-engine | 4,266,457 | 3 | true | 0 | 0 | Of course it's possible - they're just GET requests. So long as you format the URL properly with the query string correct and all (http://google.com/search?q=query - look at the site to see what it needs to be), it'll work fine. It's just a URL. | 1 | 0 | 0 | I know it's possible to open up specific URL's with python's webbrowser module. Is it possible to use strings as search queries with it, or another module? Say in an engine like Google or Yahoo? | Python Web Search | 1.2 | 0 | 1 | 830 |
4,266,741 | 2010-11-24T12:27:00.000 | 0 | 0 | 1 | 0 | python,algorithm,math,floating-point,floating-accuracy | 4,266,921 | 7 | false | 0 | 0 | The problem with real numbers in programming languages is that they are usually defined as functions returning a finite representation given an accuracy (eg. a function which takes n as an argument and returns a floating point number within 2^-n accuracy).
You can definitely turn a rational/integer into a real, but even comparing reals for equality is undecidable (it is essentially the halting problem).
You cannot tell whether a real number x is rational: even in mathematics, it is usually difficult, since you have to find p and q such that x = p/q, and this is often non constructive.
However, given an accuracy window, you can find the "best" rational approximation for this accuracy using for instance continuous fraction expansion. I believe that is essentially what mathematica does. But in your exemple, 6.75 is already rational. Try with Pi instead. | 2 | 10 | 0 | I would like to know a good way of checking if a number x is a rational (two integers n,m exist so that x=n/m) in python.
In Mathematica, this is done by the function Rationalize[6.75] : 27/4
I assume this question has an answer for a given accuracy.
Is there a common algorithm of obtaining these two integers? | Check if a number is rational in Python, for a given fp accuracy | 0 | 0 | 0 | 12,183 |
4,266,741 | 2010-11-24T12:27:00.000 | 1 | 0 | 1 | 0 | python,algorithm,math,floating-point,floating-accuracy | 4,266,788 | 7 | false | 0 | 0 | As you noted any floating point number can be converted to a rational number by moving the decimal point and dividing by the appropriate power of ten.
You can then remove the greatest common divisor from the dividend and divisor and check if both of these numbers fit in the data type of your choice. | 2 | 10 | 0 | I would like to know a good way of checking if a number x is a rational (two integers n,m exist so that x=n/m) in python.
In Mathematica, this is done by the function Rationalize[6.75] : 27/4
I assume this question has an answer for a given accuracy.
Is there a common algorithm of obtaining these two integers? | Check if a number is rational in Python, for a given fp accuracy | 0.028564 | 0 | 0 | 12,183 |
4,266,918 | 2010-11-24T12:44:00.000 | 1 | 0 | 1 | 0 | python,comparison,int,python-2.x,string | 4,267,013 | 4 | false | 0 | 0 | (And who thought it was a good idea to allow this to begin with???)
I can imagine that the reason might be to allow object from different types to be stored in tree-like structures, which use comparisons internally. | 1 | 6 | 0 | In python 3, int(50)<'2' causes a TypeError, and well it should. In python 2.x, however, int(50)<'2' returns True (this is also the case for other number formats, but int exists in both py2 and py3). My question, then, has several parts:
Why does Python 2.x (< 3?) allow this behavior?
(And who thought it was a good idea to allow this to begin with???)
What does it mean that an int is less than a str?
Is it referring to ord / chr?
Is there some binary format which is less obvious?
Is there a difference between '5' and u'5' in this regard? | Why is int(50)<str(5) in python 2.x? | 0.049958 | 0 | 0 | 709 |
4,268,152 | 2010-11-24T14:59:00.000 | 6 | 0 | 1 | 0 | c++,python,functional-programming | 4,268,217 | 7 | false | 0 | 0 | By functional programming, I assume you mean referential transparency (basically, no global state or side-effects), plus things like functions as first-class objects, polymorphic types, partial function application etc.
There is no book that I know of that covers functional programming in C++. You could program without global state and side-effects in C++, and you can pass functions as arguments using function-typed pointers, but you couldn't get partial function application, nor anonymous lambda expressions. | 3 | 5 | 0 | Is there any good book for functional programming in Python or C++ ? I need to master functional programming in those languages. | Functional programming in Python and C++ | 1 | 0 | 0 | 1,139 |
4,268,152 | 2010-11-24T14:59:00.000 | 3 | 0 | 1 | 0 | c++,python,functional-programming | 4,268,330 | 7 | false | 0 | 0 | MMhh if you want to learn functional programming you should learn a functional language first to really understand the principals then you can tree to apply them as good as you can, witch will be harder.
In python you can use functions to modify dictionarys witch is pretty functional. Make use of lambda with higher order function. You have to avoid classes and inheritance.
I cant really say much about C++. Maybe you can find some functional datastructures and then write functions on those. Look for a library that provides functions like map, reduce ...
C++0x should support closures and currying (more or less) so thing will get better.
In general:
Try to write immutible layers on librarys (be awair that that wont performe to well)
Look for librarys that are written in a functional way
Edit: I would recomend learning scheme its really small and you can pick it up fast. Read something like SICP or the Little Schemer that teach you recursiv thinking. | 3 | 5 | 0 | Is there any good book for functional programming in Python or C++ ? I need to master functional programming in those languages. | Functional programming in Python and C++ | 0.085505 | 0 | 0 | 1,139 |
4,268,152 | 2010-11-24T14:59:00.000 | 1 | 0 | 1 | 0 | c++,python,functional-programming | 4,268,194 | 7 | false | 0 | 0 | Only a future version of C++ supports lambdas / anonymous functions. I guess Boost.Lambda supports C++ Functional programming, but it isn't really a first-class citizen of C++ yet.
Books about functional programming typically use functional languages. Like Haskell, Miranda, Lisp, Scheme, OCaml, Javascript and so forth.
EDIT: I'll withhold my opinion on Python for now. It appears I'm mistaken about a few things. | 3 | 5 | 0 | Is there any good book for functional programming in Python or C++ ? I need to master functional programming in those languages. | Functional programming in Python and C++ | 0.028564 | 0 | 0 | 1,139 |
4,268,323 | 2010-11-24T15:15:00.000 | 5 | 0 | 1 | 0 | python,regex,match | 4,268,344 | 5 | false | 0 | 0 | a, b = '425x344'.split('x') | 1 | 0 | 0 | I have a string in the following form :
"425x344"
Now I'd like to resolve first and second numbers from this string as two separate variables. How can I do this ? I've created this regex:
regex = re.compile(r"^(\d+x\d+)")
to check if the string form is proper. But what next ? | Resolve variables from a string | 0.197375 | 0 | 0 | 1,218 |
4,268,374 | 2010-11-24T15:19:00.000 | 2 | 1 | 0 | 1 | python | 4,268,840 | 1 | true | 0 | 0 | Cron job. It's more likely to be "in line" with actual time, since it's a more stable and time-tested choice. It's also less demanding on resources than using a loop in Python since it doesn't require a constant Python interpreter process, and is probably better optimized than pyGTK (choice is mature, stable software vs. less mature, less stable). | 1 | 2 | 0 | Well, I have created a python script, which checks the number of uncompleted tasks of tasque and displays it using pynotify periodically. My question is how do I implement this timer. I can think of two things. A Cron job to execute a python script periodically or using a python script which uses a gtk loop to call the specified function for checking periodically. | Gtk loop or Cron for timer | 1.2 | 0 | 0 | 383 |
4,269,287 | 2010-11-24T16:47:00.000 | 3 | 0 | 0 | 0 | python,twisted | 4,269,340 | 3 | false | 0 | 0 | Yes, each computer (as long as their on the same network) can establish a server instance with inbound and outbound POST/GET. | 3 | 2 | 0 | Is it possible to write a peer-to-peer chat application in Python?
I am thinking of this from a hobbyist project point-of-view. Can two machines connect to each other directly without involving a server? I have always wondered this, but never actually seen it implemented anywhere so I am thinking there must be a catch somewhere.
PS: I intend to learn Twisted, so if that is involved, it would be an added advantage! | Writing a P2P chat application in Python | 0.197375 | 0 | 1 | 2,413 |
4,269,287 | 2010-11-24T16:47:00.000 | 0 | 0 | 0 | 0 | python,twisted | 49,536,752 | 3 | false | 0 | 0 | I think i am way too late in putting my two bits here, i accidentally stumbled upon here as i was also searching on similar lines. I think you can do this fairly easily using just sockets only, however as mentioned above one of the machines would have to act like a server, to whome the other will connect.
I am not familiar with twisted, but i did achieved this using just sockets. But yes even i am curious to know how would you achieve peer2peer chat communication if there are multiple clients connected to a server. Creating a chat room kind of app is easy but i am having hard time in thinking how to handle peer to peer connections. | 3 | 2 | 0 | Is it possible to write a peer-to-peer chat application in Python?
I am thinking of this from a hobbyist project point-of-view. Can two machines connect to each other directly without involving a server? I have always wondered this, but never actually seen it implemented anywhere so I am thinking there must be a catch somewhere.
PS: I intend to learn Twisted, so if that is involved, it would be an added advantage! | Writing a P2P chat application in Python | 0 | 0 | 1 | 2,413 |
4,269,287 | 2010-11-24T16:47:00.000 | 5 | 0 | 0 | 0 | python,twisted | 4,269,328 | 3 | true | 0 | 0 | Yes. You can do this pretty easily with Twisted. Just have one of the peers act like a server and the other one act like a client. In fact, the twisted tutorial will get you most of the way there.
The only problem you're likely to run into is firewalls. Most people run their home machines behind SNAT routers, which make it tougher to connect directly to them from outside. You can get around it with port forwarding though. | 3 | 2 | 0 | Is it possible to write a peer-to-peer chat application in Python?
I am thinking of this from a hobbyist project point-of-view. Can two machines connect to each other directly without involving a server? I have always wondered this, but never actually seen it implemented anywhere so I am thinking there must be a catch somewhere.
PS: I intend to learn Twisted, so if that is involved, it would be an added advantage! | Writing a P2P chat application in Python | 1.2 | 0 | 1 | 2,413 |
4,270,167 | 2010-11-24T18:17:00.000 | 0 | 0 | 1 | 0 | python | 15,319,698 | 13 | false | 0 | 0 | Why avoid while loops? For training purposes. I quote from the book:
Never be a slave to the rules in real life. For training purposes you
need to follow these rules to make your mind strong, but in real life
sometimes these rules are just stupid. If you think a rule is stupid,
try not using it.
The fact is that some of these rules are stupid all the time, in real life. Avoiding while loops is one. His rule for for loops is that you use them when there is a list (or tuple or generator) of elements to iterate over or a fixed number of iterations. This is correct. When there is not, and you instead have a certain state or condition you want to reach, you use while loops. Only using them when you have an infinite loop (like event handlers) is a stupid rule. But newbies tend to use them too often, maybe that's why he has the rule there. | 6 | 27 | 0 | I'm about 2 weeks deep in my study of Python as an introductory language. I've hit a point in Zed's "Learn Python the Hard Way" where he suggests:
Use a while-loop only to loop forever, and that means probably never. This only applies
to Python, other languages are different.
I've googled all over this, referenced everything I can, but I can't find any reason in the world why this would be a convention in Python. What makes it different?
When I gave up programming 10 years ago, I was working in VB and would regularly be told to get rid of my For loops and use While loops instead. I was a hack (as I am today, though I wrote a LOT of code back then), so I just did what I was told without questioning it. Well, now I'm questioning it. Is this a speed issue? Is it just to avoid escape-less infinites? | Why avoid while loops? | 0 | 0 | 0 | 10,202 |
4,270,167 | 2010-11-24T18:17:00.000 | 2 | 0 | 1 | 0 | python | 4,295,385 | 13 | false | 0 | 0 | The for loop is best for looping through a collection. I mostly think of the for loop as a "definite loop." Using a for loop for a collection prevents errors arising from attempting to use indices that are out of bounds or from accidentally using negative indices. Unless you are in a special situation, use a for loop for traversing a collection.
The while loop is most useful for situations where you may have to repeat an action an indefinite number of times. It is the "indefinite loop". The example shown above for calculating a gcd is a prime example of where to use a while loop. You must bear in mind that the predicate in the while must change, or you could get stuck in an infinite loop.
If at all possible, avoid using break to get out of a loop. | 6 | 27 | 0 | I'm about 2 weeks deep in my study of Python as an introductory language. I've hit a point in Zed's "Learn Python the Hard Way" where he suggests:
Use a while-loop only to loop forever, and that means probably never. This only applies
to Python, other languages are different.
I've googled all over this, referenced everything I can, but I can't find any reason in the world why this would be a convention in Python. What makes it different?
When I gave up programming 10 years ago, I was working in VB and would regularly be told to get rid of my For loops and use While loops instead. I was a hack (as I am today, though I wrote a LOT of code back then), so I just did what I was told without questioning it. Well, now I'm questioning it. Is this a speed issue? Is it just to avoid escape-less infinites? | Why avoid while loops? | 0.03076 | 0 | 0 | 10,202 |
4,270,167 | 2010-11-24T18:17:00.000 | 3 | 0 | 1 | 0 | python | 4,272,955 | 13 | false | 0 | 0 | Let me share a secret with you: Nine times out of ten with python, the answer is just "use common sense". It's not a terribly tricky language (aside from some notable gotchas). In this case, I'd consider Zed's rule of thumb superfluous because it's almost always common sense to know what kind of loop to use.
That said, if I run into a situation that requires iteration and I have a choice, I prefer the following (from greatest to least preference):
List/generator/set/dict comprehension
For loop
While loop
Recursion
Comprehensions are simple, but it's surprising how many times you can make a for loop into one if you put thought into it. But generally, I'd say that about 90% of all iteration I'll do is with a list comprehension or a for loop. | 6 | 27 | 0 | I'm about 2 weeks deep in my study of Python as an introductory language. I've hit a point in Zed's "Learn Python the Hard Way" where he suggests:
Use a while-loop only to loop forever, and that means probably never. This only applies
to Python, other languages are different.
I've googled all over this, referenced everything I can, but I can't find any reason in the world why this would be a convention in Python. What makes it different?
When I gave up programming 10 years ago, I was working in VB and would regularly be told to get rid of my For loops and use While loops instead. I was a hack (as I am today, though I wrote a LOT of code back then), so I just did what I was told without questioning it. Well, now I'm questioning it. Is this a speed issue? Is it just to avoid escape-less infinites? | Why avoid while loops? | 0.046121 | 0 | 0 | 10,202 |
4,270,167 | 2010-11-24T18:17:00.000 | 2 | 0 | 1 | 0 | python | 4,270,225 | 13 | false | 0 | 0 | Also there are list comprehensions e.g.:
>>> vec = [2, 4, 6]
>>> [3*x for x in vec]
[6, 12, 18] | 6 | 27 | 0 | I'm about 2 weeks deep in my study of Python as an introductory language. I've hit a point in Zed's "Learn Python the Hard Way" where he suggests:
Use a while-loop only to loop forever, and that means probably never. This only applies
to Python, other languages are different.
I've googled all over this, referenced everything I can, but I can't find any reason in the world why this would be a convention in Python. What makes it different?
When I gave up programming 10 years ago, I was working in VB and would regularly be told to get rid of my For loops and use While loops instead. I was a hack (as I am today, though I wrote a LOT of code back then), so I just did what I was told without questioning it. Well, now I'm questioning it. Is this a speed issue? Is it just to avoid escape-less infinites? | Why avoid while loops? | 0.03076 | 0 | 0 | 10,202 |
4,270,167 | 2010-11-24T18:17:00.000 | 4 | 0 | 1 | 0 | python | 4,270,207 | 13 | false | 0 | 0 | It is not a speed issue, and it is what it is, a suggestion.
I think the intention is to make the code more explicit and easier to read. If you can write it without a while loop in python, it probably looks cleaner and is easier to understand. | 6 | 27 | 0 | I'm about 2 weeks deep in my study of Python as an introductory language. I've hit a point in Zed's "Learn Python the Hard Way" where he suggests:
Use a while-loop only to loop forever, and that means probably never. This only applies
to Python, other languages are different.
I've googled all over this, referenced everything I can, but I can't find any reason in the world why this would be a convention in Python. What makes it different?
When I gave up programming 10 years ago, I was working in VB and would regularly be told to get rid of my For loops and use While loops instead. I was a hack (as I am today, though I wrote a LOT of code back then), so I just did what I was told without questioning it. Well, now I'm questioning it. Is this a speed issue? Is it just to avoid escape-less infinites? | Why avoid while loops? | 0.061461 | 0 | 0 | 10,202 |
4,270,167 | 2010-11-24T18:17:00.000 | 4 | 0 | 1 | 0 | python | 4,270,205 | 13 | false | 0 | 0 | A while loop is a tool, nothing more. To use it or not use it is a matter of whether it's the right tool for the job, nothing more. You are right to question the advice, it's silly.
That being said, there are constructs in python that obviate the need for while loops some of the time. For example, list comprehensions do things one might ordinarily do with a while or for loop.
Use the right tool for the job, don't try to memorize and stick to a bunch of rules. The goal is to write code that a) works and b) is clear. | 6 | 27 | 0 | I'm about 2 weeks deep in my study of Python as an introductory language. I've hit a point in Zed's "Learn Python the Hard Way" where he suggests:
Use a while-loop only to loop forever, and that means probably never. This only applies
to Python, other languages are different.
I've googled all over this, referenced everything I can, but I can't find any reason in the world why this would be a convention in Python. What makes it different?
When I gave up programming 10 years ago, I was working in VB and would regularly be told to get rid of my For loops and use While loops instead. I was a hack (as I am today, though I wrote a LOT of code back then), so I just did what I was told without questioning it. Well, now I'm questioning it. Is this a speed issue? Is it just to avoid escape-less infinites? | Why avoid while loops? | 0.061461 | 0 | 0 | 10,202 |
4,270,192 | 2010-11-24T18:20:00.000 | 3 | 0 | 0 | 0 | python,django,python-3.x | 4,270,236 | 3 | false | 1 | 0 | Python 2 will still live for a very long time. Actually, there's no really good reason to use Python 3 right now unless you need Python3 features which are not available as future imports and know that you won't ever need to use 3rd party modules which might not be Python3-compatible.
So the best solution is doing your app now using Python 2 instead of waiting; especially if the app will be useful for you now. | 3 | 8 | 0 | I have a website idea that I'm very excited about, and I love Python. So, I'm interested in using Django. However, I started learning Python in version 3.1, and Django currently only supports various 2.x versions. I've searched for information about when Django will start supporting Python 3.x, and gotten mostly articles from a year or two ago that say it will take a year or two. Meanwhile, the Django FAQ says that there are no immediate plans.
I'm reluctant to build in an old version of Python and then either be stuck with it or go through a huge ordeal trying to migrate later. My original solution to this was to start learning PHP instead and then choose a framework, but as it turns out I don't really like PHP. Django it is, then.
If I decide to wait for a 3.x-compatible version, I can teach myself more front-end web development (and more Python) in the meantime. I've only been at this for a few months so I have a lot to learn. But I don't want to wait forever, and I realize that even after a 3.x-compatible version comes out it will take a while for third-party APIs to catch up. What do you all recommend? | Should I wait for Django to start supporting Python 3? | 0.197375 | 0 | 0 | 884 |
4,270,192 | 2010-11-24T18:20:00.000 | 2 | 0 | 0 | 0 | python,django,python-3.x | 4,270,237 | 3 | false | 1 | 0 | I recommend you learn the frameworks on the old version now, and let 2to3 figure it out when the time comes. | 3 | 8 | 0 | I have a website idea that I'm very excited about, and I love Python. So, I'm interested in using Django. However, I started learning Python in version 3.1, and Django currently only supports various 2.x versions. I've searched for information about when Django will start supporting Python 3.x, and gotten mostly articles from a year or two ago that say it will take a year or two. Meanwhile, the Django FAQ says that there are no immediate plans.
I'm reluctant to build in an old version of Python and then either be stuck with it or go through a huge ordeal trying to migrate later. My original solution to this was to start learning PHP instead and then choose a framework, but as it turns out I don't really like PHP. Django it is, then.
If I decide to wait for a 3.x-compatible version, I can teach myself more front-end web development (and more Python) in the meantime. I've only been at this for a few months so I have a lot to learn. But I don't want to wait forever, and I realize that even after a 3.x-compatible version comes out it will take a while for third-party APIs to catch up. What do you all recommend? | Should I wait for Django to start supporting Python 3? | 0.132549 | 0 | 0 | 884 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.