Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
342,729
2008-12-05T02:20:00.000
7
0
1
0
python,winapi
343,804
12
false
0
0
Avoid tutorials (written by kids, for kids, newbie level) Read the Petzold, Richter, Pietrek, Russinovich and Adv. Win32 api newsgroup news://comp.os.ms-windows.programmer.win32
3
23
0
I have very little experience building software for Windows, and zero experience using the Windows API, but I'm reasonably familiar with Python. How should I go about learning to use the Windows API with Python?
How should I learn to use the Windows API with Python?
1
0
0
54,742
342,729
2008-12-05T02:20:00.000
2
0
1
0
python,winapi
343,020
12
false
0
0
Since you've asked about Python, why do you need the Win32 API ? That's used for writing small, fast C/C++ programs. If your tool is Python, just download wxPython which runs wonderfully on Windows and produces sleek native GUIs with 1% the code and the effort.
3
23
0
I have very little experience building software for Windows, and zero experience using the Windows API, but I'm reasonably familiar with Python. How should I go about learning to use the Windows API with Python?
How should I learn to use the Windows API with Python?
0.033321
0
0
54,742
342,729
2008-12-05T02:20:00.000
3
0
1
0
python,winapi
342,831
12
false
0
0
Learning Win32 API is 5% of initial understanding of concepts and the patterns used and 95% of RTFM. For those initial 5% the Petzold book is really good but I suspect that there ought to be some online tutorials which you can find in google as good as I can to find. Really, once you get the hang of it it's really straight forward do to be able to do anything. Once you get there it would probably be time to move on to something better like QT and never touch Win32 API ever again. Nowadays no one really uses bare Win32 API for anything more than trivial due to the sheer overhead it involves and the extreme lack of comfort.
3
23
0
I have very little experience building software for Windows, and zero experience using the Windows API, but I'm reasonably familiar with Python. How should I go about learning to use the Windows API with Python?
How should I learn to use the Windows API with Python?
0.049958
0
0
54,742
343,622
2008-12-05T12:02:00.000
2
0
0
0
python,django,testing,parsing,form-submit
343,794
4
false
1
0
It is simple... and hard at the same time. Disclaimer: I don't know much about Python and nothing at all about Django... So I give general, language agnostic advices... If one of the above advices doesn't work for you, you might want to do it manually: Load the page with an HTML parser, list the forms. If the method attribute is POST (case insensitive), get the action attribute to get the URL of the request (can be relative). In the form, get all input and select tags. The name (or id if no name) attributes are the keys of the request parameters. The value attributes (empty if absent) are the corresponding values. For select, the value is the one of the selected option or the displayed text is no value attribute. These names and values must be URL encoded in GET requests, but not in POST ones. HTH.
1
0
0
I would like to be able to submit a form in an HTML source (string). In other words I need at least the ability to generate POST parameters from a string containing HTML source of the form. This is needed in unit tests for a Django project. I would like a solution that possibly; Uses only standard Python library and Django. Allows parameter generation from a specific form if there is more than one form present. Allows me to change the values before submission. A solution that returns a (Django) form instance from a given form class is best. Because it would allow me to use validation. Ideally it would consume the source (which is a string), a form class, and optionally a form name and return the instance as it was before rendering. NOTE: I am aware this is not an easy task, and probably the gains would hardly justify the effort needed. But I am just curious about how this can be done, in a practical and reliable way. If possible.
How do I submit a form given only the HTML source?
0.099668
0
0
941
343,769
2008-12-05T13:08:00.000
3
0
0
0
python,wiki,moinmoin
343,926
3
true
1
0
check out the interwiki page in moinmoin, (most wikis have them) we use trac for example and you can set up different link paths to point to your different web resources. So in our Trac you can go [[SSGWiki:Some Topic]] and it will point to another internal wiki.
1
2
0
We use a number of diffrent web services in our company, wiki(moinmoin), bugtracker (internally), requestracker (customer connection), subversion. Is there a way to parse the wikipages so that if I write "... in Bug1234 you could ..." Bug1234 woud be renderd as a link to http://mybugtracker/bug1234
How to use InterWiki links in moinmoin?
1.2
0
1
714
344,559
2008-12-05T17:15:00.000
1
1
0
0
python,xml,performance,large-files,expat-parser
344,641
4
false
0
0
If you know that the XML files are generated using the ever-same algorithm, it might be more efficient to not do any XML parsing at all. E.g. if you know that the data is in lines 3, 4, and 5, you might read through the file line-by-line, and then use regular expressions. Of course, that approach would fail if the files are not machine-generated, or originate from different generators, or if the generator changes over time. However, I'm optimistic that it would be more efficient. Whether or not you recycle the parser objects is largely irrelevant. Many more objects will get created, so a single parser object doesn't really count much.
3
3
0
I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields. I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract the data. Is there a more efficient way? (simple text matching doesn't work) Do I need to issue a new ParserCreate() for each new file (or string) or can I reuse the same one for every file? Any caveats? Thanks!
What is the most efficient way of extracting information from a large number of xml files in python?
0.049958
0
1
572
344,559
2008-12-05T17:15:00.000
1
1
0
0
python,xml,performance,large-files,expat-parser
345,650
4
false
0
0
One thing you didn't indicate is whether or not you're reading the XML into a DOM of some kind. I'm guessing that you're probably not, but on the off chance you are, don't. Use xml.sax instead. Using SAX instead of DOM will get you a significant performance boost.
3
3
0
I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields. I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract the data. Is there a more efficient way? (simple text matching doesn't work) Do I need to issue a new ParserCreate() for each new file (or string) or can I reuse the same one for every file? Any caveats? Thanks!
What is the most efficient way of extracting information from a large number of xml files in python?
0.049958
0
1
572
344,559
2008-12-05T17:15:00.000
3
1
0
0
python,xml,performance,large-files,expat-parser
344,694
4
true
0
0
The quickest way would be to match strings (with, e.g., regular expressions) instead of parsing XML - depending on your XMLs this could actually work. But the most important thing is this: instead of thinking through several options, just implement them and time them on a small set. This will take roughly the same amount of time, and will give you real numbers do drive you forward. EDIT: Are the files on a local drive or network drive? Network I/O will kill you here. The problem parallelizes trivially - you can split the work among several computers (or several processes on a multicore computer).
3
3
0
I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields. I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract the data. Is there a more efficient way? (simple text matching doesn't work) Do I need to issue a new ParserCreate() for each new file (or string) or can I reuse the same one for every file? Any caveats? Thanks!
What is the most efficient way of extracting information from a large number of xml files in python?
1.2
0
1
572
344,753
2008-12-05T18:34:00.000
1
0
1
0
python,django,image,python-imaging-library
344,805
2
true
1
0
The error above happens because your file is called Image.py and you're trying to import yourself. As Manual pointed out, you should import Image from the PIL module, but you'd also need to rename your file so it's not called Image.py.
1
0
0
i am trying to do something with the PIL Image library in django, but i experience some problems. I do like this: import Image And then I do like this images = map(Image.open, glob.glob(os.path.join(dirpath, '*.thumb.jpg'))) But when i try to run this i get an error and it leeds me to think that its not imported correctly, anybody know? type object 'Image' has no attribute 'open'
Having problem importing the PIL image library
1.2
0
0
2,719
345,255
2008-12-05T21:41:00.000
14
0
1
0
python,python-3.x
345,269
7
false
0
0
Go with 2.6 since that's what most libraries(pygame, wxpython, django, etc) target. The differences in 3.0 aren't that huge, so transitioning to it later shouldn't be much of a problem.
7
5
0
I am extremely new to python, having started to learn it less than a month ago, but experienced with some other programming languages (primarily C# and SQL). But now that Python 3.0 has been released and is not backwards compatible, what would be the advantages and disadvantages of deciding to focus on Python 3.0 or Python 2.6?
Python Version for a Newbie
1
0
0
1,088
345,255
2008-12-05T21:41:00.000
1
0
1
0
python,python-3.x
346,438
7
false
0
0
If you're looking at it from a getting-a-job perspective, I'd definitely at least learn 2.x as well. The code I work on is still targeting python 2.4 and to the best of my knowledge there is no plans to move to even 2.6, let alone 3.0 in the near future. There will be a ton of 2.x python code floating around for years to come and the vast majority of python jobs will involve working with that code. So I'd start by learning python 2.6 while the whole time keeping an eye on 3.0 so that you are at least aware of what bits of your 2.x code won't work in 3.0
7
5
0
I am extremely new to python, having started to learn it less than a month ago, but experienced with some other programming languages (primarily C# and SQL). But now that Python 3.0 has been released and is not backwards compatible, what would be the advantages and disadvantages of deciding to focus on Python 3.0 or Python 2.6?
Python Version for a Newbie
0.028564
0
0
1,088
345,255
2008-12-05T21:41:00.000
2
0
1
0
python,python-3.x
346,278
7
false
0
0
It depends on what you are willing to do. Python 3.0 is the newer release, and with time should become the standard. However, it has almost no libraries or frameworks available, and even the tools are not so up to date (e.g. the Eclipse plug-in for Python is still in the migration phase). On the other hand, there are no huge differences, and once you learn one, moving to the other is quite easy. So, if you plan just to play around, you can go with 3.0. If you plan to use it on a new project, I would stick on an older release.
7
5
0
I am extremely new to python, having started to learn it less than a month ago, but experienced with some other programming languages (primarily C# and SQL). But now that Python 3.0 has been released and is not backwards compatible, what would be the advantages and disadvantages of deciding to focus on Python 3.0 or Python 2.6?
Python Version for a Newbie
0.057081
0
0
1,088
345,255
2008-12-05T21:41:00.000
3
0
1
0
python,python-3.x
345,917
7
false
0
0
Start with 2.6, and when you get a bit more proficient with the language (few thousands of lines of code written), transitioning to 3.0 will be easy and natural. While learning I suggest you ignore classic classes, and pay special attention to iterators, generators, and list comprehension.
7
5
0
I am extremely new to python, having started to learn it less than a month ago, but experienced with some other programming languages (primarily C# and SQL). But now that Python 3.0 has been released and is not backwards compatible, what would be the advantages and disadvantages of deciding to focus on Python 3.0 or Python 2.6?
Python Version for a Newbie
0.085505
0
0
1,088
345,255
2008-12-05T21:41:00.000
6
0
1
0
python,python-3.x
345,263
7
false
0
0
Since they have incompatibilities, I suggest you start going for Python 3.0 which is more useful in the future anyway. It's a better language. You can see the precise differences in What's new page on its Web site.
7
5
0
I am extremely new to python, having started to learn it less than a month ago, but experienced with some other programming languages (primarily C# and SQL). But now that Python 3.0 has been released and is not backwards compatible, what would be the advantages and disadvantages of deciding to focus on Python 3.0 or Python 2.6?
Python Version for a Newbie
1
0
0
1,088
345,255
2008-12-05T21:41:00.000
5
0
1
0
python,python-3.x
345,288
7
true
0
0
I would say begin with 2.6 since the vast, vast majority of documentation regarding Python will be applicable to 2.6 as well most open source projects you may want to contribute to will be in 2.6 for awhile. Then, once you have a good foundation in 2.6, you can learn 3.0. That way you can kind of appreciate how the language has evolved and where the "aesthetic" of the code comes from.
7
5
0
I am extremely new to python, having started to learn it less than a month ago, but experienced with some other programming languages (primarily C# and SQL). But now that Python 3.0 has been released and is not backwards compatible, what would be the advantages and disadvantages of deciding to focus on Python 3.0 or Python 2.6?
Python Version for a Newbie
1.2
0
0
1,088
345,255
2008-12-05T21:41:00.000
1
0
1
0
python,python-3.x
345,304
7
false
0
0
Be careful though. Libraries such as the mysql driver are still in 2.5
7
5
0
I am extremely new to python, having started to learn it less than a month ago, but experienced with some other programming languages (primarily C# and SQL). But now that Python 3.0 has been released and is not backwards compatible, what would be the advantages and disadvantages of deciding to focus on Python 3.0 or Python 2.6?
Python Version for a Newbie
0.028564
0
0
1,088
345,356
2008-12-05T22:14:00.000
10
0
1
0
python,python-3.x
345,502
2
false
0
0
All these are syntax/grammar changes. Such changes are traditionally introduced first in a Python x.y version with a from __future__ import … statement, and implemented at least on Python x.(y+1) version. Such a transition hasn't happened yet for these changes. Technically, I've answered your "why". Now, if you meant, “why didn't anyone take the time to suggest, support and implement something that I would like to have in 2.x also, even if they don't know about it since I never tried to suggest/support backporting those syntax enhancements in either comp.lang.python or Python-Dev and I never tried to even read the PEPs?”, then the answer lies in you too, and you can offer an answer yourself. HTH BTW, you shouldn't use the dict([(k,v) for k,v in d]) form, but the dict((k,v) for k,v in d). More efficient. Why create an intermediate list?
1
14
0
Python 2.6 was basically a stepping stone to make converting to Python 3 easier. A lot of the features destined for Python 3 were implemented in 2.6 if they didn't break backward compatibility with syntax and the class libs. Why weren't set literals ({1, 2, 3}), set comprehensions ({v for v in l}), or dict comprehensions ({k: v for k, v in d}) among them? In particular dict comprehensions would have been a great boon... I find myself using the considerably uglier dict([(k, v) for k, v in d]) an awful lot lately. Is there something obvious I'm missing, or was this just a feature that didn't make the cut?
Why doesn't Python 2.6 have set literals and comprehensions or dict comprehensions?
1
0
0
4,263
345,991
2008-12-06T05:59:00.000
2
0
0
0
python,logging,opengl,wxpython,pyopengl
369,184
3
false
0
1
After adding the Logging above, I was able to see that the problem was caused by missing TConstants class, which I was excluding in the py2exe setup.py file. After removing the "Tconstants" from the excluded list, I no longer had problems.
1
80
0
Okay, what is it, and why does it occur on Win2003 server, but not on WinXP. It doesn't seem to affect my application at all, but I get this error message when I close the application. And it's annoying (as errors messages should be). I am using pyOpenGl and wxPython to do the graphics stuff. Unfortunately, I'm a C# programmer that has taken over this Python app, and I had to learn Python to do it. I can supply code and version numbers etc, but I'm still learning the technical stuff, so any help would be appreciated. Python 2.5, wxPython and pyOpenGL
Python - No handlers could be found for logger "OpenGL.error"
0.132549
0
0
91,403
346,230
2008-12-06T12:41:00.000
77
0
1
0
python,file,urllib2
346,237
3
true
0
0
You can use Python in interactive mode to search for solutions. if f is your object, you can enter dir(f) to see all methods and attributes. There's one called read. Enter help(f.read) and it tells you that f.read() is the way to retrieve a string from an file object.
1
31
0
I'm using urllib2 to read in a page. I need to do a quick regex on the source and pull out a few variables but urllib2 presents as a file object rather than a string. I'm new to python so I'm struggling to see how I use a file object to do this. Is there a quick way to convert this into a string?
Read file object as string in python
1.2
0
1
48,579
346,823
2008-12-06T21:40:00.000
0
0
0
0
python,algorithm,math
346,873
5
false
0
0
Using deltaX if deltax between 2 and 10 half increment if deltax between 10 and 20 unit increment if smaller than 2 we multiply by 10 and test again if larger than 20 we divide Then we get the position of the first unit or half increment on the width using xmin. I still need to test this solution.
1
2
1
I am trying to figure out the following problem. I am building Yet another math function grapher, The function is drawn on its predefined x,y range, that's all good. Now I am working on the background and the ticking of X, Y axes (if any axes are shown). I worked out the following. I have a fixed width of 250 p The tick gap should be between 12.5 and 50p. The ticks should indicate either unit or half unit range, by that i mean the following. x range (-5, 5): one tick = 1 x range (-1, 1): one tick = 0.5 or 0.1 depending on the gap that each of this option would generate. x range (0.1, 0.3): 0.05 Given a Xrange How would you get the number of ticks between either full or half unit range ? Or maybe there are other way to approach this type of problems.
Ticking function grapher
0
0
0
239
347,054
2008-12-07T00:49:00.000
7
0
0
1
php,asp.net,python,linux
347,065
9
true
0
0
You will only have a first language for a little while. Pick any direction that interests you, and follow it. There is no way around the introduction "Drink from the Firehose" experience. Keep early project simple, and tangible. Build useful things and the motivation will be there. Web / desktop / mobile / etc, its all good. Find the one that gets you thinking about code when your not coding, and you'll know your going in the right direction.
7
3
0
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
1.2
0
0
775
347,054
2008-12-07T00:49:00.000
0
0
0
1
php,asp.net,python,linux
347,353
9
false
0
0
I had the same issue for a little while myself. I was getting bored of just being in PHP and wanted to be able to do more. I ended up settling on C# since it not only fulfilled the 'necessary evil' argument, but allows me to do anything I want in the MS realm, and is the closest syntax wise to another language (Java). Thinking about all the different types of projects this opened me up to made me choose this direction. Both languages can be used for web development, mobile devices, and desktop applications.
7
3
0
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
0
0
0
775
347,054
2008-12-07T00:49:00.000
0
0
0
1
php,asp.net,python,linux
347,348
9
false
0
0
Really all you need to do is make sure you take baby steps and are doing something you are enjoying. I started off programming in visual basic on a little game. Not the best language, but it was a good starting point for me at the time. My point is, you don't need to pick the best language/operating system/anything from the start, just iterate. It is the programming way. By the way, just because you use windows as your OS doesn't mean you have to do everything .NET I use windows and then have a server for all my web hosting that I SSH into.
7
3
0
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
0
0
0
775
347,054
2008-12-07T00:49:00.000
0
0
0
1
php,asp.net,python,linux
347,120
9
false
0
0
I find some of my junior colleagues (atleast the ones that are very passionate about CS) asking similar questions (sometimes I find myself asking this too, even though I am now 12+ yrs into the industry). One advice I give them (and to myself too), which helped me, is - Focus on the job that is already assigned to you. As part of that task, make sure you dont just "get the job done", but also make sure that you understand the fundamentals behind the same. If you want to be a good programmer, you need to understand the underlying principles of "how things work". Using an API to do matrix multiplication is easy, but if you dont really know what is matrix multiplication and how to do it by hand, you are actually losing out. So in your chosen web programming domain, make sure you go beyond the surface. Understand what is really happening behind your back, when you click that button. As part of "doing the job" you typically can figure out what is your interest area. If you are more passionate about how things are implemented, and keep figuring it out, then you are, IMO, a systems guy. If you are more passionate about finding out all the new tools and the newer features and seem to be keen in putting things together to create newer and cooler outputs, then you are an application programmer. Both are interesting areas in their own ways and as people adviced above, realize what you like and see if you can stick with it. And I like one of the advices above. If you are still confused, try doing this "rotation" thingie. There are lots of scope in just about every domain/field and so keep rotating (but give each rotation due time), until you find what you like. All the best. :-)
7
3
0
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
0
0
0
775
347,054
2008-12-07T00:49:00.000
2
0
0
1
php,asp.net,python,linux
347,066
9
false
0
0
The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. This is exactly the course to follow. I think most of us get into programming the same way. Find a problem and work out its solution in whatever technology is appropriate. Keep looking for problems that are interesting to you, and you'll find your own answer (which is probably different than my own answer) to this question.
7
3
0
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
0.044415
0
0
775
347,054
2008-12-07T00:49:00.000
0
0
0
1
php,asp.net,python,linux
347,121
9
false
0
0
Thanks for the thoughtful responses That seemed to be another distraction from learning programming for me anyway. I spent more time chasing apparent fixes for upgraded packages and such. Mostly things that were already working and it just seemed to not make much sense to spend time recreating the wheel so to speak. Believe me the jury is still out for ma as to whether it makes good sense to chase the dream of Linux as a real alternative to a usable desktop. Now remember ex-Windows users will always have to compare their experience with Linux to how they were previously able to work before trying Windows. Just my two cents
7
3
0
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
0
0
0
775
347,054
2008-12-07T00:49:00.000
0
0
0
1
php,asp.net,python,linux
347,076
9
false
0
0
Don't worry so much about the direction you're going, just make sure that: a) You are enjoying it, and are understanding what you are doing. You don't have to initially understand concepts like polymorphism for example, but you should be understanding the basics of what you are doing. Just can't wrap your mind around Tuples and Dictionaries in Python after awhile? Then it's probably not for you. Of course, that's a very low level example as if you don't get Dictionaries, then there's a problem in general :-) b) You are working on things that you want to solve, not just because you think you NEED to learn this. You used the phrase "Windows is a necessary evil" No, it isn't. Many companies (big and small) do not use the .NET platform for development. Your approach to Linux was interesting as you could not achieve something you wanted on it and your result was "it's clunky" which seems kind of awkward. Either way, this isn't about Linux vs. Windows, but I hope that helps. Just go with the flow, and don't worry about what way you're going as long as you're enjoying and learning! :)
7
3
0
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
0
0
0
775
347,812
2008-12-07T17:41:00.000
8
0
0
0
python,django,caching,django-cache
348,079
4
false
1
0
Mock the view, hit the page, and see if the mock was called. if it was not, the cache was used instead.
2
17
0
Is there a way to be sure that a page is coming from cache on a production server and on the development server as well? The solution shouldn't involve caching middleware because not every project uses them. Though the solution itself might be a middleware. Just checking if the data is stale is not a very safe testing method IMO.
How to test django caching?
1
0
0
7,621
347,812
2008-12-07T17:41:00.000
2
0
0
0
python,django,caching,django-cache
348,192
4
false
1
0
The reason you use caches is to improve performance. Test the performance by running a load test against your server. If the server's performance matches your needs, then you are all set!
2
17
0
Is there a way to be sure that a page is coming from cache on a production server and on the development server as well? The solution shouldn't involve caching middleware because not every project uses them. Though the solution itself might be a middleware. Just checking if the data is stale is not a very safe testing method IMO.
How to test django caching?
0.099668
0
0
7,621
348,392
2008-12-08T00:12:00.000
2
1
0
0
python,email
348,579
9
false
0
0
Depending on the amount of mail you are sending you might want to look into using a real mail server like postifx or sendmail (*nix systems) Both of those programs have the ability to send a received mail to a program based on the email address.
4
43
0
How can I receive and send email in python? A 'mail server' of sorts. I am looking into making an app that listens to see if it receives an email addressed to [email protected], and sends an email to the sender. Now, am I able to do this all in python, would it be best to use 3rd party libraries?
Receive and send emails in python
0.044415
0
1
51,409
348,392
2008-12-08T00:12:00.000
4
1
0
0
python,email
348,403
9
false
0
0
poplib and smtplib will be your friends when developing your app.
4
43
0
How can I receive and send email in python? A 'mail server' of sorts. I am looking into making an app that listens to see if it receives an email addressed to [email protected], and sends an email to the sender. Now, am I able to do this all in python, would it be best to use 3rd party libraries?
Receive and send emails in python
0.088656
0
1
51,409
348,392
2008-12-08T00:12:00.000
12
1
0
0
python,email
349,352
9
false
0
0
I do not think it would be a good idea to write a real mail server in Python. This is certainly possible (see mcrute's and Manuel Ceron's posts to have details) but it is a lot of work when you think of everything that a real mail server must handle (queuing, retransmission, dealing with spam, etc). You should explain in more detail what you need. If you just want to react to incoming email, I would suggest to configure the mail server to call a program when it receives the email. This program could do what it wants (updating a database, creating a file, talking to another Python program). To call an arbitrary program from the mail server, you have several choices: For sendmail and Postfix, a ~/.forward containing "|/path/to/program" If you use procmail, a recipe action of |path/to/program And certainly many others
4
43
0
How can I receive and send email in python? A 'mail server' of sorts. I am looking into making an app that listens to see if it receives an email addressed to [email protected], and sends an email to the sender. Now, am I able to do this all in python, would it be best to use 3rd party libraries?
Receive and send emails in python
1
0
1
51,409
348,392
2008-12-08T00:12:00.000
7
1
0
0
python,email
348,423
9
false
0
0
Python has an SMTPD module that will be helpful to you for writing a server. You'll probably also want the SMTP module to do the re-send. Both modules are in the standard library at least since version 2.3.
4
43
0
How can I receive and send email in python? A 'mail server' of sorts. I am looking into making an app that listens to see if it receives an email addressed to [email protected], and sends an email to the sender. Now, am I able to do this all in python, would it be best to use 3rd party libraries?
Receive and send emails in python
1
0
1
51,409
348,999
2008-12-08T09:33:00.000
5
0
0
0
python,mime-types
349,020
3
true
0
0
On my system (Debian lenny) its in /usr/lib/python2.5/mimetypes.py in the list knownfiles you can supply your own files for the init() function.
3
7
0
On my Centos server Python's mimetypes.guess_type("mobile.3gp") returns (None, None), instead of ('video/3gpp', None). Where does Python get the list of mimetypes from, and is it possible to add a missing type to the list?
Adding a mimetype in python
1.2
0
0
3,062
348,999
2008-12-08T09:33:00.000
0
0
0
0
python,mime-types
43,311,856
3
false
0
0
In python 3.6 find that file: C:\Users\Me\AppData\Local\Programs\Python\Python36\Lib\mimetypes.py Search for mp3 (to get the list of extension). Add your file (it's intuitive)
3
7
0
On my Centos server Python's mimetypes.guess_type("mobile.3gp") returns (None, None), instead of ('video/3gpp', None). Where does Python get the list of mimetypes from, and is it possible to add a missing type to the list?
Adding a mimetype in python
0
0
0
3,062
348,999
2008-12-08T09:33:00.000
2
0
0
0
python,mime-types
349,024
3
false
0
0
The mimetypes module uses mime.types files as they are common on Linux/Unix systems. If you look in mimetypes.knownfiles you will find a list of files that Python tries to access to load the data. You can also specify your own file to add new types by adding it to that list.
3
7
0
On my Centos server Python's mimetypes.guess_type("mobile.3gp") returns (None, None), instead of ('video/3gpp', None). Where does Python get the list of mimetypes from, and is it possible to add a missing type to the list?
Adding a mimetype in python
0.132549
0
0
3,062
351,656
2008-12-09T02:57:00.000
10
1
0
0
python,testing,imap,mocking
351,675
4
true
0
0
I found it quite easy to write an IMAP server in twisted last time I tried. It comes with support for writing IMAP servers and you have a huge amount of flexibility.
3
11
0
I'm curious to know if there is an easy way to mock an IMAP server (a la the imaplib module) in Python, without doing a lot of work. Is there a pre-existing solution? Ideally I could connect to the existing IMAP server, do a dump, and have the mock server run off the real mailbox/email structure. Some background into the laziness: I have a nasty feeling that this small script I'm writing will grow over time and would like to create a proper testing environment, but given that it might not grow over time, I don't want to do much work to get the mock server running.
How do I mock an IMAP server in Python, despite extreme laziness?
1.2
0
0
4,288
351,656
2008-12-09T02:57:00.000
7
1
0
0
python,testing,imap,mocking
353,175
4
false
0
0
How much of it do you really need for any one test? If you start to build something on the order of complexity of a real server so that you can use it on all your tests, you've already gone wrong. Just mock the bits any one tests needs. Don't bother trying so hard to share a mock implementation. They're not supposed to be assets, but discardable bits-n-pieces.
3
11
0
I'm curious to know if there is an easy way to mock an IMAP server (a la the imaplib module) in Python, without doing a lot of work. Is there a pre-existing solution? Ideally I could connect to the existing IMAP server, do a dump, and have the mock server run off the real mailbox/email structure. Some background into the laziness: I have a nasty feeling that this small script I'm writing will grow over time and would like to create a proper testing environment, but given that it might not grow over time, I don't want to do much work to get the mock server running.
How do I mock an IMAP server in Python, despite extreme laziness?
1
0
0
4,288
351,656
2008-12-09T02:57:00.000
1
1
0
0
python,testing,imap,mocking
352,194
4
false
0
0
I never tried but, if I had to, I would start with the existing SMTP server.
3
11
0
I'm curious to know if there is an easy way to mock an IMAP server (a la the imaplib module) in Python, without doing a lot of work. Is there a pre-existing solution? Ideally I could connect to the existing IMAP server, do a dump, and have the mock server run off the real mailbox/email structure. Some background into the laziness: I have a nasty feeling that this small script I'm writing will grow over time and would like to create a proper testing environment, but given that it might not grow over time, I don't want to do much work to get the mock server running.
How do I mock an IMAP server in Python, despite extreme laziness?
0.049958
0
0
4,288
352,340
2008-12-09T10:34:00.000
2
0
0
0
python,file,mime-types,download
352,385
3
false
1
0
You can either pass back a reference to the file itself i.e. the full path to the file. Then you can open the file or otherwise manipulate it. Or, the more normal case is to pass back the file handle, and, use the standard read/write operations on the file handle. It is not recommended to pass the actual data as files can be arbiterally large and the program could run out of memory. In your case, you probably want to return a tuple containing the open file handle, the file name and any other meta data you are interested in.
1
1
0
Edit: How to return/serve a file from a python controller (back end) over a web server, with the file_name? as suggested by @JV
Return file from python module
0.132549
0
1
14,590
352,670
2008-12-09T13:15:00.000
4
0
0
0
python,algorithm,random,random-sample
9,827,070
9
false
0
0
The following is a description of random weighted selection of an element of a set (or multiset, if repeats are allowed), both with and without replacement in O(n) space and O(log n) time. It consists of implementing a binary search tree, sorted by the elements to be selected, where each node of the tree contains: the element itself (element) the un-normalized weight of the element (elementweight), and the sum of all the un-normalized weights of the left-child node and all of its children (leftbranchweight). the sum of all the un-normalized weights of the right-child node and all of its chilren (rightbranchweight). Then we randomly select an element from the BST by descending down the tree. A rough description of the algorithm follows. The algorithm is given a node of the tree. Then the values of leftbranchweight, rightbranchweight, and elementweight of node is summed, and the weights are divided by this sum, resulting in the values leftbranchprobability, rightbranchprobability, and elementprobability, respectively. Then a random number between 0 and 1 (randomnumber) is obtained. if the number is less than elementprobability, remove the element from the BST as normal, updating leftbranchweight and rightbranchweight of all the necessary nodes, and return the element. else if the number is less than (elementprobability + leftbranchweight) recurse on leftchild (run the algorithm using leftchild as node) else recurse on rightchild When we finally find, using these weights, which element is to be returned, we either simply return it (with replacement) or we remove it and update relevant weights in the tree (without replacement). DISCLAIMER: The algorithm is rough, and a treatise on the proper implementation of a BST is not attempted here; rather, it is hoped that this answer will help those who really need fast weighted selection without replacement (like I do).
2
52
1
Recently I needed to do weighted random selection of elements from a list, both with and without replacement. While there are well known and good algorithms for unweighted selection, and some for weighted selection without replacement (such as modifications of the resevoir algorithm), I couldn't find any good algorithms for weighted selection with replacement. I also wanted to avoid the resevoir method, as I was selecting a significant fraction of the list, which is small enough to hold in memory. Does anyone have any suggestions on the best approach in this situation? I have my own solutions, but I'm hoping to find something more efficient, simpler, or both.
Weighted random selection with and without replacement
0.088656
0
0
32,149
352,670
2008-12-09T13:15:00.000
1
0
0
0
python,algorithm,random,random-sample
66,553,611
9
false
0
0
This is an old question for which numpy now offers an easy solution so I thought I would mention it. Current version of numpy is version 1.2 and numpy.random.choice allows the sampling to be done with or without replacement and with given weights.
2
52
1
Recently I needed to do weighted random selection of elements from a list, both with and without replacement. While there are well known and good algorithms for unweighted selection, and some for weighted selection without replacement (such as modifications of the resevoir algorithm), I couldn't find any good algorithms for weighted selection with replacement. I also wanted to avoid the resevoir method, as I was selecting a significant fraction of the list, which is small enough to hold in memory. Does anyone have any suggestions on the best approach in this situation? I have my own solutions, but I'm hoping to find something more efficient, simpler, or both.
Weighted random selection with and without replacement
0.022219
0
0
32,149
354,421
2008-12-09T22:07:00.000
2
0
1
0
python
354,622
4
false
0
0
There are two different implementations one for int (long in 3.0) objects and another one for float objects. The float pow is the float_pow(PyObject *v, PyObject *w, PyObject *z) function defined in Objects/floatobject.c file of the Python source code. This functions calls pow() from C stdlib's math.h The int pow has its own implementation, is the function int_pow(PyIntObject *v, PyIntObject *w, PyIntObject *z) defined in Objects/intobject.c (longobject.c for 3.0) of the Python source code.
1
12
0
I'm wondering where I find the source to show how the operator ** is implemented in Python. Can someone point me in the right direction?
How is ** implemented in Python?
0.099668
0
0
1,787
354,755
2008-12-10T00:43:00.000
0
0
0
0
python,django,django-models
355,537
2
false
1
0
You can add field CommentCount to you Post model, and update it in pre_save, pre_delete signals. It's a hard for the db to calculate comments count at every view call and number of queries will be grow.
1
2
0
I'm working on a blog application in Django. Naturally, I have models set up such that there are Posts and Comments, and a particular Post may have many Comments; thus, Post is a ForeignKey in the Comments model. Given a Post object, is there an easy way (ideally, through a method call) to find out how many Comments belong to the Post?
How can I get the number of records that reference a particular foreign key in Django?
0
0
0
270
355,539
2008-12-10T09:49:00.000
7
0
1
0
python,attributes
355,571
3
false
0
0
For checking if a key is in a dictionary you can use in: 'key' in dictionary. For checking for attributes in object use the hasattr() function: hasattr(obj, 'attribute')
1
88
0
If I had a dictionary dict and I wanted to check for dict['key'] I could either do so in a try block (bleh!) or use the get() method, with False as a default value. I'd like to do the same thing for object.attribute. That is, I already have object to return False if it hasn't been set, but then that gives me errors like AttributeError: 'bool' object has no attribute 'attribute'
A get() like method for checking for Python attributes
1
0
0
47,471
355,739
2008-12-10T11:23:00.000
1
0
1
0
python,web-crawler
355,992
4
false
0
0
I am not sure if I understood the question right, I am just curious, so here are few questions and suggestions: Are you planning to catch the Ctrl+C interrupt and do the deque? What happens if the crawler crashes for some arbitrary reason like an unhandled exception or crash? You loose the queue status and start over again? from the documentation: Note The exit function is not called when the program is killed by a signal, when a Python fatal internal error is detected, or when os._exit() is called. What happens when you happen to visit the same URI again, are you maintaining a visited list or something? I think you should be maintaining some kind of visit and session information / status for each URI you crawl. You can use the visit information to decide to crawl a URI or not when you visit the same URI next time. The other info - session information - for the last session with that URI will help in picking up only the incremental stuff and if the page is not change no need to pick it up saving some db I/O costs, duplicates, etc. That way you won't have to worry about the ctrl+C or a crash. If the crawler goes down for any reason, lets say after crawling 60K posts when 40K more were left, the next time crawler fills in the queue, though the queue may be huge but the crawler can check if the it has already visited the URI or not and what was the state of the page when it was crawled - optimization - does the page requires a new pick up coz it has changed or not. I hope that is of some help.
2
3
0
I am writing a crawler in Python, in order to make Ctrl+C not to cause my crawler to start over in next run, I need to save the processing deque in a text file (one item per line) and update it every iteration, the update operation needs to be super fast. In order not to reinvent the wheel, I am asking if there is an established module to do this?
Save a deque in a text file
0.049958
0
0
2,440
355,739
2008-12-10T11:23:00.000
0
0
1
0
python,web-crawler
355,788
4
false
0
0
Some things that come to my mind: leave the file handle open (don't close the file everytime you wrote something) or write the file every n items and catch a close signal to write the current non-written items
2
3
0
I am writing a crawler in Python, in order to make Ctrl+C not to cause my crawler to start over in next run, I need to save the processing deque in a text file (one item per line) and update it every iteration, the update operation needs to be super fast. In order not to reinvent the wheel, I am asking if there is an established module to do this?
Save a deque in a text file
0
0
0
2,440
356,090
2008-12-10T13:49:00.000
0
0
0
0
python,math,nth-root
356,110
11
false
0
0
In older versions of Python, 1/3 is equal to 0. In Python 3.0, 1/3 is equal to 0.33333333333 (and 1//3 is equal to 0). So, either change your code to use 1/3.0 or switch to Python 3.0 .
3
31
0
I need a way to compute the nth root of a long integer in Python. I tried pow(m, 1.0/n), but it doesn't work: OverflowError: long int too large to convert to float Any ideas? By long integer I mean REALLY long integers like: 11968003966030964356885611480383408833172346450467339251 196093144141045683463085291115677488411620264826942334897996389 485046262847265769280883237649461122479734279424416861834396522 819159219215308460065265520143082728303864638821979329804885526 557893649662037092457130509980883789368448042961108430809620626 059287437887495827369474189818588006905358793385574832590121472 680866521970802708379837148646191567765584039175249171110593159 305029014037881475265618958103073425958633163441030267478942720 703134493880117805010891574606323700178176718412858948243785754 898788359757528163558061136758276299059029113119763557411729353 915848889261125855717014320045292143759177464380434854573300054 940683350937992500211758727939459249163046465047204851616590276 724564411037216844005877918224201569391107769029955591465502737 961776799311859881060956465198859727495735498887960494256488224 613682478900505821893815926193600121890632
How to compute the nth root of a very big integer
0
0
0
40,897
356,090
2008-12-10T13:49:00.000
-3
0
0
0
python,math,nth-root
356,213
11
false
0
0
Well, if you're not particularly worried about precision, you could convert it to a sting, chop off some digits, use the exponent function, and then multiply the result by the root of how much you chopped off. E.g. 32123 is about equal to 32 * 1000, the cubic root is about equak to cubic root of 32 * cubic root of 1000. The latter can be calculated by dividing the number of 0s by 3. This avoids the need for the use of extension modules.
3
31
0
I need a way to compute the nth root of a long integer in Python. I tried pow(m, 1.0/n), but it doesn't work: OverflowError: long int too large to convert to float Any ideas? By long integer I mean REALLY long integers like: 11968003966030964356885611480383408833172346450467339251 196093144141045683463085291115677488411620264826942334897996389 485046262847265769280883237649461122479734279424416861834396522 819159219215308460065265520143082728303864638821979329804885526 557893649662037092457130509980883789368448042961108430809620626 059287437887495827369474189818588006905358793385574832590121472 680866521970802708379837148646191567765584039175249171110593159 305029014037881475265618958103073425958633163441030267478942720 703134493880117805010891574606323700178176718412858948243785754 898788359757528163558061136758276299059029113119763557411729353 915848889261125855717014320045292143759177464380434854573300054 940683350937992500211758727939459249163046465047204851616590276 724564411037216844005877918224201569391107769029955591465502737 961776799311859881060956465198859727495735498887960494256488224 613682478900505821893815926193600121890632
How to compute the nth root of a very big integer
-0.054491
0
0
40,897
356,090
2008-12-10T13:49:00.000
-1
0
0
0
python,math,nth-root
356,102
11
false
0
0
Try converting the exponent to a floating number, as the default behaviour of / in Python is integer division n**(1/float(3))
3
31
0
I need a way to compute the nth root of a long integer in Python. I tried pow(m, 1.0/n), but it doesn't work: OverflowError: long int too large to convert to float Any ideas? By long integer I mean REALLY long integers like: 11968003966030964356885611480383408833172346450467339251 196093144141045683463085291115677488411620264826942334897996389 485046262847265769280883237649461122479734279424416861834396522 819159219215308460065265520143082728303864638821979329804885526 557893649662037092457130509980883789368448042961108430809620626 059287437887495827369474189818588006905358793385574832590121472 680866521970802708379837148646191567765584039175249171110593159 305029014037881475265618958103073425958633163441030267478942720 703134493880117805010891574606323700178176718412858948243785754 898788359757528163558061136758276299059029113119763557411729353 915848889261125855717014320045292143759177464380434854573300054 940683350937992500211758727939459249163046465047204851616590276 724564411037216844005877918224201569391107769029955591465502737 961776799311859881060956465198859727495735498887960494256488224 613682478900505821893815926193600121890632
How to compute the nth root of a very big integer
-0.01818
0
0
40,897
358,398
2008-12-11T03:50:00.000
1
0
0
0
python,google-app-engine,post,get
358,757
6
false
1
0
HTTP is stateless, so you have no (built-in) way of knowing if the user that loads one page is the same user that loaded another. Further, even if you do know that, thanks to session cookies, for example, you have no way of telling if the browser window they're loading the subsequent page in is the same one they loaded the prior page in. The user could have multiple tabs accessing your site, and you don't want one page's state change to clobber another's. With that in mind, your best option is to include query parameters in the link to the page being fetched with GET, encoding the variables you want to send to the 'get' page (make sure they're not sensitive, since the user can modify them!). Then you can access them through self.request.GET in the get request.
5
0
0
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called?
Keeping a variable around from post to get?
0.033321
0
0
509
358,398
2008-12-11T03:50:00.000
0
0
0
0
python,google-app-engine,post,get
358,805
6
false
1
0
Why not just use memcache to temporarily store the variable, and then redirect to the POST URL? That seems like the easiest solution.
5
0
0
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called?
Keeping a variable around from post to get?
0
0
0
509
358,398
2008-12-11T03:50:00.000
3
0
0
0
python,google-app-engine,post,get
359,034
6
false
1
0
What you're talking about is establishing a "session". That is, a way to remember the user and the state of their transaction. There are several ways of tackling this, all of which rely on techniques for remembering that you're in a session in the first place. HTTP provides you no help. You have to find some place to save session state on the server, and some place to record session identification on the client. The two big techniques are Use a cookie to identify the session. Seamless and silent. Use a query string in the URL to identify the session. Obvious because you have a ?sessionid=SomeSessionGUID in your URL's. This exposes a lot and makes bookmarking annoying. After the session is cleaned up, you still have this session id floating around in people's bookmarks. In a limited way, you can also use hidden fields in a form. This only works if you have forms on every page. Not always true. Here's how it plays out in practice. GET response. Check for the cookie in the header. a. No cookie. First time user. Create a session. Save it somewhere (memory, file, database). Put the unique ID into a cookie. Respond knowing this is their first time. b. Cookie. Been here recently. Try to get the cookie. FInd the session object. Respond using information in the cookie. Drat. No session. Old cookie. Create a new one and act like this is their first visit. POST response. Check for the cookie in the header. a. No cookie. WTF? Stupid kids. Get off my lawn! Someone bookmarked a POST or is trying to mess with your head. Respond as if it was a first-time GET. b. Cookie. Excellent. Get the cookie. Find the session object. Find the thing you need in the session object. Respond. Drat. No session. Old cookie. Create a new one and respond as if was a first-time GET. You can do the same thing with a query string instead of a cookie. Or a hidden field on a form.
5
0
0
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called?
Keeping a variable around from post to get?
0.099668
0
0
509
358,398
2008-12-11T03:50:00.000
0
0
0
0
python,google-app-engine,post,get
358,425
6
false
1
0
I don't know specifically about the google app engine, but normally, here's what happens: The server would have some kind of thread pool. Every time an http request is sent to the server, a thread is selected from the pool or created. In that thread an instance of some kind of controller object will be created. This object will decide what to do with the request (like instantiating other classes and preprocessing the http request parameters). Usually, this object is the core of web frameworks. The request parameters are also resent by the browser every time (the server cannot guess what the browser wants). Web servers usually have state stores for objects in a permanent or a session state. The session is represented by a unique user (usually by a cookie or a GUID in the url), which expires after a certain time. Now in your case, you would need to take the values you got from your first function, store that in the session store and in the second function, get those values back from the session store. Another solution would be to send the items back to the page as url parameters in your generated HTML from the first function and then you would get those back "as usual" from your second function.
5
0
0
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called?
Keeping a variable around from post to get?
0
0
0
509
358,398
2008-12-11T03:50:00.000
0
0
0
0
python,google-app-engine,post,get
360,292
6
false
1
0
OK -- Thanks everyone. I'll try some of these ideas out, soon, and get back to you all. It seems I can work around some these things by doing a lot of writing and reading from the datastore*, but I thought there might be an easier way of keeping that instance of the class around (I'm trying to use my known techniques in a web framework that I don't completely get yet). *For instance, creating a unique record based on the data in the POST, and letting some variables "tag along". Is this a bad practice?
5
0
0
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called?
Keeping a variable around from post to get?
0
0
0
509
359,347
2008-12-11T13:30:00.000
30
0
0
1
python,windows,subprocess
359,737
5
false
0
0
To do that, you would have to: supply the shell=True argument in the subprocess.Popen call, and separate the commands with: ; if running under a *nix shell (bash, ash, sh, ksh, csh, tcsh, zsh etc) & if running under the cmd.exe of Windows
1
25
0
I would like to execute multiple commands in a row: i.e. (just to illustrate my need): cmd (the shell) then cd dir and ls and read the result of the ls. Any idea with subprocess module? Update: cd dir and ls are just an example. I need to run complex commands (following a particular order, without any pipelining). In fact, I would like one subprocess shell and the ability to launch many commands on it.
Execute Commands Sequentially in Python?
1
0
0
51,127
359,409
2008-12-11T13:52:00.000
3
0
0
0
python,postgresql,sqlalchemy
405,923
3
true
0
0
we've never had an "OID" type specifically, though we've supported the concept of an implicit "OID" column on every table through the 0.4 series, primarily for the benefit of postgres. However since user-table defined OID columns are deprecated in Postgres, and we in fact never really used the OID feature that was present, we've removed this feature from the library. If a particular type is not supplied in SQLA, as an alternative to specifying a custom type, you can always use the NullType which just means SQLA doesn't know anything in particular about that type. If psycopg2 sends/receives a useful Python type for the column already, there's not really any need for a SQLA type object, save for issuing CREATE TABLE statements.
1
8
0
What is the sqlalchemy equivalent column type for 'money' and 'OID' column types in Postgres?
What is the sqlalchemy equivalent column type for 'money' and 'OID' in Postgres?
1.2
1
0
10,565
359,498
2008-12-11T14:21:00.000
1
0
1
0
python,dll,ctypes
49,419,937
6
false
0
0
If you need this functionality, you could write 2 dlls where dll_A loads/Unloads library from dll_B. Use dll_A as as python interface-loader and passthrough for functions in dll_B.
1
24
0
I'm using ctypes to load a DLL in Python. This works great. Now we'd like to be able to reload that DLL at runtime. The straightforward approach would seem to be: 1. Unload DLL 2. Load DLL Unfortunately I'm not sure what the correct way to unload the DLL is. _ctypes.FreeLibrary is available, but private. Is there some other way to unload the DLL?
How can I unload a DLL using ctypes in Python?
0.033321
0
0
25,010
359,706
2008-12-11T15:26:00.000
3
0
0
0
python-imaging-library,polygon,alpha
385,867
7
false
0
0
PIL's Image module provides a blend method. Create a second image the same size as your first, with a black background. Draw your polygon on it (with full colour). Then call Image.blend passing the two images and an alpha level. It returns a third image, which should have a semi-transparent polygon on it. I haven't measured the performance (hey, I haven't even tried it!) so I cannot comment on it's suitability. I suggest you work out your performance budget, and then measure it to see if it is fast enough for your purposes.
1
27
0
I'm using PIL (Python Imaging Library). I'd like to draw transparent polygons. It seems that specifying a fill color that includes alpha level does not work. Are their workarounds? If it can't be done using PIL I'm willing to use something else. If there is more than one solution, then performance should be factored in. The drawing needs to be as fast as possible.
How to draw transparent polygons?
0.085505
0
0
36,190
359,933
2008-12-11T16:18:00.000
2
0
1
0
.net,attributes,ironpython
361,448
2
false
0
0
One, albeit ugly and sometimes impractical, workaround is to create a stub class in C# and decorate it with attributes and derive from that in IronPython.
1
1
0
Since IronPython doesn't support attributes I am wondering if there is another way to decorate IronPython classes with attributes, perhaps with reflection?
How can I add attributes to methods and types defined in IronPython?
0.197375
0
0
1,393
360,602
2008-12-11T19:38:00.000
8
0
0
0
python,windows,linux,native,gui-toolkit
361,672
3
false
0
1
Python binding of Wx is very strong since at least one of the core developer is a python guy itself. WxWdgets is robust, time proven stable, mature, but also bit more than just GUI. Even is a lot is left out in WxPython - because Python itself offers that already - you might find that extra convenient for your project. Wx is the fastest especially on Win, because it lets render the OS and yes WxLicense is de facto LGPL. With XRC you have also a way like Glade to click you to a UI that you can reuse by different projects and languages. What is one major reason for me to use Wx is the fast and helping mailing list, never seen a flamewar, you get even often answers from core developers there, like the notorious vadim zeitlin++. The only thing con to Wx is the API that once grew out of MS MFC and has still its darker(unelegant) corners, but with every version you have some improvements on that as well. QT done some nice stuff, especially warping the language but under python that don't count. They invented also a lot of extra widgets. In wx you have also combined, more complex widgets like e.g. for config dialog, but that goes not that far as in QT. And you could of course use GTK. almost no difference under linux to Wx but a bit alien and slower under win. but also free.
2
4
0
I need to decide on a GUI/Widget toolkit to use with Python for a new project. The target platforms will be Linux with KDE and Windows XP (and probably Vista). What Python GUI toolkit looks best and consistent with the native look and feel of the run time platform? If possible, cite strengths and weaknesses of the suggested toolkit. Thank you, Luis
What GUI toolkit looks best for a native LAF for Python in Windows and Linux?
1
0
0
1,840
360,602
2008-12-11T19:38:00.000
0
0
0
0
python,windows,linux,native,gui-toolkit
361,996
3
false
0
1
Like others said, PyQt or wxPython... The technical difference between the two is more or less imaginary - it's a question of your comfort with the toolkit that matters, really.
2
4
0
I need to decide on a GUI/Widget toolkit to use with Python for a new project. The target platforms will be Linux with KDE and Windows XP (and probably Vista). What Python GUI toolkit looks best and consistent with the native look and feel of the run time platform? If possible, cite strengths and weaknesses of the suggested toolkit. Thank you, Luis
What GUI toolkit looks best for a native LAF for Python in Windows and Linux?
0
0
0
1,840
360,911
2008-12-11T21:05:00.000
0
0
0
1
python,apache,cvs,sspi
361,235
1
true
1
0
Usage of SSPI make me think you are using CVSNT, thus a Windows system; what is the user you are running Apache into? Default user for services is SYSTEM, which does not share the same registry as your current user.
1
0
0
I'm running an Apache server (v2.2.10) with mod_python, Python 2.5 and Django. I have a small web app that will show the current projects we have in CVS and allow users to make a build of the different projects (the build checks out the project, and copies certain files over with the source stripped out). On the Django dev server, everything works fine. I can see the list of projects in cvs, check out, etc. On the production server (the Apache one) I get the following error: [8009030d] The credentials supplied to the package were not recognized I'm trying to log in to the CVS server using SSPI. Entering the same command into a shell will execute properly. This is the code I'm using: def __execute(self, command = ''): command = 'cvs.exe -d :sspi:user:[email protected]:/Projects ls' p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr = subprocess.STDOUT, shell=True) return p.communicate() I've tried a number of different variations of things, and I can't seem to get it to work. Right now I believe that Apache is the culprit. Any help would be appreciated
Access CVS through Apache service using SSPI
1.2
0
0
820
361,675
2008-12-12T01:50:00.000
31
1
1
0
python,unit-testing,comparison,doctest
10,861,736
11
false
0
0
I work as a bioinformatician, and most of the code I write is "one time, one task" scripts, code that will be run only once or twice and that execute a single specific task. In this situation, writing big unittests may be overkill, and doctests are an useful compromise. They are quicker to write, and since they are usually incorporated in the code, they allow to always keep an eye on how the code should behave, without having to have another file open. That's useful when writing small script. Also, doctests are useful when you have to pass your script to a researcher that is not expert in programming. Some people find it very difficult to understand how unittests are structured; on the other hand, doctests are simple examples of usage, so people can just copy and paste them to see how to use them. So, to resume my answer: doctests are useful when you have to write small scripts, and when you have to pass them or show them to researchers that are not computer scientists.
9
169
0
I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. What conditions would you use each for?
Python - doctest vs. unittest
1
0
0
29,175
361,675
2008-12-12T01:50:00.000
37
1
1
0
python,unit-testing,comparison,doctest
667,829
11
false
0
0
Another advantage of doctesting is that you get to make sure your code does what your documentation says it does. After a while, software changes can make your documentation and code do different things. :-)
9
169
0
I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. What conditions would you use each for?
Python - doctest vs. unittest
1
0
0
29,175
361,675
2008-12-12T01:50:00.000
7
1
1
0
python,unit-testing,comparison,doctest
361,788
11
false
0
0
Using both is a valid and rather simple option. The doctest module provides the DoctTestSuite and DocFileSuite methods which create a unittest-compatible testsuite from a module or file, respectively. So I use both and typically use doctest for simple tests with functions that require little or no setup (simple types for arguments). I actually think a few doctest tests help document the function, rather than detract from it. But for more complicated cases, and for a more comprehensive set of test cases, I use unittest which provides more control and flexibility.
9
169
0
I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. What conditions would you use each for?
Python - doctest vs. unittest
1
0
0
29,175
361,675
2008-12-12T01:50:00.000
7
1
1
0
python,unit-testing,comparison,doctest
361,703
11
false
0
0
I use unittest exclusively; I think doctest clutters up the main module too much. This probably has to do with writing thorough tests.
9
169
0
I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. What conditions would you use each for?
Python - doctest vs. unittest
1
0
0
29,175
361,675
2008-12-12T01:50:00.000
50
1
1
0
python,unit-testing,comparison,doctest
361,680
11
false
0
0
I use unittest almost exclusively. Once in a while, I'll put some stuff in a docstring that's usable by doctest. 95% of the test cases are unittest. Why? I like keeping docstrings somewhat shorter and more to the point. Sometimes test cases help clarify a docstring. Most of the time, the application's test cases are too long for a docstring.
9
169
0
I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. What conditions would you use each for?
Python - doctest vs. unittest
1
0
0
29,175
361,675
2008-12-12T01:50:00.000
8
1
1
0
python,unit-testing,comparison,doctest
13,722,080
11
false
0
0
I don't use doctest as a replacement for unittest. Although they overlap a bit, the two modules don't have the same function: I use unittest as a unit testing framework, meaning it helps me determine quickly the impact of any modification on the rest of the code. I use doctest as a guarantee that comments (namely docstrings) are still relevant to current version of the code. The widely documented benefits of test driven development I get from unittest. doctest solves the far more subtle danger of having outdated comments misleading the maintenance of the code.
9
169
0
I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. What conditions would you use each for?
Python - doctest vs. unittest
1
0
0
29,175
361,675
2008-12-12T01:50:00.000
4
1
1
0
python,unit-testing,comparison,doctest
361,698
11
false
0
0
I almost never use doctests. I want my code to be self documenting, and the docstrings provide the documentation to the user. IMO adding hundreds of lines of tests to a module makes the docstrings far less readable. I also find unit tests easier to modify when needed.
9
169
0
I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. What conditions would you use each for?
Python - doctest vs. unittest
0.072599
0
0
29,175
361,675
2008-12-12T01:50:00.000
3
1
1
0
python,unit-testing,comparison,doctest
361,886
11
false
0
0
I prefer the discovery based systems ("nose" and "py.test", using the former currently). doctest is nice when the test is also good as a documentation, otherwise they tend to clutter the code too much.
9
169
0
I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. What conditions would you use each for?
Python - doctest vs. unittest
0.054491
0
0
29,175
361,675
2008-12-12T01:50:00.000
14
1
1
0
python,unit-testing,comparison,doctest
361,683
11
false
0
0
If you're just getting started with the idea of unit testing, I would start with doctest because it is so simple to use. It also naturally provides some level of documentation. And for more comprehensive testing with doctest, you can place tests in an external file so it doesn't clutter up your documentation. I would suggest unittest if you're coming from a background of having used JUnit or something similar, where you want to be able to write unit tests in generally the same way as you have been elsewhere.
9
169
0
I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. What conditions would you use each for?
Python - doctest vs. unittest
1
0
0
29,175
362,428
2008-12-12T10:36:00.000
0
0
0
0
ironpython,ironpython-studio
363,455
2
true
0
1
In the end it was even simpler. I was trying to invoke the subform thus: f = frmSubform() f.Show() But I actually needed to do it this way f = frmSubform() Form.Show(f) Form.ShowDialog(f) worked also; in a Dialog format of course. A simple enough error but until you know you, well, don't know. I'm not 100% sure I understand at this stage why what works, works, but I'm sure I shall learn with experience.
1
1
0
This is a two part question. A dumb technical query and a broader query about my possibly faulty approach to learning to do some things in a language I'm new to. I'm just playing around with a few Python GUI libraries (mostly wxPython and IronPython) for some work I'm thinking of doing on an open source app, just to improve my skills and so forth. By day I am a pretty standard c# bod working with a pretty normal set of MS based tools and I am looking at Python to give me a new perspective. Thus using Ironpython Studio is probably cheating a bit (alright, a lot). This seems not to matter because however much it attempts to look like a Visual Studio project etc. There's one simple behaviour I'm probably being too dumb to implement. I.E. How do I keep my forms in nice separate code files, like the c# monkey I have always been ,and yet invoke them from one another? I've tried importing the form to be invoked to the main form but I just can't seem to get the form to be recognized as anything other than an object. The new form appears to be a form object in its own code file, I am importing the clr. I am trying to invoke a form's 'Show' method. Is this not right? I've tried a few (to my mind more unlikely) ways around this but the problem seems intractable. Is this something I'm just not seeing or would it in fact be more appropriate for me to change the way I think about my GUI scripting to fit round Python (in which case I may switch back to wxPython which seemed more approachable from a Pythonic point of view) rather than try to look at Python from the security of the Visual Studio shell?
Ironpython Studio forms
1.2
0
0
1,298
362,522
2008-12-12T11:37:00.000
1
0
1
0
python,emacs,editing
362,596
6
false
0
0
python-mode.el is written by the Python community. python.el is written by the emacs community. I've used python-mode.el for as long as I can remember and python.el doesn't even come close to the standards of python-mode.el. I trust the Python community better than the Emacs community to come up with a decent mode file. Just stick with python-mode.el, is there really a reason not to?
4
30
0
I recently tried switching from using python-mode.el to python.el for editing python files in emacs, found the experience a little alien and unproductive, and scurried back. I've been using python-mode.el for something like ten years, so perhaps I'm a little set in my ways. I'd be interested in hearing from anyone who's carefully evaluated the two modes, in particular of the pros and cons they perceive of each and how their work generally interacts with the features specific to python.el. The two major issues for me with python.el were Each buffer visiting a python file gets its own inferior interactive python shell. I am used to doing development in one interactive shell and sharing data between python files. (Might seem like bad practice from a software-engineering perspective, but I'm usually working with huge datasets which take a while to load into memory.) The skeleton-mode support in python.el, which seemed absolutely gratuitous (python's syntax makes such automation unnecessary) and badly designed (for instance, it has no knowledge of "for" loop generator expressions or "<expr 1> if <cond> else <expr 2>" expressions, so you have to go back and remove the colons it helpfully inserts after insisting that you enter the expression clauses in the minibuffer.) I couldn't figure out how to turn it off. There was a python.el variable which claimed to control this, but it didn't seem to work. It could be that the version of python.el I was using was broken (it came from the debian emacs-snapshot package) so if anyone knows of an up-to-date version of it, I'd like to hear about it. (I had the same problem with the version in CVS emacs as of approximately two weeks ago.)
Switching from python-mode.el to python.el
0.033321
0
0
7,412
362,522
2008-12-12T11:37:00.000
1
0
1
0
python,emacs,editing
1,005,515
6
false
0
0
python-mode.el has no support triple-quoted strings, so if your program contains long docstrings, all the syntax coloring (and associated syntaxic features) tends to break down. my .02
4
30
0
I recently tried switching from using python-mode.el to python.el for editing python files in emacs, found the experience a little alien and unproductive, and scurried back. I've been using python-mode.el for something like ten years, so perhaps I'm a little set in my ways. I'd be interested in hearing from anyone who's carefully evaluated the two modes, in particular of the pros and cons they perceive of each and how their work generally interacts with the features specific to python.el. The two major issues for me with python.el were Each buffer visiting a python file gets its own inferior interactive python shell. I am used to doing development in one interactive shell and sharing data between python files. (Might seem like bad practice from a software-engineering perspective, but I'm usually working with huge datasets which take a while to load into memory.) The skeleton-mode support in python.el, which seemed absolutely gratuitous (python's syntax makes such automation unnecessary) and badly designed (for instance, it has no knowledge of "for" loop generator expressions or "<expr 1> if <cond> else <expr 2>" expressions, so you have to go back and remove the colons it helpfully inserts after insisting that you enter the expression clauses in the minibuffer.) I couldn't figure out how to turn it off. There was a python.el variable which claimed to control this, but it didn't seem to work. It could be that the version of python.el I was using was broken (it came from the debian emacs-snapshot package) so if anyone knows of an up-to-date version of it, I'd like to hear about it. (I had the same problem with the version in CVS emacs as of approximately two weeks ago.)
Switching from python-mode.el to python.el
0.033321
0
0
7,412
362,522
2008-12-12T11:37:00.000
2
0
1
0
python,emacs,editing
13,267,654
6
false
0
0
Note nearly everything said here is obsolete meanwhile as things changed. python-mode.el commands are prefixed "py-" basically, you should be able to use commands from both, nonewithstanding which one was loaded first. python-mode.el does not unload python.el; beside of python-mode-map, which is re-defined. The diff is in the menu displayed and keysetting however, the last one loaded will determine.
4
30
0
I recently tried switching from using python-mode.el to python.el for editing python files in emacs, found the experience a little alien and unproductive, and scurried back. I've been using python-mode.el for something like ten years, so perhaps I'm a little set in my ways. I'd be interested in hearing from anyone who's carefully evaluated the two modes, in particular of the pros and cons they perceive of each and how their work generally interacts with the features specific to python.el. The two major issues for me with python.el were Each buffer visiting a python file gets its own inferior interactive python shell. I am used to doing development in one interactive shell and sharing data between python files. (Might seem like bad practice from a software-engineering perspective, but I'm usually working with huge datasets which take a while to load into memory.) The skeleton-mode support in python.el, which seemed absolutely gratuitous (python's syntax makes such automation unnecessary) and badly designed (for instance, it has no knowledge of "for" loop generator expressions or "<expr 1> if <cond> else <expr 2>" expressions, so you have to go back and remove the colons it helpfully inserts after insisting that you enter the expression clauses in the minibuffer.) I couldn't figure out how to turn it off. There was a python.el variable which claimed to control this, but it didn't seem to work. It could be that the version of python.el I was using was broken (it came from the debian emacs-snapshot package) so if anyone knows of an up-to-date version of it, I'd like to hear about it. (I had the same problem with the version in CVS emacs as of approximately two weeks ago.)
Switching from python-mode.el to python.el
0.066568
0
0
7,412
362,522
2008-12-12T11:37:00.000
0
0
1
0
python,emacs,editing
71,343,689
6
false
0
0
Debian has deleted the python-mode package, alas, so I felt compelled to try python.el. I loaded it and ran "describe-bindings". It appeared to be designed for elisp coders who think c-X ; is the intuitive binding for commenting a line of Python code. (Wow.) Also, I found no way at all to comment a region of code, or, rather, no binding with the strings "region" and "comment" in it. Good old python-mode can still be cloned via git clone https://gitlab.com/python-mode-devs/python-mode.git. It was last edited a week ago at this writing, so it's safe to assume it's not abandoned.
4
30
0
I recently tried switching from using python-mode.el to python.el for editing python files in emacs, found the experience a little alien and unproductive, and scurried back. I've been using python-mode.el for something like ten years, so perhaps I'm a little set in my ways. I'd be interested in hearing from anyone who's carefully evaluated the two modes, in particular of the pros and cons they perceive of each and how their work generally interacts with the features specific to python.el. The two major issues for me with python.el were Each buffer visiting a python file gets its own inferior interactive python shell. I am used to doing development in one interactive shell and sharing data between python files. (Might seem like bad practice from a software-engineering perspective, but I'm usually working with huge datasets which take a while to load into memory.) The skeleton-mode support in python.el, which seemed absolutely gratuitous (python's syntax makes such automation unnecessary) and badly designed (for instance, it has no knowledge of "for" loop generator expressions or "<expr 1> if <cond> else <expr 2>" expressions, so you have to go back and remove the colons it helpfully inserts after insisting that you enter the expression clauses in the minibuffer.) I couldn't figure out how to turn it off. There was a python.el variable which claimed to control this, but it didn't seem to work. It could be that the version of python.el I was using was broken (it came from the debian emacs-snapshot package) so if anyone knows of an up-to-date version of it, I'd like to hear about it. (I had the same problem with the version in CVS emacs as of approximately two weeks ago.)
Switching from python-mode.el to python.el
0
0
0
7,412
364,015
2008-12-12T20:22:00.000
5
0
0
0
python,django,django-models,django-templates
364,161
3
false
1
0
first, forget all MVC mantra. it's important to have a good layered structure, but MVC (as defined originally) isn't one, it was a modular structure, where each GUI module is split in these tree submodules. nothing to use on the web here. in web development, it really pays to have a layered structure, where the most important layer is the storage/modelling one, which came to be called model layer. on top of that, you need a few other layers but they're really not anything like views and controllers in the GUI world. the Django layers are roughly: storage/modelling: models.py, obviously. try to put most of the 'working' concepts there. all the relationships, all the operations should be implemented here. dispatching: mostly in urls.py. here you turn your URL scheme into code paths. think of it like a big switch() statement. try hard to have readable URLs, which map into user intentions. it will help a lot to add new functionality, or new ways to do the same things (like an AJAX UI later). gathering: mostly the view functions, both yours and the prebuilt generic views. here you simply gather all the from the models to satisfy a user request. in surprisingly many cases, it just have to pick a single model instance, and everything else can be retrieved from relationships. for these URLs, a generic view is enough. presentation: the templates. if the view gives you the data you need, it's simple enough to turn it into a webpage. it's here where you'll thank that the model classes have good accessors to get any kind of relevant data from any given instance.
1
8
0
Pretty new to this scene and trying to find some documentation to adopt best practices. We're building a fairly large content site which will consist of various media catalogs and I'm trying to find some comparable data / architectural models so that we can get a better idea of the approach we should use using a framework we've never made use of before. Any insight / help would be greatly appreciated!
MVC and django fundamentals
0.321513
0
0
5,782
364,486
2008-12-12T23:26:00.000
0
1
0
0
php,python,perl,eclipse
6,481,753
7
false
1
0
I develop in PHP, python, C(python modules), SQL and JS/HTML/CSS all on eclipse. I do this by installing PDT, CDT, pydev and SQL tools onto the eclipse-platform, and then using different workspaces for mixed projects. Two workspaces to be specific, one for PHP web development and another for Python/C. I do run it on a rather powerful machine so I allow eclipse the luxury of added memory (2G). Works like a charm and it is very nice to be able to use the same IDE for everything :)
3
4
0
I'd like to try out Eclipse, but I'm a bit baffled with all the different distributions of it. I mainly program in Python doing web development, but I also need to maintain PHP and Perl apps. It looks like EasyEclipse is a bit behind. Should I just grab the base Eclipse and start loading plug-ins?
Which Eclipse distribution is good for web development using Python, PHP, or Perl?
0
0
0
2,130
364,486
2008-12-12T23:26:00.000
0
1
0
0
php,python,perl,eclipse
18,023,885
7
false
1
0
I use the javascript eclipse helios and added pydev plugin to it for django support it seems to do everything I need.
3
4
0
I'd like to try out Eclipse, but I'm a bit baffled with all the different distributions of it. I mainly program in Python doing web development, but I also need to maintain PHP and Perl apps. It looks like EasyEclipse is a bit behind. Should I just grab the base Eclipse and start loading plug-ins?
Which Eclipse distribution is good for web development using Python, PHP, or Perl?
0
0
0
2,130
364,486
2008-12-12T23:26:00.000
0
1
0
0
php,python,perl,eclipse
364,517
7
false
1
0
PyDev is pretty decent as I'm sure you know. It can fit on top of all the Eclipse distributions (provided they meet the minimum version requirements). If you're doing webdev stuff, you'll probably find the closest fit with Aptana. That said, I find Aptana hideously clunky when compared to a decent text editor. I build sites using django and for that I use Eclipse (pure) and PyDev to do the python and gedit (gnome's souped up notepad) for writing the HTML for templates/CSS/JS/etc. At the end of the day, whatever suits you best is what you'll go with.
3
4
0
I'd like to try out Eclipse, but I'm a bit baffled with all the different distributions of it. I mainly program in Python doing web development, but I also need to maintain PHP and Perl apps. It looks like EasyEclipse is a bit behind. Should I just grab the base Eclipse and start loading plug-ins?
Which Eclipse distribution is good for web development using Python, PHP, or Perl?
0
0
0
2,130
364,802
2008-12-13T03:55:00.000
2
0
1
0
python
27,446,011
7
false
0
0
Generator comprehension is an approach to create iterables, something like a cursor which moves on a resource. If you know mysql cursor or mongodb cursor, you may be aware of that the whole actual data never gets loaded into the memory at once, but one at a time. Your cursor moves back and forth, but there is always a one row/list element in memory. In short, by using generators comprehension you can easily create cursors in python.
1
119
0
What does generator comprehension do? How does it work? I couldn't find a tutorial about it.
How exactly does a generator comprehension work?
0.057081
0
0
77,729
365,058
2008-12-13T09:55:00.000
3
0
0
0
python,winapi
365,096
2
false
0
0
In a console application, you can use win32api.SetConsoleCtrlHandler and look for CTRL_LOGOFF_EVENT. In a GUI application, you need a window open and wait for the WM_QUERYENDSESSION message. How precisely that works (and if it works at all) depends on your GUI library.
1
5
0
How can I detect, or be notified, when windows is logging out in python? Edit: Martin v. Löwis' answer is good, and works for a full logout but it does not work for a 'fast user switching' event like pressing win+L which is what I really need it for. Edit: im not using a gui this is running as a service
Detect windows logout in Python
0.291313
0
0
2,932
365,082
2008-12-13T10:30:00.000
5
0
0
0
python,python-3.x,django,django-forms,django-admin
365,431
6
false
1
0
Building on Javier's answer; if you need one label in forms (on the front-end) and another label on admin it is best to set internal (admin) one in the model and overwrite it on forms. Admin will of course use the label in the model field automatically.
1
64
0
As the title suggests. I want to be able to change the label of a single field in the admin application. I'm aware of the Form.field attribute, but how do I get my Model or ModelAdmin to pass along that information?
Can you change a field label in the Django Admin application?
0.16514
0
0
67,765
366,682
2008-12-14T16:20:00.000
5
0
1
0
python,multithreading
366,754
13
false
0
0
The only "safe" way to do this, in any language, is to use a secondary process to do that timeout-thing, otherwise you need to build your code in such a way that it will time out safely by itself, for instance by checking the time elapsed in a loop or similar. If changing the method isn't an option, a thread will not suffice. Why? Because you're risking leaving things in a bad state when you do. If the thread is simply killed mid-method, locks being held, etc. will just be held, and cannot be released. So look at the process way, do not look at the thread way.
1
90
0
There is a socket related function call in my code, that function is from another module thus out of my control, the problem is that it blocks for hours occasionally, which is totally unacceptable, How can I limit the function execution time from my code? I guess the solution must utilize another thread.
How to limit execution time of a function call?
0.076772
0
1
100,904
366,838
2008-12-14T18:48:00.000
0
0
0
0
python,django,localization,internationalization
367,026
10
false
1
0
It depends on who will provide the translations. If you want to provide a web interface to translation, then you need to develop that yourself, and also represent the translations in the database. If the same translators who translated the site will also translate the data, you can provide them with the same model that they use for the site (presumably gettext), and you can then also use gettext for this content.
2
8
0
Hey, i am currently working on a django app for my studies, and came to the point of l18n. Localizing the site itself was very easy, but now i have to allow users, to translate the dynamic content of the application. Users can save "products" in the database and give them names and descriptions, but since the whole site should be localized, i must provide a way of translating theses names and descriptions to the users. Is there a natural way in django to do this? Or do i have to realize it as part of the application (by representing the translations in the datamodel) Thanks, Janosch
How to localize Content of a Django application
0
0
0
9,378
366,838
2008-12-14T18:48:00.000
0
0
0
0
python,django,localization,internationalization
3,870,634
10
false
1
0
I think you should operate in two steps: Get translations Show translated strings For the first step, you should tell Django that the user-inserted strings are to be translated. I think there is no native way to do so. Maybe you can extract the strings from your db putting them in locale-specific files, run 'makemessages' on them, obtaint django.po files and translate. Second, use ugettext to show those strings on your web application. Hope this can help the ones with your same problem.
2
8
0
Hey, i am currently working on a django app for my studies, and came to the point of l18n. Localizing the site itself was very easy, but now i have to allow users, to translate the dynamic content of the application. Users can save "products" in the database and give them names and descriptions, but since the whole site should be localized, i must provide a way of translating theses names and descriptions to the users. Is there a natural way in django to do this? Or do i have to realize it as part of the application (by representing the translations in the datamodel) Thanks, Janosch
How to localize Content of a Django application
0
0
0
9,378
366,980
2008-12-14T21:00:00.000
17
1
1
0
python,perl,sed,awk,language-comparisons
367,082
5
false
0
0
First, there are two unrelated things in the list "Perl, Python awk and sed". Thing 1 - simplistic text manipulation tools. sed. It has a fixed, relatively simple scope of work defined by the idea of reading and examining each line of a file. sed is not designed to be particularly readable. It is designed to be very small and very efficient on very tiny unix servers. awk. It has a slightly less fixed, less simple scope of work. However, the main loop of an awk program is defined by the implicit reading of lines of a source file. These are not "complete" programming languages. While you can -- with some work -- write fairly sophisticated programs in awk, it rapidly gets complicated and difficult to read. Thing 2 - general-purposes programming languages. These have a rich variety of statement types, numerous built-in data structures, and no wired-in assumptions or shortcuts to speak of. Perl. Python. When to use them. sed. Never. It really doesn't have any value in the modern era of computers with more than 32K of memory. Perl or Python do the same things more clearly. awk. Never. Like sed, it reflects an earlier era of computing. Rather than maintain this language (in addition to all the other required for a successful system), it's more pleasant to simply do everything in one pleasant language. Perl. Any programming problem of any kind. If you like free-thinking syntax, where there are many, many ways to do the same thing, perl is fun. Python. Any programming problem of any kind. If you like fairly limited syntax, where there are fewer choices, less subtlety, and (perhaps) more clarity. Python's object-oriented nature makes it more suitable for large, complex problems. Background -- I'm not bashing sed and awk out of ignorance. I learned awk over 20 years ago. Did many things with it; used to teach it as a core unix skill. I learned Perl about 15 years ago. Did many sophisticated things with it. I've left both behind because I can do the same things in Python -- and it is simpler and more clear. There are two serious problems with sed and awk, neither of which are their age. The incompleteness of their implementation. Everything sed and awk do can be done in Python or Perl, often more simply and sometimes faster, too. A shell pipeline has some performance advantages because of its multi-processing. Python offers a subprocess module to allow me to recover those advantages. The need to learn yet another language. By doing things in Python (or Perl) your implementation depends on fewer languages, with a resulting increase in clarity.
4
274
0
What are the main differences among them? And in which typical scenarios is it better to use each language?
What are the differences between Perl, Python, AWK and sed?
1
0
0
86,075
366,980
2008-12-14T21:00:00.000
588
1
1
0
python,perl,sed,awk,language-comparisons
367,014
5
true
0
0
In order of appearance, the languages are sed, awk, perl, python. The sed program is a stream editor and is designed to apply the actions from a script to each line (or, more generally, to specified ranges of lines) of the input file or files. Its language is based on ed, the Unix editor, and although it has conditionals and so on, it is hard to work with for complex tasks. You can work minor miracles with it - but at a cost to the hair on your head. However, it is probably the fastest of the programs when attempting tasks within its remit. (It has the least powerful regular expressions of the programs discussed - adequate for many purposes, but certainly not PCRE - Perl-Compatible Regular Expressions) The awk program (name from the initials of its authors - Aho, Weinberger, and Kernighan) is a tool initially for formatting reports. It can be used as a souped-up sed; in its more recent versions, it is computationally complete. It uses an interesting idea - the program is based on 'patterns matched' and 'actions taken when the pattern matches'. The patterns are fairly powerful (Extended Regular Expressions). The language for the actions is similar to C. One of the key features of awk is that it splits the input automatically into records and each record into fields. Perl was written in part as an awk-killer and sed-killer. Two of the programs provided with it are a2p and s2p for converting awk scripts and sed scripts into Perl. Perl is one of the earliest of the next generation of scripting languages (Tcl/Tk can probably claim primacy). It has powerful integrated regular expression handling with a vastly more powerful language. It provides access to almost all system calls and has the extensibility of the CPAN modules. (Neither awk nor sed is extensible.) One of Perl's mottos is "TMTOWTDI - There's more than one way to do it" (pronounced "tim-toady"). Perl has 'objects', but it is more of an add-on than a fundamental part of the language. Python was written last, and probably in part as a reaction to Perl. It has some interesting syntactic ideas (indenting to indicate levels - no braces or equivalents). It is more fundamentally object-oriented than Perl; it is just as extensible as Perl. OK - when to use each? Sed - when you need to do simple text transforms on files. Awk - when you only need simple formatting and summarisation or transformation of data. Perl - for almost any task, but especially when the task needs complex regular expressions. Python - for the same tasks that you could use Perl for. I'm not aware of anything that Perl can do that Python can't, nor vice versa. The choice between the two would depend on other factors. I learned Perl before there was a Python, so I tend to use it. Python has less accreted syntax and is generally somewhat simpler to learn. Perl 6, when it becomes available, will be a fascinating development. (Note that the 'overviews' of Perl and Python, in particular, are woefully incomplete; whole books could be written on the topic.)
4
274
0
What are the main differences among them? And in which typical scenarios is it better to use each language?
What are the differences between Perl, Python, AWK and sed?
1.2
0
0
86,075
366,980
2008-12-14T21:00:00.000
100
1
1
0
python,perl,sed,awk,language-comparisons
2,905,791
5
false
0
0
After mastering a few dozen languages, you get tired of people like S. Lott (see his controversial answer to this question, nearly half as many down-votes as up (+45/-22) six years after answering). Sed is the best tool for extremely simple command-line pipelines. In the hands of a sed master, it's suitable for one-offs of arbitrary complexity, but it should not be used in production code except in very simple substitution pipelines. Stuff like 's/this/that/.' Gawk (the GNU awk) is by far the best choice for complex data reformatting when there is only a single input source and a single output (or, multiple outputs sequentially written). Since a great deal of real-world work conforms to this description, and a good programmer can learn gawk in two hours, it is the best choice. On this planet, simpler and faster is better! Perl or Python are far better than any version of awk or sed when you have very complex input/output scenarios. The more complex the problem is, the better off you are using python, from a maintenance and readability standpoint. Note, however, that a good programmer can write readable code in any language, and a bad programmer can write unmaintainable crap in any useful language, so the choice of perl or python can safely be left to the preferences of the programmer if said programmer is skilled and clever.
4
274
0
What are the main differences among them? And in which typical scenarios is it better to use each language?
What are the differences between Perl, Python, AWK and sed?
1
0
0
86,075
366,980
2008-12-14T21:00:00.000
22
1
1
0
python,perl,sed,awk,language-comparisons
367,002
5
false
0
0
I wouldn't call sed a fully-fledged programming language, it is a stream editor with language constructs aimed at editing text files programmatically. Awk is a little more of a general purpose language but it is still best suited for text processing. Perl and Python are fully fledged, general purpose programming languages. Perl has its roots in text processing and has a number of awk-like constructs (there is even an awk-to-perl script floating around on the net). There are many differences between Perl and Python, your best bet is probably to read the summaries of both languages on something like Wikipedia to get a good grasp on what they are.
4
274
0
What are the main differences among them? And in which typical scenarios is it better to use each language?
What are the differences between Perl, Python, AWK and sed?
1
0
0
86,075
367,029
2008-12-14T21:45:00.000
1
0
0
0
python,google-app-engine,model,referenceproperty
367,334
3
false
1
0
I'm having similar difficulties for my project. As I code the beta version of my application, I do create a lot of dead link and its trully a pain to untangle things afterward. Ideally, this tool would have to also report of the offending reference so that you could pin-point problems in the code.
2
0
0
Most of the time, the errors you get from your model properties will happen when you're saving data. For instance, if you try saving a string as an IntegerProperty, that will result in an error. The one exception (no pun intended) is ReferenceProperty. If you have lots of references and you're not completely careful about leaving in bad references, it's common to be greeted with an error like "TemplateSyntaxError: Caught an exception while rendering: ReferenceProperty failed to be resolved". And this is if there's only one bad reference in the view. D'oh. I could write a try/except block to try to access all the reference properties and delete them if an exception is raised, but this functionality could surely be useful to many other developers if there was a more generic method than the one I'd be capable of writing. I imagine it would take a list of model types and try to access each reference property of each entity in each model, setting the property to None if an exception is raised. I'll see if I can do this myself, but it would definitely help to have some suggestions/snippets to get me started.
Deleting erroneous ReferenceProperty properties in AppEngine
0.066568
0
0
1,235
367,029
2008-12-14T21:45:00.000
0
0
0
0
python,google-app-engine,model,referenceproperty
374,241
3
false
1
0
You could extend and customize ReferenceProperty to not throw this exception, but then it'll need to return something - presumably None - in which case your template will simply throw an exception when it attempts to access properties on the returned object. A better approach is to fetch the referenceproperty and check it's valid before rendering the template. ReferenceProperties cache their references, so prefetching won't result in extra datastore calls.
2
0
0
Most of the time, the errors you get from your model properties will happen when you're saving data. For instance, if you try saving a string as an IntegerProperty, that will result in an error. The one exception (no pun intended) is ReferenceProperty. If you have lots of references and you're not completely careful about leaving in bad references, it's common to be greeted with an error like "TemplateSyntaxError: Caught an exception while rendering: ReferenceProperty failed to be resolved". And this is if there's only one bad reference in the view. D'oh. I could write a try/except block to try to access all the reference properties and delete them if an exception is raised, but this functionality could surely be useful to many other developers if there was a more generic method than the one I'd be capable of writing. I imagine it would take a list of model types and try to access each reference property of each entity in each model, setting the property to None if an exception is raised. I'll see if I can do this myself, but it would definitely help to have some suggestions/snippets to get me started.
Deleting erroneous ReferenceProperty properties in AppEngine
0
0
0
1,235
367,115
2008-12-14T22:57:00.000
10
1
1
0
python,perl,command-line,language-features
367,181
6
true
0
0
The command line usage from 'python -h' certainly strongly suggests there is no such equivalent. Perl tends to make extensive use of '$_' (your examples make implicit use of it), and I don't think Python supports any similar concept, thereby making Python equivalents of the Perl one-liners much harder.
1
17
0
I know of python -c '<code>', but I'm wondering if there's a more elegant python equivalent to perl -pi -e '<code>'. I still use it quite a bit for things like find and replace in a whole directory (perl -pi -e s/foo/bar/g * or even find . | xargs perl -pi -e s/foo/bar/g for sub-directories). I actually feel that that which makes Perl Perl (free form Tim Toady-ness) is what makes perl -pi -e work so well, while with Python you'd have to do something along the lines of importing the re module, creating an re instance and then capture stdin, but maybe there's a Python shortcut that does all that and I missed it (sorely missed it)...
Is there a Python equivalent to `perl -pi -e`?
1.2
0
0
3,183
369,230
2008-12-15T18:12:00.000
0
0
0
0
python,xml,django,json,serialization
372,371
2
false
1
0
If your problem is just to serialze a ModelForm to json, just write your own simplejson serializer subclass.
1
2
0
I am using Django and the Google Web Toolkit (GWT) for my current project. I would like to pass a ModelForm instance to GWT via an Http response so that I can "chop" it up and render it as I please. My goal is to keep the form in sync with changes to my models.py file, yet increase control I have over the look of the form. However, the django classes for serialization, serializers and simplejson, cannot serialize a ModelForm. Neither can cPickle. What are my alternatives?
What is the best way to serialize a ModelForm object in Django?
0
0
0
2,670
369,305
2008-12-15T18:39:00.000
2
0
0
1
python,django,apache
392,945
1
false
1
0
This doesn't directly answer your question, but have you thought about using something like MacPorts for this sort of thing? If you're compiling a lot of software like this, MacPorts can really make your life easier, since building software and dependencies is practically automatic.
1
4
0
I'm working on a Django project that requires debugging on a multithreaded server. I've found mod_wsgi 2.0+ to be the easiest to work with, because of easy workarounds for python module reloading. Problem is can't get it to compile on Leopard. Is there anyone who has managed to do it so far, either for the builtin Apache or MAMP. I'd be grateful if someone posts a link to a precompiled binary (for intel, python 2.5, apache 2.2 or 2.0). After 3 hours of trial and error I've managed to compile mod_wsgi 2.3 for the Apache that comes with Leopard. Here are the instructions in case anyone else needs this. ./configure Change 2 lines in the Makefile CFLAGS = -Wc,'-arch i386' LDFLAGS = -arch i386 -Wl,-F/Library/Frameworks -framework Python -u _PyMac_Error make && sudo make install Make a thin binary of the original httpd cd /usr/sbin sudo mv ./httpd ./httpd.fat sudo lipo ./httpd.fat -thin i386 -output ./httpd.i386 sudo ln -s ./httpd.i386 ./httpd This should work on intel macbook, macbook pro, imac and mac mini. As I understood the problem is modwsgi won't compile against MacPython 2.5.2 because of some weird architecture missmatch problem. But, if you compile it as a thin binary it won't play with the Apache fat binary. So this hack solves the problem. The rest is pretty standard configuration, like on any other platform.
Is there anyone who has managed to compile mod_wsgi for apache on Mac OS X Leopard?
0.379949
0
0
953
369,391
2008-12-15T19:12:00.000
-1
1
1
0
python,ruby,interpreter
12,280,987
6
false
0
0
There is pybasic (python basic), rockit-minibasic (rubybasic). To make these able to use the gui, then one has to develop extensions with kivy and shoes gui toolkits for pybasic and rockit-minibasic respectively and similarly prima gui for perlbasic if ever exists.
1
2
0
I want something simple in order to experiment/hack. I've created a lot interpreters/compilers for c and I just want something simple. A basic BASIC :D If you don't know any (I've done my google search...), yacc/bison is the only way? Thx
Is there an OpenSource BASIC interpreter in Ruby/Python?
-0.033321
0
0
2,470
370,680
2008-12-16T07:55:00.000
3
0
0
0
python,pygame,pyglet
2,477,829
5
false
0
1
Having looked at both pygame and pyglet I found pyglet easier to pick up and was able to write a simple breakout style game within a few days.
2
46
0
I've had some experience with Pygame, but there seems to be a lot of buzz around Pyglet these days. How do these two libraries compare? What would be the advantage of using one over the other, both in features and ease of use? Finally, would you say that one is more Pythonic than the other?
Differences between Python game libraries Pygame and Pyglet?
0.119427
0
0
24,875
370,680
2008-12-16T07:55:00.000
15
0
0
0
python,pygame,pyglet
4,520,448
5
false
0
1
Pyglet is good (for 2D games) if you never intend to draw any vector graphics or primitives within the game itself, and just stick to loading images from disk. It's also much cleaner because there's no need to write your own game loop and have to worry about speed and timing and responsiveness. However, if you ever have to generate graphics on-the-fly, and then save them, either as a variable or as a file, then pyglet becomes considerably more complicated because you start having to muck around with the low-level OpenGL functions. In those scenarios, pygame is much more user-friendly, with its software rendering and Surface class. Or you could use Python Imaging Library and interface it with pyglet. Obviously, for 3D games, you are going to have to muck around with OpenGL functions anyway, in which case I recommend pyglet over pygame + PyOpenGL.
2
46
0
I've had some experience with Pygame, but there seems to be a lot of buzz around Pyglet these days. How do these two libraries compare? What would be the advantage of using one over the other, both in features and ease of use? Finally, would you say that one is more Pythonic than the other?
Differences between Python game libraries Pygame and Pyglet?
1
0
0
24,875
372,042
2008-12-16T17:32:00.000
43
0
1
0
python,interface,abstract-class
16,447,106
8
false
0
0
In a more basic way to explain: An interface is sort of like an empty muffin pan. It's a class file with a set of method definitions that have no code. An abstract class is the same thing, but not all functions need to be empty. Some can have code. It's not strictly empty. Why differentiate: There's not much practical difference in Python, but on the planning level for a large project, it could be more common to talk about interfaces, since there's no code. Especially if you're working with Java programmers who are accustomed to the term.
2
612
0
What is the difference between abstract class and interface in Python?
Difference between abstract class and interface in Python
1
0
0
442,422