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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | 2 | 0 | 4 | 2 | 1 | 1.2 | 0 |
I meet a problem when I try to install module omniORB&omniORBpy to a system, I don't have the root permission so I use --prefix to installed them to my user dir.
my question is : how can I make python load this module? I try add my user path to sys.path, but it still doesn't work.
Br,
J.K.
| 0 |
python,module
|
2010-12-27T10:14:00.000
| 0 | 4,537,975 |
You can add it to the search path by adding the directory to the environment variable PYTHONPATH or by adding it to sys.path in your Python script. Both work; if they don't, then you're using the wrong path.
| 0 | 1,009 | true | 0 | 1 |
add a python module with out root permission
| 4,537,989 |
2 | 2 | 0 | 1 | 2 | 1 | 0.099668 | 0 |
I meet a problem when I try to install module omniORB&omniORBpy to a system, I don't have the root permission so I use --prefix to installed them to my user dir.
my question is : how can I make python load this module? I try add my user path to sys.path, but it still doesn't work.
Br,
J.K.
| 0 |
python,module
|
2010-12-27T10:14:00.000
| 0 | 4,537,975 |
I usually use the --user option instead of --prefix, since it installs it in ${HOME}/.local/lib/pythonx/site-packages and thus it does not require to add the path to sys.path.
I think this option is available only for python 2.6 + but I am not sure.
If you have to install it in an other place, then you have no choice and I don't know what could be wrong.
By the way, maybe posting some sample code(just to see where exactly are the files and how you try to import them) would make clearer the "error".
| 0 | 1,009 | false | 0 | 1 |
add a python module with out root permission
| 4,540,025 |
1 | 3 | 0 | 8 | 27 | 1 | 1 | 0 |
I spend most of my time programming in Python, so forgive me if my approach to this problem is short-sited:
I want to have certain methods of a class require login credentials. Simply, each method should check whether the class variable user is set, and if so, continue, but if not, spit out a "you need to login" message.
In Python, I would just write a decorator to do this. How can I accomplish the same thing in java with as little redundant code as possible?
Thanks!
| 0 |
java,python
|
2010-12-29T04:22:00.000
| 0 | 4,551,457 |
The simplest thing to do is to write a method like "assertCredentials" and call that method at the start of every method that needs credentials. If credentials are not set, the method should throw an exception, which will abort the parent method.
Java has annotations that can be used to decorate methods, etc., but I don't think using annotations in this case would simplify things.
| 0 | 12,568 | false | 1 | 1 |
Python-like decorators in Java?
| 4,551,485 |
1 | 5 | 0 | 0 | 0 | 0 | 0 | 0 |
I've done a lot of web development in JSP/JSF, and lately quite a lot in ASP.NET.
I would like to learn one of the following: ruby/python/php, for quick and simple projects.
I don't really care which one it is as long as it meets following demands:
- decent IDE (forget the notepad/pspad etc.), something with code completition (like eclipse/visual studio/netbeans)
- it has to be able to run on windows (IDE and environment)
Thanks for suggestions
Cheers
| 0 |
php,python,ruby
|
2010-12-30T10:39:00.000
| 0 | 4,561,909 |
PHP and use codecanyon.net to get things up and running quick. I got INRtracker.com running in under 2 months with what I just mentioned.
If you're going to use php, then get wamp and then after you install it, restart your computer. Then click on the Wampserver short cut on your desktop to start it up and then click on the icon in the bottom right of your desktop (you might have to click a little arrow) and then click start all services, then you can put php files in your wamp/www folder (you should be able to get to that from your C drive). Then you test them by going to http://localhost/filename.php in your browser. Have fun dude!
| 0 | 1,531 | false | 1 | 1 |
From asp.net to python/ruby/php
| 11,289,391 |
1 | 4 | 0 | 1 | 2 | 0 | 0.049958 | 0 |
I have an application I wrote in PHP (on symfony) that imports large CSV files (up to 100,000 lines). It has a real memory usage problem. Once it gets through about 15,000 rows, it grinds to a halt.
I know there are measures I could take within PHP but I'm kind of done with PHP, anyway.
If I wanted to write an app that imports CSV files, do you think there would be any significant difference between Ruby and Python? Is either one of them geared to more import-related tasks? I realize I'm asking a question based on very little information. Feel free to ask me to clarify things, or just speak really generally.
If it makes any difference, I really like Lisp and I would prefer the Lispier of the two languages, if possible.
| 0 |
php,python,ruby,import,lisp
|
2010-12-31T16:23:00.000
| 0 | 4,571,119 |
I think the problem is that you are loading the csv in memory at once. If that is the case then I am sure that also python/ruby is going to blow up on you. I am a big fan of python, but that is just a personal opinion.
| 0 | 959 | false | 0 | 1 |
Ruby or Python for heavy import script?
| 4,571,760 |
2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 |
I have written a python script to draw the sierpinski gasket using Tkinter and when run from the python IDLE the program takes about half the time it takes to run when run from bash. I timed the script using them time module in python. Any ideas as to why this is happening will be appreciated. thanks
| 0 |
python
|
2011-01-01T03:30:00.000
| 1 | 4,573,094 |
Rafe is likely correct - you can test this out by limiting your imports and seeing if that makes a difference in startup time. I.e., if you are doing
from Tkinter import *
then change that to import only the modules you actually need. Or write a quick null program that just sets up and tears down without using anything in the package - that should run pretty close to the same in both.
| 0 | 830 | false | 0 | 1 |
running python script in bash slower than running code in IDLE
| 4,573,124 |
2 | 2 | 0 | 2 | 0 | 0 | 0.197375 | 0 |
I have written a python script to draw the sierpinski gasket using Tkinter and when run from the python IDLE the program takes about half the time it takes to run when run from bash. I timed the script using them time module in python. Any ideas as to why this is happening will be appreciated. thanks
| 0 |
python
|
2011-01-01T03:30:00.000
| 1 | 4,573,094 |
It's because of the way you're passing it. Based on your comment on the other answer, you're using python -c, and in IDLE you're using the Run command (or something similar). I'm not aware of any performance issues with python -c, but using Run in IDLE to run somescript.py is equivalent to python somescript.py.
You really should run scripts using python -c, it's more for small snippets.
| 0 | 830 | false | 0 | 1 |
running python script in bash slower than running code in IDLE
| 4,573,147 |
2 | 2 | 1 | 1 | 0 | 0 | 0.099668 | 0 |
I want to create a somehow complex application:
It is a game level editor. You can put in tiles and other objects for a level. Then "compress" the level data into a file.
With another application, it will read the file's data and play the game.
The application is for Windows mainly. Other platforms are yet to be considered.
So I need help deciding:
If you were to do something like what I described, which programming language would you choose?
I want to decide between Ruby or Python.
I want you to help me choose depending on my following needs:
Easy GUI platform for making the editor.
Can show sprites, move, transform them etc.
Can play audio.
Can compress data, graphics and audio. The compressed file can only be read by another application I make.
| 0 |
python,ruby,user-interface
|
2011-01-02T04:38:00.000
| 0 | 4,577,156 |
I've never used Ruby but I'm sure there is virtually no difference between the 2 when it comes to libraries. I know what you want can be done with Python using wxPython or pygame (or the combination of two). But I'm sure there are similar libs for Ruby. So just look at both languages and use the one you like better.
| 0 | 955 | false | 1 | 1 |
Making a somehow complex application: Ruby vs Python
| 4,577,169 |
2 | 2 | 1 | 4 | 0 | 0 | 1.2 | 0 |
I want to create a somehow complex application:
It is a game level editor. You can put in tiles and other objects for a level. Then "compress" the level data into a file.
With another application, it will read the file's data and play the game.
The application is for Windows mainly. Other platforms are yet to be considered.
So I need help deciding:
If you were to do something like what I described, which programming language would you choose?
I want to decide between Ruby or Python.
I want you to help me choose depending on my following needs:
Easy GUI platform for making the editor.
Can show sprites, move, transform them etc.
Can play audio.
Can compress data, graphics and audio. The compressed file can only be read by another application I make.
| 0 |
python,ruby,user-interface
|
2011-01-02T04:38:00.000
| 0 | 4,577,156 |
Python + PyGame. Hands down. You will benefit from:
Good docs for both the language and PyGame
GUI, sprites, and audio all in one, again with PyGame
Better Windows support than Ruby (you can install both Python and PyGame from .exes)
Desktop applications (esp. for Windows) aren't really Ruby's sweet spot. PyGame will serve your purposes perfectly, though.
That's not to say you couldn't do it with Ruby; you could write this in any language. But for ease of use, Python is the way to go.
| 0 | 955 | true | 1 | 1 |
Making a somehow complex application: Ruby vs Python
| 4,577,168 |
4 | 5 | 1 | 4 | 8 | 1 | 0.158649 | 0 |
I'd like to try my hand at some PC game development. I keep hearing that python is slow compared to C++. Is this something I should be worried about?
I am more familiar with python than C++. If I'm looking to make some games, should I take the time to learn C++ or just stick with Python?
| 0 |
python,performance
|
2011-01-02T12:15:00.000
| 0 | 4,578,307 |
The kind of game matters immensely. High performance games like the big name PC or console games are almost exclusively the domain of C++.
Casual games can be written in almost any language, including slower languages like Python.
If you're a garage type developer who gets his hands wet with some simple game development for this first time, Python would be more than enough. If you however have the ambition to work for a game developer studio, I would definitely recommend learning C++.
| 0 | 13,393 | false | 0 | 1 |
How "slow" is python for game development?
| 4,578,373 |
4 | 5 | 1 | 6 | 8 | 1 | 1 | 0 |
I'd like to try my hand at some PC game development. I keep hearing that python is slow compared to C++. Is this something I should be worried about?
I am more familiar with python than C++. If I'm looking to make some games, should I take the time to learn C++ or just stick with Python?
| 0 |
python,performance
|
2011-01-02T12:15:00.000
| 0 | 4,578,307 |
Elebenty-seven.
No, really, it's fast enough for most things, and can drop to C when you really need speed. Profile twice, optimize once.
| 0 | 13,393 | false | 0 | 1 |
How "slow" is python for game development?
| 4,578,311 |
4 | 5 | 1 | -3 | 8 | 1 | -0.119427 | 0 |
I'd like to try my hand at some PC game development. I keep hearing that python is slow compared to C++. Is this something I should be worried about?
I am more familiar with python than C++. If I'm looking to make some games, should I take the time to learn C++ or just stick with Python?
| 0 |
python,performance
|
2011-01-02T12:15:00.000
| 0 | 4,578,307 |
C++ is much more easier for object orientation. When you're doing things, it's easier to keep track of everything, because most IDEs for C++ are more based on projects, were as IDLE is more based on single files.
The bottom line is for game development, use what you're comfortable with using. I mean, game development is about what you want to do, not what would be better, because better == what you want.
| 0 | 13,393 | false | 0 | 1 |
How "slow" is python for game development?
| 15,419,304 |
4 | 5 | 1 | 2 | 8 | 1 | 0.07983 | 0 |
I'd like to try my hand at some PC game development. I keep hearing that python is slow compared to C++. Is this something I should be worried about?
I am more familiar with python than C++. If I'm looking to make some games, should I take the time to learn C++ or just stick with Python?
| 0 |
python,performance
|
2011-01-02T12:15:00.000
| 0 | 4,578,307 |
Many if not most top-end commercial games these days include some kind of scripting engine for game logic. Game logic decisions, for the most part, aren't particularly performance-sensitive in the way that e.g. the rendering engine is.
BTW - I'm not claiming any insider knowledge of game development - this is fairly well known outside the industry. Some games publishers have even allowed users access to the scripting stuff and other tools for games modding - for years.
If you find a game engine that is wrapped to be used in Python, you'll be dealing with the same basic principles. Write the game logic in Python, and you'll probably be fine.
PyGame is basically SDL wrapped for Python, supporting basic 2D games for the most part (though OpenGL can be used for 3D in SDL - not sure for PyGame).
It's a good starting point. You may hit a performance issue with managing your game objects and running your blit loop, since only very basic graphics stuff is handled by SDL, but you should find that it's just fine for most things.
As Ignacio implies - worry about performance problems when you know you have performance problems, not before. Some performance problems are predictable in advance, but if you're not writing the actual game engine in Python, you should be OK - don't fall into the premature optimisation trap, IOW.
| 0 | 13,393 | false | 0 | 1 |
How "slow" is python for game development?
| 4,578,381 |
2 | 4 | 0 | 0 | 3 | 0 | 0 | 1 |
I need to scrape about 100 websites that are very similar in the content that they provide.
My first doubt. Should be possible to write a generic script to scrape all the 100 websites or in scraping techniques is only possible to write scripts for particular websites. (Dumb question.). I think I should ask what possibility is easier. Write 100 different scripts for each website is hard.
Second question. My primary language is PHP, but after searching here on Stackoverflow I found that one of the most advanced scrapers is "Beautiful Soup" in Python. Should be possible to make calls in PHP to "Beautiful Soup" in Python? Or should be better to do all the script in Python?
Give me some clues on how should I go.
Sorry for my weak english.
Best Regards,
| 0 |
php,python,screen-scraping
|
2011-01-03T14:59:00.000
| 0 | 4,585,490 |
We do something sort of like this with RSS feeds using Python -- we use ElementTree since RSS is usually guaranteed to be well-formed. Beautiful Soup is probably better suited for parsing HTML.
Insofar as dealing with 100 different sites, try to write an abstraction that works on most of them and transforms the page into a common data-structure you can work with. Then override parts of the abstraction to handle individual sites which differ from the norm.
Scrapers are usually I/O bound -- look into coroutine libraries like eventlet or gevent to exploit some I/O parallelism and speed up the whole process.
| 0 | 4,219 | false | 1 | 1 |
Webscraping Techniques using PHP or Python
| 4,586,678 |
2 | 4 | 0 | 0 | 3 | 0 | 0 | 1 |
I need to scrape about 100 websites that are very similar in the content that they provide.
My first doubt. Should be possible to write a generic script to scrape all the 100 websites or in scraping techniques is only possible to write scripts for particular websites. (Dumb question.). I think I should ask what possibility is easier. Write 100 different scripts for each website is hard.
Second question. My primary language is PHP, but after searching here on Stackoverflow I found that one of the most advanced scrapers is "Beautiful Soup" in Python. Should be possible to make calls in PHP to "Beautiful Soup" in Python? Or should be better to do all the script in Python?
Give me some clues on how should I go.
Sorry for my weak english.
Best Regards,
| 0 |
php,python,screen-scraping
|
2011-01-03T14:59:00.000
| 0 | 4,585,490 |
I've done this a few ways.
1: with grep, sed, and awk. This is about the same as 2: regex. These methods are very direct, but fail whenever the HTML structure of the site changes.
3: PHP's XML/HTML parser DomDocument. This is far more reliable than regex, but I found it annoying to work with (I hate the mixture of PHP arrays and objects). If you want to use PHP, PHPQuery is probably a good solution, as Thai suggested.
4: Python and BeautifulSoup. I can't say enough good things about BeautifulSoup, and this is the method I recommend. I found my code feels cleaner in Python, and BeautifulSoup was very easy and efficient to work with. Good documentation, too.
You will have to specialize your script for each site. It depends on what sort of information you wish to extract. If it was something standard like body title, of course you wouldn't have to change anything, but it's likely the info you want is more specific?
| 0 | 4,219 | false | 1 | 1 |
Webscraping Techniques using PHP or Python
| 4,585,784 |
1 | 2 | 0 | 0 | 1 | 0 | 0 | 0 |
I am trying to send an email using python that has the standard To From, body, etc. However this is where my question comes in. My python script takes information in a string and manipulates it(adds,removes, formats, etc) I am trying to take this output and send it as an attachment on-the-fly. I know I can dump the output to a text file and then attach it to the email. However, due to the security of this CGI script I cannot write to the CGI directory. Is there a way to dynamically create a textfile object and send it as an attachment?
Using Python SMTP module.
I cannot create a traditional static text file due to permissions. I would like to see if Python is able to create a text file upon execution that i can populate with data and then attach to the email smtp module.
| 0 |
python,email,text,cgi,attachment
|
2011-01-04T20:40:00.000
| 0 | 4,598,204 |
Are you using smtplib and email.mime.multipart modules? the attach() method of the MIMEMultipart class accepts chunk of data to be attached, not a file.
| 0 | 566 | false | 0 | 1 |
python CGI email dynamic output as a text file attachment
| 4,598,568 |
4 | 6 | 0 | 0 | 0 | 0 | 0 | 0 |
I was watching the tutorials for python and the guy told that he coded the Address books and spell checker for yahoo mail in python.
Now initially i was thinking that if i build the website then i have to use one language either php or java or asp or anything.
But i am confused how can we make make separate modules in diff languages and combine to make one website
Any ideas
| 0 |
python,web,yahoo
|
2011-01-05T14:37:00.000
| 0 | 4,605,243 |
If they're different pages, they can easily be created by different software. So if a mail application written in Java offers a link to an address book, the address book can easily be Python--that's just a matter of configuring the server.
If you need an addressbook component within the mail application, that's a bit more complicated, but still doable. Especially with Java and .NET it's possible to run various languages on the same platform (e.g. Jython and Ironpython run Python on the JAVA and .NET VMs respectively).
| 0 | 99 | false | 1 | 1 |
Is it possible to use different technologies in one website
| 4,605,453 |
4 | 6 | 0 | 2 | 0 | 0 | 1.2 | 0 |
I was watching the tutorials for python and the guy told that he coded the Address books and spell checker for yahoo mail in python.
Now initially i was thinking that if i build the website then i have to use one language either php or java or asp or anything.
But i am confused how can we make make separate modules in diff languages and combine to make one website
Any ideas
| 0 |
python,web,yahoo
|
2011-01-05T14:37:00.000
| 0 | 4,605,243 |
Phisical architecture of web application can be different from the logical one visible through browser. Basically it is achieved by putting front web server (think of apache with mod_proxy, but it can be any other moder web server supporting reverse proxying) and mounting web application servers (java/python/whatever) to different paths (like /app1 for java app, /app1/subapp for python app, /app2 for php app). Of course those applications work independently by default, so if you want to pass some data between you have to establish some communication between (direct socket-to-socket or indirect with some messaging middleware or database).
In general it is very broad topic, so if you're interested, try with some basic keywords: application servers, load balancing, reverse proxy, url rewriting.
| 0 | 99 | true | 1 | 1 |
Is it possible to use different technologies in one website
| 4,605,394 |
4 | 6 | 0 | 0 | 0 | 0 | 0 | 0 |
I was watching the tutorials for python and the guy told that he coded the Address books and spell checker for yahoo mail in python.
Now initially i was thinking that if i build the website then i have to use one language either php or java or asp or anything.
But i am confused how can we make make separate modules in diff languages and combine to make one website
Any ideas
| 0 |
python,web,yahoo
|
2011-01-05T14:37:00.000
| 0 | 4,605,243 |
I know in Ruby on Rails, you can execute bash commands.
Example: puts ls
| 0 | 99 | false | 1 | 1 |
Is it possible to use different technologies in one website
| 4,605,290 |
4 | 6 | 0 | 1 | 0 | 0 | 0.033321 | 0 |
I was watching the tutorials for python and the guy told that he coded the Address books and spell checker for yahoo mail in python.
Now initially i was thinking that if i build the website then i have to use one language either php or java or asp or anything.
But i am confused how can we make make separate modules in diff languages and combine to make one website
Any ideas
| 0 |
python,web,yahoo
|
2011-01-05T14:37:00.000
| 0 | 4,605,243 |
You can use any language to provide a web service, so you can for example provide a REST/SOAP web service that returns JSON or XML. The web service can be written in any language, and the language used to interact with the web service can be any language, as all languages nowadays have JSON and XML parsers.
You can setup different subdomains to be used by different servers and setup those applications in any language you'd like.
| 0 | 99 | false | 1 | 1 |
Is it possible to use different technologies in one website
| 4,605,266 |
4 | 6 | 0 | 4 | 1 | 0 | 0.132549 | 0 |
I wrote a python script to monitor a log file on a CentOS server for a specific value and send an email when it finds it. It runs as a cron every 5 minutes.
My question is what is the best way to put this script to sleep after it has sent the first email. I don't want it to be sending emails every 5 mins, but it needs to wake up and check the log again after an hour or so. This is assuming the problem can be fixed in under an hour. The people who are receiving the email don't have shell access to disable the cron.
I thought about sleep but I'm not sure if cron will try to run the script again if another process is active (sleeping).
| 0 |
python,cron
|
2011-01-05T17:46:00.000
| 0 | 4,607,343 |
cron will absolutely run the script again. You need to think this through a little more carefully than just "sleep" and "email every 10 minutes."
You need to write out your use cases.
System sends message and user does something.
System sends message and user does nothing. Why email the user again? What does 2 emails do that 1 email didn't do? Perhaps you should SMS or email someone else.
How does the user register that something was done? How will they cancel or stop this cycle of messages?
What if something is found in the log, an email is sent and then (before the sleep finishes) the thing is found again in the log. Is that a second email? It is two incidents. Or is that one email with two incidents?
| 0 | 1,999 | false | 0 | 1 |
How to sleep a python script running as a cronjob?
| 4,607,368 |
4 | 6 | 0 | 1 | 1 | 0 | 0.033321 | 0 |
I wrote a python script to monitor a log file on a CentOS server for a specific value and send an email when it finds it. It runs as a cron every 5 minutes.
My question is what is the best way to put this script to sleep after it has sent the first email. I don't want it to be sending emails every 5 mins, but it needs to wake up and check the log again after an hour or so. This is assuming the problem can be fixed in under an hour. The people who are receiving the email don't have shell access to disable the cron.
I thought about sleep but I'm not sure if cron will try to run the script again if another process is active (sleeping).
| 0 |
python,cron
|
2011-01-05T17:46:00.000
| 0 | 4,607,343 |
When your scripts sends email, make it also create a txt file "email_sent.txt". Then make it check for existence of this txt file before sending email. If it exists, don't send email. If it does not exist, send email and create the text file.
The text files serves as an indicator that email has already been sent and it does not need to be sent again.
| 0 | 1,999 | false | 0 | 1 |
How to sleep a python script running as a cronjob?
| 4,608,337 |
4 | 6 | 0 | 3 | 1 | 0 | 1.2 | 0 |
I wrote a python script to monitor a log file on a CentOS server for a specific value and send an email when it finds it. It runs as a cron every 5 minutes.
My question is what is the best way to put this script to sleep after it has sent the first email. I don't want it to be sending emails every 5 mins, but it needs to wake up and check the log again after an hour or so. This is assuming the problem can be fixed in under an hour. The people who are receiving the email don't have shell access to disable the cron.
I thought about sleep but I'm not sure if cron will try to run the script again if another process is active (sleeping).
| 0 |
python,cron
|
2011-01-05T17:46:00.000
| 0 | 4,607,343 |
@Lennart, @S. Lott: I think the question was somewhat the other way around - the script runs as a cron job every five minutes, but after sending an error-email it shouldn't send another for at least an hour (even if the error state persists).
The obvious answer, I think, is to save a self-log - for each problem detected, an id and a timestamp for the last time an email was sent. When a problem is detected, check the self-log; if the last email for this problem-id was less than an hour ago, don't send the email. Then your program can exit normally until called again by cron.
| 0 | 1,999 | true | 0 | 1 |
How to sleep a python script running as a cronjob?
| 4,607,608 |
4 | 6 | 0 | 0 | 1 | 0 | 0 | 0 |
I wrote a python script to monitor a log file on a CentOS server for a specific value and send an email when it finds it. It runs as a cron every 5 minutes.
My question is what is the best way to put this script to sleep after it has sent the first email. I don't want it to be sending emails every 5 mins, but it needs to wake up and check the log again after an hour or so. This is assuming the problem can be fixed in under an hour. The people who are receiving the email don't have shell access to disable the cron.
I thought about sleep but I'm not sure if cron will try to run the script again if another process is active (sleeping).
| 0 |
python,cron
|
2011-01-05T17:46:00.000
| 0 | 4,607,343 |
You are running it every five minutes. Why would you sleep it? Just exit. If you want to make sure it doesn't send email every five minutes, then make the program only send an email if there is anything to send.
If you sleep it for an hour, and run it every five minutes, after an hour you'll have 12 copies running (and twelve emails sent) so that's clearly not the way to go forward. :-)
| 0 | 1,999 | false | 0 | 1 |
How to sleep a python script running as a cronjob?
| 4,607,451 |
2 | 3 | 0 | 2 | 2 | 0 | 1.2 | 0 |
How can I access the SMS inbox from an application (on Symbian s60)? Us it possible with j2me? How about C++ or Python?
| 0 |
c++,python,java-me,symbian,inbox
|
2011-01-05T22:43:00.000
| 0 | 4,609,956 |
Reading message from inbox in j2me is not possible
if you want to read sms then you can send message using particular port and
your j2me application should listen on that port
otherwise you can go with symbian c++ where it is possible.
| 0 | 939 | true | 1 | 1 |
access to sms inbox
| 4,612,488 |
2 | 3 | 0 | 2 | 2 | 0 | 0.132549 | 0 |
How can I access the SMS inbox from an application (on Symbian s60)? Us it possible with j2me? How about C++ or Python?
| 0 |
c++,python,java-me,symbian,inbox
|
2011-01-05T22:43:00.000
| 0 | 4,609,956 |
In j2me, you can't access the native message box related stuff like Inbox, Sent Message or etc. But it is possible in c++. I don't know about python.
| 0 | 939 | false | 1 | 1 |
access to sms inbox
| 4,611,971 |
1 | 2 | 0 | 5 | 2 | 0 | 1.2 | 0 |
I want to write a (preferably python) script to modify the content of one file in a gzipped tar file. The script must run on FreeBSD 6+.
Basically, I need to:
open the tar file
if the tar file has _MY_FILE_ in it:
if _MY_FILE_ has a line matching /RE/ in it:
insert LINE after the matching line
rewrite the content into the tar file, preserving all metadata except the file size
I'll be repeating this for a lot of files.
Python's tarfile module doesn't seem to be able to open tar files for read/write access when they're compressed, which makes a certain amount of sense. However, I can't find a way to copy the tar file with modifications, either.
Is there an easy way to do this?
| 0 |
python,scripting,automation,tar
|
2011-01-05T23:15:00.000
| 1 | 4,610,205 |
Don't think of a tar file as a database that you can read/write -- it's not. A tar file is a concatenation of files. To modify a file in the middle, you need to rewrite the rest of the file. (for files of a certain size, you might be able to exploit the block padding)
What you want to do is process the tarball file by file, copying files (with modifications) into a new tarball. The Python tarfile module should make this easy to do. You should be able to retain the attributes by copying them from the old TarInfo object to the new one.
| 0 | 6,217 | true | 0 | 1 |
How can I modify a file in a gzipped tar file?
| 4,610,327 |
2 | 2 | 0 | 5 | 5 | 1 | 0.462117 | 0 |
Can the equivalent of eval and exec exist in a compiled language? If so, how would they be compiled (roughly speaking)?
| 0 |
python,compilation,eval,exec
|
2011-01-06T03:03:00.000
| 0 | 4,611,369 |
Certainly, various Lisp environments have had this capability for decades. A Lisp compiler typically works on a per-function basis, and the compiler and runtime system work hand in hand.
When asked to eval something, the Lisp runtime environment will pass the list (a data structure) to the compiler for compiling. The compiler may generate machine code (or maybe bytecode, depending on the system), and then the function will be callable at the machine level just like every other function in the program.
| 0 | 453 | false | 0 | 1 |
If Python's exec and eval were compiled?
| 4,611,385 |
2 | 2 | 0 | 5 | 5 | 1 | 1.2 | 0 |
Can the equivalent of eval and exec exist in a compiled language? If so, how would they be compiled (roughly speaking)?
| 0 |
python,compilation,eval,exec
|
2011-01-06T03:03:00.000
| 0 | 4,611,369 |
For starters, python is a compiled language, it just does the compilation at runtime. That being said, all that you need to do to implement eval in any other compiled language is to be able to run the compiler (and dynamically load object code) - you can do this in Python (and a litany of other languages) easily because the compiler is an integral part of the runtime. There's technically nothing that stops a program written in C from invoking the compiler and loading the result at runtime (using dlopen), it's just not a common occurrence because the C runtime doesn't require a compiler, so most users don't have one.
| 0 | 453 | true | 0 | 1 |
If Python's exec and eval were compiled?
| 4,611,394 |
1 | 1 | 0 | 3 | 1 | 1 | 1.2 | 0 |
Taking e.g. Python as a good example of a modern scripting language, it has the option of reading a program (as opposed to input data for the program) from stdin. The REPL is the obvious use case where stdin is a terminal, but it's also designed to handle the scenario where it's not a terminal.
What use cases are there for reading the program itself from noninteractive stdin?
(The reason I ask is that I'm working on a scripting language myself, and wondering whether this is an important feature to provide, and if so, what the specifics need to look like.)
| 0 |
python,scripting,programming-languages
|
2011-01-06T10:21:00.000
| 1 | 4,613,888 |
If you want to execute code generated by some tool it could be useful to be able to pipe the generated into your interpreter/compiler..
Simply support it ;) Checking if stdin is a tty or not is not hard anyway.
| 0 | 104 | true | 0 | 1 |
Script from stdin use case
| 4,613,922 |
1 | 1 | 0 | 3 | 2 | 0 | 1.2 | 0 |
I built a small micro framework for our web service / web app and have it hosted it in a private repository on github.
I've added the private github repo in the dependency_links and have verified that it exists in dependency_links.txt
When I execute python setup.py install, I get unknown url type: git+ssh, so I looked deeper into the code and realized that distribute only has support for svn+ url types. I was under the (apparently wrong) impression that distribute used pip under the hood, but looks like it still uses easy_install.
Has anyone found a solution to using distutils / distribute to install private github repos as dependencies?
| 0 |
python,github,distribution,distutils,easy-install
|
2011-01-06T11:46:00.000
| 1 | 4,614,552 |
If you know, that "pip" works, why don't you just use "pip"? "pip" can not only install from a package index, but also from a local source directory. Just use pip install . instead of python setup.py install.
Concerning your impression, it is indeed wrong. "pip" and "distribute" are altogether different projects with different aims. "pip" is a frontend to the distutils/setuptools API, trying to replace the rather weird "easy_install" frontend, whereas "distribute" is an alternative implementation of the backend "setuptools" API (which only includes an "easy_install" implementation for the sake of compatibility). "pip" isn't tied to "distribute" and also works with the old "setuptools" implementation.
I'd therefore recommend to always use "pip" for all package installations, and to never use "easy_install" or "python setup.py install". "pip" just works, whereas the other two are somewhat strange.
| 0 | 816 | true | 1 | 1 |
Has anyone gotten distribute to work correctly with github, specifically private repositories?
| 4,615,208 |
1 | 1 | 0 | 8 | 2 | 0 | 1.2 | 0 |
I have just started using Ubuntu as my first Linux, have a couple of question.
What is the difference between easy_install and apt-get?
How do I update my packages with packages installed in both these ways?
They are under pythonpath right?
| 0 |
python,linux,ubuntu,packages
|
2011-01-06T13:20:00.000
| 1 | 4,615,299 |
You are confusing two completely separate things.
Aptitude, of which apt_get is one part, is the Ubuntu system-wide package manager. It has packages for absolutely everything - applications, libraries, system utils, whatever. They may not be the latest versions, as packages are usually only updated for each separate Ubuntu release (except for security and bug fixes).
easy_install is a Python-only system for install Python libraries. It doesn't do anything else. The libraries are installed in the system Python's site-packages directory. There are some downsides to easy_install, one of which is that it's hard to upgrade and uninstall libraries. Use pip instead.
| 0 | 1,284 | true | 0 | 1 |
what is the difference between easy_install and apt-get
| 4,615,378 |
1 | 1 | 1 | 1 | 1 | 0 | 0.197375 | 0 |
Simply, I'm developing a wireless ECG (electrocardiogram, or EKG from the German Elektrokardiogramm) and I need to choose the best language for a desktop application that allows the following:
wireless transmission of data over WiFi
real-time graphing of ECG data signal
a good DSP library
Thanks.
| 0 |
c#,java,c++,python,c
|
2011-01-07T06:26:00.000
| 0 | 4,623,047 |
From the viewpoint of a normal program (i.e., not a device driver) a Wi-Fi connection is just a network connection -- not noticeably different from (for example) a wired Ethernet connection.
Real-time graphing and digital signal processing libraries are probably a little less common, but not much. "Real time" is one of those slippery phrases that it's hard to pin down exactly what it means (different people use it differently). At a guess, you just mean you want to update the graph as data arrives. In that case, the important question is what bandwidth you're dealing with -- i.e., how many updates of how much information, how fast?
Bottom line -- none of what you've told us gives much in the way of real criteria for picking a language to use. The obvious open question would be performance -- how much data you need to process, and how much processing you need to do on it. That might at least hint at one being better than another.
| 0 | 883 | false | 0 | 1 |
ECG/EKG software language advice
| 4,623,129 |
1 | 2 | 0 | 0 | 1 | 0 | 0 | 1 |
Is it possible to send a MIME message as it is, without adding any headers? For example, if I have a correct MIME message with all headers and content saved to a text file, is it possible to use the contents of this file without modification and send it via SMTP?
Apparently both python's SMTP.sendmail and PHP smtp::mail require at least "To:" and "From:", and passing the complete message to these functions doesn't seem to work.
| 0 |
php,python,email
|
2011-01-08T13:52:00.000
| 0 | 4,634,171 |
You could read up to the first blank line, use those as additional headers, then send the rest in the body.
| 0 | 161 | false | 0 | 1 |
Sending a MIME email prepared beforehand (in PHP or Python)
| 4,634,184 |
4 | 5 | 0 | 1 | 3 | 1 | 0.039979 | 0 |
I am writing an application for image processing. I am just wondering which programming language would be the best fit. Python or PHP. This process is system based not web based so I am just thinking if Python could be of more help.
Let me know your thoughts!
| 0 |
php,python,image,image-processing,image-manipulation
|
2011-01-09T19:19:00.000
| 0 | 4,641,187 |
Possibly neither; it depends on what you want to do.
Both PHP and Python are scripting languages, and are therefore not suited for high-performance numerical routines (which most image processing requires). However, they both have a number of image-processing libraries available for them, the innards of which are probably written in C. These will be fast.
If these libraries do what you want, then fine. If you need to so something custom, then you're probably better off with C or C++ (or Pascal, or whatever) if speed of execution is of concern.
| 0 | 2,343 | false | 1 | 1 |
PHP or Python for Image Processing?
| 4,641,208 |
4 | 5 | 0 | 2 | 3 | 1 | 0.07983 | 0 |
I am writing an application for image processing. I am just wondering which programming language would be the best fit. Python or PHP. This process is system based not web based so I am just thinking if Python could be of more help.
Let me know your thoughts!
| 0 |
php,python,image,image-processing,image-manipulation
|
2011-01-09T19:19:00.000
| 0 | 4,641,187 |
One cannot suggest much without knowing the kind of image processing you have in mind.
If you just want to do some generic rotate/resize/etc then I guess there isn't much difference.
If you want to do something more complex, then study the libraries and decide which fits best for your particular task.
If you want to do something really custom, then C or similar language might be a better fit for the task.
| 0 | 2,343 | false | 1 | 1 |
PHP or Python for Image Processing?
| 4,641,228 |
4 | 5 | 0 | 0 | 3 | 1 | 0 | 0 |
I am writing an application for image processing. I am just wondering which programming language would be the best fit. Python or PHP. This process is system based not web based so I am just thinking if Python could be of more help.
Let me know your thoughts!
| 0 |
php,python,image,image-processing,image-manipulation
|
2011-01-09T19:19:00.000
| 0 | 4,641,187 |
It really depends on what you want to do with the images. You probably should just use a batch or similar script to run a command that does the processing your looking for.
Between the two languages, I would go with python. The command line interface for php is only a recent addition, while python was designed primarily as a scripting language, not for serving pages. For a console application, python is a better fit.
| 0 | 2,343 | false | 1 | 1 |
PHP or Python for Image Processing?
| 4,641,242 |
4 | 5 | 0 | 1 | 3 | 1 | 0.039979 | 0 |
I am writing an application for image processing. I am just wondering which programming language would be the best fit. Python or PHP. This process is system based not web based so I am just thinking if Python could be of more help.
Let me know your thoughts!
| 0 |
php,python,image,image-processing,image-manipulation
|
2011-01-09T19:19:00.000
| 0 | 4,641,187 |
Python is more clean and readable.
For image processing there is the imageMagic library available for Python and PHP too.
If you want to do some other complex image processing, which cannot by done using a library and you still want to do it in Python or PHP, then Python is defenitely the answer as Python can be extended with C -- But, wait, you didn't mention programming in C, well, there is Cython! It would allow you to write Python modules which are afterwards compiled to C
| 0 | 2,343 | false | 1 | 1 |
PHP or Python for Image Processing?
| 4,641,248 |
1 | 3 | 0 | 0 | 3 | 0 | 0 | 0 |
What is the easiest way to generate PDF documents with embedded fonts in Python without a commercial/restricted library?
I want to generate documents with tabular data and headers/footers. I've tried reportlab, but while powerful, it seems rather difficult to use.
| 0 |
python,pdf,pdf-generation
|
2011-01-09T21:18:00.000
| 0 | 4,641,877 |
Be careful if you want to be able to extract the tabular data later from the PDFs. They need to be created as Structured Content or there will be no tabular metadata in the PDF file.
| 0 | 383 | false | 0 | 1 |
FLOSS/Free solution to generate PDF documents in Python?
| 4,641,984 |
2 | 8 | 1 | 163 | 202 | 0 | 1 | 0 |
is it possible to convert a Python program to C/C++?
I need to implement a couple of algorithms, and I'm not sure if the performance gap is big enough to justify all the pain I'd go through when doing it in C/C++ (which I'm not good at). I thought about writing one simple algorithm and benchmark it against such a converted solution. If that alone is significantly faster than the Python version, then I'll have no other choice than doing it in C/C++.
| 0 |
c++,python,c,code-generation
|
2011-01-10T18:46:00.000
| 0 | 4,650,243 |
If the C variant needs x hours less, then I'd invest that time in letting the algorithms run longer/again
"invest" isn't the right word here.
Build a working implementation in Python. You'll finish this long before you'd finish a C version.
Measure performance with the Python profiler. Fix any problems you find. Change data structures and algorithms as necessary to really do this properly. You'll finish this long before you finish the first version in C.
If it's still too slow, manually translate the well-designed and carefully constructed Python into C.
Because of the way hindsight works, doing the second version from existing Python (with existing unit tests, and with existing profiling data) will still be faster than trying to do the C code from scratch.
This quote is important.
Thompson's Rule for First-Time Telescope Makers
It is faster to make a four-inch mirror and then a six-inch mirror than to make a six-inch mirror.
Bill McKeenan
Wang Institute
| 0 | 475,467 | false | 0 | 1 |
Convert Python program to C/C++ code?
| 4,650,953 |
2 | 8 | 1 | 12 | 202 | 0 | 1 | 0 |
is it possible to convert a Python program to C/C++?
I need to implement a couple of algorithms, and I'm not sure if the performance gap is big enough to justify all the pain I'd go through when doing it in C/C++ (which I'm not good at). I thought about writing one simple algorithm and benchmark it against such a converted solution. If that alone is significantly faster than the Python version, then I'll have no other choice than doing it in C/C++.
| 0 |
c++,python,c,code-generation
|
2011-01-10T18:46:00.000
| 0 | 4,650,243 |
I know this is an older thread but I wanted to give what I think to be helpful information.
I personally use PyPy which is really easy to install using pip. I interchangeably use Python/PyPy interpreter, you don't need to change your code at all and I've found it to be roughly 40x faster than the standard python interpreter (Either Python 2x or 3x). I use pyCharm Community Edition to manage my code and I love it.
I like writing code in python as I think it lets you focus more on the task than the language, which is a huge plus for me. And if you need it to be even faster, you can always compile to a binary for Windows, Linux, or Mac (not straight forward but possible with other tools). From my experience, I get about 3.5x speedup over PyPy when compiling, meaning 140x faster than python. PyPy is available for Python 3x and 2x code and again if you use an IDE like PyCharm you can interchange between say PyPy, Cython, and Python very easily (takes a little of initial learning and setup though).
Some people may argue with me on this one, but I find PyPy to be faster than Cython. But they're both great choices though.
Edit: I'd like to make another quick note about compiling: when you compile, the resulting binary is much bigger than your python script as it builds all dependencies into it, etc. But then you get a few distinct benefits: speed!, now the app will work on any machine (depending on which OS you compiled for, if not all. lol) without Python or libraries, it also obfuscates your code and is technically 'production' ready (to a degree). Some compilers also generate C code, which I haven't really looked at or seen if it's useful or just gibberish. Good luck.
Hope that helps.
| 0 | 475,467 | false | 0 | 1 |
Convert Python program to C/C++ code?
| 37,192,125 |
1 | 1 | 0 | 1 | 2 | 0 | 0.197375 | 0 |
I have a project where I use erlang to aggregate RSS, and I use python to process the RSS feeds.
Method 1:
Use an erlang port, using erlport.org, to call python.
I'm not sure how to design the python code to be asyncrhonous using erlport.
Method 2:
Use erlang to call on a RESTful interface with Tornado that does the processing (asynchro downloading of urls -- asynchro procssing)
| 0 |
python,erlang
|
2011-01-11T01:34:00.000
| 1 | 4,653,361 |
I haven't worked Erlang<->Python before but erlport.org seems promising. I would try that first before getting into greasiness with REST and what not. I.e. I didn't provide and answer but a recommendation :)
| 0 | 196 | false | 0 | 1 |
Which of two methods of using python within erlang should I use?
| 4,654,839 |
1 | 4 | 0 | 1 | 0 | 0 | 1.2 | 1 |
I am interested to make a chatbot. My script is currently working fine with imified.com bot. however imified is down almost everday. so i am looking for my own solution.
during my findings, I have found (through this site) openfire and I have configured it and it is working fine even with gmails users.
but i am still not getting what I need.
I need to request a URL (with the chat scripts and some other user data something like imified provides) when each gmail or other external users send me a message. let me explain.
my openfire is hosted and working for mybot.com and my id is: [email protected].
now a gmail user say [email protected] added me in his gtalk/piding and we can communicate each other. he can send me message and I can reply.
but I need a robot instead of me. when [email protected] (and any other user) sends me a message, I need to request a URL so that i can dynamically generate response based on the message he/she sent.
in which way I should go for achieving this? Is there any way to customize openfire to do so?
or should I make a php/python (i need to learn python though) script that will listen to xmpp ports and generate responses? if so, any helpful scripts that may guide me?
bunch of thanks for reading it and thanks in advance for providing any response.
| 0 |
java,php,python,xmpp
|
2011-01-11T12:29:00.000
| 0 | 4,657,611 |
The OpenFire understand XMPP, what you need is XMPP library/API (like XMPP4R if you are Rubyist). Using it your app will login to OpenFire (by sending gmail/yahoo credentials) and others will see you as online. But when they will reply to you, you will be notified in your application. Where you can receive the message, process it, and send response (by writing a required program/logic).
We have done it in our SMS Chat application with Gmail/Yahoo messenger friends/contacts.
| 0 | 2,089 | true | 0 | 1 |
XMPP, openfire and bot issue
| 8,296,818 |
2 | 3 | 0 | 0 | 1 | 0 | 1.2 | 0 |
We have a website that lists links to blogs in realtime. The problem is that the pages are slow to load because they are reading data from the various source sites.
I wrote a PHP script that creates an HTML version of each page. This runs once each hour. The problem is that the PHP script is timing out before it finishes all the pages. I know that I could increase the execute time allowed for PHP scripts, but this does not seem like the most efficient way to handle the issue.
Is there another way to do this? I just don't know what to begin looking for - PERL? JAVA? Python? How do these scripts run on a server? What should I look for from my web host?
| 0 |
php,python,cron,web-hosting
|
2011-01-11T18:45:00.000
| 0 | 4,661,377 |
A different solution might be to use a database, and not bite off so much work at once. Make a table listing the sites you pull, and store when they were last pulled. Then have the cron pull out 1 or 2 that haven't been pulled in a while. Have it run often, then you'll always have fresh data, but the script will have an easier time working as its not trying to do so much at once. This concept will scale well.
| 0 | 1,341 | true | 1 | 1 |
Alternatives to PHP Cron Job for Long Running Jobs
| 4,661,872 |
2 | 3 | 0 | 1 | 1 | 0 | 0.066568 | 0 |
We have a website that lists links to blogs in realtime. The problem is that the pages are slow to load because they are reading data from the various source sites.
I wrote a PHP script that creates an HTML version of each page. This runs once each hour. The problem is that the PHP script is timing out before it finishes all the pages. I know that I could increase the execute time allowed for PHP scripts, but this does not seem like the most efficient way to handle the issue.
Is there another way to do this? I just don't know what to begin looking for - PERL? JAVA? Python? How do these scripts run on a server? What should I look for from my web host?
| 0 |
php,python,cron,web-hosting
|
2011-01-11T18:45:00.000
| 0 | 4,661,377 |
Given the fact that your original problem is one of network latency ("pages are slow to load") I see no reason to believe that PHP is the bottleneck here. I doubt changing languages will affect your script run time.
| 0 | 1,341 | false | 1 | 1 |
Alternatives to PHP Cron Job for Long Running Jobs
| 4,661,510 |
2 | 3 | 0 | 1 | 1 | 0 | 0.066568 | 0 |
I have a Rails server which will need to run a python script at the background. I know that I can run it like I run terminal commands in ruby, but how is the performance like? is it better to use a python framework and not Rails? Is there better ways (optimization wise) to run python scripts on a Rails server?
| 0 |
python,ruby-on-rails,ruby
|
2011-01-12T00:42:00.000
| 0 | 4,664,325 |
You will incur the cost of starting python each time you run it from ruby. The cost would be the same in a python framework, unless you could use the python script as a library instead.
| 0 | 3,452 | false | 0 | 1 |
How to run a python script on a Rails server?
| 4,664,359 |
2 | 3 | 0 | 5 | 1 | 0 | 1.2 | 0 |
I have a Rails server which will need to run a python script at the background. I know that I can run it like I run terminal commands in ruby, but how is the performance like? is it better to use a python framework and not Rails? Is there better ways (optimization wise) to run python scripts on a Rails server?
| 0 |
python,ruby-on-rails,ruby
|
2011-01-12T00:42:00.000
| 0 | 4,664,325 |
If you mean that it needs to run periodically, just set it up as a cron job, no special performance characteristics to worry about there.
If you mean that it needs to run when pages are requested from your Ruby website, then simply running the script each time won't perform well as it needs to fire up the Python interpreter over and over again.
If the Python script is large but is only called from a relatively small number of page requests, you might be able to get away with this, sometimes it's not worth the time to optimise a slow operation that isn't called often.
If the bulk of your website is based around the functionality of the Python script, then yes, you are probably better off switching to a Python web framework and loading it as a module.
If the Python script isn't very big, then you are probably better off rewriting it in Ruby.
Worst case scenario is that the script is big and used often, but doesn't make up enough of your website to justify switching to Python. In that case, I'd consider wrapping the Python in a daemon that Ruby can talk to in the background.
| 0 | 3,452 | true | 0 | 1 |
How to run a python script on a Rails server?
| 4,664,387 |
1 | 4 | 0 | 0 | 4 | 1 | 0 | 0 |
each unit test I'm running is writing python code out to a file, then importing it as a module. The problem is that the code changes but further import statements don't modify the module.
I think what I need is a way to ether force a reload on a module or clear the internal bytecode cache. Any ideas?
Thanks!
| 0 |
python,cpython
|
2011-01-12T01:04:00.000
| 0 | 4,664,438 |
Ran into a similar situation.
Later on found that the white space indentation technique used matters.
Especially on windows platforms, ensure that a uniform technique is adapted
throughout the module i.e., either use tab or spaces exclusively.
| 0 | 12,520 | false | 0 | 1 |
Is there anyway to clear python bytecode cache?
| 42,154,981 |
1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
I used a python script to install boost (without bjam) but I cannot find it anymore. Does anybody know where it is located?
Thanks
| 0 |
c++,python,boost,build
|
2011-01-12T07:26:00.000
| 0 | 4,666,274 |
If on Windows, do a 'Find' (or download and use Agent Ransack). If on linux, grep for it. If it is on your local computer, one of these will find it.
| 0 | 100 | false | 0 | 1 |
python script for installing boost
| 4,671,114 |
1 | 5 | 0 | 1 | 2 | 1 | 0.039979 | 0 |
i recently wrote a method to cycle through /usr/share/dict/words and return a list of palindromes using my ispalindrome(x) method
here's some of the code...what's wrong with it? it just stalls for 10 minutes and then returns a list of all the words in the file
def reverse(a):
return a[::-1]
def ispalindrome(a):
b = reverse(a)
if b.lower() == a.lower():
return True
else:
return False
wl = open('/usr/share/dict/words', 'r')
wordlist = wl.readlines()
wl.close()
for x in wordlist:
if not ispalindrome(x):
wordlist.remove(x)
print wordlist
| 0 |
python,arrays,file,list,palindrome
|
2011-01-12T07:39:00.000
| 0 | 4,666,339 |
You're including the newline at the end of each word in /usr/share/dict/words. That means you never find any palindromes. You'll speed things up if you just log the palindromes as you find them, instead of deleting non-palindromes from the list, too.
| 0 | 3,147 | false | 0 | 1 |
python and palindromes
| 4,666,394 |
2 | 6 | 0 | 11 | 8 | 0 | 1.2 | 0 |
I am happily using fabric for my Python projects for deployment. Now I am engaged in a larger PHP project and wondering if there is something like fabric for PHP?
| 0 |
php,python,fabric
|
2011-01-12T07:49:00.000
| 0 | 4,666,392 |
Hmm? Why does it matter? Fabric is just python scripting. So it's project language agnostic. You can use it put anything on a server you'd use scp for, as well as script anything via ssh you'd use bash or [insert other tool here] for. Fabric really isn't Python's capistrano. It's more akin to a combining of both cap and rake, though I still think that's pigeonholing fabric's ability.
I do like the one stop recipe bits that cap and (from first look) weploy gives you for projects, as in fabric unless you're leveraging something like woven, you'll be rolling your own. But the customization ability of fabric is a plus to me, as I'm all over the place in my uses for it.
| 0 | 7,479 | true | 0 | 1 |
PHP alternative for Python's fabric
| 4,670,514 |
2 | 6 | 0 | 1 | 8 | 0 | 0.033321 | 0 |
I am happily using fabric for my Python projects for deployment. Now I am engaged in a larger PHP project and wondering if there is something like fabric for PHP?
| 0 |
php,python,fabric
|
2011-01-12T07:49:00.000
| 0 | 4,666,392 |
If you're looking for a build tool (as opposed to deployment), you can use Phing (http://phing.info/), a PHP equivalent of Java's Ant.
Doesn't handle the tunnelling (running remote commands etc.) but does do a nice job of breaking up your deployment into tasks with chained dependancies, and being PHP can interact with your PHP libraries easilly. You might find that some simple cap or fabfiles for the actual deployment, and could then call a Phing script to handle the post-deployment configuration.
| 0 | 7,479 | false | 0 | 1 |
PHP alternative for Python's fabric
| 4,697,683 |
1 | 2 | 0 | 0 | 1 | 1 | 0 | 1 |
How do I setup a server so I can get emails and parse them in python?
| 0 |
python
|
2011-01-12T18:48:00.000
| 0 | 4,672,697 |
There's a bunch of services on the web that will make it easier for you to send and receive e-mails using their API. This would relieve you from the pain of setting up, running and administrering your own e-mail service.
| 0 | 194 | false | 0 | 1 |
How to setup parsing emails?
| 12,867,404 |
2 | 5 | 0 | 0 | 19 | 0 | 0 | 0 |
I'm writing a CAD application that outputs PDF files using the Cairo graphics library. A lot of the unit testing does not require actually generating the PDF files, such as computing the expected bounding boxes of the objects. However, I want to make sure that the generated PDF files "look" correct after I change the code. Is there an automated way to do this? How can I automate as much as possible? Do I need to visually inspect each generated PDF? How can I solve this problem without pulling my hair out?
| 0 |
python,unit-testing,pdf-generation,imagemagick,cairo
|
2011-01-12T19:11:00.000
| 0 | 4,672,945 |
I would try this using xpresser - (https://wiki.ubuntu.com/Xpresser ) You can try to match images to similar images not exact copies - which is the problem in these cases.
I don't know if xpresser is being ctively developed, or if it can be used with stand alone image files (I think so) -- anyway it takes its ideas from teh Sikuli project (which is Java with a Jython front end, while xpresser is Python).
| 0 | 5,316 | false | 0 | 1 |
How to unit test a Python function that draws PDF graphics?
| 4,676,387 |
2 | 5 | 0 | 8 | 19 | 0 | 1.2 | 0 |
I'm writing a CAD application that outputs PDF files using the Cairo graphics library. A lot of the unit testing does not require actually generating the PDF files, such as computing the expected bounding boxes of the objects. However, I want to make sure that the generated PDF files "look" correct after I change the code. Is there an automated way to do this? How can I automate as much as possible? Do I need to visually inspect each generated PDF? How can I solve this problem without pulling my hair out?
| 0 |
python,unit-testing,pdf-generation,imagemagick,cairo
|
2011-01-12T19:11:00.000
| 0 | 4,672,945 |
You could capture the PDF as a bitmap (or at least a losslessly-compressed) image, and then compare the image generated by each test with a reference image of what it's supposed to look like. Any differences would be flagged as an error for the test.
| 0 | 5,316 | true | 0 | 1 |
How to unit test a Python function that draws PDF graphics?
| 4,673,001 |
4 | 4 | 0 | 0 | 1 | 0 | 0 | 0 |
I appreciate there are perhaps better ways of making a PHP application scale than the above, however I'm wondering more on principle. From what I've heard, Python is faster than PHP and I'm trying to decide which language to learn next, as a PHP developer.
| 0 |
php,python
|
2011-01-13T00:14:00.000
| 0 | 4,675,504 |
I cant comment on the difference in scalability of a website but i have had very positive experiences using frameworks such as django for small time websites. I really love the separation of code and templating (i know you can do this somehow with php too).
| 0 | 107 | false | 0 | 1 |
Would porting parts of a PHP application to Python help it scale?
| 4,677,419 |
4 | 4 | 0 | 3 | 1 | 0 | 1.2 | 0 |
I appreciate there are perhaps better ways of making a PHP application scale than the above, however I'm wondering more on principle. From what I've heard, Python is faster than PHP and I'm trying to decide which language to learn next, as a PHP developer.
| 0 |
php,python
|
2011-01-13T00:14:00.000
| 0 | 4,675,504 |
Python's a very good language to learn for a number of reasons, including its clear syntax, its excellent standard library, its multi-paradigm support, and the helpful community that surrounds it.
However, scalability has more to do with your system's overall architecture than with the programming language you choose. Often, the database is the main bottleneck, and the performance of the programming language that's talking to the database will not have much impact on overall site performance.
| 0 | 107 | true | 0 | 1 |
Would porting parts of a PHP application to Python help it scale?
| 4,675,567 |
4 | 4 | 0 | 2 | 1 | 0 | 0.099668 | 0 |
I appreciate there are perhaps better ways of making a PHP application scale than the above, however I'm wondering more on principle. From what I've heard, Python is faster than PHP and I'm trying to decide which language to learn next, as a PHP developer.
| 0 |
php,python
|
2011-01-13T00:14:00.000
| 0 | 4,675,504 |
I don't think rewriting in Python will help you that much, it is very hard to say anyway without knowing your exact scalability problem. When it comes to real scaling issues, every problem is unique and there is no one true solution.
That being said, Python is an interesting language, and if you've time on your hands and want to learn something, it sounds like a good idea to look at it closely. I would also look at JavaScript more closely though, be it using NodeJS (which is also pretty damn fast for some things) or just in a browser, it's a language that is not going away anytime soon. If you're a web developer, you can't know enough JS imo.
| 0 | 107 | false | 0 | 1 |
Would porting parts of a PHP application to Python help it scale?
| 4,675,551 |
4 | 4 | 0 | 0 | 1 | 0 | 0 | 0 |
I appreciate there are perhaps better ways of making a PHP application scale than the above, however I'm wondering more on principle. From what I've heard, Python is faster than PHP and I'm trying to decide which language to learn next, as a PHP developer.
| 0 |
php,python
|
2011-01-13T00:14:00.000
| 0 | 4,675,504 |
For web applications I would personally learn Python after PHP, but if your a Windows fan consider ASP.NET.
| 0 | 107 | false | 0 | 1 |
Would porting parts of a PHP application to Python help it scale?
| 4,675,549 |
1 | 13 | 0 | 0 | 395 | 0 | 0 | 0 |
How do I redirect stdout to an arbitrary file in Python?
When a long-running Python script (e.g, web application) is started from within the ssh session and backgounded, and the ssh session is closed, the application will raise IOError and fail the moment it tries to write to stdout. I needed to find a way to make the application and modules output to a file rather than stdout to prevent failure due to IOError. Currently, I employ nohup to redirect output to a file, and that gets the job done, but I was wondering if there was a way to do it without using nohup, out of curiosity.
I have already tried sys.stdout = open('somefile', 'w'), but this does not seem to prevent some external modules from still outputting to terminal (or maybe the sys.stdout = ... line did not fire at all). I know it should work from simpler scripts I've tested on, but I also didn't have time yet to test on a web application yet.
| 0 |
python,stdout
|
2011-01-13T00:51:00.000
| 1 | 4,675,728 |
I know this question is answered (using python abc.py > output.log 2>&1 ), but I still have to say:
When writing your program, don't write to stdout. Always use logging to output whatever you want. That would give you a lot of freedom in the future when you want to redirect, filter, rotate the output files.
| 0 | 655,144 | false | 0 | 1 |
Redirect stdout to a file in Python?
| 68,410,134 |
7 | 10 | 0 | 0 | 6 | 1 | 0 | 0 |
So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question. I was wondering if people change the use of get/set depending on different languages. I started learning with C++ and was taught to use getters and setters. This is what I understand:
In C++ (and Java?), a variable can either be public or private, but we cannot have a mix. For example, I can't have a read-only variable that can still be changed inside the class. It's either all public (can read and change it), or all private (can't read and can only change inside the class). Because of this (and possibly other reasons), we use getters and setters.
In MATLAB, I can control the "setaccess" and "getaccess" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it). In this case, I don't feel like I need a getter because I can just do class.property.
Also, in Python it is considered "Pythonic" to not use getters/setters and to only put things into properties if needed. I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.
I'm just curious what other people's thoughts are on this. Would you use getters and setters for all languages? Would you only use it for C++/Java and do direct access in MATLAB and Python (which is what I am currently doing)? Is the second option considered bad? For my purposes, I am only referring to simple getters and setters (just return/set the value and do not do anything else).
Thanks!
| 0 |
c++,python,matlab,setter,getter
|
2011-01-13T18:47:00.000
| 0 | 4,683,937 |
In Matlab, each additional function call incurs some overhead. So if you don't need a setter/getter, because some language feature allows you to do exactly the same, then I really cannot see why you wouldn't want to use the language feature.
| 0 | 2,133 | false | 0 | 1 |
The use of getters and setters for different programming languages
| 4,683,972 |
7 | 10 | 0 | 2 | 6 | 1 | 0.039979 | 0 |
So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question. I was wondering if people change the use of get/set depending on different languages. I started learning with C++ and was taught to use getters and setters. This is what I understand:
In C++ (and Java?), a variable can either be public or private, but we cannot have a mix. For example, I can't have a read-only variable that can still be changed inside the class. It's either all public (can read and change it), or all private (can't read and can only change inside the class). Because of this (and possibly other reasons), we use getters and setters.
In MATLAB, I can control the "setaccess" and "getaccess" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it). In this case, I don't feel like I need a getter because I can just do class.property.
Also, in Python it is considered "Pythonic" to not use getters/setters and to only put things into properties if needed. I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.
I'm just curious what other people's thoughts are on this. Would you use getters and setters for all languages? Would you only use it for C++/Java and do direct access in MATLAB and Python (which is what I am currently doing)? Is the second option considered bad? For my purposes, I am only referring to simple getters and setters (just return/set the value and do not do anything else).
Thanks!
| 0 |
c++,python,matlab,setter,getter
|
2011-01-13T18:47:00.000
| 0 | 4,683,937 |
Depends on how abstracted you need. For example, I recently needed a getter and setter in C++ when abstracting a Text object. The Direct3D text object just held a string Text member variable. The Direct2D Text object however had to be recreated and recached and that kind of thing. If I had opted for public variables when designing the original abstraction, I would have had to redesign the interface and change all the dependent code. While I agree that getters and setters over certain kinds of class are pointless, there are some cases in which they are necessary.
Of course, languages with properties don't need this kind of thing. But conceptually, they're the same. Defining a property over a variable is just a getter and setter with syntactic sugar, and while I support syntactic sugar, it doesn't change the encapsulation. I wouldn't change my encapsulation design on a language by language basis. Of course, the community opinion on whether or not encapsulation is a good thing is another matter- that's likely the difference that you're seeing. In C++ encapsulation is rated very highly, whereas the Python community cares for it less.
| 0 | 2,133 | false | 0 | 1 |
The use of getters and setters for different programming languages
| 4,684,067 |
7 | 10 | 0 | 2 | 6 | 1 | 0.039979 | 0 |
So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question. I was wondering if people change the use of get/set depending on different languages. I started learning with C++ and was taught to use getters and setters. This is what I understand:
In C++ (and Java?), a variable can either be public or private, but we cannot have a mix. For example, I can't have a read-only variable that can still be changed inside the class. It's either all public (can read and change it), or all private (can't read and can only change inside the class). Because of this (and possibly other reasons), we use getters and setters.
In MATLAB, I can control the "setaccess" and "getaccess" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it). In this case, I don't feel like I need a getter because I can just do class.property.
Also, in Python it is considered "Pythonic" to not use getters/setters and to only put things into properties if needed. I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.
I'm just curious what other people's thoughts are on this. Would you use getters and setters for all languages? Would you only use it for C++/Java and do direct access in MATLAB and Python (which is what I am currently doing)? Is the second option considered bad? For my purposes, I am only referring to simple getters and setters (just return/set the value and do not do anything else).
Thanks!
| 0 |
c++,python,matlab,setter,getter
|
2011-01-13T18:47:00.000
| 0 | 4,683,937 |
I don't generally use getters/setters because the presence of them indicates that my class isn't doing enough to be alive.
When I do consider needing them I always create them, no matter whether or not the language supports mixing access wrt variables. Only time I'd consider not doing so is in languages like VB that support "properties" where a function can look just like a variable access. The key reason here is that I don't want clients bound to the fact that the property is implemented by a variable.
| 0 | 2,133 | false | 0 | 1 |
The use of getters and setters for different programming languages
| 4,683,991 |
7 | 10 | 0 | 3 | 6 | 1 | 0.059928 | 0 |
So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question. I was wondering if people change the use of get/set depending on different languages. I started learning with C++ and was taught to use getters and setters. This is what I understand:
In C++ (and Java?), a variable can either be public or private, but we cannot have a mix. For example, I can't have a read-only variable that can still be changed inside the class. It's either all public (can read and change it), or all private (can't read and can only change inside the class). Because of this (and possibly other reasons), we use getters and setters.
In MATLAB, I can control the "setaccess" and "getaccess" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it). In this case, I don't feel like I need a getter because I can just do class.property.
Also, in Python it is considered "Pythonic" to not use getters/setters and to only put things into properties if needed. I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.
I'm just curious what other people's thoughts are on this. Would you use getters and setters for all languages? Would you only use it for C++/Java and do direct access in MATLAB and Python (which is what I am currently doing)? Is the second option considered bad? For my purposes, I am only referring to simple getters and setters (just return/set the value and do not do anything else).
Thanks!
| 0 |
c++,python,matlab,setter,getter
|
2011-01-13T18:47:00.000
| 0 | 4,683,937 |
It's OK to have all public variables in any language. Yes, I know it's the opposite of what you learned.
OO theory says that there should be a public API that is stable, and private variables, where you can do whatever you want, and an implementation you can change to your hearts delight without changing the API.
And this is correct. But what is not correct is the idea that the private API must be made inaccessible from other classes. This is simply a mistake in the OO theory. It is an idea that sounds reasonable on paper, but in practice has little to go for it, but causes plenty of problems.
For example, many years ago I needed to subclass a widget in Delphi to make it behave slightly differently. Not a lot you see, just a bit. But the code I needed to override called a method that was private, so I couldn't override it. Instead I needed to override both methods. And of course, that other method did things that was really internal, so I ended up basically not subclassing the widget, but duplicating it, just because I did one small change.
OO theory claims this is how it should be, because horror of horror, maybe otherwise my sublclass might stop work with the next version of Delphi, if the superclass changes something internal! Well, so what? In that case I would just fix it.
It's my problem if I use parts of your internal data. You don't need to care. What you need to do is somehow flag that "This bit is internal and might change, use on your own risk". But when you as a developer of a library actively prevents me from using internal bits, you are only causing me problems.
I've now developed almost exclusively with Python for soon to be ten years, and the openness of Python has never caused me problems, and it fact has saved my ass several times (as I can fix framework bugs by simply patching in fixed code at runtime). Delphis standard OO model with different levels of protection caused me problems several times during the two years I worked with it.
The OO Theory is in fact wrong. There is nothing useful in having private members. Everything should be public. And that goes for any language, in my experience.
| 0 | 2,133 | false | 0 | 1 |
The use of getters and setters for different programming languages
| 4,684,469 |
7 | 10 | 0 | 0 | 6 | 1 | 0 | 0 |
So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question. I was wondering if people change the use of get/set depending on different languages. I started learning with C++ and was taught to use getters and setters. This is what I understand:
In C++ (and Java?), a variable can either be public or private, but we cannot have a mix. For example, I can't have a read-only variable that can still be changed inside the class. It's either all public (can read and change it), or all private (can't read and can only change inside the class). Because of this (and possibly other reasons), we use getters and setters.
In MATLAB, I can control the "setaccess" and "getaccess" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it). In this case, I don't feel like I need a getter because I can just do class.property.
Also, in Python it is considered "Pythonic" to not use getters/setters and to only put things into properties if needed. I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.
I'm just curious what other people's thoughts are on this. Would you use getters and setters for all languages? Would you only use it for C++/Java and do direct access in MATLAB and Python (which is what I am currently doing)? Is the second option considered bad? For my purposes, I am only referring to simple getters and setters (just return/set the value and do not do anything else).
Thanks!
| 0 |
c++,python,matlab,setter,getter
|
2011-01-13T18:47:00.000
| 0 | 4,683,937 |
Python and C++ have different principles. C++ and Java are quite “static” and have lots of compile time checks, so you should exploit them when using C++ and Java: public vs. private, const-correctness, etc. Plus they don't have properties, so if you find that you should do some parameter validation, you cannot easily convert a public member variable into a getter–setter pair without changing syntax and breaking existing code. Python, on the other hand, is a dynamic language that allows everybody to do everything: you can override every variable from every module, encapsulation cannot be enforced, there are no static type checks, etc. Python people tend to say “we’re all adults,” and that you should not rely on undocumented behavior and use unit tests instead of compile-time checks. I’m not in the position to judge what is better, but generally you should stick to the established conventions of your language.
| 0 | 2,133 | false | 0 | 1 |
The use of getters and setters for different programming languages
| 4,684,420 |
7 | 10 | 0 | 0 | 6 | 1 | 0 | 0 |
So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question. I was wondering if people change the use of get/set depending on different languages. I started learning with C++ and was taught to use getters and setters. This is what I understand:
In C++ (and Java?), a variable can either be public or private, but we cannot have a mix. For example, I can't have a read-only variable that can still be changed inside the class. It's either all public (can read and change it), or all private (can't read and can only change inside the class). Because of this (and possibly other reasons), we use getters and setters.
In MATLAB, I can control the "setaccess" and "getaccess" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it). In this case, I don't feel like I need a getter because I can just do class.property.
Also, in Python it is considered "Pythonic" to not use getters/setters and to only put things into properties if needed. I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.
I'm just curious what other people's thoughts are on this. Would you use getters and setters for all languages? Would you only use it for C++/Java and do direct access in MATLAB and Python (which is what I am currently doing)? Is the second option considered bad? For my purposes, I am only referring to simple getters and setters (just return/set the value and do not do anything else).
Thanks!
| 0 |
c++,python,matlab,setter,getter
|
2011-01-13T18:47:00.000
| 0 | 4,683,937 |
Python, being a dynamic scripting language, is less about compile-time constraints, and more about flexibility.
Getters and setters ("property" is just getter + setter) allow for better encapsulation (checking validity, only getter, not setter; implementation details does not matter - e.g. time has hours, minutes, seconds, but how are data actually stored? who cares?), and future extensibility (e.g. code of setter might change, consumers don't care).
In modern efficient languages like C++, there is inlining, so there is no performance cost for simple getters/setters.
Point is, use public fields for structural and simple (small-scale) programming, use getters and setters for large-scale OOP projects.
| 0 | 2,133 | false | 0 | 1 |
The use of getters and setters for different programming languages
| 4,684,036 |
7 | 10 | 0 | 0 | 6 | 1 | 0 | 0 |
So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question. I was wondering if people change the use of get/set depending on different languages. I started learning with C++ and was taught to use getters and setters. This is what I understand:
In C++ (and Java?), a variable can either be public or private, but we cannot have a mix. For example, I can't have a read-only variable that can still be changed inside the class. It's either all public (can read and change it), or all private (can't read and can only change inside the class). Because of this (and possibly other reasons), we use getters and setters.
In MATLAB, I can control the "setaccess" and "getaccess" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it). In this case, I don't feel like I need a getter because I can just do class.property.
Also, in Python it is considered "Pythonic" to not use getters/setters and to only put things into properties if needed. I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.
I'm just curious what other people's thoughts are on this. Would you use getters and setters for all languages? Would you only use it for C++/Java and do direct access in MATLAB and Python (which is what I am currently doing)? Is the second option considered bad? For my purposes, I am only referring to simple getters and setters (just return/set the value and do not do anything else).
Thanks!
| 0 |
c++,python,matlab,setter,getter
|
2011-01-13T18:47:00.000
| 0 | 4,683,937 |
You're right - no need for "simple" getters and setters in modern Matlab OOP; the access modifiers that you mentioned are the "Right Way".
In the new MCOS Matlab classes, the syntax for accessing a class property is the same whether you define custom getter/setters or not. Clients can always access property foo as "obj.foo". If you decide to add the special "get.foo" and "set.foo" methods, they are implicitly called by Matlab when a client accesses that property using the "obj.foo" syntax. So it's not really "direct field access" like public fields in Java or C++. It's like Scala's "Uniform Access" model. (I think.) The "." syntax and declarative access controls you mention keep things simple and lets you transparently add custom logic when you need it, without committing to writing boilerplate code up front. The ubiquity of user-defined getters and setters in Java is partially because the language lacks these features.
In old-style Matlab classes, the inverse is true: all fields are private, so you must write your own getter/setters. The convention I've seen is to write a single method with the same name as the property that gets or sets depending on whether you call it as "foo(obj)" or "foo(obj, NewValue)".
| 0 | 2,133 | false | 0 | 1 |
The use of getters and setters for different programming languages
| 4,684,480 |
1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
I'm writing a program which is sending files through SMTP, thanks to my (local) Postfix server, on port 25.
Is it possible to use several threads (thus several sockets) to inject emails faster ?
| 0 |
python,sockets,smtp,smtplib
|
2011-01-13T21:44:00.000
| 0 | 4,685,634 |
Depends entirely on where the bottleneck is. If it's on the SMTP server or the network, the answer is no. If it's in your python code, probably yes.
| 0 | 305 | false | 0 | 1 |
Several threads connecting to a Postfix server?
| 4,685,735 |
1 | 4 | 0 | 7 | 0 | 1 | 1 | 0 |
Suppose I hashed a password and obtained a hashcode for it. I need to find the degree of similarity between the password and its hashcode. Please suggest me some different mechanism for this
| 0 |
python,cryptography
|
2011-01-14T09:04:00.000
| 0 | 4,689,456 |
This is impossible. That's the entire point of secure hash algorithms that are used, among other things, to hash passwords.
| 0 | 131 | false | 0 | 1 |
Anybody know a valid mechanism to detect the degree of similarity between a string and its hashcode?
| 4,689,577 |
1 | 2 | 0 | -1 | 8 | 0 | -0.099668 | 0 |
I normally code admin scripts in Python and I know of many that code them in Perl. I was about to invest some time on improving my skills on bash programming. But I wonder if people around think that this is a good idea ?
I know bash is a good skill to have and market very often demand it but ... if I can get by with Python or Perl then ... is it really worth the effort ?
As answers I am looking for cases where actually bash is way better than Perl or Python to develop admin scripts.
| 0 |
python,perl,bash,admin
|
2011-01-15T19:45:00.000
| 1 | 4,701,766 |
I'd say if this is only your machine and you're not supposed to share those administration scripts with any other one, so you'd better to keep doing that in Python (which seems you feel more comfortable on that).
But if you have colleagues or your admin scripts are supposed to employee by other people, so let keep it in a way that is more popular and more understandable for others also: Bash!
Also I guess if you know Bash, you can simply use dozens of existing Bash scripts by customizing them or improving them to whatever which is more suitable for you!
| 0 | 5,752 | false | 0 | 1 |
Python and/or Perl VS bash
| 13,985,089 |
2 | 2 | 0 | 0 | 1 | 0 | 1.2 | 0 |
I've got a situation where I'm contemplating using subversion/svn as the repository/version control system for a project. I'm trying to figure out if it's possible, (and if so, how) to be able to have the subversion system, on a post commit hook/process to to write the user/file/time (and maybe msg) to either an external file (csv) or to a mysql db.
Once I can figure out how to invoke the post commit hook to write the output to a file, I can then modify my issue tracker/project app to then implement a basic workflow process based on the user role, as well as the success/failure of the repository files.
Short sample/pointers would be helpful.
My test env, is running subversion/svnserve on centos5. The scripting languages in use are Php/Python.
| 1 |
php,python,svn,hook,svn-hooks
|
2011-01-15T20:14:00.000
| 0 | 4,701,902 |
I would say that's possible, but you are going to need a bit of work to retrieve the username, date and commit message.
Subversion invokes the post-commit hook with the repo path and the number of revision which was just committed as arguments.
In order to retrieve the information you're looking for, you will need to use an executable by the name of svnlook, which is bundled with Subversion.
See repo\hooks\post-commit.tmpl for a rather clear explanation about how to use it
Also, take a look at svnlook help, it's not difficult to use.
| 0 | 1,005 | true | 0 | 1 |
subversion post commit hooks
| 4,701,984 |
2 | 2 | 0 | 0 | 1 | 0 | 0 | 0 |
I've got a situation where I'm contemplating using subversion/svn as the repository/version control system for a project. I'm trying to figure out if it's possible, (and if so, how) to be able to have the subversion system, on a post commit hook/process to to write the user/file/time (and maybe msg) to either an external file (csv) or to a mysql db.
Once I can figure out how to invoke the post commit hook to write the output to a file, I can then modify my issue tracker/project app to then implement a basic workflow process based on the user role, as well as the success/failure of the repository files.
Short sample/pointers would be helpful.
My test env, is running subversion/svnserve on centos5. The scripting languages in use are Php/Python.
| 1 |
php,python,svn,hook,svn-hooks
|
2011-01-15T20:14:00.000
| 0 | 4,701,902 |
Indeed it is very possible, in your repository root there should be a folder named hooks, inside which should be a file named post-commit (if not, create one), add whatever bash code you put there and it will execute after every commit.
Note, there are 2 variables that are passed into the script $1 is the repository, and $2 is the revision number (i think), you can use those two variables to execute some svn commands/queries, and pull out the required data, and do with it whatever your heart desires.
| 0 | 1,005 | false | 0 | 1 |
subversion post commit hooks
| 4,701,973 |
1 | 3 | 0 | 3 | 2 | 1 | 1.2 | 0 |
I have a python script that outputs the program name, version number and the author when called with command line arguments like --help or --version. Currently this information is hardcoded in the python script itself. But I use distutils for building/packaging the application so all this information is already present in the setup.py. Is it possible to let distutils write metadata like version and author name/email to the built python script so I only need to maintain this data in the setup.py file? Or is there another standard mechanism to handle stuff like that?
| 0 |
python,distutils
|
2011-01-16T13:58:00.000
| 1 | 4,705,723 |
Do it the other way around. Add the version number, the author name and other metadata you need in the script to the script itself. Then import or execfile() the script in setup.py, and use the metadata defined in the script as arguments to the setup() function.
| 0 | 201 | true | 0 | 1 |
Replace symbols in python script on distribution
| 4,706,043 |
4 | 6 | 1 | 0 | 3 | 1 | 1.2 | 0 |
I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.
But I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)
or try Python / python framework.
I you are on my place which possibility you choose?
I am 17 years student, I have basic skills in C++ (OOP, little with STL), with Python I haven’t any experience.
What would be your choice and why?
| 0 |
c++,python,frameworks
|
2011-01-16T22:20:00.000
| 0 | 4,708,482 |
Personally I prefer Python, but profesionally, that is if you want a good job C++ is a better choice.
| 0 | 438 | true | 0 | 1 |
Start with some C++ framework or python
| 4,708,502 |
4 | 6 | 1 | 1 | 3 | 1 | 0.033321 | 0 |
I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.
But I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)
or try Python / python framework.
I you are on my place which possibility you choose?
I am 17 years student, I have basic skills in C++ (OOP, little with STL), with Python I haven’t any experience.
What would be your choice and why?
| 0 |
c++,python,frameworks
|
2011-01-16T22:20:00.000
| 0 | 4,708,482 |
I recommend you to keep learning C++. Before you started looking for framework learn some popular search algorithm and try implement them. After that try implement some structures, like queues, list, stack, binary trees and some operation on them. Meanwhile play with I/O (for example, try write your stack to file and read it back to stack - in plain text and binary).
It was my university tour on programming class. C++ is good choice because it is hard and multiparadigmats language so in future u will find much in common with other languages and you will be familiar with memory management system.
| 0 | 438 | false | 0 | 1 |
Start with some C++ framework or python
| 4,708,519 |
4 | 6 | 1 | 0 | 3 | 1 | 0 | 0 |
I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.
But I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)
or try Python / python framework.
I you are on my place which possibility you choose?
I am 17 years student, I have basic skills in C++ (OOP, little with STL), with Python I haven’t any experience.
What would be your choice and why?
| 0 |
c++,python,frameworks
|
2011-01-16T22:20:00.000
| 0 | 4,708,482 |
Well. Learning Python basics will take a week, and you will save the time spent in a year since it is such a good language for small hacks and scripts. So I suggest you learn it first.
Learning C++ well will take you five to ten years, so there is not the same immediate benefit :)
| 0 | 438 | false | 0 | 1 |
Start with some C++ framework or python
| 4,708,899 |
4 | 6 | 1 | 0 | 3 | 1 | 0 | 0 |
I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.
But I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)
or try Python / python framework.
I you are on my place which possibility you choose?
I am 17 years student, I have basic skills in C++ (OOP, little with STL), with Python I haven’t any experience.
What would be your choice and why?
| 0 |
c++,python,frameworks
|
2011-01-16T22:20:00.000
| 0 | 4,708,482 |
I'd pick C++ for the sole reason that it's nothing like the languages you already know, even though it shares some syntax.
| 0 | 438 | false | 0 | 1 |
Start with some C++ framework or python
| 4,708,606 |
2 | 6 | 0 | 1 | 4 | 0 | 0.033321 | 1 |
Is there a way to get python to read modules from a network?
We have many machines and it would be a too much effort to update each machine manually each time I change a module so I want python to get the modules from a location on the network.
Any ideas?
| 0 |
python,networking,module,import,centralized
|
2011-01-17T06:37:00.000
| 0 | 4,710,588 |
How I ended up doing this:
Control Panel\All Control Panel Items\System >> Advanced >> Environment Variables >> System Variables >> New >> Name = PYTHONPATH, value = \server\scriptFolder
Thanks everyone for all the help :)
| 0 | 10,613 | false | 0 | 1 |
Importing module from network
| 4,734,071 |
2 | 6 | 0 | 4 | 4 | 0 | 1.2 | 1 |
Is there a way to get python to read modules from a network?
We have many machines and it would be a too much effort to update each machine manually each time I change a module so I want python to get the modules from a location on the network.
Any ideas?
| 0 |
python,networking,module,import,centralized
|
2011-01-17T06:37:00.000
| 0 | 4,710,588 |
Mount your network location into your file-system and add that path to your PYTHONPATH. That way, Python on your local machine will be able to see the modules which are present in the remote location.
You cannot directly import from modules remotely, like specifying a js file in html.
| 0 | 10,613 | true | 0 | 1 |
Importing module from network
| 4,710,633 |
2 | 3 | 0 | 7 | 14 | 1 | 1 | 0 |
Are there any guidelines for writing test-friendly Python code?
What I believe:
One method does one thing.
Don't use side-effects.
Any other suggestions?
| 0 |
python,unit-testing
|
2011-01-17T06:43:00.000
| 0 | 4,710,621 |
Write methods that don't rely on other models or resources - if they need to access them, they should be passed in to the method.
| 0 | 3,938 | false | 0 | 1 |
Any tips on writing testing-friendly code?
| 4,710,652 |
2 | 3 | 0 | 6 | 14 | 1 | 1 | 0 |
Are there any guidelines for writing test-friendly Python code?
What I believe:
One method does one thing.
Don't use side-effects.
Any other suggestions?
| 0 |
python,unit-testing
|
2011-01-17T06:43:00.000
| 0 | 4,710,621 |
Alfred‘s answer is great, but I would add one thing for the questioner:
If you want to read a book, that is all about testing in Python using pytest, I suggest you to read „Python Testing with pytest: Simple, Rapid, Effective, and Scalable“ by Brian Okken. It’s perfect for what you want to do and it’s brand new (published September 2017).
| 0 | 3,938 | false | 0 | 1 |
Any tips on writing testing-friendly code?
| 50,113,761 |
1 | 3 | 0 | 2 | 5 | 0 | 0.132549 | 0 |
What is most similar PHP framework to Pylons?
I mean mostly ideology of programming.
| 0 |
php,python,comparison,pylons,web-frameworks
|
2011-01-17T18:49:00.000
| 0 | 4,716,689 |
Being primarily a Python developer, and having used Pylons, TurboGears, and Django, I would whole heartedly, 100% recommend Kohana 3.x. To be completely honest I am not a huge fan of PHP, even though it is the language of choice at my current employer. Given the choice I would use Python and Pylons. But, using Kohana is just about the best framework I could hope for from PHP. I hope I am not biases, considering I work with two developers on the Kohana development team. ;-)
PHP and Python are very different. As such, there is no real equivalent of Pylons in PHP. But, I would also say there is no real equivalent of Kohana in Python
| 0 | 755 | false | 0 | 1 |
PHP framework similar to Python Pylons
| 4,721,004 |
1 | 5 | 0 | 0 | 4 | 0 | 0 | 0 |
Is there any library to show progress when adding files to a tar archive in python or alternativly would be be possible to extend the functionality of the tarfile module to do this?
In an ideal world I would like to show the overall progress of the tar creation as well as an ETA as to when it will be complete.
Any help on this would be really appreciated.
| 0 |
python,progress-bar,tar
|
2011-01-17T22:23:00.000
| 1 | 4,718,588 |
How are you adding files to the tar file? Is is through "add" with recursive=True? You could build the list of files yourself and call "add" one-by-one, showing the progress as you go. If you're building from a stream/file then it looks like you could wrap that fileobj to see the read status and pass that into addfile.
It does not look like you will need to modify tarfile.py at all.
| 0 | 3,242 | false | 0 | 1 |
Python tarfile progress
| 4,718,870 |
1 | 1 | 0 | 5 | 3 | 1 | 1.2 | 0 |
Python's installation comes with some handy tools, located under
$YOUR_PYTHON/Tools/Scripts. Is there a platform-independent way to find out where on a system they are located? I want to use ftpmirror.py as part of a shell script.
| 0 |
python
|
2011-01-18T08:48:00.000
| 1 | 4,722,072 |
I see you are talking about the source bundle of Python, which includes Tools/Scripts, a set of helpful scripts for working with Python Source. It should be noted that they are not a part of Python Standard Library and installers are not obliged to bundle them with their distribution, for e.g in Ubuntu, I don't find it in /usr/lib/python2.6 or some other path.
If you want to rely on any of the Tools/Scripts, just carry them along with your script, that would be most portable.
| 0 | 1,415 | true | 0 | 1 |
Python: detecting install location of python tools
| 4,722,121 |
2 | 2 | 0 | 15 | 4 | 1 | 1.2 | 0 |
Am just being curious but I would like to know whether python can be implemented in assembly and if not why has it not been done to help for speed issues. forgive my naivete in matters of programming languages.
| 0 |
python
|
2011-01-18T17:57:00.000
| 0 | 4,727,351 |
The main implementation is written in C, and that's compiled to machine code (i.e. assembly made readable for the CPU). So writing it assembly is certainly possible, and if it's possible for a compiler, it's possible for humans - in theory. In practice, it is not even remotely practical. Not only asm is even more low-level than C (increasing development time significantly, perhaps even expotentially to the project size), it's also highly platform-specific, so each port takes a huge lot of work (and maintaince is multiplied by the number of supported platforms - quite a few in the case of CPython).
Apart from that, it's highly questionable if this would give a notable speed bonus. Writing it closer to the metal doesn't make stuff go faster magically (the contrary can be the case - you'd be hard-pressed to find a programmer who can consistently write better assembly than the four or five well-known C compilers). And much of Python's slowness comes from the many many abstractions and indirections the language consists of, not from a sloppy implementation of these.
A more promising approach (which is indeed followed by several alternative implementations) is a clever Just In Time-Compiler (JIT), which preserves all the dynamicness but exploits the fact that most Python programs make little use of that dynamicness by recognizing the most common paths at runtime and optimizing for these. Such complex programs are again not written in asm.
| 0 | 1,879 | true | 0 | 1 |
python implemented in assembly
| 4,727,418 |
2 | 2 | 0 | 6 | 4 | 1 | 1 | 0 |
Am just being curious but I would like to know whether python can be implemented in assembly and if not why has it not been done to help for speed issues. forgive my naivete in matters of programming languages.
| 0 |
python
|
2011-01-18T17:57:00.000
| 0 | 4,727,351 |
Native code isn't a magic make-it-go-faster operation. The language semantics really dictate quite a bit about how fast (or not) a language is. (For instance, erlang compiled to native code via Hipe is still fairly slow).
| 0 | 1,879 | false | 0 | 1 |
python implemented in assembly
| 4,727,381 |
2 | 5 | 0 | 3 | 2 | 0 | 0.119427 | 0 |
I want to schedule an email to be sent to a user upon a specific action.
However, if the user takes another action I want to cancel that email and have it not send.
How would I do that in django or python?
| 0 |
python,django,email,schedule
|
2011-01-19T03:16:00.000
| 0 | 4,731,419 |
I would set up a cron job which could handle everything you want to do...
| 0 | 5,173 | false | 1 | 1 |
How can I schedule an email to be sent at some point in the future in django?
| 4,731,583 |
2 | 5 | 0 | 0 | 2 | 0 | 0 | 0 |
I want to schedule an email to be sent to a user upon a specific action.
However, if the user takes another action I want to cancel that email and have it not send.
How would I do that in django or python?
| 0 |
python,django,email,schedule
|
2011-01-19T03:16:00.000
| 0 | 4,731,419 |
You said that you want to do it through Python or Django, but it seems as though something else will need to be involved. Considering you are on a shared host, there is a chance installing other packages could also be a problem.
Another possible solution could be something like this:
Use a javascript framework which can setup timed events, start/cancel them etc. I have done timed events using a framework called ExtJS. Although ExtJS is rather large im sure other frameworks such as jQuery or even raw javascript you could do a similar thing.
Set up a task on a user action, that will execute in 5 minutes. The action could be an ajax call to a python script which sends the email... If a user does something where the task needs to be stopped, just cancel the event.
It kind of seems complicated and convoluted, but it really isn't. If this seems like a path you would like to try out, let me know and I'll edit with some code
| 0 | 5,173 | false | 1 | 1 |
How can I schedule an email to be sent at some point in the future in django?
| 4,741,503 |
1 | 2 | 0 | 2 | 3 | 0 | 0.197375 | 1 |
I'm trying to create a very simple script that uses python's xmpppy to send a message over facebook chat.
import xmpp
FACEBOOK_ID = "[email protected]"
PASS = "password"
SERVER = "chat.facebook.com"
jid=xmpp.protocol.JID(FACEBOOK_ID)
C=xmpp.Client(jid.getDomain(),debug=[])
if not C.connect((SERVER,5222)):
raise IOError('Can not connect to server.')
if not C.auth(jid.getNode(),PASS):
raise IOError('Can not auth with server.')
C.send(xmpp.protocol.Message("[email protected]","Hello world",))
This code works to send a message via gchat, however when I try with facebook I recieve this error:
An error occurred while looking up _xmpp-client._tcp.chat.facebook.com
When I remove @chat.facebook.com from the FACEBOOK_ID I get this instead:
File "gtalktest.py", line 11, in
if not C.connect((SERVER,5222)):
File "/home/john/xmpppy-0.3.1/xmpp/client.py", line 195, in connect
if not CommonClient.connect(self,server,proxy,secure,use_srv) or secureNone and not secure: return self.connected
File "/home/john/xmpppy-0.3.1/xmpp/client.py", line 179, in connect
if not self.Process(1): return
File "/home/john/xmpppy-0.3.1/xmpp/dispatcher.py", line 302, in dispatch
handler['func'](session,stanza)
File "/home/john/xmpppy-0.3.1/xmpp/dispatcher.py", line 214, in streamErrorHandler
raise exc((name,text))
xmpp.protocol.HostUnknown: (u'host-unknown', '')
I also notice any time I import xmpp I get the following two messages when running:
/home/john/xmpppy-0.3.1/xmpp/auth.py:24: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
import sha,base64,random,dispatcher
/home/john/xmpppy-0.3.1/xmpp/auth.py:26: DeprecationWarning: the md5 module is deprecated; use hashlib instead
import md5
I'm fairly new to solving these kinds of problems, and advise, or links to resources that could help me move forward in solve these issues would be greatly appreciated. Thanks for reading!
| 0 |
python,facebook,chat,xmpppy
|
2011-01-19T06:03:00.000
| 1 | 4,732,230 |
I also started the same project, and was trapped into same problem. I found the solution too. You have to write the UserName of facebook (Hence You must opt one Username) and that too in small Caps. This is the most important part. Most probably you too like me would not be writing it in small Caps.
| 0 | 2,814 | false | 0 | 1 |
xmpppy and Facebook Chat Integration
| 5,268,496 |
1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 |
I'm looking for a public private key solution that I can use with a javascript client and python backend. The aim is to send data encrypted from the client to the server... Are the any solutions? Thanks for hints.
| 0 |
javascript,python,encryption,pgp
|
2011-01-19T16:17:00.000
| 0 | 4,737,721 |
Use SSL for your connections to the server. Probably the easiest way to do that is to use HTTP for communication and also to run a proxy (say, Apache) on the server that can do HTTPS and forwards requests to the actual server application.
| 0 | 401 | false | 1 | 1 |
public private key solution for javascript and python
| 4,738,545 |
1 | 5 | 0 | 2 | 6 | 1 | 0.07983 | 0 |
What is the meaning of <> in Python?
I have tried searching for it on Google but I cannot seem to get inside the search term...
I have not seen this in any other language also otherwise I would have tried to find it.
| 0 |
python
|
2011-01-19T17:05:00.000
| 0 | 4,738,285 |
It is the same as != ("not equal")
| 0 | 866 | false | 0 | 1 |
what does <> mean in Python
| 4,738,310 |
1 | 2 | 0 | 2 | 2 | 1 | 0.197375 | 0 |
Rather than triggering a flamewar on what DI framework is "best" (I don't think there's a definitive general solution), this question is meant to discuss good alternatives for projects of different kinds, no matter the programming language, based on professional experience.
Some issues I'd like to lean about:
What were the most important features you were looking for in a DI framework? Why was it what best fitted your project?
What does the DI framework have that others do not? What makes it special?
Why would you not pick the same DI framework for other different projects?
How did the DI framework improve the testability and configuration flexibility of the application (especially on different environments: development, staging, production, etc.)?
Many DI frameworks are said to be simple. But how easy is it to maintain the configuration of dependencies? (For example: Is it too verbose or difficult to read and modify?)
I may eventually accept one answer, but there is no "best answer" on this topic. I would appreciate anyone's experience that is useful to share.
I'm particularly interested in experience with DI frameworks in Python and PHP, where I think the choice isn't very straight-forward. The question is language-agnostic, though.
| 0 |
php,python,frameworks,dependency-injection
|
2011-01-19T18:10:00.000
| 0 | 4,738,980 |
I usually choose frameworks, whether DI or otherwise, using the following criteria:
Pick a framework that has the required functionality for the job at hand
Prefer frameworks that are simple - The less "extra" stuff not required for 1., the better.
Prefer frameworks "built-in" to the language/framework you're already using.
Prefer frameworks that I already know and have used
Usually, by working through the above, it's pretty obvious. For example, the last DI framework I choose was MEF, mainly because it was a C# project (point 3.), it's simple, and it did what I needed it to do.
| 0 | 367 | false | 0 | 1 |
Inversion of Control: Have you ever had to decide what Dependency Injection framework is best for a project? Which one did you pick and why?
| 4,739,047 |
4 | 5 | 0 | 2 | 9 | 1 | 0.07983 | 0 |
I've written C# and the mantra coming from on high seems to be "never use reflection in production code". I have used it for test code, but never anything that runs in the wild. All the arguments seem reasonable, and there's always a way to do it by adding another layer of abstraction or design pattern or whatever.
Now I'm starting to write some serious Python code, I wonder if the same principle applies. It seems that python is designed with reflection in mind. Modules and classes store members in an easily accessible dictionary. Django's models' Meta classes, for example take strings to reference members.
I could write C#/Java in Python but I really don't want to. I still firmly believe in 'no reflection' for said languages. Is the Python way just fundamentally different?
| 0 |
c#,java,python,reflection
|
2011-01-20T08:53:00.000
| 0 | 4,745,071 |
Yes, in that aspect, Python developement is fundametally different.
Reflection in C#/Java refers to the ability of the runtime to know things about the code it's running, and to take decisions based on that information.
Since Python uses dynamic typing, any type discovery is delegated to the runtime and not the compile time, so basically that means, that any Python program must use reflection in order to work, only it's not called reflecting, it's called running the program :)
In addition, the Python philosophy embraces the dynamic nature of execution, so you should not hesitate to use it to your advantage.
P.S. While one should avoid using reflection in tight loops, and one should be aware that reflection is one or two orders of magnitude slower, one should not be afraid to use it when it's the right tool for the job.
| 0 | 3,093 | false | 0 | 1 |
Never use reflection in production code! What about Python?
| 4,745,791 |
4 | 5 | 0 | 0 | 9 | 1 | 0 | 0 |
I've written C# and the mantra coming from on high seems to be "never use reflection in production code". I have used it for test code, but never anything that runs in the wild. All the arguments seem reasonable, and there's always a way to do it by adding another layer of abstraction or design pattern or whatever.
Now I'm starting to write some serious Python code, I wonder if the same principle applies. It seems that python is designed with reflection in mind. Modules and classes store members in an easily accessible dictionary. Django's models' Meta classes, for example take strings to reference members.
I could write C#/Java in Python but I really don't want to. I still firmly believe in 'no reflection' for said languages. Is the Python way just fundamentally different?
| 0 |
c#,java,python,reflection
|
2011-01-20T08:53:00.000
| 0 | 4,745,071 |
IMO the reason for me about avoiding using reflection in production code is the fact than reflection could make code really harder to maintain and debug.
| 0 | 3,093 | false | 0 | 1 |
Never use reflection in production code! What about Python?
| 4,745,191 |
4 | 5 | 0 | 6 | 9 | 1 | 1 | 0 |
I've written C# and the mantra coming from on high seems to be "never use reflection in production code". I have used it for test code, but never anything that runs in the wild. All the arguments seem reasonable, and there's always a way to do it by adding another layer of abstraction or design pattern or whatever.
Now I'm starting to write some serious Python code, I wonder if the same principle applies. It seems that python is designed with reflection in mind. Modules and classes store members in an easily accessible dictionary. Django's models' Meta classes, for example take strings to reference members.
I could write C#/Java in Python but I really don't want to. I still firmly believe in 'no reflection' for said languages. Is the Python way just fundamentally different?
| 0 |
c#,java,python,reflection
|
2011-01-20T08:53:00.000
| 0 | 4,745,071 |
I think that the "no reflection in production code" is not correct in c#.
Reflection often allows the programmer to do things otherwise impossible.
I would say "no reflection for non-public members in production code" and "use reflection with care!" if not used correctly, you could lose performance. Used correctly could make you gain performance (just think about static reflection)
Don't use reflection for massivly called code.
Python instead is a dynamic language. All concepts are different. The normality (and the correct way to do it) is using the techinques you are talking about.
| 0 | 3,093 | false | 0 | 1 |
Never use reflection in production code! What about Python?
| 4,745,134 |
4 | 5 | 0 | 18 | 9 | 1 | 1.2 | 0 |
I've written C# and the mantra coming from on high seems to be "never use reflection in production code". I have used it for test code, but never anything that runs in the wild. All the arguments seem reasonable, and there's always a way to do it by adding another layer of abstraction or design pattern or whatever.
Now I'm starting to write some serious Python code, I wonder if the same principle applies. It seems that python is designed with reflection in mind. Modules and classes store members in an easily accessible dictionary. Django's models' Meta classes, for example take strings to reference members.
I could write C#/Java in Python but I really don't want to. I still firmly believe in 'no reflection' for said languages. Is the Python way just fundamentally different?
| 0 |
c#,java,python,reflection
|
2011-01-20T08:53:00.000
| 0 | 4,745,071 |
As a dynamic language Python is fundamentally different than statically typed languages, so everything is reflection in it :-) Also never use reflection in production code (for static languages) seems a bit extreme to me.
| 0 | 3,093 | true | 0 | 1 |
Never use reflection in production code! What about Python?
| 4,745,093 |
1 | 1 | 0 | 3 | 2 | 0 | 0.53705 | 0 |
We have several programs generating excel documents via com automation, some written in VB6, some in python. Regardless of the programming language those programs run 5 times slower than with older excel versions. Profiling the python version shows that the additional run time is spent mostly in low level com functionality (built-in methods Bind and Invoke), so every single com call is slowed down.
Any tips, how we can speed this up, maybe a (security?) setting in excel 2010?
Thanks,
Thomas
| 0 |
python,performance,excel,com,automation
|
2011-01-20T10:44:00.000
| 0 | 4,746,115 |
I cannot answer for Python, but for VBA/VB6 a significant number of changes were made in XL 2010 to improve performance rather than make it slower, see:http://blogs.office.com/b/microsoft-excel/archive/2009/09/03/performance-improvements-in-excel-2010.aspx Could you give a VB example of something that is 5 times slower in 2010?
| 0 | 692 | false | 0 | 1 |
Automation of excel 2010 5 times slower than before
| 4,746,776 |
1 | 4 | 0 | 0 | 5 | 0 | 0 | 0 |
I'm trying to write some scripts in Python and stumbled upon the need of making something to update the password of a given user in a Linux system...
UPDATE: the objective is to achieve the script to update the password automatically from a given data/algorithm. The important thing is to have no human intervention...
is there a way to achieve that? or should I search through other means?
Thanks!
| 0 |
python,linux,authentication
|
2011-01-20T15:33:00.000
| 0 | 4,749,083 |
Use subprocess to invoke passwd.
| 0 | 9,738 | false | 0 | 1 |
is there a way to script in Python to change user passwords in Linux? if so, how?
| 4,749,108 |
1 | 2 | 0 | 2 | 7 | 0 | 0.197375 | 0 |
I have bigs files to move to a lot of servers. For now we use rsync, but I would like to experiment with bittorent.
I'm studing the code of Deluge, a Python bittorent client but it uses twisted and is utterly complex. Do you know anything hight level?
EDIT: I just read that Facebook does code deployment using Bittorent. Maybe they published their lib for that, but I can't find it. Ever hear of it?
| 0 |
python,bittorrent
|
2011-01-20T17:27:00.000
| 1 | 4,750,432 |
The original BitTorrent client is written in Python. Have you checked that out?
| 0 | 891 | false | 0 | 1 |
Do you know Python libs to send / receive files using Bittorent?
| 4,750,449 |
2 | 4 | 0 | 1 | 2 | 1 | 0.049958 | 0 |
I receive some data as a string. I need to write the data to a file, but the problem is that sometimes the data is compressed/zipped and sometimes it's just plain text. I need to determine the content-type so I know whether to write it to a .txt file or a .tgz file. Any ideas on how to accomplish this? Can I use mime type somehow even though my data is a string, not a file?
Thanks.
| 0 |
python,string,content-type
|
2011-01-20T20:52:00.000
| 0 | 4,752,451 |
If the file is downloaded from a webserver, you should have a content-type to look at, however you are at the mercy of the webserver whether or not it truly describes the type of the file.
Another alternative would be to use a heuristic to guess the file type. This can often be done by looking at the first few bytes of the file
| 0 | 2,383 | false | 0 | 1 |
How to determine content type of a string
| 4,752,526 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.