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,016,645 |
2013-04-15T13:38:00.000
| 1 | 1 | 0 | 0 |
php,python-2.7
| 16,016,728 | 1 | false | 0 | 0 |
If you have access to exec, you can run the python interpreter. However, that's:
Overkill
Not necessarily wise
A major waste of resources
If your logic is simple, why don't you write it in PHP? Furthermore, if your logic is not simple...why don't you make an API of some sort to access it and favour communication rather than code deduplication?
| 1 | 0 | 0 |
I want to implement one logic which is written in python, this code will do some searching stuffs, and I have a website done in PHP. can any one tell me whether I can include python script in PHP? if yes , how can I do that ?
Criteria :
Input to the python script will come from php or html [either text or file]. and output of python is directly displayed to the page or through php or store it in mysql and show it through PHP.[Please suggest me the best one in this].
|
Can Python Script be included in PHP?
| 0.197375 | 0 | 0 | 69 |
16,017,830 |
2013-04-15T14:32:00.000
| 0 | 0 | 0 | 0 |
python,django,django-models,internationalization
| 16,126,895 | 1 | true | 1 | 0 |
Finally I've solved the problem by introducing a new layer, like follows:
There exist the models Area and Resource, both are now translatable and are created by admin staff, current users aren't allowed to create or modify them. These models will be more abstract to allow doing the matchings.
But, to allow more "precision" two new models have been added: AreaTag and ResourceTag. These two models are created by users, and they aren't translated. So we can have "application" and "applicación" areatags, but as the user has previously choosen an Area, we can do the searches using the Area, which will be common for both cases. So searching in the level Tag won't be necessary to find affinity.
Hope this helps someone trying to do something similar! :)
| 1 | 1 | 0 |
I'm working on a Django (v. 1.5.1) website and I have several models, such as RegisteredUser and Startup. Each of these two models has a Many2ManyField to an Area model. Area contains two fields: name and slug (which is built from name).
This design works well to find users and startups within the same areas, but there is a big problem when trying to internationalizate it. In this design, users create areas and attach them to RegisteredUser and Startup instances by themselves. But, if the same area is created in different languages then an area called computer science will be different from informática (Spanish version).
The idea is that users created areas just as if they were tags, but I think this will bring problems as the one described above.
So I was wondering about possible solutions:
When the user creates an area instance, she has to fill in all the translated versions for the area and the slug'd be calculated from the English version. But this doesn't seem very atrractive for the user. Does it?
The user can only choose from a list of predefined areas, which have been previously introduced and translated. But what about new ones? This option seems really hard to maintain...
For the translations I'm using django-transmeta.
So, I'd be glad to read your opinions and suggestions on how to deal with this problem.
Thanks a lot!
|
How to translate a shared Model in Django without breaking uniqueness?
| 1.2 | 0 | 0 | 47 |
16,018,995 |
2013-04-15T15:25:00.000
| 1 | 0 | 0 | 0 |
python,postgresql,openerp,erp
| 16,029,533 | 1 | false | 1 | 0 |
Install hr_payroll module. Flow is as below:
Employee --> Contracts --> Salary Structure --> Salary Rules
In Contract, You can set Working Schedule for that employee with Wage. You need to configure Salary Structure with Salary Rules as per your need. Salary rules for Bonus, expenses, etc.
In that Salary structure, You need to add that rules. Now, go to the Employee Payslip menu, select that employee, Related information will be automatically come over there. Click on Compute sheet button. You will get Salary details in Salary Computation tab as per your Salary rules that you added in your Salary Structure.
For now, there is no link between attendance and payroll in OpenERP that you need to customize. It depends on requirements that how much time it will take for that! Hope this will help you.
| 1 | 1 | 0 |
In our company we decided to use openERP
We now working to customize openERP with our work ... we can use it successfully in warehouse dept. and sallies dept.
My question is how to make openERP calculate monthly Net Salary
with deduct if the Employee absence or leave the work or if we decided to add bonus
and if we can programming new model and add it How this difficult to work and what about expected time required to do
OR how we can access to fields related with attendance and building our own program to calculate Net Salary ?
|
Can we calculate Net Salary with openERp
| 0.197375 | 0 | 0 | 1,340 |
16,019,155 |
2013-04-15T15:33:00.000
| 1 | 0 | 0 | 0 |
python,mp3
| 21,548,733 | 1 | false | 1 | 0 |
I assume you want to split the channels losslessly, without decoding MP3 and re-encoding it - otherwise you would not have mentioned MP3 at all and would have easily found many tools like Audacity to do that.
There are 4 channel modes of MP3 frames - this means 4 types of MP3 files: simple stereo, joint-stereo, dual-channel, mono. joint-stereo files can't be split without loss. mono files doesn't need splitting. The rest: stereo and dual-channel, consists of less than 0.1% of all MP3 files, technically can be split into 2 files, each for a channel, without loss. However there is not any tool on the Internet to do that - not any command line tool nor any GUI tool, because few need the function.
There are not any python library for you neither. Most libraries abstracted MP3 files into a common audio which you can manipulate, after decoding. pymad is the only one specific to MP3 file, and it can tell if a file is using any of the 4 channel modes, but does not offer to extract a channel without decoding it. If you write a new tool, you will have to work on raw MP3 files or produce a library for it.
And it is not easy to write a tool or library for it. It's one stream with 2 channels and not two streams interleaved on a frame level. You cannot simply work on MP3 frames, drop some frames, keep others, and manage to extract a channel out that way. It's a task for a professional, and perhaps best happen in a decoder project (like lame or libmad) and not in a file manipulation project (like mp3info or the python eyeD3). In other words, this feature is likely written in C, not python.
Implementaiton Note:
The task to build such a tool thus suits well for a computer science C-programming language course project:
1. it takes a lot of time to do;
2. it requires every skill learned from C programming course;
3. it can get wrong easily;
4. it is likely built on the work of other projects, a lesson of adaptating existing work;
5. is a damn-hard endeavor that no-one did before and thus very rewarding
6. perhaps can be done in 300 difficult lines of code instead of bloated simple Visual Basic code, thus is a good lession of modesty and quality;
7. and finally: nobody is waiting in an hurry for a working implementation.
All condition fits perfectly for a C-programming course project.
Implementation Note 2:
some bit-rates are only possible in mono mode (80kbps), and some bit-rates are only possible in stereo mode (e.g. 320kpbs). Luckily this does not present a problem in this task, because all dual-mp3 bit-rate can be mapped into a fitting mono-mp3 bit-rate -- but not vice versa!
| 1 | 0 | 0 |
I'd like to seperate the channels of a mp3 file in Python and save it in two other files.
Does anybody know a library for this.
Thanks in advance.
|
Python split mp3 channel
| 0.197375 | 0 | 0 | 1,282 |
16,022,915 |
2013-04-15T19:05:00.000
| 3 | 1 | 0 | 0 |
python,pytest
| 58,883,629 | 5 | false | 0 | 0 |
This is what I use
py.test tests/ --pdbcls=IPython.core.debugger:Pdb -s
| 1 | 115 | 0 |
I'm using pytest for my test suite. While catching bugs in complex inter-components test, I would like to place import ipdb; ipdb.set_trace() in the middle of my code to allow me to debug it.
However, since pytest traps sys.stdin/sys.stdout ipdb fails. How can I use ipdb while testing with pytest.
I'm not interested in jumping to pdb or ipdb after a failure, but to place breaks anywhere in the code and be able to debug it there before the failure occurs.
|
How to execute ipdb.set_trace() at will while running pytest tests
| 0.119427 | 0 | 0 | 36,627 |
16,025,662 |
2013-04-15T22:22:00.000
| 14 | 0 | 1 | 1 |
python,windows,eyed3
| 16,025,847 | 2 | true | 0 | 0 |
try import eyed3 (without capital D)
| 2 | 3 | 0 |
On Windows, I have installed Python 2.7 and added python.exe's directory to PATH. Then I installed pip und used pip install eyeD3 to install the eyeD3 module successfully. However, using import eyeD3 doesn't work, but throws an ImportError.
I had the idea to adjust the PYTHONPATH-environment-variable in my command line, but had no clue to what I would have to set it.
|
Making the eyeD3-module available for import in python
| 1.2 | 0 | 0 | 3,498 |
16,025,662 |
2013-04-15T22:22:00.000
| 3 | 0 | 1 | 1 |
python,windows,eyed3
| 16,128,387 | 2 | false | 0 | 0 |
The namespace changed to eyed3 in 0.7, as did the API. On all platforms.
| 2 | 3 | 0 |
On Windows, I have installed Python 2.7 and added python.exe's directory to PATH. Then I installed pip und used pip install eyeD3 to install the eyeD3 module successfully. However, using import eyeD3 doesn't work, but throws an ImportError.
I had the idea to adjust the PYTHONPATH-environment-variable in my command line, but had no clue to what I would have to set it.
|
Making the eyeD3-module available for import in python
| 0.291313 | 0 | 0 | 3,498 |
16,026,129 |
2013-04-15T23:09:00.000
| 1 | 0 | 1 | 1 |
ipython,qtconsole
| 16,066,204 | 1 | true | 0 | 0 |
No, it's not really in sight. The Qt console has some support for control characters, so it can do things like coloured text, but it's definitely not enough to support curses, and we're not really interested in going down that route.
The code is all in the open if you want to try to make it into a full terminal emulator. But I rather hope there are better starting points for terminal emulators in Windows.
| 1 | 0 | 0 |
I have been trying all sorts of sourceforge projects that try to port GNU functionality to Windows, with the goal to create a very GNU aware Ipython profile providing the best terminal environment I know how (on Windows that is).
How close is QtConsole to having the ability of running something like Curses through the IpyQt frontend?
(The key here, is that I want the DPI aware rich text of QtConsole. Would knock the socks off most of the Windows terminal alternatives.)
Is that possibility even in sight, or is that a match that will likely not happen? I have never emulated a VT100 in my spare time, how much does QtConsole look like one?
|
Ipython and Curses on Windows
| 1.2 | 0 | 0 | 125 |
16,026,776 |
2013-04-16T00:21:00.000
| 3 | 0 | 0 | 0 |
python,web2py
| 16,026,857 | 1 | true | 1 | 0 |
web2py keeps the structure it thinks the table has in a separate file. If someone has manually dropped the table, web2py will still think it exists, but of course you get an error when you try to actually use the table
Look for the *.mytable.table file in the databases directory
| 1 | 2 | 0 |
I have an error no such table: mytable, even though it is defined in models/tables.py. I use sqlite. Interesting enough, if I go to admin panel -> my app -> database administration then I see a link mytable, however when I click on it then I get no such table: mytable.
I don't know how to debug such error?
Any ideas?
|
web2py. no such table error
| 1.2 | 1 | 0 | 1,115 |
16,027,450 |
2013-04-16T01:46:00.000
| 2 | 1 | 1 | 0 |
python
| 16,027,565 | 3 | false | 0 | 0 |
You can use this regex [\u2E80-\u9FFF] to match CJK characters.
| 1 | 6 | 0 |
I have a Unicode string in Python. I am looking for a way to determine if there is any Chinese/Japanese character in the string. If possible it'll be better to be able to locate those characters.
It seems this is a bit different from a language detection problem. My string can be a mixture of English and Chinese texts.
My code has Internet access.
|
Is there a way to know whether a Unicode string contains any Chinese/Japanese character in Python?
| 0.132549 | 0 | 0 | 4,416 |
16,027,516 |
2013-04-16T01:53:00.000
| 4 | 0 | 0 | 0 |
python,django,datetime,django-models
| 54,221,361 | 6 | false | 1 | 0 |
datetime.time(16, 00) does not work.
Use datetime.time(datetime.now()) instead if you are trying to get the current time or datetime.time(your_date_time)
Where your_date_time = datetime.datetime object
| 2 | 30 | 0 |
I have a model for events which almost always start at 10:00pm, but may on occasion start earlier/later. To make things easy in the admin, I'd like for the time to default to 10pm, but be changeable if needed; the date will need to be set regardless, so it doesn't need a default, but ideally it would default to the current date.
I realize that I can use datetime.now to accomplish the latter, but is it possible (and how) to I set the time to a specific default value?
Update: I'm getting answers faster than I can figure out which one(s) does what I'm trying to accomplish...I probably should have been further along with the app before I asked. Thanks for the help in the meantime!
|
Can I set a specific default time for a Django datetime field?
| 0.132549 | 0 | 0 | 26,326 |
16,027,516 |
2013-04-16T01:53:00.000
| 0 | 0 | 0 | 0 |
python,django,datetime,django-models
| 71,781,104 | 6 | false | 1 | 0 |
What if the form.TimeField it contains a widget?
start_time = forms.TimeField(widget=TimeInput)
i've used the answers above but I cant setup the default value for it and also bear in mind I'm using django-bootstrap tags so I don't have a HTML form inputs code.
| 2 | 30 | 0 |
I have a model for events which almost always start at 10:00pm, but may on occasion start earlier/later. To make things easy in the admin, I'd like for the time to default to 10pm, but be changeable if needed; the date will need to be set regardless, so it doesn't need a default, but ideally it would default to the current date.
I realize that I can use datetime.now to accomplish the latter, but is it possible (and how) to I set the time to a specific default value?
Update: I'm getting answers faster than I can figure out which one(s) does what I'm trying to accomplish...I probably should have been further along with the app before I asked. Thanks for the help in the meantime!
|
Can I set a specific default time for a Django datetime field?
| 0 | 0 | 0 | 26,326 |
16,027,942 |
2013-04-16T02:46:00.000
| 0 | 1 | 0 | 0 |
python,c
| 16,451,937 | 4 | false | 0 | 0 |
You can use Cython for setting the necessary c types and compile your python syntax code.
| 2 | 2 | 0 |
I've written a high level motor controller in Python, and have got to a point where I want to go a little lower level to get some speed, so I'm interested in coding those bits in C.
I don't have much experience with C, but the math I'm working on is pretty straightforward, so I'm sure I can implement with a minimal amount of banging my head against the wall. What I'm not sure about is how best to invoke this compiled C program in order to pipe it's outputs back into my high-level python controller.
I've used a little bit of ctypes, but only to pull some functions from a manufacfturer-supplied DLL...not sure if that is an appropriate path to go down in this case.
Any thoughts?
|
Best way to call C-functions from python?
| 0 | 0 | 0 | 1,391 |
16,027,942 |
2013-04-16T02:46:00.000
| 0 | 1 | 0 | 0 |
python,c
| 16,028,391 | 4 | false | 0 | 0 |
you can use SWIG, it is very simple to use
| 2 | 2 | 0 |
I've written a high level motor controller in Python, and have got to a point where I want to go a little lower level to get some speed, so I'm interested in coding those bits in C.
I don't have much experience with C, but the math I'm working on is pretty straightforward, so I'm sure I can implement with a minimal amount of banging my head against the wall. What I'm not sure about is how best to invoke this compiled C program in order to pipe it's outputs back into my high-level python controller.
I've used a little bit of ctypes, but only to pull some functions from a manufacfturer-supplied DLL...not sure if that is an appropriate path to go down in this case.
Any thoughts?
|
Best way to call C-functions from python?
| 0 | 0 | 0 | 1,391 |
16,034,698 |
2013-04-16T10:27:00.000
| -1 | 0 | 0 | 1 |
python,linux,kernel,conntrack
| 50,619,225 | 2 | false | 0 | 0 |
The file ip_conntrack contains only ipv4 specific conntrack entries whereas nf_conntrack includes both ipv4 and ipv6 protocol conntrack entries.
nf_conntrack file is registered with proc file system using code in
net/netfilter/nf_conntrack_standalone.c
whereas ip_conntrack file is registered with proc file system through the code in
net/netfilter/nf_conntrack_l3proto_ipv4_compat.c
| 1 | 22 | 0 |
I'm looking for a detailed documentation about content of files /proc/net/nf_conntrack and/or /proc/net/ip_contrack on Linux systems.
Yes, I know, there are many utilities which can show me the content of these files in human readable format, but... I'd like to do it on a SOHO router, with Tomato USB firmware (by Shibby).
The optware AFAIK deprecated and the entware doesn't contain any of these utilities, so I'd like to write a script instead of them, but I didn't find a detailed description of these files :(
|
Details of /proc/net/ip_conntrack and /proc/net/nf_conntrack
| -0.099668 | 0 | 0 | 26,249 |
16,034,823 |
2013-04-16T10:34:00.000
| 0 | 0 | 0 | 1 |
python,qt4,pyqt,qprocess
| 69,134,278 | 3 | false | 0 | 0 |
pid() function is provided to keep old source code working.
Use processId() instead.
Returns the native process identifier for the running process, if available. If no process is currently running, 0 is returned.
Note: Unlike processId(), pid() returns an integer on Unix and a pointer on Windows.
| 1 | 3 | 0 |
Is there some way to read the PID of a process started with QProcess.start(...)? QProcess::pid() returns sip.voidptr and there's not much I can do with it (or I don't know how).
I want to have the PID to have the possibility to make the window active later on.
|
get PID of QProcess with python on windows
| 0 | 0 | 0 | 859 |
16,037,623 |
2013-04-16T12:53:00.000
| 1 | 1 | 0 | 0 |
python,git
| 16,037,728 | 3 | false | 0 | 0 |
git status shows how many commits you are ahead/behind the remote tracking branch. You need to perform git fetch first though, because otherwise git cannot know if anything new went into remote.
| 1 | 7 | 0 |
I'm working with custom a build system that manages a large number of git repositories and written primarily in python.
It would save me a lot of time if I could write a command that would report the current branch of all repositories, then report if the head of "branch" is the same as the head of "remotes/origin/branch".
We already have a command that will run a shell command inside every git repository, what I'm looking for is a method of getting some simply formatted information from git with regards to the relative position of branch and remotes/origin/branch. Something which is either going to be number of commits difference or a simple boolean value.
What's the method of getting this information out of git which is going to minimize the amount of parsing and processing I've got to do on the python side?
|
simplest possible way git can output the number of commits between "branch" and "remotes/origin/branch"
| 0.066568 | 0 | 0 | 2,039 |
16,044,608 |
2013-04-16T18:38:00.000
| 4 | 0 | 1 | 0 |
python,pygame
| 16,044,733 | 1 | true | 0 | 1 |
None that I'm aware of. Running a Pygame application in the browser would require some way of displaying graphics and playing sound from a remote Python interpreter. This would be pretty complicated to do, and would likely not perform very well anyway.
If you want to write games which run in a web browser, learn Javascript.
| 1 | 5 | 0 |
I was wondering if there is an online python interpreter with Pygame. It would be great if there is one, because when I share a game, I don't have to compile it first, I just send the code, and possibly upload the textures to a storage server and change the URL for the image location.
Is there an online Python interpreter with Pygame?
|
Is there an online Python interpreter with the Pygame module?
| 1.2 | 0 | 0 | 10,085 |
16,048,056 |
2013-04-16T22:12:00.000
| 3 | 0 | 0 | 0 |
python,qt,pyqt,qml,pyside
| 16,048,799 | 1 | true | 0 | 1 |
The latest version of PyQt (4.10?) works with Qt5. It does not support Qt Quick 2, AFAIK. I don't believe PySide supports either.
| 1 | 3 | 0 |
Did Qt 5 and Qt Quick supported by last Version Pyside or PyQt ?
|
Pyside or PyQt support Qt 5.0 and Qt Quick 2
| 1.2 | 0 | 0 | 2,837 |
16,048,269 |
2013-04-16T22:27:00.000
| 1 | 0 | 1 | 0 |
python,py2exe
| 16,048,795 | 2 | true | 0 | 0 |
use absolute path to point to python interpreter executable.
c:\python27\python.exe setup.py py2exe
Or install cx_Freeze, which seems much better than py2exe except the lack of onefile capability.
| 1 | 1 | 0 |
I have both python 3.2 and python 2.7 installed. I am trying to compile a file, but since the default program for opening .py files is 3.2, it gives me an error for not having py2exe installed when I run the program. I tried setting the default program to python 2.7, but it won't work because the two versions have the same name. I changed the name for python 2.7, but the program wouldn't run at all. What do I do?
|
Running py2exe with multiple versions of python installed
| 1.2 | 0 | 0 | 650 |
16,049,395 |
2013-04-17T00:19:00.000
| 0 | 0 | 0 | 0 |
python,qt,pyside
| 16,050,068 | 2 | false | 0 | 1 |
If you want an infinite progress bar or spinning wheel, just have it play, then when you finish the process, stop and/or delete the bar/icon from the screen.
| 1 | 2 | 0 |
I have a GUI developed using PySide. I have a long operation to perform from the interface, but there is no way to predict how long the operation will be. I'd like to display something to the user to tell him: the operation is in progress, please wait. Something like an infinite progress bar, or a spinning wheel. Is there a widget for such operation in Qt? I found the QProgressDialog (and QProgressBar), but it's not appropriate since I cannot predict the amount of work to perform.
|
Progress bar for event with unknown duration (PySide)
| 0 | 0 | 0 | 3,339 |
16,051,345 |
2013-04-17T04:13:00.000
| 0 | 0 | 1 | 1 |
python,python-2.7,pypy,pyscripter
| 26,822,586 | 2 | false | 0 | 0 |
PyCharm Community edition IDE by JetBrains supports pypy, or any other interpreter
Just go to File > Settings > Project INterpreter and set interpreter location
| 1 | 1 | 0 |
Maybe I am missing something, but I just downloaded pypy 2.0 beta2 windows binary (32 bit), and it seems I can run the interpreter by executing pypy.exe. However, I would like pypy to work with pyscripter and for all my old libraries to be available. Is this possible? Or is it as if I just installed a new version of python (so I would need to install all of my libraries again)? I might be confused at a fundamental level.
Thanks!
|
Making pypy available to pyscripter (or any other ide for that matter) on Windows?
| 0 | 0 | 0 | 1,140 |
16,051,571 |
2013-04-17T04:34:00.000
| 1 | 1 | 0 | 1 |
python,aptana,pydev
| 16,058,892 | 1 | true | 0 | 0 |
The only way to really know what's going on would be connecting jvisualvm (or some profiler or debugger) to your process to see what's going on (and then report an issue). On jvisualvm you can get a dump with the current processes, which may be enough already if you can say which is the thread that's running.
Note that the title should probably be 'aptana studio 3 massive cpu usage' if you're able to reproduce it there but not in pydev...
| 1 | 0 | 0 |
I am using pydev through Aptana Studio 3 on a mac. Shortly after opening up Aptana, my computer heats way up, the fans go full power, and Aptana uses over 100% cpu even when it's not doing anything. I also have pydev on eclipse, but this spike doesn't occur. Has anyone else seen this? Is there any way to stop it?
|
pydev massive cpu usage
| 1.2 | 0 | 0 | 284 |
16,052,969 |
2013-04-17T06:22:00.000
| 0 | 0 | 0 | 0 |
python,user-interface,tkinter,download,tabular
| 16,053,496 | 2 | false | 0 | 0 |
Your question is a bit confusing - you're talking about data structure and persistence then about list box (GUI stuff...)
wrt/ the data structure and persistence part a "table like" structure with "rows and columns" is easily modeled as a list of ducts or list of tuples. For the perstitance part you can serialize your list as json and write it to a file or write it as CSV ( using the stdlib CVS package) or use a SQL db.
| 1 | 0 | 0 |
I am making a download manager in python..
I want to create a table like structure with multiple columns and rows to show:
Download name, download status (paused/downloading), download size and other information interactively.
Can anyone give me ideas on how to create a table-like structure where I can easily add the data mentioned above?
|
Creating a table like structure in python
| 0 | 0 | 0 | 3,399 |
16,055,254 |
2013-04-17T08:32:00.000
| 1 | 0 | 0 | 0 |
python,django,svn,version-control,pycharm
| 16,057,411 | 2 | false | 1 | 0 |
You can open trunk/branches with multiple pycharm window. The project root should be trunk/branch root.
Normally, you don't need to switch among branches frequently.
| 1 | 0 | 0 |
I have a PyCharm Django project, versioned with SVN. Project itself been created via "Checkout from version control" function, and root of a project is a root of repository, so it includes trunk and branches.
My questions is:
- How to easily switch between feature-branches?
- Maybe Im missing something - what in that case good style to work with PyCharm and SVN?
ps
Branches in my case are created frequently - new one for every specific feature-set, and by completeness they reintegrates into trunk.
|
How to easily switch to another SVN branch in PyCharm Django Project
| 0.099668 | 0 | 0 | 2,174 |
16,055,489 |
2013-04-17T08:44:00.000
| 0 | 0 | 0 | 0 |
python,django,ironmq
| 16,065,078 | 3 | false | 1 | 0 |
There are few interesting options.
As example, you can add additional reupload workers step for deploy process. It'll guarantee
consistence between deployed application and workers.
Using own (rest) api is great idea, i like it even more than sharing models between different beings
| 2 | 0 | 0 |
My question is about web application architecture.
I have a website, my users can upload files and from this files I need to create some kind of reports for users. When user upload file it stored on my server where website hosted. File path stored in Django model field. Worker is on another server and i need to get access to my database and procces that file. I know how to use django ORM itself without URLs and other parts of django.
My question: If I need to create workers on another server, which use different django models from my website i need to copy all of the models into every worker?
For example, one worker proccess file and it need models "Report" and "User". Other worker do other actions and need "User" and "Link" models. Everytime i change model in my main website i need to change same models in my workers, also different workers can have same duplicate models. I think it's not good from architecture point.
Any suggestions on how to organize my website and workers?
|
File upload and store, then proccessing with remote worker
| 0 | 0 | 0 | 229 |
16,055,489 |
2013-04-17T08:44:00.000
| 0 | 0 | 0 | 0 |
python,django,ironmq
| 16,055,809 | 3 | false | 1 | 0 |
Why do you really need the exact same models in your workers? You can design the worker to have a different model to perform it's own actions on your data. Just design API's for your data and access it separately from your main site.
If it really necessary, Django app can be shared across multiple projects. So you can just put some generic code in a separate app (like your shared models) and put them in sourcecontrol. After an update in your main website, you can easily update the workers also.
| 2 | 0 | 0 |
My question is about web application architecture.
I have a website, my users can upload files and from this files I need to create some kind of reports for users. When user upload file it stored on my server where website hosted. File path stored in Django model field. Worker is on another server and i need to get access to my database and procces that file. I know how to use django ORM itself without URLs and other parts of django.
My question: If I need to create workers on another server, which use different django models from my website i need to copy all of the models into every worker?
For example, one worker proccess file and it need models "Report" and "User". Other worker do other actions and need "User" and "Link" models. Everytime i change model in my main website i need to change same models in my workers, also different workers can have same duplicate models. I think it's not good from architecture point.
Any suggestions on how to organize my website and workers?
|
File upload and store, then proccessing with remote worker
| 0 | 0 | 0 | 229 |
16,057,689 |
2013-04-17T10:29:00.000
| 2 | 0 | 1 | 0 |
python,variables,loops
| 16,057,890 | 4 | false | 0 | 0 |
Relying on variables's names and changing them is not the best way to go.
As people already pointed out in comments, it would be better to use a dict or a list instead.
| 1 | 4 | 0 |
I want to run a program in Python which loops several times, creating a NEW array each time - i.e. no data is overwritten - with the array named with a reference to the loop number, so that I can call it in subsequent loops. For instance, I might want to create arrays x0, x1, x2, ..., xi in a loop running from 0 to i, and then call each of these in another loop running over the same variables. (Essentially the equivalent of being able to put a variable into a string as 'string %d %(x)').
|
How to rename variables in a loop in Python
| 0.099668 | 0 | 0 | 30,400 |
16,059,476 |
2013-04-17T12:02:00.000
| 4 | 0 | 1 | 0 |
python,pyc
| 16,059,584 | 3 | false | 0 | 0 |
They are cross platform, but not cross-version and not cross-implementation. In other words, different CPython versions could have trouble with one and the same .pyc file.
And if you look at other implementations such as PyPy, IronPython, Jython etc., you won't have any luck with .pyc files at all.
Besides, .pyc files correspond to one .py file. What you (probably) have in mind are libraries which include a part written in C. They must be compiled to platform-dependent files (.pyd, .dll, .so, etc.) in order to work. As not many developers have all supported platforms available, they provide it as source and leave it to the user's system to compile it.
| 2 | 6 | 0 |
If I am right in understanding, Python compile files are cross platform. So why are most libraries released requiring a build and install?
Is it laziness on the part of the distributer, or am I wrong in saying they could simply distribute the pyc files? If this isn't the case, how do I distribute a python script file that has libraries as prerequist without requiring the user to build and install the libraries?
|
Why are python libraries not supplied as pyc?
| 0.26052 | 0 | 0 | 1,400 |
16,059,476 |
2013-04-17T12:02:00.000
| 0 | 0 | 1 | 0 |
python,pyc
| 16,059,746 | 3 | false | 0 | 0 |
The process of creating a .pyc file from a .py file is done transparently by the interpreter. The reason some installers generate them at install time is purely to avoid them having to be generated the first time the script is run - usually for speed reasons, but also so that the .pyc can end up in a system-wide (non-user-writable) directory. Unlike compiled languages, or even Python modules written in C, it is not a technical requirement that these files exist in the first place - if it was, you wouldn't be able to put your own scripts directly into python and have them run without a compile step.
Any library that strictly requires a build step before it is installed certainly has a component that compiles to native code - which certainly isn't cross-platform. For any pure-python library, it is always sufficient to put the module's source directory tree somewhere in your PYTHONPATH, having copied it directly from the archive you downloaded it in.
| 2 | 6 | 0 |
If I am right in understanding, Python compile files are cross platform. So why are most libraries released requiring a build and install?
Is it laziness on the part of the distributer, or am I wrong in saying they could simply distribute the pyc files? If this isn't the case, how do I distribute a python script file that has libraries as prerequist without requiring the user to build and install the libraries?
|
Why are python libraries not supplied as pyc?
| 0 | 0 | 0 | 1,400 |
16,062,092 |
2013-04-17T13:57:00.000
| 0 | 0 | 0 | 0 |
python,django
| 16,064,152 | 2 | false | 1 | 0 |
'objs=Modelname.objects.filter(student__in=malerep).order_by('-Votes','-student__Percentage')'
then using objs[0] i was able to access the object of the student with max votes and max percentage in case of a tie.
| 2 | 0 | 0 |
Modelname.objects.filter(student__in=malerep).order_by('-Votes','-student__Percentage')
Here i want to specifically get the student who has the maximum number of votes.
What i am trying to do is, to get the list of students who stood for an election and got some votes and then sort them based on the number of votes they got. Now if i can access the first object in this list , i can make necessary modifications for the student in the database who won the election and also get the details of the rest.
I am stuck at this point. Please help
Thanx in advance.
|
django, get an object from a list of filtered objects which has the maximum value for a field
| 0 | 0 | 0 | 131 |
16,062,092 |
2013-04-17T13:57:00.000
| 1 | 0 | 0 | 0 |
python,django
| 16,063,068 | 2 | true | 1 | 0 |
At this point, you have two choice:
First, use "max" to get the max value of certain field and use that max value to retrieve the particular student instance.
Good side, this is easy to implement; bad side, you need to hit database twice to achieve your goal.
Second, use raw(). You can perform all the complicate query you want. And that will solve your problem.
Good side, you have the maximal freedom to preform any query; bad side, require sql knowledges.
| 2 | 0 | 0 |
Modelname.objects.filter(student__in=malerep).order_by('-Votes','-student__Percentage')
Here i want to specifically get the student who has the maximum number of votes.
What i am trying to do is, to get the list of students who stood for an election and got some votes and then sort them based on the number of votes they got. Now if i can access the first object in this list , i can make necessary modifications for the student in the database who won the election and also get the details of the rest.
I am stuck at this point. Please help
Thanx in advance.
|
django, get an object from a list of filtered objects which has the maximum value for a field
| 1.2 | 0 | 0 | 131 |
16,063,191 |
2013-04-17T14:46:00.000
| 3 | 0 | 1 | 0 |
python,numpy,multiprocessing,python-import
| 16,063,388 | 1 | false | 0 | 0 |
I was wondering if every process would import the package.
Assuming the import occurs after you've forked the process, then, yes. You could avoid this by doing the import before the fork, though.
There would be a major performance hit due to multiple imports of a library.
Well, there would a performance hit if you do the import after the fork, but probably not a "major" one. The OS would most likely have all the necessary files in its cache, so it would only be reading from RAM, not disk.
Update
Just noticed this...
In fact, the main thread, or rather main process also imports numpy...
If you're already importing numpy before forking, then the imports in the subprocesses will only create a reference to the existing imported module. This should take less than a millisecond, so I wouldn't worry about it.
| 1 | 0 | 0 |
I am using multiprocessing package to spawn multiple processes that execute a function, say func (with different arguments). func imports numpy package and I was wondering if every process would import the package. In fact, the main thread, or rather main process also imports numpy and that can be easily shared between different func executing processes.
There would be a major performance hit due to multiple imports of a library.
|
Sharing imports between Python processes
| 0.53705 | 0 | 0 | 801 |
16,063,698 |
2013-04-17T15:07:00.000
| 0 | 0 | 0 | 0 |
python,scipy
| 16,064,603 | 1 | false | 0 | 0 |
After looking through the source for the SciPy function, I will just subclass it and override init where the individual inputs are combined into an array anyway.
| 1 | 0 | 1 |
I am trying to generate a radial basis function where the input variables are defined at runtime. The SciPy.interpolate.Rbf function seems to request discrete lists for each input and output variable, eg: rbf(x,y,z). This restricts you to defining fixed variables before hand.
I have tried unsuccessfully to pass a list or array of variables to the Rbf function (eg. rbf(list(x,...)) with no success. Has anyone else found a solution to this problem using this Rbf library? I would like to avoid switching to a different library or rewriting one if possible. Is there a way to generate discrete variables at runtime to feed into a function?
|
Alternative inputs to SciPy Radial Basis Functions
| 0 | 0 | 0 | 512 |
16,063,928 |
2013-04-17T15:18:00.000
| 0 | 0 | 0 | 1 |
python,svn,conflict,pysvn
| 16,092,530 | 1 | false | 0 | 0 |
I solved this by adding the prop of mime-type application/octet-stream.
This way svn would bypass the contextual merge feature.
| 1 | 0 | 0 |
I'm using SVN as a backend for a collaborative framework. That said, I want to handle ALL the updates by hand, ie: no automerge, no auto-update.
so if updating brings the following changeset:
A file1
D file2
U file3
G file4
I want to process the update and the automerge by hand.
I know that this is possible in subversion CLI (for linux) by using the non-interactive flag or marking the file as binary but I didn't found this options in the pysvn.Client module.
Any thoughts about it?
|
Handling PySVN merges by manually
| 0 | 0 | 0 | 175 |
16,068,644 |
2013-04-17T19:33:00.000
| 1 | 0 | 0 | 0 |
python,redis,persistence,reload
| 16,069,631 | 1 | false | 0 | 0 |
You can stop redis and replace dump.rdb in /var/lib/redis (or whatever file is in the dbfilename variable in your redis.conf). Then start redis again.
| 1 | 2 | 0 |
I understand how to save a redis database using bgsave. However, once my database server restarts, how do I tell if a saved database is present and how do I load it into my application. I can tolerate a few minutes of lost data, so I don't need to worry about an AOF, but I cannot tolerate the loss of, say, an hour's worth of data. So doing a bgsave once an hour would work for me. I just don't see how to reload the data back into the database.
If it makes a difference, I am working in Python.
|
How to load a redis database after
| 0.197375 | 1 | 0 | 1,375 |
16,071,286 |
2013-04-17T22:23:00.000
| 0 | 1 | 1 | 0 |
python,search,binary
| 16,071,379 | 2 | false | 0 | 0 |
You would be better working off another language. Python could do it (if you use for example,
file = open("file", "wb")
(appending the b opens it in binary), and then using a simple search, but to be honest, it is much easier and faster to do it in a lower-level language such as C.
| 1 | 0 | 0 |
Is there an easy way to work in binary with Python?
I have a file of data I am receiving (in 1's and 0's) and would like to scan through it and look for certain patterns in binary. It has to be in binary because due to my system, I might be off by 1 bit or so which would throw everything off when converting to hex or ascii.
For example, I would like to open the file, then search for '0001101010111100110' or some string of binary and have it tell me whether or not it exists in the file, where it is, etc.
Is this doable or would I be better off working with another language?
|
Workin with binary in python
| 0 | 0 | 0 | 105 |
16,072,837 |
2013-04-18T01:07:00.000
| 0 | 0 | 1 | 0 |
python,scripting
| 16,073,010 | 4 | false | 0 | 0 |
If you are on a Windows OS with IDLE installed, right-clicking a .py file should offer you the option to edit in IDLE.
| 1 | 3 | 0 |
I'm trying to open a .py script on my computer but it unfortunately keeps opening in Notepad. I've tried changing the associations on my computer but even when I browse to python.exe and click it, it won't show up as a usable program (interestingly, pythonw.exe can be associated with it but nothing opens when I click on the file that's associated to pythonw). Is there any way I can fix this issue? If not, how can I run my script from the Python interpreter by hand?
Also, I've tried reinstalling Python, and that didn't help.
|
Python is not opening .py files
| 0 | 0 | 0 | 58,573 |
16,077,481 |
2013-04-18T07:58:00.000
| 3 | 0 | 1 | 1 |
python,python-2.7,distutils,enthought
| 16,088,553 | 2 | false | 0 | 0 |
Compiler options are taken from CPython’s Makefile. IOW they are the same as the ones used to compile Python. You can override most of them on the command line as Evert described.
The global distutils.cfg is something that a sysadmin can create to set default options, not a file that is installed with Python.
| 1 | 7 | 0 |
Maybe a stupid question, but I was wondering where Python's distutils get the compiler options from? It gets some linked directories wrong and I want to correct that once and for all.
I know there should be a prefix/lib/pythonver/distutils/distutils.cfg but I can't find any distutils.cfg anywhere on the computer. Obviously I haven't got a local setup.cfg or any $HOME/.pydistutils.cfg.
I'm using the Enthought 64-bit distribution, version 7.3 (Python 2.7) on Mac OS X 10.8.3
Cheers,
U.
|
Distutils compiler options configuration
| 0.291313 | 0 | 0 | 4,646 |
16,078,856 |
2013-04-18T09:11:00.000
| 2 | 0 | 1 | 0 |
python
| 16,079,138 | 1 | true | 0 | 0 |
Are you assigning a unique incrementing ID to each record? If you are, you can create a separate table that holds just the ID of the last record fetched, that way you can only retrieve records with IDs greater than this ID. Each time you fetch, you could update this table with the new latest ID.
Let me know if I misunderstood your issue, but saving the last fetched ID in the database could be a solution.
| 1 | 0 | 0 |
I have a python script that retrieves the newest 5 records from a mysql database and sends email notification to a user containing this information.
I would like the user to receive only new records and not old ones.
I can retrieve data from mysql without problems...
I've tried to store it in text files and compare the files but, of course, the text files containing freshly retrieved data will always have 5 records more than the old one.
So I have a logic problem here that, being a newbie, I can't tackle easily.
Using lists is also an idea but I am stuck in the same kind of problem.
The infamous 5 records can stay the same for one week and then we can have a new record or maybe 3 new records a day.
It's quite unpredictable but more or less that should be the behaviour.
Thank you so much for your time and patience.
|
How to check if data has already been previously used
| 1.2 | 1 | 0 | 85 |
16,085,288 |
2013-04-18T14:08:00.000
| 3 | 1 | 1 | 0 |
python,pyramid
| 16,088,122 | 1 | true | 0 | 0 |
It's not a "project name". It's the name of a python package. Yes, you'll have to search/replace and rename that package everywhere in your code. You're probably better off just starting from a new project with the right name if you are only at the tutorial stage.
| 1 | 3 | 0 |
I am just starting out with pyramid and I am doing the tutorial. I would like to use some of the tutorial code as a starting point for the project that I am going to start, but I don't want to keep the project name as tutorial. It seems like once you give a project a name that name is used in many places. Is there a way to easily change the project name? I am sure I will have to manually edit some stuff. Just wondering if there may be an easy way to do this.
|
How do you change the name of a pyramid project?
| 1.2 | 0 | 0 | 468 |
16,087,386 |
2013-04-18T15:42:00.000
| 0 | 0 | 1 | 0 |
python
| 16,087,778 | 4 | false | 0 | 0 |
You can multiply by 1.0 in order to get the value as float
amount= 125
tip1 = 15
tip2 = 20
print "tip1=" , (amount * (1.0 * tip1/100))
print "tip2=" , (amount * (1.0 * tip2/100))
| 1 | 0 | 0 |
i am VERY new to programming and i am currently learning python from a book i purchased.
At the end of each chapter it has challenges for you to write programs based on what you have learnt in the previous chapter.It is asking to create a program for a user to enter an amount for a restaurant bill and tells them two amounts a 15% and 20% tip but it has not discussed in the book how to work out percentages in python. I have tried looking online and nothing shows up regarding this. I am sure it is simple to do but i don't won't to carry on further with the book before understanding this.
|
How do i create a tipping program for python?
| 0 | 0 | 0 | 9,038 |
16,088,764 |
2013-04-18T16:48:00.000
| 1 | 0 | 0 | 0 |
android,python,kivy
| 16,287,866 | 1 | false | 1 | 1 |
I'm looking for the same thing. I too am looking at Kivy. The possible solutions I can see to audio is hooking in a 3rd party application as a "recipe" in Kivy.
There is aubio, which apparently can be compiled for iOS/Android (see stackoverflow question regarding this), but I believe you have to get your own audio source for it, which could be potentially handled by the audiostream subproject in kivy.
Kivy/audiostream imports the core libpd project it appears, so you can use libpd python bindings. I think this is the path of least resistance, but I had issues when trying to run the examples.
Both of these approaches, I think could work but both need some effort to be able to start using.
| 1 | 1 | 0 |
I am trying to write a metronome application in Python, and I intend to publish the application for Android and iOS. I have found a few cross-platform frameworks like Kivy, but their audio support is lacking. More specifically, I need very precise audio timing and I can't rely on thread timing or events. I want to write audio data directly to the device's audio output, or create a MIDI file that can be played on the fly. The problem is, I cannot find any suitable framework for this task.
I know that many games have been written for Android in Python, and those games have excellent and precise sound timing. I need help finding either:
a way to create and play MIDI files on the fly in Android with Python,
a Python framework for Android with a suitable audio API to write sound directly to an audio device, or at least play audio with very accurate timing.
Thanks!
|
Android Audio API in Python
| 0.197375 | 0 | 0 | 1,422 |
16,089,089 |
2013-04-18T17:04:00.000
| 91 | 0 | 1 | 0 |
python,markdown,ipython,mathjax
| 53,228,544 | 7 | false | 0 | 0 |
Put two backslashes in front of dollar signs. For example:
Some prices: \\$3.10, \\$4.25, \\$8.50.
(running Jupyter notebook server 5.7.0)
| 4 | 52 | 0 |
I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.
ANy ideas on how to get just the dollar sign?
Thanks
|
Escaping dollar sign in ipython notebook
| 1 | 0 | 0 | 38,570 |
16,089,089 |
2013-04-18T17:04:00.000
| 7 | 0 | 1 | 0 |
python,markdown,ipython,mathjax
| 16,095,493 | 7 | false | 0 | 0 |
If you use <span>$</span>, MathJax won't process it as a delimiter. You should be able to enter that in Markdown. For example, I've used that here: $ This is not math $.
| 4 | 52 | 0 |
I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.
ANy ideas on how to get just the dollar sign?
Thanks
|
Escaping dollar sign in ipython notebook
| 1 | 0 | 0 | 38,570 |
16,089,089 |
2013-04-18T17:04:00.000
| 11 | 0 | 1 | 0 |
python,markdown,ipython,mathjax
| 29,808,632 | 7 | false | 0 | 0 |
You can escape $ with math mode by using a backslash. Try $\$$
| 4 | 52 | 0 |
I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.
ANy ideas on how to get just the dollar sign?
Thanks
|
Escaping dollar sign in ipython notebook
| 1 | 0 | 0 | 38,570 |
16,089,089 |
2013-04-18T17:04:00.000
| 3 | 0 | 1 | 0 |
python,markdown,ipython,mathjax
| 38,617,452 | 7 | false | 0 | 0 |
I'm aware that this topic is old, but it's still somehow the first google result and its answers are incomplete.
You can also surround the $ with `backticks`, the same way that you would display code in Jupyter.
So $ becomes `$`, and should display without error
| 4 | 52 | 0 |
I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.
ANy ideas on how to get just the dollar sign?
Thanks
|
Escaping dollar sign in ipython notebook
| 0.085505 | 0 | 0 | 38,570 |
16,092,153 |
2013-04-18T20:09:00.000
| 1 | 0 | 1 | 0 |
python
| 16,092,297 | 5 | false | 0 | 0 |
There is a simple solution to this problem, however there are also much faster solutions which you may want to look at after you've implemented the simple version. What you want to be doing is checking each position in the string you're search over and seeing if the string you're searching for starts there. This is inefficient but works well enough for most purposes, if you're feeling comfortable with that then you may want to look at Boyer-Moore string searching, which is a much more complex solution but more efficient. It exploits the fact that you can determine that if a string doesn't start at a certain point you may not need to check some of the other positions.
| 1 | 3 | 0 |
I wish to create a 'find' procedure myself, which is capable of finding a sub-string in a string and it also should be able to read a string backward and give position of match- just like the original find function in python.
I am unable to figure out what logic should I use- also I don't know how the original find functions?
I just started to use python and am fairly new to programming as well.
Any guidance shall be highly appreciated!
|
How does find procedure work in python
| 0.039979 | 0 | 0 | 1,649 |
16,094,676 |
2013-04-18T23:17:00.000
| 1 | 0 | 1 | 0 |
python,hash,cryptography,sha512
| 16,094,803 | 2 | false | 0 | 0 |
It's equally as likely as any other hash value, or should be.
| 1 | 0 | 0 |
I was just thinking about numbers repeating in hashes and I was wondering if it was possible for half of a sha512 hash to consist of 64 consecutive zeros.
|
Is it possible for a sha512 hash to start with 64 zeros?
| 0.099668 | 0 | 0 | 682 |
16,095,220 |
2013-04-19T00:19:00.000
| -1 | 0 | 1 | 0 |
python,counter
| 16,095,280 | 4 | false | 0 | 0 |
You could change the __str__ method of the counter class by going into the source code for the collections module, but I wouldn't suggest that as that permanently modifies it. Maybe just changing what you print would be more beneficial?
| 1 | 2 | 0 |
So when I print the Counter (from collections import Counter) to a file I always get this the literal Counter ({'Foo': 12})
Is there anyway to make the counter not write out so literally? So it would instead write {'Foo' : 12} instead of Counter({'Foo' : 12}).
Yeah it's picky, but I am sick of grep'n the thing out of my files afterward.
|
Can you make Counter not write-out "Counter"?
| -0.049958 | 0 | 0 | 831 |
16,098,570 |
2013-04-19T06:29:00.000
| 0 | 0 | 0 | 1 |
python,mysql,google-app-engine,google-cloud-datastore,web-scraping
| 16,131,039 | 1 | false | 1 | 0 |
Based on what I know about your app it would make sense to use memcache. It will be faster, and will automatically take care of things like expiring stale cache entries.
| 1 | 0 | 0 |
I need to scrap about 40 random webpages at the same time.These pages vary on each request.
I have used rpcs in python to fetch the urls and scraped the data using BeautifulSoup. It takes about 25 seconds to scrap all the data and display on the screen.
To increase the speed i stored the data in appengine datastore so that each data is scraped only once and can be accessed from there quickly.
But the problem is-> as the size of the data increases in the datastore, it is taking too long to fetch the data from the datastore(more than the scraping).
Should i use memcache Or shift to mysql? Is mysql faster than gae-datastore?
Or is there any other better way to fetch the data as quickly as possible?
|
What is the fastest way to get scraped data from so many web pages?
| 0 | 1 | 0 | 402 |
16,102,005 |
2013-04-19T09:58:00.000
| 0 | 0 | 1 | 0 |
python,file,io
| 16,102,297 | 2 | false | 0 | 0 |
Just rewrite the file. Read it into some data format (string or list of strings with readlines()) change the char you want and then write the data to the file again. Actually it would be a more sane thing to do than performing a high-precision operation within the file.
| 1 | 1 | 0 |
I know the position of file pointer,and I want to delete the preceding char.
Of course I can create another file,writing in the left content,which is not the way I want.
In other word,I want to do this "inplace".Thank you.
|
Python, How to do deleting work in a file?
| 0 | 0 | 0 | 52 |
16,107,658 |
2013-04-19T15:02:00.000
| 1 | 0 | 0 | 1 |
python,windows,powershell,path,exe
| 16,108,206 | 1 | false | 0 | 0 |
Making the comments an answer for future reference:
Have a ; at the end of the PATH and logout and log back in.
| 1 | 1 | 0 |
I've had my python program removed from windows a while ago, and recently downloaded python2.7.4 from the main site, but when I type "python" in the Windows PowerShell(x86) prompt from C:, I get the message "'python' is not recognized as an internal or external command, operable program or batch file.", and I'd like to find out how to fix this.
I get the same message when I'm in the actual python27 folder (and the python.exe is indeed there). However, when I type in .\python, it runs as expected, and my computer can run other .exe's just fine. I'm using Windows 7 Home Premium Service Pack 1 on a Sony VAIO laptop. I'm not very familiar with the inner workings of my computer, so I'm not sure where to look from here.
My current path looks like this, with the python folder at the very end:
%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Adobe\AGL;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Java\jdk1.6.0_23\bin;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\MySQL\MySQL Workbench CE 5.2.42;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Program Files (x86)\apache-ant-1.8.4\bin;C:\Program Files\TortoiseSVN\bin;C:\Windows\system32\WindowsPowerShell\v1.0\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Adobe\AGL;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Java\jdk1.6.0_23\bin;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\MySQL\MySQL Workbench CE 5.2.42;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Program Files (x86)\apache-ant-1.8.4\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.6.0_23\bin;C:\Python27
|
Can't open python.exe in Windows Powershell
| 0.197375 | 1 | 0 | 1,533 |
16,108,560 |
2013-04-19T15:49:00.000
| 0 | 0 | 0 | 1 |
python,django,rabbitmq,celery
| 16,154,276 | 1 | false | 1 | 0 |
Replace this names: coordinator with rabbitmq (or some other broker kombu supports) and users with celery workers.
I am pretty sure you can do all you need (and much more) just by configuring celery / kombu and rabbitmq and without writing too many (if any) lines of code.
small note: Celery features scheduled tasks.
| 1 | 2 | 0 |
I have a service that needs a sort of coordinator component. The coordinator will manage entities that need to be assigned to users, taken away from users if the users do not respond on a timely manner, and also handle user responses if they do response. The coordinator will also need to contact messaging services to notify the users they have something to handle.
I want the coordinator to be a single-threaded process, as the load is not expected to be too much for the first few years of usage, and I'd much rather postpone all the concurrency issues to when I really need to handle them (if at all).
The coordinator will receive new entities and user responses from a Django webserver. I thought the easiest way to handle this is with Celery tasks - the webserver just starts a task that the coordinator consumes on its own time.
For this to happen, I need the coordinator to contain a celery worker, and replace the current worker mainloop with my own version (one that checks the broker for a new message and handles the scheduling).
How feasible is it? The alternative is to avoid Celery and use RabbitMQ directly. I'd rather not do that.
|
Embed a celery worker in my own code
| 0 | 0 | 0 | 515 |
16,112,209 |
2013-04-19T19:32:00.000
| 5 | 0 | 1 | 0 |
python,pandas
| 16,225,932 | 2 | true | 0 | 0 |
As Wouter said, the recommended method is to convert the dict to a pandas.Series and multiple the two objects together:
result = df * pd.Series(myDict)
| 1 | 4 | 1 |
Suppose I have a pandas DataFrame with two columns named 'A' and 'B'.
Now suppose I also have a dictionary with keys 'A' and 'B', and the dictionary points to a scalar. That is, dict['A'] = 1.2 and similarly for 'B'.
Is there a simple way to multiply each column of the DataFrame by these scalars?
Cheers!
|
Multiplying Columns by Scalars in Pandas
| 1.2 | 0 | 0 | 9,702 |
16,114,358 |
2013-04-19T22:23:00.000
| 0 | 1 | 0 | 0 |
php,python,html,networking
| 16,115,090 | 4 | false | 1 | 0 |
Chrome provides a built-in tool for seeing the network connections. Press Ctrl+Shift+J to open the JavaScript Console. Then open the Network tab to see all of the GET/POST calls.
| 1 | 0 | 0 |
is there a way to trace all the calls made by a web page when loading it? Say for example I went in a video watching site, I would like to trace all the GET calls recursively until I find an mp4/flv file. I know a way to do that would be to follow the URLs recursively, but this solution is not always suitable and quite limitative( say there's a few thousand links, or the links are in a file which can't be read). Is there a way to do this? Ideally, the implementation could be in python, but PHP as well as C is fine too
|
Tracing GET/POST calls
| 0 | 0 | 1 | 98 |
16,114,939 |
2013-04-19T23:35:00.000
| 0 | 0 | 0 | 0 |
python,sqlalchemy
| 17,140,662 | 2 | true | 0 | 0 |
In the end I decided that working with the tuple returned by the query wasn't a problem.
| 1 | 0 | 0 |
My little website has a table of comments and a table of votes. Each user of the website gets to vote once on each comment.
When displaying comments to the user, I will select from the comments table and outerjoin a vote if one exists for the current user.
Is there a way to make a query where the vote will be attached to the comment through comment.my_vote ?
The way I'm doing it now, the query is returning a list for each result - [comment, vote] - and I'm passing that directly to my template. I'd prefer if the vote could be a child object of the comment.
|
SqlAlchemy: Join onto another object
| 1.2 | 1 | 0 | 149 |
16,116,446 |
2013-04-20T04:05:00.000
| 6 | 0 | 1 | 0 |
python,variables,definition,literals
| 16,116,484 | 2 | false | 0 | 0 |
In any programming language a Literal is a constant value, where as identifiers can change their values. Identifiers can store literals and process them further. Identifiers are name given to variables.
1, 1.5, 'a', "abc", etc. are examples for literals. But in the statement x=123, x is a variable and 123 is a Literal.
| 1 | 12 | 0 |
I'm a beginner user for Python, but I get confused between literal and variables.
This is what I know about a literal: "a"+"b"
And variables: sentence="a"+"b"
|
What is the difference between literal and variables in Python?
| 1 | 0 | 0 | 23,504 |
16,117,044 |
2013-04-20T05:37:00.000
| 0 | 1 | 0 | 1 |
python,shell,python-2.7,putty
| 16,117,169 | 2 | false | 0 | 0 |
On the server, you can install tmux or screen. These programs run the program in the background and enable you to open a 'window', If I use tmux:
Open tmux: tmux
Detach (run in background): press Ctrl-b d
reattach (open a 'window'): tmux attach
| 1 | 0 | 0 |
I had putty on one server and run a python script available on that server. That script keep on throwing output on terminal. Later on, my internet connection went off but even then i was expecting my script to complete it job as script is on running on that server. But when internet connection resumed, I found that script has not done its job.
So is this expected ? If yes, then what to do to make sure that script runs on server even though internet connection goes off in-between?
Thanks in advance !!!
|
to keep the script running even after internet connection goes off
| 0 | 0 | 1 | 289 |
16,120,373 |
2013-04-20T12:30:00.000
| 0 | 1 | 0 | 1 |
python,c,ipc
| 16,121,274 | 3 | false | 0 | 0 |
How about writing the weight-lifting code as a library in C and then providing a Python module as wrapper around it? That is actually a pretty usual approach, in particular it allows prototyping and profiling in Python and then moving the performance-critical parts to C.
If you really have a reason to need two processes, there is an XMLRPC package in Python that should facilitate such IPC tasks. In any case, use an existing framework instead of inventing your own IPC, unless you can really prove that performance requires it.
| 1 | 9 | 0 |
I have a an application with two processes, one in C and one in Python. The C process is where all the heavy lifting is done, while the Python process handles the user interface.
The C program writes to a large-ish buffer 4 times per second, and the Python process reads this data. To this point the communication to the Python process has been done by AMQP. I would much rather setup some for of memory sharing between the two processes to reduce overhead and increase performance.
What are my options here? Ideally I would simply have the Python process read the physical memory straight (preferable from memory and not from disk), and then taking care of race conditions with Semaphores or something similar. This is however something I have little experience with, so I'd appreciate any help I can get.
I am using Linux btw.
|
How can I handle IPC between C and Python?
| 0 | 0 | 0 | 12,308 |
16,120,717 |
2013-04-20T13:06:00.000
| 1 | 0 | 0 | 0 |
python,html,web-applications,cgi
| 16,121,984 | 2 | false | 1 | 0 |
First you will need to understand HTTP. It is a text based protocol.
I assume by "web site" you mean User-Agent, like FireFox.
Now, your talking about an input box, well this will mean that you've already handled an HTTP request for your content. In most web applications this would have been several requests (one for the dynamically generated application HTML, and more for the static css and js files).
CGI is the most basic way to programmatically inspect already parsed HTTP requests and create HTTP responses from objects you've set.
Now your application is simple enough where you can probably do all the HTTP parsing yourself to gain a basic understanding of what's going on, but you will still need to understand how to develop a server that can listen on a socket.
To avoid all that just find a Python application server that has already implemented all of the above and much more. There are many python application servers to choose from. Use one with a small learning curve for something as simple as above. Some are labeled as "micro-frameworks" in this genre.
| 1 | 0 | 0 |
I have zero experience with website development but am working on a group project and am wondering whether it would be possible to create an interaction between a simple html/css website and my python function.
Required functionality:
I have to take in a simple string input from a text box in the website, pass it into my python function which gives me a single list of strings as output. This list of strings is then passed back to the website. I would just like a basic tutorial website to achieve this. Please do not give me a link to the CGI python website as I have already read it and would like a more basic and descriptive view as to how this is done. I would really appreciate your help.
|
How to Combine Html + CSS code with python function?
| 0.099668 | 0 | 0 | 3,480 |
16,122,228 |
2013-04-20T15:50:00.000
| 0 | 0 | 1 | 0 |
python,json,api
| 16,122,376 | 2 | false | 0 | 0 |
Suppose all transactions contain the same structure, it is perfectly fine to use a for item in json_tuple to deal with the transactions.
It all really depends on what you want to do with the data set.
| 1 | 0 | 0 |
Hy, still a python beginner, I am looking for help pointing me in the right direction:
I am trying to build sort of a database of api answers from bitstamp listing the transactions on bitstamp.
The api-call gives all transactions in a time frame, output is json.
After processing the api output with json.loads() output can be
no transaction: []
one transaction: {'key':'value',....}
many transactions: {'key':'value',....} {'key':'value',....} {'key':'value',....}
As I understand this:
ok: if x=='[]':return
ok: for key in x: print(x[key])
seems to be a tuple. dont know how to deal with, I would like to make as many dictionarys out of the transactions-tuple as there are. So sort of
for every tuple make dict[x] with tuple in it.
I know some mysql, in the end I want to have a table with one transaction per line, sorted chronologically, so i can build a chart of the transaction prices or some sort of 2-dimensional array, that i can acces by array[x][y].
I dont aks for a complete solution, just a short idea how it could/should be done, so I can start my way through the tutorials :)
p.s.: reason for json.load is, that the native output is like [{key:value, ..} {key:value,...}]
|
Json output with none, one or many dictionaries in a tubple - best way to manipulate? (Bitstamp transaction list)
| 0 | 0 | 0 | 144 |
16,125,352 |
2013-04-20T21:25:00.000
| 0 | 0 | 0 | 0 |
python,django
| 32,982,612 | 2 | false | 1 | 0 |
yeah, like Daniel said, so I add the next
posted = [{k.replace('person__',''):v} for k, v in request.POST.items() if k.startswith('person__')]
then I can use a model form with posted data
| 1 | 0 | 0 |
I have a form on my site that allows the user to add names to an object. The user can hit a plus button to add another name or a minus button to remove a name. I need to be able to easily pull all POST variables that start with a name.
For example. A user adds two names so we have two text boxes names 'name0' and 'name1'. Is there a way that I can pull those two values without know how many I may have?
One reason I want to do this without knowing is because they could do any number of add and remove functions on the list of names. So I could end up with this:
'name2', 'name10', 'name11'
for the names that come in. I don't want to have to know the exact values. I just want to pull all POST variables that start with 'name'.
Is this possible?
|
Getting POST values from a Django request when they start with the same string
| 0 | 0 | 0 | 1,678 |
16,125,684 |
2013-04-20T22:06:00.000
| 0 | 0 | 1 | 0 |
python,biopython
| 16,467,481 | 1 | true | 0 | 0 |
BetweenPosition is basically obsolete and can be ignored.
| 1 | 0 | 0 |
What is the difference between "BetweenPosition" and "WithinPosition" in Biopython.
It seems like one of them is inclusive of the endpoints, and the other is not -- but the description in the Biopython documentation didn't seem to describe that explicitly.
|
BetweenPosition and WithinPosition in Biopython
| 1.2 | 0 | 0 | 48 |
16,126,734 |
2013-04-21T00:27:00.000
| 0 | 0 | 1 | 0 |
python,init
| 16,126,755 | 3 | false | 0 | 0 |
Yes - when inheriting class invokes __init__() of the parent class. AFAIK, this is the only valid case of calling __init__() explicitly.
| 1 | 9 | 0 |
I am having a hard time figuring out the purpose some code that I've come across.
The code has a class Foo, which has an __init__ method that takes multiple arguments. From what I've learned of Python so far, by calling Foo('bar'), it will pass this string as a parameter to __init__ (which I think is supposed to be the equivalent of a constructor).
But the issue I am having is that the code I am looking at is calling Foo.__init__('bar') directly. What is the purpose of this? I almost feel that I am missing some other purpose behind __init__.
|
What is the purpose of calling __init__ directly?
| 0 | 0 | 0 | 26,811 |
16,128,593 |
2013-04-21T06:33:00.000
| 1 | 0 | 1 | 0 |
python,algorithm,full-text-search
| 16,128,660 | 4 | true | 0 | 0 |
Maybe build a hashtable with the counts for as many n-tuples as you can afford storage for? You can prune the trees that don't appear anymore. I wouldn't call it "approximation", but could be "upper bounds", with assurance to detect strings that don't appear.
So, say you can build all 4-tuples.
Then to count occurrences for "ABCDEF" you'd have the minimum of count(ABCD), count(BCDE), count(CDEF). If that is zero for any of those, the string is guaranteed to not appear. If it is one, it will appear at most once (but maybe not at all).
| 2 | 4 | 0 |
I have a large static binary (10GB) that doesn't change.
I want to be able to take as input small strings (15 bytes or lower each) and then to determine which string is the least frequent.
I understand that without actually searching the whole binary I wont be able to determine this exactly, so I know it will be an approximation.
Building a tree/hash table isn't feasible since it will require about 256^15 bytes which is ALOT.
I have about 100GB of disk space and 8GB RAM which will be dedicated into this task, but I can't seem to find any way to accomplish this task without actually going over the file.
I have as much time as I want to prepare the big binary, and after that I'll need to decide which is the least frequent string many many times.
Any ideas?
Thanks!
Daniel.
(BTW: if it matters, I'm using Python)
|
How many times string appears in another string
| 1.2 | 0 | 0 | 199 |
16,128,593 |
2013-04-21T06:33:00.000
| 0 | 0 | 1 | 0 |
python,algorithm,full-text-search
| 16,130,707 | 4 | false | 0 | 0 |
Because you have a large static string that does not change you could distinguish one-time work preprocessing this string which never has to be repeated from the work of answering queries. It might be convenient to do the one-time work on a more powerful machine.
If you can find a machine with an order of magnitude or so more internal storage you could build a suffix array - an array of offsets into the stream in sorted order of the suffixes starting at the offset. This could be stored in external storage for queries, and you could use this with binary search to find the first and last positions in sorted order where your query string appears. Obviously the distance between the two will give you the number of occurrences, and a binary search will need about 34 binary chops to do 16 Gbyte assuming 16Gbytes is 2^34 bytes so each query should cost about 68 disk seeks.
It may not be reasonable to expect you to find that amount of internal storage, but I just bought a 1TB USB hard drive for about 50 pounds, so I think you could increase external storage for one time work. There are algorithms for suffix array construction in external memory, but because your query strings are limited to 15 bytes you don't need anything that complicated. Just create 200GB of data by writing out the 15-byte string found at every offset followed by an 5-byte offset number, then sort these 20-byte records with an external sort. This will give you 50Gbytes of indexes into the string in sorted order for you to put into external storage to answer queries with.
| 2 | 4 | 0 |
I have a large static binary (10GB) that doesn't change.
I want to be able to take as input small strings (15 bytes or lower each) and then to determine which string is the least frequent.
I understand that without actually searching the whole binary I wont be able to determine this exactly, so I know it will be an approximation.
Building a tree/hash table isn't feasible since it will require about 256^15 bytes which is ALOT.
I have about 100GB of disk space and 8GB RAM which will be dedicated into this task, but I can't seem to find any way to accomplish this task without actually going over the file.
I have as much time as I want to prepare the big binary, and after that I'll need to decide which is the least frequent string many many times.
Any ideas?
Thanks!
Daniel.
(BTW: if it matters, I'm using Python)
|
How many times string appears in another string
| 0 | 0 | 0 | 199 |
16,128,864 |
2013-04-21T07:20:00.000
| 0 | 0 | 0 | 1 |
python,google-app-engine,google-cloud-storage
| 16,135,479 | 2 | false | 1 | 0 |
The data file doesnt "need to be in memory" and if you try that you will run oom.
If you can process it sequentially open it as a filestream. Ive done that with blobstore, should be similar
| 1 | 3 | 0 |
I'm required to process large files, up to 2GB, in GAE (I'm using Python).
of course I'll be running the code on a backend, however since a local storage isn't available the data will need to be in memory.
is there a file descriptor like wrapper for boto or other cloud storage supported protocol?
or other recommended technique?
Thanks,
Shay
|
processing large cloud storage files in app engine
| 0 | 0 | 0 | 281 |
16,131,781 |
2013-04-21T13:44:00.000
| 0 | 0 | 0 | 0 |
.net,com,interop,ironpython
| 16,272,641 | 1 | true | 0 | 1 |
This is just for anyone who ever runs into this question with a similar problem - the problem was that the parameters of the functions were of type out and ref in C#. The function could not be invoked because there was no corresponding function signature. I had to use clr.Reference[] to explicitly create references for the function parameters.
I guess when using an external COM objects one should stop thinking python and start thinking .net or C#...
| 1 | 0 | 0 |
Im trying to write an IronPython app that uses a COM object interface. I manage to import it using clr.AddReference, and manage also to call some of the functions, create objects, etc.
However at a certain point when trying to call a function I get :
StandardError: Error while invoking GetK300RZ.
(GetK300RZ being the function name.)
Why is this happening to me? What does this error mean exactly? could this be related to the 'embed interop types' option?
I would greatly appriciate any insight as to how to get around this problem...
Thanks
|
IronPython - error while invoking
| 1.2 | 0 | 0 | 126 |
16,133,206 |
2013-04-21T16:07:00.000
| 1 | 0 | 0 | 0 |
python,matplotlib,plot
| 16,133,372 | 2 | false | 0 | 0 |
I found out that subplot() should be called before the plot(), issue resolved.
| 1 | 1 | 1 |
I am plotting some data using pylab and everything works perfect as I expect. I have 6 different graphs to plot and I can individually plot them in separate figures. But when I try to subplot() these graphs, the last one (subplot(3,2,6)) doesn't show anything.
What confuses me is that this 6th graph is drawn perfectly when put in a separate figure but not in the subplot - with identical configurations.
Any ideas what may be causing the problem ?
|
Python Pylab subplot bug?
| 0.099668 | 0 | 0 | 375 |
16,133,352 |
2013-04-21T16:19:00.000
| 1 | 0 | 1 | 0 |
python-3.x,pygame
| 16,134,693 | 1 | true | 0 | 1 |
The installation packages for pygame are incompatible with python 3.x However, the vast majority of the pygame modules have been ported to python 3.x, so really it's simply a matter of moving the Pygame modules to your python 3.x dist-packages.
The scrap, _movie, surfarray for Numeric, and threads modules are the ones that have NOT been ported yet.
| 1 | 0 | 0 |
I have downloaded and installed pygame and I know where it is (/usr/lib/python2.7/dist-packages). I am trying to get the program consisting of the line 'import pygame' to recognize its existence but I keep getting 'ImportError: No module named pygame'. How would I get it to work?
|
Why can't the program recognize pygame?
| 1.2 | 0 | 0 | 691 |
16,134,927 |
2013-04-21T18:51:00.000
| 7 | 0 | 0 | 1 |
python,security,google-app-engine,nosql,google-cloud-datastore
| 16,140,194 | 1 | true | 1 | 0 |
Standard SQL injection techniques rely on the fact that SQL has various statements to either query or modify data. The datastore has no such feature. The GQL (the query language for the datastore) can only be used to query, not modify. Inserts, updates, and deletes are done using a separate method that does not use a text expression. Thus, the datastore is not vulnerable to such injection techniques. In the worst case, an attacker could only change the query to select data you did not intend, but never change it.
| 1 | 2 | 0 |
Is there any SQL injection equivalents, or other vulnerabilities I should be aware of when using NoSQL?
I'm using Google App Engine DB in Python2.7, and noticed there is not much documentation from Google about security of Datastore.
Any help would be appreciated!
|
NDB/DB NoSQL Injection Google Datastore
| 1.2 | 1 | 0 | 973 |
16,139,169 |
2013-04-22T03:54:00.000
| 0 | 0 | 0 | 0 |
python,django
| 16,141,722 | 1 | true | 1 | 0 |
There are several ways to determine user activity:
1) Use javascript to send periodic requests to server.
+: You will be able to determine user activity despite he actively working on site or just keep open window.
-: Too many requests.
2) Use django middleware
-: Can`t determine user activity if he keeps only open window
3) Use asynchronous framework to keep long-lived connection. For example tornado.
It is cleanest way but the most labor-intensive.
| 1 | 0 | 0 |
Is there a way to see if a user is currently logged in and active on a site?
For example, I know you can check the authentication token of the user and see if he is still 'actively logged in', but this doesn't tell me much, since the user could technically be logged in for two weeks, though only actively on the site for one minute of that duration. last_login would be equally unhelpful.
What would be a good method in django to check to see if the user is currently active? I have done this in Google Analytics, but was wondering how I could do an entirely-django approach.
|
How to determine if user is currently active on site in Django
| 1.2 | 0 | 0 | 799 |
16,139,929 |
2013-04-22T05:22:00.000
| 0 | 1 | 1 | 0 |
python,gevent,monkeypatching
| 16,140,423 | 1 | false | 0 | 0 |
Normally there's just one entry in sys.modules for each module. ie, the same module object is shares, so it affects the module as long as it's imported the same way.
It's possible to have the same module in sys.modules under two or more entries if it is imported differently.
| 1 | 2 | 0 |
In a file a.py, I have the lines:
import gevent
gevent.monkey.patch_all()
import b
# etc, etc
In file b.py is it necessary to monkey patch again? Is there anything wrong with monkey patching multiple times?
|
Is Python's monkey patching local to the current module?
| 0 | 0 | 0 | 1,320 |
16,142,113 |
2013-04-22T08:00:00.000
| 2 | 0 | 1 | 0 |
python,encryption,tkinter
| 16,146,593 | 5 | false | 0 | 1 |
You don't need, or even want, complex encryption for passwords--and what you are describing is a password, not a key (it just grants access, it doesn't encrypt the data). Current best practice is to store passwords salted and hashed. That is, when the user creates a new account and enters a password, you build a string from the password plus user name plus a "salt" (which is just a small string that's the same for everyone on your site--this is to thwart rainbow table attacks). Then you run that string through a good hash algorithm--something like SHA1 is fine (even MD5 is more than adequate, despite reports to the contrary). You certainly don't need anything like AES. Anyway, now that you have a hash, you store the hash in the database, and not the password. Even a strong cipher like AES is useless if don't do the rest right.
Next time the user logs in, you do the same: add his password to user name and salt, hash that, and compare the hash to what's stored. There's no way, even in principle, for you to know what his password was, so no way for an attacker to find it even if they get your database and know your algorithm and salt.
| 1 | 1 | 0 |
issue
I am writing an application in python. It takes care of contacts and other information about a person. I want to prompt the user for a master key every time that he/she wants to perform a major operation. I have everything figured out. The whole application is ready and works well. But I store the master key in a file. This file is easily readable in the plain text form. And my friends who tried using this said that the software is useless if I don't apply a strong encryption algorithm as users would simply trust the application with the details that can be easily stolen.
goal
To store the master key in a form that can be deciphered (or read) only by my program.
other things
there is an option for the user to change the master key.
The master key will be read and deciphered only once. At the start of the program. It will be stored in a variable then and and used from this variable.
It is a GUI application. And I am using python Tkinter.
details
Please note that the data is stored using another encryption that is not un breakable but enough for this kind of information.
I have not used any database to store the information.
The only data to be encrypted is a master key. It is an alphanumeric string of length anywhere from 7 to 80 characters.
specs
1. Python 2.7
2. Tkinter 8.5
3. Linux Mint 14
|
Encryption -- how to do it
| 0.07983 | 0 | 0 | 859 |
16,143,460 |
2013-04-22T09:19:00.000
| 6 | 0 | 0 | 0 |
python,python-3.x,drag-and-drop,tkinter
| 16,145,812 | 2 | true | 0 | 1 |
Tkinter has no built-in support for dragging and dropping between applications. Tkdnd is, AFAIK, the only way to accomplish it without writing the low level code yourself.
| 1 | 9 | 0 |
What is the correct/official/proper/recommended way of accomplishing drag/drop in tkinter? My documentation section 24.1.1 includes:
Tkdnd Drag-and-drop support for Tkinter. This is experimental and
should become deprecated when it is replaced with the Tk DND.
but I can find no other official documentation. Does Tkinter have drag/drop support at all? Is this something version dependant? Is this something not yet included in tk(tcl) which will then filter through to tkinter?
I should stress that I am talking about drag/drop between different applications and that I am currently using python 2 (although any solution which relies on python 3 would still be of interest).
|
Drag and Drop in Tkinter?
| 1.2 | 0 | 0 | 11,082 |
16,144,431 |
2013-04-22T10:06:00.000
| 1 | 0 | 0 | 0 |
python,django,security,django-models,django-forms
| 16,148,219 | 1 | true | 1 | 0 |
Yes. If these cases were NOT secure they would be security issues and be patched quickly if discovered.
| 1 | 2 | 0 |
Sometimes I have a form that is a bit complicated in logic, and needs validation beyond just type checking or regex, so I end up handling data directly from request.POST['item'], like:
datetime.strptime(request.POST['item'], FORMAT)
MyModel.objects.filter(name=request.POST['item2']
As far as I know, the first example would throw an exception at worst, so no security problems, and for the second example, the Django ORM would prevent SQLi. Is that correct?
I also have regex in the URLConf, so I guess it would be safe to handle the data taken from the URL in views.py because URLConf already validated it with regex, right?
|
Django: Risks in handling data directly from request.POST["item"]
| 1.2 | 0 | 0 | 159 |
16,145,317 |
2013-04-22T10:52:00.000
| 0 | 0 | 1 | 0 |
python,class,pickle,typechecking,isinstance
| 16,145,318 | 1 | false | 0 | 0 |
AFAIK, it's not possible in any simple way; type-checking is incompatible with data pickled in a different session. I'm not a zealot when it comes to type-checking, but I like what works.
| 1 | 0 | 0 |
I have a really annoying bug, and I've finally tracked it down.
I use (or more accurately, already have used) a stand-alone script to create a store of objects, after which I pickle this data structure. I can then initialize my main program with the deserialized data each time my program runs.
This becomes a problem, however, if I use type-checking. After I do pickle.dump() and get this data structure, I had it set up so that I try to check the type of one the objects. Unfortunately, the only thing I can check it against is a new reloading of my classes, which Python recognizes as distinct.
DEBUG: Object I am type-checking: >> Fixture {name: 'Front Desk', location: '0', desc: 'The front desk has a sign that read...'} <<
DEBUG: A generic GameObject: >> GameObject {name: '', location: 'None', desc: '...' } <<
(You can see that the object representations look very similar. This is because the one inherits its __repr__ from the other, i.e. OUGHT to be an instance of it.)
DEBUG: Type of object I am type-checking: {class 'chimai.chimai.objects.fix.Fixture'}
DEBUG: Type of generic GameObject: {class 'objects.game_object.GameObject'}
DEBUG: MRO for the object I'm type-checking: ({class 'chimai.chimai.objects.fix.Fixture'}, {class 'chimai.chimai.objects.game_object.GameObject'}, {type 'object'})
DEBUG: MRO for the generic GameObject: ({class 'objects.game_object.GameObject'}, {type 'object'})
(The GameObject classes have slightly different identifiers; this comes from where I ran the standalone script originally.)
DEBUG: Id of pickled Fixture type: 173671604
DEBUG: Id of Fixture type as reloaded in my main program: 149507748
The end result is, I can't think of a way to type-check my pickled data at all. Unless anyone has any genius proposals, I think I'll be duck-typing.
|
Is it possible to get isinstance or similar type-checking to work with my pickled classes?
| 0 | 0 | 0 | 618 |
16,145,516 |
2013-04-22T07:12:00.000
| 11 | 0 | 1 | 0 |
python,windows
| 16,145,517 | 2 | false | 0 | 0 |
This is the wrong way to go about performing action at system shutdown time. The job of the shutdown process is to stop running processes and then switch off power; if you try to detect this happening from within your program and react by getting some last action in, it's a race between the OS and your program who gets to go first. More likely than not your program will have been stopped before it managed to perform the necessary action.
Instead, you should hook into the normal protocol for doing things at shutdown. This will tell the shutdown utility to send an explicit signal to your program and wait for it to be acknowledged, which gives you enough time (within reason) to do what you have to do. How exactly to register to be notified varies with the OS, so this is more of an OS-specific question rather than a Python question.
| 1 | 6 | 0 |
I have a Python script that runs in a loop regularly making adjustments to my lighting system. When I shut down my computer, I'd like my script to detect that, and turn off the lights altogether.
How do I detect my computer beginning to shut down in Python?
Or, assuming Windows sends Python a "time to shut down" notice, how do I intercept that to kill my lights and exit the loop?
|
Detecting computer/program shutdown in Python?
| 1 | 0 | 0 | 7,003 |
16,148,615 |
2013-04-22T13:41:00.000
| 0 | 1 | 1 | 0 |
python,encoding,installation,xlrd
| 16,168,365 | 1 | false | 0 | 0 |
Upgraded to Python 3.3 and the library got installed ok. Not sure if that's a problem with Python 3.2 or the instance I had.
| 1 | 0 | 0 |
I'm trying to install a xlrd 0.9.2 package on Python3.2 on windows 7. When I launch the setup.py install I receive encoding error: 'utf8' codec can't decode...
The module (licenses.py) where the installer stops has an encoding declaration:
# -*- coding: cp1252 -*-
but it seems the python is ignoring it.
I was using Win cmd but also checked cygwin and have the same problem.
Few days ago I also had a problem with reading txt file that was in cp1252 even though I set this declaration in my script. I was using IDLE to run the script.
I'm not sure now if my python install has something missing or this is operating system issue
|
python encoding error at xlrd installation
| 0 | 0 | 0 | 315 |
16,148,872 |
2013-04-22T13:51:00.000
| 6 | 0 | 1 | 1 |
python,powershell,python-2.7
| 16,150,017 | 2 | true | 0 | 0 |
I just solved this issue after nearly pulling my hair out. Thought I would share. In windows system > advanced system settings > environment variables there are two places to change the PATH, user variables and system variables. I added ";c:\python27" as the value for PATH in both. It now works
| 2 | 0 | 0 |
I am trying to get python.exe to run in interactive mode in windows powershell. I have added c:\python27 to my PATH and when I type "python" in into the shell a new command prompt window opens running python, rather than running within powershell. This is a problem as when I run things like "python --version" it launches the new command prompt window and then closes before I can read it. Does anyone know how to get python to run in powershell?
Note: this used to work before I started to install pip, easy_install and virtualenv this morning.
Thanks
|
Python will not run in windows powershell
| 1.2 | 0 | 0 | 7,079 |
16,148,872 |
2013-04-22T13:51:00.000
| 0 | 0 | 1 | 1 |
python,powershell,python-2.7
| 16,149,638 | 2 | false | 0 | 0 |
I'm not expert in PS, but when I need to use python in interactive mode in windows powershell, I use something like this (version of python is 2.7.3, I didn't change env variables):
PS C:\Python27> ./python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
| 2 | 0 | 0 |
I am trying to get python.exe to run in interactive mode in windows powershell. I have added c:\python27 to my PATH and when I type "python" in into the shell a new command prompt window opens running python, rather than running within powershell. This is a problem as when I run things like "python --version" it launches the new command prompt window and then closes before I can read it. Does anyone know how to get python to run in powershell?
Note: this used to work before I started to install pip, easy_install and virtualenv this morning.
Thanks
|
Python will not run in windows powershell
| 0 | 0 | 0 | 7,079 |
16,148,893 |
2013-04-22T13:52:00.000
| 1 | 0 | 0 | 1 |
python,unix,centos,version
| 16,148,913 | 2 | false | 0 | 0 |
When you run anything on the command-line, it will search through the folders in the PATH variable, in order, until it finds an executable file with that name.
| 1 | 1 | 0 |
I have python in both /usr/bin and /usr/local/bin. Now I have this question that which one will execute if I call python?
I know that I can check with which python command to see which one is which one. But I'm asking which one would work by default?
|
which version of program will execute? the one in the /usr/bin or the one in /usr/local/bin?
| 0.099668 | 0 | 0 | 58 |
16,149,187 |
2013-04-22T14:06:00.000
| 0 | 0 | 1 | 0 |
python,file,numpy
| 16,149,290 | 4 | false | 0 | 0 |
I had this problem long ago so i dont have the code near to show you, but i used a binary write in a tmp file to get that done.
EDIT: Thats is, pickle is what i used. Thanks SpankMe and RoboInventor
| 2 | 0 | 1 |
I need to save multiple numpy arrays along with the user input that was used to compute the data these arrays contain in a single file. I'm having a hard time finding a good procedure to use to achieve this or even what file type to use. The only thing i can think of is too put the computed arrays along with the user input into one single array and then save it using numpy.save. Does anybody know any better alternatives or good file types for my use?
|
Saving python data for an application
| 0 | 0 | 0 | 106 |
16,149,187 |
2013-04-22T14:06:00.000
| 2 | 0 | 1 | 0 |
python,file,numpy
| 16,149,283 | 4 | false | 0 | 0 |
How about using pickle and then storing pickled array objects in a storage of your choice, like database or files?
| 2 | 0 | 1 |
I need to save multiple numpy arrays along with the user input that was used to compute the data these arrays contain in a single file. I'm having a hard time finding a good procedure to use to achieve this or even what file type to use. The only thing i can think of is too put the computed arrays along with the user input into one single array and then save it using numpy.save. Does anybody know any better alternatives or good file types for my use?
|
Saving python data for an application
| 0.099668 | 0 | 0 | 106 |
16,149,613 |
2013-04-22T14:26:00.000
| 8 | 0 | 1 | 1 |
python,django,gcc,lxml
| 24,547,445 | 7 | false | 0 | 0 |
I met the similar question(error: command 'gcc' failed with exit status 4) this morning. It seems you need check your machine's memory. If the memory is lower than 512M,that may be the cause.Try to close some services temporarily,like apache server,and try "pip install lxml" again.It maybe work!
| 1 | 35 | 0 |
I'm having the following error when trying to run "pip install lxml" into a virtualenv in Ubuntu 12.10 x64. I have Python 2.7.
I have seen other related questions here about the same problem and tried installing python-dev, libxml2-dev and libxslt1-dev.
Please take a look of the traceback from the moment I tip the command to the moment when the error occurs.
Downloading/unpacking lxml
Running setup.py egg_info for package lxml
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.1.2.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib
warning: no files found matching '*.txt' under directory 'src/lxml/tests'
Installing collected packages: lxml
Running setup.py install for lxml
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.1.2.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/home/admin/.virtualenvs/dev.actualito.com/build/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o
src/lxml/lxml.etree.c: In function '__pyx_f_4lxml_5etree__getFilenameForFile':
src/lxml/lxml.etree.c:26851:7: warning: variable '__pyx_clineno' set but not used [-Wunused-but-set-variable]
src/lxml/lxml.etree.c:26850:15: warning: variable '__pyx_filename' set but not used [-Wunused-but-set-variable]
src/lxml/lxml.etree.c:26849:7: warning: variable '__pyx_lineno' set but not used [-Wunused-but-set-variable]
src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_4XSLT_18__call__':
src/lxml/lxml.etree.c:138273:81: warning: passing argument 1 of '__pyx_f_4lxml_5etree_12_XSLTContext__copy' from incompatible pointer type [enabled by default]
src/lxml/lxml.etree.c:136229:52: note: expected 'struct __pyx_obj_4lxml_5etree__XSLTContext *' but argument is of type 'struct __pyx_obj_4lxml_5etree__BaseContext *'
src/lxml/lxml.etree.c: In function '__pyx_f_4lxml_5etree__copyXSLT':
src/lxml/lxml.etree.c:139667:79: warning: passing argument 1 of '__pyx_f_4lxml_5etree_12_XSLTContext__copy' from incompatible pointer type [enabled by default]
src/lxml/lxml.etree.c:136229:52: note: expected 'struct __pyx_obj_4lxml_5etree__XSLTContext *' but argument is of type 'struct __pyx_obj_4lxml_5etree__BaseContext *'
src/lxml/lxml.etree.c: At top level:
src/lxml/lxml.etree.c:12384:13: warning: '__pyx_f_4lxml_5etree_displayNode' defined but not used [-Wunused-function]
gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
error: command 'gcc' failed with exit status 4
Complete output from command /home/admin/.virtualenvs/dev.actualito.com/bin/python -c "import setuptools;__file__='/home/admin/.virtualenvs/dev.actualito.com/build/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-asDtN5-record/install-record.txt --single-version-externally-managed --install-headers /home/admin/.virtualenvs/dev.actualito.com/include/site/python2.7:
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.1.2.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib
running install
running build
running build_py
copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-2.7/lxml/includes
running build_ext
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/home/admin/.virtualenvs/dev.actualito.com/build/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o
src/lxml/lxml.etree.c: In function '__pyx_f_4lxml_5etree__getFilenameForFile':
src/lxml/lxml.etree.c:26851:7: warning: variable '__pyx_clineno' set but not used [-Wunused-but-set-variable]
src/lxml/lxml.etree.c:26850:15: warning: variable '__pyx_filename' set but not used [-Wunused-but-set-variable]
src/lxml/lxml.etree.c:26849:7: warning: variable '__pyx_lineno' set but not used [-Wunused-but-set-variable]
src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_4XSLT_18__call__':
src/lxml/lxml.etree.c:138273:81: warning: passing argument 1 of '__pyx_f_4lxml_5etree_12_XSLTContext__copy' from incompatible pointer type [enabled by default]
src/lxml/lxml.etree.c:136229:52: note: expected 'struct __pyx_obj_4lxml_5etree__XSLTContext *' but argument is of type 'struct __pyx_obj_4lxml_5etree__BaseContext *'
src/lxml/lxml.etree.c: In function '__pyx_f_4lxml_5etree__copyXSLT':
src/lxml/lxml.etree.c:139667:79: warning: passing argument 1 of '__pyx_f_4lxml_5etree_12_XSLTContext__copy' from incompatible pointer type [enabled by default]
src/lxml/lxml.etree.c:136229:52: note: expected 'struct __pyx_obj_4lxml_5etree__XSLTContext *' but argument is of type 'struct __pyx_obj_4lxml_5etree__BaseContext *'
src/lxml/lxml.etree.c: At top level:
src/lxml/lxml.etree.c:12384:13: warning: '__pyx_f_4lxml_5etree_displayNode' defined but not used [-Wunused-function]
gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
error: command 'gcc' failed with exit status 4
----------------------------------------
Command /home/admin/.virtualenvs/dev.actualito.com/bin/python -c "import setuptools;__file__='/home/admin/.virtualenvs/dev.actualito.com/build/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-asDtN5-record/install-record.txt --single-version-externally-managed --install-headers /home/admin/.virtualenvs/dev.actualito.com/include/site/python2.7 failed with error code 1 in /home/admin/.virtualenvs/dev.actualito.com/build/lxml
Storing complete log in /home/admin/.pip/pip.log
|
Installing lxml with pip in virtualenv Ubuntu 12.10 error: command 'gcc' failed with exit status 4
| 1 | 0 | 0 | 37,060 |
16,151,665 |
2013-04-22T16:08:00.000
| 1 | 0 | 0 | 0 |
python,flash,bots
| 16,154,217 | 1 | false | 0 | 0 |
I'd try saving the button you have to click as a pic, then scan your entire screen and use PIL to match the pic you saved to the button you have to press; from there you should be able to retrieve the coordinates.
| 1 | 0 | 0 |
I got a bot in Python that I've made to simulate a player playing a flash web game. The thing is, I've used an approach that requires specific screen coordinates to work, and there is a pop-up I need to click to advance to the next state that seems to appear in random positions every time it shows up.
Do you know how to "detect" where the popup is?.
Thanks.
|
How to make this bot work?
| 0.197375 | 0 | 0 | 253 |
16,151,727 |
2013-04-22T16:12:00.000
| 0 | 0 | 0 | 0 |
python,python-3.x,pyqt,pyqt4,python-3.3
| 16,198,711 | 1 | true | 0 | 1 |
I found out a solution. I was trying to do everything in my GUI thread. Im new to python but I am sure with some research I can teach myself threads.
| 1 | 1 | 0 |
What I am trying to achieve seems like it should be simple, but I can not find anything online to help.
I would like to take my pyqt program and, instead of using the command prompt, export all my print() commands to a qtextbrowser.
There are 2 parts to my question.
How do I disable the command prompt from showing up when the app is run.
How to output the print() commands to the text browser in real time.
I am using Python 3.3 and qt designer with pyqt4.
Thank you in advance!
Some of the code is confidential so if it is needed to help I can remove the sensitive info and post it.
|
Real time command prompt export in text field using pyqt4
| 1.2 | 0 | 0 | 403 |
16,152,515 |
2013-04-22T16:53:00.000
| 0 | 0 | 1 | 0 |
python-3.x,symbian3,s60-3rd-edition
| 22,061,960 | 1 | false | 0 | 0 |
With Symbian there is something called platform security, and from it there is something called data caging which is preventing access to the executable folders and some other ones as well, thus there are not really possibilities on 3rd party supplying such an application, and therefor I would suppose there would not be application with this kind of functionality available.
| 1 | 0 | 0 |
in Symbian 2nd Version, there's a software called Sisboom which works with python, with Sisboom it was possible to get the installer file of already installed software, now i've Symbian 3rd Version, and i got the same software, and i'm unbale to do the same, please help...
|
how to pack already installed software in symbain 3rd version?
| 0 | 0 | 0 | 90 |
16,152,851 |
2013-04-22T17:15:00.000
| 1 | 0 | 1 | 0 |
python,logging,stack-trace
| 16,152,852 | 2 | false | 0 | 0 |
Looking around I found the following solution / workaround:
sys.tracebacklimit = 0
| 1 | 5 | 0 |
I would like to disable the stack trace that is printed when there is an exception raised.
|
How to disable stack trace in python
| 0.099668 | 0 | 0 | 6,658 |
16,152,965 |
2013-04-22T17:20:00.000
| 1 | 0 | 0 | 0 |
java,python,pdf,text
| 16,153,090 | 3 | true | 1 | 0 |
For java: have a look at iText
For python I would use PDFMiner
| 1 | 0 | 0 |
I have about 10,000 of pdf files(conf papers) and I need to extract text from certain section (like the experimental section) of these papers and save in a file.
Does anyone know a java tool or some python tool which can help me do this?
Thanks in advance
Ayush
|
automatically extract text from pdf for many files
| 1.2 | 0 | 0 | 901 |
16,153,501 |
2013-04-22T17:50:00.000
| 0 | 0 | 1 | 0 |
python,built-in,python-internals
| 16,153,558 | 2 | false | 0 | 0 |
An object isn't aware of its own name (it can have many), let alone of any unique ID it has associated with it. So - in short - no. The reasons that __len__ and co. work is that they are bound to the object already - an object is not bound to its ID.
| 1 | 6 | 0 |
In Python:
len(a) can be replaced by a.__len__()
str(a) or repr(a) can be replaced by a.__str__() or a.__repr__()
== is __eq__, + is __add__, etc.
Is there similar method to get the id(a) ? If not, is there any workaround to get an unique id of a python object without using id() ?
edit: additional question: if not ? is there any reason not to define a __id__() ?
|
Python, what is the object method of built-in id()?
| 0 | 0 | 0 | 3,035 |
16,153,597 |
2013-04-22T17:55:00.000
| 0 | 1 | 1 | 0 |
python,windows,mingw,msys
| 16,485,372 | 2 | false | 0 | 0 |
The best possibility is to change your build script to point to -lboost_python-mgw46-mt-1_53.dll
If you rename libboost_python-mgw46-mt-1_53.dll you have to rename libboost_python-mgw46-mt-1_53.dll.a to.
Often have dll's a reciprocal reference, if you now, only renames, the original names are not found.
So do not rename, instead use copy
copy
libboost_python-mgw46-mt-1_53.dll.a to libboost_python.a
and copy
libboost_python-mgw46-mt-1_53.dll to libboost_python.dll
With this method you have both versions.
| 1 | 0 | 0 |
I am trying to compiling an autodiff python library, pyadolc, on Windows with Mingw. It requires boost python to call the underlying c++ library, adol-c.
I first compiled boost_python library (dll) with mingw. The dll generated are namead as libboost_python-mgw46-mt-1_53.dll and libboost_python-mgw46-mt-1_53.dll.a, sitting in /mingw/bin and /mingw/lib respectively.
Then when I build the pyadolc, the build script tries with command -lboost_python. It failed because the dll is named as libboost_python-mgw46-mt-1_53.dll, not libboost_python.dll.
So I renamed the dll as libboost_python.dll in /mingw/bin. It works and everything links fine.
However, when I tred in python shell
import adolc
it gave me an error: ImportError: No dll found for _adolc (something like that). Then I found that it was because it was looking for libboost_python-mgw46-mt-1_53.dll.
My question is: how does the dll naming work? what's the proper way to handle this kind of situation? Should I modify the build script or should I just rename the dll? I know in linux, I probably can just create a symbolic link of libboost_python.so to libboost_python-xxxx-mt-1_53.so. But in Windows xp, symbolic link to a file is not that easy.
|
How should I handle an "incorrectly" named dll?
| 0 | 0 | 0 | 118 |
16,154,500 |
2013-04-22T18:52:00.000
| 5 | 0 | 1 | 0 |
python
| 16,154,528 | 1 | true | 0 | 0 |
Perhaps you want rLu[int(lineList[0])-1].update(umDict)? It's a little difficult to understand your data structure from your description. If I understand you right, you do not have a "key-value pair", you have a one-key dictionary.
| 1 | 0 | 0 |
I need a little assistance with inserting a key:value pair from a dictionary (called umDict) into an already existing dictionary in a list at a specific spot in that list.
What I have already is a list (called rLu) that's filled with 943 empty dictionaries. I also have a list called lineList that has parsed a string and contains three elements. Finally, I have a key:value pair in the umDict temporary dictionary that needs to be inserted into the dictionary that's present in the rLu list at
rLu[int(lineList[0])-1]
The key value pair is composed such as:
umDict[lineList[1]] = lineList[2]
To get the results I'd like, I've tried:
umDict[lineList[1]] = lineList[2]
rLu[int(lineList[0])-1] = umDict
But it inserts a brand new dictionary instead of just the key:value into the existing dictionary. How do I get it to insert just the key:value pair into the existing dictionary?
What I'm expecting to get is something like this:
rLu = [{'1':'a','2':'b'}, {'3':'c', '4':'d'}, {'5':'e', '6':'f'}]
Where the length of those dictionaries could be any, not just two like in my example.
|
Insert dictionary key:value into existing dictionary at a specific index in a list
| 1.2 | 0 | 0 | 635 |
16,155,776 |
2013-04-22T20:07:00.000
| 0 | 0 | 0 | 0 |
python,twisted
| 16,171,818 | 1 | true | 0 | 0 |
As you use XML-RPC, you will have to write simple Twisted web application that handles XML-RPC calls. There are many possibilities for cache: expiring, storing on disk, invalidating, etc etc. You may start from simple dict for storing queries and find its limitations.
| 1 | 1 | 0 |
I am totally fresh and noob as you can be on Twisted. I chose a database proxy as my final project. The idea is, have a mysql as a database. A twisted proxy runs in between client and the database.The proxy makes the methods like UPDATE,SELECT,INSERT through its XMLRPC to the client. And, the methods itself in the proxy hits the database and grabs the data. And, I was thinking of some caching mechanism too on the proxy. So, any heads up on the project? How does chaching work in twisted
|
Database Proxy using Twisted
| 1.2 | 1 | 0 | 166 |
16,157,144 |
2013-04-22T21:36:00.000
| 2 | 0 | 0 | 0 |
python,database,pyramid
| 16,159,421 | 1 | true | 1 | 0 |
initialize_db is not a migration script. It is for bootstrapping your model and that's that. If you want to tie in migrations with upgrade/rollback support, look at alembic for SQL schema migrations.
| 1 | 0 | 0 |
I am a rails developer that is learning python and I am doing a project using the pyramid framework. I am used to having some sort of way of rolling back the database changes If I change the models in some sort of way. Is there some sort of database rollback that works similar to the initialize_project_db command?
|
Is there some sort of way to roll back the initialize_project_db script in pyramid?
| 1.2 | 1 | 0 | 139 |
16,157,258 |
2013-04-22T21:43:00.000
| 5 | 0 | 1 | 0 |
python,integer,character,comparison-operators
| 16,157,300 | 1 | true | 0 | 0 |
There's no "char" type in python, chr returns a string of length one, and with strong typing it doesn't make sense for any string to be equal to any integer.
| 1 | 1 | 0 |
I ran into this interesting little 'gotcha' this evening, consider the following code snippet:
( chr(1) == 1 )
This comparison evaluates to False on Python 2.7.4, is this a feature or a bug?, If a feature, can anyone explain the reasoning behind this design decision?
|
Python evaluates comparison of integer and character with the same value as False
| 1.2 | 0 | 0 | 386 |
16,157,636 |
2013-04-22T22:13:00.000
| 0 | 1 | 1 | 0 |
c#,special-characters,ironpython
| 16,273,312 | 1 | false | 1 | 0 |
Probably you are doing something wrong. There is no issues with encoding and IronPython. Check encoding for script you load before..
| 1 | 0 | 0 |
I am facing an encoding issue while trying to pass a string from two C# modules using Ironpython code as a bridge.
Special characters like € , © gets distorted when the string is received by the recipient module.
Can anyone please advise if its a IronPython issue ? and how to fix this type of issue
Thanks,
Amit
|
special character encoding C# and Ironpython
| 0 | 0 | 0 | 387 |
16,158,308 |
2013-04-22T23:17:00.000
| 1 | 0 | 0 | 0 |
python,django,django-1.5
| 16,158,406 | 1 | true | 1 | 0 |
If you are sure that there are not any dependencies from some other files in your project or in your apps you can safely remove them.
First comment out one by one and every time check the project in your browser if it is running correctly. Also check the logs for warnings and errors.
| 1 | 0 | 0 |
I'd like to know if I can just ditch the Sites default app (comment it out from INSTALLED_APPS and so on) without breaking anything?
It's written in the doc that some other parts of django use it (redirects framework, comments, flatpages, syndic, auth, shortcut and view on site), but it's not explicitly said if it's going to break them. Is it?
Django 1.5
|
Remove django sites app
| 1.2 | 0 | 0 | 182 |
16,159,985 |
2013-04-23T02:39:00.000
| 0 | 0 | 0 | 0 |
java,python,graph,jython,networkx
| 16,269,881 | 1 | false | 0 | 0 |
Jython is python language spec inside of the JVM much like JRuby.
NetworkX source code is C or fortran (don't remember which).
Numpy/Scipy are C based (great packages for scientific computing).
Matplotlib is c (for display of the graphs).
NetworkX will help create graphs, matplotlib will help display them but both may not work in Jython.
If you need c based resources try jpype; its older (python 2.7) but will allow some functionality between c and java using JNI (java native interface).
What I have done is create graphs in python then switch over to Gephi to visualize and display the graphs. Gephi is java based and a up and coming free tool.
| 1 | 1 | 0 |
I need to use python with Java in a project in which graphs (the kind with nodes and edges) plays a large role. I want to visualize those graphs in a simple GUI and update its node labels/edge weights/whatever every second or so. I also want to load graphs from files in graphml form.
Networkx is advised by many people, but doesn't seem to work with Jython, is that correct? If not, I get a
SyntaxError: 'import *' not allowed with 'from .'
error from inside the Networkx egg. Even if it's works, I would need Numpy and matplotlib to work and I'm not sure those work with Jython.
So firstly, could you help me with solving these NetworkX issues. Secondly, are there alternatives to Networkx that you could recommend for my purposes?
|
Jython graph library
| 0 | 0 | 1 | 1,298 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.