Q_Id
int64
2.93k
49.7M
CreationDate
stringlengths
23
23
Users Score
int64
-10
437
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
DISCREPANCY
int64
0
1
Tags
stringlengths
6
90
ERRORS
int64
0
1
A_Id
int64
2.98k
72.5M
API_CHANGE
int64
0
1
AnswerCount
int64
1
42
REVIEW
int64
0
1
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
15
5.1k
Available Count
int64
1
17
Q_Score
int64
0
3.67k
Data Science and Machine Learning
int64
0
1
DOCUMENTATION
int64
0
1
Question
stringlengths
25
6.53k
Title
stringlengths
11
148
CONCEPTUAL
int64
0
1
Score
float64
-1
1.2
API_USAGE
int64
1
1
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
15
3.72M
801,432
2009-04-29T08:28:00.000
0
0
1
0
0
c#,winforms,ironpython
0
801,447
0
5
0
false
0
0
IronRuby comes with a command line interpreter. Doesn't IronPython also have one? If so, the source code would be a good start :) Oh, and if it doesn't, be sure to look at the IronRuby interpreter, because both languages are based on the DLR and are therefore similar enough to learn from both.
1
0
0
1
I'd like to add "IDLE-like functionality" to C# WinForms application, but I don't quite have an idea how to do that and couldn't find anything useful with Google. So basically I want interactive command line interface, where user could enter some Python code and execute it (not just expressions, should be possible to define new functions). So, where to start? Are there any good tutorials or samples available?
How to create IDLE -like functionality to WinForms application
1
0
1
0
0
975
801,931
2009-04-29T11:31:00.000
5
1
0
1
0
python,architecture,containers,notifications
0
802,084
0
5
0
true
0
0
You're over-thinking this. Seriously. Python isn't C++; your concerns are non-issues in Python. Just write what makes sense in your problem domain. " Not absolutely good because of circular references." Why not? Circularity is of no relevance here at all. Bidirectional relationships are great things. Use them. Python garbage collects them just fine without any thinking on your part. What possible problem do you have with mutual (birectional) relationships? "...operate only Accounts, and within them, internally, handler operators. This one is a bit limiting because in this case I cannot pass around references to operators. " What? Your Operators are Python objects, pass all you want. All Python objects are (in effect) references, don't sweat it. What possible problem do you have with manipulating Operator objects?
2
4
0
0
I have two classes: Account and Operator. Account contains a list of Operators. Now, whenever an operator (in the list) receives a message I want to notify Account object to perform some business logic as well. I think of three alternatives on how to achieve this: 1) Hold a reference within Operator to the container [Account] object and call methods directly. Not absolutely good because of circular references. 2) Use events. As far as I know there is no built-in event handling mechanism in Python. So, this one is a bit tricky to implement. 3) Don't send messages to Operators directly. Instead, operate only Accounts, and within them, internally, handler operators. This one is a bit limiting because in this case I cannot pass around references to operators. I wonder which approach is the most advantageous from the architectural point of view. How do you usually handle this task? It would be great if you could point out snippets in Python.
Notifying container object: best practices
0
1.2
1
0
0
403
801,931
2009-04-29T11:31:00.000
3
1
0
1
0
python,architecture,containers,notifications
0
802,031
0
5
0
false
0
0
There is no "one-size-fits-all" solution for the Observer pattern. But usually, it's better to define an EventManager object where interested parties can register themselves for certain events and post these events whenever they happen. It simply creates less dependencies. Note that you need to use a global EventManager instance, which can be problematic during testing or from a general OO point of view (it's a global variable). I strongly advise against passing the EventManager around all the time because that will clutter your code. In my own code, the "key" for registering events is the class of the event. The EventManager uses a dictionary (event class -> list of observers) to know which event goes where. In the notification code, you can then use dict.get(event.__class__, ()) to find your listeners.
2
4
0
0
I have two classes: Account and Operator. Account contains a list of Operators. Now, whenever an operator (in the list) receives a message I want to notify Account object to perform some business logic as well. I think of three alternatives on how to achieve this: 1) Hold a reference within Operator to the container [Account] object and call methods directly. Not absolutely good because of circular references. 2) Use events. As far as I know there is no built-in event handling mechanism in Python. So, this one is a bit tricky to implement. 3) Don't send messages to Operators directly. Instead, operate only Accounts, and within them, internally, handler operators. This one is a bit limiting because in this case I cannot pass around references to operators. I wonder which approach is the most advantageous from the architectural point of view. How do you usually handle this task? It would be great if you could point out snippets in Python.
Notifying container object: best practices
0
0.119427
1
0
0
403
805,393
2009-04-30T05:03:00.000
0
0
0
0
0
python,sql,django,stored-procedures,django-models
0
3,675,814
0
7
1
false
1
0
I guess the improved raw sql queryset support in Django 1.2 can make this easier as you wouldn't have to roll your own make_instance type code.
2
34
0
0
I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django's ORM. Has anyone integrated SP's with Django's ORM successfully? If so, what RDBMS and how did you do it?
What is the best way to access stored procedures in Django's ORM
0
0
1
0
0
43,756
805,393
2009-04-30T05:03:00.000
6
0
0
0
0
python,sql,django,stored-procedures,django-models
0
806,302
0
7
1
false
1
0
Don't. Seriously. Move the stored procedure logic into your model where it belongs. Putting some code in Django and some code in the database is a maintenance nightmare. I've spent too many of my 30+ years in IT trying to clean up this kind of mess.
2
34
0
0
I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django's ORM. Has anyone integrated SP's with Django's ORM successfully? If so, what RDBMS and how did you do it?
What is the best way to access stored procedures in Django's ORM
0
1
1
0
0
43,756
810,055
2009-05-01T03:24:00.000
3
1
1
0
0
python
0
40,535,335
0
4
0
false
0
0
Python is very powerful language, Many big and the very high ranked websites are built on python.. Some big products of python are:- Google (extensively used) Youtube (extensively used) Disqus Eventbrite Pinterest Reddit Quora Mozilla Asana (extensively used) Dropbox (started with python, stayed with python) Even Many companies are shifting their websites from PHP to Python, Because of its efficiency, fast ability, and reliability, and availability of huge support and many good frameworks such as Django.. Moreover, I am not saying that PHP is not a good server side scripting language, But truth is that, most users are adapting python instead of PHP.
3
21
0
0
What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams. It's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller. Are there some huge companies that develop primarily in Python?
Biggest python projects
0
0.148885
1
0
0
22,280
810,055
2009-05-01T03:24:00.000
12
1
1
0
0
python
0
810,240
0
4
0
false
0
0
Among many other Python-centered companies, beyond the ones already mentioned by Unknown, I'd mention big pharma firms such as Astra-Zeneca, film studios such as Lucasfilm, and research places such as NASA, Caltech, Lawrence Livermore NRL. Among the sponsors of Pycon Italia Tre (next week in Firenze, IT -- see www.pycon.it) are Qt/Trolltech (a wholly owned subsidiary of Nokia), Google of course, Statpro, ActiveState, Wingware -- besides, of course, several Italian companies. Among the sponsors of Pycon US in Chicago in March were (of course) Google, as well as Sun Microsystems, Microsoft, Slide.com, Walt Disney Animation Studios, Oracle, Canonical, VMWare -- these are all companies who thought it worthwhile to spend money in order to have visibility to experienced Pythonistas, so presumably ones making significant large-scale use of Python (and in most cases trying to hire experienced Python developers in particular).
3
21
0
0
What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams. It's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller. Are there some huge companies that develop primarily in Python?
Biggest python projects
0
1
1
0
0
22,280
810,055
2009-05-01T03:24:00.000
8
1
1
0
0
python
0
810,992
0
4
0
false
0
0
Our project is over 30,000 lines of Python. That's probably small by some standards. But it's plenty big enough to fill my little brain. The application is mentioned in our annual report, so it's "strategic" in that sense. We're not a "huge" company, so we don't really qualify. A "huge company" (Fortune 1000?) doesn't develop primarily in any single language. Large companies will have lots of development teams, each using a different technology, depending on -- well -- on nothing in particular. When you get to "epic companies" (Fortune 10) you're looking at an organization that's very much like a conglomerate of several huge companies rolled together. Each huge company within an epic company is still a huge company with multiple uncoordinated IT shops doing unrelated things -- there's no "develop primarily in" any particular language or toolset. Even for "large companies" and "small companies" (like ours) you still have fragmentation. Our in-house IT is mostly Microsoft. Our other product development is mostly Java. My team, however, doesn't have much useful specification, so we use Python. We use python because of the duck typing and dynamic programming features. (I don't know what a dynamic type system is -- Python types are static -- when you create an object, its type can never change.) Since no huge company develops primarily in any particular language or toolset, the trivial answer to your question is "No" for any language or tool. And No for Python in particular.
3
21
0
0
What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams. It's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller. Are there some huge companies that develop primarily in Python?
Biggest python projects
0
1
1
0
0
22,280
819,355
2009-05-04T08:59:00.000
2
0
0
0
0
python,networking,ip-address,cidr
0
10,053,031
0
28
0
false
0
0
#This works properly without the weird byte by byte handling def addressInNetwork(ip,net): '''Is an address in a network''' # Convert addresses to host order, so shifts actually make sense ip = struct.unpack('>L',socket.inet_aton(ip))[0] netaddr,bits = net.split('/') netaddr = struct.unpack('>L',socket.inet_aton(netaddr))[0] # Must shift left an all ones value, /32 = zero shift, /0 = 32 shift left netmask = (0xffffffff << (32-int(bits))) & 0xffffffff # There's no need to mask the network address, as long as its a proper network address return (ip & netmask) == netaddr
1
123
0
0
Given an ip address (say 192.168.0.1), how do I check if it's in a network (say 192.168.0.0/24) in Python? Are there general tools in Python for ip address manipulation? Stuff like host lookups, ip adddress to int, network address with netmask to int and so on? Hopefully in the standard Python library for 2.5.
How can I check if an ip is in a network in Python?
0
0.014285
1
0
1
174,240
823,103
2009-05-05T02:52:00.000
1
1
1
0
0
python,profiling
0
823,117
0
4
0
false
0
0
What if you monkey-patched object's class or another prototypical object? This might not be the easiest if you're not using new-style classes.
1
3
0
0
Python is so dynamic that it's not always clear what's going on in a large program, and looking at a tiny bit of source code does not always help. To make matters worse, editors tend to have poor support for navigating to the definitions of tokens or import statements in a Python file. One way to compensate might be to write a special profiler that, instead of timing the program, would record the runtime types and paths of objects of the program and expose this data to the editor. This might be implemented with sys.settrace() which sets a callback for each line of code and is how pdb is implemented, or by using the ast module and an import hook to instrument the code, or is there a better strategy? How would you write something like this without making it impossibly slow, and without runnning afoul of extreme dynamism e.g side affects on property access?
What's the best way to record the type of every variable assignment in a Python program?
1
0.049958
1
0
0
235
825,724
2009-05-05T16:22:00.000
0
0
0
0
1
linux,ubuntu,wxpython
0
876,524
0
1
0
true
0
1
Robin Dunn himself told me that It's using the "native" GTK file dialog, just like the other apps, so there isn't anything that wx can do about it. So as a workaround I ended up installing gvfs-fuse and browsing the network through $HOME/.gvfs.. A bit klunky but it works.
1
1
0
0
I'm using wx.FileDialog in a wxPython 2.8.8.0 application, under Xubuntu 8.10.. My problem is that this dialog isn't network-aware, so I can't browse Samba shares. I see that this problem plagues other applications too (Firefox, Audacious...) so I'd like to ask where I could find informations on how to make it work. Is that dialog supposed to be already network-aware? Am I missing something? Some library maybe? Or should I write my own implementation? Many thanks!
Network-aware wx.FileDialog
0
1.2
1
0
1
276
825,909
2009-05-05T17:01:00.000
8
1
1
0
0
python,exception-handling,try-catch,runtime-error
1
826,144
0
6
0
true
0
0
I know that I can just check for root access before the import, but I'd like to know how to catch this spesific kind of error via a try/except statement for future reference. Is there any way to differentiate between this RuntimeError and others that might be raised? If the error is caused by a specific condition, then I think the easiest way to catch the error is to test for the condition, and you can raise a more specific error yourself. After all the 'error' exists before the error is thrown, since in this case its a problem with the environment. I agree with those above - text matching on an error is kind of a terrifying prospect.
1
8
0
0
I'm importing a module which raises the following error in some conditions: RuntimeError: pyparted requires root access I know that I can just check for root access before the import, but I'd like to know how to catch this spesific kind of error via a try/except statement for future reference. Is there any way to differentiate between this RuntimeError and others that might be raised?
Catch only some runtime errors in Python
0
1.2
1
0
0
24,955
826,724
2009-05-05T20:14:00.000
3
0
0
1
0
python,google-app-engine,google-cloud-datastore,custompaging
0
827,149
0
2
0
true
1
0
There is no efficient way to do this - in any DBMS. In every case, you have to at least read sequentially through the index records until you find the nth one, then look up the corresponding data record. This is more or less what fetch(count, offset) does in GAE, with the additional limitation of 1000 records. A better approach to this is to keep a 'bookmark', consisting of the value of the field you're ordering on for the last entity you retrieved, and the entity's key. Then, when you want to continue from where you left off, you can add the field's value as the lower bound of an inequality query, and skip records until you match or exceed the last one you saw. If you want to provide 'friendly' page offsets to users, what you can do is to use memcache to store an association between a start offset and a bookmark (order_property, key) tuple. When you generate a page, insert or update the bookmark for the entity following the last one. When you fetch a page, use the bookmark if it exists, or generate it the hard way, by doing queries with offsets - potentially multiple queries if the offset is high enough.
1
1
0
0
Suppose that I have the model Foo in GAE and this query: query = Foo.all().order('-key') I want to get the n-th record. What is the most efficient way to achieve that? Will the solution break if the ordering property is not unique, such as the one below: query = Foo.all().order('-color') edit: n > 1000 edit 2: I want to develop a friendly paging mechanism that shows pages available (such as Page 1, Page 2, ... Page 185) and requires a "?page=x" in the query string, instead of a "?bookmark=XXX". When page = x, the query is to fetch the records beginning from the first record of that page.
how to get the n-th record of a datastore query
0
1.2
1
0
0
845
827,295
2009-05-05T22:56:00.000
2
1
0
0
0
python,unit-testing,dbus,hal
0
827,391
0
2
0
true
0
0
If you can not mock the environment then it's probably impossible for you to write the test. If your access to HAL/D-Bus is via an object and you provide a mock instance to your test then it should be possible to emulate the necessary inputs to your test from the mock implementation.
1
2
0
0
How does one test a method that does some interactions with the local D-Bus (accessing a HAL object)? Results of tests will differ depending on the system that the test is run on, so I don't know how to provide the method reliable input. I'm working in Python, by the way.
Unit testing for D-Bus and HAL?
0
1.2
1
0
0
441
833,356
2009-05-07T07:45:00.000
0
0
0
1
0
python
0
833,364
0
2
0
false
0
0
Set the scheduled task to start the script as minimized.
2
1
0
0
I have a scheduled task which runs a python script every 10 min so it turns out that a script pops up on my desktop every 10 min how can i make it invincible so my script will work in the background ? I've been told that pythonw will do the work, but I cant figure out how to use it any help ? thanks
How to run a script without being in the tasktray?
0
0
1
0
0
109
833,356
2009-05-07T07:45:00.000
3
0
0
1
0
python
0
833,391
0
2
0
false
0
0
I've been told that pythonw will do the work, but I cant figure out how to use it Normally you just have to rename the file extension to .pyw. Then it will be executed by pythonw.
2
1
0
0
I have a scheduled task which runs a python script every 10 min so it turns out that a script pops up on my desktop every 10 min how can i make it invincible so my script will work in the background ? I've been told that pythonw will do the work, but I cant figure out how to use it any help ? thanks
How to run a script without being in the tasktray?
0
0.291313
1
0
0
109
836,992
2009-05-07T20:55:00.000
0
0
0
1
0
python,google-app-engine,transactions,google-cloud-datastore
0
838,960
0
3
0
true
1
0
After a through research, I have found that a distributed transaction layer that provides a solution to the single entity group restriction has been developed in userland with the help of some google people. But so far, it is not released and is only available in java.
1
3
0
0
in my google app application, whenever a user purchases a number of contracts, these events are executed (simplified for clarity): user.cash is decreased user.contracts is increased by the number contracts.current_price is updated. market.no_of_transactions is increased by 1. in a rdms, these would be placed within the same transaction. I conceive that google datastore does not allow entities of more than one model to be in the same transaction. what is the correct approach to this issue? how can I ensure that if a write fails, all preceding writes are rolled back? edit: I have obviously missed entity groups. Now I'd appreciate some further information regarding how they are used. Another point to clarify is google says "Only use entity groups when they are needed for transactions. For other relationships between entities, use ReferenceProperty properties and Key values, which can be used in queries". does it mean I have to define both a reference property (since I need queriying them) and a parent-child relationship (for transactions)? edit 2: and finally, how do I define two parents for an entity if the entity is being created to establish an n-to-n relationship between 2 parents?
datastore transaction restrictions
1
1.2
1
1
0
384
841,159
2009-05-08T18:23:00.000
0
0
1
0
0
python,yacc,lex,ply
1
842,331
0
4
1
false
0
0
I typically use a separate 'command reader' to obtain a complete command - probably a line in your case - into a host variable string, and then arrange for the lexical analyzer to analyze the string, including telling me when it didn't reach the end. This is hard to set up, but make some classes of error reporting easier. One of the places I've used this technique routinely has multi-line commands with 3 comment conventions, two sets of quoted strings, and some other nasties to set my teeth on edge (context sensitive tokenization - yuck!). Otherwise, Don's advice with the Yacc 'error' token is good.
2
3
0
0
Forgive me, I'm completely new to parsing and lex/yacc, and I'm probably in way over my head, but nonetheless: I'm writing a pretty basic calculator with PLY, but it's input might not always be an equation, and I need to determine if it is or not when parsing. The extremes of the input would be something that evaluates perfectly to an equation, which it parses fine and calculates, or something that is nothing like an equation, which fails parsing and is also fine. The gray area is an input that has equation-like parts, of which the parser will grab and work out. This isn't what I want - I need to be able to tell if parts of the string didn't get picked up and tokenized so I can throw back an error, but I have no idea how to do this. Does anyone know how I can define, basically, a 'catch anything that's left' token? Or is there a better way I can handle this?
Tokenizing left over data with lex/yacc
0
0
1
0
0
674
841,159
2009-05-08T18:23:00.000
1
0
1
0
0
python,yacc,lex,ply
1
842,248
0
4
1
true
0
0
There is a built-in error token in yacc. You would normally do something like: line: goodline | badline ; badline : error '\n' /* Error-handling action, if needed */ goodline : equation '\n' ; Any line that doesn't match equation will be handled by badline. You might want to use yyerrok in the error handling action to ensure error processing is reset for the next line.
2
3
0
0
Forgive me, I'm completely new to parsing and lex/yacc, and I'm probably in way over my head, but nonetheless: I'm writing a pretty basic calculator with PLY, but it's input might not always be an equation, and I need to determine if it is or not when parsing. The extremes of the input would be something that evaluates perfectly to an equation, which it parses fine and calculates, or something that is nothing like an equation, which fails parsing and is also fine. The gray area is an input that has equation-like parts, of which the parser will grab and work out. This isn't what I want - I need to be able to tell if parts of the string didn't get picked up and tokenized so I can throw back an error, but I have no idea how to do this. Does anyone know how I can define, basically, a 'catch anything that's left' token? Or is there a better way I can handle this?
Tokenizing left over data with lex/yacc
0
1.2
1
0
0
674
842,120
2009-05-08T22:41:00.000
1
0
0
1
0
python,windows,scripting,batch-file,io
0
842,139
0
3
0
false
0
0
Try subprocess.Popen(). It allows you to redirect stdout and stderr to files.
1
3
0
0
I'm trying to write a python script (in windows) that runs a batch file and will take the command line output of that batch file as input. The batch file runs processes that I don't have access to and gives output based on whether those processes are successful. I'd like to take those messages from the batch file and use them in the python script. Anyone have any ideas on how to do this ?
Piping Batch File output to a Python script
0
0.066568
1
0
0
9,251
847,860
2009-05-11T12:24:00.000
1
0
0
0
0
c#,c++,python,c,vb.net
1
847,883
0
2
0
false
0
1
Compiling can be done by calling cl.exe which comes with Visual Studio. Of course you could also use GCC instead.
1
1
0
0
I'm trying to make a vb.net application that has got 2 textboxes, 7 radio buttons and 2 buttons(one named compile and the other 'run'). How can I load the content of a C/C++(or any programming language) file into the 1st textbox and on clicking the compile button, i should be able to show the errors or the C/C++ program in the 2nd textbox. On clicking Run, I should be able to show the output in the 2nd textbox. In short, I want to use the 2nd textbox as a terminal/console. The radio buttons are 4 selecting the language C or C++ or python or C# or java or perl or vb. Are the compilers of all these languages present in .net? If so how can I call them?
How to write a vb.net code to compile C/C++ programs?
0
0.099668
1
0
0
1,053
848,508
2009-05-11T14:55:00.000
0
1
0
1
0
python,m2crypto
1
848,795
0
3
0
false
0
0
Possibly its looking up shared libs libssl.so and libcrypto.so and finding the old ones in /usr/lib if you add the new_path to the top of /etc/ld.so.conf so it gets searched first it would work. But this might break other OpenSSL applications expecting old OpenSSL.
1
2
0
0
M2Crypto provides EC support for ECDSA/ECDH. I have installed OpenSSL 0.9.8i which contains support for EC. However when I run "from M2Crypto import EC,BIO" I get error saying EC_init() failed. So I added debug to print m2.OPENSSL_VERSION_TEXT value. It gets printed as "OpenSSL 0.9.7 19 Feb 2003". This version of OpenSSL doesnot support EC. I tried "python setup.py build build_ext --openssl="new_path where OpenSSL 0.9.8i is installed". Though M2Crypto is built again "Python setup.py install" , I still see that it points to "Old version of OpenSSL". Any Pointers on how to successfully get M2Crypto to use 0.9.8i will be useful.
Python M2Crypto EC Support
0
0
1
0
0
880
851,010
2009-05-12T03:20:00.000
4
0
1
0
0
python,windows
1
851,039
0
6
0
false
0
0
You can compare len(os.listdir("path")) to zero to see if there are any files in the directory.
1
4
0
0
Say I want to manipulate some files on a floppy drive or a USB card reader. How do I check to see if the drive in question is ready? (That is, has a disk physically inserted.) The drive letter exists, so os.exists() will always return True in this case. Also, at this point in the process I don't yet know any file names, so checking to see if a given file exists also won't work. Some clarification: the issue here is exception handling. Most of the win32 API calls in question just throw an exception when you try to access a drive that isn't ready. Normally, this would work fine - look for something like the free space, and then catch the raised exception and assume that means there isn't a disk present. However, even when I catch any and all exceptions, I still get an angry exception dialog box from Windows telling me the floppy / card reader isn't ready. So, I guess the real question is - how do I suppress the windows error box?
How do I check if a disk is in a drive using python?
0
0.132549
1
0
0
3,839
855,408
2009-05-12T23:29:00.000
5
0
0
1
0
python,django,macos
0
856,033
0
4
0
false
1
0
Unless you are planning on going to production with OS X you might not want to bother. If you must do it, go straight to mod_wsgi. Don't bother with mod_python or older solutions. I did mod_python on Apache and while it runs great now, it took countless hours to set up. Also, just to clarify something based on what you said: You're not going to find a mapping between the url path (like /polls) and a script that is being called. Django doesn't work like that. With Django your application is loaded into memory waiting for requests. Once a request comes in it gets dispatched through the url map that you created in urls.py. That boils down to a function call somewhere in your code. That's why for a webserver like Apache you need a module like mod_wsgi, which gives your app a spot in memory in which to live. Compare that with something like CGI where the webserver executes a specific script on demand at a location that is physically mapped between the url and the filesystem. I hope that's helpful and not telling you something you already knew. :)
2
1
0
0
I've just completed the very very nice django tutorial and it all went swimmingly. One of the first parts of the tutorial is that it says not to use their example server thingie in production, my first act after the tutorial was thus to try to run my app on apache. I'm running OSX 10.5 and have the standard apache (which refuses to run python) and MAMP (which begrudgingly allows it in cgi-bin). The problem is that I've no idea which script to call, in the tutorial it was always localhost:8000/polls but I've no idea how that's meant to map to a specific file. Have I missed something blatantly obvious about what to do with a .htaccess file or does the tutorial not actually explain how to use it somewhere else?
Running django on OSX
0
0.244919
1
0
0
1,602
855,408
2009-05-12T23:29:00.000
2
0
0
1
0
python,django,macos
0
856,986
0
4
0
false
1
0
Yet another option is to consider using a virtual machine for your development. You can install a full version of whatever OS your production server will be running - say, Debian - and run your Apache and DB in the VM. You can connect to the virtual disk in the Finder, so you can still use TextMate (or whatever) on OSX to do your editing. I've had good experiences doing this via VMWare Fusion.
2
1
0
0
I've just completed the very very nice django tutorial and it all went swimmingly. One of the first parts of the tutorial is that it says not to use their example server thingie in production, my first act after the tutorial was thus to try to run my app on apache. I'm running OSX 10.5 and have the standard apache (which refuses to run python) and MAMP (which begrudgingly allows it in cgi-bin). The problem is that I've no idea which script to call, in the tutorial it was always localhost:8000/polls but I've no idea how that's meant to map to a specific file. Have I missed something blatantly obvious about what to do with a .htaccess file or does the tutorial not actually explain how to use it somewhere else?
Running django on OSX
0
0.099668
1
0
0
1,602
872,290
2009-05-16T12:01:00.000
2
0
1
0
0
python,string
0
872,295
0
9
0
false
0
0
You're basically testing whether a member is in a set or not, right? If so, and because you said you have lots of memory, why not just load all the words as keys in memcache, and then for every word, just check if it is present in memcache or not. Or use that data structure that is used by bash to autocomplete command names - this is fast and highly efficient in memory (can't remember the name).
2
11
0
0
I have a file containing roughly all the words in English (~60k words, ~500k characters). I want to test whether a certain word I receive as input is "in English" (i.e. if this exact word is in the list). What would be the most efficient way to do this in Python? The trivial solution is to load the file into a list and check whether the word is in that list. The list can be sorted, which I believe will shrink the complexity to O(logn). However I'm not sure about how Python implements searching through lists, and whether there's a performance penalty if such a large list is in memory. Can I "abuse" the fact I can put a cap on the length of words? (e.g. say the longest one is 15 characters long). Please note I run the application on a machine with lots of memory, so I care less for memory consumption than for speed and CPU utilization. Thanks
Most Efficient Way to Find Whether a Large List Contains a Specific String (Python)
0
0.044415
1
0
0
15,715
872,290
2009-05-16T12:01:00.000
2
0
1
0
0
python,string
0
872,353
0
9
0
false
0
0
Two things: The Python 'mutable set' type has an 'add' method ( s.add(item) ), so you could go right from reading (a line) from your big file straight into a set without using a list as an intermediate data structure. Python lets you 'pickle' a data structure, so you could save your big set to a file and save the time of reinitiating the set. Second, I've been looking for a list of all the single-syllable words in English for my own amusement, but the ones I've found mentioned seem to be proprietary. If it isn't being intrusive, could I ask whether your list of English words can be obtained by others?
2
11
0
0
I have a file containing roughly all the words in English (~60k words, ~500k characters). I want to test whether a certain word I receive as input is "in English" (i.e. if this exact word is in the list). What would be the most efficient way to do this in Python? The trivial solution is to load the file into a list and check whether the word is in that list. The list can be sorted, which I believe will shrink the complexity to O(logn). However I'm not sure about how Python implements searching through lists, and whether there's a performance penalty if such a large list is in memory. Can I "abuse" the fact I can put a cap on the length of words? (e.g. say the longest one is 15 characters long). Please note I run the application on a machine with lots of memory, so I care less for memory consumption than for speed and CPU utilization. Thanks
Most Efficient Way to Find Whether a Large List Contains a Specific String (Python)
0
0.044415
1
0
0
15,715
872,737
2009-05-16T16:19:00.000
1
0
0
0
0
python,ruby,user-interface
0
873,925
0
3
0
false
0
1
I would recommend PyGame.
2
1
0
0
using Ruby or Python, does someone know how to draw on the screen, covering up any other window? Kind of like, press a key, and the program will show current weather or stock quote on the screen (using the whole screen as the canvas), and then press the key again, and everything restores to the same as before? (like Mac OS X's dash board).
does someone know how to show content on screen (covering up any window) using Ruby or Python?
0
0.066568
1
0
0
179
872,737
2009-05-16T16:19:00.000
4
0
0
0
0
python,ruby,user-interface
0
872,757
0
3
0
true
0
1
You could use the systems dashboard (desktop widgets, or whatever it's called) API. In order to do that you need bindings to it for Python or Ruby. Alternatively you could use some generic gui toolkit or application framework and just create a frameless window with transparent background. Then you need to be sure that the chosen toolkit supports 'always-on-top' options on your desired platform(s).
2
1
0
0
using Ruby or Python, does someone know how to draw on the screen, covering up any other window? Kind of like, press a key, and the program will show current weather or stock quote on the screen (using the whole screen as the canvas), and then press the key again, and everything restores to the same as before? (like Mac OS X's dash board).
does someone know how to show content on screen (covering up any window) using Ruby or Python?
0
1.2
1
0
0
179
874,476
2009-05-17T12:09:00.000
7
1
0
1
0
python,unix,root,sudo
0
874,519
0
3
0
false
0
0
The concept of "admin-privileges" in our day of fine grained privilege control is becoming hard to define. If you are running on unix with "traditional" access control model, getting the effective user id (available in os module) and checking that against root (0) could be what you are looking for. If you know accessing a file on the system requires the privileges you want your script to have, you can use the os.access() to check if you are privileged enough. Unfortunately there is no easy nor portable method to give. You need to find out or define the security model used, what system provided APIs are available to query and set privileges and try to locate (or possibly implement yourself) the appropriate python modules that can be used to access the API. The classic question, why do you need to find out? What if your script tries to do what it needs to do and "just" catches and properly handles failures?
1
2
0
0
how can i check admin-privileges for my script during running?
Admin privileges for script
0
1
1
0
0
2,996
875,228
2009-05-17T19:00:00.000
2
0
1
0
0
python,file-io,csv,multidimensional-array,fileparsing
0
875,525
0
5
0
false
0
0
I'm looking for a simple solution using Python to store data as a flat file, such that each line is a string representation of an array that can be easily parsed. Is the data only ever going to be parsed by Python programs? If not, then I'd avoid pickle et al (shelve and marshal) since they're very Python specific. JSON and YAML have the important advantage that parsers are easily available for most any language.
1
3
1
0
I'm looking for a simple solution using Python to store data as a flat file, such that each line is a string representation of an array that can be easily parsed. I'm sure python has library for doing such a task easily but so far all the approaches I have found seemed like it would have been sloppy to get it to work and I'm sure there is a better approach. So far I've tried: the array.toFile() method but couldn't figure out how to get it to work with nested arrays of strings, it seemed geared towards integer data. Lists and sets do not have a toFile method built in, so I would have had to parse and encode it manually. CSV seemed like a good approach but this would also require manually parsing it, and did not allow me to simply append new lines at the end - so any new calls the the CSVWriter would overwrite the file existing data. I'm really trying to avoid using databases (maybe SQLite but it seems a bit overkill) because I'm trying to develop this to have no software prerequisites besides Python.
Simple data storing in Python
0
0.07983
1
0
0
5,460
876,107
2009-05-18T03:15:00.000
3
0
0
0
0
python,performance,matplotlib,pyqt
0
876,151
0
1
0
true
0
1
Yes, loading the module takes place at the line where the import statement is. If you create your QApplication and show your splash screen before that, you should be able to do what you want -- also you need to call QApplication.processEvents() whenever you need the splash screen to update with a new message.
1
4
0
0
My PyQt application that uses matplotlib takes several seconds to load for the first time, even on a fast machine (the second load time is much shorter as the DLLs are kept in memory by Windows). I'm wondering whether it's feasible to show a splash screen while the matplotlib library is being loaded. Where does the actual loading take place - is it when the from line is executed? If so, how can I make this line execute during the splash screen and still be able to use the module throughout the code? A related dilemma is how to test this - can I ask Windows to load the DLLs for every execution and not cache them?
PyQt: splash screen while loading "heavy" libraries
0
1.2
1
0
0
3,080
885,771
2009-05-20T01:22:00.000
5
0
0
0
0
php,python,mysql,ruby,migration
0
885,783
0
2
0
true
0
0
I believe MySQL only needs to alter metadata and references to the table's old name in stored procedures -- the number of records in the table should be irrelevant.
1
3
0
0
MySQL has a RENAME TABLE statemnt that will allow you to change the name of a table. The manual mentions The rename operation is done atomically, which means that no other session can access any of the tables while the rename is running The manual does not (to my knowedge) state how this renaming is accomplished. Is an entire copy of the table created, given a new name, and then the old table deleted? Or does MySQL do some magic behind the scenes to quickly rename the table? In other words, does the size of the table have an effect on how long the RENAME table statement will take to run. Are there other things that might cause the renaming of a block to significantly block?
How does MySQL's RENAME TABLE statment work/perform?
0
1.2
1
1
0
2,472
906,509
2009-05-25T12:16:00.000
2
0
0
1
0
python,plugins,gnome,rhythmbox
0
1,450,802
0
2
0
false
0
0
You can't import rhythmbox "built-in" modules from a standard python console. As far as I know they aren't real modules, they are just objects from the rhythmbox process exposed to plugins. So you can access them only if you are running your script from the rhythmbox process.
2
0
0
0
I'm writing a little script for Ubuntu. My intention is to call rhythmbox lyrics plug-in with a global short-cut (configuring gnome) . I can call it from rhythmbox python console, but I don't know how to import rhythmbox built-in modules (eg. rhythmdb). Any ideas?
show lyrics on ubuntu
0
0.197375
1
0
0
1,143
906,509
2009-05-25T12:16:00.000
0
0
0
1
0
python,plugins,gnome,rhythmbox
0
4,594,514
0
2
0
false
0
0
in this case i guess you'll have to write the whole plugin yourself and , then listen to dbus for change of songs in rhythmbox , to detect which song is being played .
2
0
0
0
I'm writing a little script for Ubuntu. My intention is to call rhythmbox lyrics plug-in with a global short-cut (configuring gnome) . I can call it from rhythmbox python console, but I don't know how to import rhythmbox built-in modules (eg. rhythmdb). Any ideas?
show lyrics on ubuntu
0
0
1
0
0
1,143
907,579
2009-05-25T18:05:00.000
0
0
0
1
0
python,hosting
0
907,605
0
5
0
false
0
0
In addition to the other fine answers here, you should be aware that most FTP clients have a chmod command to allow you to set permissions on files at the server. You may not need this if permissions come across properly, but there's a good chance they do not.
1
4
0
0
My hosting provider says my python script must be made to be executable(chmod755). What does this mean & how do I do it? Cheers!
Making a Python script executable chmod755?
0
0
1
0
0
3,729
921,268
2009-05-28T14:55:00.000
2
0
0
0
0
.net,ssis,ironpython
0
1,233,648
0
1
0
false
0
0
Set up a column which holds a CHECKSUM() of each row. Do a left outer join between the two tables . If you have any nulls for the right side, you have problems.
1
0
0
0
A table has been ETLed to another table. My task is to verify the data between two tables programmatically. One of the difficulties I m facing rite now is: how to use the expression that I can get from, let s say, derived column task and verify with the source and destination. or in other words, how can I use the expression to work in the code. Any ideas....highly appreciated Sagar
How to compare data of two tables transformed in SSIS package
0
0.379949
1
1
0
1,102
933,822
2009-06-01T07:14:00.000
0
1
0
0
0
c#,python,ruby,ironpython,ironruby
0
933,988
0
3
0
false
1
0
IronPython 2.0 has a sample compiler called PYC on Codeplex.com/ironpython which can create DLL's (and applications if you need them too). IronPython 2.6 has a newer version of PYC under Tools\script. Cheers, Davy
2
3
0
0
Does anyone know how to add python and ruby libs as a resource in a dll for deployment? I want to host a script engine in my app, but dont want to have to deploy the entire standard libraries of the respective languages in source files. Is there a simple way to do this so that a require or import statement will find the embedded resources?
Packaging script source files in IronPython and IronRuby
0
0
1
0
0
520
933,822
2009-06-01T07:14:00.000
1
1
0
0
0
c#,python,ruby,ironpython,ironruby
0
934,609
0
3
0
false
1
0
You could add custom import hook that looks for embedded resources when an import is executed. This is slightly complex and probably not worth the trouble. A better technique would be to fetch all of the embedded modules at startup time, execute them with the ScriptEngine and put the modules you have created into the sys.modules dictionary associated with the engine. This automatically makes them available for import by Python code executed by the engine.
2
3
0
0
Does anyone know how to add python and ruby libs as a resource in a dll for deployment? I want to host a script engine in my app, but dont want to have to deploy the entire standard libraries of the respective languages in source files. Is there a simple way to do this so that a require or import statement will find the embedded resources?
Packaging script source files in IronPython and IronRuby
0
0.066568
1
0
0
520
944,700
2009-06-03T13:19:00.000
241
0
1
0
0
python,math
0
944,756
0
18
0
false
0
0
numpy.isnan(number) tells you if it's NaN or not.
1
1,412
0
0
float('nan') represents NaN (not a number). But how do I check for it?
How can I check for NaN values?
0
1
1
0
0
2,218,724
952,110
2009-06-04T17:51:00.000
2
0
1
0
0
python,recursion,palindrome
0
952,171
0
11
0
false
0
0
Here's another viewpoint A palindromic string is Some letter, x. Some palindromic substrinng. The same letter, x, repeated. Also, note that you may be given a proper English sentence "Able was I ere I saw Elba." with punctuation. Your palindrome checker may have to quietly skip punctuation. Also, you may have to quietly match without considering case. This is slightly more complex. Some leading punctuation. Some letter, x. Some palindromic substring. Some letter, x, repeated without regard to case. Some trailing punctuation. And, by definition, a zero-length string is a palindrome. Also a single-letter string (after removing punctuation) is a palindrome.
2
10
0
0
I need help writing a recursive function which detects whether a string is a palindrome. But i can't use any loops it must be recursive. Can anyone help show me how this is done . Im using Python.
Recursive Function palindrome in Python
0
0.036348
1
0
0
99,261
952,110
2009-06-04T17:51:00.000
3
0
1
0
0
python,recursion,palindrome
0
952,129
0
11
0
false
0
0
If a string is zero or one letters long, it's a palindrome. If a string has the first and last letters the same, and the remaining letters (I think it's a [1: -1] slice in Python, but my Python is a bit rusty) are a palindrome, it's a palindrome. Now, write that as a palindrome function that takes a string. It will call itself.
2
10
0
0
I need help writing a recursive function which detects whether a string is a palindrome. But i can't use any loops it must be recursive. Can anyone help show me how this is done . Im using Python.
Recursive Function palindrome in Python
0
0.054491
1
0
0
99,261
960,467
2009-06-06T20:33:00.000
3
0
0
0
0
python,qt,widget,designer
0
1,235,766
0
3
0
false
0
1
I have a single main window with a QGraphicsView and lots of QGraphicsItem objects. Each type of the Items have a different context menu. I find that not being able to create the contextMenu's, or at least the actions that are in them a serious limitation of QtDesigner. It means that I can create about 10% or so of the actions using the designer, and I have to create 90% programaticaly. Compare that with the Microsoft resource editor which allows all of these things to be created, and maintained effortlessly. I hope this will be addressed at some point.
3
1
0
0
Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.
how can I add a QMenu and QMenuItems to a window from Qt Designer
1
0.197375
1
0
0
3,989
960,467
2009-06-06T20:33:00.000
3
0
0
0
0
python,qt,widget,designer
0
960,506
0
3
0
true
0
1
When you edit a QMainWindow you can right click the window and then choose "create menu bar". Or are you talking about a "context menu" aka "right click menu"?
3
1
0
0
Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.
how can I add a QMenu and QMenuItems to a window from Qt Designer
1
1.2
1
0
0
3,989
960,467
2009-06-06T20:33:00.000
0
0
0
0
0
python,qt,widget,designer
0
960,479
0
3
0
false
0
1
Adding menu editing for every widget in the designer would probably make a very awkward and inconvenient UI. There's really no place you can visualize it on. If you're editing a QMainWindow you can edit the menu bar and its popups because there's a proper place for them to be displayed in.
3
1
0
0
Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.
how can I add a QMenu and QMenuItems to a window from Qt Designer
1
0
1
0
0
3,989
964,459
2009-06-08T11:30:00.000
-1
0
1
0
0
javascript,python
0
964,478
0
9
0
false
0
0
I don't know Python good enough to tell you a solution. But if you want to use that to sanitize the user input you have to be very, very careful. Removing stuff between and just doesn't catch everything. Maybe you can have a look at existing solutions (I assume Django includes something like this).
2
5
0
0
how to remove text between <script> and </script> using python?
how to remove text between using python?
0
-0.022219
1
0
0
10,944
964,459
2009-06-08T11:30:00.000
0
0
1
0
0
javascript,python
0
964,487
0
9
0
false
0
0
If you're removing everything between <script> and </script> why not just remove the entire node? Are you expecting a resig-style src and body?
2
5
0
0
how to remove text between <script> and </script> using python?
how to remove text between using python?
0
0
1
0
0
10,944
967,661
2009-06-09T00:29:00.000
1
0
1
0
0
python,truncate
0
967,676
0
8
0
false
0
0
You have several options - you can round the number using round(), however this can introduce some inaccuracies (315.15 might round to 315.150000003 for example). If you're just looking to truncate the value of the float when you're displaying it, you can specify the width of the output using printf("%.2f", mynumber). This is probably a better solution, since without knowing more about your specific application it's a good idea in general to keep the entire length of the number for calculation.
1
12
0
0
How can truncate an input like 315.15321531321 I want to truncate all the values after the hundredths position so it becomes 315.15 how do i do that?
python truncate after a hundreds?
0
0.024995
1
0
0
38,627
971,983
2009-06-09T19:18:00.000
11
0
0
0
0
python,django
0
972,004
0
3
0
true
1
0
There's no real rule for this, But one thing I like to do is actually arrange for the index access to redirect to another spot. If you prefer, though, you can just give the index page a plain view. That said, It's probably a good idea to keep all your code in an actual app, so that you can refactor it more easily, and so that it appears on the python path as a normal module. Putting views in the project rather than an app seems to cause more headaches than it solves.
1
20
0
0
I've been having a look at Django and, from what I've seen, it's pretty darn fantastic. I'm a little confused, however, how I go about implementing a "home page" for my website? Would it be a separate app, or just a view within the project, or what?
Django - Website Home Page
0
1.2
1
0
0
11,919
973,520
2009-06-10T03:11:00.000
11
1
0
1
1
python,shell,zsh,ipython
0
1,070,597
0
2
0
true
0
0
I asked this question on the zsh list and this answer worked for me. YMMV. In genutils.py after the line if not debug: Remove the line: stat = os.system(cmd) Replace it with: stat = subprocess.call(cmd,shell=True,executable='/bin/zsh') you see, the problem is that that "!" call uses os.system to run it, which defaults to manky old /bin/sh . Like I said, it worked for me, although I'm not sure what got borked behind the scenes.
1
11
0
0
I have been in love with zsh for a long time, and more recently I have been discovering the advantages of the ipython interactive interpreter over python itself. Being able to cd, to ls, to run or to ! is indeed very handy. But now it feels weird to have such a clumsy shell when in ipython, and I wonder how I could integrate my zsh and my ipython better. Of course, I could rewrite my .zshrc and all my scripts in python, and emulate most of my shell world from ipython, but it doesn't feel right. And I am obviously not ready to use ipython as a main shell anyway. So, here comes my question: how do you work efficiently between your shell and your python command-loop ? Am I missing some obvious integration strategy ? Should I do all that in emacs ?
how to integrate ZSH and (i)python?
0
1.2
1
0
0
8,591
974,821
2009-06-10T10:42:00.000
1
0
1
0
0
python,windows,django-admin
0
974,834
0
4
0
false
1
0
you can't run a command that isn't in your path. it should be set globally when you installed python. type 'set' at a dos prompt and look at the PATH variable. c:\python25 (or whever you installed python) has to be in that variable ie PATH=c:\windows;c:\python25;... etc if it isn't in PATH then you or the installer missed the part where you needed to set it. It can be done from the 'Environment Variables' button in the 'System' control panel.
3
0
0
0
I have installed python and django in my system that uses win vista. Now when I go to command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?
python not starting properly
0
0.049958
1
0
0
139
974,821
2009-06-10T10:42:00.000
0
0
1
0
0
python,windows,django-admin
0
974,848
0
4
0
true
1
0
Either use the system control panel to set the PATH environment variable that applies permanently or Reinstall Python as a system administrator so that the installer can set the registry and environment variables for you. If you install the "just for me" option, then you have to set the PATH variable in the control panel.
3
0
0
0
I have installed python and django in my system that uses win vista. Now when I go to command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?
python not starting properly
0
1.2
1
0
0
139
974,821
2009-06-10T10:42:00.000
0
0
1
0
0
python,windows,django-admin
0
975,292
0
4
0
false
1
0
In your path, I think you need to have both the location of the Python install and the Python\Scripts folder. For example, on XP, I have C:\Python25;C:\Python25\Scripts. Can you verify that you have both?
3
0
0
0
I have installed python and django in my system that uses win vista. Now when I go to command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?
python not starting properly
0
0
1
0
0
139
978,643
2009-06-10T23:35:00.000
2
0
0
0
1
python,django,vim
0
10,666,285
0
5
0
false
1
0
Today, you not need special extentions for django autocomplete in vim. Make sure that you have vim with python support. To check it, type in xterm: vim --version|grep python output: +python -python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs ... ... To make work autocomplete, add this lines in your .vimrc: autocmd FileType python set omnifunc=pythoncomplete#Complete if has("python") python import sys,os python sys.path.append('/home/sergey/workspace/django') python os.environ['DJANGO_SETTINGS_MODULE'] = 'djangoProject.settings' endif where: sys.path.append is path to your django workspace directory djangoProject is name of your django project, which is going just after '/home/sergey/workspace/django' Finally, save it and restart vim. Now, after '.', you press default ctrl-x ctrl-o to get your autocomplete.
2
48
0
0
Does anyone know how to set up auto completion to work nicely with python, django, and vim? I've been trying to use pysmell, but I can't seem to get it set up correctly (or maybe I don't know how it works). Right now, I run pysmell in the django directory (I'm using the trunk) and move the resulting tags to my project directory, then I also run pysmell in the project directory. Vim doesn't pick up the django tags, though, and they don't get auto completed. Does anyone know how to set up auto completion in vim so that it will complete the long django functions (like get_object_or_404) as well as classes/functions in my own code? I have poked around on google but haven't found any good resources. Thanks.
Vim, Python, and Django autocompletion (pysmell?)
0
0.07983
1
0
0
19,878
978,643
2009-06-10T23:35:00.000
3
0
0
0
1
python,django,vim
0
978,766
0
5
0
false
1
0
I've had good luck with exuberant-ctags for this. I use this macro in my vimrc: execute 'map :!/usr/bin/exuberant-ctags -f '.&tags.' --recurse '.$_P4ROOT.' ' You'll want to modify that slightly, so that it includes your python /site-packages/django/ directory as well as your own code. Then, hit F2 inside vim to update the tags, and use the regular vim tag bindings to navigate.
2
48
0
0
Does anyone know how to set up auto completion to work nicely with python, django, and vim? I've been trying to use pysmell, but I can't seem to get it set up correctly (or maybe I don't know how it works). Right now, I run pysmell in the django directory (I'm using the trunk) and move the resulting tags to my project directory, then I also run pysmell in the project directory. Vim doesn't pick up the django tags, though, and they don't get auto completed. Does anyone know how to set up auto completion in vim so that it will complete the long django functions (like get_object_or_404) as well as classes/functions in my own code? I have poked around on google but haven't found any good resources. Thanks.
Vim, Python, and Django autocompletion (pysmell?)
0
0.119427
1
0
0
19,878
985,155
2009-06-12T05:28:00.000
5
0
1
0
0
python
0
985,176
0
1
0
true
0
0
Assuming you're talking about a .so file, it's not up to Python to find it -- it's up to the operating system's dynamic library loaded. For Linux, for example, LD_LIBRARY_PATH is the environment variable you need to set.
1
5
0
0
I have installed lxml which was built using a standalone version of libxml2. Reason for this was that the lxml needed a later version of libxml2 than what was currently installed. When I use the lxml module how do I tell it (python) where to find the correct version of the libxml2 shared library?
How to specify native library search path for python
0
1.2
1
0
1
2,097
995,165
2009-06-15T09:15:00.000
0
0
1
0
0
c++,python,regex,namespaces
0
998,230
0
6
0
false
0
0
That is what I did earlier today: Extract the comment out of the C++ files Use regex to extract the namespace definition Use a simple string search to get the open & close braces positions The various sanity check added show that I am successfully processing 99.925% of my files (5 failures ouf of 6678 files). The issues are due to mismatches in numbers of { and } cause by few '{' or '}' in strings, and unclean usage of the preprocessor instruction. However, I am only dealing with header files, and I own the code. That limits the number of scenari that could cause some issues and I can manually modify the ones I don't cover. Of course I know there are plenty of cases where it would fail but it is probably enough for what I want to achieve. Thanks for your answers.
5
1
0
0
I am trying to extract the namespaces defined in C++ files. Basically, if my C++ file contains: namespace n1 { ... namespace n2 { ... } // end namespace n2 ... namespace n3 { ...} //end namespace n3 ... } //end namespace n1 I want to be able to retrieve: n1, n1::n2, n1::n3. Does someone have any suggestion of how I could do that using python-regex? Thanks.
Using python regex to extract namespaces from C++ sources
0
0
1
0
0
799
995,165
2009-06-15T09:15:00.000
1
0
1
0
0
c++,python,regex,namespaces
0
997,076
0
6
0
false
0
0
You could write a basic lexer for it. It's not that hard.
5
1
0
0
I am trying to extract the namespaces defined in C++ files. Basically, if my C++ file contains: namespace n1 { ... namespace n2 { ... } // end namespace n2 ... namespace n3 { ...} //end namespace n3 ... } //end namespace n1 I want to be able to retrieve: n1, n1::n2, n1::n3. Does someone have any suggestion of how I could do that using python-regex? Thanks.
Using python regex to extract namespaces from C++ sources
0
0.033321
1
0
0
799
995,165
2009-06-15T09:15:00.000
2
0
1
0
0
c++,python,regex,namespaces
0
997,110
0
6
0
false
0
0
The need is simple enough that you may not need a complex parser. You need to: extract the namespace names count the open/close braces to keep track of where your namespace is defined. This simple approach works if the other conditions are met: you don't get spurious namespace like strings inside comments or inside strings you don't get unmatched open/closeing braces inside comments or strings I don't think this is too much asking from your source.
5
1
0
0
I am trying to extract the namespaces defined in C++ files. Basically, if my C++ file contains: namespace n1 { ... namespace n2 { ... } // end namespace n2 ... namespace n3 { ...} //end namespace n3 ... } //end namespace n1 I want to be able to retrieve: n1, n1::n2, n1::n3. Does someone have any suggestion of how I could do that using python-regex? Thanks.
Using python regex to extract namespaces from C++ sources
0
0.066568
1
0
0
799
995,165
2009-06-15T09:15:00.000
6
0
1
0
0
c++,python,regex,namespaces
0
995,182
0
6
0
false
0
0
Searching for the namespace names is pretty easy with a regular expression. However, to determine the nesting level you will have to keep track of the curly bracket nesting level in the source file. This is a parsing problem, one that cannot be solved (sanely) with regular expressions. Also, you may have to deal with any C preprocessor directives in the file which can definitely affect parsing. C++ is a notoriously tricky language to parse completely, but you may be able to get by with a tokeniser and a curly bracket counter.
5
1
0
0
I am trying to extract the namespaces defined in C++ files. Basically, if my C++ file contains: namespace n1 { ... namespace n2 { ... } // end namespace n2 ... namespace n3 { ...} //end namespace n3 ... } //end namespace n1 I want to be able to retrieve: n1, n1::n2, n1::n3. Does someone have any suggestion of how I could do that using python-regex? Thanks.
Using python regex to extract namespaces from C++ sources
0
1
1
0
0
799
995,165
2009-06-15T09:15:00.000
0
0
1
0
0
c++,python,regex,namespaces
0
997,065
0
6
0
false
0
0
Most of the time when someone asks how to do something with regex, they're doing something very wrong. I don't think this case is different. If you want to parse c++, you need to use a c++ parser. There are many things that can be done that will defeat a regex but still be valid c++.
5
1
0
0
I am trying to extract the namespaces defined in C++ files. Basically, if my C++ file contains: namespace n1 { ... namespace n2 { ... } // end namespace n2 ... namespace n3 { ...} //end namespace n3 ... } //end namespace n1 I want to be able to retrieve: n1, n1::n2, n1::n3. Does someone have any suggestion of how I could do that using python-regex? Thanks.
Using python regex to extract namespaces from C++ sources
0
0
1
0
0
799
997,904
2009-06-15T19:25:00.000
0
0
0
0
0
python,icons,pyqt4
0
999,115
0
3
0
false
0
1
I spent a decent amount of researching this myself not long ago, and my conclusion was that, unfortunately, Qt doesn't provide this functionality in a cross-platform fashion. Ideally the QIcon class would have defaults for file open, save, '+', '-', preferences, etc, but considering it doesn't you'll have to grab the appropriate icon for your desktop environment.
1
8
0
0
I'm writing a basic program in python using the PyQt4 module. I'd like to be able to use my system theme's icons for things like the preference dialog's icon, but i have no idea how to do this. So my question is, how do you get the location of an icon, but make sure it changes with the system's icon theme? If it matters, i'm developing this under ubuntu 9.04, so i am using the gnome desktop.
System theme icons and PyQt4
0
0
1
0
0
3,720
1,001,744
2009-06-16T14:09:00.000
5
1
0
1
0
python,linux,encryption,passwords
0
1,001,833
0
3
0
true
0
0
Encrypting the passwords doesn't really buy you a whole lot more protection than storing in plaintext. Anyone capable of accessing the database probably also has full access to your webserver machines. However, if the loss of security is acceptable, and you really need this, I'd generate a new keyfile (from a good source of random data) as part of the installation process and use this. Obviously store this key as securely as possible (locked down file permissions etc). Using a single key embedded in the source is not a good idea - there's no reason why seperate installations should have the same keys.
1
7
0
0
First, my question is not about password hashing, but password encryption. I'm building a desktop application that needs to authentificate the user to a third party service. To speed up the login process, I want to give the user the option to save his credentials. Since I need the password to authentificate him to the service, it can't be hashed. I thought of using the pyCrypto module and its Blowfish or AES implementation to encrypt the credentials. The problem is where to store the key. I know some applications store the key directly in the source code, but since I am coding an open source application, this doesn't seem like a very efficient solution. So I was wondering how, on Linux, you would implement user specific or system specific keys to increase password storing security. If you have a better solution to this problem than using pyCrypto and system/user specific keys, don't hesitate to share it. As I said before, hashing is not a solution and I know password encryption is vulnerable, but I want to give the option to the user. Using Gnome-Keyring is not an option either, since a lot of people (including myself) don't use it.
How To Reversibly Store Password With Python On Linux?
1
1.2
1
0
0
2,912
1,003,302
2009-06-16T18:50:00.000
-2
0
0
0
0
python,django
0
1,004,658
0
4
0
false
1
0
Edit: Added some more information about why I present this answer here. I found chartbeat when I tried to answer this same question for my django based site. I don't work for them. Not specifically Django, but chartbeat.com is very interesting to add to a website as well. django-tracking is great, +1 for that answer, etc. Couple of things I could not do with django-tracking, that chartbeat helped with; tracked interactions with completely cached pages which never hit the django tracking code and pages not delivered through django (e.g. wordpress, etc.)
1
3
0
0
In Django, how can I see the number of current visitors? Or how do I determine the number of active sessions? Is this a good method? use django.contrib.sessions.models.Session, set the expiry time short. Every time when somebody does something on the site, update expiry time. Then count the number of sessions that are not expired.
Number of visitors in Django
0
-0.099668
1
0
0
4,771
1,014,239
2009-06-18T17:57:00.000
0
0
0
0
0
wxpython,wxwidgets
0
1,021,396
0
3
0
false
0
1
from wxPython docs """ longHelpString This string is shown in the statusbar (if any) of the parent frame when the mouse pointer is inside the tool """ so toolbar in notebook doesn't get any statusbar to display long help, so either thru src we should invertigate how it inquires abt status bar and supply a ref to main frame status bar else i think better way is to just override wxToolBar::OnMouseEnter and display help directly on status bar
1
2
0
0
I have an interface that has two toolbars, one attached to the frame and one embedded in a notebook tab. The one in the frame dutifully shows longHelp strings in the statusbar, the one in the notebook tab does not. How do I tell the one on the notebook tab where to display its help, or do I have to manage enter and leave bindings myself?
wxPython: how to make two toolbars use one statusbar for tooltips?
0
0
1
0
0
948
1,016,301
2009-06-19T04:04:00.000
8
1
1
0
0
python,chuck,puredata
0
1,016,318
0
4
0
true
0
0
I would say learn them all. While it's true that many languages can do many things, specialised languages are usually more expressive and easier to use for a particular task. Case-in-point is while most languages allow shell interaction and process control very few are as well suited to the task as bash scripts. Plugins and libraries can bridge the gap between general and specialised languages but in my experience this is not always without drawbacks - be they speed, stability or complexity. It isn't uncommon to have to compile additional libraries or apply patches or use untrusted and poorly supported modules. It also isn't uncommon that the resulting interface is still harder to use than the original language. I know about 15 languages well and a few of those very well. I do not use my prefered languages when another is more suitable.
2
6
0
0
I am learning Python because it appeals to me as a mathematician but also has many useful libraries for scientific computing, image processing, web apps, etc etc. It is frustrating to me that for certain of my interests (eletronic music or installation art) there are very specific programming languages which seem better suited to these purposes, such as Max/MSP, PureData, and ChucK -- all quite fascinating. My question is, how should one approach these different languages? Should I simply learn Python and manage the others by using plugins and Python interpreters in them? Are there good tools for integrating the languages, or is the proper way simply to learn all of them?
Synthesis of general programming language (Python) with tailored language (PureData/MaxMSP/ChucK)
1
1.2
1
0
0
1,140
1,016,301
2009-06-19T04:04:00.000
4
1
1
0
0
python,chuck,puredata
0
1,716,786
0
4
0
false
0
0
This thread is a little old, but I wanted to point out that the majority of the mature audio development environments e.g. supercollider/max-msp/pure data can be controlled via open sound control. You can google up a better description of OSC, but suffice it to say that it allows you to send control data to synths built in these environments similar to how MIDI works, but way more extensive. This does not solve the problem of actually building synths in python per se but it allows you to "drive" these other environments without having to know the ins and outs of the language.
2
6
0
0
I am learning Python because it appeals to me as a mathematician but also has many useful libraries for scientific computing, image processing, web apps, etc etc. It is frustrating to me that for certain of my interests (eletronic music or installation art) there are very specific programming languages which seem better suited to these purposes, such as Max/MSP, PureData, and ChucK -- all quite fascinating. My question is, how should one approach these different languages? Should I simply learn Python and manage the others by using plugins and Python interpreters in them? Are there good tools for integrating the languages, or is the proper way simply to learn all of them?
Synthesis of general programming language (Python) with tailored language (PureData/MaxMSP/ChucK)
1
0.197375
1
0
0
1,140
1,019,707
2009-06-19T19:35:00.000
0
1
0
1
1
python,c,linux,security,sandbox
0
1,029,301
0
12
0
false
1
0
I think your solutions must concentrate on analyzing the source code. I don't know any tools, and I think this would be pretty hard with C, but, for example, a Pascal program which doesn't include any modules would be pretty harmless in my opinion.
3
16
0
0
I want to create a Web app which would allow the user to upload some C code, and see the results of its execution (the code would be compiled on the server). The users are untrusted, which obviously has some huge security implications. So I need to create some kind of sandbox for the apps. At the most basic level, I'd like to restrict access to the file system to some specified directories. I cannot use chroot jails directly, since the web app is not running as a privileged user. I guess a suid executable which sets up the jail would be an option. The uploaded programs would be rather small, so they should execute quickly (a couple of seconds at most). Hence, I can kill the process after a preset timeout, but how do I ensure that it doesn't spawn new processes? Or if I can't, is killing the entire pgid a reliable method? What would be the best way to go about this - other than "don't do it at all"? :) What other glaring security problems have I missed? FWIW, the web app will be written in Python.
Sandboxing in Linux
0
0
1
0
0
7,104
1,019,707
2009-06-19T19:35:00.000
-2
1
0
1
1
python,c,linux,security,sandbox
0
1,019,986
0
12
0
false
1
0
About the only chance you have is running a VirtualMachine and those can have vulnerabilities. If you want your machine hacked in the short term just use permissions and make a special user with access to maybe one directory. If you want to postpone the hacking to some point in the future then run a webserver inside a virtual machine and port forward to that. You'll want to keep a backup of that because you'll probably have that hacked in under an hour and want to restart a fresh copy every few hours. You'll also want to keep an image of the whole machine to just reimage the whole thing once a week or so in order to overcome the weekly hackings. Don't let that machine talk to any other machine on your network. Blacklist it everywhere. I'm talking about the virtual machine and the physical machine IP addresses. Do regular security audits on any other machines on your other machines on the network. Please rename the machines IHaveBeenHacked1 and IHaveBeenHacked2 and prevent access to those in your hosts lists and firewalls. This way you might stave off your level of hackage for a while.
3
16
0
0
I want to create a Web app which would allow the user to upload some C code, and see the results of its execution (the code would be compiled on the server). The users are untrusted, which obviously has some huge security implications. So I need to create some kind of sandbox for the apps. At the most basic level, I'd like to restrict access to the file system to some specified directories. I cannot use chroot jails directly, since the web app is not running as a privileged user. I guess a suid executable which sets up the jail would be an option. The uploaded programs would be rather small, so they should execute quickly (a couple of seconds at most). Hence, I can kill the process after a preset timeout, but how do I ensure that it doesn't spawn new processes? Or if I can't, is killing the entire pgid a reliable method? What would be the best way to go about this - other than "don't do it at all"? :) What other glaring security problems have I missed? FWIW, the web app will be written in Python.
Sandboxing in Linux
0
-0.033321
1
0
0
7,104
1,019,707
2009-06-19T19:35:00.000
0
1
0
1
1
python,c,linux,security,sandbox
0
15,609,095
0
12
0
false
1
0
Spawning a new VM under KVM or qemu to compile and run the code looks like the way to go. Running the code under jail/LXC can compromise the machine if it exploits the unsecured parts of the OS like networking code. Advantage of running under a VM are obvious. One can only hack the VM but not the machine itself. But the side effect is you need lots of resources (CPU and Memory) to spawn a VM for each request.
3
16
0
0
I want to create a Web app which would allow the user to upload some C code, and see the results of its execution (the code would be compiled on the server). The users are untrusted, which obviously has some huge security implications. So I need to create some kind of sandbox for the apps. At the most basic level, I'd like to restrict access to the file system to some specified directories. I cannot use chroot jails directly, since the web app is not running as a privileged user. I guess a suid executable which sets up the jail would be an option. The uploaded programs would be rather small, so they should execute quickly (a couple of seconds at most). Hence, I can kill the process after a preset timeout, but how do I ensure that it doesn't spawn new processes? Or if I can't, is killing the entire pgid a reliable method? What would be the best way to go about this - other than "don't do it at all"? :) What other glaring security problems have I missed? FWIW, the web app will be written in Python.
Sandboxing in Linux
0
0
1
0
0
7,104
1,025,018
2009-06-21T23:31:00.000
1
0
1
0
0
python,ajax,autocomplete,trie
0
1,025,027
0
2
0
false
1
0
I would use the first option. 'KISS' - (Keep It Simple Stupid). For small amounts of data there shouldn't be much latency. We run the same kind of thing for a name search and results appear pretty quickly on a few thousand rows. Hope that helps, Josh
1
2
0
0
I'm implementing a "Google Suggest" like autocomplete feature for tag searching using jQuery's autocomplete. I need to provide a web service to jQuery giving it a list of suggestions based on what the user has typed. I see 2 ways of implementing the web service: 1) just store all the tags in a database and search the DB using user input as prefix. This is simple, but I'm concerned about latency. 2) Use an in-process trie to store all the tags and search it for matching results. As everything will be in-process, I expect this to have much lower latency. But there are several difficulties: -What's a good way to initialize the trie on process start up? Presumable I'll store the tag data in a DB and retrieve them and turn them into a trie when I frist start up the process. But I'm not sure how. I'm using Python/Django. -When a new tag is created by a user, I need to insert the new tag into the trie. But let's say I have 5 Django processes and hence 5 tries, how do I tell the other 4 tries that they need to insert a new tag too? -How to make sure the trie is threadsafe as my Django processes will be threaded (I'm using mod_wsgi). Or do I not have to worry about threadsafty because of Python's GIL? -Any way I can store the tag's frequency of use within the trie as well? How do I tell when does the tag's string end and when does the frequency start - eg. if I store apple213 into the trie, is it "apple" with frequency 213 or is it "apple2" with frequency 13?? Any help on the issues above or any suggestions on a different approach would be really appreciated.
What's the best way to implement web service for ajax autocomplete
0
0.099668
1
0
0
1,169
1,032,888
2009-06-23T14:24:00.000
0
0
0
0
0
c#,ironpython
0
1,034,326
0
2
0
false
1
0
Jonathan helped me to figure out that I had not copied the dll file to the location where IronPython can find it. After copying the dll file to the location, usually it s "c:\Program Files\IronPython 2.0\" unless stated otherwise, I did: import clr clr.AddReference('System.Data') clr.AddReferenceToFile('Sql400.dll') from System.Data import Sql400 from System.Data.Sql400 import *
2
0
0
0
I was just wondering if anybody knows how to add reference to "Ritmo for iSeries" in IronPython. I did it successfully in C# and get it to work (since it is just click click click) And I was trying to do the same in IronPython but it says, "could not add reference to assembly Ritmo for iSeries". I was doing import clr clr.AddReference('Ritmo for iSeries') from Ritmo........ IOError: Could not add reference to assembly Ritmo for iSeries
how to addreference to Ritmo for iSeries in ironpython
0
0
1
0
0
438
1,032,888
2009-06-23T14:24:00.000
0
0
0
0
0
c#,ironpython
0
1,032,962
0
2
0
false
1
0
You need to use the actual name of the assembly (it won't have spaces). In your C# project, what does it list under the 'references' folder once you've added it as a reference? Try putting that. Also, make sure you've copied the dll for the library to where your IronPython script can find it (if it's not in the GAC).
2
0
0
0
I was just wondering if anybody knows how to add reference to "Ritmo for iSeries" in IronPython. I did it successfully in C# and get it to work (since it is just click click click) And I was trying to do the same in IronPython but it says, "could not add reference to assembly Ritmo for iSeries". I was doing import clr clr.AddReference('Ritmo for iSeries') from Ritmo........ IOError: Could not add reference to assembly Ritmo for iSeries
how to addreference to Ritmo for iSeries in ironpython
0
0
1
0
0
438
1,038,182
2009-06-24T12:54:00.000
0
0
0
0
0
wxpython
0
14,180,592
0
3
0
false
1
1
stylesheet, not slidesheet. f = open('NAMEOFSTYLESHEET.css','w') f.write('#ID{}\n.class{}')
1
0
0
0
How to convert HTML CSS file to wxPython files? That is, how to create slidsheet in wxPython like HTML CSS files?
HTML conversion
0
0
1
0
0
677
1,043,382
2009-06-25T11:19:00.000
2
0
1
0
0
python,encryption
0
1,051,793
0
4
0
false
0
0
I looked at the ezPyCrypto library that was recommended in another answer. Please don't use this library. It is very incomplete and in some cases incorrect and highly insecure. Public key algorithms have many pitfalls and need to be implemented carefully. For example, RSA message should use a padding scheme such as PKCS #1, OAEP etc to be secure. This library doesn't pad. DSA signatures should use the SHA1 hash function. This library uses the broken MD5 hash and there is even a bigger bug in the random number generation. Hence the DSA implementation is neither standards conform nor secure. ElGamal is also implemented incorrectly. Following standards does make implementations somewhat more complex. But not following any is not an option. At least not if you care about security.
1
2
0
0
I need to take a string in Python and encrypt it using a public key. Can anyone give me an example or recommendation about how to go about doing this?
Encrypt a string using a public key
0
0.099668
1
0
0
2,977
1,043,528
2009-06-25T11:59:00.000
2
0
0
0
0
python,web-services,database-design
0
1,043,653
0
5
0
true
0
0
Server 1: Convert rows to JSON, call the RESTful api of second with JSON data Server 2: listens on a URI e.g. POST /data , get json data convert back to dictionary or ORM objects, insert into db sqlalchemy/sqlobject and simplejson is what you need.
2
2
0
0
I have a system sitting on a "Master Server", that is periodically transferring quite a few chunks of information from a MySQL DB to another server in the web. Both servers have a MySQL Server and an Apache running. I would like an easy-to-use solution for this. Currently I'm looking into: XMLRPC RestFul Services a simple POST to a processing script socket transfers The app on my master is a TurboGears app, so I would prefer "pythonic" aka less ugly solutions. Copying a dumped table to another server via FTP / SCP or something like that might be quick, but in my eyes it is also very (quick and) dirty, and I'd love to have a nicer solution. Can anyone describe shortly how you would do this the "best-practise" way? This doesn't necessarily have to involve Databases. Dumping the table on Server1 and transferring the raw data in a structured way so server2 can process it without parsing too much is just as good. One requirement though: As soon as the data arrives on server2, I want it to be processed, so there has to be a notification of some sort when the transfer is done. Of course I could just write my whole own server sitting on a socket on the second machine and accepting the file with own code and processing it and so forth, but this is just a very very small piece of a very big system, so I dont want to spend half a day implementing this. Thanks, Tom
Best Practise for transferring a MySQL table to another server?
1
1.2
1
1
0
810
1,043,528
2009-06-25T11:59:00.000
0
0
0
0
0
python,web-services,database-design
0
1,043,595
0
5
0
false
0
0
Assuming your situation allows this security-wise, you forgot one transport mechanism: simply opening a mysql connection from one server to another. Me, I would start by thinking about one script that ran regularly on the write server and opens a read only db connection to the read server (A bit of added security) and a full connection to it's own data base server. How you then proceed depends on the data (is it just inserts to deal with? do you have to mirror deletes? how many inserts vs updates? etc) but basically you could write a script that pulled data from the read server and processed it immediately into the write server. Also, would mysql server replication work or would it be to over-blown as a solution?
2
2
0
0
I have a system sitting on a "Master Server", that is periodically transferring quite a few chunks of information from a MySQL DB to another server in the web. Both servers have a MySQL Server and an Apache running. I would like an easy-to-use solution for this. Currently I'm looking into: XMLRPC RestFul Services a simple POST to a processing script socket transfers The app on my master is a TurboGears app, so I would prefer "pythonic" aka less ugly solutions. Copying a dumped table to another server via FTP / SCP or something like that might be quick, but in my eyes it is also very (quick and) dirty, and I'd love to have a nicer solution. Can anyone describe shortly how you would do this the "best-practise" way? This doesn't necessarily have to involve Databases. Dumping the table on Server1 and transferring the raw data in a structured way so server2 can process it without parsing too much is just as good. One requirement though: As soon as the data arrives on server2, I want it to be processed, so there has to be a notification of some sort when the transfer is done. Of course I could just write my whole own server sitting on a socket on the second machine and accepting the file with own code and processing it and so forth, but this is just a very very small piece of a very big system, so I dont want to spend half a day implementing this. Thanks, Tom
Best Practise for transferring a MySQL table to another server?
1
0
1
1
0
810
1,048,446
2009-06-26T10:44:00.000
1
0
1
0
0
wxpython
0
1,048,463
0
1
0
false
0
1
You need to give your text control the TE_PASSWORD style. (As Jørn's comment points out, this isn't "encryption" - I'm assuming you're only talking about the visual presentation of the password.)
1
0
0
0
I am developing an student attendance application in wxpython and I need to know how to ensure that password field doesn't echo characters to the screen. Forexample :if I give the name as moni means then it should be displayed as in format of ****
Hiding characters typed into password field
0
0.197375
1
0
0
427
1,050,089
2009-06-26T16:39:00.000
1
1
0
0
0
php,python,perl,parsing,feed
0
1,050,136
0
4
0
false
0
0
Most modern languages scripting languages allow you to do all of these things. Because of that, I think your choice of language should be based on what you and the people who read your code know. In Perl I'd make use of the following modules: Net::FTP to access the ftp sites. DBI to insert data into your database. Modules like that are nice reusable pieces of code that you don't have to write, and interaction with ftp sites and databases are so common that every modern scripting language should have similar modules. I don't think that PHP is a great language so I'd avoid it if possible, but it might make sense for you if you have a lot of experience in it.
1
2
0
0
I've been having to do some basic feed processing. So, get a file via ftp, process it (i.e. get the fields I care about), and then update the local database. And similarly the other direction: get data from db, create file, and upload by ftp. The scripts will be called by cron. I think the idea would be for each type of feed, define the ftp connection/file information. Then there should be a translation of how data fields in the file relate to data fields that the application can work with (and of course process this translation). Additionally write separate scripts that do the common inserting functions for the different objects that may be used in different feeds. As an e-commerce example, lets say I work with different suppliers who provide feeds to me. The feeds can be different (object) types: product, category, or order information. For each type of feed I obviously work with different fields and call different update or insert scripts. What is the best language to implement this in? I can work with PHP but am looking for a project to start learning Perl or Python so this could be good for me as well. If Perl or Python, can you briefly give high level implementation. So how to separate the different scripts, object oriented approach?, how to make it easy to implement new feeds or processing functions in the future, etc. [full disclosure: There were already classes written in PHP which I used to create a new feed recently. I already did my job, but it was super messy and difficult to do. So this question is not 'Please help me do my job' but rather a 'best approach' type of question for my own development.] Thanks!
Get remote text file, process, and update database - approach and scripting language to use?
0
0.049958
1
0
0
1,025
1,053,794
2009-06-27T22:41:00.000
1
0
1
0
0
python,windows
0
1,053,888
0
2
0
false
0
0
just FYI, since both c:\python25 and c:\python26 are on PATH, I copy C:\Python25\python.exe to C:\Python25\py25.exe, and copy C:\Python26\python.exe to C:\Python26\py26.exe Then just type py25(or py26) get the specific version.
2
5
0
0
I have two python installations, 2.5 and 2.6 I want to change the default python interpreter from 2.5 to 2.6. Anyone know how?
Changing python interpreter windows
0
0.099668
1
0
0
7,934
1,053,794
2009-06-27T22:41:00.000
10
0
1
0
0
python,windows
0
1,053,856
0
2
0
true
0
0
PYTHONPATH is NOT what you are looking for. That is for varying where Python's "import" looks for packages and modules. You need to change the PATH variable in your environment so that it contains e.g. "....;c:\python26;...." instead of "....;c:\python25;....". Click on start > control panel > system > advanced > environment variables. Select "path". Edit it. Click on OK enough times to get out of there.
2
5
0
0
I have two python installations, 2.5 and 2.6 I want to change the default python interpreter from 2.5 to 2.6. Anyone know how?
Changing python interpreter windows
0
1.2
1
0
0
7,934
1,063,626
2009-06-30T13:14:00.000
7
0
0
0
0
python,django,unicode
0
1,063,665
0
2
0
true
1
0
You are probably storing the template in a non-unicode encoding, such as latin-1. I believe Django assumes that templates are in UTF-8 by default (though there is a setting to override this). Your editor should be capable of saving the template file in the UTF-8 encoding (probably via a dropdown on the save as page, though this may depend on your editor). Re-save the file as UTF-8, and the error should go away.
1
5
0
0
I have some french letters (é, è, à...) in a django template but when it is loaded by django, an UnicodeDecodeError exception is raised. If I don't load the template but directly use a python string. It works ok. Is there something to do to use unicode with django template?
how to use french letters in a django template?
0
1.2
1
0
0
4,002
1,063,770
2009-06-30T13:45:00.000
-10
0
0
0
0
python,transactions,pyodbc
0
1,063,879
0
2
1
false
0
0
I don't think pyodbc has any specific support for transactions. You need to send the SQL command to start/commit/rollback transactions.
1
15
0
0
I have a username which I must change in numerous (up to ~25) tables. (Yeah, I know.) An atomic transaction seems to be the way to go for this sort of thing. However, I do not know how to do this with pyodbc. I've seen various tutorials on atomic transactions before, but have never used them. The setup: Windows platform, Python 2.6, pyodbc, Microsoft SQL 2005. I've used pyodbc for single SQL statements, but no compound statements or transactions. Best practices for SQL seem to suggest that creating a stored procedure is excellent for this. My fears about doing a stored procedure are as follows, in order of increasing importance: 1) I have never written a stored procedure. 2) I heard that pyodbc does not return results from stored procedures as of yet. 3) This is most definitely Not My Database. It's vendor-supplied, vendor-updated, and so forth. So, what's the best way to go about this?
In Python, Using pyodbc, How Do You Perform Transactions?
0
-1
1
1
0
27,883
1,075,304
2009-07-02T16:16:00.000
3
1
0
1
0
python,eclipse,pydev,scons
0
1,075,694
0
6
0
true
1
0
I'm not an Eclipse expert, but since you didn't get any other answer... If you make the SCons source a part of the Eclipse project, and run the whole command from within Eclipse it should work like any Eclipse debugging. SCons is written in Python, there is no reason it shouldn't be debuggable in Eclipse just like anything else.
5
4
0
0
I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?
How to debug SCons scripts using eclipse and pydev?
1
1.2
1
0
0
2,414
1,075,304
2009-07-02T16:16:00.000
0
1
0
1
0
python,eclipse,pydev,scons
0
45,216,082
0
6
0
false
1
0
As an addendum: on Windows, I had to copy the scons-installed files to reside under C:\Python27\Lib\site-packages\scons in order for this to work. Adding the original installed location, qualified with the version number, to the PYTHONPATH, did not work.
5
4
0
0
I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?
How to debug SCons scripts using eclipse and pydev?
1
0
1
0
0
2,414
1,075,304
2009-07-02T16:16:00.000
1
1
0
1
0
python,eclipse,pydev,scons
0
15,386,322
0
6
0
false
1
0
On MAC to debug scons through pydev follow Lennart's answer but with one simply addition. Using Finder (or terminal) browse to where scons is installed. You can find this with the "which" command. e.g. which scons -> /usr/local/bin/scons Make a copy of the scons file and call it scons.py. Now when you create the Debug Configuration in Eclipse use scons.py as the "Main Module". PS: To add a scons project to Eclipse I found it easier to use a "Linked Folder" pointing at /usr/local/bin/. i.e. Because I was getting a read-only error when trying to add the directory itself.
5
4
0
0
I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?
How to debug SCons scripts using eclipse and pydev?
1
0.033321
1
0
0
2,414
1,075,304
2009-07-02T16:16:00.000
6
1
0
1
0
python,eclipse,pydev,scons
0
1,077,102
0
6
0
false
1
0
You are right. Since the SCons is python based, the SCons scripts are debuggable via EClipse PyDev. For this, you need to do the following in the debug configuration... 1. Under the main tab, set the main module to the SCons file which will be available under the python/scripts directory if you have installed SCons. If you have not run the install of SCons you can point to this file under the SCons directory. 2. Under the arguments tab, set the working directory to the root of your project. Now set the breakpoint either on SConstruct or SConcript and run in debug mode. That's all!! With this approach you can not only debug your product code but also the build scripts that builds your product :-) Happy Debugging!!!!
5
4
0
0
I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?
How to debug SCons scripts using eclipse and pydev?
1
1
1
0
0
2,414
1,075,304
2009-07-02T16:16:00.000
0
1
0
1
0
python,eclipse,pydev,scons
0
32,887,089
0
6
0
false
1
0
I've since gain more experience with SCons / Python and I'd recommend using python's pdb module. To use it simply add the following code to your SCons/Python files. import pdb; pdb.set_trace() When the file is run from the command line a breakpoint will be hit at this line. I also moved away from Eclipse. A lightweight editor will be just as good for Python development. I use Sublime.
5
4
0
0
I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?
How to debug SCons scripts using eclipse and pydev?
1
0
1
0
0
2,414
1,077,649
2009-07-03T03:24:00.000
3
0
1
0
0
python,windows,wxpython
0
1,077,697
0
2
0
true
0
1
I would advice to do it in two steps. First step is to save your prefs. as string, for that you can a) Use any xml lib or output xml by hand to output string and read similarly from string b) Just use pickle module to dump your prefs object as a string c) Somehow generate a string from prefs which you can read back as prefs e.g. use yaml, config , JSON etc actually JSON is a good option when simplejson makes it so easy. Once you have your methods to convert to and from string are ready, you just need to store it somewhere where it is persisted and you can read back next time, for that you can a) Use wx.Config which save to registry in windows and to other places depending on platform so you don't have to worry where it saves, you can just read back values in platform independent way. But if you wish you can just use wx.Config for directly saving reading prefs. b) Directly save prefs. string to a file in a folder assigned by OS to your app e.g. app data folder in windows. Benefit of saving to a string and than using wx.Config to save it, is that you can easily change where data is saved in future e.g. in future if there is a need to upload prefs. you can just upload prefs. string.
1
1
0
0
Developing a project of mine I realize I have a need for some level of persistence across sessions, for example when a user executes the application, changes some preferences and then closes the app. The next time the user executes the app, be it after a reboot or 15 minutes, I would like to be able to retain the preferences that had been changed. My question relates to this persistence. Whether programming an application using the win32 API or the MFC Framework .. or using the newer tools for higher level languages such as wxPython or wxRuby, how does one maintain the type of persistence I refer to? Is it done as a temporary file written to the disk? Is it saved into some registry setting? Is there some other layer it is stored in that I am unaware of?
Windows Application Programming & wxPython
0
1.2
1
0
0
729
1,085,304
2009-07-06T03:33:00.000
3
0
0
0
0
python,sqlalchemy
0
1,087,081
0
3
0
false
0
0
Automatic partitioning is a very database engine specific concept and SQLAlchemy doesn't provide any generic tools to manage partitioning. Mostly because it wouldn't provide anything really useful while being another API to learn. If you want to do database level partitioning then do the CREATE TABLE statements using custom Oracle DDL statements (see Oracle documentation how to create partitioned tables and migrate data to them). You can use a partitioned table in SQLAlchemy just like you would use a normal table, you just need the table declaration so that SQLAlchemy knows what to query. You can reflect the definition from the database, or just duplicate the table declaration in SQLAlchemy code. Very large datasets are usually time-based, with older data becoming read-only or read-mostly and queries usually only look at data from a time interval. If that describes your data, you should probably partition your data using the date field. There's also application level partitioning, or sharding, where you use your application to split data across different database instances. This isn't all that popular in the Oracle world due to the exorbitant pricing models. If you do want to use sharding, then look at SQLAlchemy documentation and examples for that, for how SQLAlchemy can support you in that, but be aware that application level sharding will affect how you need to build your application code.
1
2
0
0
I am not very familiar with databases, and so I do not know how to partition a table using SQLAlchemy. Your help would be greatly appreciated.
how to make table partitions?
0
0.197375
1
1
0
7,505
1,095,265
2009-07-07T22:55:00.000
4
1
0
0
0
python,matlab,file-io,import,matrix
0
1,095,296
0
7
0
false
0
0
You could write the matrix in Python to a CSV file and read it in MATLAB using csvread.
2
51
1
0
I'm working with Python and MATLAB right now and I have a 2D array in Python that I need to write to a file and then be able to read it into MATLAB as a matrix. Any ideas on how to do this? Thanks!
Matrix from Python to MATLAB
0
0.113791
1
0
0
69,405
1,095,265
2009-07-07T22:55:00.000
5
1
0
0
0
python,matlab,file-io,import,matrix
0
7,737,622
0
7
0
false
0
0
I would probably use numpy.savetxt('yourfile.mat',yourarray) in Python and then yourarray = load('yourfile.mat') in MATLAB.
2
51
1
0
I'm working with Python and MATLAB right now and I have a 2D array in Python that I need to write to a file and then be able to read it into MATLAB as a matrix. Any ideas on how to do this? Thanks!
Matrix from Python to MATLAB
0
0.141893
1
0
0
69,405
1,113,040
2009-07-11T05:45:00.000
1
1
0
1
0
python,c,macos,fonts
0
1,113,055
0
5
0
false
0
0
Do you want to write a program to do it, or do you want to use a program to do it? There are many programs that list fonts, xlsfonts comes to mind.
1
5
0
0
I'm trying to programatically get a list of installed fonts in C or Python. I need to be able to do this on OS X, does anyone know how?
List of installed fonts OS X / C
0
0.039979
1
0
0
5,834
1,113,066
2009-07-11T06:02:00.000
1
0
0
1
1
java,python,google-app-engine,httpwebrequest,keep-alive
0
4,707,002
0
4
0
false
1
0
App engine also has a new PAY feature where you can have it "always-on". Costs about $0.30 USD cents a day. Just go into your billing settings and enable it if you don't mind paying for the feature. I believe it guarantees you at least 3 instances always running. (I didn't realize hitting a /ping url which caused an instance to spin up would cause it to exceed the 30 sec limit!)
1
3
0
0
App Engine allows you 30 seconds to load your application My application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this. If the app is idle (does not receive a request for a while), it needs to be re-loaded. So, to avoid the app needing to be reloaded, I want to simulate user activity by pinging the app every so often. But there's a catch . . . If I ping the app and it has already been unloaded by App Engine, my web request will be the first request to the app and the app will try to reload. This could take longer than 30 seconds and exceed the loading time limit. So my idea is to ping the app but not wait for the response. I have simulated this manually by going to the site from a browser, making the request and immediately closing the browser - it seems to keep the app alive. Any suggestions for a good way to do this in a Python or Java web cron (I'm assuming a Python solution will be simpler)?
How to keep an App Engine/Java app running with deaf requests from a Java/Python web cron?
0
0.049958
1
0
0
1,731
1,114,312
2009-07-11T18:11:00.000
14
0
1
1
0
python,process
0
1,114,435
0
3
0
false
0
0
os.kill does not kill processes, it sends them signals (it's poorly named). If you send signal 0, you can determine whether you are allowed to send other signals. An error code will indicate whether it's a permission problem or a missing process. See man 2 kill for more info. Also, if the process is your child, you can get a SIGCHLD when it dies, and you can use one of the wait calls to deal with it.
1
3
0
0
I have a process id in Python. I know I can kill it with os.kill(), but how do I check if it is alive ? Is there a built-in function or do I have to go to the shell?
How do I check if a process is alive in Python on Linux?
0
1
1
0
0
15,728
1,126,116
2009-07-14T15:19:00.000
13
0
0
1
0
python,shell,variables,subprocess,persistent
0
1,126,137
0
2
0
true
0
0
subprocess.Popen takes an optional named argument env that's a dictionary to use as the subprocess's environment (what you're describing as "shell variables"). Prepare a dict as you need it (you may start with a copy of os.environ and alter that as you need) and pass it to all the subprocess.Popen calls you perform.
1
8
0
0
I'm trying to execute a series of commands using Pythons subprocess module, however I need to set shell variables with export before running them. Of course the shell doesn't seem to be persistent so when I run a command later those shell variables are lost. Is there any way to go about this? I could create a /bin/sh process, but how would I get the exit codes of the commands run under that?
Python: Persistent shell variables in subprocess
0
1.2
1
0
0
3,185
1,126,842
2009-07-14T17:28:00.000
0
0
1
0
0
python,windows-xp,cygwin
0
1,128,193
0
5
0
false
0
0
This probably has little value, but... I found myself in this exact situation -- we use ActivePython2.5 in production (pure windows environment) and I was trying to do my development within cygwin and cygwin's Python... After ripping out half of my hair, I have now switched over to Console2, gvim, iPython and ActivePython2.5. I'm less than thrilled dealing with Windows tools (and their concomitant warts), but at least I'm not getting in my own way when it comes to development. For a while I found I was spending more time trying to get my tools to play nice than actually getting any work done. Good luck on this one.
4
3
0
0
Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.
Best way to have full Python install under cygwin/XP?
0
0
1
0
0
2,747
1,126,842
2009-07-14T17:28:00.000
2
0
1
0
0
python,windows-xp,cygwin
0
1,126,885
0
5
0
true
0
0
I use Python from within cygwin, but I don't use the version that cygwin gives you the option of installing as I don't have the control over version number used that I need (we use an older version at work). I have my python version installed via the windows installer (the xp version as you put it) and add the /cygdrive/c/Python2x directory to my PATH environment variable.
4
3
0
0
Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.
Best way to have full Python install under cygwin/XP?
0
1.2
1
0
0
2,747
1,126,842
2009-07-14T17:28:00.000
0
0
1
0
0
python,windows-xp,cygwin
0
1,126,874
0
5
0
false
0
0
Just a little off the question, but... Have you considered running Sun's VirtualBox with Fedora or Ubuntu inside of it? I'm assuming you have to / need to use windows because you still are, but don't like it. Then you would have python running inside a native linux desktop without any of the troubles you mentioned. And if you want something that is really easy and portable, then just use Python on Windows, not mixed in with cygwin. $0.02
4
3
0
0
Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.
Best way to have full Python install under cygwin/XP?
0
0
1
0
0
2,747
1,126,842
2009-07-14T17:28:00.000
0
0
1
0
0
python,windows-xp,cygwin
0
11,792,553
0
5
0
false
0
0
I accidentally stumbled on this - If I launch Cygwin from the Cygwin.bat file (which is present directly under the main folder), I get access to the Python version installed under Cygwin (i.e 2.6.8) If I instead launch the Cygwin from bash.exe under bin directory (C:\Cygwin\bin\bash.exe for me), running "Python -V" shows that I have access to 2.7.3 version of Python (that was installed for Windows). So, I guess you can do the same.
4
3
0
0
Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.
Best way to have full Python install under cygwin/XP?
0
0
1
0
0
2,747