Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed because of a cast error
Error code:   DatasetGenerationCastError
Exception:    DatasetGenerationCastError
Message:      An error occurred while generating the dataset

All the data files must have the same columns, but at some point there are 1 new columns ({'Title'}) and 1 missing columns ({'ParentId'}).

This happened while the csv dataset builder was generating data using

hf://datasets/Gauravvaid-shell/instruct-python-llama2-20k/Questions-22K-instructions.csv (at revision f69384aac6fb22953eece770c40b408077771ee8)

Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2011, in _prepare_split_single
                  writer.write_table(table)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 585, in write_table
                  pa_table = table_cast(pa_table, self._schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2302, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2256, in cast_table_to_schema
                  raise CastError(
              datasets.table.CastError: Couldn't cast
              Id: int64
              OwnerUserId: double
              CreationDate: string
              Score: int64
              Title: string
              Body: string
              -- schema metadata --
              pandas: '{"index_columns": [{"kind": "range", "name": null, "start": 0, "' + 936
              to
              {'Id': Value(dtype='int64', id=None), 'OwnerUserId': Value(dtype='float64', id=None), 'CreationDate': Value(dtype='string', id=None), 'ParentId': Value(dtype='int64', id=None), 'Score': Value(dtype='int64', id=None), 'Body': Value(dtype='string', id=None)}
              because column names don't match
              
              During handling of the above exception, another exception occurred:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1321, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 935, in convert_to_parquet
                  builder.download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1027, in download_and_prepare
                  self._download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1122, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1882, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2013, in _prepare_split_single
                  raise DatasetGenerationCastError.from_cast_error(
              datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
              
              All the data files must have the same columns, but at some point there are 1 new columns ({'Title'}) and 1 missing columns ({'ParentId'}).
              
              This happened while the csv dataset builder was generating data using
              
              hf://datasets/Gauravvaid-shell/instruct-python-llama2-20k/Questions-22K-instructions.csv (at revision f69384aac6fb22953eece770c40b408077771ee8)
              
              Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

Id
int64
OwnerUserId
float64
CreationDate
string
ParentId
int64
Score
int64
Body
string
497
50
2008-08-02T16:56:53Z
469
4
<p>open up a terminal (Applications-&gt;Utilities-&gt;Terminal) and type this in:</p> <pre><code>locate InsertFontHere<br></code></pre> <p>This will spit out every file that has the name you want.</p> <p>Warning: there may be alot to wade through.</p>
518
153
2008-08-02T17:42:28Z
469
2
<p>I haven't been able to find anything that does this directly. I think you'll have to iterate through the various font folders on the system: <code>/System/Library/Fonts</code>, <code>/Library/Fonts</code>, and there can probably be a user-level directory as well <code>~/Library/Fonts</code>.</p>
536
161
2008-08-02T18:49:07Z
502
9
<p>You can use ImageMagick's convert utility for this, see some examples in <a href="https://web.archive.org/web/20120413111338/http://studio.imagemagick.org/pipermail/magick-users/2002-May/002636.html" rel="nofollow">http://studio.imagemagick.org/pipermail/magick-users/2002-May/002636.html</a> :</p> <blockquote> <pre...
538
156
2008-08-02T18:56:56Z
535
23
<p>One possibility is Hudson. It's written in Java, but there's integration with Python projects:</p> <blockquote> <p><a href="http://redsolo.blogspot.com/2007/11/hudson-embraces-python.html" rel="nofollow">Hudson embraces Python</a></p> </blockquote> <p>I've never tried it myself, however.</p> <p>(<strong>Update...
541
157
2008-08-02T19:06:40Z
535
20
<p>We run <a href="http://buildbot.net/trac">Buildbot - Trac</a> at work, I haven't used it too much since my code base isn't part of the release cycle yet. But we run the tests on different environments (OSX/Linux/Win) and it sends emails --and it's written in python.</p>
595
116
2008-08-03T01:17:36Z
594
25
<p>The canonical way is to use the built-in cursor iterator.</p> <pre><code>curs.execute('select * from people') for row in curs: print row </code></pre> <hr> <p>You can use <code>fetchall()</code> to get all rows at once.</p> <pre><code>for row in curs.fetchall(): print row </code></pre> <p>It can be conv...
660
197
2008-08-03T12:09:18Z
535
14
<p>Second the Buildbot - Trac integration. You can find more information about the integration on the <a href="http://buildbot.net/trac/wiki/BuildbotAndTrac">Buildbot website</a>. At my previous job, we wrote and used the plugin they mention (tracbb). What the plugin does is rewriting all of the Buildbot urls so you c...
701
111
2008-08-03T14:30:50Z
683
3
<p>No, you were not dreaming. Python has a pretty excellent list comprehension system that lets you manipulate lists pretty elegantly, and depending on exactly what you want to accomplish, this can be done a couple of ways. In essence, what you're doing is saying "For item in list if criteria.matches", and from that ...
735
145
2008-08-03T15:47:22Z
683
-2
<p>I think:</p> <pre><code>#!/bin/python<br>bar in dict(Foo)<br></code></pre> <p>Is what you are thinking of. When trying to see if a certain key exists within a dictionary in python (python's version of a hash table) there are two ways to check. First is the <strong><code>has_key()</code></strong> method attac...
745
154
2008-08-03T15:59:19Z
683
8
<p>Are you looking to get a list of objects that have a certain attribute? If so, a <a href="http://docs.python.org/tut/node7.html#SECTION007140000000000000000">list comprehension</a> is the right way to do this.</p> <pre><code>result = [obj for obj in listOfObjs if hasattr(obj, 'attributeName')]<br></code></pre>
750
199
2008-08-03T16:13:29Z
683
2
<p>What I was thinking of can be achieved using list comprehensions, but I thought that there was a function that did this in a slightly neater way.</p> <p>i.e. 'bar' is a list of objects, all of which have the attribute 'id'</p> <p>The mythical functional way:</p> <pre><code>foo = 12<br>foo in iter_attr(bar, ...
764
null
2008-08-03T17:40:25Z
742
0
<p>Sounds to me like you're trying to combine things that shouldn't be combined. If you need to do different processing in your view depending on if it's a User or Group object you're trying to look at then you should use two different view functions.</p> <p>On the other hand there can be common idioms you'd want t...
777
150
2008-08-03T18:32:27Z
766
5
<p>I don't have any experience with <a href="http://www.SiteGround.com" rel="nofollow">http://www.SiteGround.com</a> as a web host personally. </p> <p>This is just a guess, but it's common for a shared host to support Python and MySQL with the MySQLdb module (e.g., GoDaddy does this). Try the following CGI script ...
783
189
2008-08-03T18:40:09Z
773
52
<p>Can you show us your code?</p> <p>The example on the Python docs is quite straightforward:</p> <pre><code>groups = [] uniquekeys = [] for k, g in groupby(data, keyfunc): groups.append(list(g)) # Store group iterator as a list uniquekeys.append(k) </code></pre> <p>So in your case, data is a list of no...
802
1,384,652
2008-08-03T20:07:05Z
766
4
<p>I uploaded it and got an internal error</p> <pre><code>Premature end of script headers<br></code></pre> <p>After much playing around, I found that if I had</p> <pre><code>import cgi<br>import cgitb; cgitb.enable()<br>import MySQLdb<br></code></pre> <p>It would give me a much more useful answer and say th...
982
200
2008-08-04T02:31:13Z
972
14
<p>In Python monkey patching generally works by overwriting a class or functions signature with your own. Below is an example from the <a href="http://wiki.zope.org/zope2/MonkeyPatch">Zope Wiki</a>:</p> <pre><code>from SomeOtherProduct.SomeModule import SomeClass<br>def speak(self):<br> return "ook ook eee eee eee...
984
122
2008-08-04T02:36:40Z
972
-6
<p>I don't know Python syntax, but I know Ruby can do it, and it is rather trivial. Let's say you want to add a method to Array that prints the length to standard out:</p> <pre><code>class Array<br> def print_length<br> puts length<br> end<br>end<br></code></pre> <p>If you don't want to modify the whole cla...
1,478
305
2008-08-04T18:26:13Z
1,476
-1
<p>As far as I can tell Python, up through 2.5, only supports hexadecimal &amp; octal literals. I did find some discussions about adding binary to future versions but nothing definite.</p>
1,479
269
2008-08-04T18:27:26Z
1,476
-1
<p>I am pretty sure this is one of the things due to change in Python 3.0 with perhaps bin() to go with hex() and oct().</p> <p>EDIT: lbrandy's answer is correct in all cases.</p>
1,484
2,089,740
2008-08-04T18:34:45Z
1,476
57
<pre><code>&gt;&gt;&gt; print int('01010101111',2) 687 &gt;&gt;&gt; print int('11111111',2) 255 </code></pre> <p>Another way.</p>
1,619
92
2008-08-04T21:54:11Z
766
17
<p>MySQLdb is what I have used before.</p> <p>If you host is using Python version 2.5 or higher, support for sqlite3 databases is built in (sqlite allows you to have a relational database that is simply a file in your filesystem). But buyer beware, sqlite is not suited for production, so it may depend what you are ...
1,780
77
2008-08-05T01:14:30Z
1,734
8
<P>If you are looking for user facing interaction, stick with xml. It has more support, understanding, and general acceptance currently. If it's internal, I would say that protocol buffers are a great idea.</P> <P>Maybe in a few years as more tools come out to support protocol buffers, then start looking towards that ...
1,840
116
2008-08-05T02:54:54Z
1,829
8
<p><strong>On Linux:</strong></p> <ul> <li>set raw mode</li> <li>select and read the keystroke</li> <li>restore normal settings</li> </ul> <pre> import sys import select import termios import tty def getkey(): old_settings = termios.tcgetattr(sys.stdin) tty.setraw(sys.stdin.fileno()) select.select([sys.s...
1,852
116
2008-08-05T03:11:55Z
1,829
6
<p><strong>On Windows:</strong></p> <pre><code>import msvcrt answer=msvcrt.getch() </code></pre>
1,857
2,089,740
2008-08-05T03:27:03Z
1,854
341
<pre><code>&gt;&gt;&gt; import os &gt;&gt;&gt; print os.name posix &gt;&gt;&gt; import platform &gt;&gt;&gt; platform.system() 'Linux' &gt;&gt;&gt; platform.release() '2.6.22-15-generic' </code></pre> <p>See: <a href="https://docs.python.org/2/library/platform.html">platform — Access to underlying platform’s ident...
1,870
30
2008-08-05T03:51:57Z
1,829
2
<p>Wow, that took forever. Ok, here's what I've ended up with </p> <pre><code>#!C:\python25\python.exe<br>import msvcrt<br>print """Menu<br>1) Say Foo <br>2) Say Bar"""<br>while 1:<br> char = msvcrt.getch()<br> if char == chr(27): #escape<br> break<br> if char == "1":<br> print "foo"<br> ...
1,871
216
2008-08-05T03:57:22Z
1,854
112
<p>Dang -- lbrandy beat me to the punch, but that doesn't mean I can't provide you with the system results for Vista!</p> <pre><code>&gt;&gt;&gt; import os &gt;&gt;&gt; os.name 'nt' &gt;&gt;&gt; import platform &gt;&gt;&gt; platform.system() 'Windows' &gt;&gt;&gt; platform.release() 'Vista' </code></pre>
1,879
116
2008-08-05T04:13:53Z
1,854
91
<p>For the record here's the results on Mac:</p> <pre><code>&gt;&gt;&gt; import os &gt;&gt;&gt; os.name 'posix' &gt;&gt;&gt; import platform &gt;&gt;&gt; platform.system() 'Darwin' &gt;&gt;&gt; platform.release() '8.11.1' </code></pre>
1,885
50
2008-08-05T04:28:03Z
1,829
0
<p>The reason msvcrt fails in IDLE is because IDLE is not accessing the library that runs msvcrt. Whereas when you run the program natively in cmd.exe it works nicely. For the same reason that your program blows up on Mac and Linux terminals.</p> <p>But I guess if you're going to be using this specifically for wind...
1,987
269
2008-08-05T07:27:40Z
1,983
19
<p>The list [1,2,3] is dynamic and flexible but that flexibility comes at a speed cost.</p> <p>The tuple (1,2,3) is fixed (immutable) and therefore faster.</p>
2,277
156
2008-08-05T13:22:43Z
1,983
26
<p>From the <a href="http://www.python.org/doc/faq/general/#why-are-there-separate-tuple-and-list-data-types">Python FAQ</a>:</p> <blockquote> <p>Lists and tuples, while similar in many respects, are generally used in fundamentally different ways. Tuples can be thought of as being similar to Pascal records or C s...
2,316
259
2008-08-05T13:45:38Z
2,311
14
<p>Do you need to open the locfile in binary using <code>rb</code>?</p> <pre><code>f = open (locfile, "rb") </code></pre>
2,317
17
2008-08-05T13:45:47Z
2,311
2
<p>Well if you go under the properties of your file in Windows or a *nix environment, you will notice two sizes. One is the sector size, and one is the actual size. The sector size is the number of sectors in bytes that are used up on your hard disk. That is because two files cannot be in the same sector with most m...
2,510
269
2008-08-05T15:59:24Z
2,311
0
<p>Small files take up a whole node on the filesystem whatever size that is.</p> <p>My host tends to report all small files as 4kb in ftp but in a shell gives an accurate size so it might be a 'feature' common to ftp clients.</p>
2,937
275
2008-08-05T22:34:25Z
2,933
189
<p>First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.</p> <p><strong>Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)</strong></p> <p>Of course, there are many, but the most popular tha...
2,941
92
2008-08-05T22:40:17Z
2,933
0
<p>You don't need to <em>compile</em> python for Mac/Windows/Linux. It is an interpreted language, so you simply need to have the Python interpreter installed on the system of your choice (it is available for all three platforms).</p> <p>As for a GUI library that works cross platform, Python's <a href="http://www.t...
2,980
188
2008-08-06T00:29:36Z
2,933
2
<p>Since python is installed on nearly every non-Windows OS by default now, the only thing you really need to make sure of is that all of the non-standard libraries you use are installed.</p> <p>Having said that, it is possible to build executables that include the python interpreter, and any libraries you use. Thi...
2,982
99
2008-08-06T00:33:35Z
972
576
<p>In Python, there is a difference between functions and bound methods.</p> <pre><code>&gt;&gt;&gt; def foo(): ... print "foo" ... &gt;&gt;&gt; class A: ... def bar( self ): ... print "bar" ... &gt;&gt;&gt; a = A() &gt;&gt;&gt; foo &lt;function foo at 0x00A98D70&gt; &gt;&gt;&gt; a.bar &lt;bound method...
3,040
457
2008-08-06T03:01:23Z
469
12
<p>Unfortunately the only API that isn't deprecated is located in the ApplicationServices framework, which doesn't have a bridge support file, and thus isn't available in the bridge. If you're wanting to use ctypes, you can use ATSFontGetFileReference after looking up the ATSFontRef.</p> <p>Cocoa doesn't have any na...
3,071
363
2008-08-06T03:57:16Z
3,061
925
<p>Assuming module <code>foo</code> with method <code>bar</code>:</p> <pre><code>import foo methodToCall = getattr(foo, 'bar') result = methodToCall() </code></pre> <p>As far as that goes, lines 2 and 3 can be compressed to:</p> <pre><code>result = getattr(foo, 'bar')() </code></pre> <p>if that makes more sense for...
4,128
17
2008-08-06T23:40:43Z
3,976
0
<p>have you tried watching the traffic between the GUI and the serial port to see if there is some kind of special command being sent across? Also just curious, Python is sending ASCII and not UTF-8 or something else right? The reason I ask is because I noticed your quote changes for the strings and in some languages...
4,162
582
2008-08-07T00:19:03Z
3,976
4
<p><code>/dev/cu.xxxxx</code> is the "callout" device, it's what you use when you establish a connection to the serial device and start talking to it. <code>/dev/tty.xxxxx</code> is the "dialin" device, used for monitoring a port for incoming calls for e.g. a fax listener.</p>
4,572
612
2008-08-07T10:44:23Z
742
7
<p>If you're simply displaying data from models, why not use the <a href="https://docs.djangoproject.com/en/1.2/ref/generic-views/" rel="nofollow">Django Generic Views</a>? They're designed to let you easy show data from a model without having to write your own view and stuff about mapping URL paramaters to views, fetc...
4,595
618
2008-08-07T11:21:56Z
1,983
10
<p>Tuples are a quick\flexible way to create <em>composite</em> data-types. Lists are containers for, well, lists of objects.</p> <p>For example, you would use a List to store a list of student details in a class.</p> <p>Each student detail in that list may be a 3-tuple containing their roll number, name and tes...
4,600
618
2008-08-07T11:30:16Z
972
4
<p>What you're looking for is <code>setattr</code> I believe. Use this to set an attribute on an object.</p> <pre><code>&gt;&gt;&gt; def printme(s): print repr(s)<br>&gt;&gt;&gt; class A: pass<br>&gt;&gt;&gt; setattr(A,'printme',printme)<br>&gt;&gt;&gt; a = A()<br>&gt;&gt;&gt; a.printme() # s becomes the implicit '...
4,605
618
2008-08-07T11:35:23Z
3,061
145
<p>Patrick's solution is probably the cleanest. If you need to dynamically pick up the module as well, you can import it like:</p> <pre><code>m = __import__ ('foo') func = getattr(m,'bar') func() </code></pre>
4,958
613
2008-08-07T16:50:43Z
4,942
2
<p>Focus on the shorter time needed for development/prototype and possibly easier maintenance (none of this may apply against Ruby).</p>
4,978
676
2008-08-07T17:04:25Z
4,942
11
<p>This is one of those cases that really boil down to personal preference or situational details. If you're more comfortable and experienced with Python, then say so. Are they asking you to justify it because they're more comfortable with one of the other environments? After you're done, will the system be passed off ...
5,014
660
2008-08-07T17:30:10Z
4,942
3
<p>I would consider that using python on a new project is completely dependent on what problem you are trying to solve with python. If you want someone to agree with you that you should use python, then show them how python's features apply specifically to that problem.</p> <p>In the case of web development with py...
5,129
680
2008-08-07T18:40:53Z
5,102
12
<p>There are two main ways of running Python on Apache. The simplest would be to use CGI and write normal Python scripts while the second is using a web framework like Django or Pylons.</p> <p>Using CGI is straightforward. Make sure your Apache config file has a cgi-bin set up. If not, follow their documentation (<a h...
5,165
116
2008-08-07T19:02:57Z
5,102
8
<p>Yes, mod_python is pretty confusing to set up. Here's how I did it.</p> <p>In httpd.conf:</p> <pre><code>LoadModule python_module modules/mod_python.so<br><br>&lt;Directory "/serverbase/htdocs/myapp"&gt;<br> AddHandler mod_python .py<br> PythonHandler myapp<br> PythonDebug On<br></code></pre> <p>and in ...
5,168
636
2008-08-07T19:05:58Z
5,102
5
<p>Are you running Python on UNIX or Windows?</p> <p>An alternative to mod_python and FastCGI is mod_wsgi. You can find out more at <a href="http://code.google.com/p/modwsgi/" rel="nofollow">modwsgi</a></p> <p>I have built and installed this on Solaris without problems. I had previously tried mod_python but ran into ...
5,302
501
2008-08-07T20:57:20Z
5,136
4
<p>I won't help much but I remember that I was able to wrap MATLAB simulation into DLL and then call it from Delphi app. It work really well.</p> <p>Anyway: good luck!!!</p>
5,319
380
2008-08-07T21:10:27Z
5,313
8
<p>erm.. HTML? (trying to be funny here... while we wait for real answers..)</p>
5,320
216
2008-08-07T21:11:28Z
5,313
1
<p>The <a href="http://www.wxwidgets.org/" rel="nofollow" title="wxWidgets">wxWidgets</a> (formerly known as wxWindows) library might be what you're looking for. There's a particularly good port for Python, <a href="http://wxpython.org/" rel="nofollow" title="wxPython">wxPython</a>, as well as versions for different la...
5,340
108
2008-08-07T21:24:26Z
5,313
3
<P>Not sure if this is what you're looking for, but there's <A href="http://glade.gnome.org/" rel="nofollow">Glade</A> (or <A href="http://gladewin32.sourceforge.net/" rel="nofollow">Windows download</A>) which is a designer for GTK+. It generates an XML file which can then be used to build the GUI in a number of diffe...
5,343
25
2008-08-07T21:25:26Z
5,313
5
<p><a href="http://en.wikipedia.org/wiki/Qt_%28toolkit%29">Qt</a> (pronounced "cute" by its creators[1]) is a cross-platform application development framework, widely used for the development of GUI programs.</p> <p>Qt uses <strong>C++</strong> with several non-standard extensions implemented by an additional pre-pr...
5,430
267
2008-08-07T22:32:23Z
5,419
24
<p><strong>Note:</strong> This answer is sort of outdated (from 2008). Please use the solution below with care!!</p> <hr> <p>Here is a page that details the problem and a solution (search the page for the text <em>Wrapping sys.stdout into an instance</em>):</p> <p><a href="http://wiki.python.org/moin/PrintFails">Pri...
5,435
429
2008-08-07T22:35:48Z
5,415
13
<p>You'll want the <a href="https://docs.python.org/3.4/library/struct.html" rel="nofollow">struct</a> package.</p>
5,719
108,465
2008-08-08T06:06:33Z
1,983
1
<P>As others have mentioned, Lists and tuples are both containers which can be used to store python objects. Lists are extensible and their contents can change by assignment, on the other hand tuples are immutable.</P> <P>Also, lists cannot be used as keys in a dictionary whereas tuples can. </P>
5,746
699
2008-08-08T06:48:52Z
1,983
1
<p>If you can find a solution that works with tuples, use them, as it forces immutability which kind of drives you down a more functional path. You almost never regret going down the functional/immutable path.</p>
5,927
309,844
2008-08-08T13:41:43Z
5,909
6
<p>The size of the file is sent as the Content-Length header. Here is how to get it with urllib:</p> <pre><code>&gt;&gt;&gt; site = urllib.urlopen("http://python.org")<br>&gt;&gt;&gt; meta = site.info()<br>&gt;&gt;&gt; print meta.getheaders("Content-Length")<br>['16535']<br>&gt;&gt;&gt;<br></code></pre>
5,935
745
2008-08-08T13:47:26Z
5,909
16
<p>Using the returned-urllib-object method <code>info()</code>, you can get various information on the retrived document. Example of grabbing the current Google logo:</p> <pre><code>&gt;&gt;&gt; import urllib<br>&gt;&gt;&gt; d = urllib.urlopen("http://www.google.co.uk/logos/olympics08_opening.gif")<br>&gt;&gt;&gt; p...
5,938
309,844
2008-08-08T13:51:23Z
5,909
4
<p>Also if the server you are connecting to supports it, look at <a href="http://en.wikipedia.org/wiki/HTTP_ETag" rel="nofollow">Etags</a> and the <a href="http://en.wikipedia.org/wiki/List_of_HTTP_headers#Requests" rel="nofollow">If-Modified-Since</a> and <a href="http://en.wikipedia.org/wiki/List_of_HTTP_headers#Requ...
5,985
309,844
2008-08-08T14:21:51Z
5,909
19
<p>I have reproduced what you are seeing:</p> <pre><code>import urllib, os<br>link = "http://python.org"<br>print "opening url:", link<br>site = urllib.urlopen(link)<br>meta = site.info()<br>print "Content-Length:", meta.getheaders("Content-Length")[0]<br><br>f = open("out.txt", "r")<br>print "File on disk:",len(f.r...
6,125
309,844
2008-08-08T16:45:50Z
5,966
3
<p>Why not use SQLite? There is good support in Python and you can write SQL queries to get the data out. Here is the Python docs for <a href="http://docs.python.org/lib/module-sqlite3.html" rel="nofollow">sqlite3</a></p> <hr> <p>If you don't want to use SQLite you could do an array of dicts.</p> <pre><code>ep...
6,161
758
2008-08-08T17:12:24Z
1,734
10
<p>Protocol buffers are intended to optimize communications between machines. They are really not intended for human interaction. Also, the format is binary, so it could not replace XML in that use case. </p> <p>I would also recommend <a href="http://en.wikipedia.org/wiki/JSON">JSON</a> as being the most compact tex...
6,616
488
2008-08-09T04:44:41Z
5,313
3
<p><a href="http://www.mozilla.org/projects/xul/" rel="nofollow">XML User Interface Language</a>. Don't know much about it so not sure if it meets your desires. Post back with your experience if you play with it.</p>
6,805
358
2008-08-09T15:13:14Z
5,966
0
<P>I have done something similar in the past and used an in-memory XML document as a quick and dirty hierachical database for storage. You can store each show/season/episode as an element (nested appropriately) and attributes of these things as xml attributes on the elements. Then you can use XQuery to get info back ou...
7,073
878
2008-08-10T07:10:19Z
502
2
<p>Is the PC likely to have Acrobat installed? I think Acrobat installs a shell extension so previews of the first page of a PDF document appear in Windows Explorer's thumbnail view. You can get thumbnails yourself via the IExtractImage COM API, which you'll need to wrap. <a href="http://www.vbaccelerator.com/home/net/...
7,090
13
2008-08-10T08:08:33Z
502
25
<p>ImageMagick delegates the PDF->bitmap conversion to GhostScript anyway, so here's a command you can use (it's based on the actual command listed by the <code>ps:alpha</code> delegate in ImageMagick, just adjusted to use JPEG as output):</p> <pre><code>gs -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT \ -dM...
7,286
207
2008-08-10T18:45:32Z
773
394
<p>As Sebastjan said, <strong>you first have to sort your data. This is important.</strong></p> <p>The part I didn't get is that in the example construction</p> <pre><code>groups = [] uniquekeys = [] for k, g in groupby(data, keyfunc): groups.append(list(g)) # Store group iterator as a list uniquekeys.append...
7,496
680
2008-08-11T03:11:55Z
5,313
0
<p>I read a little on XML User Interface Language (XUL) and it looks really robust and well supported. The main problem for me is it's tied to the Gecko rendering engine so it's cross platform the way wxWidgets, QT and GTK+ are cross platform. Also, there Python bindings don't seem as good as those other libraries.</p>...
8,020
985
2008-08-11T17:58:28Z
5,419
-1
<p>The cause of your problem is <strong>NOT</strong> the Win console not willing to accept Unicode (as it does this since I guess Win2k by default). It is the default system encoding. Try this code and see what it gives you:</p> <pre><code>import sys sys.getdefaultencoding() </code></pre> <p>if it says ascii, there's...
8,109
1,026
2008-08-11T19:17:41Z
5,313
1
<p>@Cristian and Antony Cramp: while XUL is a nice choice for UI development (cross-platform, open-source licensed, used in Firefox and other major software), it's certainly not language agnostic. You're tied to Gecko, with JS for scripting. There is experimental support for Python scripting, but it's only experimental...
8,114
872
2008-08-11T19:21:14Z
5,313
4
<p>I seriously doubt you're going to find a markup language for GIU's that's <em>not</em> tied to a specific library. For such a thing to exist, there would need to be a standardized GUI markup language, with several implementations.</p>
8,165
985
2008-08-11T20:07:59Z
5,966
0
<p>I don't get this part here:</p> <blockquote> <p>This worked okay, but there was no easy way of checking if x[3][24] was supposed to exist or not (so I couldn't raise the season<em>not</em>found exception)</p> </blockquote> <p>There is a way to do it - called <strong>in</strong>:</p> <pre><code>&gt;&gt;&gt;x={} ...
8,320
1,057
2008-08-11T22:59:42Z
742
1
<p>Unless you want to do something a little complex, using the generic views are the way to go. They are far more powerful than their name implies, and if you are just displaying model data generic views will do the job.</p>
8,332
1,057
2008-08-11T23:16:33Z
766
4
<p>You could try setting up your own python installation using <a href="http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python" rel="nofollow">Virtual Python</a>. Check out how to setup Django using it <a href="http://forums.site5.com/showthread.php?t=10236" rel="nofollow">here</a>. That was wr...
8,699
207
2008-08-12T11:40:13Z
8,692
74
<p>The <a href="http://lxml.de/">lxml package</a> supports xpath. It seems to work pretty well, although I've had some trouble with the self:: axis. There's also <a href="http://pypi.python.org/pypi/Amara/1.1.6">Amara</a>, but I haven't used it personally.</p>
8,972
722
2008-08-12T15:32:05Z
8,948
1
<p><a href="http://www.dotfunk.com/projects/mp3/" rel="nofollow">This toolkit</a> may do what you need. I can't say if it's the "best", but really, if it does what you need, that's all that matters, right?</p> <p>HTH</p>
8,974
394
2008-08-12T15:37:24Z
8,948
6
<p>A simple example from the book Dive Into Python works ok for me, <a href="http://www.diveintopython.org/download/diveintopython-examples-5.4.zip" rel="nofollow">this</a> is the download link, the example is fileinfo.py. Don't know if it's the best, but it can do the basic job.</p> <p>The entire book is available on...
8,976
1,087
2008-08-12T15:37:59Z
8,948
1
<p>It can depend on exactly what you want to do in addition to reading the metadata. If it is just simply the bitrate / name etc. that you need, and nothing else, something lightweight is probably best.</p> <p>If you're manipulating the mp3 past that PyMedia may be suitable.</p> <p>There are quite a few, whatever you...
9,080
745
2008-08-12T17:55:22Z
5,966
0
<p>Bartosz/To clarify "This worked okay, but there was no easy way of checking if x[3][24] was supposed to exist or not"</p> <p><code>x['some show'][3][24]</code> would return season 3, episode 24 of "some show". If there was no season 3, I want the pseudo-dict to raise tvdb<em>seasonnotfound, if "some show" doesn't e...
9,171
1,146
2008-08-12T19:34:44Z
8,692
2
<p><a href="http://pyxml.sourceforge.net" rel="nofollow" title="PyXML">PyXML</a> works well. </p> <p>You didn't say what platform you're using, however if you're on Ubuntu you can get it with <code>sudo apt-get install python-xml</code>. I'm sure other Linux distros have it as well. </p> <p>If you're on a Mac, xpa...
9,358
1,057
2008-08-13T00:44:26Z
8,948
11
<p>What you're after is the <a href="http://id3-py.sourceforge.net/">ID3</a> module. It's very simple and will give you exactly what you need. Just copy the ID3.py file into your site-packages directory and you'll be able to do something like the following:</p> <pre><code>from ID3 import * try: id3info = ID3('file...
10,129
116
2008-08-13T17:56:34Z
10,123
10
<p>This will do what you want:</p> <pre><code>signum = status &amp; 0xff exitstatus = (status &amp; 0xff00) &gt;&gt; 8 </code></pre>
10,132
872
2008-08-13T17:58:27Z
10,123
1
<p>You can unpack the status using <a href="http://docs.python.org/ref/shifting.html" rel="nofollow">bit-shifting</a> and <a href="http://docs.python.org/ref/bitwise.html" rel="nofollow">masking</a> operators.</p> <pre><code>low = status &amp; 0x00FF high = (status &amp; 0xFF00) &gt;&gt; 8 </code></pre> <p>I'm not a ...
10,148
429
2008-08-13T18:14:10Z
10,123
0
<p>The folks before me've nailed it, but if you really want it on one line, you can do this:</p> <pre><code>(signum, exitstatus) = (status &amp; 0xFF, (status &gt;&gt; 8) &amp; 0xFF) </code></pre> <p>EDIT: Had it backwards.</p>
10,213
99
2008-08-13T18:52:36Z
10,123
10
<p>To answer your general question, you can use <a href="http://en.wikipedia.org/wiki/Bit_twiddling" rel="nofollow">bit manipulation</a> techniques:</p> <pre><code>pid, status = os.wait() exitstatus, signum = status &amp; 0xFF, (status &amp; 0xFF00) &gt;&gt; 8 </code></pre> <p>However, there are also <a href="http://...
10,778
985
2008-08-14T07:08:19Z
5,966
5
<p>OK, what you need is <code>classobj</code> from new module. That would allow you to construct exception classes dynamically (<code>classobj</code> takes a string as an argument for the class name). </p> <pre><code>import new myexc=new.classobj("ExcName",(Exception,),{}) i=myexc("This is the exc msg!") raise i </cod...
10,845
912
2008-08-14T09:46:21Z
8,948
25
<p>I've used <a href="https://bitbucket.org/lazka/mutagen">mutagen</a> to edit tags in media files before. The nice thing about mutagen is that it can handle other formats, such as mp4, FLAC etc. I've written several scripts with a lot of success using this API.</p>
10,846
912
2008-08-14T09:48:59Z
8,692
7
<p>The latest version of <a href="http://effbot.org/zone/element-xpath.htm">elementtree</a> supports XPath pretty well. Not being an XPath expert I can't say for sure if the implementation is full but it has satisfied most of my needs when working in Python. I've also use lxml and PyXML and I find etree nice because ...
11,074
267
2008-08-14T14:04:25Z
11,060
8
<p>I started writing up a summary of my experience with my own code generator, then went back and re-read your question and found you had already touched upon the same issues yourself, focus on the execution results instead of the code layout/look.</p> <p>Problem is, this is hard to test, the generated code might not ...
11,128
414
2008-08-14T14:38:19Z
11,060
0
<p>Yes, results are the ONLY thing that matters. The real chore is writing a framework that allows your generated code to run independently... spend your time there.</p>
11,235
1,343
2008-08-14T15:46:01Z
11,060
0
<p>If you are running on *nux you might consider dumping the unittest framework in favor of a bash script or makefile. on windows you might consider building a shell app/function that runs the generator and then uses the code (as another process) and unittest that.</p> <p>A third option would be to generate the code a...
11,443
825
2008-08-14T18:15:42Z
11,060
4
<p>Recall that "unit testing" is only one kind of testing. You should be able to unit test the <strong>internal</strong> pieces of your code generator. What you're really looking at here is system level testing (a.k.a. regression testing). It's not just semantics... there are different mindsets, approaches, expectat...
12,166
995
2008-08-15T11:56:02Z
2,933
13
<p>An alternative tool to py2exe is <a href="http://pypi.python.org/pypi/bbfreeze/">bbfreeze</a> which generates executables for windows and linux. It's newer than py2exe and handles eggs quite well. I've found it magically works better without configuration for a wide variety of applications.</p>
12,167
1,344
2008-08-15T12:00:37Z
2,933
2
<p>I'm not sure that this is the best way to do it, but when I'm deploying Ruby GUI apps (not Python, but has the same "problem" as far as .exe's are concerned) on Windows, I just write a short launcher in C# that calls on my main script. It compiles to an executable, and I then have an application executable.</p>
12,454
1,448
2008-08-15T16:38:59Z
1,983
2
<p>Whenever I need to pass in a collection of items to a function, if I want the function to not change the values passed in - I use tuples. </p> <p>Else if I want to have the function to alter the values, I use list. </p> <p>Always if you are using external libraries and need to pass in a list of values to a functio...
End of preview.
README.md exists but content is empty.
Downloads last month
3