Q_CreationDate
stringlengths
23
23
Title
stringlengths
11
149
Question
stringlengths
25
6.53k
Answer
stringlengths
15
5.1k
Score
float64
-1
1.2
Is_accepted
bool
2 classes
N_answers
int64
1
17
Q_Id
int64
0
6.76k
2012-03-14 05:13:09.437
Beginner advice on how to use FTP or SSH? (django)
I'm in the midst of trying to get my first website up and running all of the sudden I get to the point where I need to get my file online and I have zero idea on how to do that. I thought it would be as easy as selecting your files and clicking upload but so far it has not been that easy. Currently I'm using djangoeuro...
There are different tools for FTP and SSH file transfer. Which one is best for you depends on your environment (e.g. operating system) and your needs (do you want a graphical or command line interface?). But basically it's always a program you run on your machine that connects to a server to upload files. You don't do ...
0
false
1
1,746
2012-03-14 08:54:46.207
How to use pip on windows behind an authenticating proxy
My computer is running windows behind a proxy on a windows server (using active directory), and I can't figure out how to get through it with pip (in python3). I have tried using --proxy, but it still just timeouts. I have also tried setting a long timeout (60s), but that made no difference. My proxy settings are co...
For me, the issue was being inside a conda environment. Most likely it used the pip command from the conda environment ("where pip" pointed to the conda environment). Setting proxy-settings via --proxy or set http_proxy did not help. Instead, simply opening a new CMD and doing "pip install " there, helped.
0
false
1
1,747
2012-03-15 15:21:19.857
Popen-ing a python call that invokes a script using multiprocessing (pgrp issue)?
I'm writing a unittesting framework for servers that uses popen to basically execute "python myserver.py" with shell=False, run some tests, and then proceed to take the server down by killpg. This myserver.py can and will use multiprocessing to spawn subprocesses of its own. The problem is, from my tests, it seems tha...
You're asking about something pretty messy here. I suspect that none of this is what you want to do at all, and that you really want to accomplish this some simpler way. However, presuming you really want to mess with process groups... Generally, a new process group is created only by the setpgrp(2) system call. Otherw...
1.2
true
1
1,748
2012-03-15 16:59:47.290
Can you share an example of using class based view with MonthMixin?
I have a news on my site done with "James Bennett - Practical Django Projects, 2nd Edition (2009)". So I am using a date-based views, which will be deprecated in django-1.4. How can I just convert my views and urls to class-based views ? May be you have seen this, please just post a link, I can't find any working examp...
Think of CBV, more specifically "Generic Class Based Views" as a large tree of Python classes. Starting with the simplest class. Each one subclasses and over rides methods from one another. For example, the ArchiveIndexView is typically the view you will sub-class for the index of your site. It adds an extra context va...
0
false
1
1,749
2012-03-15 19:09:47.057
Multiple imports of python modules
Just for my knowledge, how does python, especially wxpython reacts to multiple imports? If I import wx in multiple files, how does it handle that when called the main frame? Does it slows the speed or it firstly checks whether it is already been imported or not?
Only the first import executes the file. Subsequent imports copy the reference from sys.modules.
0.545705
false
2
1,750
2012-03-15 19:09:47.057
Multiple imports of python modules
Just for my knowledge, how does python, especially wxpython reacts to multiple imports? If I import wx in multiple files, how does it handle that when called the main frame? Does it slows the speed or it firstly checks whether it is already been imported or not?
When Python imports a file, it keps track of it by storing it in sys.modules. So whenever Python is importing a file it checks there first and, if it finds it there, returns that instead; if it is not there, it imports it, adds it to sys.modules, and then returns it.
1.2
true
2
1,750
2012-03-16 11:38:13.003
Python : Automate the user input data(Multiple sequential inputs)?
I have a python script say script1.py. It will prompt the user with a serious of questions like Name, 'Y' / 'N' type questions. Now i need to call this python script from another python script,say scripts2.py such that I would define the user inputs in script2.py. So how to pass the input sequentially??? Help would...
Sounds like you have a stand-alone program that reads from stdin, and you want to automate input to it using python. Download and use the pexpect module, that's what it's for.
1.2
true
1
1,751
2012-03-16 15:22:11.607
Python - Small Change to a Huge File
This is a theoretical question as I don't have an actual problem, but I got to wondering ... If I had a huge file, say many gigs long and I wanted to change a single byte and I knew the offset of that byte, how could I do this efficiently? Is there a way to do this without rewriting the entire file and only writing th...
You can seek() to a position and write a single byte. It will overwrite what's there, rather than inserting.
0.201295
false
1
1,752
2012-03-17 19:08:36.900
How to handle dynamic URLs while crawling online stores?
I am crawling online stores for price comparison. Mot of the stores are using dynamic URLs heavily. This is causing my crawler to spend lot of time on every online stores. Even though most of them have only 5-6k unique products, they have unique URLs >= 300k. Any idea how to get around this. Thanks in advance!
If you parsing some product pages, usually these URLs have some kind of product id. Find the pattern to extract product id from URLs, and use it to filter already visited URLs.
1.2
true
1
1,753
2012-03-19 00:41:03.027
How to erase all text from a file using python, but not delete/recreate the file?
I want to basically copy whats from the clipboard and paste it in a file in utf-8 encoding, but what ever I try, the file has the '?' symbols in it and is Anscii encoding... But what I found out is, if there is a file that's already in utf-8 encoding, then whatever I paste in it manually (deleting whats there already),...
Opening the file in write/read mode (w+) will truncate the file without rewriting it if it already exists.
1.2
true
1
1,754
2012-03-19 04:03:29.483
How to use Coffeescript on Google App Engine
Does anyone know if it is possible to use Coffeescript on Google App Engine? If so how can this be done with the app engine Python or Go platforms?
Coffeescript compiles to Javascript, which can be run in a web browser. In that case, App Engine can serve up the resulting javascript. I don't know of any way to compile coffeescript to python, java or go though, so you can't use it as a server side language.
1.2
true
1
1,755
2012-03-20 07:42:03.747
Working on tables in pdf using python
I am working on a pdf file. There is number of tables in that pdf. According to the table names given in the pdf, I wanted to fetch the data from that table using python. I have worked on html, xlm parsing but never with pdf. Can anyone tell me how to fetch tables from pdf using python?
This is a very complex problem and not solvable in general. The reason for this is simply that the format PDF is too flexible. Some PDFs are only bitmaps (you would have to do your own OCR then—obviously not our topic here), some are a bunch of letters literally spilled out over the pages; this means that by parsing t...
0.545705
false
1
1,756
2012-03-20 13:58:01.020
Google App Engine Development and Production Environment Setup
Here is my current setup: GitHub repository, a branch for dev. myappdev.appspot.com (not real url) myapp.appspot.com (not real url) App written on GAE Python 2.7, using django-nonrel Development is performed on a local dev server. When I'm ready to release to dev, I increment the version, commit, and run "manage.py u...
I'm on a pretty similar setup, though I'm still runing on py2.5, django-nonrel. 1) I usually use 'git status' or 'git gui' to see if I forgot to check in files. 2) I personally don't check in my datastore. Are you familiar with .gitignore? It's a text file in which you list files for git to ignore when you run 'git s...
1.2
true
1
1,757
2012-03-20 23:38:44.367
how soon is `__del__` called after reference count drops to zero?
How soon after the reference count reaches zero is __del__ method called? Does the language promise that it's done right away, before any other use code can execute? Or can each implementation do what it likes, potentially delaying the call to __del__ arbitrarily long? Please ignore the situation when the program is ab...
Python doesn't make any guarantees about when __del__ is called, or whether it is called at all. As it is, __del__ methods are unlikely to be called if the object is part of a reference cycle, because even if the cycle as a whole is cleaned up, Python has no way to decide where to break the cycle and in what order the ...
1.2
true
1
1,758
2012-03-21 15:01:47.537
How to import in Java Python subclasses that use abstract methods of other classes?
We need to use in Java written software some Python subclasses of an abstract Python class. Trying to do it with Jython we had some troubles that we haven't experienced importing not-abstract Python classes. More specifically, the error that we get is this the source attachment is not contain the source for the file P...
Code would really be needed, but my gut feeling is, that your system has access to the compiled .class file from Jython but not the .py source file
0
false
1
1,759
2012-03-21 15:56:55.577
GAE wait response from other source
I don't know how to present the title more clearly. I want build a site on Google app engine (GAE), and one app on android. The site on GAE should wait the signal which is from the app on android and handle the signal to do something. I don't know how to search the "keyword" on Google of waiting signal on GAE, or wha...
You don't seem to have understood how web applications work. They don't wait for signals - or, rather, that's all they do. Every page served by a Web service is in response to a signal, ie a request. Your web service just needs to respond to normal requests in the normal way.
0.386912
false
1
1,760
2012-03-21 20:10:33.723
How do I define a method which can accept different sequences of arguments?
In C#, Python and/or VB.NET, how can I write a method of a class that can accept different sequences of arguments? As an indication, the multiple choices of arguments sequence would be accessible when pressing shift+shift+space in Visual Studio.
If the arguments are of a different type you could overload the method Alternatively, you can just pass in a value indicating the sequence of arguments and have logic within the method to treat it accordingly.
0
false
1
1,761
2012-03-22 16:16:41.417
Multiple Python projects organization for deployment and/or distribution
We have multiple Python projects that have dependencies on each other. Hierarchically, these are organized like this: P1 P2 ... Pn Each of these is an PyDev project within Eclipse and they co-exist just fine within that environment. We are in the process of structuring out build process to enable us to deploy these a...
There's different philosophies on how apps should be packaged, but most Python developers adhere to a very minimalistic approach. In other words, you package up the smallest units of logic you can. So, your goal here shouldn't be to cram everything together, but to package each discrete application separately. By appli...
1.2
true
1
1,762
2012-03-25 15:26:28.333
Openshift, python, mongodb, and cron guidance needed
I have a python web app that essentially allows 2 computers to talk with one another. If a session ends abruptly the record is still stored in pymongo, I want to be able to run a cron job to clean up old records, but I am not clear on how to do that, can't figure how to use bash to talk to pymongo... What else could I...
You could write a python script using pymongo (or any other mongodb client library) that does the necessary cleanup and configure cron to run it regularly.
0.201295
false
1
1,763
2012-03-25 23:01:56.990
QAbstractTableModel as a model for one QTableView and few QListViews
Salut, community! Briefly. I wrote usual model over QAbstractTableModel and using it in usual way for QTableView. But I think I need to use some columns of this model for the few QListViews in QWizard to fill main table in the right way (for user). For example: use the column2 as the QListView's model on the page1 of t...
Set the QTableModel as the model for each QListView, and use QListView.setModelColumn to choose which column they each display.
1.2
true
1
1,764
2012-03-26 08:16:52.450
How do I change the default font for Python code in Eclipse?
In Eclipse, how can I change default font for Python code in the editor (PyDev plugin)? I navigate to menu Window → Preference → General → Appearance → Colors & Fonts, but I don't find which item would affect the Python code font.
Following the guidance of gecco, I found out the item in General → Appearance → Colors & Fonts which affects Python code fonts. It's Text Font in the Basic folder.
0.201295
false
2
1,765
2012-03-26 08:16:52.450
How do I change the default font for Python code in Eclipse?
In Eclipse, how can I change default font for Python code in the editor (PyDev plugin)? I navigate to menu Window → Preference → General → Appearance → Colors & Fonts, but I don't find which item would affect the Python code font.
On a Mac, I can get to the PyDev settings via: Eclipse → Preferences → PyDev (in tree) → Editor (subtree) In my case, I wanted to change hash tag comments from nearly invisible grey to a better color. It worked like a charm.
0.201295
false
2
1,765
2012-03-26 12:22:36.877
how to show an object's type in google app engine
For debug use I want to show the type of a variable in Google App Engine. In traditional environment, I will use "print type( x )" to do it. But in GAE I just don't know why I can't use self.response.out.write( str( type( x ) ) ) to echo it in the browser. I got confused because I did transform the <type 'type'> to <...
When browser renders html it thinks that <type 'str'> is a (unknown) tag, so it renders it as <type 'str'></type>, hence it becomes part of your page markup... You can see this with Firebug or any similar tool.
1.2
true
1
1,766
2012-03-26 14:05:28.250
Choose m evenly spaced elements from a sequence of length n
I have a vector/array of n elements. I want to choose m elements. The choices must be fair / deterministic -- equally many from each subsection. With m=10, n=20 it is easy: just take every second element. But how to do it in the general case? Do I have to calculate the LCD?
Use a loop (int i=0; i < m; i++) Then to get the indexes you want, Ceil(i*m/n).
0.240117
false
1
1,767
2012-03-27 09:13:48.773
Different national and international shipping rate in Satchmo?
I'm taking over a Satchmo site and need it to charge a different shipping rate for international versus local postage. Any idea what I need to do to enable this?
it seems like the tieredweight shipping module is what I need here.
1.2
true
1
1,768
2012-03-27 16:04:05.863
How to use PyPy on Windows?
I was wondering how to use PyPy 1.8 on Windows XP 32-bit. I downloaded the zip file off the website and installed it into a My Documents file. Initially, I thought it was similar to psyco in that I had to "import psyco," but I found that PyPy.exe acted like the Python command line instead. I tried dragging my scripts i...
Maybe I'm not following what you're trying to do, but isn't it just a question of opening a command prompt and running pypy myscriptname ? Assuming you've got all the paths for PyPy and your script straight, anyway (e.g. your script's in PyPy's folder).
1.2
true
2
1,769
2012-03-27 16:04:05.863
How to use PyPy on Windows?
I was wondering how to use PyPy 1.8 on Windows XP 32-bit. I downloaded the zip file off the website and installed it into a My Documents file. Initially, I thought it was similar to psyco in that I had to "import psyco," but I found that PyPy.exe acted like the Python command line instead. I tried dragging my scripts i...
install Chocolatey choco install python.pypy -y
0
false
2
1,769
2012-03-27 23:32:06.163
cloud scripting through browser and evaluate python on server
Is there any way in a browser, to type python code into an input field, it will then be sent to a local server and executed and the result pushed back to the browser. Basically a browser hosted python notebook, where the code gets evaluated on a different machine. Is there any python package to do this. something like...
I haven't tried myself. You may want to check out ipython notebook.
0.135221
false
1
1,770
2012-03-27 23:48:13.370
What is the most efficient way to keep track of unique downloaded files in a Python program?
This isn't as much of a specific problem as something I am looking for more of a "Pythonic" philosophical answer to. Namely, what's the best way to keep track of unique items and ensure duplicates don't arise? For example, I am writing a script to scrape a website for links to songs on SoundCloud so I can automaticall...
Use a dict or set. Consider computing a checksum of each item. This brings you toward what's known as Content Addressable Storage, which is where the checksum actually is stored as if it were the item's "name", and a separate index is stored which maps things like filenames or song names to the checksums or data bloc...
0.673066
false
1
1,771
2012-03-28 22:58:14.100
how can i make gevent application exit immediately after any exception?
i'm working with an application written in python using gevent. i want it to exit immediately as a result of any exception that i haven't explicitly trapped. it looks like i'd have to patch the core gevent code. is there any way can i do this in my app, without patching gevent or greenlet?
You can use spawn_link_exception instead of spawn.
0
false
1
1,772
2012-03-29 07:41:07.180
Rounding numbers: Java's 'Math.rint' in Python
Does an analogue to Java's Math.rint exist in Python? If not, how can I achieve the same result?
You can use the built-in function round: round(3.5) gives 4.0 round(3.4) gives 3.0 round(3.6) gives 4.0
0
false
1
1,773
2012-03-29 13:54:39.763
How can I protect my AWS access id and secret key in my python application
I'm making an application in Python and using Amazon Web Services in some modules. I'm now hard coding my AWS access id and secret key in *.py file. Or might move them out to an configuration file in future. But there's a problem, how can I protect AWS information form other people? As I know python is a language that ...
Don't put it in applications you plan to distribute. It'll be visible and they can launch instances that are directly billable to you or worst..they can take down instances if you use it in production. I would look at your programs design and seriously question why I need to include that information in the app. If yo...
0
false
1
1,774
2012-03-29 14:48:04.253
Cookbook GUI interface for a command-line script
I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is. I could work for hours trying to determine which Python GUI toolkit is "best", then learning how to do w...
This depends mostly on your need. If your need is simple, you can just go with tkinter that is bundled with python itself. If you use this, you will not be relying on third party library to implement your GUI. Since you are wanting to make this available for your collegues, this might be easier to compile with py2exe o...
0
false
3
1,775
2012-03-29 14:48:04.253
Cookbook GUI interface for a command-line script
I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is. I could work for hours trying to determine which Python GUI toolkit is "best", then learning how to do w...
There are a few answers advocating wxpython. However, any toolkit will work for this project. Tkinter has the added benefit tha you and your collegues already have it installed and it is very easy to use. That being said, the other toolkits are more-or-less equally easy to use but you might have to jump through a hoop...
0.101688
false
3
1,775
2012-03-29 14:48:04.253
Cookbook GUI interface for a command-line script
I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is. I could work for hours trying to determine which Python GUI toolkit is "best", then learning how to do w...
Basically you just need to figure out what widgets will hold the data you want the best. I suspect you could use a couple combo boxes to hold different sets of extensions. Or you could just use the path name strings to figure that out. Hit a button and run the conversion process, probably in another thread so the GUI r...
0
false
3
1,775
2012-04-02 15:55:40.447
how to find the middle number in python
Given 3 numbers, I need to find which number lies between the two others. ie,given 3,5,2 I need 3 to be returned. I tried to implement this by going thru all three and using if else conditions to check if each is between the other two.But this seems a naive way to do this.Is there a better way?
Put them in a list, sort them, pick the middle one.
1.2
true
1
1,776
2012-04-03 10:56:17.117
Linux - Linebreak in IPython
Hi I'm new to Linux and I really like the idea of writing and testing python code in a shell. But my problem is how can I do line breaks in IPython. Every time I use the (I think) "normal" shortcut shift+enter the code gets executed. Function keys are disabled and keyboard layout works fine on my laptop, what could be ...
If you want to do a line-break, you end the line with the \ escape character, same as you do in a Python file. Shift+Enter doesn't have any special meaning in ipython, and indeed most over places in the shell. It doesn't have special meaning in Python, either. It does have special meaning in some text editors and word ...
0.740859
false
2
1,777
2012-04-03 10:56:17.117
Linux - Linebreak in IPython
Hi I'm new to Linux and I really like the idea of writing and testing python code in a shell. But my problem is how can I do line breaks in IPython. Every time I use the (I think) "normal" shortcut shift+enter the code gets executed. Function keys are disabled and keyboard layout works fine on my laptop, what could be ...
Nothing is the problem. Python code is executed line-by-line. If your code does not work when executed line-by-line, it should not work when loaded from a file (assuming in both cases a "clean" environment).
1.2
true
2
1,777
2012-04-03 14:10:45.350
How to structure complex Django project?
I have a Django project which is getting more and more complex. I started off with the traditional files: models, views, and forms.py. The issue I have right now is that those files are getting bigger and bigger and I'd like to break them into manageable parts. What are the best practices around that? In addition, I am...
I certainly use class methods, and I have found that where there are similar operations to be performed on classes, it is possible (and easy) to factor the classmethods into base classes (use the self parameter of your class method to write generic code). Probably the best way to manage broken-up views, etc is to repla...
0.135221
false
2
1,778
2012-04-03 14:10:45.350
How to structure complex Django project?
I have a Django project which is getting more and more complex. I started off with the traditional files: models, views, and forms.py. The issue I have right now is that those files are getting bigger and bigger and I'd like to break them into manageable parts. What are the best practices around that? In addition, I am...
I find refactoring can really help. Are there a lot of similar views that just have different templates or querysets? Make a more generic view that accepts multiple template names, records, etc. Anything that requires extensive calculations gets moved to a utils.py in the same directory. Class methods are for actions t...
1.2
true
2
1,778
2012-04-03 23:09:19.407
need to ssh to remote machine from web page with python/django
I acquired a python script that will either telnet to some equipment, or if the equipment is in a lab, ssh to a firewall machine and then it will telnet to the equipment, and run a command, returning the output for more processing. I took this script and tied it into a Django web app so that I could, from a browser, fi...
You're close. The problem here is probably that your web server runs as a non-privileged user (NOT root), like www or www-data or nobody (depending on your operating system). While that user can probably run the SSH binary, when doing so as nobody, it probably doesn't have a home directory, can't find your .ssh direc...
0.673066
false
1
1,779
2012-04-04 00:08:33.037
Python determinant calculation(without the use of external libraries)
I'm making a small matrix operations library as a programming challenge to myself(and for the purpose of learning to code with Python), and I've come upon the task of calculating the determinant of 2x2, 3x3 and 4x4 matrices. As far as my understanding of linear algebra goes, I need to implement the Rule of Sarrus in or...
The rule of Sarrus is only a mnemonic for solving 3x3 determinants, and won't be as helpful moving beyond that size. You should investigate the Leibniz formula for calculating the determinant of an arbitrarily large square matrix. The nice thing about this formula is that the determinant of an n*n matrix is that it can...
0.995055
false
1
1,780
2012-04-04 06:34:02.447
How python logging get it's configuration
I used to Python logging, it works fine. The logging.basicConfig(...) set in one module (a some.py file), then we can use logging every where. Obviously, logging is global. The question is how logging find it's settings, when we not call the module where basicConfig(...) appeared (in some.py file )? Is logging scan ...
I think there is no magic scanning here. Try to test it this way in a separate test directory: test/main.py: import logging logging.info('test') test/any.py: import logging logging.basicConfig(filename='test.log', level=logging.INFO) python main.py Result: NO test.log file. Now let's update the test:...
0.386912
false
1
1,781
2012-04-04 10:53:00.707
How to install the py2exe modul in Linux
I downloaded the actual py2exe package. But I've no idea how to get it in my system. I mean I can follow the tutorial a 100% but I can't find anything how to install py2exe to my kubuntu 11.10. I also can't find a py2exe.py which I could include to my workingfolder. Could some please help me the project has to be fini...
Py2exe has to run on Windows, you can not run it in Linux. (Maybe wine can help, but I'm not sure)
0.999753
false
1
1,782
2012-04-04 19:06:44.973
Maximizing apache server instances with large mod_wsgi application
I'm writing a Oracle of Bacon type website that involves a breadth first search on a very large directed graph (>5 million nodes with an average of perhaps 30 outbound edges each). This is also essentially all the site will do, aside from display a few mostly text pages (how it works, contact info, etc.). I currently h...
First up, look at daemon mode of mod_wsgi and don't use embedded mode as then you can control separate to Apache child processes the number of Python WSGI application processes. Secondly, you would be better off putting the memory hungry bits in a separate backend process. You might use XML-RPC or other message queuein...
1.2
true
1
1,783
2012-04-04 20:29:35.327
How do I create a canvas selection tool?
What I'm wanting to do is create a selection tool (like what you see in most paint programs) using PyGtk. I've seen a previous question that asked something similar, but they already seemed to know what they were doing to make the selection itself. That user said he was using an eventbox, but I don't know how I would...
If you want to display an image and allow the user to select and move parts of it, you best look for a ready-made image editing widget. GTK doesn't come with one. To roll your own you can use an image widget for display, but it doesn't care about the mouse, so you can place it inside an event box and connect to button ...
0
false
1
1,784
2012-04-04 22:52:10.343
Completely locking down Windows 7 using Python 3.2?
This might be a more difficult question since I don't even know how to do it outside of Python... I want to write a terminal program that completely locks up my PC until a password is entered. In the locked state no one should be able to do anything outside the terminal. In it, the user may rampage and write silly comm...
write a while loop Into the while loop write the command to taskkill dwm.exe It's a poor solution, but the only one I know. Regards!
-0.386912
false
1
1,785
2012-04-05 15:22:58.467
Can a python IDLE be used for iterative/in-memory development?
I'm not sure if I worded the subject correctly but essentially I'm curious if someone can develop code in the Python IDLE, or a similar tool, and then through some command spit out the current code in memory. I believe I did this previously when going through a Lisp book and recall it being a very different approach th...
The reason why this is sensible with LISP is that every LISP programs is just a bunch of macros and functions and the s-expressions can be formatted automatically into a nice representation. This isn't the case in Python, where you have more complex syntax (significant whitespace, decorators, lots of control structure...
1.2
true
1
1,786
2012-04-05 18:27:55.963
Duck typing: how to avoid name collisions?
I think understand the idea of duck typing, and would like to use it more often in my code. However, I am concerned about one potential problem: name collision. Suppose I want an object to do something. I know the appropriate method, so I simply call it and see what happens. In general, there are three possible outcome...
If you are worried that the lack of static type checking will let some bugs get through, the answer isn't to bolt on type checking, it is to write tests. In the presence of unit tests, a type checking system becomes largely redundant as a means of catching bugs. While it is true that a type checking system can catch s...
0
false
1
1,787
2012-04-06 15:03:09.837
Python: How to program an IDE Code collapsing?
I'm learning Python and want to make a small text editor that would allow the code collapsing like when def a Function, how you can collapse that to a single line. I'm thinking of using Tkinter but would be open to other environments. I mainly want to know what widget I should use, I'd like to think that I'd be able to...
You could consider the Scintilla text editing component, with bindings for Python (and other languages.) The Scintilla text editing widget is the basis for the SciTE text editor. SciTE supports code folding, so it is certainly doable - it may even be a built in part of Scintilla. From the SciTE website: Scintilla is a...
0.386912
false
1
1,788
2012-04-06 17:36:06.800
How to close the doc reading part of the IPython notebook?
In an IPython notebook, when you look at some docs with ? or help(), a split frame is opened at the bottom of the screen where the documentation shows up. While I find this useful as a guide for continuing to play with some Python code, I would like to close this spit frame when I'm done reading the docs, so to get bac...
You have to press the q key. That works for me.
0.986614
false
2
1,789
2012-04-06 17:36:06.800
How to close the doc reading part of the IPython notebook?
In an IPython notebook, when you look at some docs with ? or help(), a split frame is opened at the bottom of the screen where the documentation shows up. While I find this useful as a guide for continuing to play with some Python code, I would like to close this spit frame when I'm done reading the docs, so to get bac...
Doh, one has to click on the very slim divider line. The subframe then closes...
1.2
true
2
1,789
2012-04-07 11:45:31.420
How do I replace the GLUT title bar icon when using pyopengl?
I am trying to learn OpenGL, and I'm using PyOpenGL and GLUT. What really bugs me, is that I can't figure out how to change the title bar icon. Has anyone had any success in changing this?
You don't. Remember: GLUT is primarily for test applications and demos. If your application is complex and platform-specific enough to need to change its icon, then you probably need to move beyond GLUT.
1.2
true
1
1,790
2012-04-07 13:24:42.113
How do I get the full DN, distinguishedName of an user with python ldap?
I was able to get attributes about an user by doing queries on LDAP using Python ldap but I don't know how to obtain his DN. Remark: Doing CN=sAMAccount,base_dn) is not valid because the user can be somewhere in another sub-tree. Which is the proper way of getting the DN for an user for which I do have the sAMAccount?
The search result contains: A list of search result entries. Each search result entry in the list contains the distinguished name of the entry and a (partial) attribute list or A list of search result references. Each search result reference contains a sequence of URIs After the entries or references comes a single...
1.2
true
1
1,791
2012-04-08 21:11:59.463
How to get program to not throw "Error: Can't load Floyd's algorithm library"
another question for all of you- So i am trying to get a program called Pysomap to work (its basically ISOMAP but for python[http://web.vscht.cz/spiwokv/pysomap/]), i follow the directions best as i can, building it on Ubuntu, Windows, and Fedora (prebuilt libraries), but cant seem to get it to work. On windows (which ...
This source code is over 5 years old and the build script for floyd looks to assume hard-coded python2.4. It seems pretty clear that your floyd module did not build. You will most likely have to go back to the build step and ensure that you are properly generating a _floyd.so. If you built it correctly, then this sho...
0
false
1
1,792
2012-04-08 21:14:26.197
Adding field to SQL table from Django Application
I am developing an application designed for a secretary to use. She has a stack of hundreds of ballot forms which have a number of questions on them, and wishes to input this data into a program to show the total votes for each answer. Each question has a number of answers. For example: Q: "Re-elect current president o...
You really don't want to implement each question/answer as a separate DB field. Instead, make a table of questions and a table of answers, and have a field in the answers table (in general, a ForeignKey) to indicate which question a given answer is associated with.
1.2
true
1
1,793
2012-04-09 08:26:03.567
can we use java code in web2py application code?
I have to implement one web2py application which has to access java code (which has code to connect to the remote machine) but not sure whether we can do it in web2py or not.My PC has Java 1.6, Python2.7 ,web2py ,eclipse installed. Use case is : I have created one button in web2py application and upon clicking the butt...
I would consider looking into webservices. If you could expose url from java, that will route to a method/function of java where logic is performed and it returns json object. While in web2py urllib2 you can make a request and decode that json into native python dictionary. The clue is that you would have to expose all...
1.2
true
1
1,794
2012-04-10 06:56:11.980
Python 2.5.6 build error on Mac Lion
Here is what I would like to do. Use web2py with MySQL. To do that, I need to use source web2py rather than web2py.app To use web2py, I need Python 2.5 I am having trouble building and installing Python 2.5 I downloaded Python-2.5.6.tgz from Python release page. Now, I did ./configure and then make Then, I get th...
web2py works fine with Lion's stock Python 2.7. Unless you have a compelling reason to use 2.5, stick with 2.7.
1.2
true
2
1,795
2012-04-10 06:56:11.980
Python 2.5.6 build error on Mac Lion
Here is what I would like to do. Use web2py with MySQL. To do that, I need to use source web2py rather than web2py.app To use web2py, I need Python 2.5 I am having trouble building and installing Python 2.5 I downloaded Python-2.5.6.tgz from Python release page. Now, I did ./configure and then make Then, I get th...
I have web2py on my iMac OSX Lion using the web2py app and MySQL. I haven't run into any reason why you can't use the app with MySQL.
0
false
2
1,795
2012-04-10 14:27:11.803
Summing numbers with header in Python
I have to write a script that does this: Inputfile: Name 10 -43 54 Name2 654 43 2 -5467 Name3 65 65 Outputfile: Name 21 Name2 -4768 Name3 130 I came to the conclusion that I am supposed to split the input into arrays at the names and then print the first element and the sum of the rest, but I do not know how to do it a...
Open the files and use readline to open the files line by line. Check whether it is string or not. By looking at your file format, I assume everything in between two strings (Name1 and Name2 or else) are numbers so store those on list. Finally use sum(list) to get the output. I am not writing the code since this is "HO...
0.135221
false
1
1,796
2012-04-10 14:55:52.137
Best way to inform user of an SQL Table Update?
I have a desktop python application whose data backend is a MySQL database, but whose previous database was a network-accessed xml file(s). When it was xml-powered, I had a thread spawned at the launch of the application that would simply check the xml file for changes and whenever the date modified changed (due to any...
As I understand this is not a client-server application, but rather an application that has a common remote storage. One idea would be to change to web services (this would solve most of your problems on the long run). Another idea (if you don't want to switch to web) is to refresh periodically the data in your interfa...
0
false
1
1,797
2012-04-11 02:09:29.020
How do I navigate a website through software?
I need to navigate though a website that is written mostly in Javascript. There are no hard links at all, as the page is simply modified through the script. I can do what I need to using Javascript injections one after another, but chrome starts searching for my input instead of injecting it after a certain string leng...
You can use a tool like Selenium to emulate a user clicking things in a web browser (I believe it actually "drives" a real instance of whatever browser you choose.) Selenium has a domain-specific language for specifying what actions you want to perform, and Python bindings for controlling it programmatically. I haven't...
0.386912
false
1
1,798
2012-04-11 04:01:55.863
How do I initialize a one-dimensional array of two-dimensional elements in Python?
I want to initialize an array that has X two-dimensional elements. For example, if X = 3, I want it to be [[0,0], [0,0], [0,0]]. I know that [0]*3 gives [0, 0, 0], but how do I do this for two-dimensional elements?
Using the construct [[0,0]]*3 works just fine and returns the following: [[0, 0], [0, 0], [0, 0]]
0
false
2
1,799
2012-04-11 04:01:55.863
How do I initialize a one-dimensional array of two-dimensional elements in Python?
I want to initialize an array that has X two-dimensional elements. For example, if X = 3, I want it to be [[0,0], [0,0], [0,0]]. I know that [0]*3 gives [0, 0, 0], but how do I do this for two-dimensional elements?
I believe that it's [[0,0],]*3
0
false
2
1,799
2012-04-11 12:09:27.993
Apply decorator to context processor
I'm using Fandjango for a Django Facebook Canvas app. To use fandjango, you need to wrap all view functions with @facebook_authorization_required, which makes sure you're authorized, then gives you the variable request.facebook.user. What I want is to make a context processor which defines a few more variables based on...
There's no need to wrap the context processor. If you've wrapped the view in the first place, then the request will already be annotated with the facebook.user attribute. Since the request is passed to the context processor anyway, you have access to that attribute. You should probably do a quick check - if hasattr(req...
1.2
true
1
1,800
2012-04-12 19:25:23.610
Crawler processes dying unexpectedly
I am facing a problem with crawler processes dying unexpectedly. I am using scrapy 0.14, the problem existed in 0.12 as well . The scrapyd log shows entries like: Process died: exitstatus=None The spider logs dont show spider closed information as depicted by my database status also. Has anybody else faced similar s...
I think i had a similar situation. The reason that processes were dying was that spiders were generating an exception making the process to stop. To find out the exception look at the log files somewhere in .scrapy folder. For each started crawler process scrapy creates a log file with job id in its name.
0
false
1
1,801
2012-04-13 08:30:00.723
Python - Get MAC address of only the connected local NIC
The goal is to collect the MAC address of the connected local NIC, not a list of all local NICs :) By using socket and connect (to_a_website), I can just use getsockname() to get the IP, that is being used to connect to the Internet. But from the IP how can I then get the MAC address of the local NIC ? Main reason f...
Another roundabout way to get a systems mac id is to use the ping command to ping the system's name then performing an arp -a request against the ip address that was pinged. the downfall to doing it that way thou is you need to write the ping response into the memory of python and performing a readline operation to ret...
0
false
1
1,802
2012-04-14 07:16:47.207
__getitem__ method with tuple argument using Python C-API
Is it possible to define a class with a __getitem__ that takes a tuple argument using the Python C-API? The sq_item member of the tp_as_sequence member of a PyTypeObject must be a ssizeargfunc, so I don't see how to do it. (But I assume that the NumPy ndarray does it.)
Yes, use tp_as_mapping instead. Its mp_subscript takes a PyObject * so you can use anything as index/key. To understand how they relate, you could have a look at the source of PyObject_GetItem() which (as the doc says) is the equivalent of Python o[key] expression. You will see that it first tries tp_as_mapping and if ...
1.2
true
1
1,803
2012-04-14 08:01:26.313
Getting a piece of information from development GAE server to local filesystem
I have an application I am developing on top of GAE, using Python APIs. I am using the local development server right now. The application involves parsing large block of XML data received from outside service. So the question is - is there an easy way to get this XML data exported out of the GAE application - e.g., i...
How about writing the XML data to the blobstore and then write a handler that uses send_blob to download to your local file system? You can use the files API to write to the blobstore from you application.
1.2
true
1
1,804
2012-04-15 16:35:34.043
Move file to another directory once it is done transferring
I have a video encoding script that I would like to run as soon as a file is moved into a specific directory. If I use something like inotify, how do I ensure that the file isn't encoded until it is done moving? I've considered doing something like: Copy (rsync) file into a temporary directory. Once finished, move (si...
One technique I use works with FTP. You issue a command to the FTP server to transfer the file to an auxiliary directory. Once the command completes, you send a second command to the server, this time telling it to rename the file from from the aux directory to the final destination directory.If you're using inotify or...
1.2
true
1
1,805
2012-04-15 19:34:47.840
Buildout and zc.recipe.egg - specifying egg download URL directly?
zc.recipe.egg allows you to install any egg and its script with buildout. However, zc.recipe.egg relies on find-links and index behavior, inherit from setuptools I guess. It would like to take an egg server / HTML for scanning. What if I just want to point zc.recipe.egg to a egg direct download URL how would I do that?...
Putting it in find-links should work. I've done that in the past. You have to make sure the link is of the correct format as any python egg.
0
false
1
1,806
2012-04-16 06:19:16.297
Use Python/urllib to access web sites with "siteminder" authentication?
I am trying to access and parse a website at work using Python. The sites authorization is done via siteminder, so the usual urllib/urllib2 user password does not work. Does anyone have an idea how to do that? Thanks NoamM
Agree with Martin - you need to just replicate what the browser does. Siteminder will pass you a token once successfully authenticated. I have to do this as well, will post once I find a good way.
0.135221
false
1
1,807
2012-04-17 18:16:47.643
Pyqt table widget updation
I am inserting some data in qtablewidget after some time interval. For this i am clearing all content of qtable and then inserting data. But the table showing data from first row, I want that the table always show last row. This will feel like real updation of table. how to do this?
After inserting the row, call QTableWidget.scrollToBottom() to show that last row.
0
false
1
1,808
2012-04-17 21:49:42.480
RESTful Web service or API for a Python program in WebFaction
I have developed a few python programs that I want to make available online. I am new to web services, and I am not sure what I need to do in order to create a service where somebody makes a request to an URL (for example), and the URL triggers a Python program that displays something in the user's browser, or a set o...
Well, your question is a little bit generic, but here are a few pointers/tips: Webfaction allows you to install pretty much anything you want (you need to compile it / or ask the admins to install some CentOS package for you). They provide some default Apache server with mod_wsgi, so you can run web2py, Django or any ...
1.2
true
1
1,809
2012-04-17 22:12:49.090
Restricting the number of task requests per App Engine instance
I have a Google App Engine app that periodically processes bursts of memory-intensive long-running tasks. I'm using the taskqueue API on the Python2.7 run-time in thread-safe mode, so each of my instances is handling multiple tasks concurrently. As a result, I frequently get these errors: Exceeded soft private memory ...
There's not currently any way to advise the App Engine infrastructure about this. You could have your tasks return a non-200 status code if they shouldn't run now, in which case they'll be automatically retried (possibly on another instance), but that could lead to a lot of churn. Backends are probably your best option...
0.999998
false
1
1,810
2012-04-17 23:19:36.913
PyQt: Basic example of accessing and adding a submenu to an existing context menu?
Note: I have very little python and PyQt experience... Given a context menu already created, I'm looking for a functional example of how I would gain access to that context menu, so it can be extended for a plugin which is doing the python equivalent of a javascript greasemonkey script. Then I'm also looking for a fun...
Avaris' comments basically answered this question the best. I can't select it, though, because it's comments, rather than an answer. So I'm summarizing that answer here, so this Q can be answered: "If you are given a context menu (QMenu to be specific) you can access it." - Avaris "You can't do this without modifying...
1.2
true
1
1,811
2012-04-18 11:10:43.087
OpenERP: insert Data code
I am new in OpenERP, I have installed OpenERP v6. I want to know how can I insert data in database? Which files I have to modify to do the job? (files for the SQL code)
The addition of columns in the .py files of the corresponding modules you want to chnage will insert coumns to the pgadmin3 also defenition of classes will create tables...when the fields are displayed in xml file and values are entered to the fields through the interface the values get stored to the table values to th...
0
false
2
1,812
2012-04-18 11:10:43.087
OpenERP: insert Data code
I am new in OpenERP, I have installed OpenERP v6. I want to know how can I insert data in database? Which files I have to modify to do the job? (files for the SQL code)
OpenERP works with PostgreSQl as the Back-end Structure. Postgresql is managed by pgadmin3 (Postgres GUI),you can write sql queries there and can add/delete records from there. It is not advisable to insert/remove data directly into Database!!!!
0
false
2
1,812
2012-04-18 21:02:01.900
How to get number of visitors of a page on GAE?
I need to get the number of unique visitors(say, for the last 5 minutes) that are currently looking at an article, so I can display that number, and sort the articles by most popular. ex. Similar to how most forums display 'There are n people viewing this thread' How can I achieve this on Google App Engine? I am using ...
There is no way to tell when someone stops viewing a page unless you use Javascript to inform the server when that happens. Forums etc typically assume that someone has stopped viewing a page after n minutes of inactivity, and base their figures on that. For minimal resource use, I would suggest using memcache exclusiv...
0.135221
false
1
1,813
2012-04-18 21:59:18.727
Selenium+python Reporting
I am doing some R&D on selenium+python. I wrote some test cases in python using selenium webdriver and unittest module. I want to know how can I create report of the test cases. Is there inbuilt solution available in selenium or I need to code to generate file. Or is there any other web testing framework with javascrip...
My experience has been that any sufficiently useful test framework will end up needing a customized logging solution. You are going to end up wanting domain specific and context relevant information, and the pre-baked solutions never really fit the bill by virtue of being specifically designed to be generic and broadl...
0.067922
false
1
1,814
2012-04-19 02:41:32.657
Present blank screen, wait for key press -- how?
'lo, I am currently trying to code a simple routine for an experiment we are planning to run. The experiment starts by entering a subject number and creating a bunch of files. I got that part working. Next, we want the screen to go blank and display a message. Something like 'Please fill in questionnaire 1 and press [E...
raw_input('Please fill in questionnaire 1 and press [ENTER] when you are done.') will wait for someone to hit [enter]. Clearing the screen may be OS/environment dependent, I am not sure.
0
false
1
1,815
2012-04-19 03:55:47.537
source code of python inbuilt functions
I have used type() function in my program... I just want to know how does Python implement this? Or where could I find the source code file that implement this function?
In general import multiprocessing multiprocessing.__path__ multiprocessing.__file__ __path__ yields location of the library __file__ yields complete path of the file. If above didn't work, you need to look into python development source code. Regarding type source code, Raymond Hettinger's answer is correct.
0.386912
false
1
1,816
2012-04-20 06:27:08.403
How do I run a python interpreter in Emacs?
I just downloaded GNU emacs23.4, and I already have python3.2 installed in Windows7. I have been using Python IDLE to edit python files. The problem is that I can edit python files with Emacs but I do not know how to run python interpreter in Emacs. When i click on "switch to interpreter", then it says "Searching for p...
In emacs 24.2 there is python-switch-to-python
0
false
2
1,817
2012-04-20 06:27:08.403
How do I run a python interpreter in Emacs?
I just downloaded GNU emacs23.4, and I already have python3.2 installed in Windows7. I have been using Python IDLE to edit python files. The problem is that I can edit python files with Emacs but I do not know how to run python interpreter in Emacs. When i click on "switch to interpreter", then it says "Searching for p...
C-c C-z can do this. It is the key-binding for the command python-switch-to-python
0.613357
false
2
1,817
2012-04-20 15:31:27.853
how to implement 'daisychaining' of pluggable function in python?
here is the problem: 1) suppose that I have some measure data (like 1Msample read from my electronics) and I need to process them by a processing chain. 2) this processing chain consists of different operations, which can be swapped/omitted/have different parameters. A typical example would be to take this data, first ...
Get the functional module from pypi. It has a compose function to compose two callables. With that, you can chain functions together. Both that module, and functool provide a partial function, for partial-application. You can use the composed functions in a generator expression just like any other.
0
false
1
1,818
2012-04-20 15:38:46.240
What should I do when sys.stdout.encoding is None?
I am trying to handle the different encodings in a Python script the more user-friendly and auto-magic way possible (there are APIs for utf8). It is a cross-platform console script. For printing to stdout I use sys.stdout.encoding and it seems to do the right thing almost always when printing to the console. However wh...
If it is None, simply output your data as utf-8, and document it. If it happens that there are use cases for other encodings, make that an option through the command line or other means.
1.2
true
1
1,819
2012-04-20 19:22:37.000
Compiling PyPy on cygwin
I'm trying to compile PyPy on cygwin, and the compilation stops when python tries to open the file "externmod", which was just compiled with gcc. The problem with gcc on cygwin is that it automatically appends a '.exe' to whatever you're compiling, so even though gcc is called as gcc -shared -Wl,--enable-auto-image-ba...
Windows needs the ".exe" extension to know that it's executable. You'll need to modify the build to look for Windows and use the .exe extension.
0.135221
false
1
1,820
2012-04-21 00:44:33.617
How to scrape in python into excel
I would like to know how I would have a python web scrape dump all of it's results into excel. It's not that I don't know how to webscrape, it's just I do not know how to scrape into excel.
if you don't want to introduce a full excel library, you can write an HTML table or CSV and Excel will happily import those. The downside with this is that you're limited to one worksheet and no formulaes.
0.386912
false
1
1,821
2012-04-21 16:36:47.423
How to set up celery workers on separate machines?
I am new to celery.I know how to install and run one server but I need to distribute the task to multiple machines. My project uses celery to assign user requests passing to a web framework to different machines and then returns the result. I read the documentation but there it doesn't mention how to set up multiple ma...
My understanding is that your app will push requests into a queueing system (e.g. rabbitMQ) and then you can start any number of workers on different machines (with access to the same code as the app which submitted the task). They will pick out tasks from the message queue and then get to work on them. Once they're do...
1.2
true
2
1,822
2012-04-21 16:36:47.423
How to set up celery workers on separate machines?
I am new to celery.I know how to install and run one server but I need to distribute the task to multiple machines. My project uses celery to assign user requests passing to a web framework to different machines and then returns the result. I read the documentation but there it doesn't mention how to set up multiple ma...
The way I deployed it is like this: clone your django project on a heroku instance (this will run the frontend) add RabitMQ as an add on and configure it clone your django project into another heroku instance (call it like worker) where you will run the celery tasks
0.386912
false
2
1,822
2012-04-22 17:35:33.240
What is the most efficient way to trace markups in a string?
This question may have been asked in a different way, if so please point it to me. I just couldn't find it among my search results. I would like to parse text for mark-ups, like those here on SO. eg. * some string for bullet list eg. *some string* for italic text eg. &some string& for a URL eg. &some string&specifi...
Regular expressions, of course! If still haven't done so, learn it. After you are done, you will find it hard to imagine how you got along without it. The samples you show are simple with regular expressions. For example, an asterisk, then a space then a word is expressed as: \*\s\w+ Nothing else but regular expression...
-0.201295
false
1
1,823
2012-04-23 16:55:31.460
Python : Matplotlib annotate line break (with and without latex)
I have a very basic question : how to do a line break with matplotlib in python with an "annotate" command. I tried "\" and "\n" but it does not work. And how to do this for a "Latex" annotation and for a normal text annotation ? Thank you very much.
Quick solutions plt.annotate("I am \n"+r"$\frac{1}{2}$"+"\n in latex math environment", xy=(0.5, 0.5))
0.545705
false
1
1,824
2012-04-24 09:41:20.740
"do not show message again" checkbox in Tkinter warning message
I'm creating message boxes in Tkinter using tkMessageBox.showwarning. Does Tkinter let you insert a sort of checkbox with the message that says, for example, "do not show again" so when selected the message won't appear the next time?
No, the standard dialogs don't support that. If you want such a feature you'll have to build your own dialog out of a Toplevel window and other widgets.
1.2
true
1
1,825
2012-04-24 12:46:20.250
Using pywinauto to automate an MSI installer
I am looking at using pywinauto in python to automate the installation of a Windows MSI installer for testing purposes. When I try to launch the MSI through the application.start I get the following error: "Error returned by CreateProcess: [Error 193] " Is it possible to even do this, or do I need to launch the MSI fir...
You need to launch "msiexec.exe" and pass the MSI as a command line parameter for it to be installed. You cannot launch directly an MSI as you would launch an EXE file. Example: msiexec.exe /i [MSI_path]
0.999329
false
1
1,826
2012-04-24 15:58:51.530
How do you add multiple tuples(lists, whatever) to a single dictionary key without merging them?
I've been trying to figure out how to add multiple tuples that contain multiple values to to a single key in a dictionary. But with no success so far. I can add the values to a tuple or list, but I can't figure out how to add a tuple so that the key will now have 2 tuples containing values, as opposed to one tuple with...
A dictionary value can't contain two tuples just by themselves. Each dictionary key maps to a single value, so the only way you can have two separate tuples associated with that key is for them to be themselves contained within a tuple or list: {'Key1':[(1.000,2.003,3.0029),(2.3232,13.5232,1325.123)]} - note the extra ...
0.265586
false
1
1,827
2012-04-25 12:05:27.583
Eclipse / PyDev overrides @sys, cannot find Python 64bits interpreter
I'm working in a multiuser environment with the following setup: Linux 64bits environment (users can login in to different servers). Eclipse (IBM Eclipse RSA-RTE) 32bits. So Java VM, Eclipse and PyDev is 32bits. Python 3 interpreter is only available for 64bits at this moment. In the preferences for PyDev, I want to ...
I don't really think there's anything that can be done on the PyDev side... it seems @sys is resolved based on the kind of process you're running (not your system), so, if you use a 64 bit vm (I think) it should work... Other than that, you may have to provide the actual path instead of using @sys...
1.2
true
1
1,828
2012-04-25 12:07:29.500
openerp echo the return result of a function
In openerp, im working on a dummy function that (for example) returns the sum of a certain field on selected records. for instance, u select 3 invoices and it returns the sum of the quantity in the invoice lines. i think the function to perform the sum is correct, and even if it wasnt, i just need help in displaying th...
If your purpose is to debug, the simplest solution is to add print statements in your code and then run the server in a console.
0
false
1
1,829
2012-04-25 20:05:10.797
Removing selected characters from text file
I have long a text file where each line looks something like /MM0001 (Table(12,)) or /MM0015 (Table(11,)). I want to keep only the four-digit number next to /MM. If it weren't for the "table(12,)" part I could just strip all the non-numeric characters, but I don't know how to extract the four-digit numbers only. Any ad...
If it's exactly that format, you could just print out line[3:7]
1.2
true
2
1,830
2012-04-25 20:05:10.797
Removing selected characters from text file
I have long a text file where each line looks something like /MM0001 (Table(12,)) or /MM0015 (Table(11,)). I want to keep only the four-digit number next to /MM. If it weren't for the "table(12,)" part I could just strip all the non-numeric characters, but I don't know how to extract the four-digit numbers only. Any ad...
You could parse text line by line and then use 4th to 7th char of every line. ln[3:7]
0.201295
false
2
1,830
2012-04-25 23:52:42.283
Jump Through Polygon/Floor Collision Detection
I am trying to implement a Mario type plat-former in pyGame. I have Collision detection working with Polygons no problem. I am curious how I can get the player to be able to jump through the floor above him, which is a polygon floating in air. What is the theory on how to handle that?
you could make it so that when your character hits a block, they move up at the current speed until they are no longer colliding with the polygon. That way, when you hit the ground from above,you don't go downward through it, but when you hit the bottom, you do. I would recommend a while loop set to the collide functio...
0.386912
false
1
1,831