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
2010-02-24 00:34:30.633
How do I prevent my Python application from automatically closing once reaching the end of code?
I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.
ask user to enter one more variable and print "Press enter to exit..."
0
false
3
449
2010-02-24 00:34:30.633
How do I prevent my Python application from automatically closing once reaching the end of code?
I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.
Well, I guess you mean the terminal that Windows opens for you when you run a python file is closed too fast. You can add raw_input('Press Enter to exit') right before your program would exit. It tells Python to wait for input before exiting.
0.997458
false
3
449
2010-02-24 00:34:30.633
How do I prevent my Python application from automatically closing once reaching the end of code?
I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.
As the other people say, just ask for input to get it to hold. However, I would recommend running your Python scripts in a different manner in Windows. Using the IDLE IDE (should have come with your distribution), just open the script you want to run and press F5. Then, not only can you see the output for as long as yo...
0.386912
false
3
449
2010-02-24 02:59:35.487
django+flex: Debugging strategies
I love django, and I like flex. Django for it's cool debugging system (those yellow pages helps a lot to find bugs in my code), and flex for it possibilities. Recently I come across a problem. If I create a form in flex and then communicate with the django server, I can't see any debugging info (when the exception happ...
I've used firebug to debug the flex side of things. But I've been using json or XML for communication between the two. Since flash uses the browser to do the network stuff, the request should be visible in the net tab of firebug. To debug the django side of things, you have a few options. If you're using the django de...
1.2
true
1
450
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
It always take longer than you think. Try writing a small program doing just a bit of what you need. If you are to write a program with a GUI then make small program showing a frame with Hello World and an Ok-button and see how hard that is.
0.135221
false
11
451
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
Are you just programming or are you designing/architecting? If you are coding according to a design that an experienced Python resource has layed-out then I'd give myself 3-4 times as long since you've described this as a small, fairly simple project. If you are designing/architecting this yourself then you're taking...
0
false
11
451
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
You have roughly 5 weeks to complete the project. If you're confident the Java version would take 2 weeks, that leaves 3 weeks to flail around with the Python version until you have to give up. I say go for it. Python is relatively easy to pick up. I think three weeks of work is enough to time to know whether you c...
0.233696
false
11
451
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
Python is like baby java, you'll pick it up in a breeze.
0.101688
false
11
451
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
Well I would say how fast you pick up Python also depends on what other languages you know(or comfortable) apart from Java. If the only language you know is Java then I don't think the switch from Java to Python would be intuitive or smooth. To start with Java is statically typed and Python is dynamically typed, and it...
0.067922
false
11
451
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
My personal preference is to learn new languages on personal projects, and use tools I already understand on professional projects. So if it was me, I'd do the project in Java, and do a few little Python projects at home. But of course, you learn a lot more a lot faster when you are using a new language "for real" for...
0
false
11
451
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
If you Google for "Pythonic", you'll find a lot of discussion about how to do things in ways that fit well in Python, will be easy to understand by other Python users, and so on. It always takes a while to progress from code that simply works in a language to using that language well -- and in the case of Python, that ...
0.067922
false
11
451
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
Generally, if I'm not familiar with a language, I allow at least a month to get somewhat comfortable with it. Two or three months if it's outside my "comfort zone" of C-like languages. Having said that, I think Java and Python are similar enough that you might trim that a bit. Also, based on your own history, how goo...
0.034
false
11
451
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
Charlie, being a new hire and all, you shouldn't really decide on which technology to code the project. This is a management decision. In fact, even though team skill can be used to determine the technology of choice for one or other project, there are many other, more important, things to take into account. Which te...
0
false
11
451
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
My boss's rule of thumb is any time there's a learning curve, it can triple the time to write the application. So, if Java would take you two weeks, then Python may take about 6.
0.168447
false
11
451
2010-02-24 17:53:26.977
How much leeway do I have to leave myself to learn a new language?
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have ...
I'd say if you want to avoid possible headaches, do it in Java and learn Python at home, by trying to re-create a similar application to the one you do at work, if you want something which feels real. It's likely that if you arent familiar with Python you arent going to take advantage of its capabilities anyway. Once I...
0.034
false
11
451
2010-02-24 23:11:43.677
How to set the program title in python
I have been building a large python program for a while, and would like to know how I would go about setting the title of the program? On a mac the title of program, which has focus, is shown in the top left corner of the screen, next the apple menu. Currently this only shows the word "Python", but I would of course li...
Since your program is interpreted by Python, then what actually is run is Python itself - the interpreter program. You would have to have your Python script merged with Python into a single executable and that would be able to have a separate name. For windows there is py2exe, that does that, but I have no idea if ther...
0.545705
false
1
452
2010-02-25 01:00:55.273
which is the best way to get the value of 'session_key','uid','expires'
i have a string ''' {"session_key":"3.KbRiifBOxY_0ouPag6__.3600.1267063200-16423986","uid":164 23386,"expires":12673200,"secret":"sm7WM_rRtjzXeOT_jDoQ__","sig":"6a6aeb66 64a1679bbeed4282154b35"} ''' how to get the value . thanks
For a simple-to-code method, I suggest using ast.parse() or eval() to create a dictionary from your string, and then accessing the fields as usual. The difference between the two functions above is that ast.parse can only evaluate base types, and is therefore more secure if someone can give you a string that could cont...
0
false
1
453
2010-02-26 23:57:23.183
starting Python IDLE from command line to edit scripts
I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors. So how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?
first make sure you have location of idle in path I am using "python3.5".So mine looks like this: C:\Program Files\Python35\Lib\idlelib.Yours may differ. use this following command:idle -r file_name.py to run the file or just idle file_name.py to edit or start idle -r file_name.py ^&exit
0.116092
false
2
454
2010-02-26 23:57:23.183
starting Python IDLE from command line to edit scripts
I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors. So how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?
Just add IDLE's path to your PATH environment variable. For example I created an environment variable called IDLE_PATH and set the value to C:\Python27\Lib\idlelib Then in my PATH variable I added ;%IDLE_PATH%; and open a new cmd prompt or in console2 just open a new tab and run idle <file_name> to open the file, you w...
0
false
2
454
2010-02-28 19:35:36.417
The difference between python dict and tr1::unordered_map in C++
I have a question related to understanding of how python dictionaries work. I remember reading somewhere strings in python are immutable to allow hashing, and it is the same reason why one cannot directly use lists as keys, i.e. the lists are mutable (by supporting .append) and hence they cannot be used as dictionary ...
Keys in all C++ map/set containers are const and thus immutable (after added to the container). Notice that C++ containers are not specific to string keys, you can use any objects, but the constness will prevent modifications after the key is copied to the container.
1.2
true
1
455
2010-03-01 05:02:35.203
Automate Windows GUI operations with Python
I want to make a Python script that automates the process of setting up a VPN server in Windows XP, but the only way I know how to do it is using the Windows GUI dialogs. How would I go about figuring out what those dialogs are doing to the system and designing a Python script to automate it?
PyAutoGUI can be installed with pip from PyPI. It's cross platform and can control the mouse & keyboard. It has the features of pywinauto and a few more on top. It can't identify windows or GUI controls, but it does have basic screenshot & image recognition features to click on particular buttons. And it's well-documen...
0
false
2
456
2010-03-01 05:02:35.203
Automate Windows GUI operations with Python
I want to make a Python script that automates the process of setting up a VPN server in Windows XP, but the only way I know how to do it is using the Windows GUI dialogs. How would I go about figuring out what those dialogs are doing to the system and designing a Python script to automate it?
Find out how to do what you want using commands (on the command line) and script these commands instead.
0.067922
false
2
456
2010-03-01 23:49:13.073
Pure Python in Xcode?
Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet. Thanks in advance.
A lot of people like eclipse with PyDev for python, although I don't know how wel it works on OS X with apple's mishandling of java.
0
false
2
457
2010-03-01 23:49:13.073
Pure Python in Xcode?
Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet. Thanks in advance.
Just about the best IDE for editing and running Python code is actually still emacs. The python-mode for emacs does a wonderful job of maintaining whitespace and, with a bit of configuration, emacs is truly a powerful editor. Pretty radically different than your typical GUI editor, certainly, and some find it quite di...
0
false
2
457
2010-03-03 17:22:29.117
How do I run Javascript tests in Windmill when using test_windmill for Django?
I'm using the Windmill test system and have it running using test_windmill for Django which works fine for the Python tests. I'd like this to run a suite of Javascript tests also whilst the Django test server is running. I've used the run_js_tests call from the Windmill shell which works fine but I can't find a way to ...
Ok, so couldn't find out how to do this so I'm running the website under Apache and using the windmill standard jstests parameter to run the Javascript tests against this.
0
false
1
458
2010-03-03 19:18:08.713
What are the possible pitfalls in porting Psyco to 64-bit?
The Psyco docs say: Just for reference, Psyco does not work on any 64-bit systems at all. This fact is worth being noted again, now that the latest Mac OS/X 10.6 "Snow Leopart" comes with a default Python that is 64-bit on 64-bit machines. The only way to use Psyco on OS/X 10.6 is by recompiling a custom...
Since psyco is a compiler, it would need to be aware of the underlying assembly language to generate useful code. That would mean it would need to know about the 8 new registers, new opcodes for 64 bit code, etc. Furthermore, to interop with the existing code, it would need to use the same calling conventions as 64 ...
1.2
true
2
459
2010-03-03 19:18:08.713
What are the possible pitfalls in porting Psyco to 64-bit?
The Psyco docs say: Just for reference, Psyco does not work on any 64-bit systems at all. This fact is worth being noted again, now that the latest Mac OS/X 10.6 "Snow Leopart" comes with a default Python that is 64-bit on 64-bit machines. The only way to use Psyco on OS/X 10.6 is by recompiling a custom...
Psyco assumes that sizeof(int) == sizeof(void*) a bit all over the place. That's much harder than just writing down 64bit calling conventions and assembler. On the sidenote, pypy has 64bit jit support these days. Cheers, fijal
0.296905
false
2
459
2010-03-03 21:30:43.127
Generate image for each font on a linux system using Python
I'm looking for a way to list all fonts installed on a linux/Debian system, and then generate images of some strings using these fonts. I'm looking for your advice as I kind of see how to do each part, but not to do both: To list all fonts on a UNIX system, xlsfonts can do the trick: import os list_of_fonts=os.popen("...
You can do this using pango, through the pygtk package. Pango can list fonts and render them.
1.2
true
2
460
2010-03-03 21:30:43.127
Generate image for each font on a linux system using Python
I'm looking for a way to list all fonts installed on a linux/Debian system, and then generate images of some strings using these fonts. I'm looking for your advice as I kind of see how to do each part, but not to do both: To list all fonts on a UNIX system, xlsfonts can do the trick: import os list_of_fonts=os.popen("...
you best bet is to do a find on all the fonts on the system, and then use ImagesFont.load() on the results of that list. I don't know where the fonts are on Debian, but they should be in a well known folder you can just do an os.walk and then feed the filenames in that way.
0.201295
false
2
460
2010-03-04 01:40:53.037
Python and a "time value of money" problem
(I asked this question earlier today, but I did a poor job of explaining myself. Let me try again) I have a client who is an industrial maintenance company. They sell service agreements that are prepaid 20 hour blocks of a technician's time. Some of their larger customers might burn through that agreement in two weeks...
Thanks for the assistance even though my requirements were a bit vague. After consulting someone who is extremely versed in financial mathematics, I determined that a simple formula was not an appropriate solution. What I ended up doing is "exploding" the months into the component days using xrange() and iterating ove...
1.2
true
1
461
2010-03-05 11:48:38.173
how can I make a suggestion for a new feature in python
Suppose I think I have a great idea for some feature that should be in python's standard library. Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO. How can I suggest such a feature to the consideration of the "python committee :)"?
Either add it to the tracker, or join the developer mailing list and suggest it there. Better to do that if you feel you can contribute at least to developing the specification, if not the feature itself.
0
false
3
462
2010-03-05 11:48:38.173
how can I make a suggestion for a new feature in python
Suppose I think I have a great idea for some feature that should be in python's standard library. Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO. How can I suggest such a feature to the consideration of the "python committee :)"?
An alternative to the issue tracker suggested by mpalcona: you can submit it for discussion on the python-dev mailing list. And always, a reference implementation (something that works, even if not in all cases and not efficiently) is always welcomed.
0
false
3
462
2010-03-05 11:48:38.173
how can I make a suggestion for a new feature in python
Suppose I think I have a great idea for some feature that should be in python's standard library. Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO. How can I suggest such a feature to the consideration of the "python committee :)"?
Don't waste time "suggesting" things. Invest time doing things. Simply do this. Build it. Use it. Post it to SourceForge. Put a link to the SourceForge project on PyPi. Done. If it's actually a "great" idea, then everyone will use it and someone will recommend adding it to the standard library. If it's not a "great"...
0
false
3
462
2010-03-06 15:20:39.080
How do I change Remote Desktop Services properties of AD users in .NET?
I need to set properties related to Remote Desktop Services on Active Directory users in .NET (i.e., via System.DirectoryServices), but I can't see that these properties are exposed by the API? I know there is a COM interface for this purpose, IADsTSUserEx. Please show me how I can get at these properties in .NET :) Be...
The problem with some of these properties is that you can see them on the UI via Active Directory Users and Computers, but you cannot set them (or see them) via ADSI Editor. Usually, for properties that aren't directly available from a DirectoryEntry object, you can use its Properties collection as described by Tim Ro...
0
false
1
463
2010-03-08 14:03:58.890
Unit testing aspect-oriented features
I'd like to know what would you propose as the best way to unit test aspect-oriented application features (well, perhaps that's not the best name, but it's the best I was able to come up with :-) ) such as logging or security? These things are sort of omni-present in the application, so how to test them properly? E.g. ...
IMHO, the way of testing users permissions to the pages depends on the design of your app and design of the framework you're using. Generally, it's probably enough to cover your permission checker decorator with unit tests to make sure it always works as expected and then write a test that cycles through your 'views' (...
0.135221
false
2
464
2010-03-08 14:03:58.890
Unit testing aspect-oriented features
I'd like to know what would you propose as the best way to unit test aspect-oriented application features (well, perhaps that's not the best name, but it's the best I was able to come up with :-) ) such as logging or security? These things are sort of omni-present in the application, so how to test them properly? E.g. ...
Well... let's see. In my opinion you are testing three different things here (sorry for the "Java AOP jargon"): the features implemented by the interceptors (i.e. the methods that implement the functions activated at the cutpoints) the coverage of the filters (i.e. whether the intended cutpoints are activated correctl...
0
false
2
464
2010-03-09 13:04:49.940
standalone application in python
I wanted to know how can I make standalone application in python. Basically what I am doing right now is I have a template.tex file and my script generate the pdf by giving some input values. So I have to make exe file for windows and same for linux. I can use cx_freeze for creating exe file. But my problem is most of ...
You could write a installer (using NSIS or something) that does two things : install LateX (or make sure there is an installation of latex available), potentially by calling another installer then install your python script (which can assume latex is now available)
0.386912
false
1
465
2010-03-10 04:56:22.713
How to make script/program to make it so an application is always running?
I have a simple .exe that needs to be running continuously. Unfortunately, sometimes it crashes unexpectedly, and there's nothing that can be done for this. I'm thinking of like a C# program that scans the running application tree on a timer and if the process stops running it re-launches it... ? Not sure how to do th...
The first solution would be to fix your EXE, so it does not crash. If you can not fix it now, you probably need to add exception handling, so you can catch the exception, and not close the EXE. Second solution is to write simple guard programm that will start your simple .exe and will monitor specific process handle. I...
0.081452
false
1
466
2010-03-10 14:39:52.180
Dynamic resize with MPlayer and PyGTK
I've wrote a piece of code in python and pygtk for an embeded mplayer in a gui. I assume I use GtkSocket and the slave mode of mplayer with the -wid option. But I've got an issue, when the size of my GTK window is smaller than my stream, the stream appears to be cropped. And when the size of my window is bigger than my...
You need to tell mplayer to zoom video according to window size. This can be done either in command line (-zoom) or in the configuration file (zoom = 1).
0.201295
false
1
467
2010-03-10 19:11:28.147
How to get one value at a time from a generator function in Python?
Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?
In python 3 you don't have gen.next(), but you still can use next(gen). A bit bizarre if you ask me but that's how it is.
0.067922
false
4
468
2010-03-10 19:11:28.147
How to get one value at a time from a generator function in Python?
Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?
Yes, or next(gen) in 2.6+.
1.2
true
4
468
2010-03-10 19:11:28.147
How to get one value at a time from a generator function in Python?
Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?
In Python <= 2.5, use gen.next(). This will work for all Python 2.x versions, but not Python 3.x In Python >= 2.6, use next(gen). This is a built in function, and is clearer. It will also work in Python 3. Both of these end up calling a specially named function, next(), which can be overridden by subclassing. In Python...
1
false
4
468
2010-03-10 19:11:28.147
How to get one value at a time from a generator function in Python?
Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?
To get the value associated with a generator object in python 3 and above use next(<your generator object>). subsequent calls to next() produces successive object values in the queue.
0.327599
false
4
468
2010-03-10 20:11:32.920
How does OS handle a python dict that's larger than memory?
I have a python program that is going to eat a lot of memory, primarily in a dict. This dict will be responsible for assigning a unique integer value to a very large set of keys. As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations a...
It will just end up in swap trashing, because a hash table has very much randomized memory access patterns. If you know that the map exceeds the size of the physical memory, you could consider using a data structure on the disk in the first place. This especially if you don't need the data structure during the computat...
1.2
true
2
469
2010-03-10 20:11:32.920
How does OS handle a python dict that's larger than memory?
I have a python program that is going to eat a lot of memory, primarily in a dict. This dict will be responsible for assigning a unique integer value to a very large set of keys. As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations a...
You need a database, if the data will exceed memory. The indexing of dictionaries isn't designed for good performance when a dictionary is bigger than memory.
0.470104
false
2
469
2010-03-12 19:32:49.630
Database: storing data from user registration form
Let's say I have an user registration form. In this form, I have the option for the user to upload a photo. I have an User table and Photo table. My User table has a "PathToPhoto" column. My question is how do I fill in the "PathToPhoto" column if the photo is uploaded and inserted into Photo table before the user i...
To make sure we're on the same page, is the following correct? You're inserting the photo information into the Photo table immediately after the user uploads the photo but before he/she submits the form; When the user submits the form, you're inserting a row into the User table; One of the items in that row is informa...
1.2
true
1
470
2010-03-13 16:22:59.947
how to embed a webpage using wx?
I need to show a webpage (a complex page with script and stuff, no static html) in a frame or something. It's for a desktop application, I'm using python 2.6 + wxPython 2.8.10.1. I need to catch some events too (mostly about changing page). I've found some samples using the webview module in a gtk application, but I co...
You can embed IE, but I think that's about it. wxWebKit is working on a wx add-on to use WebKit as an embedded browser in wx, but I think it's still a work in progress.
0.201295
false
1
471
2010-03-13 23:53:07.370
Compiler options wrong with python setup.py
I'm trying to install matplotlib on my mac setup. I find that setup.py has inaccurate flags, in particular the isysroot points to an earlier SDK. Where does setup.py get its info and how can i fix it? I'm on MacOS 10.5.8, XCode 3.1.2 and Python 2.6 (default config was 2.5)
I'm guessing you've installed 2.6 on 10.5 using the python.org OS X installer. In that case, the flags are accurate and you should not try to change them. The python.org installers are built using the so-called 10.4u SDK and with a deployment target of 10.3, allowing one installer image to work on Mac OS X systems fr...
1.2
true
1
472
2010-03-15 05:04:45.647
How does Python differentiate between the different data types?
Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but h...
Python is dynamically typed: all variables can refer to an object of any type. id and name can be anything, but the actual objects are of types like int and str. 0 is a literal that is parsed to make an int object, and 'John' a literal that makes a str object. Many object types do not have literals and are returned by ...
0.516408
false
3
473
2010-03-15 05:04:45.647
How does Python differentiate between the different data types?
Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but h...
When it comes to assigning literal values to variables, the type of the literal value can be inferred at the time of lexical analysis. For example, anything matching the regular expression (-)?[1-9][0-9]* can be inferred to be an integer literal. If you want to convert it to a float, there needs to be an explicit cas...
0.3154
false
3
473
2010-03-15 05:04:45.647
How does Python differentiate between the different data types?
Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but h...
The literal objects you mention carry (pointers to;-) their own types with them of course, so when a name's bound to that object the problem of type doesn't arise -- the object always has a type, the name doesn't -- just delegates that to the object it's bound to. There's no "figuring out" in def increase(first, second...
1.2
true
3
473
2010-03-15 12:45:02.973
Programming in Python vs. programming in Java
I've been writing Java for the last couple of years , and now I've started to write in python (in addition). The problem is that when I look at my Python code it looks like someone tried to hammer Java code into a python format , and it comes out crappy because - well , python ain't Java. Any tips on how to escape th...
Learn a few other languages. It will help you make the difference between algorithms (the structure of processing, unchanged between languages) and the local syntaxic features of the language. Then you can "write Foo in Bar" for any combination of languages "Foo" and "Bar".
0
false
4
474
2010-03-15 12:45:02.973
Programming in Python vs. programming in Java
I've been writing Java for the last couple of years , and now I've started to write in python (in addition). The problem is that when I look at my Python code it looks like someone tried to hammer Java code into a python format , and it comes out crappy because - well , python ain't Java. Any tips on how to escape th...
Definitely not a panacea but I think you should try some code golf in Python. Obviously nobody should write "golfed" code IRL, but finding the most terse way to express something really forces you to exploit the built in functionality of the language.
0.093914
false
4
474
2010-03-15 12:45:02.973
Programming in Python vs. programming in Java
I've been writing Java for the last couple of years , and now I've started to write in python (in addition). The problem is that when I look at my Python code it looks like someone tried to hammer Java code into a python format , and it comes out crappy because - well , python ain't Java. Any tips on how to escape th...
Eat Python, Sleep Python and Drink Python. That is the only way........
0
false
4
474
2010-03-15 12:45:02.973
Programming in Python vs. programming in Java
I've been writing Java for the last couple of years , and now I've started to write in python (in addition). The problem is that when I look at my Python code it looks like someone tried to hammer Java code into a python format , and it comes out crappy because - well , python ain't Java. Any tips on how to escape th...
Try to find algorithms that you understand well and see how they are implemented in python standard libraries. Persist. :)
0.031387
false
4
474
2010-03-16 06:24:40.327
faking a filesystem / virtual filesystem
I have a web service to which users upload python scripts that are run on a server. Those scripts process files that are on the server and I want them to be able to see only a certain hierarchy of the server's filesystem (best: a temporary folder on which I copy the files I want processed and the scripts). The server w...
You are probably best to use a virtual machine like VirtualBox or VMware (perhaps even creating one per user/session). That will allow you some control over other resources such as memory and network as well as disk The only python that I know of that has such features built in is the one on Google App Engine. That m...
0.386912
false
1
475
2010-03-16 18:11:15.877
Checkboxes with pylons
I have been trying to add some check boxes in a pylons mako. However I don't know how to get their values in the controller. It seems that it can only get the first value of the check boxes. I tried using form encode but i got several errors. Is there an easier way to do this? Thanks
I'm assuming that "I can only get the first value" means you've got a series of checkboxes with the same value for the 'name' attribute within your form? Now, if that's the case and you're wanting a list of boolean values based on whether or not the boxes are checked or not, you'll need to do two things: First, whe...
0
false
1
476
2010-03-17 07:04:19.987
How to stop Python program execution in IDLE
I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back. On other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt...
Ctrl+F6 (Restart shell) or Shell->Restart Shell
0.613357
false
3
477
2010-03-17 07:04:19.987
How to stop Python program execution in IDLE
I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back. On other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt...
I have seen this problem with IDLE and matplotlib when using them on Windows. I don't know the exact cause, but Ctrl-c a couple times has typically worked for me. If that doesn't work for you, you can use the normal interpreter instead of write your plot directly to a file instead of the screen. This is one of those (p...
1.2
true
3
477
2010-03-17 07:04:19.987
How to stop Python program execution in IDLE
I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back. On other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt...
I had same issue in Canopy Python Editor, and I was able to interrupt python session with CTRL+. ("dot" button). Hope that helps, or they probably do things in a similar ways
0.201295
false
3
477
2010-03-17 07:28:03.357
In Python, if I have a unix timestamp, how do I insert that into a MySQL datetime field?
I am using Python MySQLDB, and I want to insert this into DATETIME field in Mysql . How do I do that with cursor.execute?
Solved. I just did this: datetime.datetime.now() ...insert that into the column.
0.135221
false
1
478
2010-03-17 18:09:49.077
How to implement a master/watchdog script in python?
I need it to open 10 processes, and each time one of them finishes I want to wait few seconds and start another one. It seems pretty simple, but somehow I can't get it to work.
I've done this same thing to process web statistics using a semaphore. Essentially, as processes are created, the semaphore is incremented. When they exit, it's decremented. The creation process is blocked when the semaphore blocks. This actually fires off threads, which run external processes down execution path a...
0.201295
false
1
479
2010-03-17 18:59:49.100
Artificial Intelligence in online game using Google App Engine
I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another s...
If the game is turn based then it would probably be best to avoid the Cron task and just update the NPCs every time the player moves. I'm not sure how big of a map you are planning on but you may consider even having the player object find the NPCs that are close to it and call their AI routine. That way NPCs that are...
0.265586
false
3
480
2010-03-17 18:59:49.100
Artificial Intelligence in online game using Google App Engine
I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another s...
Will your game be turn based or real time? Either way, I think you have 2 options to look into. One is to use the Cron feature so you can schedule NPC updates at regular intervals, the other is to stick a "update NPCs" task into the Task Queue every time a human player moves.
1.2
true
3
480
2010-03-17 18:59:49.100
Artificial Intelligence in online game using Google App Engine
I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another s...
Bear in mind that you can also break up your updates into multiple requests (internally): do a bit of work, redirect to the same handler but different state; do more work; etc. (I'm failing somehow to comment on Peter Recore's answer, which is where this really belongs.) I see that the free service only allows 100k ta...
0.265586
false
3
480
2010-03-18 04:55:28.853
Using wget via Python
How would I download files (video) with Python using wget and save them locally? There will be a bunch of files, so how do I know that one file is downloaded so as to automatically start downloding another one? Thanks.
No reason to use python. Avoid writing a shell script in Python and go with something like bash or an equivalent.
-0.386912
false
2
481
2010-03-18 04:55:28.853
Using wget via Python
How would I download files (video) with Python using wget and save them locally? There will be a bunch of files, so how do I know that one file is downloaded so as to automatically start downloding another one? Thanks.
No reason to use os.system. Avoid writing a shell script in Python and go with something like urllib.urlretrieve or an equivalent. Edit... to answer the second part of your question, you can set up a thread pool using the standard library Queue class. Since you're doing a lot of downloading, the GIL shouldn't be a pr...
0.545705
false
2
481
2010-03-18 12:45:02.663
Configuring Pydev Interpreter in Eclipse to use Enthought Python Distribution
I downloaded Pydev plugin for Eclipse (3.5.2) today on Mac OSX 10.5.8. To be able to use Pydev, I need to configure the interpreter in Eclipse. I am not clear what exactly I need to do here, or what this step does. I want to make sure that when I run programs from Eclipse using Pydev, it uses the Enthought Python Distr...
I am running Python 3, so I had to make these changes to get python.exe as my interpreter. File: C:\EasyEclipse-for-LAMP-1.2.2.2\extensions\pydev-1.3.3\eclipse\plugins\org.python.pydev_1.3.3\PySrc\interpreterInfo.py Edit all occurrences of "print ..." to "print(...)" (the ... is whatever is being printed), so wrap it i...
0.058243
false
2
482
2010-03-18 12:45:02.663
Configuring Pydev Interpreter in Eclipse to use Enthought Python Distribution
I downloaded Pydev plugin for Eclipse (3.5.2) today on Mac OSX 10.5.8. To be able to use Pydev, I need to configure the interpreter in Eclipse. I am not clear what exactly I need to do here, or what this step does. I want to make sure that when I run programs from Eclipse using Pydev, it uses the Enthought Python Distr...
Mac OS 10.6.4: Selecting the interpreter as /Library/Frameworks/Python.framework/Versions/2.7/Python did not work. I had to select /Library/Frameworks/Python.framework/Versions/2.7/bin/python
0.604183
false
2
482
2010-03-19 09:45:17.660
Python (Twisted) - reading from fifo and sending read data to multiple protocols
Im trying to write some kind of multi protocol bot (jabber/irc) that would read messages from fifo file (one liners mostly) and then send them to irc channel and jabber contacts. So far, I managed to create two factories to connect to jabber and irc, and they seem to be working. However, I've problem with reading the ...
You can read/write on a file descriptor without blocking the reactor as you do with sockets, by the way doesn't sockets use file descriptors? In your case create a class that implements twisted.internet.interfaces.IReadDescriptor and add to reactor using twisted.internet.interfaces.IReactorFDSet.addReader. For an examp...
0.545705
false
2
483
2010-03-19 09:45:17.660
Python (Twisted) - reading from fifo and sending read data to multiple protocols
Im trying to write some kind of multi protocol bot (jabber/irc) that would read messages from fifo file (one liners mostly) and then send them to irc channel and jabber contacts. So far, I managed to create two factories to connect to jabber and irc, and they seem to be working. However, I've problem with reading the ...
The fifo is the problem. Read from a socket instead. This will fit info the Twisted event-driven model much better. Trying to do things outside the control of the reactor is usually the wrong approach. ---- update based on feedback that the fifo is an external constraint, not avoidable ---- OK, the central issue is tha...
0.201295
false
2
483
2010-03-21 10:41:38.983
Convert python script to binary executable
I wrote a number crunching python code. The calculations involved can take hours. Is it possible somehow to compile it to binary? Thanks
First you can try psyco, that may give you a speed up as much as 10x, but 2x is more typical If you can post the code up somewhere, perhaps someone can point out how to leverage numpy. If your task doesn't map well only numpy then cython is a good choice to convert a intensive function or two into C code just by adding...
0.386912
false
1
484
2010-03-21 12:22:33.713
usb device identification
i am using python on ubuntu 9.04 say i have two usb devices connected to a single PC. how can i identify the devices in python code.....for example like if usb port id == A write data to device 1 if usb port id == B write data to device 2 any ideas....
but whatever.. someone will look for the answer at some point: I'm on a mac (osx 10.9).. I successfully installed libusb with mac ports, but was getting the "no backend available" message. It's because python can't find the usb dylibs. You have to add the path to your libusb to your $DYLD_LIBRARY_PATH (e.g. /opt/loc...
0.101688
false
1
485
2010-03-21 18:17:18.900
Djangobb problem
I've installed Djangobb app on my server (Debian, mod_python) by cloning original source. The only things I've changed is database options in settings.py. All needed components are installed - syncdb query was executed right. But, when I'm trying to enter on my forum, it returns me error: ImproperlyConfigured: Error i...
There are two obvious reasons to why this might happen: djangobb_forum is not on your Python path There is no __init__.py in the djangobb_forum folder If the code says from djangobb_forum import ... then you need to have the parent folder of djangobb_forum on your Python path.
0.673066
false
1
486
2010-03-21 20:55:22.837
python parallel computing: split keyspace to give each node a range to work on
My question is rather complicated for me to explain, as i'm not really good at maths, but i'll try to be as clear as possible. I'm trying to code a cluster in python, which will generate words given a charset (i.e. with lowercase: aaaa, aaab, aaac, ..., zzzz) and make various operations on them. I'm searching how to c...
You should be able to treat your words as numerals in a strange base. For example, let's say you have a..z as your charset (26 characters), 4 character strings, and you want to distribute among equally 10 machines. Then there are a total of 26^4 strings, so each machine gets 26^4/10 strings. The first machine will g...
0.201295
false
1
487
2010-03-21 21:04:25.147
django admin - adding fields on the fly
Basically I am writing a simple shopping cart. Each item can have multiple prices. (i.e. shirts where each size is priced differently). I would like to have a single price field in my admin panel, where when the first price is entered, an additional price field pops up. However I am kind of at a loss as to how to do th...
Sounds like you want two related models - Item and Option. Item would contain the name of the item, and Option would contain the option - eg size - and the price of that option. You would then set up your admin to use an inline form for Option.
0.135221
false
1
488
2010-03-22 11:35:10.763
How to return a value from __init__ in Python?
I have a class with an __init__ function. How can I return an integer value from this function when an object is created? I wrote a program, where __init__ does command line parsing and I need to have some value set. Is it OK set it in global variable and use it in other member functions? If so how to do that? So far,...
__init__ doesn't return anything and should always return None.
0.296905
false
1
489
2010-03-23 18:02:05.370
Display an image as a splash screen when running Windows batch file, vbscript/wscript or Python console script
Any ideas how I can display an image file (bmp or png) centered on the screen as an application splash screen when running a Windows console script based on a batch file, vbscript/wscript or Python console script? I'm not interested in a wxPython solution - that's too much overhead just to implement a cosmetic feature ...
Try TK, it is included with python. Also, PyGtk is lighter than wxPython, but I ended up bitting the bullet and using wxPython for the same purpose recently, it is heavy, but it didn't have any affect on the script performance.
0
false
1
490
2010-03-23 23:27:16.810
Keeping track of changes - Django
I have various models of which I would like to keep track and collect statistical data. The problem is how to store the changes throughout time. I thought of various alternative: Storing a log in a TextField, open it and update it every time the model is saved. Alternatively pickle a list and store it in a TextField. ...
Quoth my elementary chemistry teacher: "If you don't write it down, it didn't happen", therefore save logs in a file. Since the log information is disjoint from your application data (it's meta-data, actually), keep them separate. You could log to a database table but it should be distinct from your model. Text pickle ...
0.135221
false
1
491
2010-03-28 02:44:31.217
Key word extraction in Python
I'm building a website in django that needs to extract key words from short (twitter-like) messages. I've looked at packages like topia.textextract and nltk - but both seem to be overkill for what I need to do. All I need to do is filter words like "and", "or", "not" while keeping nouns and verbs that aren't conjunctiv...
You can make a set sw of the "stop words" you want to eliminate (maybe copy it once and for all from the stop words corpus of NLTK, depending how familiar you are with the various natural languages you need to support), then apply it very simply. E.g., if you have a list of words sent that make up the sentence (shorn o...
1.2
true
2
492
2010-03-28 02:44:31.217
Key word extraction in Python
I'm building a website in django that needs to extract key words from short (twitter-like) messages. I've looked at packages like topia.textextract and nltk - but both seem to be overkill for what I need to do. All I need to do is filter words like "and", "or", "not" while keeping nouns and verbs that aren't conjunctiv...
Abbreviations like NO for navigation officer or OR for operations room need a little care lest you cause a SNAFU ;-) One suspects that better results could be obtained from "Find the NO and send her to the OR" by tagging the words with parts of speech using the context ... hint 1: "the OR" should result in "the [noun]"...
0.201295
false
2
492
2010-03-29 10:02:00.843
Tornado or Django works with CGI?
Tornado is a webserver + framework like Django but for real-time features. On my server I don't have a python module or wsgi module so I thought CGI. Is there a way to get Tornado ( or Django ) works by using CGI folder ? If yes, Could you explain me how do I do that ?
Main feature of Tornado is that it is high performance web-server written in Python, for creating web applications using Python programming language. Running Tornado as CGI application negates the very reason it exists, because running CGI scripts is expensive in terms of performance, and most probably there is no way ...
0.986614
false
1
493
2010-03-29 22:34:20.433
Access to content of Lotus Notes database without Lotus Notes software installed
I am looking for a programatic way to access content in a Lotus Notes database (.nsf file) without having Lotus Notes software installed. Python would be preferred but I'm also willing to look at other languages e.g. C/C++ or other means e.g. SQL From what I have read, all of the methods e.g. Python COM access, pyodbc ...
If this is a one-time need, you may be able to find sites that will do some simple Domino/Notes hosting for free. If you could put the NSF up to a service like that, you could then use Domino URL's (REST) to extract the data and search for links, etc.
0.135221
false
3
494
2010-03-29 22:34:20.433
Access to content of Lotus Notes database without Lotus Notes software installed
I am looking for a programatic way to access content in a Lotus Notes database (.nsf file) without having Lotus Notes software installed. Python would be preferred but I'm also willing to look at other languages e.g. C/C++ or other means e.g. SQL From what I have read, all of the methods e.g. Python COM access, pyodbc ...
Like Ken says, inevitably there has to be a server in the mix. If you're searching for specific text in a Notes / Domino application, and looking to replace it, there's a tool out there which does this: Teamstudio Configurator. Configurator also has an API (written in Lotusscript, which is very like old-skool VB) so yo...
0
false
3
494
2010-03-29 22:34:20.433
Access to content of Lotus Notes database without Lotus Notes software installed
I am looking for a programatic way to access content in a Lotus Notes database (.nsf file) without having Lotus Notes software installed. Python would be preferred but I'm also willing to look at other languages e.g. C/C++ or other means e.g. SQL From what I have read, all of the methods e.g. Python COM access, pyodbc ...
The short answer is, unfortunately you will need the Notes client installed. There are a few ways to access data from an NSF such as NotesSQL, COM, C/C++, but all rely on the Lotus C API at the core, and you'll need a notes client and a notes ID file to gain access via that API.
0.386912
false
3
494
2010-03-31 03:25:08.987
how to write re-usable views in django?
These are the techniques that I use regularly to make my views reusable: take the template_name as an argument with a default take an optional extra_context which defaults to empty {} right before the template is rendered the context is updated with the extra_context for further re-usability, call any callable in ex...
whenever the view needs a particular object from the ORM, it attempts to fetch it using any "id" parameter in several ways (e.g. as a slug, as a database id) (this may be a bad practice...) So... why not just expect a model instance to be passed in as a parameter? Or a QuerySet from which you will take element 0? Th...
0
false
2
495
2010-03-31 03:25:08.987
how to write re-usable views in django?
These are the techniques that I use regularly to make my views reusable: take the template_name as an argument with a default take an optional extra_context which defaults to empty {} right before the template is rendered the context is updated with the extra_context for further re-usability, call any callable in ex...
I would think that doing all of those puts a large burden on your urlconf to get everything right. Perhaps making a function that takes all that and hardcoding your views to be a glorified wrapper around said function would be better.
0
false
2
495
2010-03-31 03:45:21.323
Any way to add my C# project as a reference in IronPython / IronRuby?
I know how to reference an existing .dll to IronPython, but is there any way to add my project as a reference like I can between Visual Studio projects? Or is it best practice to create a separate class library?
You can't add reference to a project since it's a Visual Studio thing. I suggest that during the development process, call import (IronPython) or require (IronRuby) with the full path of your project assembly like c:\dev\MyProject\bin\Debug\MyProject.dll.
1.2
true
1
496
2010-03-31 13:04:51.930
Django newbie question: can't start a new project
I'm totally new to django, and I'm using its documentation to get help on how to use it but seems like something is missing. i installed django using setup.py install command and i added the ( django/bin ) to system path variable but. i still cant start a new project i use the following syntax to start a project : d...
check whether you have djagno or not and the it is in python path or not.if using linux go to terminal type python and then try to import django
0
false
2
497
2010-03-31 13:04:51.930
Django newbie question: can't start a new project
I'm totally new to django, and I'm using its documentation to get help on how to use it but seems like something is missing. i installed django using setup.py install command and i added the ( django/bin ) to system path variable but. i still cant start a new project i use the following syntax to start a project : d...
do you have permission to write to the directory?
0.201295
false
2
497
2010-04-01 15:28:36.947
Configuring Eclipse with wxPython
I've been browsing documentation, but haven't been able to find a straightforward tutorial, so I apologize if this is a really simple question. Anyway, I have eclipse with pydev installed on MAC OSX, and I want configure wxPython to work with eclipse, how do I do this? Once I've downloaded wxpython, what steps do I tak...
Vinay's answer above is correct. However, if code completion is not picking it up, you might need to add the WX directory to the Pydev's interpreter library path. Window | Preferences | Pydev | Interpreter - Python | Libraries If wx is not present, New Folder and select the install directory.
0.740859
false
2
498
2010-04-01 15:28:36.947
Configuring Eclipse with wxPython
I've been browsing documentation, but haven't been able to find a straightforward tutorial, so I apologize if this is a really simple question. Anyway, I have eclipse with pydev installed on MAC OSX, and I want configure wxPython to work with eclipse, how do I do this? Once I've downloaded wxpython, what steps do I tak...
wxPython install by default to the following path /usr/local/lib/wxPython-2.9.4.0 When adding a path to the Interpreter libraries section in the eclipse preferences add this path: /usr/local/lib/wxPython-2.9.4.0/lib/python2.7/site-packages/wx-2.9.4-osx_cocoa
0.386912
false
2
498
2010-04-01 21:22:13.423
Making Noise with Python
I am trying to get python to make noise when certain things happen. Preferably, i would like to play music of some kind, however some kind of distinctive beeping would be sufficient, like an electronic timer going off. I have thus far only been able to make the system speaker chime using pywin32's Beep, however this si...
PyAudiere turns out to be the most convenient. It allows me to simply play an MP3, rather than generate the sound on the fly.
1.2
true
1
499
2010-04-02 08:43:06.697
How use the google maps hand cursor in Python?
I want to use the google maps hand cursor in Python but I don't know how to do it. I've downloaded the cursor but I only get to use the hand open, I also have a event that "closes" the hand when clicked but I don't know how can I change the style cursor on it. I say this because the google maps hand cursor has two styl...
Use two cursors and change them on events as they need to be.
1.2
true
1
500
2010-04-02 22:21:14.077
How to generate a mixed-case hash in Python?
I am having a hard time figuring out a reasonable way to generate a mixed-case hash in Python. I want to generate something like: aZeEe9E Right now I'm using MD5, which doesn't generate case-sensitive hashes. Do any of you know how to generate a hash value consisting of upper- and lower- case characters + numbers? - Ok...
you can base64 encode the output of the hash. This has a couple of additional characters beyond those you mentioned.
1.2
true
1
501
2010-04-03 04:03:39.587
How to convert tag-and-username-like text into proper links in a twitter message?
I'm writing a twitter-like note-taking web app. In a page the latest 20 notes of the user will be listed, and when the user scroll to the bottom of the browser window more items will be loaded and rendered. The initial 20 notes are part of the generated html of my django template, but the other dynamically loaded item...
I'm not sure exactly what you're asking, but what's wrong with something like {{ user.get_absolute_url }}? For the tag detail URLs, it really depends on what you're looking for, but you would have to construct the url and view for that yourself.
0
false
1
502
2010-04-04 00:28:33.830
Python progression path - From apprentice to guru
I've been learning, working, and playing with Python for a year and a half now. As a biologist slowly making the turn to bio-informatics, this language has been at the very core of all the major contributions I have made in the lab. I more or less fell in love with the way Python permits me to express beautiful solutio...
Not precisely what you're asking for, but I think it's good advice. Learn another language, doesn't matter too much which. Each language has it's own ideas and conventions that you can learn from. Learn about the differences in the languages and more importantly why they're different. Try a purely functional languag...
0.042938
false
5
503
2010-04-04 00:28:33.830
Python progression path - From apprentice to guru
I've been learning, working, and playing with Python for a year and a half now. As a biologist slowly making the turn to bio-informatics, this language has been at the very core of all the major contributions I have made in the lab. I more or less fell in love with the way Python permits me to express beautiful solutio...
Thoroughly Understand All Data Types and Structures For every type and structure, write a series of demo programs that exercise every aspect of the type or data structure. If you do this, it might be worthwhile to blog notes on each one... it might be useful to lots of people!
0.252225
false
5
503
2010-04-04 00:28:33.830
Python progression path - From apprentice to guru
I've been learning, working, and playing with Python for a year and a half now. As a biologist slowly making the turn to bio-informatics, this language has been at the very core of all the major contributions I have made in the lab. I more or less fell in love with the way Python permits me to express beautiful solutio...
If you're in and using python for science (which it seems you are) part of that will be learning and understanding scientific libraries, for me these would be numpy scipy matplotlib mayavi/mlab chaco Cython knowing how to use the right libraries and vectorize your code is essential for scientific computing. I wante...
0.474277
false
5
503
2010-04-04 00:28:33.830
Python progression path - From apprentice to guru
I've been learning, working, and playing with Python for a year and a half now. As a biologist slowly making the turn to bio-informatics, this language has been at the very core of all the major contributions I have made in the lab. I more or less fell in love with the way Python permits me to express beautiful solutio...
Teaching to someone else who is starting to learn Python is always a great way to get your ideas clear and sometimes, I usually get a lot of neat questions from students that have me to re-think conceptual things about Python.
0.064358
false
5
503