Re: socket.error: [Errno 98] Address already in use
In message pan.2010.09.19.05.36.20.141...@nowhere.com, Nobody wrote: On Sun, 19 Sep 2010 12:27:08 +1200, Lawrence D'Oliveiro wrote: That's why Stevens recommends that all TCP servers use the SO_REUSEADDR socket option. I don’t think I’ve ever used that. It seems to defeat a safety mechanism which was put in for a reason. It was put in for the benefit of clients, to prevent them from selecting a port which they won't be able to use. But clients typically don’t care what port they use—they let the system pick a port for them, so this kind of option is unnecessary. -- http://mail.python.org/mailman/listinfo/python-list
Re: The trouble with dynamic attributes.
On 09/18/10 03:53, Ethan Furman wrote: Lie Ryan wrote: [snip] And even dict-syntax is not perfect for accessing XML file, e.g.: a bfoo/b bbar/b /a should a['b'] be 'foo' or 'bar'? Attribute style access would also fail in this instance -- how is this worked-around? By not having multiple b in the first place! However, if you cannot avoid having duplicates, then you would have to use a different approach: SAX (Simple API for XML; Java has a weird sense of simplicity): import xml.sax as sax from xml.sax.handler import ContentHandler class MyHandler(ContentHandler): def __init__(self): self.inB = False def startElement(self, name, attrs): if name == 'b': self.inB = True def characters(self, ch): if self.inB: print ch def endElement(self, name): if name == 'b': self.inB = False data = 'abFoo/bcEvil/cbBar/b/a' sax.parseString(data, MyHandler()) or in ElementTree: import xml.etree.ElementTree as et data = 'abFoo/bcEvil/cbBar/b/a' a = et.fromstring(data) for elem in a.findall('b'): print elem.text -- http://mail.python.org/mailman/listinfo/python-list
Re: compile Py2.6 on SL
Am 16.09.2010 17:34, schrieb moerchendiser2k3: Hi, I have some trouble with Python on Snow Leopard (10.6.3). I compile Python as a framework(for 32/64bit) without any problems. But implementing the lib in my C app, I get the following error on linking: Undefined symbols: _Py_InitModule4_64, referenced from: RegisterModule_BPY(char const*, PyMethodDef*, char const*, _object*, int)in i_moduleobject.o ld: symbol(s) not found I read a lot of stuff about this problem, but nothing helped me. My app is in 64-bit and I compiled Python for 32/64bit. I'm skeptical that you did - if you really *had* compiled Python for AMD64, this error would not have occured. Please use file/lipo to verify that the Python library really is available as 64-bit code. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning inheritance
On Sep 18, 11:15 pm, Jorgen Grahn grahn+n...@snipabacken.se wrote: On Sat, 2010-09-18, Niklasro wrote: Hi How can I make the visibility of a variable across many methods or files? To avoid repeating the same line eg url = os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else os.environ['SERVER_NAME'] I repeat for many methods. So declaring it to a super class and inheriting it is my plan. Do you agree or propose otherwise? Inheritance is not the main tool for sharing code. Just make it a function and place it in one of your modules (files): def get_host(): Return the environment's $HTTP_HOST if it exists, otherwise $SERVER_NAME or (if that doesn't exist either) None. ... Perhaps you are focusing too much on inheritance in general. I personally almost never use it in Python -- it has much fewer uses here than in staticaly typed languages. /Jorgen -- // Jorgen Grahn grahn@ Oo o. . . \X/ snipabacken.se O o . Thanks for sharing the knowledge. I alternatively think about declaring the variable in a setting.py file and import it. It doesn't create many objects but I want to learn more professional code conventions than same test repeated. Sincerely, Niklas R -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning inheritance
On Sep 19, 2:31 am, alex23 wuwe...@gmail.com wrote: Niklasro nikla...@gmail.com wrote: I got 2 files main.py and i18n both with webapp request handlers which I would like access the variable. I'd probably use a module for this. Create a third file, called something like shared.py, containing the line that bruno gave above: url = os.environ.get(HTTP_HOST, os.environ[SERVER_NAME]) Then from within both main i18n you can 'import shared' and access the variable as 'shared.url'. Python only actually executes a module the first time it's imported, every other import will be given a reference to the same module object. This also lets you share temporary data between modules. Any module that imports 'shared' can add an attribute to it ('shared.foo = barbaz') that will be visible to all other modules that have (or will have) imported it. I try a file setting.py declaring it like this just loose in the file not knowing much theory about it thinking it's easy and intuitive. Thanks Niklas -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning inheritance
It works but I don't know whether it's formally inheritance or class variable. Before code was url = os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else os.environ['SERVER_NAME'] if url.find('niklas') 0: and now the change saves me from repeating myself! util.py: url = os.environ.get(HTTP_HOST, os.environ[SERVER_NAME]) #declared as class variable(?) And viola just test if util.url.find('niklas') 0: Exactly what I wanted to do with your experienced guidance. Many thanks Happy refactored -- http://mail.python.org/mailman/listinfo/python-list
Re: Plz comment on this code
fridge wrote: # bigdigits2.py import sys zero=[***, * *, ***] one=[***, * , ***] digits=[zero,one,zero,one,zero,one,zero,one,zero,one] inputted_digit=sys.argv[1] column_max=len(inputted_digit) row_max=3 r=0 while r3: line= c=0 while ccolumn_max: digit_i=int(inputted_digit[c]) digit=digits[digit_i] line+=digit[r] line+= c+=1 print(line) r+=1 - Add a docstring at the beginning of the script explaining what it is meant to do. - Use four-space indent; add a space between names and operators. - Replace the while-loops with for-loops. You can iterate over numbers and characters: for i in range(3): ... print(i) ... 0 1 2 for c in abc: ... print(c) ... a b c Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 2010-09-19, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: Define unbalanced. I'm not sure that's the word I'd use. I'm not even sure what it would mean here. Putting aside the over-use of punctuation, The C syntax feels unbalanced to me. You have: condition IF true-clause ELSE false-clause so both clauses follow the test, that is, they're on the same side: ?-- Yes. Just like: if condition: foo else: bar The condition is the primary, the clauses are secondary to it. So I like that form because it matches what I'd write if I were writing things out more verbosely for some reason. But the Python syntax looks balanced to me: true-clause IF condition ELSE false-clause which is not only plain English, but perfectly balanced, with a clause on either side of the test: -?- It may be balanced, but it requires you to reevaluate what you're reading after you've already read something that seemed to have a clear meaning. Basically, think of what happens as I read each symbol: x = x + 1 if condition else x - 1 Up through the '1', I have a perfectly ordinary assignment of a value. The, suddenly, it retroactively turns out that I have misunderstood everything I've been reading. I am actually reading a conditional, and the things I've been seeing which looked like they were definitely part of the flow of evaluation may in fact be completely skipped. It's even more confusing if I'm familiar with the postfix-if as seen in, say, perl or ruby. Python's ternary-if puts the emphasis on the true-clause, while C's ternary-if puts the emphasis on the test. I'm not convinced that this is necessarily a better choice than Python's. It's a *valid* choice, but better? I don't think so, but I accept that at least partially boils down to subjective factors. I would usually think it better, just because most often, the *fact* of there being a test is the first thing you have to know about the expression to make sense of it. If I am given the right framework first, and the information to fill into it second, I don't have to throw away parsing I'd already done. If I'm given information, then later retroactively told to move it into a slot in a framework I didn't even know I was going to need, I have to do a lot of reworking. Consider the following lovely hypothetical syntax: foo bar baz if condition else: blah blah blah And there, at least you have some cue that you're about to see something happen. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 2010-09-19, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: I'm not entirely sure I agree with you here... you can't ignore syntax in order to understand the meaning of code. No, but the syntax should be invisible. When I read English, I don't have to think about nouns and verbs and such unless something is very badly written. The syntax is handled automatically at a lower level without conscious intervention, as it should be. Calling my conscious attention to it is disruptive. The term syntax highlighting for what editors I've seen do is actually misleading -- they don't highlight *syntax*, they try to highlight *semantics*. I've never seen this. I've seen things highlight comments and keywords and operators and constants and identifiers differently. When your editor highlights the function len() in the expression x = len(y) + spam(z) but not the function spam(), you know it has nothing to do with syntax. len() is singled out because of its semantics, namely the fact that it's a built-in. Eww. (I had not yet gotten to the point of finding out that whether something was built-in or not substantially affected its semantics.) In English, the meaning of the some sentences do benefit by syntax highlighting, and in fact that's partly what punctuation is for: English partly uses punctuation marks as tags to break the sentence structure into sub-sentences, clauses and terms (particularly when the sentence would otherwise be ambiguous). Punctuation is very different from highlighting, IMHO. That said, I find punctuation very effective at being small and discrete, clearly not words, and easy to pick out. Color cues are not nearly as good at being inobtrusive but automatically parsed. Woman shoots man with crossbow Was it the man armed with a crossbow, or the woman? If we could somehow group the clause with crossbow with woman or man by something *other* than proximity, we could remove the ambiguity. Yes. But syntax highlighting won't help you here -- at least, I've never yet seen any editor that showed precedence relations or anything similar in its coloring. Bringing it back to Python, that's why punctuation like : are useful. They're syntax highlighting. I don't think they are, though. I think punctuation is fundamentally different in intent and purpose from colorizing things based on whether they're, say, constants or identifiers or comments or keywords. The punctuation is *itself* part of the syntax -- it's not being highlighted. Syntax highlighting is putting all the punctuation in green so you know it's punctuation. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning inheritance
On 2010-09-19 09:22, Niklasro wrote: util.py: url = os.environ.get(HTTP_HOST, os.environ[SERVER_NAME]) #declared as class variable(?) There is no class here, so this is no class variable, and you're not inheriting anything. You're simply using a module. And viola just test if util.url.find('niklas') 0: Exactly what I wanted to do with your experienced guidance. Many thanks Happy refactored -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning inheritance
On Sep 19, 8:12 am, Thomas Jollans tho...@jollans.com wrote: On 2010-09-19 09:22, Niklasro wrote: util.py: url = os.environ.get(HTTP_HOST, os.environ[SERVER_NAME]) #declared as class variable(?) There is no class here, so this is no class variable, and you're not inheriting anything. You're simply using a module. And viola just test if util.url.find('niklas') 0: Exactly what I wanted to do with your experienced guidance. Many thanks Happy refactored Good to learn what I'm doing :-) since important being able to explain choices taken farther than doing it because it works. I understand the concept of modules may not correspond to java programming where I come from. Sincerely with thanks for the help, Niklas -- http://mail.python.org/mailman/listinfo/python-list
Re: Plz comment on this code
Your code works (assuming digits gets populated fully), but it's the absolute bare minimum that would. To be brutally honest it's: - unpythonic - you've not used the core features of Python at all, such as for loops over a sequence - poorly formatted - Please read the python style guide and follow it - not reusable - Your code can only be called from the command line, it should be usable as a module - not documented - There is no indication what this code does, other than mentally running it - Fragile - There is no error checking on user input There are other ways to write what you have more concisely (e.g. list comprehensions, iterators) but those can wait for another time. Here is a start at improving your code wrt to the above points: #!/usr/bin/env python3 # bigdigits2.py ZERO = [***, # NB Constants are by convention ALL_CAPS * *, ***] ONE = [** , * , ***] # TODO Define and populate digits 2-9 DIGITS = [ZERO, ONE, ZERO, ONE, ZERO, ONE, ZERO, ONE, ZERO, ONE] def big_digits(str_of_digits): Return a list of lines representing the digits using 3x3 blocks of * banner = [] # Accumulate results in this # Loop over the rows/lines of the result # TODO Replace hard coded block size with global constant or measured size for row in range(3): line_parts = [] # Assemble the current line from the current row of each big digit for digit in str_of_digits: big_digit = DIGITS[int(digit)] line_parts.append(big_digit[row]) # Create a string for the current row and add it to the result line = .join(line_parts) banner.append(line) return banner def usage(): print(Usage: bigdigit.py number, file=sys.stderr) sys.exit(1) if __name__ == __main__: import sys # Check that an argument was passed # NB This will ignore additional arguments if len(sys.argv) = 2: input_string = sys.argv[1] else: usage() # Check that only digits were passed if not input_string.isnumeric(): usage() # All is well, print the output for line in big_digits(input_string): print(line) Here are some suggested further improvements: - Map directly from a digit to it's big digit with a dictionary, rather than indexing into a list: BIG_DIGITS = { 1: [** , * , ***], # ... } - Is input_string.isnumeric() the right test? Can you find a character it would not correctly flag as invalid input? - What if I wanted to use my own 4x4 big digits? Could the big_digits() function accept it as an argument? -- http://mail.python.org/mailman/listinfo/python-list
Re: Plz comment on this code
In message fdd04662-0ae7-46a3-a7d3-d6bb00438...@j19g2000vbh.googlegroups.com, Alex Willmer wrote: # NB Constants are by convention ALL_CAPS SAYS_WHO? -- http://mail.python.org/mailman/listinfo/python-list
Re: Plz comment on this code
In message 4c957412$0$3036$afc38...@news.optusnet.com.au, fridge wrote: digits=[zero,one,zero,one,zero,one,zero,one,zero,one] digits = [zero, one] * 5 row_max=3 Defined but never used. digit_i=int(inputted_digit[c]) digit=digits[digit_i] line+=digit[r] line+= Too many intermediate variables only defined and used once. Do this all on one line. -- http://mail.python.org/mailman/listinfo/python-list
Re: Cross Compiling Python for ARM
In message 4c911670$0$41115$e4fe5...@news.xs4all.nl, Hans Mulder wrote: The most popular way to get the latter problem is to write the script on a Windows box and then upload it to Unix box using FTP in binary mode (or some other transport that doesn't adjust the line endings). I always thought it was a misfeature that the Linux kernel doesn’t recognize all the common conventions for ending the shebang line. All reading of text files should be similarly tolerant. -- http://mail.python.org/mailman/listinfo/python-list
Re: program organization question for web development with python
In message 6102316a-d6e6-4cf2-8a1b-ecc5d3247...@w15g2000pro.googlegroups.com, Hans wrote: print a href=display_tb.py?id=%stable=%scursor=%s%s/a % (record[0],table_name,cursor_name,record1) I would recommend avoiding filename extensions in your URLs wherever possible. For executables, in particular, leaving out the “.py” or “.pl” or whatever makes it easier to switch languages, should you need to in future. -- http://mail.python.org/mailman/listinfo/python-list
Re: Plz comment on this code
On Sep 19, 12:20 pm, Lawrence D'Oliveiro l...@geek- central.gen.new_zealand wrote: In message fdd04662-0ae7-46a3-a7d3-d6bb00438...@j19g2000vbh.googlegroups.com, Alex Willmer wrote: # NB Constants are by convention ALL_CAPS SAYS_WHO? Says PEP 8: Constants Constants are usually declared on a module level and written in all capital letters with underscores separating words. Examples include MAX_OVERFLOW and TOTAL. -- http://www.python.org/dev/peps/pep-0008/ -- http://mail.python.org/mailman/listinfo/python-list
Re: [DB-SIG] dbf files and compact indices
Ethan Furman wrote: Carl Karsten wrote: On Sat, Sep 18, 2010 at 11:23 PM, Ethan Furman et...@stoneleaf.us wrote: Thanks for the suggestion, but I don't want to be tied to Foxpro, which means I need to be able to parse these files directly. I have the dbf files, now I need the idx and cdx files. What do you mean tied ? I meant having to have Foxpro installed. I just learned from another reply that I may not have to have Foxpro installed as long as I have the Foxpro ODBC driver, because then I could use odbc instead of fiddling with the files directly. While I may switch over to odbc in the future, I would still like to have the idx/cdx components. If you are working on Windows, you can install the MS MDAC package to get a hold of the MS FoxPro ODBC drivers. They are usually already installed in Vista and 7, in XP they comes with MS SQL Server and MS Office as well. mxODBC can then provide Python access on Windows, mxODBC Connect on other platforms. If you want direct files access on other platforms, you can use http://pypi.python.org/pypi/dbf/ or http://dbfpy.sourceforge.net/. If you want to add support for index files (which the above two don't support), you could also have a look at this recipe for some inspiration: http://code.activestate.com/recipes/362715-dbf-reader-and-writer/ -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Sep 19 2010) Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ ::: Try our new mxODBC.Connect Python Database Interface for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- http://mail.python.org/mailman/listinfo/python-list
Re: This Is International Don’t-Squawk-Like-A -Parrot Day
On 09/18/10 23:46, Lawrence D'Oliveiro wrote: Do your bit to help stamp out parrocy. Did you send this by mistake? It looks like a parroty-error. I think it's a bit off... -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes and buffers
On Sunday 19 September 2010, it occurred to Carl Banks to exclaim: I am creating a ctypes buffer from an existing non-ctypes object that supports buffer protocol using the following code: from ctypes import * PyObject_AsReadBuffer = pythonapi.PyObject_AsReadBuffer PyObject_AsReadBuffer.argtypes = [py_object,POINTER(c_void_p),POINTER(c_size_t)] PyObject_AsReadBuffer.restype = None def ctypes_buffer_from_buffer(buf): cbuf = c_void_p() size = c_size_t() PyObject_AsReadBuffer(buf,byref(cbuf),byref(size)) return cbuf If I understand what you are doing correctly, you're referencing a Python buffer object and returning a pointer wrapped in some ctypes thingy. hmm. I see some problems in your code: * You're not passing the size along. In the name of sanity, why on earth not?! The pointer cannot be safely used without knowing how long the area of memory referenced is! * You're using the old buffer protocol. You might rather implement this with the one introduced with Python 3.0, and supported in 2.6 as well. It works, but is there a standard way to do this in ctypes? I couldn't find anything in the documentation. Python 2.6 for now. Thanks. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: C++ - Python API
In article mailman.334.1283373081.29448.python-l...@python.org, Thomas Jollans tho...@jollybox.de wrote: On Wednesday 01 September 2010, it occurred to Markus Kraus to exclaim: So the feature overview: First, the obligatory things you don't want to hear: Have you had a look at similar efforts? A while ago, Aahz posted something very similar on this very list. You should be able to find it in any of the archives without too much trouble. You almost certainly have me confused with someone else -- I wouldn't touch C++ with a ten-meter pole if I could possibly help it. (The last time I dealt with C++ code, about a decade ago, I just rewrote it in C.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: This Is International Don’t-Squawk-Like-A -Parrot Day
In article mailman.878.1284897801.29448.python-l...@python.org, Tim Chase python.l...@tim.thechases.com wrote: On 09/18/10 23:46, Lawrence D'Oliveiro wrote: Do your bit to help stamp out parrocy. Did you send this by mistake? It looks like a parroty-error. I think it's a bit off... Agh! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Down with tinyurl! (was Re: importing excel data into a python matrix?)
In article mailman.343.1283384585.29448.python-l...@python.org, geremy condra debat...@gmail.com wrote: On Wed, Sep 1, 2010 at 4:35 PM, patrick mcnameeking pmcnameek...@gmail.com wrote: I've been working with Python now for about a year using it primarily for scripting in the Puredata graphical programming environment. I'm working on a project where I have been given a 1000 by 1000 cell excel spreadsheet and I would like to be able to access the data using Python. Does anyone know of a way that I can do this? http://tinyurl.com/2eqqjxv Please don't use tinyurl -- it's opaque and provides zero help to anyone who might later want to look it up (and also no accessibility if tinyurl ever goes down). At the very least, include the original URL for reference. (Yes, I realize this is probably a joke given the smiley I excised, but too many people do just post tinyurl.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: This Is International Don’t-Squawk-Like-A -Parrot Day
On Sep 19, 2010, at 7:37 AM, Tim Chase wrote: On 09/18/10 23:46, Lawrence D'Oliveiro wrote: Do your bit to help stamp out parrocy. Did you send this by mistake? It looks like a parroty-error. I think it's a bit off... What an wkward thing to say. Are you crackers? -- http://mail.python.org/mailman/listinfo/python-list
Re: C++ - Python API
On Sunday 19 September 2010, it occurred to Aahz to exclaim: In article mailman.334.1283373081.29448.python-l...@python.org, Thomas Jollans tho...@jollybox.de wrote: On Wednesday 01 September 2010, it occurred to Markus Kraus to exclaim: So the feature overview: First, the obligatory things you don't want to hear: Have you had a look at similar efforts? A while ago, Aahz posted something very similar on this very list. You should be able to find it in any of the archives without too much trouble. You almost certainly have me confused with someone else -- I wouldn't touch C++ with a ten-meter pole if I could possibly help it. (The last time I dealt with C++ code, about a decade ago, I just rewrote it in C.) Sorry about that. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 09/18/2010 11:28 PM, Steven D'Aprano wrote: On Sat, 18 Sep 2010 21:58:58 -0400, AK wrote: I don't understand this. So far as I know, the phrase speed reading refers to various methods of reading much faster than most people read, and is real but not exceptionally interesting. Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. Woody Allen joke: I learned speed reading and read WarPeace; - it involves Russia. My wife can read scarily fast. It's very something to watch her reading pages as fast as she can turn them, and a few years ago she read the entire Harry Potter series (to date) in one afternoon, and could gives a blow-by-blow account of the plots, including a detailed critique of the writing style and characters. But then, she feels that reading the Potter series is a chore to be completed as fast as possible, rather than a pleasure to be savored. She'll sometimes drag a new Terry Pratchett or Stephen King novel out for as much as two days. That's pretty impressive. I used to get somewhat close to that speed when, years ago, I'd read a lot of trashy scifi. The way it would work is that I'd sense in advance that there's a passage where the hero with his team is going through a desert area and I'd know that a 30-40 page section will be punctuated by two battles and one friendly encounter. I would be able to read at different speeds depending on what's going on, slowing down a bit where a twist is presented or a crucial plot point is revealed, both would be telegraphed well in advance. In other spots, I'd be able to scan a few words at the top of page, a few in the middle and at the bottom and I'd know what's going on, generally. I would also be able to give a detailed account of the plot and writing style and characters but this would be entirely due to predictability of writing and following tropes. Interestingly, I've also read LoTR in the same way when I was younger because I was interested in battles and skipped the dull parts. I tried a few times to read Potter book 3 but couldn't bear it.. spoiled too much by Barrie and Grahame. When I was reading The book of the new sun, though, I could stop and read a single sentence a few times over and reflect on it for a minute. -ak -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 09/19/2010 03:31 AM, Seebs wrote: On 2010-09-19, Steven D'Apranost...@remove-this-cybersource.com.au wrote: Define unbalanced. I'm not sure that's the word I'd use. I'm not even sure what it would mean here. Putting aside the over-use of punctuation, The C syntax feels unbalanced to me. You have: condition IF true-clause ELSE false-clause so both clauses follow the test, that is, they're on the same side: ?-- Yes. Just like: if condition: foo else: bar The condition is the primary, the clauses are secondary to it. To me, the problem with C ternary is, why is true condition first and false second? It could just as well be the other way around. With if and else, the meaning is direct, x if y else z, or if y: x; else: z. It may be balanced, but it requires you to reevaluate what you're reading after you've already read something that seemed to have a clear meaning. Basically, think of what happens as I read each symbol: x = x + 1 if condition else x - 1 Up through the '1', I have a perfectly ordinary assignment of a value. The, suddenly, it retroactively turns out that I have misunderstood everything I've been reading. I am actually reading a conditional, and the things I've been seeing which looked like they were definitely part of the flow of evaluation may in fact be completely skipped. That's absolutely not how I read code. For example, if you have a line like: x = x + 1 a...@#$!@$asfa...@#$!@$#adfas...@# Do you read it as ok, assignment.. x is x + 1.. whoa, what the hell is this?. I would read it like there's something wrong at the end of line, before I even see it as an assignment. That's where syntax highlighting comes in, as well. What I see, at the same time (i.e. not in sequence): .. = .. if .. else .. The second thing I see is what variable is being assigned to. Of couse, this might change if I'm looking for that particular variable, then I might see: x or x = Consider the following lovely hypothetical syntax: foo bar baz if condition else: blah blah blah And there, at least you have some cue that you're about to see something happen. After some time getting used to it, I'd end up seeing this as: . . . if .. else: . . . at first and then processing everything else. Again, syntax highlighting would help here. The only issue is that it'd be hard to separate the beginning from other code, for me that'd be the primary reason why this is not a good construct. -ak -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 09/19/2010 03:36 AM, Seebs wrote: On 2010-09-19, Steven D'Apranost...@remove-this-cybersource.com.au wrote: I'm not entirely sure I agree with you here... you can't ignore syntax in order to understand the meaning of code. No, but the syntax should be invisible. When I read English, I don't have to think about nouns and verbs and such unless something is very badly written. The syntax is handled automatically at a lower level without conscious intervention, as it should be. Calling my conscious attention to it is disruptive. The interesting thing is that syntax highlight for me *is* handled at a lower level. What you're describing is exactly the same as when I try a highlight scheme with colours that are too strong, or have a background. I would rather use no highlighting at all than a theme with garish colours. When I read code, I filter out colours when I don't need them and filter out non-coloured text when I'm looking for a particular structure. So, with x = y if a else z, I might see . = . if . else . and then immediately see x . y . a . z, already with knowledge of what is the structure surrounding vars. Punctuation is very different from highlighting, IMHO. That said, I find punctuation very effective at being small and discrete, clearly not words, and easy to pick out. Color cues are not nearly as good at being inobtrusive but automatically parsed. Seems like the difference of how you process colours vs. how I do, for me they work precisely in the same way as punctuation might, but adding an additional layer which may be used but never gets in the way. -ak -- http://mail.python.org/mailman/listinfo/python-list
comp.lang.python
http://127760.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Making logging.getLogger() simpler
On Sun, 19 Sep 2010 02:35:15 +1000, Lie Ryan wrote: I was expecting this to work: import logging logger = logging.getLogger(__name__) logger.warn('this is a warning') instead it produced the error: No handlers could be found for logger __main__ However, if instead I do: import logging logging.warn('creating logger') logger = logging.getLogger(__name__) logger.warn('this is a warning') then it does work. Is there any reason why getLogger()-created logger shouldn't automatically create a default handler? Hello Lie, Calling logging.warn(), or logging.debug() etc. before handlers have been assigned to the root logger will result in logging.basicConfig() being called automatically. By default a StreamHandler will be created on the root logger and your logger inherits the StreamHandler. So you can avoid the No handlers... warning by calling logging.basicConfig() before your program does any logging. I don't know why getLogger() doesn't so something similar when it's called. Perhaps so that the logger is explicitly initialised with basic, file or dictConfig? Cheers, Kev -- http://mail.python.org/mailman/listinfo/python-list
Re: socket.error: [Errno 98] Address already in use
On Sun, 19 Sep 2010 18:42:51 +1200, Lawrence D'Oliveiro wrote: That's why Stevens recommends that all TCP servers use the SO_REUSEADDR socket option. I don’t think I’ve ever used that. It seems to defeat a safety mechanism which was put in for a reason. It was put in for the benefit of clients, to prevent them from selecting a port which they won't be able to use. But clients typically don’t care what port they use—they let the system pick a port for them, so this kind of option is unnecessary. If they use an ephemeral port, the kernel won't pick a port which has any connections in the TIME_WAIT state. However, some clients choose their own source ports. E.g. rlogin/rsh use privileged (low-numbered) ports, and you can't get the kernel to choose a random privileged port for you. If you're writing a server which listens on a known port, you *should* be using SO_REUSEADDR to avoid unnecessary delays in start-up. The kernel will automatically reject packets relating to stale connections, and your server should be accepting any new connections ASAP. -- http://mail.python.org/mailman/listinfo/python-list
newbie: class and __dict__ variable.
Hallo Group Members. From time to time I see in python code following notation that (as I believe) extends namespace of MyClass. class MyClass: def __init__(self): self.__dict__[maci]=45 myCl2 = MyClass2() print myCl2.maci I am guessing that there must be some difference between the one above and the one below, because otherwise no one would probably use the one above. Do YOu know that difference? class MyClass2: def __init__(self): self.maci=45 myCl = MyClass() print myCl.maci best regards, Pawel -- http://mail.python.org/mailman/listinfo/python-list
develop for Windows on GNU/Linux, using Python
Consider: Can someone do development of programs for use on Windows systems, but developed totally on a GNU/Linux system, using standard, contemporary 32 and / or 64-bit PC hardware? This would be for someone who can not or will not use Windows, but wants to create software for those who do. This might not include the use of VM for developing on GNU/Linux, as that would seem to require a Windows installation disk, which the developer may not be able or willing to obtain and use. Is the correct answer: 1) no. 2) yes. 3) yes, a Hello World program will run just fine on the Windows Python interpreter. 4) other. -- http://mail.python.org/mailman/listinfo/python-list
http2https proxy
I'd like to open a ssl connection to a https server, done Create a socket and bind it to a local port, done Connect the two in such a way that everything read or written to the local port is actually read or written to the https server. In other words I want a http2https proxy. ideas? best regards, Seb -- http://mail.python.org/mailman/listinfo/python-list
Re: develop for Windows on GNU/Linux, using Python
On Sun, 19 Sep 2010 12:55:43 -0500, Default User wrote: Consider: Can someone do development of programs for use on Windows systems, but developed totally on a GNU/Linux system, using standard, contemporary 32 and / or 64-bit PC hardware? This would be for someone who can not or will not use Windows, but wants to create software for those who do. This might not include the use of VM for developing on GNU/Linux, as that would seem to require a Windows installation disk, which the developer may not be able or willing to obtain and use. Is the correct answer: 1) no. 2) yes. 3) yes, a Hello World program will run just fine on the Windows Python interpreter. 4) other. Hello, The answer is it depends, or 4 on your list of responses. You can write pure python on a Linux machine and it will run fine on Windows as long as you've taken care to program in a portable fashion. However, writing the code isn't everything. To be confident that your code is good you need to test it on a Windows box (we all test, right?). If you want to distribute your application to non-developers you'll need to wrap it in a Windows installer; if you have C-extensions in your code you'll need to compile them over Windows. If you want to program against the Windows API you'll need access to a Windows box. So, if you really want to develop code for Windows (or cross-platform code) I think you need to bite the bullet and get access to a Windows (virtual) machine. Cheers, Kev PS - You might be able to get away with using an emulator like WINE, but given the ubiquity of Windows in business/home computing I think you're better of testing on the real thing. -- http://mail.python.org/mailman/listinfo/python-list
Re: [DB-SIG] dbf files and compact indices
M.-A. Lemburg wrote: If you are working on Windows, you can install the MS MDAC package to get a hold of the MS FoxPro ODBC drivers. They are usually already installed in Vista and 7, in XP they comes with MS SQL Server and MS Office as well. mxODBC can then provide Python access on Windows, mxODBC Connect on other platforms. If you want direct files access on other platforms, you can use http://pypi.python.org/pypi/dbf/ ^--- I'm the author if this package :) or http://dbfpy.sourceforge.net/. ^--- from the quick skim of the code, I think mine does more at this point (memos, adding/deleting/renaming fields in existing tables, in-memory indexes, unicode support, export to csv,tab,fixed formats, field access via attribute/dictionary/index style (e.g. table.fullname or table['fullname'] or table[0] if fullname is the first field), very rudimentary sql support, etc.) If you want to add support for index files (which the above two don't support), you could also have a look at this recipe for some inspiration: http://code.activestate.com/recipes/362715-dbf-reader-and-writer/ I didn't see anything regarding the .idx or .cdx files in this recipe. :( Thanks for your time, though! -- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 2010-09-19, AK andrei@gmail.com wrote: On 09/19/2010 03:31 AM, Seebs wrote: Just like: if condition: foo else: bar The condition is the primary, the clauses are secondary to it. To me, the problem with C ternary is, why is true condition first and false second? It could just as well be the other way around. Again, look at the long-form if/else above; it's always if a then b otherwise c. With if and else, the meaning is direct, x if y else z, or if y: x; else: z. The latter still has condition, true, false. Basically, think of what happens as I read each symbol: x = x + 1 if condition else x - 1 Up through the '1', I have a perfectly ordinary assignment of a value. The, suddenly, it retroactively turns out that I have misunderstood everything I've been reading. I am actually reading a conditional, and the things I've been seeing which looked like they were definitely part of the flow of evaluation may in fact be completely skipped. That's absolutely not how I read code. For example, if you have a line like: x = x + 1 a...@#$!@$asfa...@#$!@$#adfas...@# Do you read it as ok, assignment.. x is x + 1.. whoa, what the hell is this?. Not for something that big and visible. But the if/else stuff is just ordinary blocks of text. That's where syntax highlighting comes in, as well. So basically, if we use syntax highlighting to make up for the legibility problems of a given syntax, then the syntax is okay, but people who don't use syntax highlighting to make up for its legibility problems are wrong. I see. This does seem self-contained; you like syntax highlighting because you like constructs which are hard to read without it. You like those constructs because they let you show off syntax highlighting. After some time getting used to it, I'd end up seeing this as: . . . if .. else: . . . at first and then processing everything else. Assuming that the if/else was on the same page. :) Again, syntax highlighting would help here. The only issue is that it'd be hard to separate the beginning from other code, for me that'd be the primary reason why this is not a good construct. No matter how long I'd been using that construct, I'd still have the problem that, mechanically, I'm going to see the opening few lines first, and that means that those lines are going to get parsed first. I read largely in order. I do have some lookahead, but no matter how much I use the lookahead, I'm already parsing the first things I see, and that's top-down-left-right. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Making logging.getLogger() simpler
On Sep 18, 5:35 pm, Lie Ryan lie.1...@gmail.com wrote: I was expecting this to work: importlogging logger =logging.getLogger(__name__) logger.warn('this is a warning') instead it produced the error: No handlers could be found for logger __main__ However, if instead I do: importlogging logging.warn('creating logger') logger =logging.getLogger(__name__) logger.warn('this is a warning') then it does work. Is there any reason why getLogger()-created logger shouldn't automatically create a default handler? There is a good reason why a getLogger()-created logger doesn't add a default handler. Imagine if it did, and the code you were writing was a library module that was used in an application being written by another developer. Imagine if there were several other libraries which also declared loggers (and therefore several default handlers). Then the result of running the application would be to get a whole bunch of unexpected messages from those libraries, including yours. This would annoy the application developer no end, and rightly so. For simple uses of logging (where you are writing a utility script, for example, when you are the application developer) you can call logging.warning() etc. which will (for your convenience) add a handler to write to the console for you, if there isn't a handler already. If you are doing something more involved, you will need to configure logging to do whatever it is you want, and when you run your program your log will contain messages from your application as well as third- party libraries you use, all playing well together and with no unpleasant surprises. If you are writing a library, you will typically: 1. Add a NullHandler to your top-level logger. 2. If you want to force your users (application developers) to add handlers explicitly to their loggers, set your top-level logger's propagate flag to False. 3. If you want to have a specific verbosity on your loggers, which is different from the default (WARNING), you need to set that level on your top-level logger, or on individual loggers for which you want that specific, non-default verbosity. I hope that helps, Vinay Sajip -- http://mail.python.org/mailman/listinfo/python-list
Re: Making logging.getLogger() simpler
On Sep 19, 7:52 pm, Vinay Sajip vinay_sa...@yahoo.co.uk wrote: If you are writing a library, you will typically: 2. If you want to force your users (application developers) to add handlers explicitly to their loggers, set your top-level logger's propagate flag to False. Sorry, in the above text, where it says their loggers it should say your loggers Regards, Vinay Sajip -- http://mail.python.org/mailman/listinfo/python-list
Re: develop for Windows on GNU/Linux, using Python
Kev Dwyer wrote: On Sun, 19 Sep 2010 12:55:43 -0500, Default User wrote: Consider: Can someone do development of programs for use on Windows systems, but developed totally on a GNU/Linux system, using standard, contemporary 32 and / or 64-bit PC hardware? This would be for someone who can not or will not use Windows, but wants to create software for those who do. This might not include the use of VM for developing on GNU/Linux, as that would seem to require a Windows installation disk, which the developer may not be able or willing to obtain and use. Is the correct answer: 1) no. 2) yes. 3) yes, a Hello World program will run just fine on the Windows Python interpreter. 4) other. Hello, The answer is it depends, or 4 on your list of responses. You can write pure python on a Linux machine and it will run fine on Windows as long as you've taken care to program in a portable fashion. And not use modules not yet converted to microsoft, seems to happen from time to time. if you have C-extensions in your code you'll need to compile them over Windows. If you want to program against the Windows API you'll need access to a Windows box. You can always cross compile, not only over OS but even CPU architecture, but of course testing will be more difficult, on x86 based Linux you can use wine or similar to test, but can give you some differences to run on a native or virtualized instance. -- //Aho -- http://mail.python.org/mailman/listinfo/python-list
Python and unicode
Hi everybody. I've played for few hours with encoding in py, but it's still somewhat confusing to me. So I've written a test file (encoded as utf-8). I've put everything I think is true in comment at the beginning of script. Could you check if it's correct (on side note, script does what I intended it to do). One more thing, is there some mechanism to avoid writing all the time 'something'.decode('utf-8')? Some sort of function call to tell py interpreter that id like to do implicit decoding with specified encoding for all string constants in script? Here's my script: --- # vim: set encoding=utf-8 : - encoding and py - - 1st (or 2nd) line tells py interpreter encoding of file - if this line is missing, interpreter assumes 'ascii' - it's possible to use variations of first line - the first or second line must match the regular expression coding[:=]\s*([-\w.]+) (PEP-0263) - some variations: ''' # coding=encoding name ''' ''' #!/usr/bin/python # -*- coding: encoding name -*- ''' ''' #!/usr/bin/python # vim: set fileencoding=encoding name : ''' - this version works for my vim: ''' # vim: set encoding=utf-8 : ''' - constants can be given via str.decode() method or via unicode constructor - if locale is used, it shouldn't be set to 'LC_ALL' as it changes encoding import datetime, locale #locale.setlocale(locale.LC_ALL,'croatian') # changes encoding locale.setlocale(locale.LC_TIME,'croatian') # sets correct date format, but encoding is left alone print 'default locale:', locale.getdefaultlocale() s='abcdef ČčĆćĐ𩹮ž'.decode('utf-8') ss=unicode('ab ČćŠđŽ','utf-8') # date part of string is decoded as cp1250, because it's default locale all=datetime.date(2000,1,6).strftime('%d.%m.%Y.', %x, %A, %B, ).decode('cp1250')+'%s, %s' % (s, ss) print all --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and unicode
One more thing, is there some mechanism to avoid writing all the time 'something'.decode('utf-8')? Yes, use u'something' instead (i.e. put the letter u before the literal, to make it a unicode literal). Since Python 2.6, you can also put from __future__ import unicode_literals at the top of the file to make all string literals Unicode objects. Since Python 3.0, this is the default (i.e. all string literals *are* unicode objects). Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 09/19/2010 02:21 PM, Seebs wrote: On 2010-09-19, AKandrei@gmail.com wrote: On 09/19/2010 03:31 AM, Seebs wrote: Just like: if condition: foo else: bar The condition is the primary, the clauses are secondary to it. To me, the problem with C ternary is, why is true condition first and false second? It could just as well be the other way around. Again, look at the long-form if/else above; it's always if a then b otherwise c. Because that's what 'if' and 'else' mean. I have no problem with '?' separating condition from possible outcomes.. The most natural reading of that construct is that depending on condition, there are two possible outcomes, separated by a ':' and you have to remember that first outcome corresponds to true condition. x = y if a else z is much more pythonic because 'else' is explicitly saying what happens on false condition. Explicit is better than implicit. That's absolutely not how I read code. For example, if you have a line like: x = x + 1 a...@#$!@$asfa...@#$!@$#adfas...@# Do you read it as ok, assignment.. x is x + 1.. whoa, what the hell is this?. Not for something that big and visible. But the if/else stuff is just ordinary blocks of text. Not with syntax highlighting they're not ;) Seriously though, my guess is even without syntax highlighting I'd still prefer it because I do enough look-ahead and in 95% of cases the first 'if' is close enough to the beginning of the line. In fact, most often plain assignments will be much shorter than this construct so you can figure it out by combination of line length and the 'if' keyword. It still has the advantage over the more verbose version that I mentioned before: you can see immediately that there's an assignment to a single variable, and the logic flows like a single sentence in a natural language. That's where syntax highlighting comes in, as well. So basically, if we use syntax highlighting to make up for the legibility problems of a given syntax, then the syntax is okay, but people who don't use syntax highlighting to make up for its legibility problems are wrong. That's not really true, it merely makes a given syntax easier to read even when it's already a preferable syntax. It's like this, if someone gives you five dollars for nothing, and then later gives you three dollars, you don't complain that the latter amount is less than former :). I see. This does seem self-contained; you like syntax highlighting because you like constructs which are hard to read without it. You like those constructs because they let you show off syntax highlighting. Well, you're exaggerating this out of all proportion just to prove a point. I like syntax highlighting in all of python and, in fact, in all languages I've used. Even in crontab files! This is a single construct I can think of, which, being already very readable, explicit, and succinct, *on top of that*, gains even more in readability due to syntax highlight. So, as you can see, I'd like syntax highlight just fine if this construct was not present in Python, and in fact I did. Conversely, I'd prefer it to the longer version if there was no syntax highlight at all. After some time getting used to it, I'd end up seeing this as: . . . if .. else: . . . at first and then processing everything else. Assuming that the if/else was on the same page. :) I'll concede you one point in this case: if the statement 'x = .. if .. else .. ' is split over two pages, I would at least seriously consider the 'if: .. else: ' version. ;) -ak -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 2010-09-19, AK andrei@gmail.com wrote: Because that's what 'if' and 'else' mean. My point is, I don't want the order of the clauses in if/else to change. If it is sometimes if condition true-clause else false-clause, then it should *ALWAYS WITHOUT EXCEPTION* be condition first, then true clause, then false clause. If it's sometimes if condition true-clause else false-clause, and sometimes true-clause if condition else false-clause, that's a source of extra complexity. I have no problem with '?' separating condition from possible outcomes.. The most natural reading of that construct is that depending on condition, there are two possible outcomes, separated by a ':' and you have to remember that first outcome corresponds to true condition. Exactly as it ALWAYS does. That's the point. x = y if a else z is much more pythonic because 'else' is explicitly saying what happens on false condition. Explicit is better than implicit. Is it more pythonic to shuffle the orders of clauses in precisely analagous constructs? I'm not arguing against the use of the *words* if and else. I'm arguing that the shuffling of the orders of the clauses creates confusion. It still has the advantage over the more verbose version that I mentioned before: you can see immediately that there's an assignment to a single variable, and the logic flows like a single sentence in a natural language. I'm getting frustrated here because I really felt my point was pretty clearly expressed, and yet, every time you respond, you respond to things TOTALLY DIFFERENT from what I am saying. The syntax I like for this kind of thing is: x = if condition then true-clause else false-clause This is because it follows the same *ordering* as the multi-line if/else, so it preserves the logical flow. Condition, then true clause, then false clause. Always. The only way in which this is more verbose than the inverted one is the then, and you don't even need that if you stick with a python-style colon: x = if condition: true-clause else false-clause But this is *always* easier to follow because it follows the same logical structure. Leave poetic inversion to the poets. That's not really true, it merely makes a given syntax easier to read even when it's already a preferable syntax. Except that it's *NOT PREFERABLE* to me, because it is BACKWARDS. Have I somehow failed to express this? Is there some magical rule that it is not pythonic for you to react in any way to the actual comparison I'm making, rather than to totally unrelated comparisons? I gave the example of what an if/else statement looks like, not because I think it is always better to use statements and blocks instead of expressions, but to point out the LOGICAL ORDER. You were asking why I preferred the condition to come first. My answer is, because the condition comes first in an if/else statement normally, and I like to preserve the logical flow. Instead, you're off ranting about how that's too long. But that's not my point. My point was *only* that the logical flow is consistent between if/else and the way various languages have done if/else expressions: Condition first, then true clause, then false clause. Doesn't matter whether it's ruby or C or lua or even bourne shell, in every other language I use that lets me use an if/else as part of an expression, it follows the SAME logical flow as the regular if/else statement. In Python, it's inverted. You were arguing that this inversion is better and more intuitive, and that there is no reason to expect the condition to come first. But there is! The condition comes first in regular if/else statements. This establishes a pattern -- if/else things are introduced by their condition, then you get the true clause and then you get the false clause. Well, you're exaggerating this out of all proportion just to prove a point. No, I'm not. This is a single construct I can think of, which, being already very readable, explicit, and succinct, *on top of that*, gains even more in readability due to syntax highlight. But it's *not readable to me*. Because it's backwards. So, as you can see, I'd like syntax highlight just fine if this construct was not present in Python, and in fact I did. Conversely, I'd prefer it to the longer version if there was no syntax highlight at all. And again, NO ONE HAS SUGGESTED THE LONGER VERSION. AT ALL. EVER. I don't understand why you keep contrasting this with the longer version when the only reason that was brought up was to COMPARE it in terms of *logical flow*. I pointed out the *PARALLELS* between conditional expressions and conditional statements. I did not suggest that the longer version should be preferred in all cases, or even in all that many. I'll concede you one point in this case: if the statement 'x = .. if .. else .. ' is split over two pages, I would at least seriously consider the 'if: .. else: ' version. ;) Okay, one more
Re: Too much code - slicing
On 19/09/2010 22:32, Seebs wrote: On 2010-09-19, AKandrei@gmail.com wrote: Because that's what 'if' and 'else' mean. My point is, I don't want the order of the clauses in if/else to change. If it is sometimes ifcondition true-clause elsefalse-clause, then it should *ALWAYS WITHOUT EXCEPTION* be condition first, then true clause, then false clause. If it's sometimes if condition true-clause else false-clause, and sometimes true-clause if condition else false-clause, that's a source of extra complexity. [snip] Have you read PEP 308? There was a lot of discussion about it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
On Sun, Sep 19, 2010 at 9:16 AM, Aahz a...@pythoncraft.com wrote: In article mailman.343.1283384585.29448.python-l...@python.org, geremy condra debat...@gmail.com wrote: On Wed, Sep 1, 2010 at 4:35 PM, patrick mcnameeking pmcnameek...@gmail.com wrote: I've been working with Python now for about a year using it primarily for scripting in the Puredata graphical programming environment. I'm working on a project where I have been given a 1000 by 1000 cell excel spreadsheet and I would like to be able to access the data using Python. Does anyone know of a way that I can do this? http://tinyurl.com/2eqqjxv Please don't use tinyurl -- it's opaque and provides zero help to anyone who might later want to look it up (and also no accessibility if tinyurl ever goes down). At the very least, include the original URL for reference. (Yes, I realize this is probably a joke given the smiley I excised, but too many people do just post tinyurl.) Not that I disagree with you, but you might find this helpful: http://tinyurl.com/preview.php -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
On 20 September 2010 07:59, Ken Watford kwatford+pyt...@gmail.comkwatford%2bpyt...@gmail.com wrote: Not that I disagree with you, but you might find this helpful: http://tinyurl.com/preview.php -- http://mail.python.org/mailman/listinfo/python-list I don't think the OP wants a preview feature. The fact that you still have to go through tinyurl (which by the way, the short link itself in the email has no information on where it is whatsoever), and it makes searching through the archives difficult, too. We don't have a 140 character limit like Twitter. There's no reason we can't post the full link for reference purposes. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes and buffers
On Sep 19, 5:10 am, Thomas Jollans tho...@jollybox.de wrote: On Sunday 19 September 2010, it occurred to Carl Banks to exclaim: I am creating a ctypes buffer from an existing non-ctypes object that supports buffer protocol using the following code: from ctypes import * PyObject_AsReadBuffer = pythonapi.PyObject_AsReadBuffer PyObject_AsReadBuffer.argtypes = [py_object,POINTER(c_void_p),POINTER(c_size_t)] PyObject_AsReadBuffer.restype = None def ctypes_buffer_from_buffer(buf): cbuf = c_void_p() size = c_size_t() PyObject_AsReadBuffer(buf,byref(cbuf),byref(size)) return cbuf If I understand what you are doing correctly, you're referencing a Python buffer object and returning a pointer wrapped in some ctypes thingy. hmm. I see some problems in your code: * You're not passing the size along. In the name of sanity, why on earth not?! The pointer cannot be safely used without knowing how long the area of memory referenced is! How D'Olivero of you to overreact this way. A. No, and B. I already know the size of the object * You're using the old buffer protocol. You might rather implement this with the one introduced with Python 3.0, and supported in 2.6 as well. Hmm, I didn't know they got that into 2.6. Maybe I'll do that, thanks. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and unicode
Goran Novosel goran.novo...@gmail.com writes: # vim: set encoding=utf-8 : This will help Vim, but won't help Python. Use the PEP 263 encoding declaration URL:http://www.python.org/dev/peps/pep-0263/ to let Python know the encoding of the program source file. # -*- coding: utf-8 -*- You can use the bottom of the file for editor hints. s='abcdef ČčĆćĐ𩹮ž'.decode('utf-8') ss=unicode('ab ČćŠđŽ','utf-8') In Python 2.x, those string literals are created as byte strings, which is why you're having to decode them. Instead, tell Python explicitly that you want a string literal to be a Unicode text string: s = u'abcdef ČčĆćĐ𩹮ž' ss = u'ab ČćŠđŽ' Learn more from the documentation URL:http://docs.python.org/howto/unicode. -- \ “He that would make his own liberty secure must guard even his | `\ enemy from oppression.” —Thomas Paine | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
AK wrote: Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. I've never understood why anyone would *want* to read a novel that fast, though. For me at least, reading a novel is something done for pleasure, so reading it at ten times normal speed would waste 90% of the benefit. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 2010-09-19, MRAB pyt...@mrabarnett.plus.com wrote: On 19/09/2010 22:32, Seebs wrote: On 2010-09-19, AKandrei@gmail.com wrote: Because that's what 'if' and 'else' mean. My point is, I don't want the order of the clauses in if/else to change. If it is sometimes ifcondition true-clause elsefalse-clause, then it should *ALWAYS WITHOUT EXCEPTION* be condition first, then true clause, then false clause. If it's sometimes if condition true-clause else false-clause, and sometimes true-clause if condition else false-clause, that's a source of extra complexity. [snip] Have you read PEP 308? There was a lot of discussion about it. Interesting, in the historical section we see: The original version of this PEP proposed the following syntax: expression1 if condition else expression2 The out-of-order arrangement was found to be too uncomfortable for many of participants in the discussion; especially when expression1 is long, it's easy to miss the conditional while skimming. But apparently those objections were either unknown or disregarded when the syntax was later adopted. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 2010-09-19, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: AK wrote: Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. I've never understood why anyone would *want* to read a novel that fast, though. For me at least, reading a novel is something done for pleasure, so reading it at ten times normal speed would waste 90% of the benefit. I get pleasure from the story, not from the time spent. Reading faster means I get more stories. Same thing, to some extent, with programming. I could easily spend much more time writing some programs by switching to a language ill-suited to them (say, using C for heavy string manipulation, or PHP for anything), but that wouldn't mean I had more fun, it would mean my fun was spread out over a longer period of time, and might well cross over to no-longer-fun. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: socket.error: [Errno 98] Address already in use
In message pan.2010.09.19.17.19.19.687...@nowhere.com, Nobody wrote: However, some clients choose their own source ports. E.g. rlogin/rsh use privileged (low-numbered) ports, and you can't get the kernel to choose a random privileged port for you. But nobody uses rlogin/rsh any more, and who would attach any trustworthy meaning to a connection coming from a remote low-numbered source port? If you're writing a server which listens on a known port, you *should* be using SO_REUSEADDR to avoid unnecessary delays in start-up. The kernel will automatically reject packets relating to stale connections, and your server should be accepting any new connections ASAP. That makes it sound like SO_REUSEADDR should really be a superfluous option. But it’s not. -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
In message i752g1$1r...@panix5.panix.com, Aahz wrote: Please don't use tinyurl -- it's opaque and provides zero help to anyone who might later want to look it up (and also no accessibility if tinyurl ever goes down). At the very least, include the original URL for reference. +1 from someone who has seen URL-shortening used even in reader comments on websites which allow HTML links. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
AK andrei@gmail.com wrote: When I was reading The book of the new sun, though, I could stop and read a single sentence a few times over and reflect on it for a minute. Totally understandable, Wolfe is a far, far greater writer than Rowling :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 09/19/2010 07:18 PM, Gregory Ewing wrote: AK wrote: Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. I've never understood why anyone would *want* to read a novel that fast, though. For me at least, reading a novel is something done for pleasure, so reading it at ten times normal speed would waste 90% of the benefit. One definite advantage would be that if, say, it takes you 70 pages of a given novel to figure out whether you like it enough to continue, you'd want to read those pages in 2 minutes rather than an hour. Unfortunately, beginning of a novel is where I have to read at the slowest rate because I'm not used to author's style and pacing yet and I don't want to miss something crucial. -ak -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie: class and __dict__ variable.
On 9/19/2010 1:37 PM, mafeu...@gmail.com wrote: Hallo Group Members. From time to time I see in python code following notation that (as I believe) extends namespace of MyClass. No, it does not affect MyClass, just the instance dict. class MyClass: def __init__(self): self.__dict__[maci]=45 Have you seen exactly this usage? myCl2 = MyClass2() print myCl2.maci I am guessing that there must be some difference between the one above and the one below, because otherwise no one would probably use the one above. Do YOu know that difference? class MyClass2: def __init__(self): self.maci=45 If the class has a .__setattr__ method, the first bypasses that method, the second results in it being called. The direct __dict__ access is most useful within a .__setattr__ method to avoid infinite recursion. myCl = MyClass() print myCl.maci -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
On Sep 19, 2010, at 6:05 PM, Xavier Ho wrote: On 20 September 2010 07:59, Ken Watford kwatford+pyt...@gmail.comkwatford%2bpyt...@gmail.com wrote: Not that I disagree with you, but you might find this helpful: http://tinyurl.com/preview.php -- http://mail.python.org/mailman/listinfo/python-list I don't think the OP wants a preview feature. The fact that you still have to go through tinyurl (which by the way, the short link itself in the email has no information on where it is whatsoever), and it makes searching through the archives difficult, too. We don't have a 140 character limit like Twitter. There's no reason we can't post the full link for reference purposes. Some email systems still insert hard line breaks around the 72 or 80 column mark and as a result long URLs get broken. I hope anyone on this list would be able to surgically repair a broken URL, but I email plenty of people who can't and tinyurl friends are really helpful in that context. bye P -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 2010-09-20, alex23 wuwe...@gmail.com wrote: AK andrei@gmail.com wrote: When I was reading The book of the new sun, though, I could stop and read a single sentence a few times over and reflect on it for a minute. Totally understandable, Wolfe is a far, far greater writer than Rowling :) Certainly true. On the other hand, I found it frustrating when I *had* to re-read a passage a couple of times to figure out what had just happened. :) ... Not that rereading books is necessarily a bad thing. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
AK andrei@gmail.com writes: On 09/19/2010 07:18 PM, Gregory Ewing wrote: AK wrote: Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. I've never understood why anyone would *want* to read a novel that fast, though. For me at least, reading a novel is something done for pleasure, so reading it at ten times normal speed would waste 90% of the benefit. One definite advantage would be that if, say, it takes you 70 pages of a given novel to figure out whether you like it enough to continue, you'd want to read those pages in 2 minutes rather than an hour. Heh, to me speed reading those 70 pages in a very short while, concluding that it's a good book, and start over again would be quite the spoiler. Do you fast forward movies as well? I do speed read but not the books I read for pleasure. -- John Bokma j3b Blog: http://johnbokma.com/Facebook: http://www.facebook.com/j.j.j.bokma Freelance Perl Python Development: http://castleamber.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and unicode
On Sep 19, 4:09 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: Goran Novosel goran.novo...@gmail.com writes: # vim: set encoding=utf-8 : This will help Vim, but won't help Python. Use the PEP 263 encoding declaration URL:http://www.python.org/dev/peps/pep-0263/ to let Python know the encoding of the program source file. That's funny because I went to PEP 263 and the line he used was listed there. Apparently, you're the one that needs to read PEP 263. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 2010-09-20, John Bokma j...@castleamber.com wrote: Heh, to me speed reading those 70 pages in a very short while, concluding that it's a good book, and start over again would be quite the spoiler. I rarely encounter substantive spoilers in the first 70 pages or so of a book. That said, I'm pretty much immune to spoilers; while I'm reading, I'm usually ignoring anything I might have previously known about a story, so it all works even if I've read it before. Do you fast forward movies as well? Amusingly, I can't generally watch movies at normal speed. They're too boring. Luckily, computers are finally advancing to a point where 1.2x faster, but no chipmunks is an available setting in some software. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: C++ - Python API
In article mailman.882.1284906611.29448.python-l...@python.org, Thomas Jollans tho...@jollybox.de wrote: On Sunday 19 September 2010, it occurred to Aahz to exclaim: In article mailman.334.1283373081.29448.python-l...@python.org, Thomas Jollans tho...@jollybox.de wrote: On Wednesday 01 September 2010, it occurred to Markus Kraus to exclaim: So the feature overview: First, the obligatory things you don't want to hear: Have you had a look at similar efforts? A while ago, Aahz posted something very similar on this very list. You should be able to find it in any of the archives without too much trouble. You almost certainly have me confused with someone else -- I wouldn't touch C++ with a ten-meter pole if I could possibly help it. (The last time I dealt with C++ code, about a decade ago, I just rewrote it in C.) Sorry about that. No biggie, just wanted to prevent further confusion. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
In article mailman.897.1284944085.29448.python-l...@python.org, Philip Semanchuk phi...@semanchuk.com wrote: Some email systems still insert hard line breaks around the 72 or 80 column mark and as a result long URLs get broken. I hope anyone on this list would be able to surgically repair a broken URL, but I email plenty of people who can't and tinyurl friends are really helpful in that context. There's no reason you can't cater to that problem by using tinyurl *in* *addition* to the full regular URL. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On Mon, 20 Sep 2010 11:18:57 +1200, Gregory Ewing wrote: AK wrote: Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. I've never understood why anyone would *want* to read a novel that fast, though. For me at least, reading a novel is something done for pleasure, so reading it at ten times normal speed would waste 90% of the benefit. Or reduce the pain by 90%, depending on the book... -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: SimpleHTTPServer, external CSS, and Google Chrome
On Sep 18, 2:54 am, MrJean1 mrje...@gmail.com wrote: FWIW, There is a blue text on a red background in all 4 browsers Google Chrome 6.0.472.59, Safari 5.0.1 (7533.17.8), FireFox 3.6.9 and IE 6.0.2900.5512 with Python 2.7 serving that page on my Windows XP SP 3 machine. /Jean Hmm. Will download and install newer python versions to re-check then. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and unicode
On Mon, 20 Sep 2010 09:09:31 +1000, Ben Finney wrote: Goran Novosel goran.novo...@gmail.com writes: # vim: set encoding=utf-8 : This will help Vim, but won't help Python. It will actually -- the regex Python uses to detect encoding lines is documented, and Vim-style declarations are allowed as are Emacs style. In fact, something as minimal as: # coding=utf-8 will do the job. Use the PEP 263 encoding declaration URL:http://www.python.org/dev/peps/pep-0263/ to let Python know the encoding of the program source file. While PEPs are valuable, once accepted or rejected they become historical documents. They don't necessarily document the current behaviour of the language. See here for documentation on encoding declarations: http://docs.python.org/reference/lexical_analysis.html#encoding-declarations -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
On Sun, 19 Sep 2010 06:16:49 -0700, Aahz wrote: Please don't use tinyurl -- it's opaque and provides zero help to anyone who might later want to look it up (and also no accessibility if tinyurl ever goes down). At the very least, include the original URL for reference. Do you have something against tinyurl in particular, or would any URL shortener service also get your ire? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
On 2010-09-20, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Sun, 19 Sep 2010 06:16:49 -0700, Aahz wrote: Please don't use tinyurl -- it's opaque and provides zero help to anyone who might later want to look it up (and also no accessibility if tinyurl ever goes down). At the very least, include the original URL for reference. Do you have something against tinyurl in particular, or would any URL shortener service also get your ire? I'd assume all of them have the same essential problems: * No hint as to what site you'll be getting redirected to. * No cues from URL as to what the link is to. * If the service ever goes away, the links become pure noise. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 09/19/2010 10:32 PM, John Bokma wrote: AKandrei@gmail.com writes: On 09/19/2010 07:18 PM, Gregory Ewing wrote: AK wrote: Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. I've never understood why anyone would *want* to read a novel that fast, though. For me at least, reading a novel is something done for pleasure, so reading it at ten times normal speed would waste 90% of the benefit. One definite advantage would be that if, say, it takes you 70 pages of a given novel to figure out whether you like it enough to continue, you'd want to read those pages in 2 minutes rather than an hour. Heh, to me speed reading those 70 pages in a very short while, concluding that it's a good book, and start over again would be quite the spoiler. Do you fast forward movies as well? I honestly doubt it would be a spoiler if it's a good book. Generally I find that poor books rely on twists and turns while better ones rely on the fabric of story-telling. Aside from that, though, it's a very interesting question - I'll try to think of good books and see if they'd be spoiled by peeking in the first 70 pages.. Starting with children's books, Peter Pan and Wind in the Willows, I think, would not be. Don quixote would not be. Crime and punishment - maybe if you get as far as the murder? Same author's the Devils, I would say you can read the last 70 pages and it'd be just as good :). -ak -- http://mail.python.org/mailman/listinfo/python-list
www.127760.blogspot.com
www.127760.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
AK andrei@gmail.com writes: On 09/19/2010 10:32 PM, John Bokma wrote: AKandrei@gmail.com writes: On 09/19/2010 07:18 PM, Gregory Ewing wrote: AK wrote: Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. I've never understood why anyone would *want* to read a novel that fast, though. For me at least, reading a novel is something done for pleasure, so reading it at ten times normal speed would waste 90% of the benefit. One definite advantage would be that if, say, it takes you 70 pages of a given novel to figure out whether you like it enough to continue, you'd want to read those pages in 2 minutes rather than an hour. Heh, to me speed reading those 70 pages in a very short while, concluding that it's a good book, and start over again would be quite the spoiler. Do you fast forward movies as well? I honestly doubt it would be a spoiler if it's a good book. Generally I find that poor books rely on twists and turns while better ones rely on the fabric of story-telling. Aside from that, though, it's a very interesting question - I'll try to think of good books and see if they'd be spoiled by peeking in the first 70 pages.. Starting with children's books, Peter Pan and Wind in the Willows, I think, would not be. Don quixote would not be. Crime and punishment - maybe if you get as far as the murder? Same author's the Devils, I would say you can read the last 70 pages and it'd be just as good :). -ak I didn't mean that there are spoilers in the first 70 pages, just that to me the excercise would spoil the book, so, I wouldn't do it. I consider a book like a meal, I wouldn't gobble down food, regurgitate it, and eat it again at a slower pace. Books, movies, family, walks are the things I prefer to do at a normal mudane pace, or even slower, if I can bring myself to it. My favourite books I try to read slow, and enjoy. ;-). Too much of my life is already in overdrive. -- John Bokma j3b Blog: http://johnbokma.com/Facebook: http://www.facebook.com/j.j.j.bokma Freelance Perl Python Development: http://castleamber.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
On 2010-09-20, Seebs usenet-nos...@seebs.net wrote: On 2010-09-20, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Sun, 19 Sep 2010 06:16:49 -0700, Aahz wrote: Please don't use tinyurl -- it's opaque and provides zero help to anyone who might later want to look it up (and also no accessibility if tinyurl ever goes down). At the very least, include the original URL for reference. Do you have something against tinyurl in particular, or would any URL shortener service also get your ire? I'd assume all of them have the same essential problems: * No hint as to what site you'll be getting redirected to. Tinyurl, in particular, allows you to preview the url if you choose to do so. Other URL shortning services have a similar feature. * No cues from URL as to what the link is to. Same point as above. Same solution. * If the service ever goes away, the links become pure noise. This happens a lot on the web anyway. Do you have any idea how many pieces of free software are first hosted on university servers to disappear when the author graduates/moves to another school or free shared host servers that have to be moved due to lack of scalability? Sourceforge solved much of this problem; but, then if sourceforge should ever disappear, all of its links will be pure noise as well. The simple fact is that the Internet changes. It changed before URL shortening services came into the mainstream and it will be true long after they have left. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too much code - slicing
On 2010-09-20, John Bokma j...@castleamber.com wrote: I didn't mean that there are spoilers in the first 70 pages, just that to me the excercise would spoil the book, so, I wouldn't do it. I consider a book like a meal, I wouldn't gobble down food, regurgitate it, and eat it again at a slower pace. Books, movies, family, walks are the things I prefer to do at a normal mudane pace, or even slower, if I can bring myself to it. My favourite books I try to read slow, and enjoy. ;-). Too much of my life is already in overdrive. Now that you explain it like this, that makes a fair bit of sense. I often wonder whether reading slowly would be more pleasant. I have no idea how to do it, so the question remains theoretical. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
On 2010-09-20, Tim Harig user...@ilthio.net wrote: On 2010-09-20, Seebs usenet-nos...@seebs.net wrote: * No hint as to what site you'll be getting redirected to. Tinyurl, in particular, allows you to preview the url if you choose to do so. Other URL shortning services have a similar feature. I have no idea how. If I see a tinyurl URL, and I paste it into a browser, last I tried it, I ended up on whatever page it redirected to. * No cues from URL as to what the link is to. Same point as above. Same solution. I'm not reading news in a web browser. I don't want to have to cut and paste and go look at a page in order to determine whether I want to switch to my browser. * If the service ever goes away, the links become pure noise. This happens a lot on the web anyway. True. Do you have any idea how many pieces of free software are first hosted on university servers to disappear when the author graduates/moves to another school or free shared host servers that have to be moved due to lack of scalability? Sourceforge solved much of this problem; but, then if sourceforge should ever disappear, all of its links will be pure noise as well. This is true. But two points of failure strikes me as worse than one. :) The simple fact is that the Internet changes. It changed before URL shortening services came into the mainstream and it will be true long after they have left. Oh, certainly. I'm not particularly convinced that these are *significant* complaints about URL-shorteners. But I will say, of the last couple hundred links I've followed from Usenet posts, precisely zero of them were through URL redirectors. If I can't at least look at the URL to get some initial impression of what it's a link to, I'm not going to the trouble of swapping to a web browser to find out. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: compiling python 3.1.2 with local readline fails to get readline - help!
On Sep 15, 6:41 pm, James Mills prolo...@shortcircuit.net.au wrote: On Thu, Sep 16, 2010 at 11:10 AM, gavino gavcom...@gmail.com wrote: I am comiling 3.1.2. I am not root but a user. I compiled readline and it did not complain. gdb and zlib and some other modules also were not found. Like I said earlier in my previous post, is the readline line that you compiled and installed to your home directory actually working and can you actually compile any C programs that use this custom readline ? cheers James -- -- James Mills -- -- Problems are solved by method I don't know how to test readline. It compiled without complaint. I guess my questions boils down to how to point the python compile to the readline lib? I don't have root. -- http://mail.python.org/mailman/listinfo/python-list
programming
I am in a computer science class in which I am supposed to be creating a program involving a sine wave and some other functions. I understand the concept of the problem, but I don't understand any of the lingo being used. The directions might as well be written in a different language. Is there anyone on here that might be able to help me in understanding what certain things mean? -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
On 2010-09-20, Seebs usenet-nos...@seebs.net wrote: On 2010-09-20, Tim Harig user...@ilthio.net wrote: On 2010-09-20, Seebs usenet-nos...@seebs.net wrote: * No hint as to what site you'll be getting redirected to. Tinyurl, in particular, allows you to preview the url if you choose to do so. Other URL shortning services have a similar feature. I have no idea how. If I see a tinyurl URL, and I paste it into a browser, last I tried it, I ended up on whatever page it redirected to. 1. Don't bother to manually paste when you can use something like urlview to lauch directly. 2. tinyurl addresses can be previewed by adding the preview subdomain to the tinyurl. For example, the address that started this subthread would become: http://preview.tinyurl.com/2eqqjxv If you want this behavior by default, you can easily wrap urlview to automatically add the prefix. * If the service ever goes away, the links become pure noise. This happens a lot on the web anyway. True. Do you have any idea how many pieces of free software are first hosted on university servers to disappear when the author graduates/moves to another school or free shared host servers that have to be moved due to lack of scalability? Sourceforge solved much of this problem; but, then if sourceforge should ever disappear, all of its links will be pure noise as well. This is true. But two points of failure strikes me as worse than one. :) I question first whether most tinyurl links are really of such an intransient nature that they need to be long lasting. I personally use them most when writing paper notes. They only need to last long enough for me, or whoever I made the note for, to get back to them. In theory, something like this adds the possibilty of adding another level of indirection; which could make the system more robust if used properly. Just think of how much resiliency is gained by using DNS, which can be redirected, as opposed to IP addresses which you cannot take with you if you move. This is academic as tinyurl addresses cannot be changed; but, it does point out that simple logic such as two points of failure must be worse then one isn't always correct. The simple fact is that the Internet changes. It changed before URL shortening services came into the mainstream and it will be true long after they have left. I'm not particularly convinced that these are *significant* complaints about URL-shorteners. But I will say, of the last couple hundred links I've followed from Usenet posts, precisely zero of them were through URL redirectors. If I can't at least look at the URL to get some initial impression of what it's a link to, I'm not going to the trouble of swapping to a web browser to find out. But why should the rest of us be penalized because you make the choice not to use (or not take full advantage of) all of the tools that are available to you? -- http://mail.python.org/mailman/listinfo/python-list
Re: programming
On Sun, Sep 19, 2010 at 10:46 PM, Jordan Blanton jeblan...@crimson.ua.edu wrote: I am in a computer science class in which I am supposed to be creating a program involving a sine wave and some other functions. I understand the concept of the problem, but I don't understand any of the lingo being used. The directions might as well be written in a different language. Is there anyone on here that might be able to help me in understanding what certain things mean? Yes. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
[issue8998] add crypto routines to stdlib
Gregory P. Smith g...@krypto.org added the comment: This bug has turned into a bikeshed. Lets stop that please. I _DON'T_ care about performance when it comes to someone submitting an actual working implementation of a crypto library for inclusion with the standard library. The first priority needs to be a useful stable API. After that is settled, implementations backed by whatever libraries can be written by anyone who wants to contribute them. Lets not stop that from happening by arguing about who's library is a prettier color. The first one may well be implemented in Python itself as a for all I care. -gps (comments below are to answer questions but really are not relevant to the bug) On Sat, Sep 18, 2010 at 3:54 PM, lorph rep...@bugs.python.org wrote: lorph lor...@gmail.com added the comment: OpenSSL outperforms libtomcrypt by a significant factor (easily 2x) in most cases. Gregory, do you have any evidence to substantiate this claim? Not that it isn't plausible, but I couldn't find any benchmarks, and here the author of libtomcrypt finds it to be 40% faster than OpenSSL concerning RSA operations. I should not have said most cases but there are many cases where it does. Run your own microbenchmarks on various hardware if you're curious (openssl speed algorithmname on the command line is an existing openssl benchmark). The important thing to realize is that libtomcrypt is intentionally written in very portable C. That is great but it leaves a lot on the table. Optimizations for various platforms to take advantage of enhanced instruction sets such as SSE2 and explicit hardware crypto acceleration instructions such as http://software.intel.com/en-us/articles/intel-advanced-encryption-standard-aes-instructions-set/are not likely to be part of libtomcrypt, nor should they ever be part of code included with and distributed as part of Python. That should come from a dynamic library that is part of the OS. That may be NSS, that may be OpenSSL, that may be any number of other things. Its beyond the scope of this bug. I'm sorry for bringing the performance angle up even if it motivate me to make hashlib happen. An example benchmark of hashlib using libtomcrypt sha1 vs openssl sha1 is here http://bugs.python.org/issue1121611#msg47779 if you're curious but please make any responses to that outside of this bug. -gps -- Added file: http://bugs.python.org/file18928/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8998 ___meta charset=utf-8divThis bug has turned into a bikeshed./divdivbr/divdivLets stop that please./divdivbr/divdivI _DON#39;T_ care about performance when it comes to someone submitting an actual working implementation of a crypto library for inclusion with the standard library.  The first priority needs to be a useful stable API./div divbr/divdivAfter that is settled, implementations backed by whatever libraries can be written by anyone who wants to contribute them.  Lets not stop that from happening by arguing about who#39;s library is a prettier color.  The first one may well be implemented in Python itself as a for all I care./div divbr/divdiv-gps/divdivbr/divdiv(comments below are to answer questions but really are not relevant to the bug)/divbrdiv class=gmail_quoteOn Sat, Sep 18, 2010 at 3:54 PM, lorph span dir=ltrlt;a href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;/span wrote:br blockquote class=gmail_quote style=margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;br lorph lt;a href=mailto:lor...@gmail.com;lor...@gmail.com/agt; added the comment:br div class=imbr gt; OpenSSL outperforms libtomcrypt by a significant factor (easily 2x) in most cases.br br /divGregory, do you have any evidence to substantiate this claim? Not that it isn#39;t plausible, but I couldn#39;t find any benchmarks, and here the author of libtomcrypt finds it to be 40% faster than OpenSSL concerning RSA operations.br /blockquotedivbr/divdivI should not have said quot;mostquot; cases but there are many cases where it does.  Run your own microbenchmarks on various hardware if you#39;re curious (quot;openssl speed algorithmnamequot; on the command line is an existing openssl benchmark).  The important thing to realize is that libtomcrypt is intentionally written in very portable C.  That is great but it leaves a lot on the table.  Optimizations for various platforms to take advantage of enhanced instruction sets such as SSE2 and explicit hardware crypto acceleration instructions such as a href=http://software.intel.com/en-us/articles/intel-advanced-encryption-standard-aes-instructions-set/;http://software.intel.com/en-us/articles/intel-advanced-encryption-standard-aes-instructions-set//a are not likely to be part of libtomcrypt, nor should they ever be part of code included with and distributed as part of Python. Â
[issue9884] The 4th parameter of method always None or 0 on x64 Windows.
Owen j2.n...@gmail.com added the comment: Note: This issue also occurs on other 64 bit windows OS(i.e. windows xp 64bit) Load testPy2.dll needs vc++ runtime library (http://download.microsoft.com/download/2/d/6/2d61c766-107b-409d-8fba-c39e61ca08e8/vcredist_x64.exe) Update testPy2.dll, use this to reproduce the issue. python code: import sys from ctypes import * windll.LoadLibrary(testPy2.dll) # def test3(param1,param2,param3,param4,param5,param6,param7,param8,param9,param10): print() print(param1) print(param2) print(param3) print(param4) print(param5) print(param6) print(param7) print(param8) print(param9) print(param10) print() return 20 C_METHOD_TYPE4 = WINFUNCTYPE(c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32) windll.testPy2.fntestPy7(9,C_METHOD_TYPE4(test3)) # def test4(param1,param2,param3,param4,param5,param6,param7,param8,param9,param10): print() print(param1) print(param2) print(param3) print(param4) print(param5) print(param6) print(param7) print(param8) print(param9) print(param10) print() return 20 C_METHOD_TYPE5 = WINFUNCTYPE(c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32) windll.testPy2.fntestPy8(10,C_METHOD_TYPE5(test4)) # def test5(param1,param2,param3,param4,param5,param6,param7,param8,param9,param10): print() print(param1) print(param2) print(param3) print(param4) print(param5) print(param6) print(param7) print(param8) print(param9) print(param10) print() return 20 C_METHOD_TYPE6 = WINFUNCTYPE(c_int32, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float) windll.testPy2.fntestPy9(11,C_METHOD_TYPE6(test5)) -- Added file: http://bugs.python.org/file18929/testPy2.dll ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9884 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9552] ssl build under Windows always rebuilds OpenSSL
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Thanks. I've committed in r84902(py3k). -- resolution: - fixed status: open - closed versions: +Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9552 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Daniel Urban urban.dani...@gmail.com added the comment: What is the use case for this? The basic idea was, that in Python almost everything is introspectable, so why range objects aren't. It was pretty straightforward to implement it, so I've done it (actually when I was working on rangeobject.c, I was surprised to see that these members aren't available from python code). But if this isn't needed, I'm absolutely ok with that. I think this would be a nice to have feature, but of course not necessary. Also, if it violates the moratorium (I don't know), then of course this sould be at least postponed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9897] multiprocessing problems
New submission from hume hume...@gmail.com: when use multiprocessing managers, while use socket to communicate between server process and client process, if I used the global socket timeout feature(no matter how large the value is) the client will always say File c:\python27\lib\multiprocessing\connection.py, line 149, in Client answer_challenge(c, authkey) File c:\python27\lib\multiprocessing\connection.py, line 383, in answer_challenge message = connection.recv_bytes(256) # reject large message IOError: [Errno 10035] this is not reasonable, because this behaviour will make subprocess unable to use socket's timeout features globally. Another question is line 138 in managers.py: # do authentication later self.listener = Listener(address=address, backlog=5) self.address = self.listener.address backlog=5 will accept only 5 cocurrent connections, this is not so user friendly, you'd better make this a argument that can be specified by user -- components: Library (Lib) messages: 116854 nosy: hume priority: normal severity: normal status: open title: multiprocessing problems versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2090] __import__ with fromlist=
Aaron Sterling aaronasterl...@gmail.com added the comment: FWIW, I also get this behavior on 2.6.5 and there are claims that it occurs on 2.6.4 and 3.1.1. see http://stackoverflow.com/questions/3745221/import-calls-init-py-twice/3745273#3745273 -- nosy: +Aaron.Sterling versions: +Python 2.6 -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2090 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8998] add crypto routines to stdlib
Georg Brandl ge...@python.org added the comment: The license clearly states: All advertising materials mentioning features or use of this software. Do you somehow disagree that base64 is a feature of the OpenSSL library? http://www.openssl.org/docs/crypto/BIO_f_base64.html That's funny. Do you think that if OpenSSL provided its own implementation of strlen(), every text that mentions strlen() needs to acknowledge OpenSSL? Do you realize how ridiculous that is? -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2090] __import__ with fromlist=
Changes by Aaron Sterling aaronasterl...@gmail.com: -- versions: +Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2090 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Mark Lawrence breamore...@yahoo.co.uk added the comment: Patch worked fine with 2.7. I reworked it for SVN trunk but got this failure. FAILED (failures=1) Traceback (most recent call last): File test_filecmp.py, line 179, in module test_main() File test_filecmp.py, line 176, in test_main support.run_unittest(FileCompareTestCase, DirCompareTestCase) File c:\py3k\lib\test\support.py, line 1128, in run_unittest _run_suite(suite) File c:\py3k\lib\test\support.py, line , in _run_suite raise TestFailed(err) test.support.TestFailed: Traceback (most recent call last): File test_filecmp.py, line 158, in test_dircmp_fnmatch self.assertEqual(d.left_list, ['file']) AssertionError: Lists differ: ['dir-ignore', 'file', 'file.t... != ['file'] First differing element 0: dir-ignore file First list contains 2 additional elements. First extra element 1: file - ['dir-ignore', 'file', 'file.tmp'] + ['file'] I've attached a py3k patch as a different pair of eyes is more likely to spot a problem. -- nosy: +BreamoreBoy Added file: http://bugs.python.org/file18930/issue1738py3k.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1738 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1744] readline module - set/get quote delimiters
Mark Lawrence breamore...@yahoo.co.uk added the comment: Can a committer review this please. Can't test it myself as I don't have a *NIX box, sorry. -- nosy: +BreamoreBoy stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1744 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1763] Winpath module - easy access to Windows directories like My Documents
Mark Lawrence breamore...@yahoo.co.uk added the comment: No reply to msg110596. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1763 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8998] add crypto routines to stdlib
Marc-Andre Lemburg m...@egenix.com added the comment: Just another data point for the discussion: The PSF is currently funding the effort to port pyOpenSSL to Python 3.x and the port is nearly finished. It may be worthwhile investigating adding the EVP interface from evpy (with the ctypes bindings converted to real C wrappers) to pyOpenSSL and then adding the pyOpenSSL package to the stdlib. Note that going for other crypto libs than OpenSSL is currently not an option, since those are not widely available on the OSes and we cannot easily add crypto code itself to Python's stdlib due to the issues with crypto import/export/use restrictions which would limit the use of Python in various countries. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1778] SyntaxError.offset sometimes wrong
Mark Lawrence breamore...@yahoo.co.uk added the comment: This will go nowhere until someone supplies a patch. I'm assuming unit tests can be built using the attached test file. -- nosy: +BreamoreBoy stage: unit test needed - needs patch versions: +Python 2.7, Python 3.2 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1778 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1783] nonexistent data items declared as exports in sysmodule.h
Mark Lawrence breamore...@yahoo.co.uk added the comment: The 1st declaration still exists, the 2nd has been removed. -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1783 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1785] inspect gets broken by some descriptors
Mark Lawrence breamore...@yahoo.co.uk added the comment: I can't apply the patch to any current SVN version. -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1785 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1794] Hot keys must work in any keyboard layout
Mark Lawrence breamore...@yahoo.co.uk added the comment: From msg86386 Nevertheless, after reading your comments I came to the conclusion that doing what you want is very unlikely to happen. so closing. -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1800] ctypes callback fails when called in Python with array argument
Mark Lawrence breamore...@yahoo.co.uk added the comment: Anybody? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1800 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1827] svnversion_init() doesn't support svn urls in sandbox/trunk
Mark Lawrence breamore...@yahoo.co.uk added the comment: Is this ever likely to happen given the switch to Mercurial, or is that a different scenario to this? -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1838] Ctypes C-level infinite recursion
Mark Lawrence breamore...@yahoo.co.uk added the comment: I'm not convinced that this needs doing, so I'll close in a couple of weeks unless anyone objects. -- nosy: +BreamoreBoy status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1838 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9786] Native TLS support for pthreads
Antoine Pitrou pit...@free.fr added the comment: Patch looks good to me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9786 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8998] add crypto routines to stdlib
Antoine Pitrou pit...@free.fr added the comment: It may be worthwhile investigating adding the EVP interface from evpy (with the ctypes bindings converted to real C wrappers) to pyOpenSSL and then adding the pyOpenSSL package to the stdlib. pyOpenSSL being LGPL'ed, I'm not sure this is possible. On the other hand, gradually adding some of pyOpenSSL's most useful functionalities to the ssl module would be worthwhile, and I know Jean-Paul would be interested in this. This has already begun in 3.2, but I've been alone in doing it and it would be nice if other people contributed: http://docs.python.org/dev/library/ssl.html#ssl-contexts -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com