title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
list
Formatting an output file
2,249,162
<p>I'm currently indexing my music collection with python. Ideally I'd like my output file to be formatted as;</p> <pre><code>"Artist; Album; Tracks - length - bitrate - md5 Artist2; Album2; Tracks - length - bitrate - md5" </code></pre> <p>But I can't seem to work out how to achieve this....
0
2010-02-12T01:51:26Z
2,249,216
<p>If your input data is a list of tuples each with 6 strings <code>(artist, album, tracks, length, bitrate, md5)</code>:</p> <pre><code>for artist, album, tracks, length, bitrate, md5 in input_data: print "%s;" % artist print "%s;" % album print " %s - %s - %s - %s" % (tracks, length, bitrate, md5) <...
1
2010-02-12T02:05:24Z
[ "python", "text", "formatting", "logging" ]
Django Master-Detail View Plugins
2,249,285
<p>Let's say I have 3 django apps, app <strong>Country</strong>, app <strong>Social</strong> and app <strong>Financial</strong>.</p> <p>Country is a 'master navigation' app. It lists all the countries in a 'index' view and shows details for each country on its 'details' view. </p> <p>Each country's details include th...
2
2010-02-12T02:23:38Z
2,250,366
<p>2 common solution I use for this problem: </p> <p><strong>Partial Templates:</strong><br> Create a template for rendering "social" and "financial" that does not need stuff from the view, other than the object it is working on (and uses the objects functions or template tags to render it). then you can easily {% in...
2
2010-02-12T08:05:10Z
[ "python", "django", "django-templates", "django-views", "master-detail" ]
`if __name__ == '__main__'` equivalent in Ruby
2,249,310
<p>I am new to Ruby. I'm looking to import functions from a module that contains a tool I want to continue using separately. In Python I would simply do this:</p> <pre><code>def a(): ... def b(): ... if __name__ == '__main__': a() b() </code></pre> <p>This allows me to run the program or import it a...
77
2010-02-12T02:30:27Z
2,249,332
<p>From the Ruby I've seen out in the wild (granted, not a ton), this is not a standard Ruby design pattern. Modules and scripts are supposed to stay separate, so I wouldn't be surprised if there isn't really a good, clean way of doing this.</p> <p><strong>EDIT:</strong> <a href="http://gimbo.org.uk/blog/2006/04/18/sc...
104
2010-02-12T02:36:16Z
[ "python", "ruby", "main" ]
`if __name__ == '__main__'` equivalent in Ruby
2,249,310
<p>I am new to Ruby. I'm looking to import functions from a module that contains a tool I want to continue using separately. In Python I would simply do this:</p> <pre><code>def a(): ... def b(): ... if __name__ == '__main__': a() b() </code></pre> <p>This allows me to run the program or import it a...
77
2010-02-12T02:30:27Z
19,370,576
<p>If stack trace is empty, we can start executing to the right and left. I don't know if that's used conventionally or unconventionally since I'm into Ruby for about a week. </p> <pre><code>if caller.length == 0 # do stuff end </code></pre> <p>Proof of concept:</p> <p>file: test.rb</p> <pre><code>#!/usr/bin/ruby...
5
2013-10-14T22:55:45Z
[ "python", "ruby", "main" ]
MySQL select query not working with limit, offset parameters
2,249,331
<p>I am running MySQL 5.1 on my windows vista installation. The table in question uses MyISAM, has about 10 million rows. It is used to store text messages posted by users on a website.</p> <p>I am trying to run the following query on it, </p> <pre><code>query = "select id, text from messages order by id limit %d off...
1
2010-02-12T02:36:16Z
2,251,354
<p>Have you checked the table with <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html" rel="nofollow">myisamchk</a>?</p>
0
2010-02-12T11:14:25Z
[ "python", "mysql" ]
Python MediaWiki table regex (find strings of a particular format, then extract substrings within)
2,249,340
<p>I'm trying to find all strings of the format <code>{{rdex|001|001|Bulbasaur|2|Grass|Poison}}</code> in a large text file, and then extract the substrings corresponding to the first <code>001</code> and to <code>Bulbasaur</code>, perhaps as a tuple.</p> <p>I'm assuming regex with capturing groups can be used for bot...
1
2010-02-12T02:40:32Z
2,249,362
<pre><code>re.match('^{{[^|]+\|([^|]+)\|[^|]+\|([^|]+)\|[^|]+\|[^|]+\|[^|]+\}}$', S).groups() </code></pre>
1
2010-02-12T02:46:15Z
[ "python", "regex", "mediawiki" ]
Python MediaWiki table regex (find strings of a particular format, then extract substrings within)
2,249,340
<p>I'm trying to find all strings of the format <code>{{rdex|001|001|Bulbasaur|2|Grass|Poison}}</code> in a large text file, and then extract the substrings corresponding to the first <code>001</code> and to <code>Bulbasaur</code>, perhaps as a tuple.</p> <p>I'm assuming regex with capturing groups can be used for bot...
1
2010-02-12T02:40:32Z
2,249,370
<pre><code>import re text="""{{rdex|001|001|Bulbasaur|2|Grass|Poison}}""" re.findall("\{\{[^|]+\|(\d+)\|\d+\|([^|]+)",text) [('001', 'Bulbasaur')] </code></pre>
1
2010-02-12T02:49:27Z
[ "python", "regex", "mediawiki" ]
Python MediaWiki table regex (find strings of a particular format, then extract substrings within)
2,249,340
<p>I'm trying to find all strings of the format <code>{{rdex|001|001|Bulbasaur|2|Grass|Poison}}</code> in a large text file, and then extract the substrings corresponding to the first <code>001</code> and to <code>Bulbasaur</code>, perhaps as a tuple.</p> <p>I'm assuming regex with capturing groups can be used for bot...
1
2010-02-12T02:40:32Z
2,249,397
<pre><code>line="{{rdex|001|001|Bulbasaur|2|Grass|Poison}}" s=line.find("{{") e=line.find("}}") if s != -1 and e != -1: sub=line[s+2:e].split("|") print sub[1],sub[3] </code></pre> <p>output</p> <pre><code>$ ./python.py 001 Bulbasaur </code></pre>
0
2010-02-12T02:58:58Z
[ "python", "regex", "mediawiki" ]
Can we get the following flexibility in Python as In Perl
2,249,419
<p>Sorry. I am not trying to start any flame. My scripting experience is from Perl, and I am pretty new in Python.</p> <p>I just want to check whether I can have the same degree of flexibility as in Python.</p> <p>In Python :</p> <pre><code>page = form.getvalue("page") str = 'This is string : ' + str(int(page) + 1) ...
4
2010-02-12T03:04:15Z
2,249,426
<p>No, since Python is strongly typed. If you keep <code>page</code> as an int you can do the following:</p> <pre><code>s = 'This is string : %d' % (page + 1,) </code></pre>
7
2010-02-12T03:06:53Z
[ "python", "perl" ]
Can we get the following flexibility in Python as In Perl
2,249,419
<p>Sorry. I am not trying to start any flame. My scripting experience is from Perl, and I am pretty new in Python.</p> <p>I just want to check whether I can have the same degree of flexibility as in Python.</p> <p>In Python :</p> <pre><code>page = form.getvalue("page") str = 'This is string : ' + str(int(page) + 1) ...
4
2010-02-12T03:04:15Z
2,249,428
<p>No. Python doesn't have the same level of polymorphism as perl. You can print anything, and mix and match floats and ints quite easily, and lots of things (0, '', "", () and []) all end up False, but no, it's not perl in terms of polymorphism.</p>
0
2010-02-12T03:07:41Z
[ "python", "perl" ]
Can we get the following flexibility in Python as In Perl
2,249,419
<p>Sorry. I am not trying to start any flame. My scripting experience is from Perl, and I am pretty new in Python.</p> <p>I just want to check whether I can have the same degree of flexibility as in Python.</p> <p>In Python :</p> <pre><code>page = form.getvalue("page") str = 'This is string : ' + str(int(page) + 1) ...
4
2010-02-12T03:04:15Z
2,249,524
<p>It looks like <code>page</code> is a <code>str</code></p> <pre><code>page = form.getvalue("page") S = 'This is string : %d'%(int(page)+1) </code></pre> <p>otherwise make page an <code>int</code></p> <pre><code>page = int(form.getvalue("page")) S = 'This is string : %d'%(page+1) </code></pre> <p>For the record (a...
1
2010-02-12T03:38:26Z
[ "python", "perl" ]
Can we get the following flexibility in Python as In Perl
2,249,419
<p>Sorry. I am not trying to start any flame. My scripting experience is from Perl, and I am pretty new in Python.</p> <p>I just want to check whether I can have the same degree of flexibility as in Python.</p> <p>In Python :</p> <pre><code>page = form.getvalue("page") str = 'This is string : ' + str(int(page) + 1) ...
4
2010-02-12T03:04:15Z
2,249,931
<p>You could use:</p> <pre><code>mystr = "This string is: %s" % (int(page) + 1) </code></pre> <p>... the string conversion will be automatic when interpolating into the <code>%s</code> via the <code>%</code> (string formating operator).</p> <p>You can't get around the need to convert from string to integer. Python ...
1
2010-02-12T05:53:02Z
[ "python", "perl" ]
How to generate data model from sql schema in Django?
2,249,489
<p>Our website uses a PHP front-end and a PostgreSQL database. We don't have a back-end at the moment except phpPgAdmin. The database admin has to type data into phpPgAmin manually, which is error-prone and tedious. We want to use Django to build a back-end.</p> <p>The database has a few dozen of tables already there....
19
2010-02-12T03:24:22Z
2,249,495
<p>If each table has an autoincrement integer PK then you can use the <a href="http://docs.djangoproject.com/en/dev/howto/legacy-databases/#howto-legacy-databases" rel="nofollow">legacy database</a> instructions.</p>
2
2010-02-12T03:26:42Z
[ "python", "database", "django" ]
How to generate data model from sql schema in Django?
2,249,489
<p>Our website uses a PHP front-end and a PostgreSQL database. We don't have a back-end at the moment except phpPgAdmin. The database admin has to type data into phpPgAmin manually, which is error-prone and tedious. We want to use Django to build a back-end.</p> <p>The database has a few dozen of tables already there....
19
2010-02-12T03:24:22Z
2,249,559
<p>Yes it is possible, using the <a href="http://docs.djangoproject.com/en/dev/ref/django-admin/#inspectdb">inspectdb</a> command:</p> <pre><code>python manage.py inspectdb </code></pre> <p>or</p> <pre><code>python manage.py inspectdb &gt; models.py </code></pre> <p>to get them in into the file</p> <p>This will lo...
28
2010-02-12T03:50:01Z
[ "python", "database", "django" ]
How to improve the throughput of request_logs on Google App Engine
2,249,530
<p>Downloading logs from App Engine is nontrivial. Requests are batched; <code>appcfg.py</code> does not use normal file IO but rather a temporary file (in reverse chronological order) which it ultimately appends to the local log file; when appending, the need to find the "sentinel" makes log rotation difficult since o...
1
2010-02-12T03:40:16Z
2,249,540
<p>You can increase the per-request batch size of logs. In the latest SDK (1.3.1), check out <code>google_appengine/google/appengine/tools/appcfg.py</code> around like 861 (<code>RequestLogLines</code> method of <code>LogsRequester</code> class). You can modify the "limit" parameter.</p> <p>I am using 1000 and it work...
1
2010-02-12T03:43:21Z
[ "python", "google-app-engine", "logging" ]
Python lazy iterator
2,249,651
<p>I am trying to understand how and when iterator expressions get evaluated. The following seems to be a lazy expression:</p> <pre><code>g = (i for i in range(1000) if i % 3 == i % 2) </code></pre> <p>This one, however fails on construction:</p> <pre><code>g = (line.strip() for line in open('xxx', 'r') if len(line)...
5
2010-02-12T04:20:17Z
2,249,658
<p>The iteration over the file returned by the call to <code>open()</code> is lazy. The call to <code>open()</code> is not.</p>
5
2010-02-12T04:24:26Z
[ "python", "lazy-evaluation" ]
Python lazy iterator
2,249,651
<p>I am trying to understand how and when iterator expressions get evaluated. The following seems to be a lazy expression:</p> <pre><code>g = (i for i in range(1000) if i % 3 == i % 2) </code></pre> <p>This one, however fails on construction:</p> <pre><code>g = (line.strip() for line in open('xxx', 'r') if len(line)...
5
2010-02-12T04:20:17Z
2,249,660
<p>From the <a href="http://docs.python.org/reference/expressions.html" rel="nofollow">documentation</a>:</p> <blockquote> <p>Variables used in the generator expression are evaluated lazily in a separate scope when the <code>next()</code> method is called for the generator object (in the same fashion as for ...
3
2010-02-12T04:24:48Z
[ "python", "lazy-evaluation" ]
"De-instrument" an instantiated object from the sqlalchemy ORM
2,249,694
<p>Is there an easy way to "de-instrument" an instantiated class coming from sqlalchemy's ORM, i.e., turn it into a regular object? </p> <p>I.e., suppose I have a Worker class that's mapped to a worker table: </p> <pre><code>class Worker(object): def earnings(self): return self.wage*self.hours mappe...
4
2010-02-12T04:36:24Z
2,249,887
<p>If you know the names of the fields you want, say you have them in a list of strings called <code>fields</code>, and those of the methods you want, like <code>earnings</code> in your example, in a list of strings called <code>methods</code>, then:</p> <pre><code>def deinstrument(obj, fields, methods): cls = type(...
0
2010-02-12T05:39:51Z
[ "python", "optimization", "sqlalchemy" ]
"De-instrument" an instantiated object from the sqlalchemy ORM
2,249,694
<p>Is there an easy way to "de-instrument" an instantiated class coming from sqlalchemy's ORM, i.e., turn it into a regular object? </p> <p>I.e., suppose I have a Worker class that's mapped to a worker table: </p> <pre><code>class Worker(object): def earnings(self): return self.wage*self.hours mappe...
4
2010-02-12T04:36:24Z
2,253,156
<p>If you need to permanently deinstrument a class, just dispose of the mapper:</p> <pre><code>sqlalchemy.orm.class_mapper(Worker).dispose() </code></pre> <p>SQLAlchemy instrumentation lives as property descriptors on the class object. So if you need separate deinstrumented versions of objects you'll need to create a...
5
2010-02-12T16:09:02Z
[ "python", "optimization", "sqlalchemy" ]
Convert unicode string to array of bytes
2,249,817
<p>I'm using OpenGL and I need to pass to a function array of bytes.</p> <pre><code>glCallLists(len('text'), GL_UNSIGNED_BYTES, 'text'); </code></pre> <p>This way it's working fine. But I need to pass unicode text. I think that it should work like this:</p> <pre><code>text = u'unicode text' glCallLists(len(text), GL...
0
2010-02-12T05:14:21Z
2,249,849
<p>The UTF encoding that takes up 2 bytes per character is UTF-16:</p> <pre><code>print repr(u'あいうえお'.encode('utf-16be')) print repr(u'あいうえお'.encode('utf-16le')) </code></pre>
2
2010-02-12T05:27:50Z
[ "python", "unicode" ]
Django not translating Bittorrent query string properly
2,249,947
<p>I'm writing a small Bittorrent tracker on top of the Django framework, as part of a larger project. However, I'm having problems with decoding the "info_hash" parameter of the announce request.</p> <p>Basically, uTorrent takes the SHA1 hash of the torrent in question and URL encodes the hex representation of it, wh...
0
2010-02-12T05:56:57Z
2,249,998
<p>Django decodes all GET data using the default encoding. You'll need to get the query string yourself, possibly from <code>os.environ['QUERY_STRING']</code> or <code>request.environ['QUERY_STRING']</code>.</p>
0
2010-02-12T06:15:57Z
[ "python", "django", "encoding", "bittorrent" ]
Django not translating Bittorrent query string properly
2,249,947
<p>I'm writing a small Bittorrent tracker on top of the Django framework, as part of a larger project. However, I'm having problems with decoding the "info_hash" parameter of the announce request.</p> <p>Basically, uTorrent takes the SHA1 hash of the torrent in question and URL encodes the hex representation of it, wh...
0
2010-02-12T05:56:57Z
2,250,318
<p>What is your settings.DEFAULT_ENCODING? Also how deoes the hash look like in HTTP headers? It shouldn't be modified at all during encoding as below:</p> <pre><code>&gt;&gt;&gt; import urllib &gt;&gt;&gt; urllib.urlencode({'hash':"A44B44B0EE8D85A9F7135489D522A19DA2C87C91"}) 'hash=A44B44B0EE8D85A9F7135489D522A19DA2C8...
1
2010-02-12T07:53:11Z
[ "python", "django", "encoding", "bittorrent" ]
how to get the same day of next month of a given day in python using datetime
2,249,956
<p>i know using datetime.timedelta i can get the date of some days away form given date </p> <pre><code>daysafter = datetime.date.today() + datetime.timedelta(days=5) </code></pre> <p>but seems no datetime.timedelta(months=1)</p> <p>!Thanks for any help!</p>
20
2010-02-12T05:59:54Z
2,249,988
<p>Of course there isn't -- if today's January 31, what would be "the same day of the next month"?! Obviously there is no <em>right</em> solution, since February 31 does not exist, and the <code>datetime</code> module does <strong>not</strong> play at "guess what the user posing this impossible problem without a right...
18
2010-02-12T06:12:41Z
[ "python", "datetime", "date" ]
how to get the same day of next month of a given day in python using datetime
2,249,956
<p>i know using datetime.timedelta i can get the date of some days away form given date </p> <pre><code>daysafter = datetime.date.today() + datetime.timedelta(days=5) </code></pre> <p>but seems no datetime.timedelta(months=1)</p> <p>!Thanks for any help!</p>
20
2010-02-12T05:59:54Z
2,251,203
<p>Use <a href="http://labix.org/python-dateutil"><code>dateutil</code></a> module. It has <a href="http://labix.org/python-dateutil#head-ba5ffd4df8111d1b83fc194b97ebecf837add454">relative time deltas</a>:</p> <pre><code>import datetime from dateutil import relativedelta nextmonth = datetime.date.today() + relativedel...
46
2010-02-12T10:48:22Z
[ "python", "datetime", "date" ]
how to get the same day of next month of a given day in python using datetime
2,249,956
<p>i know using datetime.timedelta i can get the date of some days away form given date </p> <pre><code>daysafter = datetime.date.today() + datetime.timedelta(days=5) </code></pre> <p>but seems no datetime.timedelta(months=1)</p> <p>!Thanks for any help!</p>
20
2010-02-12T05:59:54Z
3,634,310
<pre><code>from calendar import mdays from datetime import datetime, timedelta today = datetime.now() next_month_of_today = today + timedelta(mdays[today.month]) </code></pre> <p>I don't want to import dateutil. Have a try this. Good luck.</p>
1
2010-09-03T09:02:33Z
[ "python", "datetime", "date" ]
how to get the same day of next month of a given day in python using datetime
2,249,956
<p>i know using datetime.timedelta i can get the date of some days away form given date </p> <pre><code>daysafter = datetime.date.today() + datetime.timedelta(days=5) </code></pre> <p>but seems no datetime.timedelta(months=1)</p> <p>!Thanks for any help!</p>
20
2010-02-12T05:59:54Z
10,626,630
<pre><code>import calendar, datetime def next_month ( date ): """return a date one month in advance of 'date'. If the next month has fewer days then the current date's month, this will return an early date in the following month.""" return date + datetime.timedelta(days=calendar.monthrange(date.year,d...
4
2012-05-16T20:59:35Z
[ "python", "datetime", "date" ]
how to get the same day of next month of a given day in python using datetime
2,249,956
<p>i know using datetime.timedelta i can get the date of some days away form given date </p> <pre><code>daysafter = datetime.date.today() + datetime.timedelta(days=5) </code></pre> <p>but seems no datetime.timedelta(months=1)</p> <p>!Thanks for any help!</p>
20
2010-02-12T05:59:54Z
23,447,314
<pre><code>from datetime import timedelta try: next_month = (x.replace(day=28) + timedelta(days=7)).replace(day=x.day) except ValueError: # assuming January 31 should return last day of February. next_month = (x + timedelta(days=31)).replace(day=1) - timedelta(days=1) </code></pre>
0
2014-05-03T16:56:27Z
[ "python", "datetime", "date" ]
how to get the same day of next month of a given day in python using datetime
2,249,956
<p>i know using datetime.timedelta i can get the date of some days away form given date </p> <pre><code>daysafter = datetime.date.today() + datetime.timedelta(days=5) </code></pre> <p>but seems no datetime.timedelta(months=1)</p> <p>!Thanks for any help!</p>
20
2010-02-12T05:59:54Z
24,654,569
<p>This is how I solved it.</p> <pre class="lang-python prettyprint-override"><code>from datetime import date try: (year, month) = divmod(date.today().month, 12) next_month = date.today().replace(year=date.today().year+year, month=month+1) except ValueError: # This day does not exist in next month </code><...
0
2014-07-09T13:07:00Z
[ "python", "datetime", "date" ]
how to get the same day of next month of a given day in python using datetime
2,249,956
<p>i know using datetime.timedelta i can get the date of some days away form given date </p> <pre><code>daysafter = datetime.date.today() + datetime.timedelta(days=5) </code></pre> <p>but seems no datetime.timedelta(months=1)</p> <p>!Thanks for any help!</p>
20
2010-02-12T05:59:54Z
38,089,808
<p>This work for me</p> <pre><code>import datetime import calendar def next_month_date(d): _year = d.year+(d.month//12) _month = 1 if (d.month//12) else d.month + 1 next_month_len = calendar.monthrange(_year,_month)[1] next_month = d if d.day &gt; next_month_len: next_month = next_month....
0
2016-06-29T03:20:09Z
[ "python", "datetime", "date" ]
Use psycopg2 to obtain long value from PostgreSQl
2,250,135
<p>I am facing problem in retrieving long value from PostgreSQL</p> <p>I use the following SQL command :</p> <pre><code>SELECT *, (extract(epoch FROM start_timestamp) * 1000) FROM lot WHERE EXTRACT(EPOCH FROM lot.start_timestamp) * 1000 &gt;=1265299200000 AND EXTRACT(EPOCH FROM lot.start_timestamp) * 1000 &lt;=1265...
1
2010-02-12T06:51:55Z
2,250,371
<p>I have the same results using both psycopg2 and pygres. While this select returns float value you can modify your code to format returned value:</p> <pre><code>def format_float_fld(v): #return str(v) return ('%20.0f' % (v)).strip() </code></pre> <p>If you use <code>str(s)</code> then you will get scientifi...
1
2010-02-12T08:05:55Z
[ "python", "postgresql" ]
Replace a word in a file
2,250,357
<p>I am new to Python programming...</p> <p>I have a .txt file....... It looks like..</p> <p>0,Salary,14000</p> <p>0,Bonus,5000</p> <p>0,gift,6000</p> <p>I want to to replace the first '0' value to '1' in each line. How can I do this? Any one can help me.... With sample code..</p> <p>Thanks in advance. Nimmyliji ...
2
2010-02-12T08:02:18Z
2,250,370
<pre><code>f = open(filepath,'r') data = f.readlines() f.close() edited = [] for line in data: edited.append( '1'+line[1:] ) f = open(filepath,'w') f.writelines(edited) f.flush() f.close() </code></pre> <p>Or in Python 2.5+:</p> <pre><code>with open(filepath,'r') as f: data = f.readlines() with open(outfile...
2
2010-02-12T08:05:41Z
[ "python", "file" ]
Replace a word in a file
2,250,357
<p>I am new to Python programming...</p> <p>I have a .txt file....... It looks like..</p> <p>0,Salary,14000</p> <p>0,Bonus,5000</p> <p>0,gift,6000</p> <p>I want to to replace the first '0' value to '1' in each line. How can I do this? Any one can help me.... With sample code..</p> <p>Thanks in advance. Nimmyliji ...
2
2010-02-12T08:02:18Z
2,250,384
<pre><code>o=open("output.txt","w") for line in open("file"): s=line.split(",") s[0]="1" o.write(','.join(s)) o.close() </code></pre> <p>Or you can use fileinput with in place edit</p> <pre><code>import fileinput for line in fileinput.FileInput("file",inplace=1): s=line.split(",") s[0]="1" pri...
2
2010-02-12T08:09:35Z
[ "python", "file" ]
Replace a word in a file
2,250,357
<p>I am new to Python programming...</p> <p>I have a .txt file....... It looks like..</p> <p>0,Salary,14000</p> <p>0,Bonus,5000</p> <p>0,gift,6000</p> <p>I want to to replace the first '0' value to '1' in each line. How can I do this? Any one can help me.... With sample code..</p> <p>Thanks in advance. Nimmyliji ...
2
2010-02-12T08:02:18Z
2,250,389
<p>I know that you're asking about Python, but forgive me for suggesting that perhaps a different tool is better for the job. :) It's a one-liner via <a href="http://en.wikipedia.org/wiki/Sed" rel="nofollow"><code>sed</code></a>:</p> <pre><code>sed 's/^0,/1,/' yourtextfile.txt &gt; output.txt </code></pre> <p>This ap...
4
2010-02-12T08:10:02Z
[ "python", "file" ]
Replace a word in a file
2,250,357
<p>I am new to Python programming...</p> <p>I have a .txt file....... It looks like..</p> <p>0,Salary,14000</p> <p>0,Bonus,5000</p> <p>0,gift,6000</p> <p>I want to to replace the first '0' value to '1' in each line. How can I do this? Any one can help me.... With sample code..</p> <p>Thanks in advance. Nimmyliji ...
2
2010-02-12T08:02:18Z
2,250,394
<pre><code>inFile = open("old.txt", "r") outFile = open("new.txt", "w") for line in inFile: outFile.write(",".join(["1"] + (line.split(","))[1:])) inFile.close() outFile.close() </code></pre> <p>If you would like something more general, take a look to Python <a href="http://docs.python.org/library/csv.html" rel=...
3
2010-02-12T08:11:08Z
[ "python", "file" ]
Python: Plotting a power law function with exponential cutoff
2,250,385
<p>I have a graph between 2 functions f and g. I know it follows a power law function with exponential cutoff.</p> <pre><code>f(x) = x**(-alpha)*e**(-lambda*x) </code></pre> <p>How do I find the value of exponent alpha?</p>
1
2010-02-12T08:09:53Z
2,250,466
<p>If you know that the points follow this law exactly, then invert the equation and put in an x and its corresponding f(x) value:</p> <pre><code>import math alpha = -(lamda*x + math.log(f(x)))/math.log(x) </code></pre> <p>But the if the points do not exactly fit the equation you will need to do some sort of regressi...
0
2010-02-12T08:32:45Z
[ "python" ]
Python: Plotting a power law function with exponential cutoff
2,250,385
<p>I have a graph between 2 functions f and g. I know it follows a power law function with exponential cutoff.</p> <pre><code>f(x) = x**(-alpha)*e**(-lambda*x) </code></pre> <p>How do I find the value of exponent alpha?</p>
1
2010-02-12T08:09:53Z
2,250,553
<p>If you have sufficiently close x points (for example one every 0.1), you can try the following:</p> <pre> ln(f(x)) = -alpha ln(x) - lambda x ln(f(x))' = - alpha / x - lambda </pre> <p>So depending on where you have your points: If you have a lot of points near 0, you can try:</p> <pre> h(x) = x ln(f(x))' = -alpha...
3
2010-02-12T08:51:51Z
[ "python" ]
Python: Plotting a power law function with exponential cutoff
2,250,385
<p>I have a graph between 2 functions f and g. I know it follows a power law function with exponential cutoff.</p> <pre><code>f(x) = x**(-alpha)*e**(-lambda*x) </code></pre> <p>How do I find the value of exponent alpha?</p>
1
2010-02-12T08:09:53Z
2,262,823
<p>The usual and general way of doing what you want is to perform a non-linear regression (even though, as noted in another response, it is possible to linearize the problem). Python can do this quite easily with the help of the <a href="http://www.scipy.org/" rel="nofollow">SciPy</a> package, which is used by many sc...
2
2010-02-14T21:18:23Z
[ "python" ]
Python: Plotting a power law function with exponential cutoff
2,250,385
<p>I have a graph between 2 functions f and g. I know it follows a power law function with exponential cutoff.</p> <pre><code>f(x) = x**(-alpha)*e**(-lambda*x) </code></pre> <p>How do I find the value of exponent alpha?</p>
1
2010-02-12T08:09:53Z
7,151,622
<p>It sounds like you might be trying to fit a power-law to a distribution with an exponential cutoff at the low end due to incompleteness - but I may be reading too far into your problem.</p> <p>If that is the problem you're dealing with, this website (and accompanying publication) addresses the issue: <a href="http:...
2
2011-08-22T18:07:55Z
[ "python" ]
Left inverse in numpy or scipy?
2,250,403
<p>I am trying to obtain the left inverse of a non-square matrix in python using either numpy or scipy. How can I translate the following Matlab code to Python?</p> <pre><code>&gt;&gt; A = [0,1; 0,1; 1,0] A = 0 1 0 1 1 0 &gt;&gt; y = [2;2;1] y = 2 2 1 &gt;&gt; A\y ans ...
9
2010-02-12T08:14:32Z
2,250,418
<p>Use <code>linalg.lstsq(A,y)</code> since <code>A</code> is not square. See <a href="http://www.scipy.org/NumPy_for_Matlab_Users" rel="nofollow">here</a> for details. You can use <code>linalg.solve(A,y)</code> if <code>A</code> is square, but not in your case.</p>
8
2010-02-12T08:20:10Z
[ "python", "matlab", "numpy", "linear-algebra", "matrix-inverse" ]
Left inverse in numpy or scipy?
2,250,403
<p>I am trying to obtain the left inverse of a non-square matrix in python using either numpy or scipy. How can I translate the following Matlab code to Python?</p> <pre><code>&gt;&gt; A = [0,1; 0,1; 1,0] A = 0 1 0 1 1 0 &gt;&gt; y = [2;2;1] y = 2 2 1 &gt;&gt; A\y ans ...
9
2010-02-12T08:14:32Z
2,250,430
<p>I haven't tested it, but according to <a href="http://mathesaurus.sourceforge.net/matlab-numpy.html" rel="nofollow">this web page</a> it is:</p> <pre><code>linalg.solve(A,y) </code></pre>
0
2010-02-12T08:23:21Z
[ "python", "matlab", "numpy", "linear-algebra", "matrix-inverse" ]
Left inverse in numpy or scipy?
2,250,403
<p>I am trying to obtain the left inverse of a non-square matrix in python using either numpy or scipy. How can I translate the following Matlab code to Python?</p> <pre><code>&gt;&gt; A = [0,1; 0,1; 1,0] A = 0 1 0 1 1 0 &gt;&gt; y = [2;2;1] y = 2 2 1 &gt;&gt; A\y ans ...
9
2010-02-12T08:14:32Z
2,252,642
<p>You can also look for the equivalent of the pseudo-inverse function <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.pinv.html" rel="nofollow"><code>pinv</code></a> in <code>numpy/scipy</code>, as an alternative to the other answers that is.</p>
2
2010-02-12T14:58:25Z
[ "python", "matlab", "numpy", "linear-algebra", "matrix-inverse" ]
Left inverse in numpy or scipy?
2,250,403
<p>I am trying to obtain the left inverse of a non-square matrix in python using either numpy or scipy. How can I translate the following Matlab code to Python?</p> <pre><code>&gt;&gt; A = [0,1; 0,1; 1,0] A = 0 1 0 1 1 0 &gt;&gt; y = [2;2;1] y = 2 2 1 &gt;&gt; A\y ans ...
9
2010-02-12T08:14:32Z
2,253,623
<p>Here is a method that will work with sparse matrices (which from your comments is what you want) which uses the leastsq function from the optimize package</p> <pre><code>from numpy import * from scipy.sparse import csr_matrix from scipy.optimize import leastsq from numpy.random import rand A=csr_matrix([[0.,1.],[0...
2
2010-02-12T17:10:54Z
[ "python", "matlab", "numpy", "linear-algebra", "matrix-inverse" ]
Left inverse in numpy or scipy?
2,250,403
<p>I am trying to obtain the left inverse of a non-square matrix in python using either numpy or scipy. How can I translate the following Matlab code to Python?</p> <pre><code>&gt;&gt; A = [0,1; 0,1; 1,0] A = 0 1 0 1 1 0 &gt;&gt; y = [2;2;1] y = 2 2 1 &gt;&gt; A\y ans ...
9
2010-02-12T08:14:32Z
2,366,023
<p>For those who wish to solve large sparse least squares problems:</p> <p>I have added the LSQR algorithm to SciPy. With the next release, you'll be able to do:</p> <pre><code>from scipy.sparse import csr_matrix from scipy.sparse.linalg import lsqr import numpy as np A = csr_matrix([[0., 1], [0, 1], [1, 0]]) b = n...
2
2010-03-02T19:21:22Z
[ "python", "matlab", "numpy", "linear-algebra", "matrix-inverse" ]
Left inverse in numpy or scipy?
2,250,403
<p>I am trying to obtain the left inverse of a non-square matrix in python using either numpy or scipy. How can I translate the following Matlab code to Python?</p> <pre><code>&gt;&gt; A = [0,1; 0,1; 1,0] A = 0 1 0 1 1 0 &gt;&gt; y = [2;2;1] y = 2 2 1 &gt;&gt; A\y ans ...
9
2010-02-12T08:14:32Z
5,957,184
<p>You can use lsqr from scipy.sparse.linalg to solve sparse matrix systems with least squares</p>
0
2011-05-10T22:20:29Z
[ "python", "matlab", "numpy", "linear-algebra", "matrix-inverse" ]
Can someone help me with this JAVA SAXParser?
2,250,450
<p>I've been fiddling for 3 hours and I can't get this F*<strong>** parser to work. Sorry for cursing. I don't understand why I can't find **one decent tutorial</strong> that does exactly what I want. </p> <p>I just want to send the function a String/XML. Then, parse it. it's not that hard. In python, I can do it wit...
2
2010-02-12T08:29:14Z
2,250,495
<p>You have to extends your default handler DefaultHandler. For example, try this:</p> <pre><code> saxParser.parse( new InputSource(new StringReader(thexml)) , new DefaultHandler() { public void startElement(String uri, String localName, String qName, Attributes attributes) ...
3
2010-02-12T08:39:53Z
[ "java", "python", "xml" ]
Can someone help me with this JAVA SAXParser?
2,250,450
<p>I've been fiddling for 3 hours and I can't get this F*<strong>** parser to work. Sorry for cursing. I don't understand why I can't find **one decent tutorial</strong> that does exactly what I want. </p> <p>I just want to send the function a String/XML. Then, parse it. it's not that hard. In python, I can do it wit...
2
2010-02-12T08:29:14Z
2,250,497
<p>I don't know if this would be an option for you, but since Groovy and Java play nice together why not try one of the <a href="http://groovy.codehaus.org/Processing+XML" rel="nofollow">Groovy options</a> to process XML.</p> <p>In particular look at the XML Slurper (<code>http://groovy.codehaus.org/Reading+XML+using+...
0
2010-02-12T08:40:49Z
[ "java", "python", "xml" ]
Can someone help me with this JAVA SAXParser?
2,250,450
<p>I've been fiddling for 3 hours and I can't get this F*<strong>** parser to work. Sorry for cursing. I don't understand why I can't find **one decent tutorial</strong> that does exactly what I want. </p> <p>I just want to send the function a String/XML. Then, parse it. it's not that hard. In python, I can do it wit...
2
2010-02-12T08:29:14Z
2,250,502
<p>Ok, so what you need to do is to implement your own handler (instead of using default one). So replace </p> <pre><code>saxParser.parse( thexml , new DefaultHandler() ); </code></pre> <p>with</p> <pre><code> saxParser.parse( thexml , new MyFreakingHandler() ); </code></pre> <p>where MyFreakingHandler implements...
3
2010-02-12T08:41:46Z
[ "java", "python", "xml" ]
Can someone help me with this JAVA SAXParser?
2,250,450
<p>I've been fiddling for 3 hours and I can't get this F*<strong>** parser to work. Sorry for cursing. I don't understand why I can't find **one decent tutorial</strong> that does exactly what I want. </p> <p>I just want to send the function a String/XML. Then, parse it. it's not that hard. In python, I can do it wit...
2
2010-02-12T08:29:14Z
2,250,508
<p>You must extend DefaultHandler with your own implementation. The sax parser is good if you are working with large documents. If not, you might be better off with another xml parser, for example dom4j.</p> <p>Here's a simple <a href="http://developerlife.com/tutorials/?p=29" rel="nofollow">sax tutorial</a></p>
2
2010-02-12T08:42:08Z
[ "java", "python", "xml" ]
Can someone help me with this JAVA SAXParser?
2,250,450
<p>I've been fiddling for 3 hours and I can't get this F*<strong>** parser to work. Sorry for cursing. I don't understand why I can't find **one decent tutorial</strong> that does exactly what I want. </p> <p>I just want to send the function a String/XML. Then, parse it. it's not that hard. In python, I can do it wit...
2
2010-02-12T08:29:14Z
2,250,515
<p>Using the Java XPath API</p> <pre><code>XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xPathExpression = xPath.compile("//first_name"); NodeList nodes = (NodeList) xPathExpression.evaluate( new InputSource(new FileInputStream(the_xml)), XPathConstants.NODESE...
0
2010-02-12T08:43:56Z
[ "java", "python", "xml" ]
Entry with suggestions
2,250,477
<p>I'm building a small PyGTK application and I have an text input field (currently a ComboBoxEntry) which is populated with a few values that the user should be able to choose from.</p> <p>I think what I want to do is to filter out the matching fields and only show those ones so the user using the keyboard arrows can...
5
2010-02-12T08:35:36Z
2,250,493
<p>You may want to look at how <a href="http://projects.gnome.org/deskbar-applet/" rel="nofollow">Deskbar Applet</a>'s <code>Cuemiac</code> does it.</p>
0
2010-02-12T08:39:28Z
[ "python", "pygtk" ]
Entry with suggestions
2,250,477
<p>I'm building a small PyGTK application and I have an text input field (currently a ComboBoxEntry) which is populated with a few values that the user should be able to choose from.</p> <p>I think what I want to do is to filter out the matching fields and only show those ones so the user using the keyboard arrows can...
5
2010-02-12T08:35:36Z
2,252,724
<p>Well, you obviously want to deal with prefixes so you'll probably want to use some sort of trie. Of course, there are issues to deal with. For instance, after a person has typed in a few letters ( or maybe even just one) you will want to either traverse the rest of the branches of the trie to find suggestions, or ha...
0
2010-02-12T15:12:30Z
[ "python", "pygtk" ]
Entry with suggestions
2,250,477
<p>I'm building a small PyGTK application and I have an text input field (currently a ComboBoxEntry) which is populated with a few values that the user should be able to choose from.</p> <p>I think what I want to do is to filter out the matching fields and only show those ones so the user using the keyboard arrows can...
5
2010-02-12T08:35:36Z
2,262,200
<p>An <code>Entry</code> with an <a href="http://www.pygtk.org/docs/pygtk/class-gtkentrycompletion.html"><code>EntryCompletion</code></a> seems more appropriate than a <code>ComboBoxEntry</code>. As always, the <a href="http://www.pygtk.org/pygtk2tutorial/sec-EntryCompletion.html">tutorial</a> is a good start.</p> <p...
5
2010-02-14T18:21:13Z
[ "python", "pygtk" ]
Python: find a list within members of another list(in order)
2,250,633
<p>If I have this:</p> <pre><code>a='abcdefghij' b='de' </code></pre> <p>Then this finds b in a:</p> <pre><code>b in a =&gt; True </code></pre> <p>Is there a way of doing an similar thing with lists? Like this:</p> <pre><code>a=list('abcdefghij') b=list('de') b in a =&gt; False </code></pre> <p>The 'False' resu...
12
2010-02-12T09:06:30Z
2,250,763
<p>So, if you aren't concerned about the order the subset appears, you can do:</p> <pre><code>a=list('abcdefghij') b=list('de') set(b).issubset(set(a)) True </code></pre> <p>Edit after you clarify: If you need to preserve order, and the list is indeed characters as in your question, you can use:</p> <pre><code>''.j...
2
2010-02-12T09:29:08Z
[ "list", "python" ]
Python: find a list within members of another list(in order)
2,250,633
<p>If I have this:</p> <pre><code>a='abcdefghij' b='de' </code></pre> <p>Then this finds b in a:</p> <pre><code>b in a =&gt; True </code></pre> <p>Is there a way of doing an similar thing with lists? Like this:</p> <pre><code>a=list('abcdefghij') b=list('de') b in a =&gt; False </code></pre> <p>The 'False' resu...
12
2010-02-12T09:06:30Z
2,250,774
<p>Not sure how complex your application is, but for pattern matching in lists, <a href="http://www.google.ie/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;ved=0CAkQFjAA&amp;url=http%3A%2F%2Fpyparsing.wikispaces.com%2F&amp;ei=2x91S5fqHo3X4ga5qc3HCg&amp;usg=AFQjCNHYfzwvzIxYKcHuYSR5TCAIrvtEqw&amp;sig2=u82fak0P7La1jRKSx...
1
2010-02-12T09:31:39Z
[ "list", "python" ]
Python: find a list within members of another list(in order)
2,250,633
<p>If I have this:</p> <pre><code>a='abcdefghij' b='de' </code></pre> <p>Then this finds b in a:</p> <pre><code>b in a =&gt; True </code></pre> <p>Is there a way of doing an similar thing with lists? Like this:</p> <pre><code>a=list('abcdefghij') b=list('de') b in a =&gt; False </code></pre> <p>The 'False' resu...
12
2010-02-12T09:06:30Z
2,250,878
<p>Don't know if this is very pythonic, but I would do it in this way:</p> <pre><code>def is_sublist(a, b): if a == []: return True if b == []: return False return b[:len(a)] == a or is_sublist(a, b[1:]) </code></pre> <p>Shorter solution is offered in this <a href="http://mail.python.org/pipermail/python-...
4
2010-02-12T09:50:24Z
[ "list", "python" ]
Python: find a list within members of another list(in order)
2,250,633
<p>If I have this:</p> <pre><code>a='abcdefghij' b='de' </code></pre> <p>Then this finds b in a:</p> <pre><code>b in a =&gt; True </code></pre> <p>Is there a way of doing an similar thing with lists? Like this:</p> <pre><code>a=list('abcdefghij') b=list('de') b in a =&gt; False </code></pre> <p>The 'False' resu...
12
2010-02-12T09:06:30Z
2,250,918
<p>I suspect there are more pythonic ways of doing it, but at least it gets the job done:</p> <pre><code>l=list('abcdefgh') pat=list('de') print pat in l # Returns False print any(l[i:i+len(pat)]==pat for i in xrange(len(l)-len(pat)+1)) </code></pre>
11
2010-02-12T09:56:41Z
[ "list", "python" ]
Python: find a list within members of another list(in order)
2,250,633
<p>If I have this:</p> <pre><code>a='abcdefghij' b='de' </code></pre> <p>Then this finds b in a:</p> <pre><code>b in a =&gt; True </code></pre> <p>Is there a way of doing an similar thing with lists? Like this:</p> <pre><code>a=list('abcdefghij') b=list('de') b in a =&gt; False </code></pre> <p>The 'False' resu...
12
2010-02-12T09:06:30Z
2,250,981
<pre><code>&gt;&gt;&gt;''.join(b) in ''.join(a) True </code></pre>
1
2010-02-12T10:06:55Z
[ "list", "python" ]
Python: find a list within members of another list(in order)
2,250,633
<p>If I have this:</p> <pre><code>a='abcdefghij' b='de' </code></pre> <p>Then this finds b in a:</p> <pre><code>b in a =&gt; True </code></pre> <p>Is there a way of doing an similar thing with lists? Like this:</p> <pre><code>a=list('abcdefghij') b=list('de') b in a =&gt; False </code></pre> <p>The 'False' resu...
12
2010-02-12T09:06:30Z
2,251,082
<p>Use the lists' string representation and remove the square braces. :)</p> <pre><code>def is_sublist(a, b): return str(a)[1:-1] in str(b) </code></pre> <p>EDIT: Right, there are false positives ... e.g. <code>is_sublist([1], [11])</code>. Crappy answer. :)</p>
-1
2010-02-12T10:27:14Z
[ "list", "python" ]
Python: find a list within members of another list(in order)
2,250,633
<p>If I have this:</p> <pre><code>a='abcdefghij' b='de' </code></pre> <p>Then this finds b in a:</p> <pre><code>b in a =&gt; True </code></pre> <p>Is there a way of doing an similar thing with lists? Like this:</p> <pre><code>a=list('abcdefghij') b=list('de') b in a =&gt; False </code></pre> <p>The 'False' resu...
12
2010-02-12T09:06:30Z
2,251,638
<p>I think this will be faster - It uses C implementation <code>list.index</code> to search for the first element, and goes from there on.</p> <pre><code>def find_sublist(sub, bigger): if not bigger: return -1 if not sub: return 0 first, rest = sub[0], sub[1:] pos = 0 try: w...
7
2010-02-12T12:07:36Z
[ "list", "python" ]
Python: find a list within members of another list(in order)
2,250,633
<p>If I have this:</p> <pre><code>a='abcdefghij' b='de' </code></pre> <p>Then this finds b in a:</p> <pre><code>b in a =&gt; True </code></pre> <p>Is there a way of doing an similar thing with lists? Like this:</p> <pre><code>a=list('abcdefghij') b=list('de') b in a =&gt; False </code></pre> <p>The 'False' resu...
12
2010-02-12T09:06:30Z
2,251,709
<p>I timed the accepted solution, my earlier solution and a new one with an index. The one with the index is clearly best.</p> <p>EDIT: I timed nosklo's solution, it's even much better than what I came up with. :)</p> <pre><code>def is_sublist_index(a, b): if not a: return True index = 0 for elem...
3
2010-02-12T12:20:30Z
[ "list", "python" ]
how change my pinax basic_project from chinese to english
2,250,696
<p>I made a pinax basic_project,and i found this in settings.py:</p> <pre><code>LANGUAGE_CODE = 'en' </code></pre> <p>and my pinax is not only en :</p> <p><img src="http://omploader.org/vM2oyNw" alt="alt text"></p> <p>why?</p>
0
2010-02-12T09:16:26Z
2,251,639
<p>It should have got something to do with your browser's language selection preference.</p>
0
2010-02-12T12:07:40Z
[ "python", "django" ]
Using subprocess.call to crop an image
2,250,933
<p>I'm having trouble in my python script, and I don't understand it : </p> <pre><code>subprocess.call(['convert', file, '-crop', '80x10+90+980', '+repage', 'test.jpg']) </code></pre> <p>Returns "<em>invalid argument - -crop</em>"</p> <p>But if I run this from the command line, it works fine : </p> <pre><code>conve...
1
2010-02-12T09:58:44Z
2,250,963
<p>Is there more than one <code>convert</code> in the system? Try an absolute path to the command you want?</p>
2
2010-02-12T10:03:43Z
[ "python", "imagemagick" ]
Using subprocess.call to crop an image
2,250,933
<p>I'm having trouble in my python script, and I don't understand it : </p> <pre><code>subprocess.call(['convert', file, '-crop', '80x10+90+980', '+repage', 'test.jpg']) </code></pre> <p>Returns "<em>invalid argument - -crop</em>"</p> <p>But if I run this from the command line, it works fine : </p> <pre><code>conve...
1
2010-02-12T09:58:44Z
2,250,967
<p>What about using the <a href="http://www.pythonware.com/products/pil/" rel="nofollow">python image library instead</a>? That seems much more reliable than to call a subprocess (especially for error handling...).</p>
1
2010-02-12T10:04:41Z
[ "python", "imagemagick" ]
Using subprocess.call to crop an image
2,250,933
<p>I'm having trouble in my python script, and I don't understand it : </p> <pre><code>subprocess.call(['convert', file, '-crop', '80x10+90+980', '+repage', 'test.jpg']) </code></pre> <p>Returns "<em>invalid argument - -crop</em>"</p> <p>But if I run this from the command line, it works fine : </p> <pre><code>conve...
1
2010-02-12T09:58:44Z
2,251,018
<p><code>file</code> is a <strong>__<em>builtin</em>__</strong> class. Overriding it may produce unwanted results. Try using a different variable name.</p>
1
2010-02-12T10:13:28Z
[ "python", "imagemagick" ]
Using subprocess.call to crop an image
2,250,933
<p>I'm having trouble in my python script, and I don't understand it : </p> <pre><code>subprocess.call(['convert', file, '-crop', '80x10+90+980', '+repage', 'test.jpg']) </code></pre> <p>Returns "<em>invalid argument - -crop</em>"</p> <p>But if I run this from the command line, it works fine : </p> <pre><code>conve...
1
2010-02-12T09:58:44Z
2,251,166
<p>I've actually tried your code:</p> <pre><code>&gt;&gt;&gt; import subprocess &gt;&gt;&gt; subprocess.call(['convert', 'capa.jpg', '-crop', '80x10+90+980', '+repage', 'capa2.jpg']) 0 &gt;&gt;&gt; </code></pre> <p>And it works for me!</p> <p>So you must have something wrong, somewhere else. Check our assumptions a...
1
2010-02-12T10:42:04Z
[ "python", "imagemagick" ]
sphinx (python) pdf generator
2,251,450
<p>I use <a href="http://sphinx.pocoo.org/">sphinx python documentation generator</a>. Creating pdf documents are very easy and simple but.... i have one problem. </p> <p>All generated pdf documents have english words like "chapter", "release", "part". Is it possible change it? How set another words or remove it?</p>...
11
2010-02-12T11:33:16Z
2,252,547
<p>Sphinx generates LaTeX files, and then uses LaTeX to generate the PDF. So yes, you can, but it typically involves learning LaTeX and changing the LaTeX macros. I did a quick search and couldn't find any place where the "Chapter" was defined, so it's probably defined in the Bjarne chapter heading style (which is the ...
8
2010-02-12T14:45:43Z
[ "python", "pdf", "documentation", "pdf-generation", "python-sphinx" ]
sphinx (python) pdf generator
2,251,450
<p>I use <a href="http://sphinx.pocoo.org/">sphinx python documentation generator</a>. Creating pdf documents are very easy and simple but.... i have one problem. </p> <p>All generated pdf documents have english words like "chapter", "release", "part". Is it possible change it? How set another words or remove it?</p>...
11
2010-02-12T11:33:16Z
5,246,570
<p>In your <code>conf.py</code>, there is the following paragraph (around line 57 in a <code>conf.py</code> created by <code>sphinx-quickstart</code>):</p> <pre><code># The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None </code></pre> <p>In my...
11
2011-03-09T13:37:16Z
[ "python", "pdf", "documentation", "pdf-generation", "python-sphinx" ]
Ajax Form submission in Google App Engine with jQuery
2,251,505
<p>could not figure out why it is not working:</p> <p>i need to send request to server, generate some fragment of html in python with meanCal method, and then want that fragment embedded into submitting html file using calculation method and dynamically shows in dyContent div. all the processes are done by single cli...
1
2010-02-12T11:44:11Z
2,255,346
<p>To submit a form via AJAX, you'd better consider using <a href="http://malsup.com/jquery/form" rel="nofollow">Form Plugins</a>. You will not need to build the parameter to be sent by yourself.</p> <p>Also, it's better if you make sure that the form is working without javascript enabled. This way, your page will sti...
1
2010-02-12T21:50:07Z
[ "jquery", "python", "ajax", "google-app-engine" ]
Ajax Form submission in Google App Engine with jQuery
2,251,505
<p>could not figure out why it is not working:</p> <p>i need to send request to server, generate some fragment of html in python with meanCal method, and then want that fragment embedded into submitting html file using calculation method and dynamically shows in dyContent div. all the processes are done by single cli...
1
2010-02-12T11:44:11Z
2,620,472
<p>The <code>.submit()</code> method actually submits the form as if you pressed the submit button. Using jQuery, you can submit the form depending on certain conditions only, or as a response to an event. </p> <p>If you want to send the form data to the server and get a response back, you need to create a data sting ...
1
2010-04-12T07:26:54Z
[ "jquery", "python", "ajax", "google-app-engine" ]
Ajax Form submission in Google App Engine with jQuery
2,251,505
<p>could not figure out why it is not working:</p> <p>i need to send request to server, generate some fragment of html in python with meanCal method, and then want that fragment embedded into submitting html file using calculation method and dynamically shows in dyContent div. all the processes are done by single cli...
1
2010-02-12T11:44:11Z
13,830,215
<p>To debug the python code in your GAE app, use the app engine launcher log on a running app:</p> <p><img src="http://i.stack.imgur.com/Erww6.png" alt="Using Google App Engine logs"></p> <p>This should help clarify where the app is failing. I would also suggest sprinkling some calls to logging.info (or logging.debug...
2
2012-12-11T23:24:28Z
[ "jquery", "python", "ajax", "google-app-engine" ]
Getting raw post data in Google App Engine Python API
2,251,584
<p>I am trying to get raw data sent as post to Google App engine, using self.request.get('content'), but in vain. It returns empty. I am sure the data is being sent from the client, coz I checked with another simple server code.</p> <p>Any idea what I am doing wrong? I am using the following code on the client side ge...
3
2010-02-12T12:00:22Z
2,252,253
<p><code>self.request.get('content')</code> will give you data sent with the argument name 'content'. If you want the raw post data, use <code>self.request.body</code>.</p>
6
2010-02-12T14:04:07Z
[ "iphone", "python", "google-app-engine", "post", "request" ]
Getting raw post data in Google App Engine Python API
2,251,584
<p>I am trying to get raw data sent as post to Google App engine, using self.request.get('content'), but in vain. It returns empty. I am sure the data is being sent from the client, coz I checked with another simple server code.</p> <p>Any idea what I am doing wrong? I am using the following code on the client side ge...
3
2010-02-12T12:00:22Z
2,252,773
<p>Try submitting the POST data with a content type other than <code>application/x-www-form-urlencoded</code>, which is the default when a form is submitted by a browser. If you use a different content type, the raw post data will be in <code>self.request.body</code>, as Wooble suggested.</p> <p>If this is actually c...
4
2010-02-12T15:20:35Z
[ "iphone", "python", "google-app-engine", "post", "request" ]
Django version selection
2,251,696
<p>Greetings, I am currently working on a long term project that uses Django 1.1.1, and we are planning to release it around march of 2010.</p> <p>Now while surfing I came upon to this <a href="http://djangoadvent.com/1.2/welcome-django-advent/" rel="nofollow">article</a> which says the planned release date of Django ...
1
2010-02-12T12:17:45Z
2,251,799
<p>The upgrade path is not difficult. I would familiarize yourself with the differences and avoid deprecations, but continue on the battle tested 1.1 branch. While you should never ever trust software release dates, you also probably don't want to bet your farm on a brand new branch with features you clearly don't ne...
1
2010-02-12T12:40:01Z
[ "python", "django" ]
Django version selection
2,251,696
<p>Greetings, I am currently working on a long term project that uses Django 1.1.1, and we are planning to release it around march of 2010.</p> <p>Now while surfing I came upon to this <a href="http://djangoadvent.com/1.2/welcome-django-advent/" rel="nofollow">article</a> which says the planned release date of Django ...
1
2010-02-12T12:17:45Z
2,251,822
<p>I'd say only develop for the latest version if there is a specific feature you need/like. Read up on it so you know of course what is in store. </p> <p>1.0 onwards. I've found swapping django versions to be relatively trouble free. At any stage all you need to do is swap symlinks on a source tree on your test serve...
4
2010-02-12T12:43:55Z
[ "python", "django" ]
Django version selection
2,251,696
<p>Greetings, I am currently working on a long term project that uses Django 1.1.1, and we are planning to release it around march of 2010.</p> <p>Now while surfing I came upon to this <a href="http://djangoadvent.com/1.2/welcome-django-advent/" rel="nofollow">article</a> which says the planned release date of Django ...
1
2010-02-12T12:17:45Z
2,257,671
<p>Part of our current application under development is being put into production now, but we hope to use Django 1.2 final. Our strategy is to write code, test and deploy using Django 1.1.1, but also test using <a href="http://pypi.python.org/pypi/virtualenv" rel="nofollow">virtualenv</a>. There's really no reason no...
1
2010-02-13T13:26:37Z
[ "python", "django" ]
How to test a folder for new files using python
2,251,751
<p>Hello How would you go about testing to see if 2 folders contain the same files, and then to be able to manipulate ONLY the file which is new.</p> <pre><code>A = listdir('C:/') B = listdir('D:/') If A==B </code></pre> <p>...</p> <p>I know this could be used to test if directories are different but is there a bet...
2
2010-02-12T12:29:15Z
2,251,763
<pre><code>A = set(os.listdir('C:\\')) B = set(os.listdir('D:\\')) print 'Files in A but not in B:', A - B print 'Files in B but not in A:', B - A </code></pre>
4
2010-02-12T12:32:45Z
[ "python", "file", "directory" ]
How to test a folder for new files using python
2,251,751
<p>Hello How would you go about testing to see if 2 folders contain the same files, and then to be able to manipulate ONLY the file which is new.</p> <pre><code>A = listdir('C:/') B = listdir('D:/') If A==B </code></pre> <p>...</p> <p>I know this could be used to test if directories are different but is there a bet...
2
2010-02-12T12:29:15Z
2,251,820
<p><a href="http://docs.python.org/library/filecmp.html" rel="nofollow">http://docs.python.org/library/filecmp.html</a></p> <p><a href="http://docs.python.org/library/filecmp.html#the-dircmp-class" rel="nofollow">http://docs.python.org/library/filecmp.html#the-dircmp-class</a></p> <pre><code>import filecmp compare = ...
8
2010-02-12T12:43:28Z
[ "python", "file", "directory" ]
What are the functions / AT commands to reconnect a disconnected GSM modem?
2,251,796
<ol> <li><p>I have a GSM modem that disconnect after a while, maybe because of low signal. I am just wondering is there an AT command that can detect the disconnection and re-establish a reconnection.</p></li> <li><p>Is there a way in code (preferably python) I can detect the disconnection and re-establish a reconnecti...
2
2010-02-12T12:39:13Z
2,251,902
<p>Depending on what type of connection, circuit switched (CS) or packet switched (PS), the monitoring will be a little bit different. To detect a disconnect you can enable UR (unsolicited result) code <code>AT+CPSB=1</code> to monitor PDP context activity (aka packet switched connections). For circuit switched calls y...
4
2010-02-12T13:01:22Z
[ "python", "gsm", "at-command" ]
What are the functions / AT commands to reconnect a disconnected GSM modem?
2,251,796
<ol> <li><p>I have a GSM modem that disconnect after a while, maybe because of low signal. I am just wondering is there an AT command that can detect the disconnection and re-establish a reconnection.</p></li> <li><p>Is there a way in code (preferably python) I can detect the disconnection and re-establish a reconnecti...
2
2010-02-12T12:39:13Z
2,251,941
<p>You can try to check the signal strength on a regular basis with AT+CSQ. If the signal goes under a given threshold consider that you are disconnected and force a new connection.</p> <p>You can try the very nice pyserial <a href="http://pyserial.sourceforge.net/" rel="nofollow">http://pyserial.sourceforge.net/</a> ...
0
2010-02-12T13:10:18Z
[ "python", "gsm", "at-command" ]
What are the functions / AT commands to reconnect a disconnected GSM modem?
2,251,796
<ol> <li><p>I have a GSM modem that disconnect after a while, maybe because of low signal. I am just wondering is there an AT command that can detect the disconnection and re-establish a reconnection.</p></li> <li><p>Is there a way in code (preferably python) I can detect the disconnection and re-establish a reconnecti...
2
2010-02-12T12:39:13Z
9,159,117
<p>Here is how I do it with <a href="http://www.telit.com/" rel="nofollow">Telit</a> devices:</p> <p>I use <code>AT+CGREG=1</code> to subscribe to unsolicited messages. Extract from documentation:</p> <pre><code>+CGREG - GPRS Network Registration Status AT+CGREG=[&lt;n&gt;] Set command controls the presentation of an...
2
2012-02-06T11:00:26Z
[ "python", "gsm", "at-command" ]
Python, IMAP and GMail. Mark messages as SEEN
2,251,977
<p>I have a python script that has to fetch unseen messages, process it, and mark as seen (or read)</p> <p>I do this after login in:</p> <pre><code> typ, data = self.server.imap_server.search(None, '(UNSEEN)') for num in data[0].split(): print "Mensage " + str(num) + " mark" self.server.imap_s...
6
2010-02-12T13:16:56Z
2,257,102
<p>I think the flag names need to start with a backslash, eg: \SEEN</p>
3
2010-02-13T09:41:22Z
[ "python", "email", "gmail", "imap" ]
Python, IMAP and GMail. Mark messages as SEEN
2,251,977
<p>I have a python script that has to fetch unseen messages, process it, and mark as seen (or read)</p> <p>I do this after login in:</p> <pre><code> typ, data = self.server.imap_server.search(None, '(UNSEEN)') for num in data[0].split(): print "Mensage " + str(num) + " mark" self.server.imap_s...
6
2010-02-12T13:16:56Z
3,140,319
<pre><code>import imaplib obj = imaplib.IMAP4_SSL('imap.gmail.com', '993') obj.login('user', 'password') obj.select('Inbox') &lt;--- it will select inbox typ ,data = obj.search(None,'UnSeen') obj.store(data[0].replace(' ',','),'+FLAGS','\Seen') </code></pre>
12
2010-06-29T11:48:42Z
[ "python", "email", "gmail", "imap" ]
What behaviour is preferred? (Embedding Python)
2,252,089
<p>I'm embedding Python into an application. <code>MyClass.name</code> is a property of <code>str</code> type:</p> <pre><code>&gt;&gt;&gt; foo = MyClass() &gt;&gt;&gt; foo.name 'Default Name' </code></pre> <p>Should I allow users to do this:</p> <pre><code>&gt;&gt;&gt; foo.name = 123 &gt;&gt;&gt; foo.name '123' </co...
3
2010-02-12T13:36:27Z
2,252,202
<p>That depends really on what you want to achieve. I think the best solution is to allow any object, that can be coerced to string and then use python properties.</p> <pre><code>class MyClass(object): def set_name(self, name): self._name = str(name) def get_name(self): return self._name name = propert(...
1
2010-02-12T13:56:52Z
[ "python" ]
What behaviour is preferred? (Embedding Python)
2,252,089
<p>I'm embedding Python into an application. <code>MyClass.name</code> is a property of <code>str</code> type:</p> <pre><code>&gt;&gt;&gt; foo = MyClass() &gt;&gt;&gt; foo.name 'Default Name' </code></pre> <p>Should I allow users to do this:</p> <pre><code>&gt;&gt;&gt; foo.name = 123 &gt;&gt;&gt; foo.name '123' </co...
3
2010-02-12T13:36:27Z
2,252,272
<p>Definitely raise a <code>TypeError</code> rather than attempting to automatically coerce. Normally I would be conservative about saying that something is "pythonic" or not – it's one of those words that really just means "the speaker thinks that this is good" – but if it means anything at all, it must refer to ...
4
2010-02-12T14:07:44Z
[ "python" ]
ImageField not failing at IOError exception
2,252,355
<p>Hay, i have a model which saves 2 images</p> <pre><code>class Picture(models.Model): picture = models.ImageField(upload_to=make_filename) thumbnail = models.ImageField(upload_to=make_thumb_filename) car = models.ForeignKey('Car') created_on = models.DateField(auto_now_add=True) updated_on = mode...
0
2010-02-12T14:20:09Z
2,252,549
<p>The code that (I assume) throws the IOError is being run <em>after</em> you call the <code>super(Picture,self).save()</code> method. Because of this, the picture getting written to the database even if the exception is thrown.</p> <p>You just need to move the <code>super</code> call to after the setup code.</p> <p...
1
2010-02-12T14:45:51Z
[ "python", "django", "ioerror", "imagefield" ]
Efficent way to bulk insert with get_or_create() in Django (SQL, Python, Django)
2,252,530
<p>Is there a more efficent way for doing this?</p> <pre><code>for item in item_list: e, new = Entry.objects.get_or_create( field1 = item.field1, field2 = item.field2, ) </code></pre>
15
2010-02-12T14:44:30Z
2,252,564
<p>Depends on what you are aiming at. You can use <code>manage.py</code>'s <a href="http://docs.djangoproject.com/en/dev/ref/django-admin/#loaddata-fixture-fixture" rel="nofollow"><code>loaddata</code></a> function to load data in a appropriate format (JSON, XML, YAML,...).</p> <p>See also <a href="http://www.pubbs.ne...
4
2010-02-12T14:48:22Z
[ "python", "django", "bulkinsert" ]
Efficent way to bulk insert with get_or_create() in Django (SQL, Python, Django)
2,252,530
<p>Is there a more efficent way for doing this?</p> <pre><code>for item in item_list: e, new = Entry.objects.get_or_create( field1 = item.field1, field2 = item.field2, ) </code></pre>
15
2010-02-12T14:44:30Z
2,252,643
<p>I'd say there isn't. </p> <p>But I wonder what type your <code>item</code>s are, if they have <code>field1</code> and <code>field2</code> as attributes. Looks like there exists another class representing an entry but is not derived from <code>models.Model</code>. Maybe you can omit this class and create <code>Entry...
0
2010-02-12T14:58:36Z
[ "python", "django", "bulkinsert" ]
Efficent way to bulk insert with get_or_create() in Django (SQL, Python, Django)
2,252,530
<p>Is there a more efficent way for doing this?</p> <pre><code>for item in item_list: e, new = Entry.objects.get_or_create( field1 = item.field1, field2 = item.field2, ) </code></pre>
15
2010-02-12T14:44:30Z
2,252,961
<p>If you're not sure whether the things in your <code>item_list</code> already exist in your DB, and you need the model objects, then <code>get_or_create</code> is definitely the way to go. </p> <p>If you know the items are NOT in your DB, you would be much better doing:</p> <pre><code>for item in item_list: new...
1
2010-02-12T15:42:58Z
[ "python", "django", "bulkinsert" ]
Efficent way to bulk insert with get_or_create() in Django (SQL, Python, Django)
2,252,530
<p>Is there a more efficent way for doing this?</p> <pre><code>for item in item_list: e, new = Entry.objects.get_or_create( field1 = item.field1, field2 = item.field2, ) </code></pre>
15
2010-02-12T14:44:30Z
2,254,452
<p>You can't do decent bulk insertions with get_or_create (or even create), and there's no API for doing this easily.</p> <p>If your table is simple enough that creating rows with raw SQL isn't too much of a pain, it's not too hard; something like:</p> <pre><code>INSERT INTO site_entry (field1, field2) ( SEL...
8
2010-02-12T19:13:53Z
[ "python", "django", "bulkinsert" ]
Efficent way to bulk insert with get_or_create() in Django (SQL, Python, Django)
2,252,530
<p>Is there a more efficent way for doing this?</p> <pre><code>for item in item_list: e, new = Entry.objects.get_or_create( field1 = item.field1, field2 = item.field2, ) </code></pre>
15
2010-02-12T14:44:30Z
15,310,266
<p>Since 1.4 you can do bulk_create</p> <p>See <a href="https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.bulk_create" rel="nofollow">the docs</a></p> <p>*Do pay attention to the caveats though (most important one being that the model’s save() method will not be called, and...
1
2013-03-09T11:44:02Z
[ "python", "django", "bulkinsert" ]
Site name appearing in django URLs
2,252,593
<p>I'm having an issue where a call to the url template tag in Django is appending the site name (I don't want it in there.)</p> <p>Let's say that the site name is 'mysite'.</p> <p>So for example:</p> <pre><code>&lt;a href="{% url myapp.views.myview "myparam" %}"&gt;Link text&lt;/a&gt; </code></pre> <p>is producing...
3
2010-02-12T14:51:29Z
2,252,707
<p>Are you sure, that this is the rendered version? <a href="http://docs.djangoproject.com/en/1.1/ref/templates/builtins/#url" rel="nofollow">Docs</a> say, that an absolute url should be produced, i.e. <code>/mysite/foo/bar</code>. Are you checking source in the browser? Try printing out the result of <code>render_to_s...
1
2010-02-12T15:09:20Z
[ "python", "django", "url", "django-urls" ]
Site name appearing in django URLs
2,252,593
<p>I'm having an issue where a call to the url template tag in Django is appending the site name (I don't want it in there.)</p> <p>Let's say that the site name is 'mysite'.</p> <p>So for example:</p> <pre><code>&lt;a href="{% url myapp.views.myview "myparam" %}"&gt;Link text&lt;/a&gt; </code></pre> <p>is producing...
3
2010-02-12T14:51:29Z
2,253,038
<p>Check your modpython configuration, if you've got one. There may be a line that looks like <code>PythonOption django.root /mysite</code> Remove that.</p>
6
2010-02-12T15:53:31Z
[ "python", "django", "url", "django-urls" ]
Class Inheritance
2,252,620
<p>I am trying to get completely to grips with class inheritence in Python. I have created program's with classes but they are all in one file. I have also created scripts with multiple files containing just functions. I have started using class inheritence in scripts with multiple files and I am hitting problems. I h...
0
2010-02-12T14:55:04Z
2,252,660
<p>I would say you messed up class definition with function stuff. It should look more like this:</p> <pre><code>class Test(object): def __init__(self): self.a = 20 self.b = 30 if __name__ == '__main__': test_instance = Test() </code></pre> <p>and</p> <pre><code>from class1 import Test cla...
12
2010-02-12T15:01:48Z
[ "python", "inheritance", "class" ]
Class Inheritance
2,252,620
<p>I am trying to get completely to grips with class inheritence in Python. I have created program's with classes but they are all in one file. I have also created scripts with multiple files containing just functions. I have started using class inheritence in scripts with multiple files and I am hitting problems. I h...
0
2010-02-12T14:55:04Z
2,252,661
<p>In Python, each member function (method) of a class should have a variable called <code>self</code> which is pretty much the <code>this</code> pointer/reference in C++, Java, C#. </p> <p>Basically, to make your code work add <code>self</code> as the first argument to all methods. To assign/read member variables use...
1
2010-02-12T15:02:03Z
[ "python", "inheritance", "class" ]
Running script on server start in google app engine, in Python
2,252,672
<p>Is it possible to run a script each time the dev server starts? Also at each deploy to google?</p> <p>I want the application to fill the database based on what some methods returns.</p> <p>Is there any way to do this?</p> <p>..fredrik</p>
4
2010-02-12T15:03:31Z
2,252,697
<p>You can do this by writing a script in your favorite scripting language that performs the actions that you desire and then runs the dev server or runs appcfg.py update.</p>
1
2010-02-12T15:07:46Z
[ "python", "google-app-engine" ]
Running script on server start in google app engine, in Python
2,252,672
<p>Is it possible to run a script each time the dev server starts? Also at each deploy to google?</p> <p>I want the application to fill the database based on what some methods returns.</p> <p>Is there any way to do this?</p> <p>..fredrik</p>
4
2010-02-12T15:03:31Z
2,253,428
<p>I use appengine python with the django helper. As far as I know you cannot hook anything on the deploy, but you could put a call to check if you need to do your setup in the main function of main.py. This is how the helper initializes itself on the first request. I haven't looked at webapp in a while, but I assum...
3
2010-02-12T16:42:15Z
[ "python", "google-app-engine" ]
Running script on server start in google app engine, in Python
2,252,672
<p>Is it possible to run a script each time the dev server starts? Also at each deploy to google?</p> <p>I want the application to fill the database based on what some methods returns.</p> <p>Is there any way to do this?</p> <p>..fredrik</p>
4
2010-02-12T15:03:31Z
2,259,561
<p>Try to make wrapper around the server runner and script that run deployment. So you will be able to run custom code when you need.</p>
0
2010-02-13T23:37:17Z
[ "python", "google-app-engine" ]
Running script on server start in google app engine, in Python
2,252,672
<p>Is it possible to run a script each time the dev server starts? Also at each deploy to google?</p> <p>I want the application to fill the database based on what some methods returns.</p> <p>Is there any way to do this?</p> <p>..fredrik</p>
4
2010-02-12T15:03:31Z
32,296,945
<p><a href="https://cloud.google.com/appengine/docs/python/config/appconfig#Python_Warmup_requests" rel="nofollow">Warmup Requests</a> in combination with <a href="https://cloud.google.com/appengine/docs/python/modules/#min_idle_instances" rel="nofollow">min_idle_instances</a> will probably work in your deploy usecase....
1
2015-08-30T13:16:50Z
[ "python", "google-app-engine" ]
How to create PDF files in Python
2,252,726
<p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p> <p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
104
2010-02-12T15:12:44Z
2,252,752
<p>You can try <a href="http://www.devshed.com/c/a/Python/Python-for-PDF-Generation/">this</a>(Python-for-PDF-Generation) or you can try <a href="http://www.riverbankcomputing.co.uk/news">PyQt</a>, which has support for printing to pdf. <br><br> <b>Python for PDF Generation</b><br><br> The Portable Document Format (PDF...
11
2010-02-12T15:16:18Z
[ "python", "pdf" ]
How to create PDF files in Python
2,252,726
<p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p> <p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
104
2010-02-12T15:12:44Z
2,252,756
<p>I suggest <a href="https://github.com/mstamy2/PyPDF2">pyPdf</a>. It works really nice. I also wrote a blog post some while ago, you can find it <a href="http://ssscripting.wordpress.com/2009/08/16/get-your-job-done-faster-with-pypdf/">here</a>.</p>
43
2010-02-12T15:16:46Z
[ "python", "pdf" ]