Available Count
int64
1
31
AnswerCount
int64
1
35
GUI and Desktop Applications
int64
0
1
Users Score
int64
-17
588
Q_Score
int64
0
6.79k
Python Basics and Environment
int64
0
1
Score
float64
-1
1.2
Networking and APIs
int64
0
1
Question
stringlengths
15
7.24k
Database and SQL
int64
0
1
Tags
stringlengths
6
76
CreationDate
stringlengths
23
23
System Administration and DevOps
int64
0
1
Q_Id
int64
469
38.2M
Answer
stringlengths
15
7k
Data Science and Machine Learning
int64
0
1
ViewCount
int64
13
1.88M
is_accepted
bool
2 classes
Web Development
int64
0
1
Other
int64
1
1
Title
stringlengths
15
142
A_Id
int64
518
72.2M
1
3
0
0
2
0
0
1
What would be the best method to restrict access to my XMLRPC server by IP address? I see the class CGIScript in web/twcgi.py has a render method that is accessing the request... but I am not sure how to gain access to this request in my server. I saw an example where someone patched twcgi.py to set environment variables and then in the server access the environment variables... but I figure there has to be a better solution. Thanks.
0
python,twisted
2009-08-13T17:03:00.000
0
1,273,297
I'd use a firewall on windows, or iptables on linux.
0
3,265
false
0
1
Python Twisted: restricting access by IP address
1,273,455
2
3
0
2
1
1
0.132549
0
I have the Python expression n <<= 1 How do you express this in PHP?
0
php,python,operators,bitwise-operators
2009-08-13T20:50:00.000
0
1,274,493
$n <<= 1; is valid php
0
527
false
0
1
How can I write 'n <<= 1' (Python) in PHP?
1,274,508
2
3
0
5
1
1
1.2
0
I have the Python expression n <<= 1 How do you express this in PHP?
0
php,python,operators,bitwise-operators
2009-08-13T20:50:00.000
0
1,274,493
It's the same operator in php. $n <<= 1;
0
527
true
0
1
How can I write 'n <<= 1' (Python) in PHP?
1,274,505
1
6
0
2
1
1
0.066568
0
Sequence 1.1.1 ATGCGCGCGATAAGGCGCTA ATATTATAGCGCGCGCGCGGATATATATATATATATATATT Sequence 1.2.2 ATATGCGCGCGCGCGCGGCG ACCCCGCGCGCGCGCGGCGCGATATATATATATATATATATT Sequence 2.1.1 ATTCGCGCGAGTATAGCGGCG NOW,I would like to remove the last digit from each of the line that starts with '>'. For example, in this first line, i would like to remove '.1' (rightmost) and in second instance i would like to remove '.2' and then write the rest of the file to a new file. Thanks,
0
python,file
2009-08-14T15:52:00.000
0
1,278,664
map "".join(line.split('.')[:-1]) to each line of the file.
0
336
false
0
1
How to eliminate last digit from each of the top lines
1,278,690
1
2
0
4
1
0
1.2
0
Question: How do I get a byte stream that works like StringIO for Python 2.5? Application: I'm converting a PDF to text, but don't want to save a file to the hard disk. Other Thoughts: I figured I could use StringIO, but there's no mode parameter (I guess "String" implies text mode). Apparently the io.BytesIO class is new in v2.6, so that doesn't work for me either. I've got a solution with the tempfile module, but I'd like to avoid any reads/writes to/from the hard disk.
0
python,stringio,bytesio
2009-08-14T17:54:00.000
0
1,279,244
In Python 2.x, "string" means "bytes", and "unicode" means "string". You should use the StringIO or cStringIO modules. The mode will depend on which kind of data you pass in as the buffer parameter.
0
4,303
true
0
1
BytesIO with python v2.5
1,279,251
1
2
0
0
12
0
0
0
I'm not familiar with the PDF specification at all. I was wondering if it's possible to directly manipulate a PDF file so that certain blocks of text that I've identified as important are highlighted in colors of my choice. Language of choice would be python.
0
python,pdf,fonts
2009-08-15T22:52:00.000
0
1,283,065
Highlight is possible in pdf file using PDF annotations but doing it natively is not that easy job. If any of the mentioned library provide such facility is something that you may look for.
0
6,726
false
0
1
Programmatically change font color of text in PDF
1,285,029
1
3
0
11
2
0
1
0
I'd like for a script of mine to have 2 behaviours, one when started as a scheduled task, and another if started manually. How could I test for interactiveness? EDIT: this could either be a cron job, or started by a windows batch file, through the scheduled tasks.
0
python,interactive
2009-08-16T18:48:00.000
1
1,285,024
You should simply add a command-line switch in the scheduled task, and check for it in your script, modifying the behavior as appropriate. Explicit is better than implicit. One benefit to this design: you'll be able to test both behaviors, regardless of how you actually invoked the script.
0
1,179
false
0
1
How can I check to see if a Python script was started interactively?
1,285,056
1
2
0
0
0
0
1.2
0
I am using Pyme to interface with GPGME and have had no problems signing / encrypting. When I try to decrypt, however, it always brings up the prompt for the passphrase despite having set it via a c.set_passphrase_cb callback. Am I doing something wrong?
0
python,gnupg,pyme,gpgme
2009-08-17T16:19:00.000
0
1,288,959
Add "c.set_armor(1)" before you set the passphrase callback.
0
1,048
true
0
1
Python Pyme: Simple decryption without user interaction
2,618,041
2
4
0
1
5
0
0.049958
1
Long story short, I created a new gmail account, and linked several other accounts to it (each with 1000s of messages), which I am importing. All imported messages arrive as unread, but I need them to appear as read. I have a little experience with python, but I've only used mail and imaplib modules for sending mail, not processing accounts. Is there a way to bulk process all items in an inbox, and simply mark messages older than a specified date as read?
0
python,email,gmail,imap,pop3
2009-08-18T20:52:00.000
0
1,296,446
Just go to the Gmail web interface, do an advanced search by date, then select all and mark as read.
0
5,833
false
0
1
Parse Gmail with Python and mark all older than date as "read"
1,296,476
2
4
0
1
5
0
0.049958
1
Long story short, I created a new gmail account, and linked several other accounts to it (each with 1000s of messages), which I am importing. All imported messages arrive as unread, but I need them to appear as read. I have a little experience with python, but I've only used mail and imaplib modules for sending mail, not processing accounts. Is there a way to bulk process all items in an inbox, and simply mark messages older than a specified date as read?
0
python,email,gmail,imap,pop3
2009-08-18T20:52:00.000
0
1,296,446
Rather than try to parse our HTML why not just use the IMAP interface? Hook it up to a standard mail client and then just sort by date and mark whichever ones you want as read.
0
5,833
false
0
1
Parse Gmail with Python and mark all older than date as "read"
1,296,465
1
1
0
7
5
1
1.2
0
scope.SetVariable("math", ?? typeof(System.Math) ??); or do I need create a module?
0
c#,static,ironpython,dynamic-language-runtime
2009-08-19T14:15:00.000
0
1,300,265
You can do: scope.SetVariable("math", DynamicHelpers.GetPythonTypeFromType(typeof(System.Math))); DynamicHelpers is in IronPython.Runtime.Types.
0
1,921
true
0
1
How to import static class (or static method) into IronPython (or DLR) using C# code(not python)?
1,301,404
1
2
0
0
1
0
0
1
I have setup the logging module for my new python script. I have two handlers, one sending stuff to a file, and one for email alerts. The SMTPHandler is setup to mail anything at the ERROR level or above. Everything works great, unless the SMTP connection fails. If the SMTP server does not respond or authentication fails (it requires SMTP auth), then the whole script dies. I am fairly new to python, so I am trying to figure out how to capture the exception that the SMTPHandler is raising so that any problems sending the log message via email won't bring down my entire script. Since I am also writing errors to a log file, if the SMTP alert fails, I just want to keep going, not halt anything. If I need a "try:" statement, would it go around the logging.handlers.SMTPHandler setup, or around the individual calls to my_logger.error()?
0
python,logging,handler
2009-08-20T07:45:00.000
0
1,304,593
You probably need to do both. To figure this out, I suggest to install a local mail server and use that. This way, you can shut it down while your script runs and note down the error message. To keep the code maintainable, you should extends SMTPHandler in such a way that you can handle the exceptions in a single place (instead of wrapping every logger call with try-except).
0
1,574
false
0
1
Python logging SMTPHandler - handling offline SMTP server
1,304,622
1
5
0
0
14
1
0
0
Is there a Python module for the translation of texts from one human language to another? I'm planning to work with texts that are to be pre and post processed with Python scripts. What other Python-integrated approaches can be used?
0
python,linguistics
2009-08-22T16:33:00.000
0
1,316,386
What to use depends on what you want to translate. Texts that are a part of your application, like UI etc. Then use gettext directly, or zope.i18n, which wraps gettext so it's easier to use. Arbitrary texts: The Google Translation API is the thing for you. "Content", ie things that the user of the application will modify and translate: Well... nothing, really. You have to implement that yourself. On your description, it sounds like you are after #2.
0
31,530
false
0
1
Translating human languages in Python
1,316,803
1
3
0
2
2
1
0.132549
0
im looking for simple script that will compile to exe , and i found py2exe before i decide to work with it , what do you think are the pros and cons of the py2exe tool?
0
python,py2exe
2009-08-23T11:13:00.000
0
1,318,311
Look through the third-party libraries that you use. Some libraries (e.g. PIL) do tricks with conditional imports that make it hard for py2exe to bundle the right code. These issues can often be worked around, but a bit of googling up front might save you some headaches later.
0
969
false
0
1
what are the pros/cons of py2exe
1,319,719
3
4
0
6
2
0
1
0
I was just reviewing one of my client's applications which uses some old outdated php framework that doesn't rely on caching at all and is pretty much completely database dependent. I figure I'll just rewrite it from scratch because it's really outdated and in this rewrite I want to implement a caching system. It'd be nice if I could get a few pointers if anyone has done this prior. Rewrite will be done in either PHP or Python Would be nice if I could profile before and after this implementation I have my own server so I'm not restricted by shared hosting
0
php,python,memcached,scalability
2009-08-27T03:57:00.000
0
1,338,777
If your site performance is fine then there's no reason to add caching. Lots of sites can get by without any cache at all, or by moving to a file-system based cache. It's only the super high traffic sites that need memcached. What's "crazy" is code architecture (or a lack of architecture) that makes adding caching in latter difficult.
0
385
false
1
1
Is it crazy to not rely on a caching system like memcached nowadays ( for dynamic sites )?
1,338,810
3
4
0
10
2
0
1.2
0
I was just reviewing one of my client's applications which uses some old outdated php framework that doesn't rely on caching at all and is pretty much completely database dependent. I figure I'll just rewrite it from scratch because it's really outdated and in this rewrite I want to implement a caching system. It'd be nice if I could get a few pointers if anyone has done this prior. Rewrite will be done in either PHP or Python Would be nice if I could profile before and after this implementation I have my own server so I'm not restricted by shared hosting
0
php,python,memcached,scalability
2009-08-27T03:57:00.000
0
1,338,777
Caching, when it works right (==high hit rate), is one of the few general-purpose techniques that can really help with latency -- the harder part of problems generically describes as "performance". You can enhance QPS (queries per second) measures of performance just by throwing more hardware at the problem -- but latency doesn't work that way (i.e., it doesn't take just one month to make a babies if you set nine mothers to work on it;-). However, the main resource used by caching is typically memory (RAM or disk as it may be). As you mention in a comment that the only performance problem you observe is memory usage, caching wouldn't help: it would just earmark some portion of memory to use for caching purposes, leaving even less available as a "general fund". As a resident of California I'm witnessing first-hand what happens when too many resources are earmarked, and I couldn't recommend such a course of action with a clear conscience!-)
0
385
true
1
1
Is it crazy to not rely on a caching system like memcached nowadays ( for dynamic sites )?
1,338,828
3
4
0
0
2
0
0
0
I was just reviewing one of my client's applications which uses some old outdated php framework that doesn't rely on caching at all and is pretty much completely database dependent. I figure I'll just rewrite it from scratch because it's really outdated and in this rewrite I want to implement a caching system. It'd be nice if I could get a few pointers if anyone has done this prior. Rewrite will be done in either PHP or Python Would be nice if I could profile before and after this implementation I have my own server so I'm not restricted by shared hosting
0
php,python,memcached,scalability
2009-08-27T03:57:00.000
0
1,338,777
Depending on the specific nature of the codebase and traffic patterns, you might not even need to re-write the whole site. Horribly inefficient code is not such a big deal if it can be bypassed via cache for 99.9% of page requests. When choosing PHP or Python, make sure you figure out where you're going to host the site (or if you even get to make that call). Many of my clients are already set up on a webserver and Python is not an option. You should also make sure any databases/external programs you want to interface with are well-supported in PHP or Python.
0
385
false
1
1
Is it crazy to not rely on a caching system like memcached nowadays ( for dynamic sites )?
1,338,864
6
7
0
13
19
1
1.2
0
Is there a consensus about the best place to put Python unittests? Should the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules? Perhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a /test subdirectory?). I assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he/she has to remember to update the additional test module if the module under test is modified. I'd be interested to know peoples' thoughts on the best way of organizing unittests.
0
python,unit-testing,testing
2009-08-27T12:52:00.000
0
1,340,892
Where you have to if using a library specifying where unittests should live, in the modules themselves for small projects, or in a tests/ subdirectory in your package for larger projects. It's a matter of what works best for the project you're creating. Sometimes the libraries you're using determine where tests should go, as is the case with Django (where you put your tests in models.py, tests.py or a tests/ subdirectory in your apps). If there are no existing constraints, it's a matter of personal preference. For a small set of modules, it may be more convenient to put the unittests in the files you're creating. For anything more than a few modules I create the tests separately in a tests/ directory in the package. Having testing code mixed with the implementation adds unnecessary noise for anyone reading the code.
0
5,565
true
0
1
Should Python unittests be in a separate module?
1,341,053
6
7
0
4
19
1
0.113791
0
Is there a consensus about the best place to put Python unittests? Should the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules? Perhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a /test subdirectory?). I assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he/she has to remember to update the additional test module if the module under test is modified. I'd be interested to know peoples' thoughts on the best way of organizing unittests.
0
python,unit-testing,testing
2009-08-27T12:52:00.000
0
1,340,892
I generally keep test code in a separate module, and ship the module/package and tests in a single distribution. If the user installs using setup.py they can run the tests from the test directory to ensure that everything works in their environment, but only the module's code ends up under Lib/site-packages.
0
5,565
false
0
1
Should Python unittests be in a separate module?
1,340,964
6
7
0
0
19
1
0
0
Is there a consensus about the best place to put Python unittests? Should the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules? Perhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a /test subdirectory?). I assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he/she has to remember to update the additional test module if the module under test is modified. I'd be interested to know peoples' thoughts on the best way of organizing unittests.
0
python,unit-testing,testing
2009-08-27T12:52:00.000
0
1,340,892
if __name__ == '__main__', etc. is great for small tests.
0
5,565
false
0
1
Should Python unittests be in a separate module?
1,341,011
6
7
0
3
19
1
0.085505
0
Is there a consensus about the best place to put Python unittests? Should the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules? Perhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a /test subdirectory?). I assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he/she has to remember to update the additional test module if the module under test is modified. I'd be interested to know peoples' thoughts on the best way of organizing unittests.
0
python,unit-testing,testing
2009-08-27T12:52:00.000
0
1,340,892
There might be reasons other than testing to use the if __name__ == '__main__' check. Keeping the tests in other modules leaves that option open to you. Also - if you refactor the implementation of a module and your tests are in another module that was not edited - you KNOW the tests have not been changed when you run them against the refactored code.
0
5,565
false
0
1
Should Python unittests be in a separate module?
1,341,048
6
7
0
1
19
1
0.028564
0
Is there a consensus about the best place to put Python unittests? Should the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules? Perhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a /test subdirectory?). I assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he/she has to remember to update the additional test module if the module under test is modified. I'd be interested to know peoples' thoughts on the best way of organizing unittests.
0
python,unit-testing,testing
2009-08-27T12:52:00.000
0
1,340,892
I usually have them in a separate folder called most often test/. Personally I am not using the if __name__ == '__main__' check, because I use nosetests and it handles the test detection by itself.
0
5,565
false
0
1
Should Python unittests be in a separate module?
1,341,060
6
7
0
15
19
1
1
0
Is there a consensus about the best place to put Python unittests? Should the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules? Perhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a /test subdirectory?). I assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he/she has to remember to update the additional test module if the module under test is modified. I'd be interested to know peoples' thoughts on the best way of organizing unittests.
0
python,unit-testing,testing
2009-08-27T12:52:00.000
0
1,340,892
YES, do use a separate module. It does not really make sense to use the __main__ trick. Just assume that you have several files in your module, and it does not work anymore, because you don't want to run each source file separately when testing your module. Also, when installing a module, most of the time you don't want to install the tests. Your end-user does not care about tests, only the developers should care. No, really. Put your tests in tests/, your doc in doc, and have a Makefile ready around for a make test. Any other approaches are just intermediate solutions, only valid for specific tiny modules.
0
5,565
false
0
1
Should Python unittests be in a separate module?
1,341,119
2
6
0
1
2
1
0.033321
0
I have a friend who I am trying to teach how to program. He comes from a very basic PHP background, and for some reason is ANTI C#, I guess because some of his PHP circles condemn anything that comes from Microsoft. Anyways - I've told him its possible to use either Ruby or Python with the VS2008 IDE, because I've read somewhere that this is possible. But I was wondering. Is it really that practical, can you do EVERYTHING with Python in VS2008 that you can do with C# or VB.net. I guess without starting a debate... I want to know if you're a developer using VS IDE with a language other than VB.net or C#, then please leave an answer with your experience. If you are (like me) either a VB.net or C# developer, please don't post speculative or subjective answers. This is a serious question, and I don't want it being closed as subjective. ... Thank you very much. update So far we've established that IronPython is the right tool for the job. Now how practical is it really? Mono for example runs C# code in Linux, but... ever tried to use it? Not practical at all, lots of code refactoring needs to take place, no support for .net v3.5, etc...
0
python,visual-studio,ironpython
2009-08-27T16:57:00.000
0
1,342,377
Firstly, there seems to be a question as to whether python (or various implementations) are as 'powerful' as C#. I'm not quite sure what to take powerful to mean, but in my experience of both languages it will be somewhat easier and faster to write a given piece of code in python than in C#. C# is faster than cpython (although if speed is desired, the psyco python module is well worth a look). Also I would object to your dismissal of Mono. Mono is great on Linux if you write an application for it from scratch. It is not really meant to be a compatibility layer between Windows and Linux (see Wine!), and if you treat it as such you will only be disappointed. It just seems to me that you are taking the wrong approach. If you want to convince him that not everything Microsoft is evil, and he is adamant about not learning C#, get him to learn Python (or Ruby, or LUA or whatever) until he is competent, and then introduce him to C# and get him to make his own judgement - I'm fairly in favour of open source, and am far from a rabid Microsoft supporter, but I tried C#, and found I quite liked it. I think that getting him to use python and visual studio in a suboptimal way will turn him against both of them - far from your desired goal!
0
505
false
0
1
Can you really use the Visual Studio 2008 IDE to code in Python?
1,343,191
2
6
0
2
2
1
0.066568
0
I have a friend who I am trying to teach how to program. He comes from a very basic PHP background, and for some reason is ANTI C#, I guess because some of his PHP circles condemn anything that comes from Microsoft. Anyways - I've told him its possible to use either Ruby or Python with the VS2008 IDE, because I've read somewhere that this is possible. But I was wondering. Is it really that practical, can you do EVERYTHING with Python in VS2008 that you can do with C# or VB.net. I guess without starting a debate... I want to know if you're a developer using VS IDE with a language other than VB.net or C#, then please leave an answer with your experience. If you are (like me) either a VB.net or C# developer, please don't post speculative or subjective answers. This is a serious question, and I don't want it being closed as subjective. ... Thank you very much. update So far we've established that IronPython is the right tool for the job. Now how practical is it really? Mono for example runs C# code in Linux, but... ever tried to use it? Not practical at all, lots of code refactoring needs to take place, no support for .net v3.5, etc...
0
python,visual-studio,ironpython
2009-08-27T16:57:00.000
0
1,342,377
I find it odd that your friend is against C# but is ok with Visual Studio. There is, after all, an open source development environment for .NET called SharpDevelop. The C# language is a standard. .NET is free (as in beer) and there is an open source implementation of that platform called Mono. The only "un-free" thing is Visual Studio (though there are "Express" versions which are free as in beer).
0
505
false
0
1
Can you really use the Visual Studio 2008 IDE to code in Python?
1,342,463
2
7
0
1
26
1
0.028564
0
I'm writing an application where users can enter a python script and execute it in a sandbox. I need a way to prevent the exec'ed code from importing certain modules, so malicious code won't be as much of a problem. Is there a way to do this in Python?
0
python,module,sandbox
2009-08-29T04:39:00.000
0
1,350,466
Unfortunately, I think that what you're trying to do is fundamentally impossible. If users can execute arbitrary code in your application then they can do whatever they want. Even if you were able to prevent them from importing certain modules there would be nothing stopping them from writing equivalent functionality themselves (from scratch or using some of the modules that are available). I don't really know the specifics of implementing a sandbox in Python, but I would imagine it's something that needs to be done at the interpreter level and is far from easy!
0
21,579
false
0
1
Preventing Python code from importing certain modules?
1,350,473
2
7
0
-3
26
1
-0.085505
0
I'm writing an application where users can enter a python script and execute it in a sandbox. I need a way to prevent the exec'ed code from importing certain modules, so malicious code won't be as much of a problem. Is there a way to do this in Python?
0
python,module,sandbox
2009-08-29T04:39:00.000
0
1,350,466
You can overload the import mechanism. We used this to have a licensing system for plugins, you can easily have a whitelist / blacklist of module names.
0
21,579
false
0
1
Preventing Python code from importing certain modules?
1,350,472
3
5
0
9
3
1
1.2
0
I'm new to Python, coming from a C# background and I'm trying to get up to speed. I understand that Python is dynamically typed, whereas C# is strongly-typed. -> see comments. What conceptual obstacles should I watch out for when attempting to learn Python? Are there concepts for which no analog exists in Python? How important is object-oriented analysis? I believe answers to these and any other questions you might be able to think of would speed up my understanding Python besides the Nike mentality ("just do it")? A little more context: My company is moving from ASP.NET C# Web Forms to Django. I've gone through the Django tutorial and it was truly great. I need to get up to speed in about 2 weeks time (ridiculous maybe? LOL) Thank you all for your time and efforts to respond to a realllly broad question(s).
0
c#,asp.net,python,django,programming-languages
2009-08-29T11:39:00.000
0
1,351,227
" I understand that Python is dynamically typed, whereas C# is strongly-typed. " This is weirdly wrong. Python is strongly typed. A list or integer or dictionary is always of the given type. The object's type cannot be changed. Python variables are not strongly typed. Indeed, Python variables are just labels on objects. Variables are not declared; hence the description of Python as "dynamic". C# is statically typed. The variables are declared to the compiler to be of a specific type. The code is generated based on certain knowledge about the variables use at run-time. Python is "interpreted" -- things are done at run-time -- little is assumed. [Technically, the Python source is compiled into byte code and the byte code is interpreted. Some folks think this is an important distinction.] C# is compiled -- the compiler generates code based on the declared assumptions. What conceptual obstacles should I watch out for when attempting to learn Python? None. If you insist that Python should be like something else; or you insist that something else is more intuitive then you've polluted your own thinking with inappropriate concepts. No programming language has obstacles. We bring our own obstacles when we impose things on the language. Are there concepts for which no analog exists in Python? Since Python has object-oriented, procedural and functional elements, you'd be hard-pressed to find something missing from Python. How important is object-oriented analysis? OO analysis helps all phases of software development -- even if you aren't doing an OO implementation. This is unrelated to Python and should be a separate question. I need to get up to speed in about 2 weeks time (ridiculous maybe?) Perhaps not. If you start with a fresh, open mind, then Python can be learned in a week or so of diligent work. If, on the other hand, you compare and contrast Python with C#, it can take you years to get past your C# bias and learn Python. Don't translate C# to Python. Don't translate Python to C#. Don't go to the well with a full bucket.
0
3,579
true
0
1
What are some of the core conceptual differences between C# and Python?
1,351,670
3
5
0
2
3
1
0.07983
0
I'm new to Python, coming from a C# background and I'm trying to get up to speed. I understand that Python is dynamically typed, whereas C# is strongly-typed. -> see comments. What conceptual obstacles should I watch out for when attempting to learn Python? Are there concepts for which no analog exists in Python? How important is object-oriented analysis? I believe answers to these and any other questions you might be able to think of would speed up my understanding Python besides the Nike mentality ("just do it")? A little more context: My company is moving from ASP.NET C# Web Forms to Django. I've gone through the Django tutorial and it was truly great. I need to get up to speed in about 2 weeks time (ridiculous maybe? LOL) Thank you all for your time and efforts to respond to a realllly broad question(s).
0
c#,asp.net,python,django,programming-languages
2009-08-29T11:39:00.000
0
1,351,227
You said that Python is dynamically typed and C# is strongly typed but this isn't true. Strong vs. weak typing and static vs. dynamic typing are orthagonal. Strong typing means str + int doesn't coerce one of the opperands, so in this regard both Python and C# are strongly typed (whereas PHP or C is weakly typed). Python is dynamically typed which means names don't have a defined type at compile time, whereas in C# they do.
0
3,579
false
0
1
What are some of the core conceptual differences between C# and Python?
1,351,664
3
5
0
1
3
1
0.039979
0
I'm new to Python, coming from a C# background and I'm trying to get up to speed. I understand that Python is dynamically typed, whereas C# is strongly-typed. -> see comments. What conceptual obstacles should I watch out for when attempting to learn Python? Are there concepts for which no analog exists in Python? How important is object-oriented analysis? I believe answers to these and any other questions you might be able to think of would speed up my understanding Python besides the Nike mentality ("just do it")? A little more context: My company is moving from ASP.NET C# Web Forms to Django. I've gone through the Django tutorial and it was truly great. I need to get up to speed in about 2 weeks time (ridiculous maybe? LOL) Thank you all for your time and efforts to respond to a realllly broad question(s).
0
c#,asp.net,python,django,programming-languages
2009-08-29T11:39:00.000
0
1,351,227
The conceptual differences are important, but mostly in how they result in different attitudes. Most important of those are "duck typing". Ie, forget what type things are, you don't need to care. You only need to care about what attributes and methods objects have. "If it looks like a duck and walks like a duck, it's a duck". Usually, these attitude changes come naturally after a while. The biggest conceptual hurdles seems to be The significant indenting. But the only ones who hate it are people who have, or are forced to work with, people who change their editors tab expansion from something other than the default 8. No compiler, and hence no type testing at the compile stage. Many people coming from statically typed languages believe that the type checking during compilation finds many bugs. It doesn't, in my experience.
0
3,579
false
0
1
What are some of the core conceptual differences between C# and Python?
1,351,334
3
5
0
5
71
1
0.197375
0
Anyone know this? I've never been able to find an answer.
0
python,bash
2009-08-30T02:30:00.000
1
1,352,922
It finds 'python' also in /usr/local/bin, ~/bin, /opt/bin, ... or wherever it may hide.
0
38,302
false
0
1
Why is '#!/usr/bin/env python' supposedly more correct than just '#!/usr/bin/python'?
1,352,927
3
5
0
10
71
1
1
0
Anyone know this? I've never been able to find an answer.
0
python,bash
2009-08-30T02:30:00.000
1
1,352,922
it finds the python executable in your environment and uses that. it's more portable because python may not always be in /usr/bin/python. env is always located in /usr/bin.
0
38,302
false
0
1
Why is '#!/usr/bin/env python' supposedly more correct than just '#!/usr/bin/python'?
1,352,941
3
5
0
67
71
1
1.2
0
Anyone know this? I've never been able to find an answer.
0
python,bash
2009-08-30T02:30:00.000
1
1,352,922
If you're prone to installing python in various and interesting places on your PATH (as in $PATH in typical Unix shells, %PATH on typical Windows ones), using /usr/bin/env will accomodate your whim (well, in Unix-like environments at least) while going directly to /usr/bin/python won't. But losing control of what version of Python your scripts run under is no unalloyed bargain... if you look at my code you're more likely to see it start with, e.g., #!/usr/local/bin/python2.5 rather than with an open and accepting #!/usr/bin/env python -- assuming the script is important I like to ensure it's run with the specific version I have tested and developed it with, NOT a semi-random one;-).
0
38,302
true
0
1
Why is '#!/usr/bin/env python' supposedly more correct than just '#!/usr/bin/python'?
1,352,938
6
8
0
2
4
1
0.049958
0
I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer. I am in a quandary putting this into practice. I want to know specific ways that using Python or Ruby can make me a more productive .NET developer. One specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it. See standard format below.
0
python,.net,ruby
2009-08-30T06:13:00.000
0
1,353,211
Embedding a script engine Use of IronPython for a scripting engine inside your .NET application. For example enabling end-users of your application to change customizable parts with a full fledge language such as Python. A possible example might be to expose custom logic to end-users for a work flow engine.
0
403
false
0
1
I'm a .NET Programmer. What are specific uses of Python and/or Ruby for that will make me more productive?
1,353,301
6
8
0
2
4
1
0.049958
0
I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer. I am in a quandary putting this into practice. I want to know specific ways that using Python or Ruby can make me a more productive .NET developer. One specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it. See standard format below.
0
python,.net,ruby
2009-08-30T06:13:00.000
0
1,353,211
Advanced Text Processing Traditional strengths of awk and perl. You can just glue together a bunch of regular expressions to create a simple data-mining system on the go.
0
403
false
0
1
I'm a .NET Programmer. What are specific uses of Python and/or Ruby for that will make me more productive?
1,353,228
6
8
0
1
4
1
0.024995
0
I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer. I am in a quandary putting this into practice. I want to know specific ways that using Python or Ruby can make me a more productive .NET developer. One specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it. See standard format below.
0
python,.net,ruby
2009-08-30T06:13:00.000
0
1,353,211
Quick Prototyping - Both In the simplest cases when firing a python interpreter and writing a line or two is way faster than creating a new project in visual studio. And you can use ruby to. Or lua, or evel perl, whatever. The point is implicit typing and light-weight feel.
0
403
false
0
1
I'm a .NET Programmer. What are specific uses of Python and/or Ruby for that will make me more productive?
1,353,220
6
8
0
1
4
1
0.024995
0
I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer. I am in a quandary putting this into practice. I want to know specific ways that using Python or Ruby can make me a more productive .NET developer. One specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it. See standard format below.
0
python,.net,ruby
2009-08-30T06:13:00.000
0
1,353,211
Cross platform Compared to .NET a simple script Python is more easily ported to other platforms such as Linux. Although possible to achieve the same with the likes of Mono it simpler to run a Python script file on different platforms.
0
403
false
0
1
I'm a .NET Programmer. What are specific uses of Python and/or Ruby for that will make me more productive?
1,353,244
6
8
0
4
4
1
0.099668
0
I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer. I am in a quandary putting this into practice. I want to know specific ways that using Python or Ruby can make me a more productive .NET developer. One specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it. See standard format below.
0
python,.net,ruby
2009-08-30T06:13:00.000
0
1,353,211
Less Code I think productivity is direct result on how proficient you are in a specific language. That said the terseness of a language like Python might save some time on getting certain things done. If I compare how much less code I have to write for simple administration scripts (e.g. clean-up of old files) compared to .NET code there is certain amount of productivity gain. (Plus it is more fun which also helps getting the job done)
0
403
false
0
1
I'm a .NET Programmer. What are specific uses of Python and/or Ruby for that will make me more productive?
1,353,229
6
8
0
1
4
1
0.024995
0
I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer. I am in a quandary putting this into practice. I want to know specific ways that using Python or Ruby can make me a more productive .NET developer. One specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it. See standard format below.
0
python,.net,ruby
2009-08-30T06:13:00.000
0
1,353,211
Processing received Email Python has built-in support for POP3 and IMAP where the standard .NET framework doesn't. Useful for automating email triggered tasks.
0
403
false
0
1
I'm a .NET Programmer. What are specific uses of Python and/or Ruby for that will make me more productive?
1,353,255
7
10
0
10
5
1
1
0
I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++. Things like: In an if statement with an or always put the condition most likely to fail first, so the second will not be checked. Use the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings. Call as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates. I say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python. What's your view of the matter?
0
python,performance
2009-08-30T11:49:00.000
0
1,353,715
This sort of premature micro-optimisation is usually a waste of time in my experience, even in C and C++. Write readable code first. If it's running too slowly, run it through a profiler, and if necessary, fix the hot-spots. Fundamentally, you need to think about return on investment. Is it worth the extra effort in reading and maintaining "optimised" code for the couple of microseconds it saves you? In most cases it isn't. (Also, compilers and runtimes are getting cleverer. Some micro-optimisations may become micro-pessimisations over time.)
0
805
false
0
1
Should I optimise my python code like C++? Does it matter?
1,353,775
7
10
0
3
5
1
0.059928
0
I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++. Things like: In an if statement with an or always put the condition most likely to fail first, so the second will not be checked. Use the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings. Call as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates. I say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python. What's your view of the matter?
0
python,performance
2009-08-30T11:49:00.000
0
1,353,715
I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python. Given this, I'd say that you should take your colleague's advice about writing efficient Python but ignore anything he says that goes against prioritizing readability and maintainability of the code, which will probably be more important than the speed at which it'll execute.
0
805
false
0
1
Should I optimise my python code like C++? Does it matter?
1,353,728
7
10
0
4
5
1
0.07983
0
I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++. Things like: In an if statement with an or always put the condition most likely to fail first, so the second will not be checked. Use the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings. Call as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates. I say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python. What's your view of the matter?
0
python,performance
2009-08-30T11:49:00.000
0
1,353,715
I agree with others: readable code first ("Performance is not a problem until performance is a problem."). I only want to add that when you absolutely need to write some unreadable and/or non-intuitive code, you can generally isolate it in few specific methods, for which you can write detailed comments, and keep the rest of your code highly readable. If you do so, you'll end up having easy to maintain code, and you'll only have to go through the unreadable parts when you really need to.
0
805
false
0
1
Should I optimise my python code like C++? Does it matter?
1,353,788
7
10
0
2
5
1
0.039979
0
I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++. Things like: In an if statement with an or always put the condition most likely to fail first, so the second will not be checked. Use the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings. Call as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates. I say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python. What's your view of the matter?
0
python,performance
2009-08-30T11:49:00.000
0
1,353,715
I think there are several related 'urban legends' here. False Putting the more often-checked condition first in a conditional and similar optimizations save enough time for a typical program that it is worthy for a typical programmer. True Some, but not many, people are using such styles in Python in the incorrect belief outlined above. True Many people use such style in Python when they think that it improves readability of a Python program. About readability: I think it's indeed useful when you give the most useful conditional first, since this is what people notice first anyway. You should also use ''.join() if you mean concatenation of strings since it's the most direct way to do it (the s += x operation could mean something different). "Call as less functions as possible" decreases readability and goes against Pythonic principle of code reuse. And so it's not a style people use in Python.
0
805
false
0
1
Should I optimise my python code like C++? Does it matter?
1,354,718
7
10
0
1
5
1
0.019997
0
I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++. Things like: In an if statement with an or always put the condition most likely to fail first, so the second will not be checked. Use the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings. Call as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates. I say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python. What's your view of the matter?
0
python,performance
2009-08-30T11:49:00.000
0
1,353,715
My visceral reaction is this: I've worked with guys like your colleague and in general I wouldn't take advice from them. Ask him if he's ever even used a profiler.
0
805
false
0
1
Should I optimise my python code like C++? Does it matter?
1,354,833
7
10
0
13
5
1
1
0
I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++. Things like: In an if statement with an or always put the condition most likely to fail first, so the second will not be checked. Use the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings. Call as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates. I say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python. What's your view of the matter?
0
python,performance
2009-08-30T11:49:00.000
0
1,353,715
The answer is really simple : Follow Python best practices, not C++ best practices. Readability in Python is more important that speed. If performance becomes an issue, measure, then start optimizing.
0
805
false
0
1
Should I optimise my python code like C++? Does it matter?
1,353,732
7
10
0
14
5
1
1.2
0
I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++. Things like: In an if statement with an or always put the condition most likely to fail first, so the second will not be checked. Use the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings. Call as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates. I say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python. What's your view of the matter?
0
python,performance
2009-08-30T11:49:00.000
0
1,353,715
My answer to that would be : We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. (Quoting Knuth, Donald. Structured Programming with go to Statements, ACM Journal Computing Surveys, Vol 6, No. 4, Dec. 1974. p.268) If your application is doing anything like a query to the database, that one query will take more time than anything you can gain with those kind of small optimizations, anyway... And if running after performances like that, why not code in assembly language, afterall ? Because Python is easier/faster to write and maintain ? Well, if so, you are right :-) The most important thing is that your code is easy to maintain ; not a couple micro-seconds of CPU-time ! Well, maybe except if you have thousands of servers -- but is it your case ?
0
805
true
0
1
Should I optimise my python code like C++? Does it matter?
1,353,722
1
4
0
0
1
0
0
0
I am writing a python script that will perform performance test in linux file system. so besides deadlocks, race conditions and time takes to perform an action (delete, read, write and create) what other variables/parameters should the test contain?
0
python,filesystems,performance-testing
2009-08-31T07:29:00.000
1
1,356,240
You might be inetersting in looking at tools like caollectd and iotop. Then again, yopu mightalso by interested in just using them instead of reinventing the wheel - as far as I see, such performance analysis is not learned in a day, and these guys invested significant amounts of time and knowledge in building these tools.
0
1,679
false
0
1
file system performance testing
1,356,966
3
10
0
6
22
0
1
0
I have been exploring and developing an application in Python for mission critical work in the commercial banking arena. Banks are way conservative in selecting new applications. I need real proof of stability and others using. Have looked at the Python site but now I'm hoping this crowd can tell me more. So far I don't have a development bank partner which I will need next stage, so I'm gathering proof and pitch info. All help and comments appreciated.
0
python,enterprise,banking,onlinebanking
2009-08-31T15:47:00.000
0
1,358,084
Of course you can implement mission-critical software (whatever that is in your case) using Python. At the end of the day the success of your application is going to weigh more on its capabilities than whether it is written in Python. Some all .NET companies will even bring in Python applications provided that there is a way to talk to the system from .NET. I would not market your application as being a Python application. This is going to cause you trouble down the road because you will run into roadblocks. This often happens when you satisfy a business customer and he speaks to their IT guy who says "whoa we can't support that" without a full analysis of the cost/benefit to the business. This is the place that references to use of Python in mission-critical systems will arise. Try to avoid this area. With Python you can always target the popular platforms if you build your application under certain constraints. IronPython runs on .NET and Jython runs on Java. Being able to fire back with info on how to run your application on these platforms might be helpful.
0
16,188
false
0
1
Python in the enterprise: Pros and cons
1,358,743
3
10
0
-5
22
0
-1
0
I have been exploring and developing an application in Python for mission critical work in the commercial banking arena. Banks are way conservative in selecting new applications. I need real proof of stability and others using. Have looked at the Python site but now I'm hoping this crowd can tell me more. So far I don't have a development bank partner which I will need next stage, so I'm gathering proof and pitch info. All help and comments appreciated.
0
python,enterprise,banking,onlinebanking
2009-08-31T15:47:00.000
0
1,358,084
Python doesn't have anywhere close to as much money backing it as MSFT or Redhat etc. If Guido gets hit by a bus, Python is in trouble. I <3 python for a lot of things, but a financial transaction system probably wants a real, trusted, stable company backing it. Edit: this isn't flame bait; this is a major lesson learned from watching a colleague push a platform backed by a small company, and the resulting 'business-strategic' nightmare that ended with his project getting dropped in favor of someone using a far crappier project with lots of money. There's more to project success than the technical bit.
0
16,188
false
0
1
Python in the enterprise: Pros and cons
1,358,385
3
10
0
0
22
0
0
0
I have been exploring and developing an application in Python for mission critical work in the commercial banking arena. Banks are way conservative in selecting new applications. I need real proof of stability and others using. Have looked at the Python site but now I'm hoping this crowd can tell me more. So far I don't have a development bank partner which I will need next stage, so I'm gathering proof and pitch info. All help and comments appreciated.
0
python,enterprise,banking,onlinebanking
2009-08-31T15:47:00.000
0
1,358,084
i know topic is rather old, but anyway. if we talk about mission critical. Python is widly used in Thales software provided with is hardware encryption solutions. and in PayShield application for example, which i believe really mission critical. Although Java is being used there more than Python.
0
16,188
false
0
1
Python in the enterprise: Pros and cons
7,913,484
2
2
0
1
2
0
0.099668
0
I'm building a centralized desktop application using Python/wxPython. One of the requirements is User authentication, which I'm trying to implement using LDAP (although this is not mandatory). Users of the system will be mechanical and electrical engineers making budgets, and the biggest problem would be industrial espionage. Its a common problem that leaks occur commonly from the bottom on informal ways, and this could pose problems. The system is set up in such a way that every user has access to all and only the information it needs, so that no one person but the people on top has monetary information on the whole project. The problem is that, for every way I can think to implement the authentication system, Python's openness makes me think of at least one way of bypassing/getting sensible information from the system, because "compiling" with py2exe is the closest I can get to obfuscation of the code on Windows. I'm not really trying to hide the code, but rather make the authentication routine secure by itself, make it in such a way that access to the code doesn't mean capability to access the application. One thing I wanted to add, was some sort of code signing to the access routine, so the user can be sure that he is not running a modified client app. One of the ways I've thought to avoid this is making a C module for the authentication, but I would rather not have to do that. Of course this question is changing now and is not just "Could anyone point me in the right direction as to how to build a secure authentication system running on Python? Does something like this already exist?", but "How do you harden an scripting (Python) against wrongful modification?"
0
python,security,design-patterns,authentication,cracking
2009-09-02T00:03:00.000
1
1,365,254
Possibly: The user enters their credentials into the desktop client. The client says to the server: "Hi, my name username and my password is password". The server checks these. The server says to the client: "Hi, username. Here is your secret token: ..." Subsequently the client uses the secret token together with the username to "sign" communications with the server.
0
272
false
0
1
How to deal with user authentication and wrongful modification in scripting languages?
1,365,394
2
2
0
3
2
0
1.2
0
I'm building a centralized desktop application using Python/wxPython. One of the requirements is User authentication, which I'm trying to implement using LDAP (although this is not mandatory). Users of the system will be mechanical and electrical engineers making budgets, and the biggest problem would be industrial espionage. Its a common problem that leaks occur commonly from the bottom on informal ways, and this could pose problems. The system is set up in such a way that every user has access to all and only the information it needs, so that no one person but the people on top has monetary information on the whole project. The problem is that, for every way I can think to implement the authentication system, Python's openness makes me think of at least one way of bypassing/getting sensible information from the system, because "compiling" with py2exe is the closest I can get to obfuscation of the code on Windows. I'm not really trying to hide the code, but rather make the authentication routine secure by itself, make it in such a way that access to the code doesn't mean capability to access the application. One thing I wanted to add, was some sort of code signing to the access routine, so the user can be sure that he is not running a modified client app. One of the ways I've thought to avoid this is making a C module for the authentication, but I would rather not have to do that. Of course this question is changing now and is not just "Could anyone point me in the right direction as to how to build a secure authentication system running on Python? Does something like this already exist?", but "How do you harden an scripting (Python) against wrongful modification?"
0
python,security,design-patterns,authentication,cracking
2009-09-02T00:03:00.000
1
1,365,254
How malicious are your users? Really. Exactly how malicious? If your users are evil sociopaths and can't be trusted with a desktop solution, then don't build a desktop solution. Build a web site. If your users are ordinary users, they'll screw the environment up by installing viruses, malware and keyloggers from porn sites before they try to (a) learn Python (b) learn how your security works and (c) make a sincere effort at breaking it. If you actually have desktop security issues (i.e., public safety, military, etc.) then rethink using the desktop. Otherwise, relax, do the right thing, and don't worry about "scripting". C++ programs are easier to hack because people are lazy and permit SQL injection.
0
272
true
0
1
How to deal with user authentication and wrongful modification in scripting languages?
1,365,422
1
3
1
3
20
1
0.197375
0
I'm currently working on an application written in C#, which I'm embedding IronPython in. I generally have no problems about it, but there's one thing that I don't know how to deal with. I want to import an external module into the script. How can I do that? Simple import ext_lib doesn't work. Should I add a path to the lib to sys.path? Maybe it is possible to copy the lib's .py file into app directory and import from there? EDIT: I finally chosen another solution - compiled my script with py2exe and I'm just running it from main C# app with Process (without using IronPython). Anyway, thanks for help ;)
0
python,import,ironpython
2009-09-03T07:50:00.000
0
1,371,994
If you have installed IronPython from NuGet packages and you want modules from the CPython Standard Library then the best way to do it is by installing the IronPython.StdLib NuGet package which is from the same authors of IronPython.
0
34,961
false
0
1
Importing external module in IronPython
67,905,932
3
5
0
0
0
1
0
0
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good option, but can I run IronPython from it, and can I link to .NET assemblies from it? What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
0
.net,python,ironpython
2009-09-04T06:28:00.000
0
1,377,548
You can also consider using Eclipse with PyDev which has support for IronPython
0
210
false
0
1
What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
1,383,258
3
5
0
0
0
1
0
0
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good option, but can I run IronPython from it, and can I link to .NET assemblies from it? What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
0
.net,python,ironpython
2009-09-04T06:28:00.000
0
1,377,548
FWIW, Frood himself uses Wing IDE. But, if its on Windows, why not VS?
0
210
false
0
1
What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
1,378,519
3
5
0
0
0
1
0
0
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good option, but can I run IronPython from it, and can I link to .NET assemblies from it? What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
0
.net,python,ironpython
2009-09-04T06:28:00.000
0
1,377,548
You can use Visual Studio. I use IronPython Studio integrated with VS2008. But I feel that it has very poor intellisense for Python.
0
210
false
0
1
What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
1,389,592
2
4
0
4
3
1
1.2
0
Many languages of REPL consoles with additional features like autocomplete and intellisense. For instance, iPython, Mathematica, and PyCrust all make some effort to go beyond a basic read eval loop. REPLs are particularly useful in languages where interactive exploration is very important, such as Matlab or R. I'm looking for inspiration. What application provides the slickest REPL? Or what features do you always wish existed in your REPL of choice?
0
python,matlab,console
2009-09-04T17:35:00.000
0
1,380,592
I really like Safari's Web Inspector Javascript console. Specifically: Collapsible interactive object hierarchies sprintf-style logging Pretty-printing of closures, allowing you to peer into the internals of anonymous functions Auto-complete / hinting of object properties on the command-line
0
352
true
0
1
Slickest REPL console in any language
1,380,716
2
4
0
5
3
1
0.244919
0
Many languages of REPL consoles with additional features like autocomplete and intellisense. For instance, iPython, Mathematica, and PyCrust all make some effort to go beyond a basic read eval loop. REPLs are particularly useful in languages where interactive exploration is very important, such as Matlab or R. I'm looking for inspiration. What application provides the slickest REPL? Or what features do you always wish existed in your REPL of choice?
0
python,matlab,console
2009-09-04T17:35:00.000
0
1,380,592
Common Lisp and emacs with SLIME. All you could really want, think of, dream of, and then some.
0
352
false
0
1
Slickest REPL console in any language
1,380,870
2
7
0
1
70
1
0.028564
0
I'm a fairly strong Python coder, but too much of my style is a little haphazard, and I'm sure there are more Pythonic solutions to many problems than the ones I come up with. Which PEPs are essential for any well versed Pythonista to read?
0
python,pep
2009-09-05T06:43:00.000
0
1,382,648
I'd also recommend PEPs 8 and 257. I know this deviates slightly from the original question, but I'd like to point out that PyCharm (probably the best Python IDE around in my opinion) automatically checks if you're following some of the most important PEP 8 guidelines, just in case anyone's interested...
0
7,197
false
0
1
Which PEP's are must reads?
21,502,630
2
7
0
8
70
1
1
0
I'm a fairly strong Python coder, but too much of my style is a little haphazard, and I'm sure there are more Pythonic solutions to many problems than the ones I come up with. Which PEPs are essential for any well versed Pythonista to read?
0
python,pep
2009-09-05T06:43:00.000
0
1,382,648
I found that reading the declined ones can give some good insights into what's Pythonic and what isn't. This was a while ago so I don't have any specific examples.
0
7,197
false
0
1
Which PEP's are must reads?
1,382,662
6
6
0
0
2
1
0
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
0
python,code-organization
2009-09-05T15:25:00.000
0
1,383,590
Put them in the Path class, and document that they are "obscure" either with comments or docstrings. Separate them at the end if you like.
0
328
false
0
1
Code organization in Python: Where is a good place to put obscure methods?
1,383,613
6
6
0
4
2
1
0.132549
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
0
python,code-organization
2009-09-05T15:25:00.000
0
1,383,590
If the method is relevant to the Path - no matter how obscure - I think it should reside within the class itself. If you have multiple places where you have path-related functionality, it leads to problems. For example, if you want to check if some functionality already exists, how will a new programmer know to check the other, less obvious places? I think a good practice might be to order functions by importance. As you may have heard, some suggest putting public members of classes first, and private/protected ones after. You could consider putting the common methods in your class higher than the obscure ones.
0
328
false
0
1
Code organization in Python: Where is a good place to put obscure methods?
1,383,607
6
6
0
0
2
1
0
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
0
python,code-organization
2009-09-05T15:25:00.000
0
1,383,590
I would just prepend the names with an underscore _, to show that the reader shouldn't bother about them. It's conventionally the same thing as private members in other languages.
0
328
false
0
1
Code organization in Python: Where is a good place to put obscure methods?
1,383,601
6
6
0
0
2
1
0
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
0
python,code-organization
2009-09-05T15:25:00.000
0
1,383,590
Oh wait, I thought of something -- I can just define them in the Path.py module, where every obscure method will be a one-liner that will call the function from the separate module that currently exists. With this compromise, the obscure methods will comprise of maybe 10 lines in the end of the file instead of 50% of its bulk.
0
328
false
0
1
Code organization in Python: Where is a good place to put obscure methods?
1,383,639
6
6
0
2
2
1
1.2
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
0
python,code-organization
2009-09-05T15:25:00.000
0
1,383,590
If you're keen to put those methods in a different source file at any cost, AND keen to have them at methods at any cost, you can achieve both goals by using the different source file to define a mixin class and having your Path class import that method and multiply-inherit from that mixin. So, technically, it's quite feasible. However, I would not recommend this course of action: it's worth using "the big guns" (such as multiple inheritance) only to serve important goals (such as reuse and removing repetition), and separating methods out in this way is not really a particularly crucial goal. If those "obscure methods" played no role you would not be implementing them, so they must have SOME importance, after all; so I'd just clarify in docstrings and comments what they're for, maybe explicitly mention that they're rarely needed, and leave it at that.
0
328
true
0
1
Code organization in Python: Where is a good place to put obscure methods?
1,383,623
6
6
0
0
2
1
0
0
I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant. Where would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things. Currently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) Does anyone have a suggestion?
0
python,code-organization
2009-09-05T15:25:00.000
0
1,383,590
I suggest making them accessible from a property of the Path class called something like "Utilties". For example: Path.Utilities.RazzleDazzle. This will help with auto-completion tools and general maintenance.
0
328
false
0
1
Code organization in Python: Where is a good place to put obscure methods?
8,028,755
3
5
0
0
7
0
0
0
I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako. I've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe? Wouldn't templating JUST suffice without having embedded Python code?
0
python,template-engine,mako,genshi
2009-09-06T01:11:00.000
0
1,384,634
You could discipline yourself to not inject any Python code within the template unless it's really the last resort to get the job done. I have faced a similar issue with Django's template where I have to do some serious CSS gymnastics to display my content. If I could have used some Python code in the template, it would have been better.
0
6,454
false
0
1
Should I use Mako for Templating?
1,384,847
3
5
0
2
7
0
0.07983
0
I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako. I've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe? Wouldn't templating JUST suffice without having embedded Python code?
0
python,template-engine,mako,genshi
2009-09-06T01:11:00.000
0
1,384,634
This seems to be a bit of a religious issue. Django templates take a hard line: no code in templates. They do this because of their history as a system used in shops where there's a clear separation between those who write code and those who create pages. Others (perhaps you) don't make such a clear distinction, and would feel more comfortable having a more flexible line between layout and logic. It really comes down to a matter of taste.
0
6,454
false
0
1
Should I use Mako for Templating?
1,384,671
3
5
0
16
7
0
1
0
I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako. I've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe? Wouldn't templating JUST suffice without having embedded Python code?
0
python,template-engine,mako,genshi
2009-09-06T01:11:00.000
0
1,384,634
Wouldn't templating JUST suffice without having embedded Python code? Only if your templating language has enough logical functionality that it is essentially a scripting language in itself. At which point, you might just as well have used Python. More involved sites often need complex presentation logic and non-trivial templated structures like sections repeated in different places/pages and recursive trees. This is no fun if your templating language ties your hands behind your back because it takes the religious position that "code in template are BAD". Then you just end up writing presentation helper functions in your Python business logic, which is a worse blending of presentation and application logic than you had to start with. Languages that take power away from you because they don't trust you to use it tastefully are lame.
0
6,454
false
0
1
Should I use Mako for Templating?
1,391,510
1
6
0
2
2
1
0.066568
0
I have been trying to learn a cross platform language with a fast learning curve, and so it seemed obvious Python was the logical choice. I've never programmed before but I have been reading on pragmatic programming and agile development for quite some time. The question comes, "What is the single best choice to create a desktop software that is built heavily in python and can handle flexibilty of SQL injections, along with rich interface reporting?" e.g. SQL Alchemy, ReportLabs. I have been looking into pyHed found in sourceforge.net. However, it's on early development stage and is still not well documented. I checked out Titanium Desktop from Appcelerator and the concept seems exciting, but it's not in stable condition yet. Any suggestions, comments or ideas of what is currently being used? or new technologies out there now?
0
python,database,open-source,frameworks
2009-09-07T20:33:00.000
0
1,390,868
There are many answers to your question because you raise a number of issues: Agile development is methodology and has very little to do with the language or software platform. It is more a set of principles around which software teams organize themselves. Refer to the works of Kent Beck for a bit more detail. Do you have an existing Python code base? If you do have an existing Python code base you could get relatively far with pyHed. Otherwise you could look at something like Java Swing or C#. But really you might want to consider moving the application to a web platform - that seems to be the direction almost all desktop apps are heading. Django is well known Python framework. Or any number of the Java, C#, Ruby platforms if it strikes your fancy. The jquery JavaScript framework is a good tool to provide rich Web interfaces.
0
2,206
false
0
1
Agile Software Development in Python
1,390,896
5
6
0
7
5
0
1.2
1
I am trying to understand crc32 to generate the unique url for web page. If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates? What could be the approximative string length to keep the checksum to be 2^32? When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further. Mostly I want to convert the url (maximum 1024 chars) to shorted id.
0
c#,python,url,crc32,short-url
2009-09-09T18:16:00.000
0
1,401,218
There is no such number as the "maximum number of urls can be used so that we can avoid duplicates" for CRC32. The problem is that CRC32 can produce duplicates, and it's not a function of how many values you throw at it, it's a function of what those values look like. So you might have a collision on the second url, if you're unlucky. You should not base your algorithm on producing a unique hash, instead produce a unique value for each url manually.
0
3,162
true
0
1
CRC32 to make short URL for web
1,401,231
5
6
0
4
5
0
0.132549
1
I am trying to understand crc32 to generate the unique url for web page. If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates? What could be the approximative string length to keep the checksum to be 2^32? When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further. Mostly I want to convert the url (maximum 1024 chars) to shorted id.
0
c#,python,url,crc32,short-url
2009-09-09T18:16:00.000
0
1,401,218
If you're already storing the full URL in a database table, an integer ID is pretty short, and can be made shorter by converting it to base 16, 64, or 85. If you can use a UUID, you can use an integer, and you may as well, since it's shorter and I don't see what benefit a UUID would provide in your lookup table.
0
3,162
false
0
1
CRC32 to make short URL for web
1,401,237
5
6
0
1
5
0
0.033321
1
I am trying to understand crc32 to generate the unique url for web page. If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates? What could be the approximative string length to keep the checksum to be 2^32? When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further. Mostly I want to convert the url (maximum 1024 chars) to shorted id.
0
c#,python,url,crc32,short-url
2009-09-09T18:16:00.000
0
1,401,218
CRC32 means cyclic redundancy check with 32 bits where any arbitrary amount of bits is summed up to a 32 bit check sum. And check sum functions are surjective, that means multiple input values have the same output value. So you cannot inverse the function.
0
3,162
false
0
1
CRC32 to make short URL for web
1,401,243
5
6
0
0
5
0
0
1
I am trying to understand crc32 to generate the unique url for web page. If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates? What could be the approximative string length to keep the checksum to be 2^32? When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further. Mostly I want to convert the url (maximum 1024 chars) to shorted id.
0
c#,python,url,crc32,short-url
2009-09-09T18:16:00.000
0
1,401,218
No, even you use md5, or any other check sum, the URL CAN BE duplicate, it all depends on your luck. So don't make an unique url base on those check sum
0
3,162
false
0
1
CRC32 to make short URL for web
1,401,286
5
6
0
2
5
0
0.066568
1
I am trying to understand crc32 to generate the unique url for web page. If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates? What could be the approximative string length to keep the checksum to be 2^32? When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further. Mostly I want to convert the url (maximum 1024 chars) to shorted id.
0
c#,python,url,crc32,short-url
2009-09-09T18:16:00.000
0
1,401,218
The right way to make a short URL is to store the full one in the database and publish something that maps to the row index. A compact way is to use the Base64 of the row ID, for example. Or you could use a UID for the primary key and show that. Do not use a checksum, because it's too small and very likely to conflict. A cryptographic hash is larger and less likely, but it's still not the right way to go.
0
3,162
false
0
1
CRC32 to make short URL for web
1,401,331
1
5
0
3
20
0
0.119427
1
Okay. So I have about 250,000 high resolution images. What I want to do is go through all of them and find ones that are corrupted. If you know what 4scrape is, then you know the nature of the images I. Corrupted, to me, is the image is loaded into Firefox and it says The image “such and such image” cannot be displayed, because it contains errors. Now, I could select all of my 250,000 images (~150gb) and drag-n-drop them into Firefox. That would be bad though, because I don't think Mozilla designed Firefox to open 250,000 tabs. No, I need a way to programmatically check whether an image is corrupted. Does anyone know a PHP or Python library which can do something along these lines? Or an existing piece of software for Windows? I have already removed obviously corrupted images (such as ones that are 0 bytes) but I'm about 99.9% sure that there are more diseased images floating around in my throng of a collection.
0
php,python,image
2009-09-09T19:15:00.000
0
1,401,527
If your exact requirements are that it show correctly in FireFox you may have a difficult time - the only way to be sure would be to link to the exact same image loading source code as FireFox. Basic image corruption (file is incomplete) can be detected simply by trying to open the file using any number of image libraries. However many images can fail to display simply because they stretch a part of the file format that the particular viewer you are using can't handle (GIF in particular has a lot of these edge cases, but you can find JPEG and the rare PNG file that can only be displayed in specific viewers). There are also some ugly JPEG edge cases where the file appears to be uncorrupted in viewer X, but in reality the file has been cut short and is only displaying correctly because very little information has been lost (FireFox can show some cut off JPEGs correctly [you get a grey bottom], but others result in FireFox seeming the load them half way and then display the error message instead of the partial image)
0
23,397
false
0
1
How do I programmatically check whether an image (PNG, JPEG, or GIF) is corrupted?
1,401,566
2
3
0
5
0
1
0.321513
0
I don't see that the compilation step is adding any value.
0
python,gettext
2009-09-10T19:52:00.000
0
1,407,364
Reading just quickly about .mo files, it is clear that: It is a machine-readable representation It is a hash table Given gettext's function, to lookup strings by keys at runtime, it is reasonable for this lookup to be implemented efficiently. Also, it is needed for gettext's performance impact to be negligible; else interest to play nice with the international community would be even lower for english-speaking hackers (from all countries, we all speak english, programming languages are in english). Making the .mo file an already processed representation is good since The format is well suited for quick lookup (hash table) The format needs little processing at application launch (custom-representation binary)
0
626
false
0
1
Why does the Python gettext module require a compilation step (.po -> .mo)?
1,408,109
2
3
0
1
0
1
0.066568
0
I don't see that the compilation step is adding any value.
0
python,gettext
2009-09-10T19:52:00.000
0
1,407,364
Because gettext module in Python follows GNU gettext standards which required to use PO files for do translations by people, and MO files for using by application in runtime. When you're using gettext module you're actually using GNUTranslations class, which name suggests it's implementation of GNU gettext. But you can provide your own Translations class and load translations from PO files, there is nothing special about it. There is even some implementation of PO files reader in standard Python distribution, see script msgfmt.py in Tools directory.
0
626
false
0
1
Why does the Python gettext module require a compilation step (.po -> .mo)?
2,021,653
1
7
0
-1
21
0
-0.028564
0
os.stat returns st_mtime and st_ctime attributes, the modification time is st_mtime and st_ctime "change time" on POSIX. is there any function that return the creation time of a file using python and under Linux?
0
python,linux
2009-09-10T23:35:00.000
1
1,408,272
What do you mean it can't be done [1]? The function, os.stat(path).st_birthtime, works great. [1]: Somebody said that it couldn’t be done But he with a chuckle replied That “maybe it couldn’t,” but he would be one Who wouldn’t say so till he’d tried. So he buckled right in with the trace of a grin On his face. If he worried he hid it. He started to sing as he tackled the thing That couldn’t be done, and he did it! -- Edgar Albert Guest
0
11,846
false
0
1
Get file creation time with Python on linux
48,969,869
5
6
0
0
1
0
0
0
I know that this is a difficult question to answer, but I thought I would try anwyays.... I am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby. It is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code. The ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...). I have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason. If you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language? How do the libraries stack up? Thanks!!!
0
python,ruby
2009-09-13T00:59:00.000
0
1,416,570
Using Ruby für two years now , i find it powerful, easy to learn, having good libraries, good community. But how should we know if it fits your needs? Try it an you will find out.
0
567
false
1
1
To Ruby or not to Ruby
25,123,266
5
6
0
4
1
0
0.132549
0
I know that this is a difficult question to answer, but I thought I would try anwyays.... I am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby. It is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code. The ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...). I have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason. If you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language? How do the libraries stack up? Thanks!!!
0
python,ruby
2009-09-13T00:59:00.000
0
1,416,570
Ruby Madness. Sure, it seems cool, but it might lead to the hard stuff: Lisp My predictions: It's pretty clear that you are OK with either Ruby or Python, and obviously php can be made to work. You will really like Ruby. I'm a little bit worried that after Ruby the only place left to go will be Lisp, and that I will become one of those raving lisp maniacs with bad haircuts waving my arms and muttering about The One True Macro Processor. Slightly more seriously, though Lisp and Smalltalk are still in tiny niche spaces after 60 and 40 years, it turns out that the child of the two bore fruit. Various Lisp and Smalltalk hackers are starting to show up speaking about their child Ruby at Ruby and Rails cons. As it happens, Ruby (timeframe 15 years) has quite a bit of the Lisp and Smalltalk magic. And, to this party, Ruby brings about every single bit of the day-to-day and 3-line-script usefulness of Perl. Ruby is an explosion on the language scene that combines the scripting superpower of Perl with the object-orient superpower of an exotic language like Smalltalk. Ruby is an awesome and groundbreaking language with or without Rails. I say, drink the kool-aid.
0
567
false
1
1
To Ruby or not to Ruby
1,416,827
5
6
0
1
1
0
0.033321
0
I know that this is a difficult question to answer, but I thought I would try anwyays.... I am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby. It is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code. The ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...). I have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason. If you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language? How do the libraries stack up? Thanks!!!
0
python,ruby
2009-09-13T00:59:00.000
0
1,416,570
Rails apps can potentially make a great REST backend for a php based system. The REST stuff is made for it. You want xml? ok. You want json? ok. If you and the staff aren't comfy with it, use something you are more comfy in to write a REST interface. :)
0
567
false
1
1
To Ruby or not to Ruby
1,416,574
5
6
0
0
1
0
0
0
I know that this is a difficult question to answer, but I thought I would try anwyays.... I am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby. It is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code. The ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...). I have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason. If you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language? How do the libraries stack up? Thanks!!!
0
python,ruby
2009-09-13T00:59:00.000
0
1,416,570
Why wouldn't you just keep it consistent and use PHP?
0
567
false
1
1
To Ruby or not to Ruby
1,416,583
5
6
0
0
1
0
0
0
I know that this is a difficult question to answer, but I thought I would try anwyays.... I am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby. It is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code. The ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...). I have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason. If you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language? How do the libraries stack up? Thanks!!!
0
python,ruby
2009-09-13T00:59:00.000
0
1,416,570
IMO, if you're comfortable with Python then you shouldn't have too much trouble picking up Ruby. This doesn't mean Ruby is the best choice - you should still evaluate the options.
0
567
false
1
1
To Ruby or not to Ruby
1,416,625
1
3
0
0
12
0
0
1
How can I find out the http request my python cgi received? I need different behaviors for HEAD and GET. Thanks!
0
python,http,httpwebrequest,cgi
2009-09-13T13:12:00.000
0
1,417,715
Why do you need to distinguish between GET and HEAD? Normally you shouldn't distinguish and should treat a HEAD request just like a GET. This is because a HEAD request is meant to return the exact same headers as a GET. The only difference is there will be no response content. Just because there is no response content though doesn't mean you no longer have to return a valid Content-Length header, or other headers, which are dependent on the response content. In mod_wsgi, which various people are pointing you at, it will actually deliberately change the request method from HEAD to GET in certain cases to guard against people who wrongly treat HEAD differently. The specific case where this is done is where an Apache output filter is registered. The reason that it is done in this case is because the output filter may expect to see the response content and from that generate additional response headers. If you were to decide not to bother to generate any response content for a HEAD request, you will deprive the output filter of the content and the headers they add may then not agree with what would be returned from a GET request. The end result of this is that you can stuff up caches and the operation of the browser. The same can apply equally for CGI scripts behind Apache as output filters can still be added in that case as well. For CGI scripts there is nothing in place though to protect against users being stupid and doing things differently for a HEAD request.
0
6,773
false
0
1
Detecting the http request type (GET, HEAD, etc) from a python cgi
1,420,886
3
5
0
3
2
1
0.119427
0
I'm removing an item from an array if it exists. Two ways I can think of to do this Way #1 # x array, r item to remove if r in x : x.remove( r ) Way #2 try : x.remove( r ) except : pass Timing it shows the try/except way can be faster (some times i'm getting:) 1.16225508968e-06 8.80804972547e-07 1.14314196588e-06 8.73752536492e-07 import timeit runs = 10000 x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113', 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow', 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig', ] r = 'a' code1 =""" x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113', 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow', 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig', ] r = 'a' if r in x : x.remove(r) """ print timeit.Timer( code1 ).timeit( runs ) / runs code2 =""" x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113', 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow', 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig', ] r = 'a' try : x.remove( r ) except : pass """ print timeit.Timer( code2 ).timeit( runs ) / runs Which is more pythonic?
0
python
2009-09-13T17:15:00.000
0
1,418,266
Speed depends on the ratio of hits to misses. To be pythonic choose the clearer method. Personally I think way#1 is clearer (It takes less lines to have an 'if' block rather than an exception block and also uses less brain space). It will also be faster when there are more hits than misses (an exception is more expensive than skipping a if block).
1
267
false
0
1
Which is more pythonic for array removal?
1,418,321
3
5
0
2
2
1
0.07983
0
I'm removing an item from an array if it exists. Two ways I can think of to do this Way #1 # x array, r item to remove if r in x : x.remove( r ) Way #2 try : x.remove( r ) except : pass Timing it shows the try/except way can be faster (some times i'm getting:) 1.16225508968e-06 8.80804972547e-07 1.14314196588e-06 8.73752536492e-07 import timeit runs = 10000 x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113', 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow', 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig', ] r = 'a' code1 =""" x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113', 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow', 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig', ] r = 'a' if r in x : x.remove(r) """ print timeit.Timer( code1 ).timeit( runs ) / runs code2 =""" x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113', 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow', 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig', ] r = 'a' try : x.remove( r ) except : pass """ print timeit.Timer( code2 ).timeit( runs ) / runs Which is more pythonic?
0
python
2009-09-13T17:15:00.000
0
1,418,266
The try/except way
1
267
false
0
1
Which is more pythonic for array removal?
1,418,275
3
5
0
6
2
1
1.2
0
I'm removing an item from an array if it exists. Two ways I can think of to do this Way #1 # x array, r item to remove if r in x : x.remove( r ) Way #2 try : x.remove( r ) except : pass Timing it shows the try/except way can be faster (some times i'm getting:) 1.16225508968e-06 8.80804972547e-07 1.14314196588e-06 8.73752536492e-07 import timeit runs = 10000 x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113', 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow', 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig', ] r = 'a' code1 =""" x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113', 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow', 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig', ] r = 'a' if r in x : x.remove(r) """ print timeit.Timer( code1 ).timeit( runs ) / runs code2 =""" x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113', 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow', 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig', ] r = 'a' try : x.remove( r ) except : pass """ print timeit.Timer( code2 ).timeit( runs ) / runs Which is more pythonic?
0
python
2009-09-13T17:15:00.000
0
1,418,266
I've always gone with the first method. if in reads far more clearly than exception handling does.
1
267
true
0
1
Which is more pythonic for array removal?
1,418,310
1
6
0
3
3
0
1.2
0
Sorry if this is on the wrong site ( maybe superuser ) but I'm trying to make my python.py file executable so I can click on it and it automatically does its thing, without me specifying it to open in the terminal by that default prompt, and I already have 'chmod +x' for its permissions. Clarification: I want to run it by clicking on it, not through the terminal ( I meant that when I said 'can click on it and it automatically does its thing ' ) Already have a shebang line When I click it right now, it prompts me with do you want to open it in a text file, terminal - can I make it always default to opening in the terminal or is this just an oddball request?
0
python,linux
2009-09-13T18:53:00.000
1
1,418,553
First, pick a file extension you want for files you want to have this behavior. pyw is probably a good choice. Name your file that, and in your file browser associate that file type with python. In GNOME, you'd open its Properties window, go to the Open With tab, and enter python as a custom command. Now here's the important part: That little dialog you've been getting asking you what you'd like to do with the file is because it is marked as executable. Remove the executable bit with chmod -x. Now when you double click it, it will simply be opened with the associated program. Of course, if you want to run it from the command line, you'll now have to start it with python explicitly since it isn't marked executable. The shebang line doesn't matter anymore, but I'd leave it in anyway in case someone else marks it executable and expects it to work.
0
9,279
true
0
1
Auto executable python file without opening from terminal?
1,419,455
1
3
0
95
86
0
1.2
0
I received a Python project (which happens to be a Django project, if that matters,) that uses the fcntl module from the standard library, which seems to be available only on Linux. When I try to run it on my Windows machine, it stops with an ImportError, because this module does not exist here. Is there any way for me to make a small change in the program to make it work on Windows?
0
python,windows,linux
2009-09-14T15:43:00.000
1
1,422,368
The substitute of fcntl on windows are win32api calls. The usage is completely different. It is not some switch you can just flip. In other words, porting a fcntl-heavy-user module to windows is not trivial. It requires you to analyze what exactly each fcntl call does and then find the equivalent win32api code, if any. There's also the possibility that some code using fcntl has no windows equivalent, which would require you to change the module api and maybe the structure/paradigm of the program using the module you're porting. If you provide more details about the fcntl calls people can find windows equivalents.
0
122,994
true
0
1
fcntl substitute on Windows
1,422,436
1
2
0
0
8
0
0
0
I have a GSM modem connected to my computer, i want to receive text messages sent to it using a python program i have written, am just wondering what is the best technique to poll for data. Should i write a program that has a infinite loop that continuously checks for incoming sms's i.e within the loop the program sends the AT commands and reads the input data. or do modems have a way of signaling an application of an incoming data(sms). Am trying to imagine a cellphone is just a GSM modem, and when an sms is received, the phone alerts you of the event, or does the phone software have an infinite loop that polls for incoming data.
0
python,modem,gsm,at-command
2009-09-14T18:59:00.000
0
1,423,308
I find I can't remember much of the AT command set related to SMS. Andre Miller's answer seems to ring a few bells. Anyway you should read the documentation very carefully, I'm sure there were a few gotchas. My recommentation for polling is at least every 5 seconds - this is just for robustness and responsiveness in the face of disconnection. I used a state machine to navigate between initialisation, reading and deleting messages.
0
3,845
false
0
1
What is the best design for polling a modem for incoming data?
1,424,253
8
11
0
4
9
0
0.072599
0
Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?
0
python,python-idle
2009-09-14T23:28:00.000
1
1,424,398
I actually just discovered the easiest answer, if you use the shortcut link labeled "IDLE (Python GUI)". This is in Windows Vista, so I don't know if it'll work in other OS's. 1) Right-click "Properties". 2) Select "Shortcut" tab. 3) In "Start In", write file path (e.g. "C:\Users..."). Let me know if this works!
0
28,611
false
0
1
Default save path for Python IDLE?
20,500,218
8
11
0
1
9
0
0.01818
0
Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?
0
python,python-idle
2009-09-14T23:28:00.000
1
1,424,398
For OS X: Open a new finder window,then head over to applications. Locate your Python application. (For my mac,it's Python 3.5) Double click on it. Right click on the IDLE icon,show package contents. Then go into the contents folder,then resources. Now,this is the important part: (Note: You must be the administrator or have the administrator's password for the below to work) Right click on the idlemain.py,Get Info. Scroll all the way down. Make sure under the Sharing & Permissions tab,your "name"(Me) is on it with the privilege as Read & Write. If not click on the lock symbol and unlock it. Then add/edit yourself to have the Read & Write privilege. Lastly,as per Ned Deily's instructions,edit the line: os.chdir(os.path.expanduser('~/Documents')) with your desired path and then save the changes. Upon restarting the Python IDLE,you should find that your default Save as path to be the path you've indicated.
0
28,611
false
0
1
Default save path for Python IDLE?
35,376,000
8
11
0
2
9
0
0.036348
0
Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?
0
python,python-idle
2009-09-14T23:28:00.000
1
1,424,398
In Windows 10+, click the Windows Start button, then type idle, and then right-click on the IDLE desktop app and open the file location. This should bring you to the Start Menu shortcuts for Python, and you'll find a shortcut to IDLE there. Right-click on the IDLE shortcut and select properties. Set the "Start in" directory to be where you want default save path to be.
0
28,611
false
0
1
Default save path for Python IDLE?
53,340,799
8
11
0
1
9
0
0.01818
0
Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?
0
python,python-idle
2009-09-14T23:28:00.000
1
1,424,398
I am using windows 7 and by going to Start-> IDLE(Python 3.6 32-bit) The click on properties and then in the shortcut tab go to Start in and entering the desired path worked for me kindly note if IDLE is open and running while you do this you'll have to shut it down and restart it for this to work
0
28,611
false
0
1
Default save path for Python IDLE?
43,900,532
8
11
0
2
9
0
0.036348
0
Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?
0
python,python-idle
2009-09-14T23:28:00.000
1
1,424,398
It seems like you can get idle into the directory you want if you run any module from that directory. I had previously tried opening idlemain.py through the path browser. I was able to open and edit the file, but it seemed like I wasn't able to save my modifications. I'm just glad to hear other people are having this problem. I just thought I was being stupid.
0
28,611
false
0
1
Default save path for Python IDLE?
5,161,261
8
11
0
1
9
0
0.01818
0
Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?
0
python,python-idle
2009-09-14T23:28:00.000
1
1,424,398
On Windows (Vista at least, which is what I'm looking at here), shortcut icons on the desktop have a "Start in" field where you can set the directory used as the current working directory when the program starts. Changing that works for me. Anything like that on the Mac? (Starting in the desired directory from the command line works, too.)
0
28,611
false
0
1
Default save path for Python IDLE?
1,424,722
8
11
0
0
9
0
0
0
Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?
0
python,python-idle
2009-09-14T23:28:00.000
1
1,424,398
If you locate the idlelib directory in your Python install, it will have a few files with the .def extension. config-main.def has instructions on where to put the custom config files. However, looking through these I did not find any configurable paths (your install may vary). Looks like you might need to crack open the editor code to alter it.
0
28,611
false
0
1
Default save path for Python IDLE?
1,424,502
8
11
0
1
9
0
0.01818
0
Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?
0
python,python-idle
2009-09-14T23:28:00.000
1
1,424,398
If you open a module, that sets the default working directory. Start IDLE. File -> Open to open your file. And set the current working directory.
0
28,611
false
0
1
Default save path for Python IDLE?
1,424,507
1
2
0
0
1
0
0
1
I have a python program which starts up a PHP script using the subprocess.Popen() function. The PHP script needs to communicate back-and-forth with Python, and I am trying to find an easy but robust way to manage the message sending/receiving. I have already written a working protocol using basic sockets, but it doesn't feel very robust - I don't have any logic to handle dropped messages, and I don't even fully understand how sockets work which leaves me uncertain about what else could go wrong. Are there any generic libraries or IPC frameworks which are easier than raw sockets? ATM I need something which supports Python and PHP, but in the future I may want to be able to use C, Perl and Ruby also. I am looking for something robust, i.e. when the server or client crashes, the other party needs to be able to recover gracefully.
0
php,python,ipc
2009-09-15T00:47:00.000
0
1,424,593
You could look at shared memory or named pipes, but I think there are two more likely options, assuming at least one of these languages is being used for a webapp: A. Use your database's atomicity. In python, begin a transaction, put a message into a table, and end the transaction. From php, begin a transaction, take a message out of the table or mark it "read", and end the transaction. Make your PHP and/or python self-aware enough not to post the same messages twice. Voila; reliable (and scaleable) IPC, using existing web architecture. B. Make your webserver (assuming as webapp) capable of running both php and python, locking down any internal processes to just localhost access, and then call them using xmlrpc or soap from your other language using standard libraries. This is also scalable, as you can change your URLs and security lock-downs later.
0
2,322
false
0
1
Easy, Robust IPC between Python and PHP
1,424,687