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
3,743,222
2010-09-18T19:44:00.000
0
0
1
0
python,datetime
66,881,576
9
false
0
0
I use data.strftime('%y-%m-%d') with lambda to transfer column to date
2
899
0
How do I convert a datetime.datetime object (e.g., the return value of datetime.datetime.now()) to a datetime.date object in Python?
How do I convert a datetime to date?
0
0
0
961,155
3,743,329
2010-09-18T20:13:00.000
5
0
0
0
python,database,django,class
3,743,351
2
true
1
0
Do not store code in the database!!! Imagine a class with a malicious __init__ method finding it's way in your "class repository" in the database. This means whoever has write access to those database tables has the ability to read any file from your web server and even nuke it's file system, since they have the ability to execute any python code on it.
1
2
0
I'm using Django and want to be able to store classes in a database for things like forms and models so that I can easily make them creatable through a user interface since they are just stored in the database as opposed to a regular file. I don't really know a whole lot about this and am not sure if this is a situation where I need to use exec in python or if there is some other way. My searches on this aren't turning up much of anything. Basically, it would just be where I do a database call and get the contents of a class, then I want to instantiate it. Any advice is appreciated on how to best do this sort of thing. EDIT: In response to the idea of a malicious __init__ in the class, these are only for things like forms or models where it is tightly controlled through validation what goes in the class, there would never be an __init__ in the class and it would be basically impossible, since I would validate everything server side, to put anything malicious in the class.
Python, how to instantiate classes from a class stored in a database?
1.2
0
0
262
3,743,532
2010-09-18T21:14:00.000
7
0
1
0
python,ruby,dictionary,symbols,language-comparisons
3,743,553
5
false
0
0
No, there is no equivalent. No you can use every hashable object as dictionary key.
1
81
0
Is there a Python equivalent to Ruby symbols? If so then what is it? If not then are we stuck with using strings as our keys in dictionaries only?
Is there a Python equivalent to Ruby symbols?
1
0
0
17,962
3,743,653
2010-09-18T21:53:00.000
1
0
1
0
python,regex,parsing,delimiter
3,743,911
4
false
0
0
I don't know your problem domain, so I don't know what forms of regex you're expecting, but it seems to me you should keep your section formatting as it is. A regex that starts with [ and ends with ] and has no square brackets in between is quite unusual. It can only match a single character. So leave the section headers as they are. Strictly speaking, they are valid regexes, but they probably aren't interesting regexes. Also, why not use ConfigParser from the standard library, and let it do the parsing for you?
1
2
0
I have a config file that the user can specify sections, and then within those section they can specify regular expressions. I have to parse this config file and separate the regex's into the various sections. Is there an easy way to delimitate a regex from a section header? I was thinking just the standard [section] regex1 regex2 But I just realized that [section] is a valid regex. So I'm wondering if there's a way I can format a section header so that it can ONLY be understood as a section header and not a regex.
easy way to determine if a string CAN'T be a valid regex
0.049958
0
0
115
3,743,812
2010-09-18T22:43:00.000
0
0
0
1
python,linux,windows,shell,osx-leopard
3,743,825
2
false
0
0
All of those operating systems should support a PATH environment variable which specifies directories that have executables that should be available everywhere. Make your script executable by chmod +x and place it into one of those directories (or add a new one to your PATH - I have ~/bin for instance). I don't know how to make new kinds of files directly executable on Windows, though, but I guess you could use a .bat file as a proxy.
1
3
0
Can someone tell me how to make my script callable in any directory? My script simply returns the number of files in a directory. I would like it to work in any directory by invoking it, instead of first being copied there and then typing python myscript.py I am using Mac OS X, but is there a common way to get it installed on Windows and Linux?
Making Python script accessible system wide
0
0
0
3,533
3,744,180
2010-09-19T01:30:00.000
1
0
1
0
java,javascript,python,methods,properties
3,744,184
9
false
0
0
Typically properties are accessors, and methods perform some sort of action. Going on this assumption, it's cheap to use a property, expensive to use a method. Foo.Bar, for example, would indicate to me that it would return a value, like a string, without lots of overhead. Foo.Bar() (or more likely, Foo.GetBar()), on the other hand, implies needing to retrieve the value for "Bar", perhaps from a database. Properties and methods have different purposes and different implications, so they should be differentiated in code as well. By the way, in all languages I know of the difference in syntax is explicit, but behind the scenes properties are often treated as simply special method calls.
3
5
0
One of my most common bugs is that I can never remember whether something is a method or a property, so I'm constantly adding or removing parentheses. So I was wondering if there was good logic behind making the difference between calling on an object's properties and methods explicit. Obviously, it allows you to have properties and methods that share the same name, but I don't think that comes up much. The only big benefit I can come up with is readability. Sometimes you might want to know whether something is a method or a property while you're looking at code, but I'm having trouble coming up with specific examples when that would be really helpful. But I am a n00b, so I probably just haven't encountered such a situation yet. I'd appreciate examples of such a situation. Also, are there other languages where the difference isn't explicit? Anyways, if you could answer, it will help me be less annoyed every time I make this mistake ^-^. UPDATE: Thanks everyone for the awesome answers so far! I only have about a week's worth of js, and 1 day of python, so I had no idea you could reference functions without calling them. That's awesome. I have a little more experience with java, so that's where I was mostly coming from... can anyone come up with an equally compelling argument for that to be the case in java, where you can't reference functions? Aside from it being a very explicit language, with all the benefits that entails :).
Why does java/javascript/python force the use of () after a method name, even if it takes no arguments?
0.022219
0
0
454
3,744,180
2010-09-19T01:30:00.000
3
0
1
0
java,javascript,python,methods,properties
3,744,187
9
false
0
0
I think you answered it yourself: One of my most common bugs is that I can never remember whether something is a method or a property, so I'm constantly adding or removing parentheses. Consider the following: if (colorOfTheSky == 'blue') vs: if (colorOfTheSky() == 'blue') We can tell just by looking that the first checks for a variable called colorOfTheSky, and we want to know if its value is blue. In the second, we know that colorOfTheSky() calls a function (method) and we want to know if its return value is blue. If we didn't have this distinction it would be extremely ambiguous in situations like this. To answer your last question, I don't know of any languages that don't have this distinction. Also, you probably have a design problem if you can't tell the difference between your methods and your properties; as another answer points out, methods and properties have different roles to play. Furthermore it is good practice for your method names to be actions, e.g. getPageTitle, getUserId, etc., and for your properties to be nouns, e.g., pageTitle, userId. These should be easily decipherable in your code for both you and anyone who comes along later and reads your code.
3
5
0
One of my most common bugs is that I can never remember whether something is a method or a property, so I'm constantly adding or removing parentheses. So I was wondering if there was good logic behind making the difference between calling on an object's properties and methods explicit. Obviously, it allows you to have properties and methods that share the same name, but I don't think that comes up much. The only big benefit I can come up with is readability. Sometimes you might want to know whether something is a method or a property while you're looking at code, but I'm having trouble coming up with specific examples when that would be really helpful. But I am a n00b, so I probably just haven't encountered such a situation yet. I'd appreciate examples of such a situation. Also, are there other languages where the difference isn't explicit? Anyways, if you could answer, it will help me be less annoyed every time I make this mistake ^-^. UPDATE: Thanks everyone for the awesome answers so far! I only have about a week's worth of js, and 1 day of python, so I had no idea you could reference functions without calling them. That's awesome. I have a little more experience with java, so that's where I was mostly coming from... can anyone come up with an equally compelling argument for that to be the case in java, where you can't reference functions? Aside from it being a very explicit language, with all the benefits that entails :).
Why does java/javascript/python force the use of () after a method name, even if it takes no arguments?
0.066568
0
0
454
3,744,180
2010-09-19T01:30:00.000
3
0
1
0
java,javascript,python,methods,properties
3,744,267
9
false
0
0
If you're having troubles, distinguishing between your properties and methods, you're probably not naming them very well. In general, your methods should have a verb in them: i.e. write, print, echo, open, close, get, set, and property names should be nouns or adjectives: name, color, filled, loaded. It's very important to use meaningful method and property names, without it, you'll find that you'll have difficulty reading your own code.
3
5
0
One of my most common bugs is that I can never remember whether something is a method or a property, so I'm constantly adding or removing parentheses. So I was wondering if there was good logic behind making the difference between calling on an object's properties and methods explicit. Obviously, it allows you to have properties and methods that share the same name, but I don't think that comes up much. The only big benefit I can come up with is readability. Sometimes you might want to know whether something is a method or a property while you're looking at code, but I'm having trouble coming up with specific examples when that would be really helpful. But I am a n00b, so I probably just haven't encountered such a situation yet. I'd appreciate examples of such a situation. Also, are there other languages where the difference isn't explicit? Anyways, if you could answer, it will help me be less annoyed every time I make this mistake ^-^. UPDATE: Thanks everyone for the awesome answers so far! I only have about a week's worth of js, and 1 day of python, so I had no idea you could reference functions without calling them. That's awesome. I have a little more experience with java, so that's where I was mostly coming from... can anyone come up with an equally compelling argument for that to be the case in java, where you can't reference functions? Aside from it being a very explicit language, with all the benefits that entails :).
Why does java/javascript/python force the use of () after a method name, even if it takes no arguments?
0.066568
0
0
454
3,744,792
2010-09-19T06:49:00.000
0
0
1
0
python,python-internals
3,809,298
4
false
0
0
I don't do any error checking here because (1) this is just for debugging/profiling/hacking (2) this exact process was 'just' completed or the code wouldn't be running. Is there a problem with this? Yes: Start a program Wait unit it imports a particular module foo.py Edit foo.py Now code that's loaded in a Python process doesn't match code found on disk. Yet another reason why disassembling the bytecode may be a better technique.
1
6
0
I'm writing some code to determine the name that an object is assigned to. This is for general debugging work and to further familiarize myself with python internals. I have it structured as a class decorator so that all instances of that class will have their names recorded if it is possible to do. The code is fairly long so I won't post it unless asked. The general technique is as follows though decorate the class' __init__ method with the code to do what I want set caller = inspect.currentframe().f_back and open inspect.getframeinfo(caller).filename and send it to ast.parse. I don't do any error checking here because (1) this is just for debugging/profiling/hacking (2) this exact process was 'just' completed or the code wouldn't be running. Is there a problem with this? find the ast.Assignment instance that causes the currently executing __init__ method to run if len(assignment.targets) == 1 then there is only one item on the left hand side, and I can get the name out of targets[0].id. In a simple form like a = Foo(), then the assignment.value is an instance of ast.Call. if it's a literal (e.g. list), then value will be that list and bail because the object I'm interested in isn't being assigned to a name. What is the best way to confirm that assignment.value.func is in fact type(obj).__call__ of the object that I'm interested in. I'm pretty sure that I'm guaranteed that It's "in there somewhere" or the code wouldn't even be running. I just need for it to be at the top level. The obvious thing to do is walk it and make sure that it doesn't contain any interior calls. Then I'm guaranteed that I have the name. (My reasoning is correct, I'm not sure if its assumptions are). This is not ideal though because if I'm interested in Foo, this could lead me to toss away a = Foo(Bar()) because I don't know if it's a = Bar(Foo()). Of course I can just check assignment.value.func.id but then somebody could have done Foobar = Foo or something so I don't want to rely on this too heavily Any help would be greatly appreciated. As always, I'm interested in any other suggestions or problems that I might be overlooking. Also, I'm really surprised that I just had to invent the 'python-internals' tag.
Accessing the name that an object being created is assigned to
0
0
0
327
3,745,724
2010-09-19T12:47:00.000
0
0
0
0
python,django,web-services
3,746,062
2
false
1
0
There are so many things like SOAPpy, XML-RPC, JSON-RPC RESTful, web service. This should give you a clue - there are different services out there that use one or more of these mechanisms. Basically all i want to know is what is the standard way of implementing web service in Python/Django and has anyone implemented in live production environment There is no single standard way of implementing a web service. This is as true for Django/Python as for other web frameworks. Different people have used Django in different ways to create a web service to suit their needs.
1
0
0
I am trying to explore more about web service in Python/Django and to be honest i am quite confused. There are so many things like SOAPpy, XML-RPC, JSON-RPC RESTful, web service. Basically all i want to know is what is the standard way of implementing web service in Python/Django and has anyone implemented in live production environment
Python / Django Web service Confusion
0
0
0
1,172
3,745,917
2010-09-19T13:48:00.000
2
0
1
1
python,windows,pyqt4,startup
3,745,929
2
true
0
0
You can just place a shortcut in the "Startup" folder, in the windows start menu.
1
2
0
I'm writing a program using python 2.6 and pyqt4. I want this program to automatically start whenever windows stars (something like uTorrent client). How do I make this work? I am using windows 7.
How to write a python program that automatically starts when windows start?
1.2
0
0
2,821
3,746,090
2010-09-19T14:29:00.000
1
1
1
0
python,deployment,packages
3,746,128
1
false
0
0
I would run the program and do proper try..except at place of first use of feature in informative message to user for what is missing (not installed db, installed but not running etc)
1
4
0
I am building a system that has dependencies such as Apache, Postgresql, and mod_wsgi. As part of my deployment process, I would like to write a sanity-checking script that tries to determine whether the server environment conforms to various assumptions, the most basic of which is whether the dependencies are installed. Checks I have considered: Check the service is responding, e.g. make an HTTP request, connect to a database, etc. Check somehow that a service is running, e.g. maybe grepping ps ax? (This seems unreliable) Check that the package is installed, e.g. through querying dpkg. These obviously go in order of decreasing specificity, the hope being that if one test fails, I might find out why by running a more specific test. But where do I stop? How many levels of specificity should I check? Are there any best practices for doing this sort of thing? Thanks!
Best practices for programmatically sanity checking environment using Python?
0.197375
0
0
533
3,746,221
2010-09-19T15:11:00.000
4
1
1
1
python,perl,awk,tcl,expect
3,747,275
4
false
0
0
ajsie asks, "Which other automation tools are you talking about?" I'll answer a different question: "which other contexts do I have in mind"? The answer: any interactive environment OTHER than a stdio one. Expect is NOT for automation of GUI points-and-clicks, for example. Expect is also not available for Win* non-console applications, even if they look as though they are character-oriented (such exist). An exciting counter-realization: Expect is for automation of wacky equipment that permits control by a term-like connection. If your diesel engine (or, more typically, telecomm iron) says it can be monitored by hooking up a telnet-like process (even through an old-style serial line, say), you're in a domain where Expect has a chance to work its magic.
2
8
0
I am amazed by how Expect (TCL) can automate a lot of things I normally could not do. I thought I could dig deeper into Expect by reading a book, but before I do that I want to ask if there are other solutions/languages that could do what Expect does? Eg. I have read that people compare Expect with Awk and also Perl. Could Awk and Perl do the same thing? How about other languages like Python and Ruby? Is Expect the de-facto automation tool or are there other solutions/languages that are more superior?
Other solutions/languages that are superior to the TCL-based Expect?
0.197375
0
0
1,532
3,746,221
2010-09-19T15:11:00.000
9
1
1
1
python,perl,awk,tcl,expect
3,747,203
4
true
0
0
There's more to it. Bluntly, the original Expect--the Tcl Expect--is the best one. It better supports "interact" and various pty eccentricities than any of its successors. It has no superior, for what it does. HOWEVER, at the same time, most Expect users exploit such a small fraction of Expect's capabilities that this technical superiority is a matter of indifference to them. In nearly all cases, I advise someone coming from Perl to use Expect.pm, someone familiar with Python to rely on Pexpect, and so on. Naive comparisons of Perl with "... Awk and also Perl" are ill-founded. In the abstract, all the common scripting languages--Lua, awk, sh, Tcl, Ruby, Perl, Python, ...--are about the same. Expect slightly but very effectively extends this common core in the direction of pty-awareness (there's a little more to the story that we can neglect for the moment). Roughly speaking, if your automation involves entering an invisible password, you want Expect. Awk and Perl do NOT build in this capability. There are other automation tools for other contexts.
2
8
0
I am amazed by how Expect (TCL) can automate a lot of things I normally could not do. I thought I could dig deeper into Expect by reading a book, but before I do that I want to ask if there are other solutions/languages that could do what Expect does? Eg. I have read that people compare Expect with Awk and also Perl. Could Awk and Perl do the same thing? How about other languages like Python and Ruby? Is Expect the de-facto automation tool or are there other solutions/languages that are more superior?
Other solutions/languages that are superior to the TCL-based Expect?
1.2
0
0
1,532
3,746,520
2010-09-19T16:34:00.000
7
0
1
0
python,vb.net
3,746,627
1
false
0
0
VB is flamed less for being easy than for the population of programmers who use it. VB is perceived as being for people one step up from writing Excel macros, often in in-house corporate environments, churning out crapware. Being a Microsoft product doesn't help. VB is also seen as being the low-end language in the Microsoft ecosystem, with an ad-hoc design. Python, on the other hand is open source, and cool because it is used in scientific applications, web startups, etc. I'm not defending these positions, just giving you the perspective I've seen. As others have said, language wars are usually pointless. Occasionally you'll get a discussion that will truly touch on interesting differences between languages, but usually not.
1
4
0
I have always wondered about this and seen this among lots of programmers. Why is a VB programmer or VB code easily dismissed as too noobish and easy while the same does not apply to Python or Python code? After all, isn't Python as easy as VB is? And it does provide drag-n-drop GUI application building also. So why is it that VB is flamed and yet Python is not? I am just wondering out of curiosity.
Why is VB flamed for being easy and yet Python is not?
1
0
0
309
3,746,790
2010-09-19T17:50:00.000
0
0
0
0
python,django,django-models
3,746,881
2
false
1
0
If you are okay with changing these setting programmatically via settings.py you should do that. However, if you want to change these settings via the Admin Console, you should use models.
1
1
0
I want to keep some global settings for my project in Django. I need to have access to these settings from the code. For example, I need to set a current theme for my site that I can set using admin console or from the code. Or I need to set a tagline that will show in the header of all pages. I suppose I should use models for keeping the settings but I can't realize how I should better do it.
How to work with settings in Django
0
0
0
108
3,747,402
2010-09-19T20:44:00.000
0
0
1
0
python,user-interface
3,747,540
1
false
0
0
uninstalling Python AND manually deleting the Python installation folder (which isn't removed by default when uninstalling) allowed me to re-install Python successfully
1
1
0
For some reason my Python IDLE interface stopped working :( I ran a some code which seems to have been buggy since i couldn't even exit it with ctrl+F6. I had to close the IDLE window down and since then it won't launch anymore. Reinstalling Python didn't make any difference....any ideas to help me get it runnig again would be great. Strangely the Python Command Line opens up fine... OS: Vista thanks, Baba
Python27 IDLE GUI stopped working
0
0
0
345
3,747,772
2010-09-19T22:36:00.000
3
0
0
1
python,google-app-engine
3,747,783
2
true
1
0
Try updating your model so that the Districts field is not required (i.e., pass required=False as a keyword parameter to the Districts field). Then the validator shouldn't complain about the existing entities and you should be able to delete the entities. Alternatively, if you know the keys for the entities you want to delete, you can delete them directly using db.delete() without ever needing to fetch them in the first place. You might even be able to use the datastore viewer from the Dashboard to delete them (if you don't have many entities to delete, this might be easiest).
2
3
0
I am trying to delete records in the datastore. Unfortunately, whenever I try to delete the items, it gives me a BadValueError, saying Districts (one of the columns) is required. Because of an issue with the bulk loader, Districts is null for all of the rows...but I still need to clean out the datastore to try to fix the bulk loader error. What can I do?
Getting BadValueError on Google App Engine Datastore Delete
1.2
0
0
481
3,747,772
2010-09-19T22:36:00.000
0
0
0
1
python,google-app-engine
3,747,781
2
false
1
0
Change your entities/models so that Districts is no longer a required property?
2
3
0
I am trying to delete records in the datastore. Unfortunately, whenever I try to delete the items, it gives me a BadValueError, saying Districts (one of the columns) is required. Because of an issue with the bulk loader, Districts is null for all of the rows...but I still need to clean out the datastore to try to fix the bulk loader error. What can I do?
Getting BadValueError on Google App Engine Datastore Delete
0
0
0
481
3,748,720
2010-09-20T04:31:00.000
7
1
1
0
python
3,748,735
2
false
0
0
Assuming you're already familiar with another programming language: Time to learn python basics: 1 week. Total time to figure out email module: 2 days. Total time to figure out httplib module: 1 days. Total time to figure out creating database: 3 days. Total time to learn about SQL: 2 weeks. Total time to figure out that you probably don't need SQL: 1 week. Total time writing the rest of the logic in python: 1 week. Probably...
2
1
0
I have been wanting to get into Python for a while now and have accumulated quite a few links to tutorials, books, getting started guides and the like. I have done a little programming in PERL and PHP, but mostly just basic stuff. I'd like to be able to set expectations for myself, so based on the following requirements how long do you think it will take to get this app up and running? Online Collection DB Users can create accounts that are authenticated through token sent via e-mail Once logged in, users can add items to pre-created collections (like "DVD" or "Software") Each collection has it's own template with attributes (ie: DVD has Name, Year, Studio, Rating, Comments, etc) Users can list all items in collections (all DVDs, all Software), sort by various attributes Also: Yes I know there are lots of online tools like this, but I want to build it on my own with Python
Complete newbie excited about Python. How hard would this app be to build?
1
0
0
221
3,748,720
2010-09-20T04:31:00.000
0
1
1
0
python
3,748,731
2
false
0
0
Assuming that you don't write everything from the ground up and reuse basic components, this shouldn't be too hard. Probably the most difficult aspect will be authentication, because that requires domain specific knowledge and is hard to get right in any language. I would suggest starting with the basic functionality, even maybe learn how to get it up and running on App Engine, and then once you have the basic functionality, then you can deal with the business of authentication and users.
2
1
0
I have been wanting to get into Python for a while now and have accumulated quite a few links to tutorials, books, getting started guides and the like. I have done a little programming in PERL and PHP, but mostly just basic stuff. I'd like to be able to set expectations for myself, so based on the following requirements how long do you think it will take to get this app up and running? Online Collection DB Users can create accounts that are authenticated through token sent via e-mail Once logged in, users can add items to pre-created collections (like "DVD" or "Software") Each collection has it's own template with attributes (ie: DVD has Name, Year, Studio, Rating, Comments, etc) Users can list all items in collections (all DVDs, all Software), sort by various attributes Also: Yes I know there are lots of online tools like this, but I want to build it on my own with Python
Complete newbie excited about Python. How hard would this app be to build?
0
0
0
221
3,749,270
2010-09-20T07:04:00.000
0
0
0
1
python,header,exe
3,749,339
3
false
0
0
Of course it is possible to write a Python script to retrieve header information from an XYZ file. Three simple steps: (1) Find docs for the header part of an XYZ file; read them. (2) Read the docs for the Python struct module or ctypes module or both. (3) Write and test the script. Which step are you having trouble with?
1
2
0
I was wondering whether it would be possible to write a python script that retrieves header information from an .exe file. I tried googling but didn't really find any results that were usable. Thanks. Sept
Retrieve header information from exe
0
0
0
3,428
3,749,729
2010-09-20T08:26:00.000
0
1
0
0
python,code-coverage
3,749,902
2
false
0
0
I don't know how you can check for inter-language unit test coverage. You will have to tweak the framework yourself to achieve something like this. That said, IMHO this is a wrong approach to take for various reasons. Inter-language disqualifies the tests from being described as "unit". These are functional tests. and thereby shouldn't care about code coverage (See @Ned's comment below). If you must (unit) test the Python code then I suggest that you do it using Python. This will also solve your problem of checking for test coverage. If you do want to function test then it would be good idea to keep Python code coverage checks away from Java. This would reduce the coupling between the Java and Python code. Tests are code after all and it is usually a good idea to reduce coupling between parts.
1
0
0
I have a python script which generates some reports based on a DB. I am testing the script using java Db Units which call the python script. My question is how can I verify the code coverage for the python script while I am running the DB Units?
While running some java DB Unit tests which call a python script how can I test the code coverage for the python script?
0
0
0
172
3,752,154
2010-09-20T13:58:00.000
0
0
1
0
python
3,777,996
1
true
1
0
should be 'className' in IE...
1
0
0
I wrote the sentence as follows: allLinkValues = ie.getLinksValue('class') but the return values are all None, don't know why...
how to get the value of the 'class' attribute in a link?
1.2
0
0
34
3,753,612
2010-09-20T16:50:00.000
2
0
0
0
python,winapi,pywin32,windows
3,762,323
2
false
0
1
So far the only possible solution I see is to use SetWindowsHookEx. Pywin32 doesn't interface this, so I think I'll have to do something like this: Write a C extension module. It has a function like setCallback which takes a python function to be called when the drag event happens. Write a C DLL that contains the actual hook into windows. This DLL will somehow have to call the python function that is currently set. I'm not sure how to do these, or if it's correct, though..
1
2
0
Is there a way to detect when a window that doesn't belong to my application is being dragged in windows using python/pywin32? I want to set it up so that when I drag a window whose title matches a pattern near the desktop edge, it snaps to the edge when the mouse is let go. I could write code to snap all windows with that title to the desktop whenever the mouse is released, but I want to only move the particular window that was being dragged.
python+win32: detect window drag
0.197375
0
0
1,517
3,753,982
2010-09-20T17:47:00.000
1
1
0
0
java,python,email,scheduling
3,754,181
6
false
0
0
I don't think standard SMTP protocol has such a feature, so if you want to be platform-independent, you will have to search for another solution. How about writing your message to a queue (local database, for example) with a timestamp and then have some program watching it periodically and send pending emails out? Is the delay an exact timedelta or is it "1-2 hours later"? If it is the latter, than you can have an hourly job (cronjob starting every hour or a background job sleeping for an hour), which would then send out the emails.
2
1
0
I'm writing an application and I'd like it to somehow schedule an email to be sent at a later date (likely an hour after it is run). The programming language will be Python or Java. Any open-source tools available for that purpose? EDIT: I forgot to mention it's to be run after a test run, so the application will already be down and I believe the Quartz solution wouldn't work. Would this be possible? Ideally, I'd like to hear that SMTP protocol has some hidden stuff that allows this, and would just require adding some flag to the message and email providers would interpret as to having to send them later.
Scheduling a time in the future to send an email in Java or Python
0.033321
0
0
4,238
3,753,982
2010-09-20T17:47:00.000
2
1
0
0
java,python,email,scheduling
3,754,446
6
false
0
0
You can build the actual email to send, using JavaMail (with attachments and all), save it to disk, and then delegate a "mail foo@bar.com < textfilefromjavamail" to the Linux batch system. There is an "at" command which will most likely do exactly what you want.
2
1
0
I'm writing an application and I'd like it to somehow schedule an email to be sent at a later date (likely an hour after it is run). The programming language will be Python or Java. Any open-source tools available for that purpose? EDIT: I forgot to mention it's to be run after a test run, so the application will already be down and I believe the Quartz solution wouldn't work. Would this be possible? Ideally, I'd like to hear that SMTP protocol has some hidden stuff that allows this, and would just require adding some flag to the message and email providers would interpret as to having to send them later.
Scheduling a time in the future to send an email in Java or Python
0.066568
0
0
4,238
3,754,848
2010-09-20T19:33:00.000
1
1
0
1
python,permissions
3,754,917
3
false
0
0
Try cp -a from_dir to_dir. It will maintain the permissions from the first directory.
1
1
0
I'm curious how to copy the permission from directory to another. Any idea? Thanks
How to copy directory permissions
0.066568
0
0
1,862
3,755,493
2010-09-20T21:03:00.000
3
0
1
0
.net,python,ironpython
3,755,511
1
true
0
0
you need to deploy the python libraries you're referencing along with your dll. it wont be included statically in there for you.
1
1
0
If I reference the Python Standard Library using IronPython do I have to deploy any Python related libraries or runtimes along with my .net dll? Or, can I just deploy the dll?
Does IronPython .net based DLL need to be deployed with Python Standard Library if it uses the Standard Library?
1.2
0
0
177
3,758,440
2010-09-21T08:16:00.000
3
1
0
0
python,ruby,twitter
3,758,455
4
false
1
0
I know of twissandra which is an open source clone. Of course I doubt it meets your need of feature rich implementations.
1
6
0
Is there any production ready open source twitter clones written in Ruby or Python ? I am more interested in feature rich implementations, not just bare bones twitter like messages (e.g.: APIs, FBconnect, Notifications, etc) Thanks !
Open source Twitter clone (in Ruby/Python)
0.148885
0
0
2,578
3,758,468
2010-09-21T08:20:00.000
1
0
0
0
python,wxpython
3,758,497
1
true
0
1
I think you could do 2 progress bars, one for files, and second for line in just read file. This will be similar to copy progress in TotalCommander. If you want one progress bar you could just count file sizes using os.path.getsize(path) and then show how many bytes have you processed/bytes total.
1
0
0
I have wxpython application that run over a list of files on some directory and proccess the files line by line I need to build a progress bar that show the status how records already done with wx.gauge control I need to count the number of the records before i use the wx.guage in order to build the progress bar , is this the way to do this and if yes what is the best method to count the number of lines of all the files on some directory with pyhon ?
counting records of files on directory with python
1.2
0
0
222
3,758,509
2010-09-21T08:28:00.000
9
0
0
0
python,django,customization,admin
3,759,347
2
true
1
0
Slow down. Relax. Follow the Django philosophy. You have an "app". It presents data. Focus on presentation. You have a default, built-in admin for your "app". It updates data and it's already there. If the admin app doesn't meet your needs update Forms and update Models to get close. But don't strain yourself messing with admin. Get as close as you can. But relax about it. [Also, "more intuitive admin" is sometimes not an accurate description of what you're trying to do. It could be, but I've seen some "more intuitive" that actually wasn't.] a more designed and intuitive admin interface for the client. Is this part of the app? Does the app do more than simply present data? If the app is transactional -- add, change, delete -- crud rules -- that kind of thing, then that's your app. If you want a fancy UI, that's not admin any more. There's no redirect. That's your app. It's just coding. Stop messing with admin and start writing your app. Hint: Use generic views as much as possible. Other than that, you're talking about your app, not hacking the admin stuff that already works. if you know how to hack the admin views and templates to your heart's content you are not a semi-pro Wrong. All the source is there. You can read it, also. That's what the pros do. We read the source. And we don't hack the admin app. If you have complex transactions, you have a first-class, for-real, actual application. Not default admin, but a part of your app that has forms. If you have forms, then, well, you have forms. This does not require hacking the admin app, it's just coding more of your app.
1
1
0
I am new to django and have gotten a bit stuck on trying to make the admin site work as I'd like it to. I am wondering if for making the admin functionality I want it is better to make a custom admin app with a template inheriting from admin/base_site.html, using the frontend login with a redirect when is_staff is true. The initial details that make me think this: I have a chain of foreignkeys and would like to display nested inlines on the parent admin page. I have tried using easymode, but it's got its own issues and requirements that may cause headaches later i can do without. I would like to add a function allowing the admin to add an instance of a model, which triggers the creation of instances its related models and redirects etc. This requires adding some callables at least, which I havent figured out yet how to really do with any success in the admin model, and at the moment seems easier to just quickly do this in the views.py of my own app rather than trying to toy with the admin views. In general, creating a custom admin app (using a is_staff=true redirect on the FrontEnd login) seems more flexible in the long run, and will result in a more designed and intuitive admin interface for the client - so I suppose my question is, what are the semi-pros doing? (if you know how to hack the admin views and templates to your heart's content you are not a semi-pro :) ) Thanks for any advice you can offer, Im still getting my feet wet and this kind of advice could save me alot of time and headache.
Customizing Django Admin Interface functionality
1.2
0
0
4,748
3,758,648
2010-09-21T08:48:00.000
13
0
0
0
python,pyqt,pyside
3,761,216
1
true
0
1
u need to import QtCore so the code will look like this : self.setWindowFlags(QtCore.Qt.FramelessWindowHint) whenever you see Qt.something put in mind that they are talking about the Qt class inside QtCore module . hope this helps
1
7
0
I've been looking for how to do this and I've found places where the subject comes up, but none of the suggestions actually work for me, even though they seem to work out okay for the questioner (they don't even list what to import). I ran across self.setWindowFlags(Qt.FramelessWindowHint) but it doesn't seem to work regardless of the import I try (QtGui.FramelessWindowHint, QtCore.FramelessWindowHint, etc.). Any ideas?
Setting window style in PyQT/PySide?
1.2
0
0
6,028
3,758,658
2010-09-21T08:49:00.000
1
0
0
0
javascript,jquery,python,matplotlib,hyperlink
3,759,346
2
false
0
0
You can do this with an imagemap or HTML element overlay controlled by JavaScript/jQuery. Essentially, send your chart data to the page along with the chart image, and use JS to create the elements with the links according to the specification of the data. It's a bit harder than the bar graphs I've done this to before, but should work fine.
1
3
0
I want to do a pie chart in matplotlib. This pie chart will be a representation of two variables: male and female. That's easy to do :) What I would like to do next, I'm not even sure if it's possible to do with matplotlib, I would like to make these two variables clickable so if I click on male, I would see another page with information about this, same thing with female. Image map isn't a solution since this variables may change in the future. Anyone has any idea how to do this? If it's possible with matplotlib or what program would you recommend. Thank you!
how to create hyperlink in piechart
0.099668
0
0
1,491
3,759,003
2010-09-21T09:37:00.000
0
0
0
0
python,django,google-app-engine,django-models,google-cloud-datastore
3,808,459
3
true
1
0
Two possible solutions: Check if the reference still exists, before you access it: if not obj.reference: # Referenced entity was deleted When you delete a model object that may be referenced, query all models that might reference it, and set their reference property to None.
3
1
0
I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that. Can someone please suggest how that can be done? Thanks in advance.
Django Google app engine reference issues
1.2
0
0
249
3,759,003
2010-09-21T09:37:00.000
0
0
0
0
python,django,google-app-engine,django-models,google-cloud-datastore
3,759,035
3
false
1
0
When I have the same problem ago, I could not find a general solution. The only way I found is to do try/except for every reference property. If you find another answer post it here.
3
1
0
I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that. Can someone please suggest how that can be done? Thanks in advance.
Django Google app engine reference issues
0
0
0
249
3,759,003
2010-09-21T09:37:00.000
1
0
0
0
python,django,google-app-engine,django-models,google-cloud-datastore
3,808,505
3
false
1
0
You could also just set a flag, say deleted, on the entity you're deleting, and then leave it in the datastore. This has the advantage of avoiding all referential integrity problems in the first place, but it comes at the cost of two main disadvantages: All your existing queries need to be changed to deal with entities that have the deleted property set, either by omitting them from the result set or by special casing them somehow. "Deleted" data stays in the datastore; this can bloat the datastore, and also may not be an option for sensitive information. This doesn't really solve your problem at all, but I thought I'd mention it for completeness's sake.
3
1
0
I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that. Can someone please suggest how that can be done? Thanks in advance.
Django Google app engine reference issues
0.066568
0
0
249
3,759,021
2010-09-21T09:39:00.000
2
0
0
1
python,google-app-engine
3,759,934
1
true
1
0
No. An entity's Key is composed of the application ID, the Kind, the path of the parent entity (if any) and either a key name or an auto-generated ID. It's not possible to have both. The entire Key is the "primary key".
1
0
0
I'm building a facebook app, and my users table's keyName is set to the Uid of the facebook user. I found this to be efficient because I can use db.Key.from_path() to efficiently query the datastore for a particular user instead of doing a query (where uid = x, limit = 1). This is actually my first time using key names. But when I did this in the sdk, the key().id() is set to None. Is there a way have an id as well? I'd like an id for use as a primary key is because it's shorter and an integer which makes it faster when I'm storing users in a listProperty (i.e a seperate Buddies entity with a list of friends the user has in the app). I hope this makes sense :) thanks a ton!
is it possible to have keyname and an id for an entity in Appengine?
1.2
0
0
68
3,760,714
2010-09-21T13:25:00.000
1
0
1
0
python,user-interface
3,762,679
4
false
0
0
I Think the latest Tkinter version offers native look for Macos. WxPython and QT offers native look for macos,windows and linux. GTK is abit ugly and prone to crashes on mac cause of the X11 implentation there. Of course you could build your own GUI , that something I am trying to do with pygame.Let me clarify , I am not making a GUI library just GUI for my own application. I am making the graphics in the 3d app Blender. My vote for Generic GUI goes to wxPython, tried it, looks great, easy to use and works like a charm across platforms. You will also find tons of info about it. Integrates well with opengl so if you want to do extreme guis on it , it can do them.
1
7
0
Last time I saw, GUIs in Python were extremely ugly, how's it today? (saw some beautiful images on google images, but I don't know if are really Python's)
How's Python GUI development today (Sep/2010)?
0.049958
0
0
1,095
3,761,655
2010-09-21T15:07:00.000
0
0
1
0
java,python,timezone,data-processing
3,764,242
3
false
0
0
In my experience with this, we've rolled the data up into hourly (or fifteen minute) buckets during the nightly run. Then you can have the user requests grab the relevant buckets based on the time zone they are using for their report.
1
2
0
curious how people have solved this problem... I have a series of jobs that run overnight that roll up reports based on that day's data for customers. They're now asking for timezone support. One of the reports is.. you had x number of orders last night, however last night could be different depending on timezone. What is the best way to organize or process the data so timezones are taking into account to make that job easier? thanks
How do you handle timezones for data processing?
0
0
0
881
3,761,994
2010-09-21T15:45:00.000
2
1
0
0
c++,python,linear-algebra
3,762,217
5
false
0
0
I don't have directly applicable experience, but the scipy/numpy operations are almost all implemented in C. As long as most of what you need to do is expressed in terms of scipy/numpy functions, then your code shouldn't be much slower than equivalent C/C++.
2
4
1
I'm writing an application where quite a bit of the computational time will be devoted to performing basic linear algebra operations (add, multiply, multiply by vector, multiply by scalar, etc.) on sparse matrices and vectors. Up to this point, we've built a prototype using C++ and the Boost matrix library. I'm considering switching to Python, to ease of coding the application itself, since it seems the Boost library (the easy C++ linear algebra library) isn't particularly fast anyway. This is a research/proof of concept application, so some reduction of run time speed is acceptable (as I assume C++ will almost always outperform Python) so long as coding time is also significantly decreased. Basically, I'm looking for general advice from people who have used these libraries before. But specifically: 1) I've found scipy.sparse and and pySparse. Are these (or other libraries) recommended? 2) What libraries beyond Boost are recommended for C++? I've seen a variety of libraries with C interfaces, but again I'm looking to do something with low complexity, if I can get relatively good performance. 3) Ultimately, will Python be somewhat comparable to C++ in terms of run time speed for the linear algebra operations? I will need to do many, many linear algebra operations and if the slowdown is significant then I probably shouldn't even try to make this switch. Thank you in advance for any help and previous experience you can relate.
Python vs. C++ for an application that does sparse linear algebra
0.07983
0
0
3,064
3,761,994
2010-09-21T15:45:00.000
1
1
0
0
c++,python,linear-algebra
3,762,759
5
false
0
0
Speed nowdays its no longer an issue for python since ctypes and cython emerged. Whats brilliant about cython is that your write python code and it generates c code without requiring from you to know a single line of c and then compiles to a library or you could even create a stanalone. Ctypes also is similar though abit slower. From the tests I have conducted cython code is as fast as c code and that make sense since cython code is translated to c code. Ctypes is abit slower. So in the end its a question of profiling , see what is slow in python and move it to cython, or you could wrap your existing c libraries for python with cython. Its quite easy to achieve c speeds this way. So I will recommend not to waste the effort you invested creating these c libraries , wrap them with cython and do the rest with python. Or you could do all of it with cython if you wish as cython is python bar some limitations. And even allows you to mix c code as well. So you could do part of it in c and part of it python/cython. Depending what makes you feel more comfortable. Numpy ans SciPy could be used as well for saving more time and providing ready to use solutions to your problems / needs.You should certainly check them out. Numpy has even has weaver a tool that let you inline c code inside your python code, just like you can inline assembly code inside your c code. But i think you would prefer to use cython . Remember because cython is both c and python at the same time it allows you to use directly c and python libraries.
2
4
1
I'm writing an application where quite a bit of the computational time will be devoted to performing basic linear algebra operations (add, multiply, multiply by vector, multiply by scalar, etc.) on sparse matrices and vectors. Up to this point, we've built a prototype using C++ and the Boost matrix library. I'm considering switching to Python, to ease of coding the application itself, since it seems the Boost library (the easy C++ linear algebra library) isn't particularly fast anyway. This is a research/proof of concept application, so some reduction of run time speed is acceptable (as I assume C++ will almost always outperform Python) so long as coding time is also significantly decreased. Basically, I'm looking for general advice from people who have used these libraries before. But specifically: 1) I've found scipy.sparse and and pySparse. Are these (or other libraries) recommended? 2) What libraries beyond Boost are recommended for C++? I've seen a variety of libraries with C interfaces, but again I'm looking to do something with low complexity, if I can get relatively good performance. 3) Ultimately, will Python be somewhat comparable to C++ in terms of run time speed for the linear algebra operations? I will need to do many, many linear algebra operations and if the slowdown is significant then I probably shouldn't even try to make this switch. Thank you in advance for any help and previous experience you can relate.
Python vs. C++ for an application that does sparse linear algebra
0.039979
0
0
3,064
3,762,199
2010-09-21T16:04:00.000
24
0
0
0
python,data-warehouse,etl
3,762,400
2
true
0
0
Yes. Just write Python using a DB-API interface to your database. Most ETL programs provide fancy "high-level languages" or drag-and-drop GUI's that don't help much. Python is just as expressive and just as easy to work with. Eschew obfuscation. Just use plain-old Python. We do it every day and we're very, very pleased with the results. It's simple, clear and effective.
2
14
0
I am working on a data warehouse and looking for an ETL solution that uses Python. I have played with SnapLogic as an ETL, but I was wondering if there were any other solutions out there. This data warehouse is just getting started. Ihave not brought any data over yet. It will easily be over 100 gigs with the initial subset of data I want to load into it.
ETL using Python
1.2
0
0
6,797
3,762,199
2010-09-21T16:04:00.000
1
0
0
0
python,data-warehouse,etl
61,763,849
2
false
0
0
You can use pyodbc a library python provides to extract data from various Database Sources. And than use pandas dataframes to manipulate and clean the data as per the organizational needs. And than pyodbc to load it to your data warehouse.
2
14
0
I am working on a data warehouse and looking for an ETL solution that uses Python. I have played with SnapLogic as an ETL, but I was wondering if there were any other solutions out there. This data warehouse is just getting started. Ihave not brought any data over yet. It will easily be over 100 gigs with the initial subset of data I want to load into it.
ETL using Python
0.099668
0
0
6,797
3,763,766
2010-09-21T19:31:00.000
1
1
0
0
c++,python,symbian
3,763,786
5
false
0
1
Python is more easy to use, but you have to know that a mobile is normally a very strict environment, so is possible that C++ be a better alternative.
2
0
0
I am interested in programming for Mobile Devices. Now I have a phone which runs Symbian S60 3rd, which is one of my motivations for programming for mobile devices. Now, my question is, which one is better to go for? Python or C++? I have a good background in C++ (ANSI), Java and C#. Thanks.
Python or C++? Programming for mobile devices
0.039979
0
0
1,838
3,763,766
2010-09-21T19:31:00.000
2
1
0
0
c++,python,symbian
3,763,991
5
true
0
1
There's a large learning curve associated with Symbian C++, if you want to do a quick prototype probably do it in Python. It depends on what you want your application to do. I believe the Symbian Python implementation was done in some Symbian developers spare time so it may not give you access to everything on the phone. Symbian C++ will give you access to almost everything. Also, Java and MIDP may be useful to you too.
2
0
0
I am interested in programming for Mobile Devices. Now I have a phone which runs Symbian S60 3rd, which is one of my motivations for programming for mobile devices. Now, my question is, which one is better to go for? Python or C++? I have a good background in C++ (ANSI), Java and C#. Thanks.
Python or C++? Programming for mobile devices
1.2
0
0
1,838
3,764,291
2010-09-21T20:39:00.000
10
0
0
0
python,networking
3,764,315
21
false
0
0
You can just try to download data, and if connection fail you will know that somethings with connection isn't fine. Basically you can't check if computer is connected to internet. There can be many reasons for failure, like wrong DNS configuration, firewalls, NAT. So even if you make some tests, you can't have guaranteed that you will have connection with your API until you try.
2
162
0
I want to see if I can access an online API, but for that, I need to have Internet access. How can I see if there's a connection available and active using Python?
How can I see if there's an available and active network connection in Python?
1
0
1
229,860
3,764,291
2010-09-21T20:39:00.000
5
0
0
0
python,networking
3,764,759
21
false
0
0
Try the operation you were attempting to do anyway. If it fails python should throw you an exception to let you know. To try some trivial operation first to detect a connection will be introducing a race condition. What if the internet connection is valid when you test but goes down before you need to do actual work?
2
162
0
I want to see if I can access an online API, but for that, I need to have Internet access. How can I see if there's a connection available and active using Python?
How can I see if there's an available and active network connection in Python?
0.047583
0
1
229,860
3,764,360
2010-09-21T20:48:00.000
10
0
1
0
python
3,764,790
4
false
0
0
Not only does __repr__() get called when you use repr(), but also in the following cases: You type obj in the shell and press enter You ever print an object in a dictionary/tuple/list. E.g.: print [u'test'] does not print ['test']
2
18
0
print OBJECT calls OBJECT.__str__(), then when OBJECT.__repr__() is called? I see that print OBJECT calls OBJECT.__repr__() when OBJECT.__str__() doesn't exist, but I expect that's not the only way to call __repr__().
When __repr__() is called?
1
0
0
13,116
3,764,360
2010-09-21T20:48:00.000
1
0
1
0
python
3,764,522
4
false
0
0
In python 2.x, `obj` will end up calling obj.__repr__(). It's shorthand for repr().
2
18
0
print OBJECT calls OBJECT.__str__(), then when OBJECT.__repr__() is called? I see that print OBJECT calls OBJECT.__repr__() when OBJECT.__str__() doesn't exist, but I expect that's not the only way to call __repr__().
When __repr__() is called?
0.049958
0
0
13,116
3,764,851
2010-09-21T22:02:00.000
1
0
0
0
python,oop
3,764,942
2
false
1
0
I would not couple my project tightly to the library, but instead try to abstract functionality and couple both using one or more objects in between. The mediator and/or facade pattern come to my mind here.
1
1
0
I'm working on a poker analysis tool with the following use case: User create Strategy class with one method: input GameState, output PokerAction User runs Analysis script, which launches a PokerGame between various Strategy subclasses (i.e. various strategies) PokerGame generates random deck PokerGame sends GameState to Strategy Strategy sends PokerAction to PokerGame PokerGame updates GameState When the game is done (managed by PokerGame), send GameResult to Analysis script User reviews output of Analysis script There's a third-party library that performs all of the PokerGame functionality. It doesn't match at all with my own modeling of the domain in some areas (e.g. card values, etc.) but performs much of the "hard-to-code" functionality that I need (i.e. the non-trivial steps 4 - 7). General design question When faced with a library like this (eliminates a lot of hard coding, but might constrain future design choices in related projects), do you tend to mold the rest of your project to the library? Do you refactor the key library to conform to your domain model? Or is it something else? Thanks, Mike
Designing my domain model around one 3rd-party library
0.099668
0
0
191
3,764,879
2010-09-21T22:10:00.000
7
0
1
0
python,recursion,functional-programming,tree,traversal
3,764,896
5
false
0
0
Pretty much the same as in every other language - in your case, you pass a reference to the parent and check if it is None. If so, you create a proper parent node.
1
1
0
I'm writing a function to traverse the user's file system and create a tree representing that directory (the tree is really a TreeView widget in Tkinter, but that's functionally a tree). The best way I can think of doing this is recursion. However, one of my cases in the function requires me to know if it is the "original" function call, in which case the files have no parent node, or if it is a "recursive" function call, i.e. a call that has been made by the function itself, so that I can give those files an appropriate parent node. Is there any way in Python to ask a function, "hey, are you recursive?" or "hey, where were you called from?"
Is there a way to tell if I'm using recursion in Python?
1
0
0
281
3,765,178
2010-09-21T23:17:00.000
15
0
1
1
python,windows
3,765,219
6
true
0
0
Don't tell anybody this, but I've run python/django on windows. It works all right and the performance hit isn't any worse than you would expect from windows. I used MySQL and it installed without a problem. I had to grope around to find out how to manage it (no good ol' sudo /etc/init.d/mysql restart but i eventually found a graphical interface to do what I needed.
6
17
0
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
Running python on a Windows machine vs Linux
1.2
0
0
63,443
3,765,178
2010-09-21T23:17:00.000
1
0
1
1
python,windows
3,765,246
6
false
0
0
Which software are you affraid will not work on windows, the actual web app or your development enviroment. If you mean the IDE, then I wouldn't worry about that there are very good python IDEs for windows, as for the webapp that's another discussion all together The statement that "it is very easy integrating C++ libs with python" is not accurate, there are many ways of doing it and they are not all easy, I have personally only tried SWIG, but there are many other alternatives (for example Boost.Python), whoever I wouldn't believe it is as easy to get up and running with some of these tools on a windows enviromeny with out something like mingw or cygwin as at least SWIG is built with *nix in mind
6
17
0
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
Running python on a Windows machine vs Linux
0.033321
0
0
63,443
3,765,178
2010-09-21T23:17:00.000
1
0
1
1
python,windows
3,765,233
6
false
0
0
Shouldn't be a problem. Some people even host Python+Django on Windows.
6
17
0
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
Running python on a Windows machine vs Linux
0.033321
0
0
63,443
3,765,178
2010-09-21T23:17:00.000
1
0
1
1
python,windows
3,765,227
6
false
0
0
Python program is very easily portable. Most of the time your code will work on any platform that have the appropriate version of python. One point to be aware of though, is file path handling. Linux, Windows, Macs, etc uses different path schemes, so you shouldn't be handling them as strings; instead use os.path functions to join, split, etc. There is ultimately some slight performance difference with regard to timing, threading, processing, I/O, but they're nothing to worry about. Integrating Python and C++ is easy; the only problem is in the C++ side, i.e. you will have to recompile the C++ code.
6
17
0
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
Running python on a Windows machine vs Linux
0.033321
0
0
63,443
3,765,178
2010-09-21T23:17:00.000
9
0
1
1
python,windows
3,765,244
6
false
0
0
I've been working Py on both Windows and Linux. I favor Linux because of several things: virtualenvs - once you start working with virtualenvs, there is no turning back. SHELL - CMD is very frustrating when executing python/management commands in django. Also, you should add python.exe every time :). ipython works better on Linux. GeoDjango doesn't work on Vista/7 last time i checked. I spent 3 days trying to set it up. Just for comparison, i set GeoDjango-able development environment in 20 minutes in Linux. Linux is free :) Although there is no visible performance impact or incompatibility when working python cross-platform, the benefits of Linux for python development outweigh Windows by a lot. It's a lot more comfortable and definitely will boost your productivity. ... IMHO Linux is the smart choice for Python development.
6
17
0
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
Running python on a Windows machine vs Linux
1
0
0
63,443
3,765,178
2010-09-21T23:17:00.000
14
0
1
1
python,windows
3,765,742
6
false
0
0
but afraid the software may not work well on a windows box. Your software will work. The Windows OS may not work as you hope. But that's Windows, not Python. We develop 100% on Windows. We completely test: Unit test, integration test and user acceptance test on Windows. 100%. We deploy for production 0% on Windows, 100% on Linux. We have a few (less than 6) differences in the unit tests that are Windows-specific. The application has no changes. It works with Apache or not. It works with SQLite or MySQL.
6
17
0
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
Running python on a Windows machine vs Linux
1
0
0
63,443
3,765,496
2010-09-22T00:37:00.000
0
0
0
0
python,macos,user-interface,wxpython
3,765,854
1
true
0
1
I was thinking maybe a class decorator, but this is functionality that will be added at runtime, due to the dynamic nature of python. I don't understand why this makes you "a little stumped". The class decorator executes just after the end of the class statement -- yes, that's "at runtime", but, so is the clqss statement itself, all the def statement in it for its methods, and so forth. By the time you instantiate any of the classes thus decorated, the decorator will have run and so the class you're instantiating will have been modified accordingly by the decorator's code. Can you please give a small example of why this isn't working for you?
1
0
0
It's my understanding that in wxPython in OSX, ⌘+w support for closing wx.Window objects. In order to add it, I've had to bind to wx.EVT_KEY_DOWN, checking for event.MetaDown() and event.KeyCode == 'W' explicitly. In my app, I need to have all windows and dialogs support this. I'm still in the process of layout out my GUI, but I got to thinking, and I'm wondering what the best way to add this support to an existing class easily is. I tried out Multiple Inheritance, but it didn't seem to be working (my event handler never got called). I was thinking maybe a class decorator, but this is functionality that will be added at runtime, due to the dynamic nature of python. So I'm a little stumped. PS: I know 'best' is subjective, but I'm honestly looking for anything here that might work that's not an exorbitant amount of code.
Command+W Support in wxPython
1.2
0
0
93
3,765,897
2010-09-22T02:23:00.000
2
0
1
0
python,multithreading,sigint
3,765,907
1
false
0
0
Only the main tread can handle signals. Just make all your threads "daemonic" ones (set the thread object's .daemon property to True before you start the thread) to ensure the threads terminate when the main thread does.
1
4
0
I have a multithreaded program and use the signal.signal(SIGINT,func) to kill all threads when ctrl c is pressed. The question I have is this: I have to call signal.signal(...) from main in python. Do I have to call that on a loop or can I just set it once and whenever the user presses ctrl c, the signal will be caught?
Signal handler, python
0.379949
0
0
409
3,768,019
2010-09-22T09:44:00.000
4
0
0
1
python,wsgi
3,768,227
3
true
0
0
The software uses UDP to send sequential updates to a given set of variables in (near) real-time (updates every 5-10 ms). thus, I do not need to capture all UDP data -- it is sufficient that the latest update is retrieved What you must do is this. Step 1. Build a Python app that collects the UDP data and caches it into a file. Create the file using XML, CSV or JSON notation. This runs independently as some kind of daemon. This is your listener or collector. Write the file to a directory from which it can be trivially downloaded by Apache or some other web server. Choose names and directory paths wisely and you're done. Done. If you want fancier results, you can do more. You don't need to, since you're already done. Step 2. Build a web application that allows someone to request this data being accumulated by the UDP listener or collector. Use a web framework like Django for this. Write as little as possible. Django can serve flat files created by your listener. You're done. Again. Some folks think relational databases are important. If so, you can do this. Even though you're already done. Step 3. Modify your data collection to create a database that the Django ORM can query. This requires some learning and some adjusting to get a tidy, simple ORM model. Then write your final Django application to serve the UDP data being collected by your listener and loaded into your Django database.
1
6
0
I am currently working on exposing data from legacy system over the web. I have a (legacy) server application that sends and receives data over UDP. The software uses UDP to send sequential updates to a given set of variables in (near) real-time (updates every 5-10 ms). thus, I do not need to capture all UDP data -- it is sufficient that the latest update is retrieved. In order to expose this data over the web, I am considering building a lightweight web server that reads/write UDP data and exposes this data over HTTP. As I am experienced with Python, I am considering to use it. The question is the following: how can I (continuously) read data from UDP and send snapshots of it over TCP/HTTP on-demand with Python? So basically, I am trying to build a kind of "UDP2HTTP" adapter to interface with the legacy app so that I wouldn't need to touch the legacy code. A solution that is WSGI compliant would be much preferred. Of course any tips are very welcome and MUCH appreciated!
How to serve data from UDP stream over HTTP in Python?
1.2
0
1
4,771
3,769,701
2010-09-22T13:28:00.000
-6
1
0
0
python,imaplib
3,787,209
4
false
0
0
No idea how they do it but doesn't Microsoft Outlook let you move an email from a local folder to a remote IMAP folder?
1
5
0
I am trying to use python's imaplib to create an email and send it to a mailbox with specific name, e.g. INBOX. Anyone has some great suggestion :).
How to create an email and send it to specific mailbox with imaplib
-1
0
1
18,674
3,770,394
2010-09-22T14:43:00.000
5
0
0
0
python,mysql,optimization
3,770,439
2
false
0
0
25Mb is tiny. Microscopic. SQL is slow. Glacial. Do not waste time on SQL unless you have transactions (with locking and multiple users). If you're doing "analysis", especially computationally-intensive analysis, load all the data into memory. In the unlikely event that data doesn't fit into memory, then do this. Query data into flat files. This can be fast. It's fastest if you don't use Python, but use the database native tools to extract data into CSV or something small. Read flat files and do computations, writing flat files. This is really fast. Do bulk updates from the flat files. Again, this is fastest if you use database native toolset for insert or update. If you didn't need SQL in the first place, consider the data as you originally received it and what you're going to do with it. Read the original file once, parse it, create your Python objects and pickle the entire list or dictionary. This means that each subsequent program can simply load the pickled file and start doing analysis. However. You can't easily update the pickled file. You have to create a new one. This is not a bad thing. It gives you complete processing history. Read the original file once, parse it, create your Python objects using shelve. This means you can update the file. Read the original file once, parse it, create your Python objects and save the entire list or dictionary as a JSON or YAML file. This means that each subsequent program can simply load the JSON (or YAML) file and start doing analysis. However. You can't easily update the file. You have to create a new one. This is not a bad thing. It gives you complete processing history. This will probably be slightly slower than pickling. And it will require that you write some helpers so that the JSON objects are dumped and loaded properly. However, you can read JSON (and YAML) giving you some advantages in working with the file.
1
2
0
I am building an application with objects which have their data stored in mysql tables (across multiple tables). When I need to work with the object (retrieve object attributes / change the attributes) I am querying the sql database using mysqldb (select / update). However, since the application is quite computation intensive, the execution time is killing me. Wanted to understand if there are approaches where all of the data is loaded into python, the computations / modifications are done on those objects and then subsequently a full data update is done to the mysql database? Will loading the data initially into lists of those objects in one go from the database improve the performance? Also since the db size is close to around 25 mb, will it cause any memory problems. Thanks in advance.
Optimizing Python Code for Database Access
0.462117
1
0
1,287
3,772,260
2010-09-22T18:02:00.000
48
0
0
0
python,django,ipython
26,771,173
12
false
1
0
My solution to it is I write the code and save to a file and then use: python manage.py shell < test.py So I can make the change, save and run that command again till I fix whatever I'm trying to fix.
2
108
0
I am working with Django and use Django shell all the time. The annoying part is that while the Django server reloads on code changes, the shell does not, so every time I make a change to a method I am testing, I need to quit the shell and restart it, re-import all the modules I need, reinitialize all the variables I need etc. While iPython history saves a lot of typing on this, this is still a pain. Is there a way to make django shell auto-reload, the same way django development server does? I know about reload(), but I import a lot of models and generally use from app.models import * syntax, so reload() is not much help.
How to reload modules in django shell?
1
0
0
52,169
3,772,260
2010-09-22T18:02:00.000
25
0
0
0
python,django,ipython
3,816,813
12
false
1
0
It seems that the general consensus on this topic, is that python reload() sucks and there is no good way to do this.
2
108
0
I am working with Django and use Django shell all the time. The annoying part is that while the Django server reloads on code changes, the shell does not, so every time I make a change to a method I am testing, I need to quit the shell and restart it, re-import all the modules I need, reinitialize all the variables I need etc. While iPython history saves a lot of typing on this, this is still a pain. Is there a way to make django shell auto-reload, the same way django development server does? I know about reload(), but I import a lot of models and generally use from app.models import * syntax, so reload() is not much help.
How to reload modules in django shell?
1
0
0
52,169
3,772,981
2010-09-22T19:40:00.000
0
0
1
0
python,class
3,773,003
1
true
0
0
What do you mean by use? storage[0] will give you a reference to the record. From there you can just use whatever methods main.Record exposes to access its data.
1
0
0
storage = [] ... after running program storage = [ <main.Record instance at 0x032E8530> ] inside the instance of Record are: "Model No." "Standard: Part Number" "Standard: Issue Date" "Date of Declaration" "Declaration Document Number" Question: How do I use specific data from within the Record?
Using data from a specific class in python
1.2
0
0
46
3,773,208
2010-09-22T20:10:00.000
3
0
0
0
python,django
3,773,276
1
false
1
0
There is no requirement in Django that you import modules at function scope. You can, but that is true of python generally. I'd like to see your code and error message. I don't think that your problem is due to the cause you attribute it to.
1
0
0
I always thought it was OK to just import all of your modules at the top of a view file. Then if you ever change a model name you can just edit the import at the top and not go digging through every view function that you need it imported in. Well, I just ran into an instance where I had imported a model at the top of a view file, and then used it in a function, but for some reason django threw an unbound variable error when I tried to use the model to do a query, which leads me to believe that I do need to do my imports for each function? So, my question is, what is the proper way to do it? Import everything at the top of the file or in each function as needed. Thanks
Django, where to import your modules
0.53705
0
0
81
3,773,566
2010-09-22T20:56:00.000
1
1
0
0
php,python,sockets,web-applications,tcp
3,773,702
3
false
1
0
I believe you need to close the low-level socket fairly abruptly. You won't be able to do it from Javascript. For the other languages you'll generally need to get a handle on the underlying socket object and close() it manually. I also doubt you can do this through Apache since it is Apache and not your application holding the socket. At best your efforts are likely to generate a HTTP 500 error which is not what you're after.
1
8
0
I'm sure you've seen the "the connection was reset" message displayed when trying to browse web pages. (The text is from Firefox, other browsers differ.) I need to generate that message/error/condition on demand, to test workarounds. So, how do I generate that condition programmatically? (How to generate a TCP RST from PHP -- or one of the other web-app languages?) Caveats and Conditions: It cannot be a general IP block. The test client must still be able to see the test server when not triggering the condition. Ideally, it would be done at the web-application level (Python, PHP, Coldfusion, Javascript, etc.). Access to routers is problematic. Access to Apache config is a pain. Ideally, it would be triggered by fetching a specific web-page. Bonus if it works on a standard, commercial web host. Update: Sending RST is not enough to cause this condition. See my partial answer, below. I've a solution that works on a local machine, Now need to get it working on a remote host.
How do I generate a connection reset programatically?
0.066568
0
0
3,959
3,774,108
2010-09-22T22:30:00.000
5
1
1
0
c++,python,scripting,lua,embedded-language
3,774,415
4
false
0
0
Having incorporated Lua in one of my C projects myself, I'll suggest Lua, as this is easier. But that depends on what your scripting language needs to be capable of. Lua rose to the de-facto scripting language of games. If you need advanced scripting capabilities, you might use Python, but if it's just for easy scripting support, take Lua. From what I've seen, Lua is easier to learn for newbees, that aren't used to scripting. I'd argue, that Lua is lighter, if you need to have external packages, you can add them, but the point is, the atomic part of Lua, is much smaller than that of Python.
2
16
0
For a project I'm currently working on, I'm looking to embed a scripting engine into my C++ code to allow for some extensibility down the line. The application will require a fair amount of text processing and the use of regular expressions within these scripts. I know Lua is generally the industry darling when it comes to embedded scripting, but I also know it doesn't support regular expressions (at least out of the box). This is causing me to lean toward python for my language to embed, as it seems to have the best support behind Lua and still offers powerful regex capabilities. Is this the right choice? Should I be looking at another language? Is there a reason I should give Lua a second look?
Python vs Lua for embedded scripting/text processing engine
0.244919
0
0
9,483
3,774,108
2010-09-22T22:30:00.000
4
1
1
0
c++,python,scripting,lua,embedded-language
3,774,148
4
false
0
0
dont forget the grand-daddy of them all - tcl there is a c++ wrapper for tcl which makes it incredibly easy to embed i am using it in a current project in previous (c#) project I used lua over python. In older c# projects I had used python; I chose lua because the syntax is more normal for average scripter (used to vbscript or javascript). However I will change back to (iron)python for next c# project; lua is just too obscure For c++ I will always use tcl from now on EDIT: My new favorite is jint (.net javascriptt interpreter) v easy to use, nice interface. And nobody can complain about the language given that js is the cool language at the moment
2
16
0
For a project I'm currently working on, I'm looking to embed a scripting engine into my C++ code to allow for some extensibility down the line. The application will require a fair amount of text processing and the use of regular expressions within these scripts. I know Lua is generally the industry darling when it comes to embedded scripting, but I also know it doesn't support regular expressions (at least out of the box). This is causing me to lean toward python for my language to embed, as it seems to have the best support behind Lua and still offers powerful regex capabilities. Is this the right choice? Should I be looking at another language? Is there a reason I should give Lua a second look?
Python vs Lua for embedded scripting/text processing engine
0.197375
0
0
9,483
3,774,772
2010-09-23T01:21:00.000
2
1
0
1
python,cron,package,execute,at-job
3,774,794
4
false
0
0
type man at, it will explain how to use it. Usage will slighty differ from system to system, so there's no use to tell you here exactly.
1
2
0
When I try to use cron to execute my python script in a future time, I found there is a command at, AFAIK, the cron is for periodically execute, but what my scenario is only execute for once in specified time. and my question is how to add python script to at command, also it there some python package for control the at command My dev os is ubuntu 10.04 lucid,and my product server is ubuntu-server 10.04 lucid version. in fact, I want through python script add python script tasks to at command, which file's change can effect at command add or remove new jobs
How to use at command to set python script execute at specified time
0.099668
0
0
2,030
3,776,665
2010-09-23T08:47:00.000
11
0
1
0
python,python-3.x,python-2.x
3,776,824
1
true
0
0
Write your code entirely against 2.x, targeting the most recent version in the 2.x series. In this case, it's probably going to remain 2.7. Run it through 2to3, and if it doesn't pass all of its unit tests, fix the 2.x version until the generated 3.x version works. Eventually, when you want to drop 2.x support, you can take the generated 3.x version and start modifying it directly. Until then, only modify the 2.x version. This is the workflow highly recommended by the people who worked on 2to3. Unfortunately I don't remember offhand the link to the document I gleaned all of this from.
1
9
0
I've written a pure-Python module for Python 3.0/3.1 which I'd also like to make it compatible with 2.x (probably just 2.6/2.7) in order to make it available to the widest possible audience. The module is concerned with reading and writing a set of related file formats, so the differences between 2.x and 3.x versions would be slight — e.g. io.BytesIO instead of StringIO.StringIO — but not all of them are easily handled via try/except blocks, such as setting metaclasses. What's the correct way to handle this? Two nearly-identical codebases which must be kept in sync or one codebase sprinkled with feature detection? A single, clean codebase plus 2to3 or 3to2?
Writing a module for both Python 2.x and 3.x
1.2
0
0
444
3,778,043
2010-09-23T11:52:00.000
5
0
0
0
python,image-processing
3,778,086
1
false
0
1
Your target image size has a different aspect ratio to that of the original. The original is 2:1 but the target is 4:3. You can resize preserving the aspect ratio, but depending on which dimension you choose you'll either get an image that's 400 x 200 or 600 x 300. If you need the image to be 400 x 300 then you'll need to resize to 400 x 200 and then add border to each side or 600 x 300 and add the border to the top and bottom.
1
0
0
I have an image having dimension 1000*500 I want to make it of 400*300 But My image should not looked distorted. http://www.daniweb.com/forums/thread295652.html - i used this as a reference. But My image get distorted.
i want a to resize an image but without distortion
0.761594
0
0
1,120
3,780,094
2010-09-23T15:47:00.000
0
0
1
1
python,file,relative-path
3,780,153
4
false
0
0
Put it in a well known directory (/usr/lib/yourproject/ or ~/lib or something similar), or have it in a well known relative path based on the location of your source files that are using it.
2
0
0
I have a python module that is shared among several of my projects (the projects each have a different working directory). One of the functions in this shared module, executes a script using os.spawn. The problem is, I'm not sure what pathname to give to os.spawn since I don't know what the current working directory will be when the function is called. How can I reference the file in a way that any caller can find it? Thanks!
Determining a file's path name from different working directories in python
0
0
0
165
3,780,094
2010-09-23T15:47:00.000
1
0
1
1
python,file,relative-path
3,780,160
4
true
0
0
So I just learned about the __file__ variable, which will provide a solution to my problem. I can use file to get a pathname which will be constant among all projects, and use that to reference the script I need to call, since the script will always be in the same location relative to __file__. However, I'm open to other/better methods if anyone has them.
2
0
0
I have a python module that is shared among several of my projects (the projects each have a different working directory). One of the functions in this shared module, executes a script using os.spawn. The problem is, I'm not sure what pathname to give to os.spawn since I don't know what the current working directory will be when the function is called. How can I reference the file in a way that any caller can find it? Thanks!
Determining a file's path name from different working directories in python
1.2
0
0
165
3,780,379
2010-09-23T16:14:00.000
0
1
0
0
ironpython
3,780,791
1
false
0
0
Resolved. Turns out that you need to rebuild IronPython from source, with the command line options –X:Frames or –X:FullFrames.
1
0
0
I'm trying to use a module that requires sys._getframe(), which, as I understand it, is not enabled by default. I've seen a lot of material that suggests that there is a way to enable _getframe(), but I've yet to find anything that tells me how to do so. What is the proper method for enabling this function in IronPython 2.6.1? Does one even exist? Thanks in advance.
How can I enable sys._getframe in IronPython 2.6.1?
0
0
0
905
3,781,087
2010-09-23T17:41:00.000
0
0
0
1
python,unix,shell
3,786,764
7
false
0
0
If you don't want to use paramiko, then try telnetlib. You can use it to execute remote commands.
2
6
0
Is there a way that I can use Python on Windows to execute shell scripts which are located on a remote Unix machine? P.S: Sorry about the late edit. I do know of Paramiko, but I wanted to know if there is way of doing it without it. For starters, could it be done with subprocess()?
shell script remote execution using python
0
0
0
11,566
3,781,087
2010-09-23T17:41:00.000
0
0
0
1
python,unix,shell
3,781,130
7
false
0
0
You will either need to run some sort of server on the remote machine, or ssh in and do it yourself. It would not be difficult to use one of the many pre-written Python servers to listen for a client and kick off a shell script. Authentication may or may not be a problem for you; be aware that anyone else can follow the same steps you do and possibly get the same result. You don't want to allow anyone on the intarwubs to start your scripts!
2
6
0
Is there a way that I can use Python on Windows to execute shell scripts which are located on a remote Unix machine? P.S: Sorry about the late edit. I do know of Paramiko, but I wanted to know if there is way of doing it without it. For starters, could it be done with subprocess()?
shell script remote execution using python
0
0
0
11,566
3,781,454
2010-09-23T18:35:00.000
10
0
1
0
python,programming-languages
3,781,496
4
true
0
0
I'm sure you know the + function. So, what is it's type? Numbers? Well, it works for lists and strings too. It even works for every object that defines __add__. Or in some cases when one object defines __radd__. So it's hard to tell the type of this function already. But Python makes it even possible to define these methods at runtime, for example through descriptors or a metaclass. You could even define them based on user input! Because Python is so highly dynamic, it's simply impossible for the Python compiler to figure out the type of anything (besides literals) without executing the program. So even if you wrote annotations, you would gain nothing, the type checking would still occur at runtime!
2
6
0
If we know the type of variable or parameter very well, why not to declare them? I'd like to know why it's bad or not necessary. Sorry, I'm new on Python (from about 1 year) and before I was on C, VB, VB.NET and C# programming languages. With Python, I hope to have bad parameter types to be catched at compilation time. And I hope to have an IDE that suggests me every attributes of a variable at design time. May be I'm too Microsoft minded, but variable type declaration seems to be the basic for me.
why python doesn't need type declaration for python, other way what are the adv. of not declaring type?
1.2
0
0
10,558
3,781,454
2010-09-23T18:35:00.000
3
0
1
0
python,programming-languages
3,781,478
4
false
0
0
That's the nature of dynamic languages. Static typing is the Java/C# style. (And even C# can infer type using var now.) It's a tradeoff: you're exchanging type safety for flexibility at runtime.
2
6
0
If we know the type of variable or parameter very well, why not to declare them? I'd like to know why it's bad or not necessary. Sorry, I'm new on Python (from about 1 year) and before I was on C, VB, VB.NET and C# programming languages. With Python, I hope to have bad parameter types to be catched at compilation time. And I hope to have an IDE that suggests me every attributes of a variable at design time. May be I'm too Microsoft minded, but variable type declaration seems to be the basic for me.
why python doesn't need type declaration for python, other way what are the adv. of not declaring type?
0.148885
0
0
10,558
3,781,802
2010-09-23T19:23:00.000
1
0
0
0
python,mysql,django,pylons,cherrypy
3,783,714
5
false
1
0
CherryPy is the only framework I'm aware of that does real HTTP caching out of the box (but look at "beaker" for a WSGI component solution). Many of the others give you tools to store arbitrary objects in Memcached or other storage.
1
6
0
This may seem like a subjective question. But it is not (that's not the idea, at least). I'm developing an Advertising software (like AdWords, AdBrite, etc) and i've decide to use Python. And would like to use one of those well known web frameworks (Django, Cherrypy, pylons, etc). The question is: Given that it will have just a few Models (seven or eight), which has the best cache support? and What is the most efficient retrieving data from a MySQL database? Thanks!
Selecting a Python Web Framework
0.039979
0
0
2,699
3,781,873
2010-09-23T19:33:00.000
0
0
1
1
python,pywin32,python-embedding
3,782,055
1
false
0
0
I previously used py2exe to freeze the application and all the DLLs. Then use Innosetup to create an installer. Work like a charm.
1
2
0
I have python as an embedded scripting environment in my application. I supply the python bits (python26.dll, DLLs & Lib folders) with my application. All this to avoid asking users to install python (you know how it goes in big corporations). All works nice except pywin32. It installs pythoncom26.dll and pywintypes26.dll to the system32 directory. I want to keep these dlls in my Python directory. One option is to add my Python directory to the PATH env variable. But would like to avoid it for obvious reasons (windows DLL search path priorities issues). Is there a way to tell Windows (a windows API is also fine) to look at my directories to load these pywin32 dlls? From what I understand these dlls get called by Windows COM. Thanks. Edit1: Note that python is deployed embedded with my application.
pywin32 captive installation (avoid py*.dll getting installed in system32 directory)
0
0
0
573
3,782,386
2010-09-23T20:40:00.000
3
0
0
0
python,django-models,sqlalchemy,data-warehouse,olap
3,782,627
3
false
0
0
I'm using SQLAlchemy with a pretty big datawarehouse and I'm using it for the full ETL process with success. Specially in certain sources where I have some complex transformation rules or with some heterogeneous sources (such as web services). I'm not using the Sqlalchemy ORM but rather using its SQL Expression Language because I don't really need to map anything with objects in the ETL process. Worth noticing that when I'm bringing a verbatim copy of some of the sources I rather use the db tools for that -such as PostgreSQL dump utility-. You can't beat that. SQL Expression Language is the closest you will get with SQLAlchemy (or any ORM for the matter) to handwriting SQL but since you can programatically generate the SQL from python you will save time, specially if you have some really complex transformation rules to follow. One thing though, I rather modify my schema by hand. I don't trust any tool for that job.
3
10
0
We've worked hard to work up a full dimensional database model of our problem, and now it's time to start coding. Our previous projects have used hand-crafted queries constructed by string manipulation. Is there any best/standard practice for interfacing between python and a complex database layout? I've briefly evaluated SQLAlchemy, SQLObject, and Django-ORM, but (I may easily be missing something) they seem tuned for tiny web-type (OLTP) transactions, where I'm doing high-volume analytical (OLAP) transactions. Some of my requirements, that may be somewhat different than usual: load large amounts of data relatively quickly update/insert small amounts of data quickly and easily handle large numbers of rows easily (300 entries per minute over 5 years) allow for modifications in the schema, for future requirements Writing these queries is easy, but writing the code to get the data all lined up is tedious, especially as the schema evolves. This seems like something that a computer might be good at?
Python: interact with complex data warehouse
0.197375
1
0
3,376
3,782,386
2010-09-23T20:40:00.000
2
0
0
0
python,django-models,sqlalchemy,data-warehouse,olap
3,782,432
3
false
0
0
SQLAlchemy definitely. Compared to SQLAlchemy, all other ORMs look like child's toy. Especially the Django-ORM. What's Hibernate to Java, SQLAlchemy is to Python.
3
10
0
We've worked hard to work up a full dimensional database model of our problem, and now it's time to start coding. Our previous projects have used hand-crafted queries constructed by string manipulation. Is there any best/standard practice for interfacing between python and a complex database layout? I've briefly evaluated SQLAlchemy, SQLObject, and Django-ORM, but (I may easily be missing something) they seem tuned for tiny web-type (OLTP) transactions, where I'm doing high-volume analytical (OLAP) transactions. Some of my requirements, that may be somewhat different than usual: load large amounts of data relatively quickly update/insert small amounts of data quickly and easily handle large numbers of rows easily (300 entries per minute over 5 years) allow for modifications in the schema, for future requirements Writing these queries is easy, but writing the code to get the data all lined up is tedious, especially as the schema evolves. This seems like something that a computer might be good at?
Python: interact with complex data warehouse
0.132549
1
0
3,376
3,782,386
2010-09-23T20:40:00.000
6
0
0
0
python,django-models,sqlalchemy,data-warehouse,olap
3,782,509
3
false
0
0
Don't get confused by your requirements. One size does not fit all. load large amounts of data relatively quickly Why not use the databases's native loaders for this? Use Python to prepare files, but use database tools to load. You'll find that this is amazingly fast. update/insert small amounts of data quickly and easily That starts to bend the rules of a data warehouse. Unless you're talking about Master Data Management to update reporting attributes of a dimension. That's what ORM's and web frameworks are for. handle large numbers of rows easily (300 entries per minute over 5 years) Again, that's why you use a pipeline of Python front-end processing, but the actual INSERT's are done by database tools. Not Python. alter schema (along with python interface) easily, for future requirements You have almost no use for automating this. It's certainly your lowest priority task for "programming". You'll often do this manually in order to preserve data properly. BTW, "hand-crafted queries constructed by string manipulation" is probably the biggest mistake ever. These are hard for the RDBMS parser to handle -- they're slower than using queries that have bind variables inserted.
3
10
0
We've worked hard to work up a full dimensional database model of our problem, and now it's time to start coding. Our previous projects have used hand-crafted queries constructed by string manipulation. Is there any best/standard practice for interfacing between python and a complex database layout? I've briefly evaluated SQLAlchemy, SQLObject, and Django-ORM, but (I may easily be missing something) they seem tuned for tiny web-type (OLTP) transactions, where I'm doing high-volume analytical (OLAP) transactions. Some of my requirements, that may be somewhat different than usual: load large amounts of data relatively quickly update/insert small amounts of data quickly and easily handle large numbers of rows easily (300 entries per minute over 5 years) allow for modifications in the schema, for future requirements Writing these queries is easy, but writing the code to get the data all lined up is tedious, especially as the schema evolves. This seems like something that a computer might be good at?
Python: interact with complex data warehouse
1
1
0
3,376
3,782,613
2010-09-23T21:19:00.000
0
0
0
1
python,vim,autocomplete
44,201,882
3
false
0
0
That's the way my same problem i solve: before i get this problem - i was set the path only to directory and that's was wrong After i set the path Including the filename it starts work!
3
1
0
So I installed pydiction into vim for autocompleting my python code in windows. No problemo. Worked like a charm. Tried the same thing with my Ubuntu setup, creating the .vim/after/ftplugin directory in my home folder and updating the vimrc with the correct path of the pydiction dictionary but I fail every time. Why is that ? I follow the readme.txt closely , I even found a webpage that describes the process on ubuntu again repeating the same things , nothing. Each time I tab after i type "raw" while it worked in windows in ubuntu it reports "Dictionary Completion (^K^N^P) Pattern not Found". Tried other keyword , same problem. Anyone has an idea why this happens ?
Problems with Vim's Pydiction and Python in Ubuntu 10.4
0
0
0
2,092
3,782,613
2010-09-23T21:19:00.000
0
0
0
1
python,vim,autocomplete
3,788,533
3
false
0
0
Sounds like it's having a problem with your complete-dict file. I'm using Ubuntu 10.04 and it works fine for me. Make sure your complete-dict file actually has content in it, in this case make sure it has the word 'raw' in it.
3
1
0
So I installed pydiction into vim for autocompleting my python code in windows. No problemo. Worked like a charm. Tried the same thing with my Ubuntu setup, creating the .vim/after/ftplugin directory in my home folder and updating the vimrc with the correct path of the pydiction dictionary but I fail every time. Why is that ? I follow the readme.txt closely , I even found a webpage that describes the process on ubuntu again repeating the same things , nothing. Each time I tab after i type "raw" while it worked in windows in ubuntu it reports "Dictionary Completion (^K^N^P) Pattern not Found". Tried other keyword , same problem. Anyone has an idea why this happens ?
Problems with Vim's Pydiction and Python in Ubuntu 10.4
0
0
0
2,092
3,782,613
2010-09-23T21:19:00.000
1
0
0
1
python,vim,autocomplete
3,793,008
3
false
0
0
Problem has been solved, apparently gvim did not like the fact that i put the files in a ".vim" directory even though that was exactly what the instructions told me to do. I put them in my home folder pydiction.vim and complete-dictionary and now it works ok, with no issues. Now autocomplete works with any word I tried it with. I am abit confused with gvim , as the instructions said to create ".vim" directory but I have also found a vimfiles directory in a etc folder. Why vim structure is so confusing? Maybe the manual should clarify directory structure to avoid confusing. Now I use a source command to load pydiction.vim from my home folder and setup the vimrc properly to point to the new paths. At least I solved my problem myself , thanks for all replies.
3
1
0
So I installed pydiction into vim for autocompleting my python code in windows. No problemo. Worked like a charm. Tried the same thing with my Ubuntu setup, creating the .vim/after/ftplugin directory in my home folder and updating the vimrc with the correct path of the pydiction dictionary but I fail every time. Why is that ? I follow the readme.txt closely , I even found a webpage that describes the process on ubuntu again repeating the same things , nothing. Each time I tab after i type "raw" while it worked in windows in ubuntu it reports "Dictionary Completion (^K^N^P) Pattern not Found". Tried other keyword , same problem. Anyone has an idea why this happens ?
Problems with Vim's Pydiction and Python in Ubuntu 10.4
0.066568
0
0
2,092
3,783,887
2010-09-24T02:42:00.000
7
1
0
0
python,cgi,bioinformatics,biopython
3,784,056
3
true
0
0
Here are a couple of possibilities: Apache (on Unix) generally runs as a different user, and with a different environment, to python from the command line. Try making a small script that just prints out sys.version and sys.prefix, and compare the result through apache and via the command line, to make sure that you're running from the same installation of python in both environments. Is Biopython installed under your home directory, or only readable just for your normal user? Again, because apache generally runs as a different user, perhaps you don't have access to that location, so can't import it. Can you try doing import site before trying to import Biopython? Perhaps something is preventing site packages from being imported when you run through apache.
1
9
0
I have no idea what could be the problem here: I have some modules from Biopython which I can import easily when using the interactive prompt or executing python scripts via the command-line. The problem is, when I try and import the same biopython modules in a web-executable cgi script, I get a "Import Error" : No module named Bio Any ideas here?
Why can't python find some modules when I'm running CGI scripts from the web?
1.2
0
0
9,473
3,785,502
2010-09-24T08:48:00.000
2
0
0
0
python,django
3,787,861
1
true
1
0
Well I found the answer. It was quite easy actually. you just need to set the FileField value to some string and it will point to that file. The point is that the path specified should be correct otherwise you get a 404 error when trying to access it.
1
1
0
I wanted to know how is it possible in django to bind an already uploaded file (stored in the file system of server) to a Model FileField. This way I want to have my edit page of that model to prepopulate the FileField with this file. Thanks
Prepopulating a Django FileField
1.2
0
0
669
3,786,881
2010-09-24T12:07:00.000
0
0
1
0
python,methods
54,966,515
8
false
0
0
If you think of an object as being similar to a noun, then a method is similar to a verb. Use a method right after an object (i.e. a string or a list) to apply a method's action to it.
1
79
0
Can anyone, please, explain to me in very simple terms what a "method" is in Python? The thing is in many Python tutorials for beginners this word is used in such way as if the beginner already knew what a method is in the context of Python. While I am of course familiar with the general meaning of this word, I have no clue what this term means in Python. So, please, explain to me what the "Pythonian" method is all about. Some very simple example code would be very much appreciated as a picture is worth thousand words.
What is a "method" in Python?
0
0
0
215,845
3,787,405
2010-09-24T13:13:00.000
-1
1
1
0
python,caching,hash
3,787,439
3
false
0
0
The usual reason is that most objects in Python are mutable, so if the hash depends on the properties, it changes as soon as you change a property. If your class really is an immutable and (all the properties which go into the hash are immutable, too!), then you can cache the hash.
1
14
0
I've written a class whose .__hash__() implementation takes a long time to execute. I've been thinking to cache its hash, and store it in a variable like ._hash so the .__hash__() method would simply return ._hash. (Which will be computed either at the end of the .__init__() or the first time .__hash__() is called.) My reasoning was: "This object is immutable -> Its hash will never change -> I can cache the hash." But now that got me thinking: You can say the same thing about any hashable object. (With the exception of objects whose hash is their id.) So is there ever a reason not to cache an object's hash, except for small objects whose hash computation is very fast?
Is there any reason *not* to cache an object's hash?
-0.066568
0
0
2,299
3,788,198
2010-09-24T14:46:00.000
2
0
1
0
c++,python,data-structures,boost
3,793,491
2
false
0
0
Since python collections only store references to objects, not objects themselves, theres isn't much difference between having one collection with multiple indexing schemes, and just having multiple collections. You can for example have several dicts with your data, each of them using different keys to refer to them.
2
5
0
I have come to appreciate a lot boost::multi_index in C++. It happens that I would happily use something like that in Python; for scripts that process data coming out from numerical intensive applications. Is there such a thing for Python? I just want to be sure that it doesn't exist, then I would try to implement it myself. Things that won't do it for me: Wrapping boost::multi_index in Python. It simply doesn't scale. Using sqlite3 in memory. It is ugly.
Something like boost::multi_index for Python
0.197375
0
0
1,017
3,788,198
2010-09-24T14:46:00.000
1
0
1
0
c++,python,data-structures,boost
9,054,439
2
true
0
0
To answer your question of whether a similar thing exists in Python, I would say no. One useful feature of Boost.MultiIndex is that elements can be modified in-place (via replace() or modify()). Python's native dict doesn't provide such a functionality and requires the key to be immutable. I haven't seen other implementations that allow the key to be altered. So in this specific area, there's no comparable thing as Boost.MultiIndex in Python. If you only require multiple static views of your data, then I would agree with Radomir Dopieralski. You can wrap multiple dicts in your own class to provide a unified API to ensure the synchronization between different views. I don't know what you mean by "performance-aware transformations" but if you were talking about the computational complexity of the insertion/deletion operations, even with Boost.MultiIndex, "inserting an element into a multi_index_container reduces to a simple combination of elementary insertion operations on each of the indices, and similarly for deletion."
2
5
0
I have come to appreciate a lot boost::multi_index in C++. It happens that I would happily use something like that in Python; for scripts that process data coming out from numerical intensive applications. Is there such a thing for Python? I just want to be sure that it doesn't exist, then I would try to implement it myself. Things that won't do it for me: Wrapping boost::multi_index in Python. It simply doesn't scale. Using sqlite3 in memory. It is ugly.
Something like boost::multi_index for Python
1.2
0
0
1,017
3,789,220
2010-09-24T16:48:00.000
1
0
1
0
python,sockets,asyncore
3,854,614
1
true
0
0
To answer my own question: For this type of polling application it is necessary to have a small timeout value. The timeout specifies how long the internal select function blocks waiting for a socket to become active. If you are sending data frequently you need to set the timeout to a small value, so that select polls your socket for writable data at an acceptable interval. Otherwise select will block for too long before checking and can cause these kinds of delays. In the end I used a timeout of 0.05 seconds.
1
1
0
I have written a program that communicates with many servers at once using the asyncore module. For the most part I am just responding to data received from the servers, but occasionally I need to send some data "out-of-sync". With the default timeout of 30 seconds there is an obvious delay before the packet gets sent, so I have lowered the timeout to 0.1 for more responsiveness. My question is: is it a good idea performance-wise to use a timeout with such a low value, and if not, is there another more performant way of accomplishing the same thing? What's the best practice for doing this?
Python asyncore with very low timeout
1.2
0
0
800
3,789,716
2010-09-24T17:58:00.000
1
1
1
0
ironpython
3,803,617
2
false
0
0
It is not possible. The only way is to change the clr.AddReference method. As IronPython is open source it should be easy.
1
0
0
I was wondering if there was a way that you could get init code to run upon importing a .NET assembly using clr.AddReference(), in the same way that importing a python file executes the init.py code that resides in the same directory. Thanks in advance!
IronPython: how can I run init code when I import a module using clr.AddReference()?
0.099668
0
0
416
3,790,142
2010-09-24T19:04:00.000
1
0
0
0
java,python
3,790,193
14
false
1
0
If you mean to use it like you would in a Python loop, Java loops nicely with the for statement, which renders this structure unnecessary for that purpose.
1
115
0
Does Java have an equivalent to Python's range(int, int) method?
Java: Equivalent of Python's range(int, int)?
0.014285
0
0
96,489
3,791,527
2010-09-24T22:39:00.000
1
0
0
0
python,ajax,user-interface,browser
3,791,545
2
true
1
0
The closest you can get is using (ick) frames, with one frame for your bar and one for the page. That's what Google Image Search does. It can easily get broken by frame-busting scripts though.
2
1
0
Goal I want to create a web app with a horizontal GUI bar that floats with the user as they move from site to site. e.g. A user will sign into the web at the home page and then proceed to say Google to start searching for their topic. Once they are signed in and leave the web app homepage a horizontal GUI bar will appear on each page they visit until they log out. So when a user goes to Google to start searching the GUI bar will be there. When they click on a link and go to that page, the GUI bar will be there too. Known Ways I noticed apps like Get Glue and Layers.com work by having the user install browser extensions. I would like to avoid this if possible. Additionally it can not be like the Digg Bar because it only appears when a user presses the book marklet or places digg.com in front of the site/page URL. It also can't be like the Facebook or Meebo bars because it requires the web developer to already have implemented that code on their site. Closest Example The best example of what I am trying to go after is something like Google Image search where if you click an image Google will open up the site (but grayed out) with the picture hovering above it and a left side bar with image info in it. So Google opens a site with in it self. Another example might be Stumble Upon's top GUI bar. Is my idea possible with technologies like AJAX and Python?
Is there any other way besides browser extensions that one could have a GUI bar hover over any website a user visits?
1.2
0
0
115
3,791,527
2010-09-24T22:39:00.000
0
0
0
0
python,ajax,user-interface,browser
3,791,539
2
false
1
0
Is my idea possible with technologies like AJAX and Python? If the pages you want floating under the bar belong to a different domain than yours (it seems like that's what you want), then the answer is No. This is not possible with client-sided scripting alone (eg: Javascript) because of the same origin policy. What you use on the server side, Python or Ruby or whatever is irrelevant.
2
1
0
Goal I want to create a web app with a horizontal GUI bar that floats with the user as they move from site to site. e.g. A user will sign into the web at the home page and then proceed to say Google to start searching for their topic. Once they are signed in and leave the web app homepage a horizontal GUI bar will appear on each page they visit until they log out. So when a user goes to Google to start searching the GUI bar will be there. When they click on a link and go to that page, the GUI bar will be there too. Known Ways I noticed apps like Get Glue and Layers.com work by having the user install browser extensions. I would like to avoid this if possible. Additionally it can not be like the Digg Bar because it only appears when a user presses the book marklet or places digg.com in front of the site/page URL. It also can't be like the Facebook or Meebo bars because it requires the web developer to already have implemented that code on their site. Closest Example The best example of what I am trying to go after is something like Google Image search where if you click an image Google will open up the site (but grayed out) with the picture hovering above it and a left side bar with image info in it. So Google opens a site with in it self. Another example might be Stumble Upon's top GUI bar. Is my idea possible with technologies like AJAX and Python?
Is there any other way besides browser extensions that one could have a GUI bar hover over any website a user visits?
0
0
0
115
3,791,903
2010-09-25T00:26:00.000
17
0
1
0
python,python-import
3,791,936
3
false
0
0
You only need it in Python 2.5. Older versions (<= 2.4) don't support it and newer versions (>= 2.6) have it enabled by default. So if you want to support Python >= 2.5, you can simply put the from __future__ import with_statement at the beginning. For newer versions, it will simply be ignored.
1
27
0
Using python 2.6.5, I can use the with statement without calling from __future__ import with_statement. How can I tell which version of Python supports with without specifically importing it from __future__?
Which python version needs from __future__ import with_statement?
1
0
0
12,726