Re: learning python
"placid" <[EMAIL PROTECTED]> writes: > I was just wondering about good books that teach python (either with > programming or no programming experience at all) ? Or some online > tutorial? Did you even bother doing a web search? "Learn Python" or "Python tutorial" would be enough. Christopher -- http://mail.python.org/mailman/listinfo/python-list
FS: O'Reilly Python Pocket Reference
I am offering for sale a copy of O'Reilly's _Python Pocket Reference_. It is the second edition, covering Python 2. It is in fine condition, with no broken spine or dog-earned pages. One might even believe it just came out of the bookstore. Asking price is US$4 plus shipping (USPS Media Mail within the US, airmail internationally), payable by check or money order in the US, or Paypal elsewhere. Christopher Culver [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Unzipping a .zip properly, and from a remote URL
Returning to Python after several years away, I'm working on a little script that will download a ZIP archive from a website and unzip it to a mounted filesystem. The code is below, and it works so far, but I'm unsure of a couple of things. The first is, is there a way to read the .zip into memory without the use of a temporary file? If I do archive = zipfile.ZipFile(remotedata.read()) directly without creating a temporary file, the zipfile module complains that the data is in the wrong string type. The second issue is that I don't know if this is the correct way to unpack a file onto the filesystem. It's strange that the zipfile module has no one simple function to unpack a zip onto the disk. Does this code seem especially liable to break? try: remotedata = urllib2.urlopen(theurl) except IOError: print("Network down.") sys.exit() data = os.tmpfile() data.write(remotedata.read()) archive = zipfile.ZipFile(data) if archive.testzip() != None: print "Invalid zipfile" sys.exit() contents = archive.namelist() for item in contents: try: os.makedirs(os.path.join(mountpoint, os.path.dirname(item))) except OSError: # OSError means that the dir already exists, but no matter. pass if item[-1] != "/": outputfile = open(os.path.join(mountpoint, item), 'w') outputfile.write(archive.read(item)) outputfile.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: Unzipping a .zip properly, and from a remote URL
Tino Wildenhain writes: > so instead you would use archive = zipfile.ZipFile(remotedata) That produces the following error if I try that in the Python interpreter (URL edited for privacy): >>> import zipfile >>> import urllib2 >>> remotedata = urllib2.urlopen("http://...file.zip";) >>> archive = zipfile.ZipFile(remotedata) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.5/zipfile.py", line 346, in __init__ self._GetContents() File "/usr/lib/python2.5/zipfile.py", line 366, in _GetContents self._RealGetContents() File "/usr/lib/python2.5/zipfile.py", line 376, in _RealGetContents endrec = _EndRecData(fp) File "/usr/lib/python2.5/zipfile.py", line 133, in _EndRecData fpin.seek(-22, 2) # Assume no archive comment. AttributeError: addinfourl instance has no attribute 'seek' -- http://mail.python.org/mailman/listinfo/python-list
Converting timestamps across timezones
A script that I'm writing pulls the system time off of an iPod connected to the computer. The iPod's time is represented as a Unix timestamp (seconds since the epoch), but this timestamp does not represent UTC time, but rather the local timezone of the owner. I need to convert this local time timestamp into a UTC timestamp by referring to the timezone specified by /etc/localtime on the computer. I've read through the docs, but I'm rather lost on how to pull this particular operation off. Any advice would be appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: An assessment of the Unicode standard
Hyuga writes: > I just wanted to add, in defense of the Chinese written language > ... that I think it would make a fairly good candidate for use at > least as a universal *written* language. Particularly simplified > Chinese since, well, it's simpler. > > The advantages are that the grammar is relatively simple, and it can > be used to illustrate concepts independently of the writer's spoken > language. Musings about the universality of the Chinese writing system, once so common among Western thinkers, nevertheless do not square with reality. The Chinese writing system is in fact deeply linked to the Chinese language, even to the specific dialect being spoken. See Defrancis' _The Chinese Language: Fact and Fantasy_ (Honolulu: University of Hawaii Press, 1984): http://preview.tinyurl.com/rbyuuk -- http://mail.python.org/mailman/listinfo/python-list
Re: An assessment of the Unicode standard
ru...@yahoo.com writes: > Fashion changes in science as well as clothes. :-) A favourite line of crackpots who think that their ridiculous position is not held by others merely because of "fashion". > I wouldn't count > Sapir-Whorf out yet... > http://edge.org/3rd_culture/boroditsky09/boroditsky09_index.html That researcher does not say that language *constrains* thought, which was the assertion of the OP and of the strict form of the Sapir-Whorf hypothesis. She merely says that it may influence thought. -- http://mail.python.org/mailman/listinfo/python-list
Re: An assessment of the Unicode standard
Robin Becker writes: > well allegedly, "the medium is the message" so we also need to take > account of language in addition to the meaning of communications. I > don't believe all languages are equivalent in the meanings that they > can encode or convey. Our mathematics is heavily biassed towards > continuous differential systems and as a result we end up with many > physical theories that have smooth equilibrium descriptions, we may > literally be unable to get at other theories of the physical world > because our languages fall short. This is the old Sapir-Whorf hypothesis, which fell out of favour among linguists half a century ago already. 1) Language does not constrain human thought, and 2) any two human languages are both capable of expressing the same things, though one may already have a convenient lexeme for the topic at hand while the other uses circumlocution. -- http://mail.python.org/mailman/listinfo/python-list
Re: An assessment of the Unicode standard
Hendrik van Rooyen writes: > 2) Is about as useful as stating that any Turing complete language and > processor pair is capable of solving any computable problem, given enough > time. So why are we not all programming in brainfuck? Except the amount of circumlocution one language might happen to use over another is quite limited. > Or speaking the language of the people who wrote linear B? You mean Mycenaean Greek? There's still a few million people in Europe who speak a descendent of that very language. > When a language lacks a word for a concept like "window", then (I > believe :-) ), it kind of puts a crimp in the style of thinking that a > person will do, growing up with only that language. "Window" goes back to an Anglo-Saxon compound "windeye". Even if a word does not already exist in a given language for whatever novel item, the language is capable of creating from its own resources. -- http://mail.python.org/mailman/listinfo/python-list