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 t...
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...
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 t...
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...
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...
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 si...
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 A...
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 ...
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{ ...
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 simp...
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 ...
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 (T...
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 ...
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...
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. Neithe...
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 ...
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...
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 bot...
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 sh...
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 wa...
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 wrappe...
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 ...
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 run...
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:...
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 i...
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...
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 strin...
'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 ... Espe...
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 a...
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 a...
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 ...
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 a...
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, especiall...
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...
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...
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...
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 instal...
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 ...
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 ...
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 ...
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 ...
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 sho...
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...
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 connec...
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 r...
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 ...
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? W...
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 ...
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 pointer...
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...
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 th...
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,...)? Tha...
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...
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 ke...
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...
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 loo...
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...
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 requirem...
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...
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 ...
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 spe...
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 ...
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 ...
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 t...
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 ...
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 a...
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 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...
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 the...
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 ...
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 ...
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 ...
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 ...
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, l...
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 pro...
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 sur...
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 incrementa...
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.S...
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 ...
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.S...
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...
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 applica...
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...
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 applica...
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 fun...
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 s...
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 eve...
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...
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 withou...
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 ord...
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....
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 v...
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...
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 catc...
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 fami...
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 catc...
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 mak...
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 catc...
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 tha...
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, refer...
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...
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, refer...
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 sa...
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, refer...
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, refer...
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, refer...
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 d...
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, refer...
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...
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 articl...
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 articl...
Should I wait for Django to start supporting Python 3?
0.132549
0
0
884