Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
16,782,047
2013-05-28T00:04:00.000
0
0
1
0
python
16,782,089
7
false
0
1
You can't. In Windows, custom icons can only be assigned to certain types of files (executables and shortcuts, mostly), and Python scripts are not one of those types.
2
7
0
I am developing a game in Python and was wondering how to give it its own icon. I am using a windows computer and have no extra things installed with Python. Oh also I am using version 3.3 Is this even possible. P.S I have found other things on Stack Overflow but they are using different Operating Systems like Ubuntu and Macintosh
How To Add An Icon Of My Own To A Python Program
0
0
0
40,170
16,782,047
2013-05-28T00:04:00.000
2
0
1
0
python
16,782,121
7
false
0
1
If you are trying to change the icon of the shortcut for your program, then you need to get to the file where ever it is right-click it and go to create a shortcut then drag that shortcut to your desktop then right-click that shortcut and click properties then click on "Change Icon" then go to where your desire .ico image is saved and set that as the icon if you do this and you open your program in the corner will be the .ico you selected and on your desktop, it will show the icon instead of the python image. that is how you change the shortcut icon but there is no way to change the actual window icon in the corner unless you're using something like Tk or Pygame.
2
7
0
I am developing a game in Python and was wondering how to give it its own icon. I am using a windows computer and have no extra things installed with Python. Oh also I am using version 3.3 Is this even possible. P.S I have found other things on Stack Overflow but they are using different Operating Systems like Ubuntu and Macintosh
How To Add An Icon Of My Own To A Python Program
0.057081
0
0
40,170
16,782,531
2013-05-28T01:24:00.000
0
0
1
0
python,ssh,paramiko
17,585,357
1
true
0
0
What I ended up doing here is use queues to ferry out the STDOUT/STDERR and ferry in STDIN to this thread class. Worked wonderfully as expected.
1
0
0
Trying to implement a generic class which will do remote command execution using Paramiko. Faced with this question. The init() method of the class which is inheriting threading.Thread will do the connect to the host and the run() method will do the command execution on the remote host. Now the command which is getting executed is a daemon. That daemon will be ready to accept inputs on the stdin and will be spewing out messages on the stdout and stderr. How should we handle this stderr, stdout reading while putting stuff on stdin ? I was thinking of using 3 more threads to do regular checking on the stream handles and handling the I/O to the remote daemon in that way. Thoughts ?
Python - Threads inside Thread - kosher?
1.2
0
0
808
16,784,271
2013-05-28T05:09:00.000
1
0
0
0
python,orm,module,openerp
16,789,456
1
true
1
0
there is a model called 'ir.sequence'. You can create a sequence type and sequence for your model and then just by calling the code of the sequence you will be able to generate new sequences
1
0
0
I need a field which adds a counter to a specific item i add in the product section of a custom module. Like an automatic number generated by the system, for let's say Internal Reference, so every time i save a new product this field will create a number for it in this field, like IN0001, IN0002, IN0003, etc... I've looked into the internet, searching for some example on how to achieve this in OpenErp but no luck. Is there any module or already made function in OpenErp which has this behavior? Thanks in advance
Counter in OpenErp - Python
1.2
0
0
171
16,786,183
2013-05-28T07:27:00.000
3
0
1
1
python,python-bindings
16,788,200
1
true
0
0
I can hardly imagine a case where one would prefer wrapping a library's command line interface over wrapping the library itself. (Unless there is a library that comes with a neat command line interface while being a total mess internally; but the OP indicates that the same functionality available via the command line is easily accessible in terms of library function calls). The biggest advantage of writing a Python binding is a clearly defined data interface between the library and Python. Ideally, the library can operate directly on memory managed by Python, without any data copying involved. To illustrate this, let's assume a library function does something more complicated than printing the current time, i.e., it obtains a significant amount of data as an input, performs some operation, and returns a significant amount of data as an output. If the input data is expected as an input file, Python would need to generate this file first. It must make sure that the OS has finished writing the file before calling the library via the command line (I have seen several C libraries where sleep(1) calls were used as a band-aid for this issue...). And Python must get the output back in some way. If the command line interface does not rely on files but obtains all arguments on the command line and prints the output on stdout, Python probably needs to convert between binary data and string format, not always with the expected results. It also needs to pipe stdout back and parse it. Not a problem, but getting all this right is a lot of work. What about error handling? Well, the command line interface will probably handle errors by printing error messages on stderr. So Python needs to capture, parse and process these as well. OTOH, the corresponding library function will almost certainly make a success flag accessible to the calling program. This is much more directly usable for Python. All of this is obviously affecting performance, which you already mentioned. As another point, if you are developing the library yourself, you will probably find after some time that the Python workflow has made the whole command line interface obsolete, so you can drop supporting it altogether and save yourself a lot of time. So I think there is a clear case to be made for the Python bindings. To me, one of the biggest strengths of Python is the ease with which such wrappers can be created and maintained. Unfortunately, there are about 7 or 8 equally easy ways to do this. To get started, I recommend ctypes, since it does not require a compiler and will work with PyPy. For best performance use the native C-Python API, which I also found very easy to learn.
1
3
0
I have a question regarding python bindings. I have a command-line which exposes some functionality and code is re-factored to provide the functionality through a shared library. I wanted to know what the real advantage that I get from "writing a python binding for the shared library" vs "calling the command line directly". One obvious advantage I think will be performance, the shared library will link to the same process and the functionality can called within the same process. It will avoid spawning a new process through the command line. Any other advantages I can get from writing a python binding for such a case ? Thanks.
"writing a python binding" vs "using command-line directly"
1.2
0
0
619
16,794,333
2013-05-28T14:13:00.000
1
0
0
0
python,pygame,sprite,rect
16,797,483
1
true
0
1
Unless you manually clear your screen surface, flip will not change its content. Thus, if you neglect to draw to a certain location, it will remain the same. If you want to get rid of this effect, usually called "hall of mirrors", you will have to keep track of what portions of the screen have not been drawn to yet and draw over these yourself. It may be easier to define background sprites around your map's contours and block your camera from going off too far. Since you use a "dirty/clean" approach to only redrawing what's changed, you won't have the option to just fill the whole screen surface before you draw your frame, because that would draw over anything that's stayed the same since the last frame.
1
0
0
I made a 2D project with a lot of tile sprites, and one player sprite. I'm trying to get the camera to follow the player, and for the most part it's working. However, there's one problem: If you go to the edge of the map, it scrolls normally, but instead of the black background, it displays copies of the sprites on the edge of the map instead of the background (black). It has the same problem if I leave some squares empty, when I move it displays a copy of the tile that was previously there. The camera works like this: Select sprites that should be visible Do sprite.visible = 1 for them, and sprite.visible = 0 for all other sprites Set the position sprite.rect of all sprites to coords - offset Update the screen (I use flip(), because the camera moves every turn, so the whole screen has to be updated every turn) All DirtySprites have dirty = 2. Does anyone know why it's displaying copies of the sprites on the edge instead of the background? Help would be appreciated!
(pygame) Empty squares displaying copies of what was previously there instead of background
1.2
0
0
86
16,794,658
2013-05-28T14:29:00.000
0
1
0
0
python,bluetooth,hidden,device
16,795,191
2
false
0
0
You could attempt to connect to your phone. If it's nearby, the connection will succeed. Devices can be connectable when they are not discoverable. You would have to already know the device address of your phone (via discovery when your phone was visible) in order to initiate the connection.
1
1
0
Im trying to make a algorithm in python to detect if my phone is in the area. Im using this to find my device: bluetooth.discover_devices() But it only detects my phone if I set my Bluetooth on my phone to "visible". Is there a function or command to detect my phone when it's set to hidden? Im fairly new to python so any form of help is very welcome! Thanks in advance!
How to find bluetooth devices not set to visible in python?
0
0
0
1,954
16,794,850
2013-05-28T14:38:00.000
1
0
0
0
python,security,networking,windows-7,wifi
16,797,510
1
true
0
0
No. Python standard library doesn't ship with any functionality to control platform-specific functionality like wireless adapters. You have to invoke the tools shipped with the platform, find some 3rd party libraries that control this functionality, or write your own such libraries.
1
0
0
My question I guess is: Is this possible without shelling out to command line and without 3rd party Python packages? I can't seem to find any native Python commands to manipulate or configure a wireless network connection. I know there are already built-in 'netsh wlan' commands in Windows 7, but would rather this all be in python. I am also confused by the logistics of this operation. With the netsh stuff, you still are required to have a wireless profile xml file specified in the command. My current image doesn't have any wireless profiles and I do not really understand the purpose of that if you are connecting to a brand new network. Why is this not automatically generated when you connect? A little bit about the network Network type: Infrastructure Authentication: WPA2-Enterprise Encryption: CCMP The ultimate goal is to have a script that my users can just launch, put in their credentials, and never see the multiple Windows dialogues while doing so. I'm not asking for someone to write this for me. That's what I'm suppose to do. I just need to know if anyone has successfully done something like this in strictly Python or point me in the right direction. Thanks!
Simple Python program to connect to a secure wifi network with user input credentials
1.2
0
1
1,246
16,795,018
2013-05-28T14:46:00.000
2
0
0
0
python,django,django-models,security
16,795,862
4
false
1
0
Storing passwords using a reversible encryption is about as safe as plain text. Use OAuth or something similar, or prepare for serious troubles when (not "if" - "when") someone will hack your database.
1
1
0
I have to store some sensitive information in my database using Django. I have a Client model and each client has a bunch of SocialAccounts (twitter, fb, etc) with an URL, client and password. Considering ALL users that belong to the group "Administrator" should be able to see the passwords. What's a safe way to store those passwords in the database?
How to store sensitive information that needs to be shared across different users?
0.099668
0
0
2,061
16,799,088
2013-05-28T18:37:00.000
1
1
1
0
python,django,file,checksum
16,799,533
4
false
0
0
md5 tends to work great for checksums ... same with SHA-1 ... both have very small probability of collisions although I think SHA-1 has slightly smaller collision probability since it uses more bits if you are really worried about it, you could use both checksums (one md5 and one sha1) the chance that both match and the files differ is infinitesimally small (still not 100% impossible but very very very unlikely) ... (this seems like bad form and by far the slowest solution) typically (read: in every instance I have ever encountered) an MD5 OR an SHA1 match is sufficient to assume uniqueness there is no way to 100% guarantee uniqueness short of byte by byte comparisson
1
4
0
I am creating an application related to files. And I was looking for ways to compute checksums for files. I want to know what's the best hashing method to calculate checksums of files md5 or SHA-1 or something else based on this criterias The checksum should be unique. I know its theoretical but still I want the probablity of collisions to be very very small. Can compare two files to be equal if there checksums are equal or not. Speed(not very important, but still) Please feel free to as elaborative as possible.
File Checksums in Python
0.049958
0
0
2,494
16,802,879
2013-05-28T23:00:00.000
0
0
1
0
pypy,rpython
16,895,246
1
false
0
0
There are a lot of possible answers to this question. One answer is that yes, you can try, but it's not really interesting. Yes, you can play with a different front-end that feeds into the same toolchain; but then you're only changing the syntax, and that's it. Let's take the example of writing "RuRu" in "RRuby" rather than in RPython. If you only change the front-end of PyPy, the RRuby language you get is mostly just RPython with a different syntax. The toolchain will still assume that RRuby handles the same kinds of objects, like strings, lists, tuples, dicts, all with a Python-ish behavior. That's probably not what you want from a real RRuby. You want instead some subset of Ruby, with a Ruby-ish behavior. Supporting that into PyPy is much more work.
1
2
0
What would be the steps involved in updating the PyPy toolchain, to allow one to substitute RPython with any well-defined statically-typed language (e.g "RRuby", "RJavaScript", or any subsets of Haskell or ML or C that map to RPython's functionality)? Would it be possible to define an AST generator for each of those languages and feed that AST into the toolchain? Or is RPython completely baked into the toolchain? I was thinking something like this would redefine the PyPy project, at least the first goal of creating "A set of tools for implementing interpreters for interpreted languages". It would completely decouple Python from that aspect of the project. So one could write e.g. "RuRu" instead of just a "PyPy-based Ruby implementation".
Making PyPy toolchain input-language-independent
0
0
0
110
16,803,144
2013-05-28T23:26:00.000
5
0
1
0
python,python-2.7,dictionary
16,803,155
2
true
0
0
Yes, dictionaries are not special and can be imported into other modules, just like anything else you define in a Python module. Like functions and classes, dictionaries are Python objects, and importing does nothing but create a new reference in the current module to values you imported. You can manipulate the dictionary from anywhere; dictionaries are mutable structures, once you have a reference to it you can alter the keys and values of that dictionary.
1
3
0
Can dictionaries be accessed by multiple files in Python 2.7? One can import classes and functions from other files, but can the same be done with dictionaries? I might have a file with a dictionary and an assortment of functions that can be used by other files to do things with the dictionary, but is it necessary to write a function for every single thing I might want to do? I would like to be able to do basic things, like printing part of the dictionary, from another file. Essentially, what I want to know is: Does importing a file also import a dictionary within the file and if not, how can I? If this is possible, I would also like to know if the original dictionary can be edited from another file. As well as printing part of it, could I then change a value in the original dictionary? I have been unable to find anything about this on the internet. Please educate me, stackoverflow.
Accessing and editing a dictionary from multiple files
1.2
0
0
5,750
16,803,826
2013-05-29T00:55:00.000
0
0
0
0
android,python,eclipse,pygame,pydev
16,803,982
1
false
0
1
No, there's really no way of doing this. Pygame is not natively runnable on Android: you'd need to somehow find a Pygame port to Jython and then figure out how to make that work using the Android drawing primitives. Probably more work than it is worth.
1
0
0
I am working on a project in eclipse, i have been working for the last few months in python/pygame, making pygames in the Python IDLE. I have my eclipse build setup with android sdk and pydev to run python programs (pygame) in eclipse. What I am trying to do is build an app with the android sdk that can use my pygame inside the app (put game built in pygame on android app through android sdk) that way the main menu would be coded in java with buttons, etc, then when you click the play button it goes to the pygame code. Is there anyway of doing this, you can make individual projects of the 2, and make an android app, but I want to integrate both languages features for the best performance. How am I going to do this???? I have looked on the web and I can't find anybody talking about doing this, it may be impossible, maybe not. Is it possible for this to be done for an app in eclipse????
How do you integrate PyGame and Android SDK together inside Eclipse to build an Android App running Java SDK as the main menu for PyGame?
0
0
0
418
16,804,806
2013-05-29T03:04:00.000
3
0
1
0
python,windows-xp,cx-freeze
16,848,122
1
true
0
1
Thank you eveyone for your help. I finally get it working with a different solution. I found other programs in my system that has this dlls too. Eclipese was one of them (in this path: eclipse\plugins\com.intland.hgbinary.win32_2.3.2\os\win32 )so I just took: Microsoft.VC90.CRT.manifest msvcm90.dll msvcp90.dll msvcr90.dll this files and copy and paste them to the folder of my compiled python code. And it works like magic. Thank you anyway for your help!! :D
1
6
0
I have used cx_freeze several times in my windows 7 and I had never any problem with it but now I want to run the executable produced by cx_freeze in a Windows XP. But when I run the program I get this error: the application configuration is incorrect. Reinstalling this application may fix this problem I have searched for info about this problem and it seems to be the that the Microsoft Visual Studio 2008 redistributable is not intstalled. I am going to launch this executable in many computers so I don't want to install absolutelly nothing in the system. I have read that I can just place those 4 files in the same folder than my binary is: Those 3 from this directory C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_d08d0375 msvcm90.dll msvcp90.dll msvcr90.dll And this file from this directory C:\WINDOWS\WinSxS\Manifests x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_d08d0375.manifest I have search this direcories in my system (Win 8) and they are not with this exactly folder. Anyway I downloaded them from internet and try it but it did not work I have Python 2.7 and cx_Freeze-4.3.1 I have read that if I use a lower version of pyython it could works. It is true? Why? Do you know hoy can I solve it without installing anything in the system? Thank you very much for your help.
Python Cx_Freeze error in Windows XP
1.2
0
0
1,636
16,808,328
2013-05-29T07:54:00.000
1
0
0
0
python,d3.js,web2py
16,812,347
1
true
1
0
No, there should not be any compatibility issues. web2py is primarily a server-side framework, and D3 is all client-side. They are completely independent. web2py does provide some client-side scaffolding, but it is optional and won't interfere with D3 anyway.
1
1
0
I'm a relatively unexperienced developer starting on a new project to expose some pre-existing Python analytical libraries' functions in a web application through javascript visualization library d3.js. I've explored the web2py framework for Python, and would just like to ask a simple question: Are there any compatibility issues I should be aware of between web2py and d3.js? Thanks a lot!
web2py and d3.js compatibility
1.2
0
0
358
16,811,683
2013-05-29T10:38:00.000
2
0
1
0
python,logging
16,811,734
3
false
0
0
This is not possible through the logger. If you want this, you'll have to write your own custom logger, read all the entries in the log file, add the new entry to the top, then write the entire log file again.
3
1
0
I'm using the Python logging module. Each time I open the log file I have to scroll all the way down to read the latest entries. Is there a way I can make the logger prepend entries to the beginning of file?
Prepend entry to log file
0.132549
0
0
802
16,811,683
2013-05-29T10:38:00.000
0
0
1
0
python,logging
16,816,812
3
false
0
0
Prepending data to the head of a log file would be quite resource intensive because you'd have to write out the entire file every time. Instead of 'scrolling' at all, why not just use 'tail -f ' to seek to the end and begin reading? On Linux you can use tail -F , which will re-open the logfile if it gets removed/recreated on the fly. Alternatively, you could create a new log file for every time you start the program using a timestamp. Or, you could log to stderr and run your program interactively. Or you could log to syslog.
3
1
0
I'm using the Python logging module. Each time I open the log file I have to scroll all the way down to read the latest entries. Is there a way I can make the logger prepend entries to the beginning of file?
Prepend entry to log file
0
0
0
802
16,811,683
2013-05-29T10:38:00.000
1
0
1
0
python,logging
16,816,940
3
false
0
0
I concur with others: prepending to a file is costly, and making your code more complex than it should be. If you view your log using tools such as more or less, then press the capital G key will bring you all the way to the end.
3
1
0
I'm using the Python logging module. Each time I open the log file I have to scroll all the way down to read the latest entries. Is there a way I can make the logger prepend entries to the beginning of file?
Prepend entry to log file
0.066568
0
0
802
16,813,243
2013-05-29T11:57:00.000
2
1
0
0
java,c++,python,machine-learning,artificial-intelligence
16,813,957
2
false
0
0
Quake 3 is an ideal candidate for bot design. open source code base. Realistic scenario (compared to robocode which is a toy domain). existing bots and I believe the first bots used in Quake 3 where the output of a Ph.D. lots of documentation.
1
0
0
I'm looking for a game which will allow me to test various artificial intelligence, reinforcement learning and machine learning algorithms. It would be great, if there will be good documentation or even helpful framework for writing AI. I know about TORCS, but do you know other games? It doesn't matter in which language it is written. It can be any arcade game, simulator, FPS, etc.
Game which allows to test AI algorithms
0.197375
0
0
520
16,814,703
2013-05-29T13:04:00.000
0
0
1
0
python,regex
16,814,785
3
false
0
0
group1 will be at least one number and group0 will contain group1 and maybe other characters but not necessarily. edit to answer the edited question: AFAIK there should be no difference in the matching between those 2 other than the grouping.
1
0
0
Is the meaning of this regex: (\d+).*? - group a set of numbers, then take whatever that comes after (only one occurance of it at maximum, except a newline)? Is there a difference in: (\d+) and [\d]+?
Meaning of regex Python
0
0
0
91
16,816,914
2013-05-29T14:40:00.000
-1
0
0
0
python,windows,cairo,pango
68,884,724
2
false
0
0
For Mac you can use Brew to install Pango: brew install pango
2
5
0
Since ReportLab does not support Python 3 I am now attempting to generate PDF with cairo, which works but lacks text-wrapping support. The next step seems to require pango and its Python-bindings, but I cannot find any information on how to install this for Windows.
How to install pango for Python on Windows?
-0.099668
0
0
5,509
16,816,914
2013-05-29T14:40:00.000
0
0
0
0
python,windows,cairo,pango
51,411,884
2
false
0
0
You can use Anaconda's conda package manager. But, what i found from the personal experiment that the pango works with python3 and cairo works with python2. and You my friend is stuck in middle.
2
5
0
Since ReportLab does not support Python 3 I am now attempting to generate PDF with cairo, which works but lacks text-wrapping support. The next step seems to require pango and its Python-bindings, but I cannot find any information on how to install this for Windows.
How to install pango for Python on Windows?
0
0
0
5,509
16,816,929
2013-05-29T14:41:00.000
2
0
1
0
python,twisted,scrapy,importerror
16,818,251
1
false
1
0
Verify that you have zope.interface 4.0.5 installed on the same version of Python as you are using to run scrapy. Most likely you have more than one version of Python installed and scrapy is using a different version than you expect.
1
3
0
When I try to run Scrapy I get an ImportError stating that Twisted requires zope.interface 3.6.0 or later. The version of zope.interface I have is 4.0.5, so I'm perplexed by this error. I've read other suggestions recommending installing zope.interface via pip, but that did not work. I'd like some help figuring out how Twisted or Scrapy is getting the zope.interface version number, or if there's a work-around that I can employ to get this to work?
Scrapy ImportError
0.379949
0
0
907
16,817,623
2013-05-29T15:10:00.000
1
1
1
0
python
16,817,965
1
false
0
0
This is just my opinion, but I would probably use a combination of virtualenvs and Makefiles/scripts in this case. I haven't done it for your specific use case, but I often set up multiple virtualenvs for a project, each with a different python version. Then I can use Makefiles to run my code or tests in one or all of my virtualenvs. Seems like it wouldn't be too hard to set up a makefile that would let you type make devel to run in the development envionment, and make production for the production environment. Alternatively, you could use git branches to do this. Keep your production scripts on master, and use feature branches to isolate and test changes while still having your production scripts just a git checkout master away.
1
2
0
I'm using Python with a Cygwin environment to develop data processing scripts and Python packages I'd like to actively use the scripts while also updating the packages on which those scripts depend. My question is what is the best practice, recommendation for managing the module loading path to isolate and test my development changes but not affect the working of a production script. Python imports modules in the following order (see M. Lutz, Learning Python) Home directory. PYTHONPATH directories. Standard library directories. The contents of any *.pth file. My current solution is to install my packages in a local (not in /usr/lib/python2.x/ ) site-packages directory and add a *.pth file in the global site-packages directory so these are loaded by default. In the development directory I then simply modify PYTHONPATH to load the packages I'm actively working on with local changes. Is there a more standard way of handling this situation? Setting up a virtualenv or some other way of manipulating the module load path?
Separate Python paths for development and production
0.197375
0
0
170
16,817,777
2013-05-29T15:17:00.000
0
1
0
0
java,android,python,bluetooth,playstation
16,818,550
2
false
1
0
Im pretty sure you need an emulator for this. Correct me if Im wrong.
1
1
0
i am trying to find if it is possible to send a message over Bluetooth to consoles like playstation 3 to make it turn on or off? since it is possible to be done from controllers. I been reading around about it. but was wondering if there is any information or exapmles that could help. as all i could find was python code which i am not really a pro in. Any information will be much appreciated.
Android to Playstation and other consoles
0
0
0
150
16,820,895
2013-05-29T18:03:00.000
1
0
1
1
python,pyparsing
16,822,978
1
false
0
0
Try Suppress("\r\n") instead of Suppress(LineEnd())
1
1
0
I have a simple pyparsing construct for extracting parts of a log message. It looks like this log_line = timestamp + task_info + Suppress(LineEnd()) This construct parses a log file generated in Linux very well but doesn't parse a similar file generated in windows. I am pretty sure it is because of the new line representation difference. I was wondering if LineEnd() takes care of that? If it doesn't how do I take care of it?
pyparsing not working on windows text file but works on linux text file
0.197375
0
0
147
16,820,903
2013-05-29T18:04:00.000
1
0
1
0
python,matplotlib,python-3.3
16,823,062
2
true
0
0
I suspect you need to install python3-matplotlib, python3-numpy, etc. python-matlab is the python2 version.
1
1
1
Today I upgraded to Xubuntu 13.04 which comes with Python 3.3. Before that, I was working with Pyton 3.2, which was working perfectly fine. When running my script under Python 3.3, I get an ImportError: No module named 'pylab' in import pylab. Running in Python 3.2, which I reinstalled, throws ImportError: cannot import name multiarray in import numpy. Scipy, numpy and matplotlib are, recording to apt, on the newest version. I don't have much knowledge about this stuff. Do you have any recommendations on how to get my script to work again, preferably on Python 3.2? Thanks in advance, Katrin Edit: We solved the problem: Apparently, there where a lot of fragments / pieces of the packages in different paths, as I installed from apt, pip as well as manually. After deleting all packages and installing them only via pip, everything works fine. Thank you very much for the help!
Pylab after upgrading
1.2
0
0
312
16,822,338
2013-05-29T19:31:00.000
2
0
1
0
python,select,boolean,pygame,midi
16,822,525
2
true
0
1
When developing games you usually do everything in a main loop. If you want e.g. 50 fps, then you want to go through this loop 50x per second. If you assume that you are not doing anything time consuming, then you can sleep for 20ms at the end of every iteration. So I think that's the reason why only poll is available, you are supposed to check whether the midi is loaded in your loop. If it is, then you can do something with it, otherwise you would continue rendering or doing something else. Generally while creating games and apps that should have consistent fps, you don't want to wait for some event.
2
0
0
i need to use select() on a bool because the module pygame.midi lets you know when a midi message is ready only through the function Input.poll() that returns a bool. if i check this value in the simple way, i do busy waiting and my cpu works at 100% all the time. is there a way to use the select() or similar functions to wait for a variable to change its value in a context without automatic event raising? (i don't strictly need to live eventless, indeed i would love to use them, but i can't see midi events anywhere in the package..)
python - select() on boolean variable
1.2
0
0
364
16,822,338
2013-05-29T19:31:00.000
0
0
1
0
python,select,boolean,pygame,midi
16,822,580
2
false
0
1
If your input doesn't have any way to fire events, you have to check it on a timer. In most games, your main event loop already has some "frame limiter" code, so the event loop runs no more than 50 times/sec. So, you can just poll once per event loop. If not, you'll essentially have to add a frame limiter now. If your game for some reason doesn't fit this paradigm—or if you need to poll the input much more often than your max frame rate—you have to write a background thread that reads from the input (blocking if possible, polling and sleeping if not) and either handles the events directly, or pushes then onto a queue that the main thread can read from each time through the loop.
2
0
0
i need to use select() on a bool because the module pygame.midi lets you know when a midi message is ready only through the function Input.poll() that returns a bool. if i check this value in the simple way, i do busy waiting and my cpu works at 100% all the time. is there a way to use the select() or similar functions to wait for a variable to change its value in a context without automatic event raising? (i don't strictly need to live eventless, indeed i would love to use them, but i can't see midi events anywhere in the package..)
python - select() on boolean variable
0
0
0
364
16,823,109
2013-05-29T20:21:00.000
2
0
1
1
python,file,unix,file-io,operating-system
17,035,837
1
true
0
0
It is almost certainly not python's fault. If python closes the file, OR exits cleanly (rather than killed by a signal), then the OS will have the new contents for the file. Any subsequent open should return the new contents. There must be something more complicated going on. Here are some thoughts. What you describe sounds more likely to be a filesystem bug than a Python bug, and a filesystem bug is pretty unlikely. Filesystem bugs are far more likely if your files actually reside in a remote filesystem. Do they? Do all the processes use the same file? Do "ls -li" on the file to see its inode number, and see if it ever changes. In your scenario, it should not. Is it possible that something is moving files, or moving directories, or deleting directories and recreating them? Are there symlinks involved? Are you sure that there is no overlap in the running of your programs? Are any of them run from a shell with "&" at the end (i.e. in the background)? That could easily mean that a second one is started before the first one is finished. Are there any other programs writing to the same file? This isn't your question, but if you need atomic changes (so that any program running in parallel only sees either the old version or the new one, never the empty file), the way to achieve it is to write the new content to another file (e.g. "foo.tmp"), then do os.rename("foo.tmp", "foo"). Rename is atomic.
1
4
0
I have a library that interacts with a configuration file. When the library is imported, the initialization code reads the configuration file, possibly updates it, and then writes the updated contents back to the file (even if nothing was changed). Very occasionally, I encounter a problem where the contents of the configuration file simply disappear. Specifically, this happens when I run many invocations of a short script (using the library), back-to-back, thousands of times. It never occurs during the same directories, which leads me to believe it's a somewhat random problem--specifically a race condition with IO. This is a pain to debug, since I can never reliably reproduce the problem and it only happens on some systems. I have a suspicion about what might happen, but I wanted to see if my picture of file I/O in Python is correct. So the question is, when does a Python program actually write file contents to a disk? I thought that the contents would make it to disk by the time that the file closed, but then I can't explain this error. When python closes a file, does it flush the contents to the disk itself, or simply queue it up to the filesystem? Is it possible that file contents can be written to disk after Python terminates? And can I avoid this issue by using fp.flush(); os.fsync(fp.fileno()) (where fp is the file handle)? If it matters, I'm programming on a Unix system (Mac OS X, specifically). Edit: Also, keep in mind that the processes are not running concurrently. Appendix: Here is the specific race condition that I suspect: Process #1 is invoked. Process #1 opens the configuration file in read mode and closes it when finished. Process #1 opens the configuration file in write mode, erasing all of its contents. The erasing of the contents is synced to the disk. Process #1 writes the new contents to the file handle and closes it. Process #1: Upon closing the file, Python tells the OS to queue writing these contents to disk. Process #1 closes and exits Process #2 is invoked Process #2 opens the configuration file in read mode, but new contents aren't synced yet. Process #2 sees an empty file. The OS finally finishes writing the contents to disk, after process 2 reads the file Process #2, thinking the file is empty, sets defaults for the configuration file. Process #2 writes its version of the configuration file to disk, overwriting the last version.
When does Python write a file to disk?
1.2
0
0
1,521
16,824,419
2013-05-29T21:46:00.000
2
0
0
1
python,beautifulsoup,ipython
16,824,528
3
false
0
0
Just install virtualenv once, then work on local environments. It's a good practice too.
1
0
0
I don't have admin privileges on my work computer (OSX) and do some light Python scripting (mostly web scraping). I don't have admin privileges at work and don't really want to learn OSX but I also don't want to lug my Ubuntu laptop around everyday just to write scrapers. Is there a straightforward way for me to install modules without admin privileges? It seems like I need sudo to run easy_install. I can ask to have things installed, but I'd rather not have to ask every time I want to see if a module does what I need. FWIW, right now I just need BeautifulSoup and csv
How do I install Python modules on OSX if I don't have admin privs?
0.132549
0
0
709
16,824,942
2013-05-29T22:26:00.000
0
1
1
1
python,eclipse,pydev,jython
18,384,815
1
false
0
0
The version that PyDev uses internally is Jython 2.1, so, you can't add newer libraries to that version unless they're compatible... If you need to use a different version, you'd need to first update the version used inside PyDev itself (it wasn't updated so far because the current Jython size is too big -- PyDev has currently 7.5 MB and just the newer Jython jar is 10 MB -- with libs it goes to almost 16 MB, so making PyDev have 22 MB just for this upgrade is something I'm trying to avoid... now, I think there's probably too much bloat there in Jython, so, if that can be removed, it's something that may be worth revisiting...).
1
2
0
PyDev has its own jython interpreter, inside pydev.jython.VERSION that jython has its own python libraries i.e. pydev.jython.VERSION/LIB/zipfile.py Now if I write a jython script for pydev-jython-scripting, it will load only its internal Lib pydev.jython.VERSION/LIB/ How do I have this pydev-jython recognize PYTHONPATH, I tried appending to sys.path but there is some python version problem some invalid syntax My system python installation has all the .py source, my pydev interpreter configuration has python interpreter setup and NOT jython and NOT ironpython pydev-jython script does not recognize many of regular system python modules, why?
pydev eclipse, jython scripting , syspath
0
0
0
205
16,825,742
2013-05-29T23:47:00.000
0
0
0
0
wxpython
16,826,193
1
false
0
1
It's probably due to circular imports. One file is not yet fully imported when it imports another, which then imports the first one again. Since it was already started the original module object is returned, but it hasn't yet defined the class you are looking for.
1
0
0
So, I am actually trying to restart a frame. I have my frame defined in my mainF.py file, and my panels defined as classes in a panels.py file. I call these two methods when my clear button is pressed: self.frame.Destroy() main() where main() is my method for jumpstarting my frame object. In my mainF file, I am using this statement from panels import * and in my panels file, I have tried import mainF and from panels import * However, I always receive NameError: Panel1 is not defined. This is confusing me since I do define it in my import statements, and the programs executes main() the first time through without this error. When I had all classes defined in one file, I never received this error. Any help would be appreciated, thanks.
wxpython global name not defined error
0
0
0
173
16,826,233
2013-05-30T00:51:00.000
5
0
0
0
python,css,debugging,sass,webassets
16,826,275
2
false
1
0
Figured it out. Webassets does not pick up on changes to scss files that are included in other scss files using @import. The only solution is to always make a change to the including scss file if you make a change to the included one.
1
3
0
I'm using the pyscss compiler in the python webassets library with webassets debug configs all set to true. But when I make changes to an scss file and reload the page that includes the generated css file, I see that the css file has not be regenerated and does not include my changes. Why is this happening?
Why won't python webassets pyscss regenerate css from scss files in debug mode?
0.462117
0
0
850
16,826,304
2013-05-30T00:59:00.000
1
0
0
0
python,robotframework
16,847,883
1
false
1
0
The Execute Javascript extension isn't a part of RobotFramework, it's something added by the Selenium integration, it would therefore follow that you can't use Selenium to execute a .py file. That said, RobotFramework is written in Python and can obviously be extended with a Python script. Can you clear up what you're actually trying to achieve here though? My concern is that if you're using a .py file in your test state to validate your code, isn't that introducing an uncertainty that means that what you're testing is not the same as the code that gets executed when you release your project? A bit more detail would help a lot here!
1
1
0
Has anyone found a method for executing their .py files from the Robot Framework like you can for JS? RobotFramework: Executes the given JavaScript code. code may contain multiple statements and the return value of last statement is returned by this keyword. code may be divided into multiple cells in the test data. In that case, the parts are catenated together without adding spaces. If code is an absolute path to an existing file, the JavaScript to execute will be read from that file. Forward slashes work as a path separator on all operating systems. The functionality to read the code from a file was added in SeleniumLibrary 2.5. Note that, by default, the code will be executed in the context of the Selenium object itself, so this will refer to the Selenium object. Use window to refer to the window of your application, e.g. window.document.getElementById('foo'). Example: Execute JavaScript window.my_js_function('arg1', 'arg2') Execute JavaScript ${CURDIR}/js_to_execute.js It's bs that I can't run my .py files this way...
Can Not execute Python .py file using RobotFramework like Javascript
0.197375
0
1
635
16,829,049
2013-05-30T06:05:00.000
1
0
0
0
python,tkinter
16,834,234
1
true
0
1
You will want to use the text widget. To color certain words or characters you will need to define a tag, and apply that tag to a range of text.
1
0
0
I would like to display a file having Unicode data (Malayalam) in a window with a scrolled area, with all the named entities in different colours in tkinter (PYTHON). For example, consider the sentence - 'Python is a programming language.' In my window, Python should be in a different colour. My file contains more than 100 lines. So I need the display in a scrolled area and text in it having different colours. Thanks in advance for your help.
How to display unicode data in a file with named entities in different colours in a popup window with scrolled area in tkinter?
1.2
0
0
65
16,831,701
2013-05-30T08:50:00.000
1
1
1
0
python,doctest
16,831,858
2
false
0
0
Your doctest could use module StringIO to provide a file object from a string.
1
4
0
my function reads from a file, and a doctest needs to be written in a way independent of an absolute path. What's the best way of wrting a doctest? Writing a temp file is expensive and not failproof.
How to write a doctest for a function that reads from a file?
0.099668
0
0
1,135
16,833,285
2013-05-30T10:05:00.000
0
0
1
0
python,python-2.7,printing,syntax-highlighting,python-idle
64,529,376
6
false
0
0
I do this all the time with large amounts of code. Just install SciTE "https://www.scintilla.org/SciTEDownload.html" Copy and paste your code and print. I like to grab some tape and markers stick all the sheets on a wall and put some music on. Happy coding!
3
9
0
I have searched for an answer to this but the related solutions seem to concern 'print'ing in the interpreter. I am wondering if it is possible to print (physically on paper) python code in color from IDLE? I have gone to: File > Print Window in IDLE and it seems to just print out a black and white version without prompting whether to print in color etc. Edit: It seems like this might not be available so the option is to copy code to a text editor like SciTE and print from there - quite like the default IDLE syntax highlighting though.
How to physically print python code in color from IDLE?
0
0
0
23,412
16,833,285
2013-05-30T10:05:00.000
2
0
1
0
python,python-2.7,printing,syntax-highlighting,python-idle
26,572,656
6
false
0
0
Use the IDLE extension called IDLE2HTML.py (search for this). This lets IDLE print to an HTML file that has color in its style sheet. Then save the HTML file to a PDF (the color will still be there).
3
9
0
I have searched for an answer to this but the related solutions seem to concern 'print'ing in the interpreter. I am wondering if it is possible to print (physically on paper) python code in color from IDLE? I have gone to: File > Print Window in IDLE and it seems to just print out a black and white version without prompting whether to print in color etc. Edit: It seems like this might not be available so the option is to copy code to a text editor like SciTE and print from there - quite like the default IDLE syntax highlighting though.
How to physically print python code in color from IDLE?
0.066568
0
0
23,412
16,833,285
2013-05-30T10:05:00.000
0
0
1
0
python,python-2.7,printing,syntax-highlighting,python-idle
58,010,122
6
false
0
0
I had the same problem and opened the py file into Visual Studio Code, then simply copied (Ctrl A / Ctrl C) and pasted the text (Ctrl V) into a Microsoft editor such as Word or RTF, or even outlook. The colors stay, including when printing. Note that in order to avoid the night mode set as a default in VS Code, go to File->Preferences->Color Theme and choose a day mode which is more suitable for printing.
3
9
0
I have searched for an answer to this but the related solutions seem to concern 'print'ing in the interpreter. I am wondering if it is possible to print (physically on paper) python code in color from IDLE? I have gone to: File > Print Window in IDLE and it seems to just print out a black and white version without prompting whether to print in color etc. Edit: It seems like this might not be available so the option is to copy code to a text editor like SciTE and print from there - quite like the default IDLE syntax highlighting though.
How to physically print python code in color from IDLE?
0
0
0
23,412
16,837,715
2013-05-30T13:35:00.000
0
0
1
0
python,function,binary
16,837,739
1
false
0
0
Yes. Read the source code of the library.
1
0
0
I am trying to modify a program. I see function calls that go into a file called myProgLib.so Its a binary file but I want to know what happens in these functions that are being called, is there a way to do this? I need to understand them before I can modify them to my needs Thank you
.so files in python
0
0
0
595
16,838,198
2013-05-30T13:58:00.000
0
0
0
0
python,xml,soap,httpresponse,minidom
16,850,655
1
true
0
0
Ok the solution was just to cast it to a string using str(response)
1
0
0
Is there a way to parse a SOAP Response (similar to XML) in Python? I have browsed through most of Stackoverflow solutions and they usually use minidom or ET functions parse() or parseString(). parse() takes a filename as input, while parseString() takes a string as input. However SOAP response type is HTTPResponse and hence I am always getting type mismatch error while using parse() or parseString(), so not sure how to parse the SOAP response in Python. I have also tried converting the HTTPResponse to string (failed), or using XML function (failed), or using response.read() function (failed). I have checked that the SOAP response is correct with valid XML. I am using SUDS to call the SOAP service.
Parse SOAP Response in Python
1.2
0
1
1,989
16,838,457
2013-05-30T14:09:00.000
6
0
1
0
python,dictionary,python-3.x,encryption
16,838,485
1
true
0
0
Encode the dict as a string with e.g. json, and then encrypt the resultant string.
1
4
0
I have a dictionary, myDict = {1:'a',2:'b',3:'c'}, that I'd like to encrypt and write to an external raw text file. I've already downloaded and installed PyCrypto since a lot of other threads seem to recommend it, but it's too confusing for me to grasp its terminology and syntax. Could someone explain how I'd go about doing this in Layman's terms?
How do I encrypt/decrypt a dictionary in Python 3.3?
1.2
0
0
4,783
16,838,499
2013-05-30T14:11:00.000
1
0
1
0
python,windows-7
16,839,021
2
false
0
0
Well as Tim Peters explained it's because of the whitespace/null space or embedded space in the path. If ever you've used an older windows version and tried cd'in to a path such as documents and settings you'd get an error saying 'documents' not recognized blah blah.. that's because it thinks documents is a directory, and is a directory, and files is a directory because of the blank spaces in it's path name. I found enclosing it in " " quotation marks bound it as a single string rather than three separate strings. Same rules applied to Python when errors occurred trying to access the path, so the simplest solution was to put it's path in an area where there are no null spaces, such as C:\Python, and not C:\Program Files\Python. Yet again as stated above, those Windows tools mentioned are all in paths without white spaces such as C:\Windows or C:\Windows\system32. Just helps not to have space when setting the path in the global path variable because it's less error prone when utilities in the path specified are utilized. -k0r8i05
1
9
0
Apologies for a likely stupid question, but no amount of Googling or searching here for my query could get me anywhere. Just having issues with root installations lead me to wonder WHY Python 2.7 is naturally set up in the root directory of Windows, when everything else is in ProgramFiles? Is there a simple answer for this I'm missing?
Why is Python 2.7 installed at root, unlike most programs today?
0.099668
0
0
186
16,840,711
2013-05-30T15:55:00.000
1
0
1
0
python,image,pygame
16,841,217
2
false
0
1
I believe you need to load the image as a Surface before you can get its width and height. You do that with foo = pygame.image.load(PATHNAME). Then you can get the width and height by creating a Rectangle with foo.get_rect() and asking the rectangle.
1
1
0
If I'm using an image and I want to know the image's size in the file. There is a function to get the picture's height and width ? EDIT: Of course I loaded the image to the program with pygame.image.load(PATH).
How to get the picture size in pygame (python)
0.099668
0
0
3,476
16,846,264
2013-05-30T21:36:00.000
2
0
1
1
python
16,846,327
2
false
0
0
Not with os.startfile(), no; it provides no way of communicating with the launched process. You could use the subprocess module, though; this will allow you to send data to and receive data from the launched process through standard in/out. Or, since the thing you want to call is another Python script, simply import the other file and call its functions directly, or use execfile().
1
6
0
I'm wondering if it is possible to run another file: os.startfile('File.py') and have that file return a value to the file that called the other file. For example, you have File1. Is it possible for File1 to call and run File2 and have File2 return a value to File1?
Is it possible to return a value from one Python file to another?
0.197375
0
0
1,474
16,846,391
2013-05-30T21:45:00.000
3
0
0
0
python,django,web-applications
16,846,436
4
false
1
0
For this to be meaningful, you likely need to connect to the same database Why would you need two codebases? You have two copies of a single codebase.
3
2
0
I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website. So far I see my only option is as follows... Copy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad! So, how do other handle this? What options do I have? Can my models be shared somehow?
Does a Django site with a Tastypie interface need two codebases?
0.148885
0
0
134
16,846,391
2013-05-30T21:45:00.000
1
0
0
0
python,django,web-applications
16,846,450
4
false
1
0
Why don't you run the api on the same server on a different port? that will save you a lot of problems to start with. Sharing database connections cross servers will likely require you to think about security, a lot. Also if you are reusing the same apps in different projects you might want to package and version your apps for comfort. Think about the real problem you are trying to solve and always keep that in mind. There are plenty of solutions for every problem, finding the right one makes a difference.
3
2
0
I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website. So far I see my only option is as follows... Copy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad! So, how do other handle this? What options do I have? Can my models be shared somehow?
Does a Django site with a Tastypie interface need two codebases?
0.049958
0
0
134
16,846,391
2013-05-30T21:45:00.000
2
0
0
0
python,django,web-applications
16,855,093
4
true
1
0
I wouldn't recommend splitting your project like this. Every time you edit a model you have to edit it on both immediately or risk things getting out of sync. This will get very very painful, instead; Is the server the bottleneck? Split site and api machines (but using the same models.py) and share the connection to the DB somewhere. Is the DB the bottleneck? Scale up the DB to a faster machine / cluster and use the same site for to supply web and api. Either way, One codebase, One set of models, One DB!
3
2
0
I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website. So far I see my only option is as follows... Copy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad! So, how do other handle this? What options do I have? Can my models be shared somehow?
Does a Django site with a Tastypie interface need two codebases?
1.2
0
0
134
16,846,967
2013-05-30T22:37:00.000
1
0
0
0
android,python,sockets,tcp
16,847,185
2
false
0
1
Well, you could have the Android Application save the image to a folder and have the Python file import that image.
2
1
0
I have an Android application that captures an image and Python code that extracts some features from images. I want to connect them to each other (receive the image in Python from the Android application). I read some things about building a TCP Server, but I don't know how to do it and how to start as it's my first time to do something like that. Can anyone help?
Connect Android to Python
0.099668
0
0
653
16,846,967
2013-05-30T22:37:00.000
-1
0
0
0
android,python,sockets,tcp
36,057,987
2
false
0
1
You can upload a image to server using any of the database, use python code on server side and you will get the result.
2
1
0
I have an Android application that captures an image and Python code that extracts some features from images. I want to connect them to each other (receive the image in Python from the Android application). I read some things about building a TCP Server, but I don't know how to do it and how to start as it's my first time to do something like that. Can anyone help?
Connect Android to Python
-0.099668
0
0
653
16,847,597
2013-05-30T23:40:00.000
1
0
1
0
python,python-2.7,random
16,847,624
4
false
0
0
1) Calculate how many elements you want to remove, call it k. 2) random.randrange(len(listA)) will return a random number between 0 and len(listA)-1 inclusive, e.g. a random index you can use in listA. 3) Grab the element at that index, remove it from listA, append it to listB. 4) Repeat until you have removed k elements.
1
1
0
I am new to python and programming, so apologies in advance. I know of remove(), append(), len(), and rand.rang (or whatever it is), and I believe I would need those tools, but it's not clear to me how to code it. What I would like to do is, while looping or otherwise accessing List_A, randomly select an index within List_A, remove the selected_index from List_A, and then append() the selected_index to List_B. I would like to randomly remove only up to a certain percentage (or real number if this is impossible) of items from List A. Any ideas?? Is what I'm describing possible?
Is it possible to randomly *remove* a percentage/number of items from a list & then *append* them to another list?
0.049958
0
0
2,089
16,848,912
2013-05-31T02:34:00.000
1
0
0
0
python,windows,qt,gtk,pyqt
16,854,156
2
false
0
1
I prefer PyQt, there is some examples in the pyqt release directory, you can try it out. I think the effect is really cool. I haven't tried other library so i could not compare PyQt with others . As I am familiar with Qt, the coding experience is very easy if you switch Qt to PyQt.
1
1
0
In your opinion, what is the best way to create gui in Windows with python ? Do you recommend PyQt for windows?
Your best library for create GUI with Python (PyQt, PyGTK, wxPython, IronPython, etc)
0.099668
0
0
5,220
16,852,911
2013-05-31T08:23:00.000
-1
0
1
0
python,date,pandas
60,213,042
10
false
0
0
Try to convert one of the rows into timestamp using the pd.to_datetime function and then use .map to map the formular to the entire column
2
133
1
I have a Pandas data frame, one of the column contains date strings in the format YYYY-MM-DD For e.g. '2013-10-28' At the moment the dtype of the column is object. How do I convert the column values to Pandas date format?
How do I convert strings in a Pandas data frame to a 'date' data type?
-0.019997
0
0
297,830
16,852,911
2013-05-31T08:23:00.000
25
0
1
0
python,date,pandas
33,577,649
10
false
0
0
Now you can do df['column'].dt.date Note that for datetime objects, if you don't see the hour when they're all 00:00:00, that's not pandas. That's iPython notebook trying to make things look pretty.
2
133
1
I have a Pandas data frame, one of the column contains date strings in the format YYYY-MM-DD For e.g. '2013-10-28' At the moment the dtype of the column is object. How do I convert the column values to Pandas date format?
How do I convert strings in a Pandas data frame to a 'date' data type?
1
0
0
297,830
16,853,789
2013-05-31T09:12:00.000
1
1
1
0
python
16,853,869
2
false
0
0
No. Think about it: If Python is slower than C for a processor running at speed X, what can you say about the speed of Python vs. C for a processor running at speed 2X? But then... You can write operating systems in dynamic languages. And people do. Once you bootstrap the interpreter. But this won't become mainstream. At least not anytime soon. Because: The mainstream operating systems are already... well... mainstream. And people want to use all that processing power in their new processors for... um... processing stuff. And not for providing the underpinnings to... um... process stuff.
1
1
0
I have a question which has been on my mind for a while. I'm aware that languages like C are faster than Python and are therefore used to write operating systems. I've read somewhere that an operating system written in Python will be very slow. So here is my question: As processor speed is continuously improved, does the execution speed of a particular language become less of a factor in operation system development? Will it be possible, in the future, to write an operating system solely in Python that will be running almost on the same speed with one written in C? Thank you.
Python's speed in operating system development
0.099668
0
0
190
16,859,674
2013-05-31T14:27:00.000
0
0
0
1
python,google-app-engine,python-memcached
16,866,096
3
false
1
0
Any object is a valid key, provided that the object can be serialized using pickle. If pickle.dumps(key) succeeds, then you shouldn't get a BadKeyError.
2
1
0
Is there a function in Google App Engine to test if a string is valid 'string key' prior to calling memcache.get(key) without using db.get() or db.get_by_key_name() first? In my case the key is being passed from the user's get request: obj = memcache.get(self.request.get("obj")) Somehow I'd like to know if that string is a valid key string without calling the db first, which would defeat the purpose of using memcache.
Test if string is valid key prior to memcache.get()
0
0
0
581
16,859,674
2013-05-31T14:27:00.000
1
0
0
1
python,google-app-engine,python-memcached
16,867,410
3
false
1
0
A db module key sent to a client should pass through str(the_key) which gives you an URL safe encoded key. Your templating environment etc.. will do this for you just by rendering the key into a template. On passing the key back from a client, you should recreate the key with key = db.Key(encoded=self.request.get("obj")) At this point it could fail with something like BadKeyError: Invalid string key "thebadkeystring"=. If not you have a valid key obj = memcache.get(self.request.get("obj")) won't actually raise BadKeyError because at that point you are just working with a string, and you just get None returned or a value. So at that point all you know is you have a key missing. However you need to use the memcache.get(self.request.get("obj")) to get the object from memcache, as a db.Key instance is not a valid memcache key. So you will be constructing a key to validate the key string at this point. Of course if the memcache get fails then you can use the just created key to fetch the object with db.get(key)
2
1
0
Is there a function in Google App Engine to test if a string is valid 'string key' prior to calling memcache.get(key) without using db.get() or db.get_by_key_name() first? In my case the key is being passed from the user's get request: obj = memcache.get(self.request.get("obj")) Somehow I'd like to know if that string is a valid key string without calling the db first, which would defeat the purpose of using memcache.
Test if string is valid key prior to memcache.get()
0.066568
0
0
581
16,861,536
2013-05-31T16:07:00.000
0
0
1
0
python,regex,file-io
16,861,680
3
false
0
0
Use the csv module to read the files in, create a dictionary of the measurement names, and make the values in the dictionary a list of the values from the file.
1
2
0
I am attempting to combine a collection of 600 text files, each line looks like Measurement title Measurement #1 ebv-miR-BART1-3p 4.60618701 .... evb-miR-BART1-200 12.8327289 with 250 or so rows in each file. Each file is formatted that way, with the same data headers. What I would like to do is combine the files such that it looks like this Measurement title Measurement #1 Measurement #2 ebv-miR-BART1-3p 4.60618701 4.110878867 .... evb-miR-BART1-200 12.8327289 6.813287556 I was wondering if there is an easy way in python to strip out the second column of each file, then append it to a master file? I was planning on pulling each line out, then using regular expressions to look for the second column, and appending it to the corresponding line in the master file. Is there something more efficient?
Combining files in python using
0
0
0
160
16,863,537
2013-05-31T18:24:00.000
1
0
1
0
python
16,863,623
2
false
0
0
This probably has to do with Python's roots being in C. In C, false == 0. Also at an academic level, in binary representation, 0 is almost always regarded as false.
2
0
0
Python is an object-oriented programming language, although it treats 0 as False, while languages like, for example, Ruby evaluates 0 to true, because (I believe) 0 it's a number and numbers are objects so they must evaluate to true because they exists. well, all I know about these conventions is that, they are there because performance and or designs reasons, but: What are the advantages of treating 0 as False? What are the disadvantages of treating 0 as true?
Why python evaluates 0 to False?
0.099668
0
0
404
16,863,537
2013-05-31T18:24:00.000
0
0
1
0
python
16,863,633
2
false
0
0
Almost every common language (everything on the C branch, Haskell, Python, etc.) interpret 0 as False. This makes a lot of sense, because the question "Does this variable contain something meaningful?" is most often True when > 0, and False when 0. The only place I recall seeing 0 being used as True is in the Unix shell, because all other exit codes from a program indicate a particular error, and 0 means no error. If Ruby treats 0 as True, I can only imagine it's to fit with Unix scripting and handle return codes.
2
0
0
Python is an object-oriented programming language, although it treats 0 as False, while languages like, for example, Ruby evaluates 0 to true, because (I believe) 0 it's a number and numbers are objects so they must evaluate to true because they exists. well, all I know about these conventions is that, they are there because performance and or designs reasons, but: What are the advantages of treating 0 as False? What are the disadvantages of treating 0 as true?
Why python evaluates 0 to False?
0
0
0
404
16,865,213
2013-05-31T20:12:00.000
0
0
1
0
python,global-variables
37,989,329
7
false
0
0
A normal variable is only usable inside of a function, a global variable can be called for outside the function, but don't use this if you don't need to, it can create errors and big programming companies consider this a rookie thing to do.
2
19
0
How do I set a global variable inside of a python function?
How do I use global variables in python functions?
0
0
0
33,612
16,865,213
2013-05-31T20:12:00.000
1
0
1
0
python,global-variables
16,865,257
7
false
0
0
Explicit declaration by using global <variable name> inside a function should help
2
19
0
How do I set a global variable inside of a python function?
How do I use global variables in python functions?
0.028564
0
0
33,612
16,865,390
2013-05-31T20:23:00.000
2
0
1
0
python
16,865,448
6
false
0
0
I would say because finding the length depends on OS specific functionality. You can find the length of a file with this code: import os os.path.getsize('C:\\file.txt') You could also read the entire file into a string and find the length of the string. However you would want to be sure that the file is not of a huge size that will eat up all your memory.
2
23
0
I'm not exactly new to Python, but I do still have trouble understanding what makes something "Pythonic" (and the converse). So forgive me if this is a stupid question, but why can't I get the size of a file by doing a len(file)? file.__len__ is not even implemented, so it's not like it's needed for something else? Would it be confusing/inconsistent for some reason if it was implemented to return the file size?
Why no len(file) in Python?
0.066568
0
0
55,177
16,865,390
2013-05-31T20:23:00.000
24
0
1
0
python
16,865,516
6
false
0
0
Files have a broader definition, especially in Unix, than you may be thinking. What is the length of a printer, for example? Or a CDROM drive? Both are files in /dev, and sort of in Windows. For what we normally think of as a file, what would its length be? The size of the variable? The size of the file in bytes? The latter makes more sense, but then it gets ickier. Should the size of the file's contents be listed, or its size on disk (modulus allocation unit size). The question arises again for sparse files (files that have large empty sections which take no space, but are part of the file's normally reported size, supported by some file systems like NTFS and XFS). Of course, the answer to all of those could be, "just pick one and document what you picked." Perhaps that is exactly what should be done, but to be Pythonic, something usually must be clear-cut without having to read a lot of docs. len(string) is mostly obvious (one may ask if bytes or characters are the return value), len(array) is obvious, len(file) maybe not quite enough.
2
23
0
I'm not exactly new to Python, but I do still have trouble understanding what makes something "Pythonic" (and the converse). So forgive me if this is a stupid question, but why can't I get the size of a file by doing a len(file)? file.__len__ is not even implemented, so it's not like it's needed for something else? Would it be confusing/inconsistent for some reason if it was implemented to return the file size?
Why no len(file) in Python?
1
0
0
55,177
16,867,749
2013-06-01T00:15:00.000
0
0
0
0
android,python,sockets,tcp
16,868,676
2
false
0
0
poof's answer is a good overview, but here are some notes on the various options: Option 1: Have your Android get the picture and do a HTTP POST to a Python application running a framework such as Django. It should be 1 line of code on Android, and only a few lines of code on Python (around your existing code). The upside is that the low-level "Glue" is written for you, and it scales easily. The downside is that HTTP has some overhead. Option 2: Have your Android talk a custom TCP protocol to a custom TCP application. This is more work, so you should avoid it unless you need it. It will be more efficient and have lower latency, especially if you're sending multiple pictures. The response can also be much smaller without HTTP headers. In either option, you don't have to send a JPEG, you could send any custom format you want (there is a trade-off between compression on Android and size of file). I thought of using TCP Server, but I am new to socket programming and don't know how and where to start. Start where everyone else started - by reading a lot and playing a lot. You can find plenty of introductions to Socket programming in Python on the web. Go thru the tutorials, and start modifying them to see how they work. Read up on TCP/IP itself -- there are a lot of dark corners (Nagel, fragmentation, slow start) that can affect how you write the app when you get to a low level.
1
0
0
I am currently involved in a project where we performed some computer vision object recognition and classification using python. It is necessary to use photos taken from an Android phone (photos should be automatically sent from android to python). I actually don't know how should I connect both applications (android and python) together. I thought of using TCP Server, but I am new to socket programming and don't know how and where to start. Any one can help?
Tcp/IP socket programming in python
0
0
1
780
16,867,823
2013-06-01T00:26:00.000
3
0
0
0
python,mysql,mysql-python
16,867,914
4
false
0
0
Yes if you really need unlimited precision then you'll have to use a blob because even strigns are limited. But really I can almost guarantee that you'll be fine with a NUMERIC/DECIMAL data type. 65 digits means that you can represent numbers in the range (-10^65, 10^65). How large is this? To give you some idea: The number of atoms in the whole universe is estimated to be about 10^80. If you only need positive numbers you can further increase the range by a factor of 2 by subtracting 10^65 -1 beforehand.
1
2
0
I need to represent instances of Python "Long integer" in MySQL. I wonder what the most appropriate SQL data type I should use. The Python documentation (v2.7) says (for numbers.Integral): Long integers These represent numbers in an unlimited range, subject to available (virtual) memory only. For the purpose of shift and mask operations, a binary representation is assumed, and negative numbers are represented in a variant of 2’s complement which gives the illusion of an infinite string of sign bits extending to the left. My read of the MySQL documentation suggests that BIGINT is limited to 64 bits. The DECIMAL type seems to be limited to 65 digits. I can, of course, use BLOB. The application needs to support very large amounts of data, but I don't know yet how big these long integers might get, nor how many of them I'm likely to see. I'd like to preserve the spirit of the Python long integer definition, which suggests BLOB. I'd also like to avoid re-inventing the wheel, and so I am appealing to the stackoverflow hive-mind. Suggestions?
What are the options for storing Python long integers in MySQL?
0.148885
1
0
1,333
16,868,320
2013-06-01T01:54:00.000
1
0
1
1
python,unicode,encoding,enthought,canopy
16,913,698
1
true
0
0
are you running this code from an unsaved buffer? If yes, this is a known issue in Canopy 1.0 and should be fixed in the next update. If no, can you provide a minimal example to reproduce your problem, so this can be fixed? Thanks!
1
0
0
I've been using python from time to time for some small projects and just started using it again after quite a while. I'm using Enthoughts Canopy IDE and get the following error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 1: ordinal not in range(128) I know that I have to define the encoding first and I do so in the 2nd Line: " # -- coding: utf-8 -- " but when I run the script within Canopy I keep getting the error whenever I enter one of the following letters: ä,ö,ü as user input When I start my script via console ("python XXX.py" or "ipython XXX.py") it works like a charm . I'm just a little confused since I thought Canopy uses the ipython interpreter so there shouldn't be any differences whether I start it from console as ipython or via canopy best regards
Enthought Canopy Encoding Error
1.2
0
0
763
16,869,024
2013-06-01T04:24:00.000
4
0
1
0
python,python-3.x,caching
43,122,347
11
false
0
0
In 3.2 and later, Python saves .pyc compiled byte code files in a sub-directory named __pycache__ located in the directory where your source files reside with filenames that identify the Python version that created them (e.g. script.cpython-33.pyc)
4
936
0
From what I understand, a cache is an encrypted file of similar files. What do we do with the __pycache__ folder? Is it what we give to people instead of our source code? Is it just my input data? This folder keeps getting created, what it is for?
What is __pycache__?
0.072599
0
0
470,821
16,869,024
2013-06-01T04:24:00.000
5
0
1
0
python,python-3.x,caching
50,962,374
11
false
0
0
The python interpreter compiles the *.py script file and saves the results of the compilation to the __pycache__ directory. When the project is executed again, if the interpreter identifies that the *.py script has not been modified, it skips the compile step and runs the previously generated *.pyc file stored in the __pycache__ folder. When the project is complex, you can make the preparation time before the project is run shorter. If the program is too small, you can ignore that by using python -B abc.py with the B option.
4
936
0
From what I understand, a cache is an encrypted file of similar files. What do we do with the __pycache__ folder? Is it what we give to people instead of our source code? Is it just my input data? This folder keeps getting created, what it is for?
What is __pycache__?
0.090659
0
0
470,821
16,869,024
2013-06-01T04:24:00.000
5
0
1
0
python,python-3.x,caching
56,339,890
11
false
0
0
Execution of a python script would cause the byte code to be generated in memory and kept until the program is shutdown. In case a module is imported, for faster reusability, Python would create a cache .pyc (PYC is 'Python' 'Compiled') file where the byte code of the module being imported is cached. Idea is to speed up loading of python modules by avoiding re-compilation ( compile once, run multiple times policy ) when they are re-imported. The name of the file is the same as the module name. The part after the initial dot indicates Python implementation that created the cache (could be CPython) followed by its version number.
4
936
0
From what I understand, a cache is an encrypted file of similar files. What do we do with the __pycache__ folder? Is it what we give to people instead of our source code? Is it just my input data? This folder keeps getting created, what it is for?
What is __pycache__?
0.090659
0
0
470,821
16,869,024
2013-06-01T04:24:00.000
0
0
1
0
python,python-3.x,caching
71,937,472
11
false
0
0
does the byte code in __pycache__ get automatically invoked the next time the application is started? I.E: if we run some application main.py for the first time and all the necessary modules get complied and stored in pycache then the next time are they automatically used even if I call python main.py? or we will have to call python _pycache_/main.pyc?
4
936
0
From what I understand, a cache is an encrypted file of similar files. What do we do with the __pycache__ folder? Is it what we give to people instead of our source code? Is it just my input data? This folder keeps getting created, what it is for?
What is __pycache__?
0
0
0
470,821
16,869,621
2013-06-01T06:00:00.000
2
0
0
0
java,android,python,pygtk,kivy
16,878,423
1
false
0
1
I see you tagged the question with kivy, I can only answer that we don't have such a thing for kivy yet, although a GSOC student got accepted for this and will start working on it soon, let's hope it'll work out nicely :). I'm of the opinion that the kvlang we have in kivy makes the need of a Graphical Designer far less than in other toolkits, but i guess YMMMV. Other than that, I don't think you can do PyGTK development on Android currently, but I think PySide works, so maybe QtDesigner or some other Qt design application would be worth a look?
1
3
0
I want to use pygtk app for android app development. I want to use app like pygtk which will have easy drag and drop options for developing the front end for android application. Is there any of such thing which can let me design my front end for android app with drag and drop? (specially in python or else in java)
use pygtk for android apps development
0.379949
0
0
1,574
16,870,858
2013-06-01T08:44:00.000
1
0
1
0
python,flask
16,891,362
3
false
1
0
I have not threading solution: I'm using celery for hard operations: send email, fetch url, create many database records, periodic tasks. + you can use flask application and celery instances on different servers - you need backend (rabbitmq, redis, mongodb and etc.)
1
2
0
Recently I've been practicing to build a website with flask. Now i encounter a problem.There is a function which to achieve registration. The code like this: def register(): ... some judgment ... if true: sendmail() return redirect(url_for('onepage')) My question is : When preforming sendmail(), it needs much time. So the users have to wait for a moment to get "onepage", about 4-5s. This will bring a bad experience. I know that using threading can let these two functions independently of each other, but I have learnt programming for a very short time so I have no experience in threading programming, Could anybody provide some ideas or code examples for me at this problem?
threading programming in python
0.066568
0
0
2,730
16,871,254
2013-06-01T09:33:00.000
12
0
1
0
python,django,virtualenv
16,871,438
1
true
1
0
Nope, it doesnt infuence the performance. Basically all what it do is changing python path to the virtualenvs ones. So there shouldn`t be any difference with performance.
1
8
0
I have a django app up and running. I never encountered any performance problems, though the app is hosted on a shared hosting platform. The provider asked my recently to use python's virtualenv. Since then the performance has been really bad, though I can't detect the change in CPU usage or any other statistic. So my question is: does using a virtual environment influence the performance? If yes, how?
Does using a virtual environment influence the performance of a web app?
1.2
0
0
2,134
16,872,221
2013-06-01T11:31:00.000
6
0
0
0
python,mysql,mongodb,nlp,bigdata
16,873,052
1
true
0
0
This really depends on what exactly you are storing and which operations you will perform on this data. SQL vs. NoSQL is a very fundamental decision and no one can give you a good advice here. If your data fits relational model well, then, SQL (PostgreSQL or MySQL) is your choice. If your data is more like documents, use MongoDB. That said, just recently I made a search engine. We had to store indexed pages (raw text), the same text but tokenized and some additional metadata. MongoDB performed really well.
1
0
0
Can someone advise on what database is better for storing textual information such as part of speech sequences, dependencies, sentences used in NLP project written in python. Now this information is stored in files and they need to be parsed every time in order to extract the mentioned blocks which are used as an input for next processing stage. Options considered - MongoDB, Cassandra and MySQL. Are NoSQL databases better in this type of application. Thanks.
Database for NLP project
1.2
1
0
2,075
16,874,046
2013-06-01T15:04:00.000
17
0
1
0
python,console,pycharm
29,418,064
9
false
0
0
For anyone still having this problem: Go to the Run/Debug menu, choose Edit Configuration, check the box 'Show command line' this will enable you to enter parameters in the console at the >>> prompt and test your function. Edit: To make this change apply to all your .py files (as this check box only applies to the current file you're working on) go to: Edit configuration, in the pop up you will see a menu tree on the left, select Defaults, then Python, then check the 'Show command line' box, this will make it the default setting whenever you open a .py file, (this feature should really be on by default!)
2
25
0
I'm new to python and pycharm and I'd like to run a module from the pycharm console in the same way as you can from IDLE, if it's possible. The idea is to create simple functions and test them "live" using the console. ...how do you do that in pycharm?
Running a module from the pycharm console
1
0
0
69,594
16,874,046
2013-06-01T15:04:00.000
3
0
1
0
python,console,pycharm
27,771,551
9
false
0
0
Select the script lines that you want to execute and press Shift+Alt+E
2
25
0
I'm new to python and pycharm and I'd like to run a module from the pycharm console in the same way as you can from IDLE, if it's possible. The idea is to create simple functions and test them "live" using the console. ...how do you do that in pycharm?
Running a module from the pycharm console
0.066568
0
0
69,594
16,874,716
2013-06-01T16:22:00.000
0
0
0
0
python,import,intellij-idea,pygame
32,979,653
1
false
0
1
you can try to install the pygame lib to your python directory, but you might have to make your python 32 bit for that to work dunno how it works on windows. On mac though there are several tutorials.
1
3
0
I use intellij idea plug in for python developing. I want to import pygame module to my project, but everytime I get error "ImportError: No module named 'pygame'". I tried to add the pygame lib folder to dependencies but it didn't work, I also added it to library but it didn't work either. Could anyone help me with this issue. Thanks
importing pygame in Intellij IDEA
0
0
0
1,211
16,876,974
2013-06-01T20:30:00.000
2
0
1
1
python,virtualenv
54,860,786
2
false
0
0
virtualenv --python=python3 mynewenv
1
2
0
I recently have started learning python and have run into an issue. When I run python on my mac without virtualenv, the version number is Python 2.7.5. Unfortunately, when I go into my virtualenv, and run Python, the version number is Python 2.6.1. I tried, creating another virtualenv using: virtualenv -p /usr/bin/python2.7 newdev but got: The executable /usr/bin/python2.7 (from --python=/usr/bin/python2.7) does not exist
Virtualenv is installing with wrong version of Python
0.197375
0
0
3,193
16,877,448
2013-06-01T21:29:00.000
2
0
1
0
python,scikit-learn
16,877,799
1
true
0
0
Found it, there's a note on the svm page that if you enable verbose settings multiprocessing may break. Disabling verbose fixed it
1
1
1
Trying to use gridsearch CV with multiple jobs via the n_jobs argument and I can see using htop that they're all launched and running but they all get stuck/assigned on the same core using 25% each (I'm using a 4 core machine). I'm on Ubuntu 12.10 and I'm running the latest master pulled from github. Anyone know how to fix this? Thanks!
Scikit-Learn n_jobs Multiprocessing Locked To One Core
1.2
0
0
391
16,879,278
2013-06-02T02:45:00.000
1
0
0
0
python,django
16,879,697
1
true
1
0
You don't need to copy whole django-userena module in you project directory. You only need to copy "emails" folder from userena/templates/userena/ into you project template directory with same directory structure. For Example : you_project_dir/templates/userena/emails After that just change activation_email_message.txt file content in emails folder of your project template directory.
1
0
0
I want to replace the default django-userna email message for user account activation with one that is website specific. I've thought of some ways to do this like copying the entire installed django-userna module into a project specific app and replacing the default message stored in the module, but, all of my solutions have felt really hackish. Thank you!
How to overwrite the default email message for user account activation in django-userna?
1.2
0
0
173
16,881,335
2013-06-02T09:08:00.000
0
1
0
0
php,python,selenium,hostmonster
16,975,487
2
false
0
0
when i enter import sys and then print sys.path into ssh shell I receive the following: ['', '/home2/klickste/python/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/home2/klickste/python/lib/python2.7/site-packages/mechanize-0.2.5-py2.7.egg', '/home2/klickste/python/lib/python2.7/site-packages/html2text-3.200.3-py2.7.egg', '/home2/klickste/python/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg', '/home2/klickste/python/lib/python27.zip', '/home2/klickste/python/lib/python2.7', '/home2/klickste/python/lib/python2.7/plat-linux2', '/home2/klickste/python/lib/python2.7/lib-tk', '/home2/klickste/python/lib/python2.7/lib-old', '/home2/klickste/python/lib/python2.7/lib-dynload', '/home2/klickste/python/lib/python2.7/site-packages']
2
0
0
I have created a python script that uses selenium to automate an online task. The script works perfect on my local machine (windows 7) and gives the output i am looking for. I am now trying to get it up and running from PHP on my hostmonster shared server which is running linux and having no luck. I have installed this version of selenium on both my win7 comp and the server: pypi.python.org/pypi/selenium Python version: 2.7.5 The script i wrote gets the following error at "import selenium":ImportError: No module named selenium When i log into the server through ssh shell, i can type in "import selenium" and receive no errors. I can also type in "from selenium import webdriver" in the ssh shell and receive no errors. Any help/guidance would be greatly appreciated.
Import selenium error on hostmonster shared linux server
0
0
1
238
16,881,335
2013-06-02T09:08:00.000
1
1
0
0
php,python,selenium,hostmonster
16,991,512
2
true
0
0
I have resolved the issue. I used the following command to install selenium outside of the python folder. easy_install --prefix=$HOME/.local/ selenium I also added these lines at the bottom of my .bashrc file located in my home directory export PYTHONPATH=$HOME/.local/lib/python/site-packages:$PYTHONPATH export PYTHONPATH=$HOME/.local/lib/python2.7/site-packages:$PYTHONPATH export PATH=$HOME/.local/bin:$PATH
2
0
0
I have created a python script that uses selenium to automate an online task. The script works perfect on my local machine (windows 7) and gives the output i am looking for. I am now trying to get it up and running from PHP on my hostmonster shared server which is running linux and having no luck. I have installed this version of selenium on both my win7 comp and the server: pypi.python.org/pypi/selenium Python version: 2.7.5 The script i wrote gets the following error at "import selenium":ImportError: No module named selenium When i log into the server through ssh shell, i can type in "import selenium" and receive no errors. I can also type in "from selenium import webdriver" in the ssh shell and receive no errors. Any help/guidance would be greatly appreciated.
Import selenium error on hostmonster shared linux server
1.2
0
1
238
16,885,902
2013-06-02T18:25:00.000
1
0
1
1
python,github,virtualenv,github-for-mac
16,885,929
2
false
0
0
Open terminal. cd into your virtualenv directory, and run git clone from there.
1
3
0
I could be missing something fundamental here, but I'm struggling to work out what. I'm using Github for Mac for the first time. I've found a repo i want to look at, so I've logged into GH and installed and configured the mac app. I've created a virtualenv that I want to work in. added python 2.7. I've forked the repo on GH. Then I've hit the clone to mac button. this works fine and asks me where i want to put it. the problem is here, the only action is to overwrite the whole directory. which isnt good. ive checked the help for virtualenv and theres no convert to virtualenv option, which would allow me to download the project then make it a virtualenv. im aware that i can probably get by with a copy and paste operation and two different folders, but this seems silly. Is there an easier way to accomplish this?
how to clone a repo to a virtualenv on mac Mountain Lion
0.099668
0
0
2,468
16,889,768
2013-06-03T03:51:00.000
1
1
0
0
python,http,ftp
16,889,799
1
true
0
0
In your case I would use the HTTP because: Your service is stateless. If you use TCP you will have problem scaling up your service (since every request will be directed to the server that establish the TCP connection ), this relate to that your service is stateless. In HTTP you just add more servers behind load balane For TCP you will need to state some port which can be block due to firewall and ect' - you can use port 80/8080 but I don't think this is good practice if you service were more like suggestion that change as the use typein his word you may want to use TCP/HTTP Socket TCP is used for more long term connection - like Security system that report the state of the system every X seconds - which is not the case
1
0
0
I am building a back end that will handle requests from web apps and mobile device apps. I am trying to decide if an TCP server is appropriate for this vs. Regular http GET and POST requests. Use case 1: 1. Client on mobile device executes a search on the device for the word "red". Word sent to server (unclear wether JSON or TCP somehow) The word red goes to the server and the server pulls all rows from a mysql db that have red as their color (this could be ~5000 results). Alternate step 2 (maybe TCP should make more sense here): there is a hashmap built with the word red as the key and the value a pointer to an array of all the objects with the word red (I think this will be a faster look up time). Data is sent to the phone (either JSON or some other way, not sure). I am unclear on this step. The phone parses, etc... There is a possibility that I may want to keep the array alive on the server until the user finishes the query (since they could continue to filter down results). Based on this example, what is the architecture I should be looking at? Any different way is highly appreciated. Thank you
Should I build a TCP server or use simple http messages for a back-end?
1.2
0
1
110
16,890,209
2013-06-03T04:54:00.000
2
0
0
0
python,hash,web-scraping
16,890,397
2
false
1
0
You can keep track of the date of the last version you got and use the If-Modified-Since header in your request. However, some resources ignore that header. (In general it's difficult to handle it for dynamically-generated content.) In that case you'll have to fall back to less efficient method.
2
0
0
I have some webpages where I'm collecting data over time. I don't care about the content itself, just whether the page has changed. Currently, I use Python's requests.get to fetch a page, hash the page (md5), and store that hash value to compare in the future. Is there a computationally cheaper or smaller-storage strategy for this? Things work now; I just wanted to check if there's a better/cheaper way. :)
Efficient way to check whether a page changed (while storing as little info as possible)?
0.197375
0
1
89
16,890,209
2013-06-03T04:54:00.000
0
0
0
0
python,hash,web-scraping
16,890,487
2
true
1
0
A hash would be the most trustable source of change detection. I would use CRC32. It's only 32 bits as opposed to 128bits for md5. Also, even in browser Javascript it can be very fast. I have personal experience in improving the speed for a JS implementation of CRC32 for very large datasets.
2
0
0
I have some webpages where I'm collecting data over time. I don't care about the content itself, just whether the page has changed. Currently, I use Python's requests.get to fetch a page, hash the page (md5), and store that hash value to compare in the future. Is there a computationally cheaper or smaller-storage strategy for this? Things work now; I just wanted to check if there's a better/cheaper way. :)
Efficient way to check whether a page changed (while storing as little info as possible)?
1.2
0
1
89
16,893,102
2013-06-03T08:54:00.000
2
0
0
0
python,matplotlib,tiff
16,893,364
1
true
0
0
Using matplotlib to export to TIFF will use PIL anyway. As far as I know, matplotlib has native support only for PNG, and uses PIL to convert to other file formats. So when you are using matplotlib to export to TIFF, you can use PIL immediately.
1
0
1
I'm trying to save some arrays as TIFF with matplotlib, but I'm getting 24 bit RGB files instead with plt.imsave(). Can I change that without resorting to the PIL? It's quite important for me to keep everything in pure matplotlib.
How to save 32/64 bit grayscale floats to TIFF with matplotlib?
1.2
0
0
792
16,893,882
2013-06-03T09:43:00.000
0
0
1
1
python,python-module
16,894,057
2
false
0
0
You need to change the permissions for the directory the process wants to write to. Find out what directory joblib wants to put things in and change its permissions or use a different directory with the needed permissions for this. In order to be able to give the permissions and to allow Python to write to the filesystem, it must be mounted in a way that allows writing.
1
0
0
Anyone knows what this error is and how to fix it? I've already tried to chmod -R 777 /usr/local/python2.6/dist-packages/joblib but with no luck.
/usr/local/lib/python2.6/dist-packages/joblib/parallel.py:40: UserWarning: [Errno 30] Read-only file system. joblib will operate in serial mode
0
0
0
776
16,897,305
2013-06-03T12:58:00.000
1
0
1
0
python,python-3.x
16,900,464
2
true
0
0
You'll have to install 32-bit Python to run 32-bit extension modules. In my experience, two Python installations can live side-by-side quite nicely on Windows, as long as you make sure your environment (PYTHONPATH esp.) is set properly.
1
2
0
Note: Running windows7X64 I want to use some audio functions I have seen allot for python 2.7 like snack and such, however I'm using python 3.3. I have come across pygame.py that has some audio functions however pygame doesn't support 64bit arch yet. So can it be done? if not do we know of any python audio integration modules that can get the job done on python 3 with a 64bit arch Yes I can just install python 3 32bit but that seems counterproductive and unnecessarily complicated. Thanks Ben
Run Python 64bit In 32Bit mode?
1.2
0
0
9,258
16,898,086
2013-06-03T13:36:00.000
0
0
1
0
python,multithreading,timing
16,898,280
1
false
0
0
You could create a scheduler using a priority queue and a time quantum. Not sure on the specifics for this in Python, but the concept is the same: create a Scheduler class that accepts a thread, add the thread to a priority queue with a given priority, then sleep the thread after a specified time quantum has elapsed. You can tailor the time quantum depending on the current threads priority. This is similar to how an Operating System schedules process threads.
1
2
0
Is it possible to control the proportional execution time of a thread in python. For example, I have three functions F1, F2 and F3 in my program. I am calling each function with using start_new_thread in python. I want F2 thread to execute 70 percent of time while F1 and F3 should share rest of 30 percent. Is there a way to explicitly control these timings.
Controlling Thread Execution Time in Python
0
0
0
321
16,898,520
2013-06-03T13:57:00.000
0
0
0
0
javascript,python,html,web-applications,flask
16,898,841
3
false
1
0
Yuo should try localstorage .
1
1
0
I am building a website that does not require people to login, but still needs large session data. Example: a person uploads a 0.5 MB file. I want to able to manipulate this this from now and then. Where should I store it? I would prefer something like a cookie system, but obviously this is too small. Redis seems like an opportunity, but I was hoping for something simpler. I'm using Python flask. Thanks in advance.
What is the best way to store large session data in web applications?
0
0
0
758
16,899,170
2013-06-03T14:30:00.000
1
0
1
0
python,installation,version,pygame
16,899,819
2
true
0
1
I solved it. I installed "Lion apple supplied python: pygame-1.9.2pre-py2.7-macosx10.7.mpkg.zip" Then i went into terminal and tried to import pygame through Aplle python and it prompted me to install "Xquartz" after i did this pygame works in both Terminal and 64 bit Idle 2.7.5.
1
0
0
Im running Mac OS 10.8.3 and python/idle 2.7.5. I tried to install pygame 1.9.1 but it didnt work. Is this the right pygame? if not which is?
Which pygame should i install?
1.2
0
0
356
16,899,597
2013-06-03T14:51:00.000
0
0
0
0
python,django,django-views
16,899,786
3
false
1
0
You can totally do that, it is only a convention to use views.py. Now, the question is: do you really need to create a new file to put your views inside ? Shouldn't these regrouped in a new application ? Think of an other person reviewing your code: would the reason of the separation be crystal clear to him ?
1
3
0
I have just started learning Django. I was wondering if Django app can have more than one views file? Let's say, I have two separate classes. Should I keep them in one views file or can I make two views files? Thanks in advance!
Can a django app have more than one views.py?
0
0
0
1,066
16,900,215
2013-06-03T15:20:00.000
4
0
0
0
python,django,javascriptmvc
16,900,507
1
false
1
0
If you don't want to render a template, simply don't render it. Django won't render anything unless you specifically call template.render or one of the shortcuts. If you just want to return an HTML file, you could just open it as a normal file, read it, then return the content as the response. Alternatively, as suggested in the comment, you can serve it as a static file.
1
2
0
I'm writing a single view Javascript application with a Django backend that only needs to return the initial index.html and all other templates come from a CDN. My problem is that this first index.html file is parsing out some of my "{{}}" handlebars which I wanted to leave for the JS library to interpret. I DO NOT want to use 'verbatim' or 'raw' or any additional tags because I don't want any django specific stuff in my static template files. A possible alternative answer to this would be desmonstrating how to to make your inital index HTML response also come from the CDN but I didn't think that was possible.
Django return .html file directly without parsing for template tags at all
0.664037
0
0
2,717
16,901,130
2013-06-03T16:07:00.000
1
0
1
0
python,api,sdk,dropbox,importerror
17,679,874
1
true
0
0
Update: I found the problem, i called my own file dropbox.py and in that file imported dropbox. I accidently imported my own file. Renamed my file and now it works.
1
2
0
I am trying to use the dropbox sdk for python. I installed a virtual enviroment and used pip install to install dropbox-sdk. When I try to run the example code (see below) I get a importerror client cannot be found, but if I try to do it from the interactive intreperter it works. So what am I doing wrong. APP key and secret key and acces_type ommitted.
Dropbox python sdk import error
1.2
0
1
216
16,901,650
2013-06-03T16:41:00.000
0
1
0
0
python,sftp,checksum,paramiko
68,450,855
1
false
0
0
I came with a similar scenario. the solution I currently take is to compare the remote file's size by using item.st_size for item in sftp.listdir_attr(remote_dir) with the local file's size by using os.path.getsize(local_file). when the two files are around 1MB or smaller,this solution is fine. However, a weird thing might happen: when the files are around 10MB or larger, the two size might differ slightly,e.g., one is 10000 Byte, another is 10003 Byte.
1
2
0
I have a script that downloads a lot of fairly large (20MB+) files. I would like to be able to check if the copy I have locally is identical to the remote version. I realize I can just use a combination of date modified and length, but is there something even more accurate I can use (that is also available via paramiko) that I can use to ensure this? Ideally some sort of checksum? I should add that the remote system is Windows and I have SFTP access only, no shell access.
Python + Paramiko - Checking whether two files are identical without downloading
0
0
1
614
16,905,303
2013-06-03T20:29:00.000
1
0
0
1
java,python,google-app-engine,load-testing
23,557,544
2
false
1
0
We had a similar problem - I found that disabling the app in Application Settings and then re-enabling it terminated all 88 instances we had running, without any other adverse effects.
2
1
0
We are running multiple load tests every day against one of our GAE apps. We use the following pattern: Start a load test and let it run for a few hours. Look at graphs. Optionally deploy a new version of our app with performance improvements. Go back to 1. Each load test creates a couple hundred front end instances. We would like to terminate those between individual load tests even when we are not deploying a new version of our app. Is there a way to terminate all dynamic instances? Right now we either have to deploy a new version or terminate all instances by hand.
How to shutdown all dynamic instances in Google App Engine without re-deploying the app?
0.099668
0
0
1,179
16,905,303
2013-06-03T20:29:00.000
0
0
0
1
java,python,google-app-engine,load-testing
16,909,149
2
false
1
0
Maybe have them all periodically probe the datastore (or memcache) for a kill value?
2
1
0
We are running multiple load tests every day against one of our GAE apps. We use the following pattern: Start a load test and let it run for a few hours. Look at graphs. Optionally deploy a new version of our app with performance improvements. Go back to 1. Each load test creates a couple hundred front end instances. We would like to terminate those between individual load tests even when we are not deploying a new version of our app. Is there a way to terminate all dynamic instances? Right now we either have to deploy a new version or terminate all instances by hand.
How to shutdown all dynamic instances in Google App Engine without re-deploying the app?
0
0
0
1,179