Re: Python for philosophers
On 2013-05-13, Steven D'Aprano wrote: > Your premise that Python tries to be "economical" is incorrect. If > anything, Python is the opposite: it is often profligate with resources > (memory mostly) in order to save the human programmer time and effort. IOW, Python is designed to be economical, but the resource of concern is not computer memory, it's the programmer's time/effort. Computer memory gets cheaper every year. My time gets more valuable every year (hopefully). -- Grant Edwards grant.b.edwardsYow! The entire CHINESE at WOMEN'S VOLLEYBALL TEAM all gmail.comshare ONE personality -- and have since BIRTH!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Fractal
On 2013-05-13, Sharon COUKA wrote: > Hello, I'm new to python and i have to make a Mandelbrot fractal image for > school but I don't know how to zoom in my image. > Thank you for helping me. It's a fractal image, so you zoom in/out with the following Python instruction: pass ;) -- Grant Edwards grant.b.edwardsYow! I'm not available at for comment.. gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Python for philosophers
On 2013-05-14, Citizen Kant wrote: > 2013/5/14 Steven D'Aprano > >> On Tue, 14 May 2013 01:32:43 +0200, Citizen Kant wrote: >> >> >> An entity named Python must be somehow as a serpent. Don't forget that >> >> I'm with the freeing up of my memory, now I'm not trying to follow the >> >> path of what's told but acting like the monkey and pushing with my >> >> finger against the skin of the snake. >> >> >Python is not named after the snake, but after Monty Python the British >> >comedy troupe. And they picked their name because it sounded funny. >> >> > http://en.wikipedia.org/wiki/Monty_Python<http://en.wikipedia.org/wiki/Monty_Python> >> >> I'm sorry to hear that. Mostly because, as an answer, seems to example >> very well the "taken because I've been told how things are" kind of >> actions, which is exactly the opposite of the point I'm trying to state. Firstly, watch your quoting, Steve D'Aprano didn't write that despite your claim that he did. Secondly, if a the person who named something tells you they named it after A rather than B, what are you going to do other than "taken because I've been told". Are you claiming Guido lied about the source of the name? -- Grant Edwards grant.b.edwardsYow! My life is a patio at of fun! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for philosophers
On 2013-05-16, Tim Daneliuk wrote: > On 05/15/2013 08:01 PM, Ned Batchelder wrote: >> On 5/11/2013 4:03 PM, Citizen Kant wrote: >>> Don't get me wrong. I can see the big picture and the amazing things that >>> programmers write on Python, it's just that my question points to the >>> lowest level of it's existence. >> >> Sometimes a cigar is just a cigar. Python is a tool, it does what you tell >> it. To make an analogy, or maybe to clarify your philosophical view of the >> world, consider a hammer. What is the "lowest level of its existence"? >> >> --Ned. > > All You People are making this way too hard. To understand how > questions like the OPs ought be resolved, please read: > > http://pvspade.com/Sartre/cookbook.html Yea, I've decided we're being trolled... -- Grant Edwards grant.b.edwardsYow! I'd like MY data-base at JULIENNED and stir-fried! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Future standard GUI library
On 2013-05-20, Terry Jan Reedy wrote: > On 5/20/2013 1:04 AM, Vito De Tullio wrote: >> Terry Jan Reedy wrote: >> >>>> Do you think tkinter is going to be the standard python built-in gui >>>> solution as long as python exists? >>> >>> AT the moment, there is nothing really comparable that is a realistic >>> candidate to replace tkinter. >> >> FLTK? (http://www.fltk.org/index.php) > > tkinter is the Python wrapper of the tk library, just as wxpython is > the python wrapper of the wx library. I do not see a py-fltk wrapper. http://pyfltk.sourceforge.net/ -- Grant Edwards grant.b.edwardsYow! Is it 1974? What's at for SUPPER? Can I spend gmail.commy COLLEGE FUND in one wild afternoon?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Diagnosing socket "Connection reset by peer"
On 2013-05-22, Jorgen Grahn wrote: > On Wed, 2013-05-22, Dave Angel wrote: >> On 05/22/2013 04:46 AM, loial wrote: >>> >>> >>> Is there any additional traceing I can do(either within my >>> python code or on the network) to establish what is causing this >>> error? >> >> Try using Wireshark. It can do a remarkable job of filtering, >> capturing, and analyzing packets. It can also read and write pcap >> files, which you could either save for later analysis, or send to >> someone who might help. > > Or use tcpdump, which has a text interface so you can show the problem > in a text medium like Usenet. There's also tshark, which is sort of a command-line version of wireshark. http://www.wireshark.org/docs/man-pages/tshark.html >> (Note - unfiltered pcap files can be very large on a busy network, >> but if you can quiet other traffic, you may not need to filter at >> all.) > > Or simply filter. It's not hard -- the capture filter "host > my-printer-hostname-or-address" is enough. Indeed. Even a simple filter can make life several orders of magnitude easier. If filtering by IP address isn't enough, the next step is usually to add a port number filter... -- Grant Edwards grant.b.edwardsYow! Of course, you at UNDERSTAND about the PLAIDS gmail.comin the SPIN CYCLE -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Future standard GUI library
On 2013-05-23, Wolfgang Keller wrote: >> But there's another option that is available to every platform and >> (practially) every high level language: the web browser. Make your app >> serve HTTP and do up your UI in HTML5/CSS3 - your facilities are >> pretty extensive. Plus you get networking support for free! Obviously >> this option isn't for everyone, but don't discount it out of hand. > > Both the concept and actually implemented examples of so-called "web > applications" prove that they are just plain garbage and hopelessly > unusable for anything remotely resembling actual screenwork. What is "screenwork"? -- Grant Edwards grant.b.edwardsYow! Am I elected yet? at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Text-to-Sound or Vice Versa (Method NOT the source code)
On 2013-05-25, Rakshith Nayak wrote: > Always wondered how sound is generated from text. Googling couldn't > help. Devs having knowledge about this could provide, the > information, Links, URLs or anything that could help. > > http://www.cstr.ed.ac.uk/projects/festival/ http://code.google.com/p/pyfestival/ http://machakux.appspot.com/blog/44003/making_speech_with_python -- Grant Edwards grant.b.edwardsYow! at BI-BI-BI-BI-BI-BI gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Short-circuit Logic
On 2013-05-28, Steven D'Aprano wrote: > On Tue, 28 May 2013 01:39:09 -0700, Ahmed Abdulshafy wrote: > >> He just said that the way to test for zero equality is x == 0, and I >> meant that this is true for integers but not necessarily for floats. And >> that's not specific to Python. > > Can you show me a value of x where x == 0.0 returns False, but x actually > isn't zero? I'm confused. Don't all non-zero values satisfy your conditions? >>> x = 1.0 >>> x == 0.0 False >>> x is 0.0 False -- Grant Edwards grant.b.edwardsYow! I'm dressing up in at an ill-fitting IVY-LEAGUE gmail.comSUIT!! Too late... -- http://mail.python.org/mailman/listinfo/python-list
Re: Output from to_bytes
On 2013-05-26, Mok-Kong Shen wrote: > I don't understand why with the code: > > for k in range(8,12,1): > print(k.to_bytes(2,byteorder='big')) > > one gets the following output: > > b'\x00\x08' > b'\x00\t' > b'\x00\n' > b'\x00\x0b' > > I mean the 2nd and 3rd should be b'\x00\x09' and b'x00\x0a'. > Anyway, how could I get the output in the forms I want? Well, it would help if you told us what output form you want. -- Grant Edwards grant.b.edwardsYow! I'm gliding over a at NUCLEAR WASTE DUMP near gmail.comATLANTA, Georgia!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Future standard GUI library
On 2013-05-26, Roy Smith wrote: > Michael Torrie wrote: > >> On good thing web development has brought us is the knowledge that >> modularization and layers are a brilliant idea. > > Modularization and layers were a brilliant idea long before the web came > around. Once again USENET proves to be an unsuitable RPC protocol for implementing irony. :) [OTOH, perhaps Micheal wasn't being ironic...] -- Grant Edwards grant.b.edwardsYow! Am I having fun yet? at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: how to compare two json file line by line using python?
On 2013-05-27, Steven D'Aprano wrote: > On Sun, 26 May 2013 21:32:40 -0700, Avnesh Shakya wrote: > >> But I want to compare line by line and value by value. but i found that >> json data is unordered data, so how can i compare them without sorting >> it. please give me some idea about it. I am new for it. I want to check >> every value line by line. > > Why do you care about checking every value line by line? As you say > yourself, JSON data is unordered, so "line by line" is the wrong way to > compare it. There's no such thing as "lines" in JSON anyway. Outside of string literals, all whitespace is equivalent, so replacing all newlines with space characters results in equivalent blobs of JSON -- but one is a single line, and the other is multiple lines. > The right way is to decode the JSON data, and then compare whether it > gives you the result you expect: > > a = json.load("file-a") > b = json.load("file-b") > if a == b: > print("file-a and file-b contain the same JSON data") > > If what you care about is the *data* stored in the JSON file, this is > the correct way to check it. Yup. -- Grant Edwards grant.b.edwardsYow! Are we laid back yet? at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Making safe file names
On 2013-05-28, Albert van der Horst wrote: >> There's also the Windows device name hole. There may be trouble with >> artists named 'COM4', 'CLOCK$', 'Con', or similar. >> >>http://support.microsoft.com/kb/74496 > > That applies to MS-DOS names. God forbid that this still holds on > more modern Microsoft operating systems? There are no more modern Microsoft operating systems. Only more recent ones. There are still lots of reserved filenames in recent versions of Windows. -- Grant Edwards grant.b.edwardsYow! I've got an IDEA!! at Why don't I STARE at you gmail.comso HARD, you forget your SOCIAL SECURITY NUMBER!! -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get an integer from a sequence of bytes
On 2013-05-27, Mok-Kong Shen wrote: > From an int one can use to_bytes to get its individual bytes, > but how can one reconstruct the int from the sequence of bytes? One way is using the struct module. -- Grant Edwards grant.b.edwardsYow! Uh-oh!! I forgot at to submit to COMPULSORY gmail.comURINALYSIS! -- http://mail.python.org/mailman/listinfo/python-list
Re: Future standard GUI library
On 2013-05-28, Wolfgang Keller wrote: > Actually productive work of significant intensity at a computer screen. Oh. You mean emacs. -- Grant Edwards grant.b.edwardsYow! Will it improve my at CASH FLOW? gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python #ifdef
On 2013-05-28, Carlos Nepomuceno wrote: > Thank you! I made it run like the following. What do you think about > that? IS there a better way? > > #The following runs on Python 2.7 > sc3=''' > # Python 3 > def original(n): > ??? m = 0 > ??? for b in n.to_bytes(6, 'big'): > ??? m = 256*m + b > ??? return m > ''' > if sys.version_info[0] == 3: > ??? exec(sc3) You're trying to make this a lot harder than it really is: if sys.version_info[0] == 3: def original(n): m = 0 for b in n.to_bytes(6, 'big'): m = 256*m + b return m else: def original(n): -- Grant Edwards grant.b.edwardsYow! Am I having fun yet? at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python #ifdef
On 2013-05-28, Carlos Nepomuceno wrote: > [...] >> You're trying to make this a lot harder than it really is: >> >> if sys.version_info[0] == 3: >> def original(n): >> m = 0 >> for b in n.to_bytes(6, 'big'): >> m = 256*m + b >> return m >> else: >> def original(n): >> > > Haha! That's it!!! > > Just realized how funny this can be: ;) Here's the important lesson from this thread: Instead of asking "how do I write X in Python" where yoy've assumed X is the solution to your problem, you're usually better off asking how to solve the underlying problem in a Pythonic way. IOW, instead of asking about a Python preprocessor (which you have assumed is the solution to the problem because that's how you would do it in C), ask about the actual problem (how to define a function differently depending on Python version). People on this list are very inventive and will expend a surprising amount of time to figure out often too-clever ways to do X because you asked how to do X -- even if doing X is a lousy way to solve your actual problem... When asking how do I solve a problem, it's OK to illustrate that question with an example X of how you would solve it in C or Java or Ruby or Perl or whatever, but remember 1) Not everybody here knows C or Java or Ruby or Perl or whatever, and the person who _does_ know everyting there is to know about solving some particular underlying problem isn't going to go learn a new language so that they can understand your example and figure out what you're trying to accomplish. 2) Programming languages differ. X may be the best way to solve the problem in one language, but it might be an awful way to do it in another language. -- Grant Edwards grant.b.edwardsYow! I'm ANN LANDERS!! at I can SHOPLIFT!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python #ifdef
On 2013-05-28, Carlos Nepomuceno wrote: > How do you have "invalid@invalid.invalid" instead of your email address? I have this in my .slrnrc: set hostname "invalid.invalid" set username "grant" set realname "Grant Edwards" I'm not sure why it doesn't show up as grant@invalid.invalid -- I think it used to. Since I'm this as a Usenet news group using the slrn newsreader program, there's no need to make my email address visible in the message headers in a usable form. I originally did this long ago (probably 20 years) to avoid spam. I'm pretty sure that it's all in vain these days, and the spam filters at Google are what's keeping me from drowning. -- Grant Edwards grant.b.edwardsYow! Gee, I feel kind of at LIGHT in the head now, gmail.comknowing I can't make my satellite dish PAYMENTS! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python #ifdef
On 2013-05-29, Dan Stromberg wrote: > And in case you still want a preprocessor for Python (you likely don't need > one this time), here's an example of doing this using the venerable m4: > https://pypi.python.org/pypi/red-black-tree-mod . Note the many comments > added to keep line numbers consistent. I was wondering whether or not to mention m4. Since m4 is (in my mind) inextricably linked to RATFOR and sendmail config files I try to avoid thinking about it lest the flashbacks start again... -- Grant Edwards grant.b.edwardsYow! Hmmm ... a CRIPPLED at ACCOUNTANT with a FALAFEL gmail.comsandwich is HIT by a TROLLEY-CAR ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Python #ifdef
On 2013-05-29, Chris Angelico wrote: > On Thu, May 30, 2013 at 12:55 AM, Grant Edwards > wrote: >> On 2013-05-29, Dan Stromberg wrote: >> >>> And in case you still want a preprocessor for Python (you likely don't need >>> one this time), here's an example of doing this using the venerable m4: >>> https://pypi.python.org/pypi/red-black-tree-mod . Note the many comments >>> added to keep line numbers consistent. >> >> I was wondering whether or not to mention m4. Since m4 is (in my >> mind) inextricably linked to RATFOR and sendmail config files I try >> to avoid thinking about it lest the flashbacks start again... > > It's not a bad tool. I used it as a sort of PHP preprocessor, > [...] > But still, GNU M4 is a decent piece of technology. I didn't mean to disparage m4 -- it always seemed well thought out and useful. It just happens to be associated with unpleasant things for me. [And it didn't really seem like a good option for the OP's problem.] Still, if one really did want a preprocessor for Python programs, m4 would be the first thing I'd look at. -- Grant Edwards grant.b.edwardsYow! I wonder if I ought at to tell them about my gmail.comPREVIOUS LIFE as a COMPLETE STRANGER? -- http://mail.python.org/mailman/listinfo/python-list
Re: The state of pySerial
On 2013-05-29, Ma Xiaojun wrote: > pySerial is probably "the solution" for serial port programming. > Physical serial port is dead on PC but USB-to-Serial give it a second > life. Serial port stuff won't interest end users at all. But it is > still used in the EE world and so on. Arduino uses it to upload > programs. Sensors may use serial port to communicate with PC. GSM > Modem also uses serial port to communicate with PC. > > Unforunately, pySerial project doesn't seem to have a good state. I > find pySerial + Python 3.3 broken on my machine (Python 2.7 is OK) . > There are unanswered outstanding bugs, PyPI page has 2.6 while SF > homepage still gives 2.5. > > Any idea? Volunteer as a maintainer and start fixing bugs? I use pyserial regularly, and the current version works fine for me, but I'm using Python 2.7. There are still too many libraries that don't support 3.x for me to consider using 3.x for real work. -- Grant Edwards grant.b.edwardsYow! They collapsed at ... like nuns in the gmail.comstreet ... they had no teen appeal! -- http://mail.python.org/mailman/listinfo/python-list
Re: The state of pySerial
On 2013-05-29, Terry Jan Reedy wrote: > On 5/29/2013 3:47 PM, Grant Edwards wrote: >> On 2013-05-29, Ma Xiaojun wrote: [...] >>> Unforunately, pySerial project doesn't seem to have a good state. I >>> find pySerial + Python 3.3 broken on my machine (Python 2.7 is OK) . >>> There are unanswered outstanding bugs, PyPI page has 2.6 while SF >>> homepage still gives 2.5. >>> >>> Any idea? >> >> Volunteer as a maintainer and start fixing bugs? > > It seems to be getting around 200 downloands a day. Quite worth > someone supporting it. Chris has a day job, just like the rest of us. He might even have a family and hobbies other than supporting pyserial. ;) Everybody should feel free to submit patches for open bugs and to test any patches waiting to be accepted. >> I use pyserial regularly, and the current version works fine for me, >> but I'm using Python 2.7. There are still too many libraries that >> don't support 3.x for me to consider using 3.x for real work. > > The only download is a .exe. It it just the executable binary or is that > a zip unpacker with source? http://pyserial.sourceforge.net/pyserial.html#from-source-tar-gz-or-checkout https://pypi.python.org/packages/source/p/pyserial/pyserial-2.6.tar.gz#md5=cde799970b7c1ce1f7d6e9ceebe64c98 -- Grant -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get an integer from a sequence of bytes
On 2013-06-03, Dennis Lee Bieber wrote: > On Sun, 02 Jun 2013 21:25:45 +0200, Mok-Kong Shen > declaimed the following in > gmane.comp.python.general: > > >> b'7' is the byte with the character 7 in a certain code, so that's >> ok. In other PLs one assigns an int to a byte, with that int in either > > In other languages "byte" is an 8-bit signed/unsigned numeric. That's a common assumption, but historically, a "byte" was merely the smallest addressable unit of memory. The size of a "byte" on widely used used CPUs ranged from 4 bits to 60 bits. Quoting from http://en.wikipedia.org/wiki/Byte "The size of the byte has historically been hardware dependent and no definitive standards existed that mandated the size." That's why IEEE standards always use the word "octet" when referring a value containing 8 bits. Only recently has it become common to assume that an "byte" contains 8 bits. -- Grant Edwards grant.b.edwardsYow! It's a lot of fun at being alive ... I wonder if gmail.commy bed is made?!? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get an integer from a sequence of bytes
On 2013-06-03, Dave Angel wrote: > On 06/03/2013 10:31 AM, Grant Edwards wrote: >> On 2013-06-03, Dennis Lee Bieber wrote: >>> On Sun, 02 Jun 2013 21:25:45 +0200, Mok-Kong Shen >>> declaimed the following in >>> gmane.comp.python.general: >>> >>> >>>> b'7' is the byte with the character 7 in a certain code, so that's >>>> ok. In other PLs one assigns an int to a byte, with that int in either >>> >>> In other languages "byte" is an 8-bit signed/unsigned numeric. >> >> That's a common assumption, but historically, a "byte" was merely the >> smallest addressable unit of memory. The size of a "byte" on widely >> used used CPUs ranged from 4 bits to 60 bits. >> > > I recall rewriting the unpacking algorithm to get the 10 > characters from each byte, on such a machine. Yep. IIRC there were CDC machines (Cyber 6600?) with a 60-bit wide "byte" and a 6-bit wide upper-case-only character set. ISTM that the Pascal compiler limited you to 6 significant characters in variable names so that it could use a simple single register compare while doing symbol lookups... I think some IBM machines had 60-bit "bytes" as well. -- Grant Edwards grant.b.edwardsYow! DIDI ... is that a at MARTIAN name, or, are we gmail.comin ISRAEL? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get an integer from a sequence of bytes
On 2013-06-03, Dan Stromberg wrote: > On Mon, Jun 3, 2013 at 7:31 AM, Grant Edwards wrote: > >> That's a common assumption, but historically, a "byte" was merely the >> smallest addressable unit of memory. The size of a "byte" on widely >> used used CPUs ranged from 4 bits to 60 bits. >> >> Quoting from http://en.wikipedia.org/wiki/Byte >> >> "The size of the byte has historically been hardware >> dependent and no definitive standards existed that mandated the >> size." >> >> That's why IEEE standards always use the word "octet" when referring a >> value containing 8 bits. > > When I was a Freshman in college, I used a CDC Cyber a lot; it had 6 bit > bytes and 60 bit words. This was in 1985. But you couldn't address individual 6-bit "hextets" in memory could you? My recollection is that incrementing a memory address got you the next 60-bit chunk -- that means that by the older terminology a "byte" was 60 bits. A "character" was 6 bits, and a single register or memory location could hold 6 characters. > Today though, it would be difficult to sell a conventional (Von Neumann) > computer that didn't have 8 bit bytes. There are tons (as in millions of units per month) of CPUs still being sold in the DSP market with 16, 20, 24, and 32 bit "bytes". (When writing C on a TMS320Cxx CPU sizeof (char) == sizeof (int) == sizeof (long) == sizeof (float) == sizeof (double) == 1. They all contain 32 bits. > Quantum computers would still sell if they were odd this way - > they're going to be really different anyway. -- Grant Edwards grant.b.edwardsYow! Either CONFESS now or at we go to "PEOPLE'S COURT"!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get an integer from a sequence of bytes
On 2013-06-03, Carlos Nepomuceno wrote: > >> Date: Mon, 3 Jun 2013 15:41:41 -0700 >> Subject: Re: How to get an integer from a sequence of bytes >> From: drsali...@gmail.com >> To: python-list@python.org > [...] >> Today though, it would be difficult to sell a conventional (Von >> Neumann) computer that didn't have 8 bit bytes. Quantum computers >> would still sell if they were odd this way - they're going to be really >> different anyway. > > Nowadays it would be a hard task to find a Von Neumann architecture > machine. > > Most of current CPUs are variants of the Harvard architecture: they > separate instructions from data at the cache level. VN designs are still very common in smaller CPUs (embedded stuff). Even modern desktop CPUs are "logically" still Von Neumann designs from the programmer's point of view (there's only a single address space for both data and instructions). The fact that there are two sparate caches is almost entirely hidden from the user. If you start to do stuff like write self-modifying code, then _may_ start having to worry about cache coherency. -- Grant Edwards grant.b.edwardsYow! I request a weekend in at Havana with Phil Silvers! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Bools and explicitness [was Re: PyWart: The problem with "print"]
On 2013-06-06, Chris Angelico wrote: > Would you say that doubling the testing period is a good thing or a > bad thing? It could be a neutral thing (ignoring the costs involved). I once read read an article claiming that as you test (and fix) any large, complex piece of software, you asymptotically approach a certain fixed "minimum number of bugs" that's determined by the system's overall architecture, design and implentation. Once you get sufficiently close to that minimum, additional testing doesn't reduce the number/severity of bugs -- it just "moves them around" by creating additional bugs at the same rate you are eliminating old ones. When you get to that point, the only way to significantly improve the situation is to toss the whole thing out and start over with a better system architecture and/or development model. After having maintined a few largish pieces of software for well over a decade, I'm fairly convinced that's true -- especially if you also consider post-deployment maintenance (since at that point you're usually also trying to add features at the same time you're fixing bugs). -- Grant Edwards grant.b.edwardsYow! I just went below the at poverty line! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Popen and reading stdout in windows
On 2013-06-10, Joseph L. Casale wrote: > I have a use where writing an interim file is not convenient and I > was hoping to iterate through maybe 100k lines of output by a process > as its generated or roughly anyways. > > Seems to be a common question on ST, and more easily solved in Linux. > Anyone currently doing this with Python 2.7 in windows and can share > some guidance? http://docs.python.org/2/library/subprocess.html -- Grant Edwards grant.b.edwardsYow! All of life is a blur at of Republicans and meat! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: question regarding references and class relationships
On 2013-06-10, Terry Jan Reedy wrote: > Another principle similar to 'Don't add extraneous code' is 'Don't > rebind builtins'. OK, we've all done it by accident (especially when starting out), but are there people that rebind builtins intentionally? -- Grant Edwards grant.b.edwardsYow! FROZEN ENTREES may at be flung by members of gmail.comopposing SWANSON SECTS ... -- http://mail.python.org/mailman/listinfo/python-list
Re: "Don't rebind built-in names*" - it confuses readers
On 2013-06-11, Mark Janssen wrote: >>> list = [] >>> Reading further, one sees that the function works with two lists, a list of >>> file names, unfortunately called 'list', >> >> That is very good advice in general: never choose a variable name >> that is a keyword. > > Btw, shouldn't it be illegal anyway? Most compilers don't let you do > use a keyword as a variable name We're not talking about keywords. We're talking about built-ins -- which are just global symbols that are pre-imported for your shopping convenience. Other than the fact that they're pre-imported for you, they're no different than symbols imported from any other module. -- Grant Edwards grant.b.edwardsYow! Could I have a drug at overdose? gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: "Don't rebind built-in names*" - it confuses readers
On 2013-06-11, Mark Janssen wrote: >> list = [] >> Reading further, one sees that the function works with two lists, a list of >> file names, unfortunately called 'list', > > That is very good advice in general: never choose a variable name > that is a keyword. You can't choose a vriable name that is a keyword: the compiler won't allow it. "list" isn't a keyword. -- Grant Edwards grant.b.edwardsYow! Maybe I should have at asked for my Neutron Bomb gmail.comin PAISLEY -- -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get an integer from a sequence of bytes
On 2013-06-12, F?bio Santos wrote: > On 5 Jun 2013 06:23, "Tim Roberts" wrote: >> A single machine word was 60 bits, so a single register read got you 10 >> characters. > > 10 characters! Now that sounds like it's enough to actually store a word. > However long words can inadverten be cropped. Only the first 10 characters in variable names were significant when you wrote Pascal programs (I don't remember if that was true for FORTRAN, but I bet it was). -- Grant Edwards grant.b.edwardsYow! I'm gliding over a at NUCLEAR WASTE DUMP near gmail.comATLANTA, Georgia!! -- http://mail.python.org/mailman/listinfo/python-list
Re: A certainl part of an if() structure never gets executed.
On 2013-06-12, Tim Roberts wrote: > ?? wrote: >> >>[code] >> if not re.search( '=', name ) and not re.search( '=', month ) >> and not re.search( '=', year ): >> cur.execute( '''SELECT * FROM works WHERE clientsID = >> (SELECT id FROM clients WHERE name = %s) and MONTH(lastvisit) = %s and >> YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (name, month, year) ) >> elif not re.search( '=', month ) and not re.search( '=', year ): >> cur.execute( '''SELECT * FROM works WHERE >> MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', >> (month, year) ) >> elif not re.search( '=', year ): >> cur.execute( '''SELECT * FROM works WHERE >> YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', year ) > > There is so much you didn't tell us here, including which database you are > using. Are you guys _still_ on Nikos hook? [No, I don't really think he's trolling, but it would be really impressive if he were.] Anyway, I salute your patience. -- Grant Edwards grant.b.edwardsYow! ... I'm IMAGINING a at sensuous GIRAFFE, CAVORTING gmail.comin the BACK ROOM of a KOSHER DELI -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Version Control Software
On 2013-06-13, Ben Finney wrote: > cutems93 writes: > >> I am looking for an appropriate version control software for python >> development, and need professionals' help to make a good decision. > >> Currently I am considering four software: git, SVN, CVS, and >> Mercurial. > > These days there is no good reason to use CVS nor Subversion for new > projects. They are not distributed (the D in DVCS), and they have > specific design flaws that often cause insidious problems with common > version control workflows. As a salient example, branching and merging > are so painful with these tools that many users have learned the > terrible habit of never doing it at all. I agree that branch/merge handling in svn is primitive compared to git (haven't used hg enough to comment). The last time we made the choice (4-5 years ago), Windows support for get, bzr, and hg was definitely lacking compared to svn. The lack of something like tortoisesvn for hg/git/bzr was a killer. It looks like the situation has improved since then, but I'd be curious to hear from people who do their development on Windows. -- Grant Edwards grant.b.edwardsYow! I wonder if there's at anything GOOD on tonight? gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Turnign greek-iso filenames => utf-8 iso
On 2013-06-13, wrote: > On 13/6/2013 5:16 , Zero Piraeus wrote: >> : >> >>> Steven, i can create a normal user account for you and copy files.py into >>> your home folder if you want to take a look from within. >> >> Nikos, please, DO NOT DO THIS. >> >> It must be clear to you that Steven is *much* more experienced than >> you. Your presumptions about what he can and can't do with the access >> you give him are therefore not much more than uninformed guesswork. > > But iam not offering Steven full root access, but restricted user > level access. That's what you _think_ you're offering. Unless you're are a very careful, very experienced system admin -- and you're also lucky -- you're probably wrong. If not now, then you'll be wrong next week or next month when a new privelege elevation exploit is discovered for your OS. > Are you implying that for example one could elevate his privileges to > root level access form within a normal restricted user account? Yes, that's what he's implying. -- Grant Edwards grant.b.edwardsYow! I'm thinking about at DIGITAL READ-OUT systems gmail.comand computer-generated IMAGE FORMATIONS ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Turnign greek-iso filenames => utf-8 iso
On 2013-06-13, wrote: > On 13/6/2013 8:27 , Zero Piraeus wrote: > >> Then you need to contract with paid, professional support to solve >> your problems. > > Or receive some free help, to solve this single detail i'am missing. "single detail I am missing" Seriously? -- Grant Edwards grant.b.edwardsYow! What I want to find at out is -- do parrots know gmail.commuch about Astro-Turf? -- http://mail.python.org/mailman/listinfo/python-list
Re: Wrong website loaded when other requested
On 2013-06-13, Nick the Gr33k wrote: > On 13/6/2013 9:37 , Andreas Perstinger wrote: >> On 13.06.2013 20:10, Nick the Gr33k wrote: >> [nothing new] >> >> Could you please stop spamming the whole internet with your problems. >> Not only that you've posted two similar offtopic messages within only 6 >> minutes to this list, you've also crossposted to alt.os.linux (where it >> is offtopic too) and to the forum at devshed.com (at least you've found >> the right subforum there). >> >> Thank you very much! > > Andrea i need to fix this my friend. Then shut up, stop bothering us, and fix it. -- Grant Edwards grant.b.edwardsYow! I'm into SOFTWARE! at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Version Control Software
On 2013-06-13, Chris Angelico wrote: > On Fri, Jun 14, 2013 at 3:06 AM, Grant Edwards > wrote: > >> The last time we made the choice (4-5 years ago), Windows support for >> get, bzr, and hg was definitely lacking compared to svn. The lack of >> something like tortoisesvn for hg/git/bzr was a killer. It looks like >> the situation has improved since then, but I'd be curious to hear from >> people who do their development on Windows. > > I do almost exclusively Linux dev, but occasionally nip onto Windows > for one reason or another (possibly inside a virtual machine). It's > possible to get git for Windows, including gitk and 'git gui' (not > sure about any other graphical tools, they're the only two I use), but > the most convenient way to use them is from a ported bash. > Fortunately, the installer will provide all of that, putting a 'Git > Bash' entry into the Start menu, and for someone who's come from Linux > anyway, working in bash is quite welcome. Unfortunately, something that requires typing commands would not fly. I mostly use svn via command line and sometimes via meld, but for some others (even one Linux developer), if it can't be done done entirely from a GUI, then it isn't going to get done. If it wasn't for Cygwin, I'd never be able to accomplish much of anything in Windows. :) -- Grant Edwards grant.b.edwardsYow! Oh my GOD -- the at SUN just fell into YANKEE gmail.comSTADIUM!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Version Control Software
On 2013-06-14, Roy Smith wrote: > All that being said, it is, as Anssi points out, a horrible, bloated, > overpriced, complicated mess which requires teams of specially > trained ClearCase admins to run. In other words, it's exactly the > sort of thing big, stupid, Fortune-500 companies buy because the IBM > salesperson plays golf with the CIO. Years ago, I worked at one largish company where a couple of the embedded development projects used ClearCase. The rest of us used CVS or RCS or some other cheap commercial systems. Judging by those results, ClearCase requires a full-time administrator for every 10 or so users. The other systems seemed to require almost no regular administration, and what was required was handled by the developers themselves (mayby a couple hours per month). The cost of ClearCase was also sky-high. -- Grant Edwards grant.b.edwardsYow! VICARIOUSLY experience at some reason to LIVE!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A certainl part of an if() structure never gets executed.
On 2013-06-14, Nick the Gr33k wrote: > Well i do not understand it. Yea. We know. -- Grant Edwards grant.b.edwardsYow! I feel like a wet at parking meter on Darvon! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Wrong website loaded when other requested
On 2013-06-14, Nick the Gr33k wrote: > On 13/6/2013 10:31 ????, Grant Edwards wrote: >> On 2013-06-13, Nick the Gr33k wrote: >>> On 13/6/2013 9:37 , Andreas Perstinger wrote: >>>> On 13.06.2013 20:10, Nick the Gr33k wrote: >>>> [nothing new] >>>> >>>> Could you please stop spamming the whole internet with your problems. >>>> Not only that you've posted two similar offtopic messages within only 6 >>>> minutes to this list, you've also crossposted to alt.os.linux (where it >>>> is offtopic too) and to the forum at devshed.com (at least you've found >>>> the right subforum there). >>>> >>>> Thank you very much! >>> >>> Andrea i need to fix this my friend. >> >> Then shut up, stop bothering us, and fix it. > > I would, if i knew how to do it. > > And surely i'm not bothering you, since you never care to reply for > anything i ask. This newsgroup/list has been completely taken over by threads you start asking the same questions and then refusing to read the answers, try the suggested solutions, or read the references you're given. > And if you do not like my posts, just don't read them. I _try_ not to read them. But your constantly changing e-mail addresses and your constant creation of new (and equally futile) threads makes it pretty difficult to avoid... -- Grant Edwards grant.b.edwardsYow! Where do your SOCKS at go when you lose them in gmail.comth' WASHER? -- http://mail.python.org/mailman/listinfo/python-list
Re: Eval of expr with 'or' and 'and' within
On 2013-06-14, Nick the Gr33k wrote: > I started another thread no kidding. > because the last one was !@#$'ed up by irrelevant replies and was > difficult to jeep track. > > >>> name="abcd" > >>> month="efgh" > >>> year="ijkl" > > >>> print(name or month or year) > abcd > > Can understand that, it takes the first string out of the 3 strings > that has a truthy value. Yes, it does. That's the way the language is defined to work. If you don't like it, pick a different language. > >>> print("k" in (name and month and year)) > True > > No clue. since the expression in parenthesis returns 'abcd' No it doesn't. Try it: Python 2.7.3 (default, Mar 20 2013, 14:16:24) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> name="abcd" >>> month="efgh" >>> year="ijkl" >>> >>> "k" in (name and month and year) True >>> (name and month and year) 'ijkl' >>> > how can 'k' contained within 'abcd' ? It doesn't -- Grant Edwards grant.b.edwardsYow! Am I having fun yet? at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Eval of expr with 'or' and 'and' within
On 2013-06-14, Nobody wrote: > On Fri, 14 Jun 2013 18:16:05 +0300, Nick the Gr33k wrote: > >> My question is why the expr (name and month and year) result in the >> value of the last variable whic is variable year? > > For much the same reason that an OR expression returns the first true > value. > > "or" and "and" only evaluate as many arguments are required in order to > determine the correct result (aka "short-circuit evaluation"). If the > first argument of "or" is true, or the first argument of "and" is false, > the second argument isn't evaluated (this is important if evaluation can > have side effects). There are two completely orthogonal concepts here: 1. Short-circuit evaluation. Many languages do this. AFAICT, this isn't what he's asking about, but this is what people keep explaining. 2. Returning one the objects that result from the evaluation of the operands instead of returning True or False. This is what seems to be confusing him. This is much less common than short-circuit evaluation. C does short-circuit evaluation of && and || operators, but the result is always 1 or 0 (true of false). Instead of always returning True or False (which could be done and still preserver short-circuit evaluation), Python returns one of the operands or False. If you also have 1. there are cases where the value returned by the "or" operator is useful apart from it's "truthyness" value. There may be cases where the result returned by the "and" operator is useful apart from it's truthyness, but that seems to be less common. Taking advantage of that fact can lead to some hard-to-read code, so it's often discouraged as being too clever. It's important to note that these are somewhat orthogonal: You can have #1 and #2 (like Python). You can have #1 without #2 (like C). You can have #2 without #1 You can have neither #1 or #2 But again, #2 is more useful if you also have #1. -- Grant Edwards grant.b.edwardsYow! ... I have read the at INSTRUCTIONS ... gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Eval of expr with 'or' and 'and' within
On 2013-06-14, Chris Angelico wrote: > On Sat, Jun 15, 2013 at 3:49 AM, MRAB wrote: >> The general rule is that an object is true-ish unless it's false-ish >> (there are fewer false-ish objects than true-ish objects, e.g. zero vs >> non-zero int). > > With a few random oddities: > >>>> bool(float("nan")) > True > > I somehow expected NaN to be false. Maybe that's just my expectations > that are wrong, though. If you work with floating point long enough you realize that most of your expectations are wrong. Sometimes. Eventually. -- Grant Edwards grant.b.edwardsYow! My pants just went to at high school in the Carlsbad gmail.comCaverns!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Eval of expr with 'or' and 'and' within
On 2013-06-14, Nick the Gr33k wrote: > On 14/6/2013 7:47 , Benjamin Kaplan wrote: > In an "and" clause, >> python returns the first false value or the last value, because that >> will evaluate to the correct Boolean value. In an "or" clause, python >> returns the first true value or the last value. When Python finally got >> a Boolean type, no one wanted to break backwards compatibility for this. > > > This is exactly what i dont understand and thats why i keep asking and > people call me an idiot. I just dont understand why it behaves like that. > > Why return first or last value? There are cases where it's useful not only to know wether an expression was True or False, but _why_ it was true or false. > because that will evaluate to the correct Boolean value Yes. All values in Pyton have a "truthness" and you can be guaranteed that if A or B or C: will behave exactly the same way whether the "or" operator returns True or it returns one of it's operands. -- Grant Edwards grant.b.edwardsYow! Where do your SOCKS at go when you lose them in gmail.comth' WASHER? -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll... (was: Re: A few questiosn about encoding)
On 2013-06-14, Chris Angelico wrote: > On Sat, Jun 15, 2013 at 3:13 AM, D'Arcy J.M. Cain wrote: >> The answer is to always make sure that you include the previous poster >> in the reply as a Cc or To. I filter out any email that has the string >> "supp...@superhost.gr" in a header so I would also filter out the >> replies if people would follow that simple rule. >> >> I have suggested this before but the push back I get is that then >> people would get two copies of the email, one to them and one to the >> list. My answer is simple. Get a proper email system that filters out >> duplicates. Is there an email client out there that does not have this >> facility? > > The main downside to that is not the first response, to > somebody@somewhere and python-list, but the subsequent ones. Do you > include everyone's addresses? And if so, how do they then get off the > list? (This is a serious consideration. I had some very angry people > asking me to unsubscribe them from a (private) mailman list I run, but > they weren't subscribed at all - they were being cc'd.) I think the answer is to automatically kill all threads stared by "him". Unfortunately, I don't know if that's possible in most newsreaders. -- Grant Edwards grant.b.edwardsYow! A dwarf is passing out at somewhere in Detroit! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A few questiosn about encoding
On 2013-06-15, Denis McMahon wrote: > On Fri, 14 Jun 2013 16:58:20 +0300, Nick the Gr33k wrote: > >> On 14/6/2013 1:14 , Cameron Simpson wrote: >>> Normally a character in a b'...' item represents the byte value >>> matching the character's Unicode ordinal value. > >> The only thing that i didn't understood is this line. >> First please tell me what is a byte value > > Seriously? You don't understand the term byte? And you're the support > desk for a webhosting company? Well, we haven't had this thread for a week or so... There is some ambiguity in the term "byte". It used to mean the smallest addressable unit of memory (which varied in the past -- at one point, both 20 and 60 bit "bytes" were common). These days the smallest addressable unit of memory is almost always 8 bits on desktop and embedded processors (but often not on DSPs). That's why when IEEE stadards want to refer to an 8-bit chunk of data they use the term "octet". :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 2013-06-15, Chris ???Kwpolska??? Warrick wrote: > On Sat, Jun 15, 2013 at 5:40 PM, Steven D'Aprano > wrote: >> On Sat, 15 Jun 2013 07:58:27 -0400, D'Arcy J.M. Cain wrote: >> >>> I suggested including the poster that you are replying to. >> >> In the name of all that's good and decent in the world, why on earth >> would you do that when replying to a mailing list??? They're already >> getting a reply. Sending them TWO identical replies is just rude. > > Mailman is intelligent enough not to send a second copy in that case. > This message was sent with a CC, and you got only one copy. I don't want _any_ copies from from Mailman. I don't subscribe to whatever mailing list you're talking about. I'm reading this via an NNTP server. Keep replies in the group or on the list. -- Grant Edwards grant.b.edwardsYow! I just remembered at something about a TOAD! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Why 'files.py' does not print the filenames into a table format?
On 2013-06-15, Nick the Gr33k wrote: > On 15/6/2013 10:46 ??, Jarrod Henry wrote: >> Nick, at this point, you need to hire someone to do your work for you. > > The code is completely ready. OK. Good-bye then. -- Grant Edwards grant.b.edwardsYow! Th' MIND is the Pizza at Palace of th' SOUL gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 2013-06-17, Simpleton wrote: > On 16/6/2013 9:39 , Antoon Pardon wrote: >> If nikos's project was a college project we would have told >> him he has to make his homework himself. > > This is where you all mistaken. > > You see, my website could be done ina CMS like (Joomla or Drupal) or > even in DreamWeaver. > > I choosed Python because i like Python. > Mny of my friends and clients told me hey man your website is very > simple, how not Joomla-lize it with cool animation effects and stuff? > > Well, i could, but i dont want to because: > > 1. i want to learn Python > 2. i want to have full control of my webisite, knowing each and every > line does, since i'm writing it. > > > But now he is earning > > money with it, you seem to find it acceptable his job is done > > for him. > > No. I first try and inevitably i fail. But failing _isn't_ inevitible. If you take the time to actually learn Python by reading the references people provide, by studying small examples, and by experimenting with Python code, there's no reason why you should fail. -- Grant Edwards grant.b.edwardsYow! MY income is ALL at disposable! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 2013-06-18, Chris Angelico wrote: > On Tue, Jun 18, 2013 at 2:39 PM, alex23 wrote: >> tl;dr Stop acting like a troll and we'll stop perceiving you as such. > > This being Python-list, we duck-type. You don't have to declare that > you're a troll, like you would in C; you just react like a troll and > we'll treat you as one. We never ask "are you a troll", we just ask > "do you quack like a troll". Indeed. The "is he a troll" question is a discussion about internals. And like many Python users, some of us do like to discuss questions about internals (though we hopefully know enough not to depend on the answers being the same tomorrow). -- Grant Edwards grant.b.edwardsYow! What I want to find at out is -- do parrots know gmail.commuch about Astro-Turf? -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 2013-06-18, Antoon Pardon wrote: > Op 17-06-13 19:56, ru...@yahoo.com schreef: >>> I don't see that much change in his style. He just admitted >>> not reading help files (because they are too technical for >>> him). So essentialy he is asking we give him a beginners >>> tutorial in everything he doesn't understand without much >>> effort of him trying to understand things on his own and >>> without much appreciation for the time of others. >> >> See my reply to ChrisA. > > Your reply doesn't address his unwillingness to read the > documentation which was IMO rather apparant. It's not only apparent, he explicitly stated that he refused to go read the references he has been provided because he prefers to have his questions answered by a "live" persion. IMO, anybody who behaves like doesn't deserve any more responses. -- Grant Edwards grant.b.edwardsYow! I guess you guys got at BIG MUSCLES from doing too gmail.commuch STUDYING! -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is regex so slow?
On 2013-06-18, Antoine Pitrou wrote: > Roy Smith panix.com> writes: > > You should read again on the O(...) notation. It's an asymptotic complexity, > it tells you nothing about the exact function values at different data points. > So you can have two O(n) routines, one of which always twice faster than the > other. And you can have two O(n) routines, one of which is twice as fast for one value of n and the other is twice as fast for a different value of n (and that's true for any value of 'twice': 2X 10X 100X). All the O() tells you is the general shape of the line. It doesn't tell you where the line is or how steep the slope is (except in the case of O(1), where you do know the slope is 0. It's perfectly feasible that for the range of values of n that you care about in a particular application, there's an O(n^2) algorithm that's way faster than another O(log(n)) algorithm. [Though that becomes a lot less likely as n gets large.] -- Grant Edwards grant.b.edwardsYow! Where's SANDY DUNCAN? at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 2013-06-18, Dennis Lee Bieber wrote: > On Tue, 18 Jun 2013 13:38:40 + (UTC), Grant Edwards >>On 2013-06-18, Chris Angelico wrote: >>> On Tue, Jun 18, 2013 at 2:39 PM, alex23 wrote: >>>> tl;dr Stop acting like a troll and we'll stop perceiving you as such. >>> >>> This being Python-list, we duck-type. You don't have to declare that >>> you're a troll, like you would in C; you just react like a troll and >>> we'll treat you as one. We never ask "are you a troll", we just ask >>> "do you quack like a troll". >> >>Indeed. The "is he a troll" question is a discussion about internals. >>And like many Python users, some of us do like to discuss questions >>about internals (though we hopefully know enough not to depend on the >>answers being the same tomorrow). > > And suddenly I have visions of a Druidical reading of the entrails... Well, that might explain how some of the code I've seen recently in this newsgroup was written. -- Grant -- http://mail.python.org/mailman/listinfo/python-list
Re: Default Value
On 2013-06-22, Ian Kelly wrote: > On Fri, Jun 21, 2013 at 7:15 PM, Steven D'Aprano > wrote: >> On Fri, 21 Jun 2013 23:49:51 +0100, MRAB wrote: >> >>> On 21/06/2013 21:44, Rick Johnson wrote: >> [...] >>>> Which in Python would be the "MutableArgumentWarning". >>>> >>>> *school-bell* >>>> >>> I notice that you've omitted any mention of how you'd know that the >>> argument was mutable. >> >> That's easy. Just call ismutable(arg). The implementation of ismutable is >> just an implementation detail, somebody else can work that out. A >> language designer of the sheer genius of Rick can hardly be expected to >> worry himself about such trivial details. > > While we're at it, I would like to petition for a function > terminates(f, args) that I can use to determine whether a function > will terminate before I actually call it. I think it should be terminate_time() -- so you can also find out how long it's going to run. It can return None if it's not going to terminate... -- Grant Edwards grant.b.edwardsYow! I'm continually AMAZED at at th'breathtaking effects gmail.comof WIND EROSION!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python development tools
On 2013-06-23, cutems93 wrote: > I am new to python development and I want to know what kinds of tools > people use for python development. 1) emacs 2) Cpython 3) subversion 4) http://www.python.org/doc/ 5) comp.lang.python 99.9% of the programs I write are command-line tools. -- Grant Edwards grant.b.edwardsYow! I'm shaving!! at I'M SHAVING!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python development tools
On 2013-06-25, MRAB wrote: > Automating tasks, e.g. controlling other applications and stringing > together tasks that you would otherwise be doing by hand. That, IMO, is the definition of "scripting": writing a program to automate a task that would probably be done by hand if you didn't have to do it more that a few times. -- Grant Edwards grant.b.edwardsYow! I'm a fuschia bowling at ball somewhere in Brittany gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is the argparse module so inflexible?
On 2013-06-27, Jason Swails wrote: > He _is_ using cmd. He's subclassed cmd.Cmd and trying to use > argparse to handle argument parsing in the Cmd.precmd method to > preprocess the user input. [...] > Having subclassed cmd.Cmd myself in one of my programs and written my > own argument parsing class to service it, I can appreciate what the > OP is trying to do (and it's clever IMO). Unfortunately, when writing software, being "clever" turns out to be A Bad Thing(tm) as often as not. ;) -- Grant Edwards grant.b.edwardsYow! ... I want to perform at cranial activities with gmail.comTuesday Weld!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug reports [was Re: Python list code of conduct]
On 2013-07-03, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> Of course, it's possible for there to be dark corners. But if you're >> working with those, you know it full well. The dark corners of Python >> might be in some of its more obscure modules, or maybe in IPv6 >> handling, > > The sad thing about this statement is that IPv6 has been around for > about as long as Python. I've recently added IPv6 support to some embedded firmware. We had to add it because various purchasing people (mostly government) have non-negotiable feature checklists and "IPv6 support" is starting to show up on the checklists. However, so far, none of the people requiring IPv6 support actually have any plans to use IPv6 -- ever. I'm convinced we could put "IPv6 support" on the data sheets and continue shipping IPv4-only stuff for many years to come, and all our customers would be perfectly happy. -- Grant Edwards grant.b.edwardsYow! My NOSE is NUMB! at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug reports [was Re: Python list code of conduct]
On 2013-07-03, Roy Smith wrote: > In article , > Grant Edwards wrote: > >> On 2013-07-03, Roy Smith wrote: >> > In article , >> > Chris Angelico wrote: >> > >> >> Of course, it's possible for there to be dark corners. But if you're >> >> working with those, you know it full well. The dark corners of Python >> >> might be in some of its more obscure modules, or maybe in IPv6 >> >> handling, >> > >> > The sad thing about this statement is that IPv6 has been around for >> > about as long as Python. >> >> I've recently added IPv6 support to some embedded firmware. We had to >> add it because various purchasing people (mostly government) have >> non-negotiable feature checklists and "IPv6 support" is starting to >> show up on the checklists. > > Yup. I did one of those.Hmmm, just found the powerpoint deck dated > March 2006, so we probably started the project around September 2005. > Same deal, we couldn't sell into government accounts unless we had IPv6. > Have they actually used it? I doubt it. > > The really annoying thing about the project was I never got around to > implementing rfc1924. Thankfully, the network library for our RTOS had support functions to handle rfc1924. Otherwise I would have had to do it myself because there's no way I could have made it through the project having to read and type full-length IPv6 addresses the whole time. >> However, so far, none of the people requiring IPv6 support actually >> have any plans to use IPv6 -- ever. > > What's known in the industry as "shelfware". Yep. 99.9% of the time, our products are used on small, isolated industrial networks that have little or no internet connectivity. The product line started out when a lot of customers weren't even using IPv4 yet. We still have customers who use our products with all IP support disabled (though these days it's always on networks that have other IP traffic). -- Grant Edwards grant.b.edwardsYow! On the road, ZIPPY at is a pinhead without a gmail.compurpose, but never without a POINT. -- http://mail.python.org/mailman/listinfo/python-list
Re: Important features for editors
On 2013-07-04, ?? wrote: > > If you guys want to use it i can send you a patch for it. I know its > illegal thing to say but it will help you use it without buying it. A new low. Now he's offering to help people steal others' work. -- Grant -- http://mail.python.org/mailman/listinfo/python-list
Re: Important features for editors
On 2013-07-04, Ferrous Cranus wrote: > 4/7/2013 9:40 , ??/?? Grant Edwards : >> On 2013-07-04, ?? wrote: >>> >>> If you guys want to use it i can send you a patch for it. I know its >>> illegal thing to say but it will help you use it without buying it. >> >> A new low. Now he's offering to help people steal others' work. > > Like you never downloaded serials/keygens/patch/cracks for warez and > torrents websites. No, not that I can recall. -- Grant Edwards grant.b.edwardsYow! In Newark the at laundromats are open 24 gmail.comhours a day! -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
On 2013-07-05, ?? Gr33k wrote: > Is there a way to extract out of some environmental variable the Geo > location of the user being the city the user visits out website from? No. > Perhaps by utilizing his originated ip address? There is a very poor correlation between IP address and geographical location. I know that users of the ISPs in hometown are consistently mis-identified as being from towns 1500km away. -- Grant Edwards grant.b.edwardsYow! If elected, Zippy at pledges to each and every gmail.comAmerican a 55-year-old houseboy ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
On 2013-07-06, ?? Gr33k wrote: > Yes i know iam only storing the ISP's city instead of visitor's homeland > but this is the closest i can get: > > try: >gi = pygeoip.GeoIP('/home/nikos/GeoLiteCity.dat') >city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] ) >host = socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] ) > except Exception as e: >host = repr(e) > > > Tried it myself and it falsey said that i'am from Europe/Athens (capital > of Greece) while i'am from Europe/Thessaloniki (sub-capital of Greece) > > If we can pin-point the uvisitor more accurately plz let me know. For the Nth time: you can't. -- Grant Edwards grant.b.edwardsYow! HOORAY, Ronald!! at Now YOU can marry LINDA gmail.comRONSTADT too!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
On 2013-07-06, ?? Gr33k wrote: > 6/7/2013 4:41 , ??/?? ?? Gr33k : >> Yes i know iam only storing the ISP's city instead of visitor's homeland >> but this is the closest i can get: >> >> try: >>gi = pygeoip.GeoIP('/home/nikos/GeoLiteCity.dat') >>city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] ) >>host = socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] ) >> except Exception as e: >>host = repr(e) >> >> >> Tried it myself and it falsey said that i'am from Europe/Athens (capital >> of Greece) while i'am from Europe/Thessaloniki (sub-capital of Greece) >> >> If we can pin-point the uvisitor more accurately plz let me know. > > Good morning from Greece, > > All my Greece visitors as Dave correctly said have the ISP address which > here in Greece is Europe/Athens, so i have now way to distinct the > cities of the visitors. > > Is there any way to pinpoint the visitor's exact location? No. -- Grant Edwards grant.b.edwardsYow! Does someone from at PEORIA have a SHORTER gmail.comATTENTION span than me? -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for a new router
On 2013-07-09, Steven D'Aprano wrote: > On Mon, 08 Jul 2013 21:52:19 -0700, saadharana wrote: > >> Hey i'm looking for a new router. > > I recommend this one: > > http://www.bunnings.com.au/products_product_1350w-aeg-12-router-rt1350e_P6230066.aspx I just got a Bosch combo model (both plunge and fixed base), and I'm very happy with it: http://www.boschtools.com/Products/Tools/Pages/BoschProductDetail.aspx?pid=1617EVSPK It did take me a few days to find the extra 1/4" collet that came with it since it had worked it's way inside the molded case lid. -- Grant Edwards grant.b.edwardsYow! The PINK SOCKS were at ORIGINALLY from 1952!! gmail.comBut they went to MARS around 1953!! -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for a new router
On 2013-07-09, Skip Montanaro wrote: > As long as we are wandering off-topic. (What defines "on-topic" for spam?) > >> I just got a Bosch combo model (both plunge and fixed base), and I'm >> very happy with it: >> >> http://www.boschtools.com/Products/Tools/Pages/BoschProductDetail.aspx?pid=1617EVSPK > > I have a 1604. Any idea if the plunge base is available separately > and will fit my motor? I don't think so. Google gives me the impression that Bosch didn't make a plunge base for the 1604. These threads says a Porter-Cable 693 plunge base will work: http://www.routerforums.com/introductions/41838-bosch-1604-question.html http://forums.finewoodworking.com/fine-woodworking-knots/power-tools-and-machinery/pc-6931-plunge-base -- Grant Edwards grant.b.edwardsYow! Where's the Coke at machine? Tell me a joke!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Best Scripting Language for Embedded Work?
On 2013-07-10, David T Ashley wrote: > We develop embedded software for 32-bit micros using Windows as the > development platform. > > We are seeking a general purpose scripting language to automate > certain tasks, like cleaning out certain directories of certain types > of files in preparation for ZIP'ing, generating certain source files > automatically, etc. That's what a command shell is for. Since windows doesn't come with a real one, I'd recommend installing Cygwin and then using bash, make, etc. Better yet. Abandon windows and switch to an OS environment intended for software development rather than generating time-wasting power-point presentations. -- Grant Edwards grant.b.edwardsYow! Look! A ladder! at Maybe it leads to heaven, gmail.comor a sandwich! -- http://mail.python.org/mailman/listinfo/python-list
Re: GeoIP2 for retrieving city and region ?
On 2013-07-12, ?? wrote: > I know i have asked before but hwta i get is ISP city not visitors > precise city. You can't reliably do that. > GeoLiteCity.dat isnt accurate that's why it comes for free. i must > somehow get access to GeoIPCity.dat which is the full version. > > And of course it can be done, i dont want to believe that it cant. Believe what you want. > When visiting http://www.geoiptool.com/en/__ip_info/ it pinpoints my > _exact_ city of living, not the ISP's. It did not even ask me to > allow a geop ip javascript to run it present sit instantly. So you've reached your conclusion on a sample size of one? -- Grant Edwards grant.b.edwardsYow! I'm encased in the at lining of a pure pork gmail.comsausage!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Storing a very large number
On 2013-07-17, Hasit Mistry wrote: > I came across a problem that requires me to store a very large number > (say >10^100). How do I do it efficiently? First you must define "efficient". If you want to store the least number of bytes, and all you need to do is store the number (you don't need to manipulate it numerically, then storing it as an ascii string in exponential notion might be the smallest and fastest: veryLargeNumber = "10^100" That's only 27 bytes (CPython 2.7 on Linux). If you do need to do math on it, then what's wrong with this? veryLargeNumber = 10**100 That takes 58 bytes, but is much simpler for doing calculations. > And also, how do I select a particular number (say 209th) from that very > large number? I don't know what you mean by "a particular number". Do you mean you want to know the value of a particular digit when it's representing in a partuclar base (e.g. base 10)? Does this do what you want? First, we'll generate a number with a lot of digits: >>> int(math.pi * 10**15) ** 40 76912142205156893736567110721938151873066848551250079691933197504698382687850162519363381241341072061717399276279446152783228293733394674915106506777652714586583257515548935662783041098025828748644732150180263384738920337734332306732579704813309358353325051464419679305008247276777590803598706960718369750920313818346498676991944268444745266147723127330821117640028009756028827267657249563468436491879452209207125425662579803287297238987286648041733328816128585346936668110411776730224052535307657062833269810807032506745274610105341051559960125927107837478566295005327614374967849408928939897747893587527876150286368001L >>> x = int(math.pi * 10**15) ** 40 >>> sys.getsizeof(x) 288 >>> math.log10(x) 619.8859949077654 It has 600+ digits and requires 288 bytes to store. Counting from the left-hand side, starting '7' as digit 0, the 209th digit in the base-10 representation is: >>> str(x)[209] '3' -- Grant Edwards grant.b.edwardsYow! If elected, Zippy at pledges to each and every gmail.comAmerican a 55-year-old houseboy ... -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
On 2013-07-18, Chris Angelico wrote: > On Thu, Jul 18, 2013 at 4:11 PM, Aseem Bansal wrote: >> @vikash agrawal >> >> About GUI I discussed it at >> https://groups.google.com/forum/#!starred/comp.lang.python/M-Dy2pyWRfM and I >> am thinking about using PySide 1.2 for clients of chat system. I think I'll >> need downloadable clients if I want to make something like google talk. Then >> I'll need to implement server side programming also. I think google app >> engine would be suitable for this as it is going to be always online. > > Hrm. Rather than pointing people to Google Groups, which a number here > (and not unreasonably) detest, you may want to link to the python-list > archive: > > http://mail.python.org/pipermail/python-list/2013-July/thread.html#651359 While that's the canonical archive, the UI is awful. I find gmane's web UI to be _far_ more friendly and useful than the pipermail archive UI: http://thread.gmane.org/gmane.comp.python.general/737271/ 1) The search facility sort-of works (though using google with site:gmane.org:/gmane.comp.python usually works better). 2) You can post from the gmane web UI. 3) It offers both a threaded and a flat, blog-like version. -- Grant Edwards grant.b.edwardsYow! We just joined the at civil hair patrol! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
On 2013-07-18, Serhiy Storchaka wrote: > 18.07.13 20:04, Terry Reedy ??(): >> On 7/18/2013 3:29 AM, Aseem Bansal wrote: >>> About reading comp.lang.python can you suggest how to read it and >>> reply? >> >> To read this list as a newsgroup use news.gmane.org. The difference >> between the mailing list interface and newsgroup interface is that the >> latter automatically segregates messages by group and only downloads the >> messages you want to read. Gmane is also a better way to search the >> archive. > > Also newsgroup interface allow you reply to messages that have already > been posted before your subscription. Indeed. I read about 20 mailing lists by pointing a newsreader (I use slrn) at gmane.org. I find it to take far less effort than actualling having all of those messages actually sent to me. For _some_ of the gmane groups/lists you will actually have to subscribe to the mailing list in question if you want to be allowed to post messages -- but in your account settings for that mailing list server you can turn off delivery, so that it doesn't actually send you any of the postings. I really can't recommend gmane.org highly enough. [I don't actually read the python list using gmane.org, since I've read it from a Usenet news server via the group comp.lang.python since long before I discovered gmane.org.] -- Grant Edwards grant.b.edwardsYow! Not SENSUOUS ... only at "FROLICSOME" ... and in gmail.comneed of DENTAL WORK ... in PAIN!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On 2013-07-21, Gilles wrote: > Every once in a while, my ISP's SMTP server refuses to send > perfectly legit e-mails because it considers them as SPAM. > > So I'd like to install a dead-simple SMTP server on my XP computer > just to act as SMTP backup server. All I'd need is to change the SMTP > address in my e-mail client, and off they go. No need for anything > else like user authentication or SPAM control. Unless you've got a static IP address, a domain name, and a valid MX record that will match up when they do a reverse DNS lookup, it's pretty unlikely that you're going to have much luck running an SMTP server. Most other SMTP servers are probably going to ignore or reject your attempts to transfer mail from your own SMTP server. > Is there a no-brainer, ready-to-use solution in Python that I could > use for this? I'd recommend postfix or exim if I was going to try to do it, but I think they're Unix-only. -- Grant -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On 2013-07-22, Gilles wrote: > On Sun, 21 Jul 2013 21:01:09 + (UTC), Grant Edwards > wrote: >>Unless you've got a static IP address, a domain name, and a valid MX >>record that will match up when they do a reverse DNS lookup, it's >>pretty unlikely that you're going to have much luck running an SMTP >>server. Most other SMTP servers are probably going to ignore or >>reject your attempts to transfer mail from your own SMTP server. > > Incidently, how do ISP MTAs find whether the remote MTA is legit or > running on some regular user's computer? > > 1. Query Reverse DNS for IP > 2. Find domain > 3. Query DNS for MX > 4. ? There are a variety of things they check. They've got lists of IP address blocks that they know are residential DSL/cable customers, and sometimes they'll reject mail from those regardless of what you do. Some will compare the reverse-DNS lookup with the headers to make sure you're being honest about things like return-path, some will compare the IP address with the MX record for the domain they got when they did the reverse-lookup-DNS, and they've all probably got a variety of other secret heuristics they use to generate a "SPAM" score. For many years I ran my own SMTP server and had it configured to deliver mail directly to recipients. About 10 years, I had to give up on that because so many SMTP servers were rejecting/ignoring mail I sent. And I did have a static IP with a valid domain and MX record. But it was a residential DSL IP address, and I suspect that was enough to get mail rejected by some servers. -- Grant Edwards grant.b.edwardsYow! Well, O.K. at I'll compromise with my gmail.comprinciples because of EXISTENTIAL DESPAIR! -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it that easy to install Python ?
On 2013-07-25, santiago.d...@caoba.fr wrote: > Hi there, > > I never write any Python program but as a system administrator, I'm > often asked to install python on Debian servers. Are you sure it's not already installed? I haven't seen a Linux distro for a _long_ time that didn't include Python as part of the base installation. > I just finished downloading, configuring, making and installing. > > The binary is now installed in : > /usr/local/Python-2.7.5/bin/python2.7 Why not just apt-get install python? -- Grant Edwards grant.b.edwardsYow! Uh-oh!! I'm having at TOO MUCH FUN!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected results comparing float to Fraction
On 2013-07-29, MRAB wrote: > On 29/07/2013 17:40, Ian Kelly wrote: >> On Mon, Jul 29, 2013 at 10:20 AM, Chris Angelico wrote: >>> On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: >>>> I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats >>>> are approximate anyway, and the float value 1/3 is more likely to be >>>> Fraction(1, 3) than Fraction(6004799503160661, 18014398509481984). >>> >>> At what point should it become Fraction(1, 3)? >> >> At the point where the float is exactly equal to the value you get >> from the floating-point division 1/3. If it's some other float then >> the user didn't get there by entering 1/3, so it's not worth trying to >> pretend that they did. > > I thought that you're not meant to check for equality when using floats. You check for equality if equality is what you want to check. However much of the time when people _think_ they want to check for FP equality, they're wrong. You'll have to consult with a spiritual advisor to determin what you are "meant" to do... -- Grant Edwards grant.b.edwardsYow! Awright, which one of at you hid my PENIS ENVY? gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise Operations
On 2013-07-29, Devyn Collier Johnson wrote: > On Python3, how can I perform bitwise operations? For instance, I want > something that will 'and', 'or', and 'xor' a binary integer. http://www.google.com/search?q=python+bitwise+operations -- Grant Edwards grant.b.edwardsYow! I have the power to at HALT PRODUCTION on all gmail.comTEENAGE SEX COMEDIES!! -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-30, Joshua Landau wrote: > On 30 July 2013 18:08, Vito De Tullio wrote: > >> Ed Leafe wrote: >> >> > I had read about a developer who switched to using proportional fonts for >> > coding, and somewhat skeptically, tried it out. After a day or so it >> > stopped looking strange, and after a week it seemed so much easier to >> > read. >> >> By my (limited) experience with proportional fonts, they can be useful only >> with something like elastic tabstops[0]. But, as a general rule, I simply >> found more "squared" to just use a fixed-width font. >> > > Not if you give up on the whole "aligning" thing. You don't think that Python code at a given level should all be aligned? I find it very helpful when a given block of code is visually left-aligned. I also find intializers for tables of data to be much more easily read and maintained if the columns can be aligned. -- Grant Edwards grant.b.edwardsYow! MMM-MM!! So THIS is at BIO-NEBULATION! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31, Tim Chase wrote: > On 2013-07-31 07:16, Joshua Landau wrote: >> On 30 July 2013 18:52, Grant Edwards wrote: >>> I also find intializers for tables of data to be much more easily >>> read and maintained if the columns can be aligned. >> >> Why do you have tables in your Python code? For example: if you're writing an assembler, you usually have a table of mnemonics/opcodes/instruction-format/addressing-modes. > I've had occasion to write things like: > > for name, value, description in ( > ("cost", 42, "How much it cost"), > ("status", 3141, "Status code from ISO-3.14159"), > ... > ): > do_something(name, value) > print(description) > > I interpret Grant's statement as wanting the "table" to look like > > for name, value, description in ( > ("cost", 42, "How much it cost"), > ("status", 3141, "Status code from ISO-3.14159"), > ... > ): > do_something(name, value) > print(description) Exactly. When you have more than about 5 columns and 10 rows, having things aligned makes it far, far, easier to maintain. > which does give some modest readability benefits, but at a creation > cost I personally am unwilling to pay. It only gets typed once, it gets read hundreds or thousands of times. Optimize the common case. -- Grant Edwards grant.b.edwardsYow! I am NOT a nut at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
On 2013-07-31, Neil Cerutti wrote: > On 2013-07-31, Tim Chase wrote: >> On 2013-07-31 07:16, Joshua Landau wrote: >>> On 30 July 2013 18:52, Grant Edwards wrote: >>>> I also find intializers for tables of data to be much more easily >>>> read and maintained if the columns can be aligned. >>> >>> Why do you have tables in your Python code? >> >> I've had occasion to write things like: >> >> for name, value, description in ( >> ("cost", 42, "How much it cost"), >> ("status", 3141, "Status code from ISO-3.14159"), >> ... >> ): >> do_something(name, value) >> print(description) >> >> I interpret Grant's statement as wanting the "table" to look like >> >> for name, value, description in ( >> ("cost", 42, "How much it cost"), >> ("status", 3141, "Status code from ISO-3.14159"), >> ... >> ): >> do_something(name, value) >> print(description) >> >> which does give some modest readability benefits, but at a >> creation cost I personally am unwilling to pay. > > I'm actually OK with the creation cost, but not the maintenance cost. In my experience, aligning columns in large tables reduces maintence cost by making it much easier/faster to see what you've got and by providing a way to visually "prompt" you for the correct value in the correct place when you add new lines. -- Grant Edwards grant.b.edwardsYow! hubub, hubub, HUBUB, at hubub, hubub, hubub, HUBUB, gmail.comhubub, hubub, hubub. -- http://mail.python.org/mailman/listinfo/python-list
Re: PySerial could not open port COM4: [Error 5] Access is denied - please help
On 2012-06-27, David H. Lipman wrote: > From: "Adam" >> "John Nagle" wrote in message >> news:jse604$1cq$1...@dont-email.me... >>> On 6/26/2012 9:12 PM, Adam wrote: >>>> Host OS:Ubuntu 10.04 LTS >>>> Guest OS:Windows XP Pro SP3 >>>> >>>> I am able to open port COM4 with Terminal emulator. >>>> >>>> So, what can cause PySerial to generate the following error ... >>>> >>>> C:\Wattcher>python wattcher.py >>>> Traceback (most recent call last): >>>>File "wattcher.py", line 56, in >>>> ser.open() >>>>File "C:\Python25\Lib\site-packages\serial\serialwin32.py", line 56, in >>>> open >>>> raise SerialException("could not open port %s: %s" % (self.portstr, >>>> ctypes.WinError())) >>>> serial.serialutil.SerialException: could not open port COM4: [Error 5] >>>> Access is denied. >>> >>> Are you trying to access serial ports from a virtual machine? Which >>> virtual machine environment? Xen? VMware? QEmu? VirtualBox? I >>> wouldn't expect that to work in most of those. Except he says it _does_ work with his terminal emulator. >>> What is "COM4", anyway? Few machines today actually have four >>> serial ports. Is some device emulating a serial port? It shouldn't matter. If other apps can open COM4, then pyserial should be able to open COM4. >> Thanks, and yes, I am using VirtualBox. My laptop does not have a >> serial port so I use a USB-to-serial converter, which is assigned >> COM4. > > Then it is a Virtual COM port. Often software will want to > communicate directly to the COM4 port which is usually at: IRQ3 and > I/O 2E8h. Pyserial doesn't do that. It uses the standard win32 serial API, and it should work just fine with any Win32 serial device (what you call a "virtual" COM port). -- Grant Edwards grant.b.edwardsYow! World War III? at No thanks! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PySerial could not open port COM4: [Error 5] Access is denied - please help
On 2012-06-27, Adam wrote: > The Python script needed a call to ser.close() before ser.open() in > order to work. IOW, the port opened OK, but when you tried to open it a second time without closing it first, _that's_ when the .open() call failed. That's a restriction built in to Win32. You can't open a serial port that's already open. [Linux doesn't have that restriction.] Why do you need to open it a second time? -- Grant Edwards grant.b.edwardsYow! Send your questions to at ``ASK ZIPPY'', Box 40474, gmail.comSan Francisco, CA 94140, USA -- http://mail.python.org/mailman/listinfo/python-list
Re: PySerial could not open port COM4: [Error 5] Access is denied - please help
On 2012-06-27, Adam wrote: > "Grant Edwards" wrote: >> On 2012-06-27, Adam wrote: >> >>> The Python script needed a call to ser.close() before ser.open() in >>> order to work. >> >> IOW, the port opened OK, but when you tried to open it a second time >> without closing it first, _that's_ when the .open() call failed. >> >> That's a restriction built in to Win32. You can't open a serial port >> that's already open. [Linux doesn't have that restriction.] >> >> Why do you need to open it a second time? > > As far as I can tell, the wireless hardware connected to the > USB-to-serial converter is receiving data (which may have the serial > port open?). I can see the data being received in TeraTerm (using > COM4). After closing TeraTerm, I start up the Python script and get > the following error message ... > > C:\Wattcher>python wattcher.py > Traceback (most recent call last): > File "wattcher.py", line 56, in > ser.open() > File "C:\Python25\Lib\site-packages\serial\serialwin32.py", line 56, in > open > raise SerialException("could not open port %s: %s" % (self.portstr, > ctypes.WinError())) > serial.serialutil.SerialException: could not open port COM4: [Error 5] > Access is denied. > > > Searching for similar encounters of this error message, some people > said that calling ser.close() before ser.open() solved the problem. > And, it worked for me as well. > > Is this considered a chicken & egg situation? Can you post a small example showing what you're doing? If you're getting that error (and calling ser.close() makes that error go away), then it's because you're trying to re-open a port that you already have open. What happens if you just get rid of both the ser.close() and ser.open() calls? IOW, the port is apparently already open -- why do you want to close() and then re-open() it? -- Grant Edwards grant.b.edwardsYow! I wonder if I should at put myself in ESCROW!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PySerial could not open port COM4: [Error 5] Access is denied - please help
On 2012-06-27, Grant Edwards wrote: > On 2012-06-27, Adam wrote: >> "Grant Edwards" wrote: >>> Why do you need to open it a second time? >> >> As far as I can tell, the wireless hardware connected to the >> USB-to-serial converter is receiving data (which may have the serial >> port open?). I can see the data being received in TeraTerm (using >> COM4). After closing TeraTerm, I start up the Python script and get >> the following error message ... [...] >> Searching for similar encounters of this error message, some people >> said that calling ser.close() before ser.open() solved the problem. >> And, it worked for me as well. >> >> Is this considered a chicken & egg situation? > > Can you post a small example showing what you're doing? The best way to get help is to write as small a program as possible that demonstrates the problem, and post it. I'll help you get started... Does this program work? import serial ser = serial.Serial("COM4") ser.close() At the moment, I don't have access to a Windows machine, but I think the above should run without any errors. If it works, then you've successfully opened and closed the COM4 port. Start adding "features", in increments as small as possible, until the program fails. Then try to remove stuff that's not needed while still keeping the failure. IOW, try to find the smallest possible program that fails. Usually, in the process of doing that, you'll figure out what you were doing wrong. If not, post the smallest failing program you can come up with, and somebody will be able to help. If you won't show us what you're doing, we can't tell you what you're doing wrong. -- Grant Edwards grant.b.edwardsYow! Gee, I feel kind of at LIGHT in the head now, gmail.comknowing I can't make my satellite dish PAYMENTS! -- http://mail.python.org/mailman/listinfo/python-list
Re: PySerial could not open port COM4: [Error 5] Access is denied - please help
On 2012-06-27, Adam wrote: > >> Actually, I believe someone in an earlier thread in the newsgroup or >> elsewhere pointed out that serial ports automatically open under >> Windows. I'd have to look it back up when I have the time, which I >> don't have at the moment, unfortunately. What they're referring to is that on startup, Windows used to open serial ports and query them to see if there was a serial mouse connected. If it _thought_ it found a mouse, it would then hold the port. I don't think that behavior has been enabled by default for a long time. If that were the case, then your terminal program wouldn't be able to open the port either. However, IIRC, some versions of windows do open and then close the ports during the bus/device enumeration step of startup. However, they don't keep the port open, so it doesn't affect the ability of user applications to later open the port. > Thanks, I think I read that as well but can't recall where. > > I am just running Python scripts (downloaded), which is not opening > the serial port more than once (as Grant keeps assuming). Well, I'm assuming your description of what you're doing is accurate. If you're telling the truth, then the program is opening the port more than once. If the port wasn't already open, then calling ser.close() wouldn't do _anything_. Here's the close() implmentation from pyserial: def close(self): """Close port""" if self._isOpen: if self.hComPort: # Restore original timeout values: win32.SetCommTimeouts(self.hComPort, self._orgTimeouts) # Close COM-Port: win32.CloseHandle(self.hComPort) win32.CloseHandle(self._overlappedRead.hEvent) win32.CloseHandle(self._overlappedWrite.hEvent) self.hComPort = None self._isOpen = False There's only _one_ place where self._isOpen is set to True, and that's at the end of the open() call: def open(self): """Open port with current settings. This may throw a SerialException if the port cannot be opened.""" [...] self._overlappedWrite.hEvent = win32.CreateEvent(None, 0, 0, None) self._isOpen = True If you have to add the call "ser.close()" before you can open the port with "ser.open()", then that means that the port _was_already_open_. -- Grant Edwards grant.b.edwardsYow! World War III? at No thanks! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PySerial could not open port COM4: [Error 5] Access is denied - please help
On 2012-06-28, Adam wrote: > Obviously pySerial considers the serial port open Because it's already been opened by the Python program. > and will not open an already open serial port. Pyserial will happily try if you call the open() of a port that's already open, but Windows will return an error. > However, why is it that TeraTerm can open the serial port? Because TeraTerm only opens it once. > Here's the link where I read about calling ser.close() before > ser.open() ... > > Trying to open a serial port with pyserial on WinXP -> "Access denied" > > http://stackoverflow.com/questions/2063257/trying-to-open-a-serial-port-with-pyserial-on-winxp-access-denied That code is broken. The port is opened by this line: self.ser=serial.Serial(port='\\.\COM1', baudrate=9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=1) And then the author tries to _open_it_a_second_time_ here: self.ser.open() > Here's the Python scripts ... > https://github.com/adafruit/Tweet-a-Watt/downloads > Click on the "Download as ..." button for the Python scripts Like I kept telling you, those programs are trying to re-open a port that they've already open. Here's the erroneous code: wattcher.py: 53 54 # open up the FTDI serial port to get data transmitted to xbee 55 ser = serial.Serial(SERIALPORT, BAUDRATE) 56 ser.open() 57 Line 55 opens the serial port. Line 56 tries to _open_it_again_. _The_port_is_already_open_. Windows doesn't allow a serial port to be opened twice, therefore the ser.open() call raises an exception. Just delete line 56. The same thing happens here: gmeter-wattcher.py 83 84 # open up the FTDI serial port to get data transmitted to xbee 85 ser = serial.Serial(SERIALPORT, BAUDRATE) 86 ser.open() 87 Just delete line 86. See how simple it was to get the problem solved once you posted the actual code? -- Grant Edwards grant.b.edwardsYow! HUMAN REPLICAS are at inserted into VATS of gmail.comNUTRITIONAL YEAST ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Encapsulation, inheritance and polymorphism
On 2012-07-17, Lipska the Kat wrote: > and what's this obsession with 'correct' indentation of code ??? If you can explain to us Java's obsession with 'correct' placemnt of curly-braces, then you've explained indentation in python. Unless you're asking about the tabs vs. spaces argument. In that case, people who use 4 spaces per level are 'correct'; people who use a different number of spaces are a bit less correct; people who use tabs are wrong; and people who mix spaces and tabs -- well, we don't talk about them in polite company. -- Grant Edwards grant.b.edwardsYow! NEWARK has been at REZONED!! DES MOINES has gmail.combeen REZONED!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Foxpro goto command and deleted records
On 2012-07-17, Ethan Furman wrote: > In Foxpro if you do a Foxpro? -- Grant Edwards grant.b.edwardsYow! I am NOT a nut at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting a list of strings into a list of integers?
On 2012-07-22, Jan Riechers wrote: > I am not sure why everyone is using the for-iterator option over a > "map", but I would do it like that: > > MODUS_LIST= map(int, options.modus_list) > > "map" works on a list and does commandX (here "int" conversion, use > "str" for string.. et cetera) on sequenceY, returning a sequence. More > in the help file. "map" is what comes to mind first for me, but that's probably because 1) Before I learned Python, I learned other more functional languages where map was the definitive answer. 2) When I first learned Python it didn't have list comprehensions. That said, "map" seems to be frowned upon by the Python community for reasons I've never really understood, and most people are going to prefer reading a list comprehension. "What most people are going to prefer reading" does matter... -- Grant Edwards grant.b.edwardsYow! ... the MYSTERIANS are at in here with my CORDUROY gmail.comSOAP DISH!! -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Text editors
On 2012-07-29, Mark Lawrence wrote: > Point taken, snag being I've never used any nix box in anger. This > thread reminds of the good 'ole days when I were a lad using TPU on > VMS. Have we got any VMS aficionados here? It's been a long time, but I used eve/tpu as my main editor for several years back when I did embedded SW development on VMS. I was an ex-Unix user, so I used DECShell a lot -- even though it was painfully slow. The entire Unix philosophy is based on the assumption that process creation is inexpensive, and I was told process creation on VMS was _very_ expensive, so Bourne shell scripts that would have taken second under Unix took minutes under VMS. -- Grant -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python a commercial proposition ?
On 2012-07-30, Stefan Behnel wrote: > Still, you may still get away with the above statement by providing a > sufficiently narrow definition of "standalone". By my definition, there > isn't much "standalone" code out there. Most code I know interfaces with a > couple of external tools, libraries or backends, usually written in > languages I don't have to care about because they provide a language > independent interface. It's not really relevent to this discussion, but there is _lots_ of stand-alone code out there. It runs in sub-one-dollar microcontrollers that are programmed in assembly language or in C without external libraries (sometimes not even the "libc" that's included in the C language definition). Those microcontrollers are everywhere in toys, appliances, and all sorts of other "non-computer" things. -- Grant Edwards grant.b.edwardsYow! Mr and Mrs PED, can I at borrow 26.7% of the RAYON gmail.comTEXTILE production of the INDONESIAN archipelago? -- http://mail.python.org/mailman/listinfo/python-list
Re: Extracting bit fields from an IEEE-784 float
On 2012-07-30, Steven D'Aprano wrote: > 1) Are there any known implementations or platforms where Python floats > are not C doubles? If so, what are they? And the question you didn't ask: are there any platforms where a C double isn't IEEE-754? The last ones I worked on that where the FP format wasn't IEEE were the DEC VAX and TI's line if 32-bit floating-point DSPs. I don't think Python runs on the latter, but it might on the former. -- Grant Edwards grant.b.edwardsYow! I was born in a at Hostess Cupcake factory gmail.combefore the sexual revolution! -- http://mail.python.org/mailman/listinfo/python-list
Re: Extracting bit fields from an IEEE-784 float
On 2012-07-30, Mark Lawrence wrote: > On 30/07/2012 15:16, Grant Edwards wrote: >> On 2012-07-30, Steven D'Aprano wrote: >> >>> 1) Are there any known implementations or platforms where Python floats >>> are not C doubles? If so, what are they? >> >> And the question you didn't ask: are there any platforms where a C >> double isn't IEEE-754? >> >> The last ones I worked on that where the FP format wasn't IEEE were >> the DEC VAX and TI's line if 32-bit floating-point DSPs. I don't >> think Python runs on the latter, but it might on the former. >> > > Support for Python on VMS has been dropped for v3.3 see > http://bugs.python.org/issue11918 I imagine that VAXes running Unix went extinct in the wild long before VAXes running VMS. -- Grant Edwards grant.b.edwardsYow! Did YOU find a at DIGITAL WATCH in YOUR box gmail.comof VELVEETA? -- http://mail.python.org/mailman/listinfo/python-list
Re: Pass data to a subprocess
On 2012-08-01, Laszlo Nagy wrote: >> >> As I wrote "I found many nice things (Pipe, Manager and so on), but >> actually even >> this seems to work:" yes I did read the documentation. > Sorry, I did not want be offensive. >> >> I was just surprised that it worked better than I expected even >> without Pipes and Queues, but now I understand why.. >> >> Anyway now I would like to be able to detach subprocesses to avoid the >> nasty code reloading that I was talking about in another thread, but >> things get more tricky, because I can't use queues and pipes to >> communicate with a running process that it's noit my child, correct? >> > Yes, I think that is correct. I don't understand why detaching a child process on Linux/Unix would make IPC stop working. Can somebody explain? -- Grant Edwards grant.b.edwardsYow! My vaseline is at RUNNING... gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Pass data to a subprocess
On 2012-08-01, Laszlo Nagy wrote: > >>>> things get more tricky, because I can't use queues and pipes to >>>> communicate with a running process that it's noit my child, correct? >>>> >>> Yes, I think that is correct. >> I don't understand why detaching a child process on Linux/Unix would >> make IPC stop working. Can somebody explain? > > It is implemented with shared memory. I think (although I'm not 100% > sure) that shared memory is created *and freed up* (shm_unlink() system > call) by the parent process. It makes sense, because the child processes > will surely die with the parent. If you detach a child process, then it > won't be killed with its original parent. But the shared memory will be > freed by the original parent process anyway. I suspect that the child > that has mapped that shared memory segment will try to access a freed up > resource, do a segfault or something similar. I still don't get it. shm_unlink() works the same way unlink() does. The resource itself doesn't cease to exist until all open file handles are closed. From the shm_unlink() man page on Linux: The operation of shm_unlink() is analogous to unlink(2): it removes a shared memory object name, and, once all processes have unmapped the object, de-allocates and destroys the contents of the associated memory region. After a successful shm_unlink(), attempts to shm_open() an object with the same name will fail (unless O_CREAT was specified, in which case a new, distinct object is created). Even if the parent calls shm_unlink(), the shared-memory resource will continue to exist (and be usable) until all processes that are holding open file handles unmap/close them. So not only will detached children not crash, they'll still be able to use the shared memory objects to talk to each other. -- Grant Edwards grant.b.edwardsYow! Why is it that when at you DIE, you can't take gmail.comyour HOME ENTERTAINMENT CENTER with you?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Pass data to a subprocess
On 2012-08-02, Laszlo Nagy wrote: > >> I still don't get it. shm_unlink() works the same way unlink() does. >> The resource itself doesn't cease to exist until all open file >> handles are closed. From the shm_unlink() man page on Linux: >> >> The operation of shm_unlink() is analogous to unlink(2): it >> removes a shared memory object name, and, once all processes >> have unmapped the object, de-allocates and destroys the >> contents of the associated memory region. After a successful >> shm_unlink(), attempts to shm_open() an object with the same >> name will fail (unless O_CREAT was specified, in which case a >> new, distinct object is created). >> >> Even if the parent calls shm_unlink(), the shared-memory resource >> will continue to exist (and be usable) until all processes that are >> holding open file handles unmap/close them. So not only will >> detached children not crash, they'll still be able to use the shared >> memory objects to talk to each other. Note that when I say the detached children will still be able to talk to each other using shared memory after the parent calls shm_unlink() and exit(), I'm talking about the general case -- not specifically about the multiprocessing module. There may be something else going on with the multiprocessing module. > I stand corrected. It should still be examined, what kind shared > memory is used under non-linux systems. System V on AIX? And what > about Windows? So maybe the general answer is still no. But I guess > that the OP wanted this to work on a specific system. > > Dear Andrea Crotti! Please try to detach two child processes, exit > from the main process, and communicate over a multiprocessing queue. > It will possibly work. Sorry for my bad advice. I'm not claiming it will work, since I don't know how the IPC in the multiprocessing module works. It may indeed break when a child process is detatched (which I'm assuming means being removed from the process group and/or detached from the controlling tty). But, I'm not aware of any underlying Unix IPC mechanism that breaks when a child is detached, so I was curious about what would cause multiprocessing's IPC to break. -- Grant Edwards grant.b.edwardsYow! I didn't order any at WOO-WOO ... Maybe a YUBBA gmail.com... But no WOO-WOO! -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for a neat solution to a nested loop problem
On 2012-08-06, Grant Edwards wrote: > On 2012-08-06, Tom P wrote: >> On 08/06/2012 06:18 PM, Nobody wrote: >>> On Mon, 06 Aug 2012 17:52:31 +0200, Tom P wrote: >>> >>>> consider a nested loop algorithm - >>>> >>>> for i in range(100): >>>> for j in range(100): >>>> do_something(i,j) >>>> >>>> Now, suppose I don't want to use i = 0 and j = 0 as initial values, but >>>> some other values i = N and j = M, and I want to iterate through all >>>> 10,000 values in sequence - is there a neat python-like way to this? >>> >>> for i in range(N,N+100): >>> for j in range(M,M+100): >>> do_something(i,j) >>> >>> Or did you mean something else? >> >> no, I meant something else .. >> >>j runs through range(M, 100) and then range(0,M), and i runs through >> range(N,100) and then range(0,N) > > In 2.x: > > for i in range(M,100)+range(0,M): > for j in range(N,100)+range(0,N): > do_something(i,j) > > Dunno if that still works in 3.x. I doubt it, since I think in 3.x > range returns an iterator, not? Indeed it doesn't work in 3.x, but this does: from itertools import chain for i in chain(range(M,100),range(0,M)): for j in chain(range(N,100),range(0,N)): do_something(i,j) -- Grant Edwards grant.b.edwardsYow! People humiliating at a salami! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for a neat solution to a nested loop problem
On 2012-08-06, Tom P wrote: > On 08/06/2012 06:18 PM, Nobody wrote: >> On Mon, 06 Aug 2012 17:52:31 +0200, Tom P wrote: >> >>> consider a nested loop algorithm - >>> >>> for i in range(100): >>> for j in range(100): >>> do_something(i,j) >>> >>> Now, suppose I don't want to use i = 0 and j = 0 as initial values, but >>> some other values i = N and j = M, and I want to iterate through all >>> 10,000 values in sequence - is there a neat python-like way to this? >> >> for i in range(N,N+100): >> for j in range(M,M+100): >> do_something(i,j) >> >> Or did you mean something else? > > no, I meant something else .. > >j runs through range(M, 100) and then range(0,M), and i runs through > range(N,100) and then range(0,N) In 2.x: for i in range(M,100)+range(0,M): for j in range(N,100)+range(0,N): do_something(i,j) Dunno if that still works in 3.x. I doubt it, since I think in 3.x range returns an iterator, not? -- Grant Edwards grant.b.edwardsYow! I wish I was on a at Cincinnati street corner gmail.comholding a clean dog! -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for a neat solution to a nested loop problem
On 2012-08-06, Tom P wrote: >>>> no, I meant something else .. >>>> >>>> j runs through range(M, 100) and then range(0,M), and i runs through >>>> range(N,100) and then range(0,N) >>> >>> In 2.x: >>> >>> for i in range(M,100)+range(0,M): >>> for j in range(N,100)+range(0,N): >>> do_something(i,j) >>> >>> Dunno if that still works in 3.x. I doubt it, since I think in 3.x >>> range returns an iterator, not? >> >> Indeed it doesn't work in 3.x, but this does: >> >> from itertools import chain >> >> for i in chain(range(M,100),range(0,M)): >> for j in chain(range(N,100),range(0,N)): >> do_something(i,j) > > ah, that looks good - I guess it works in 2.x as well? I don't know. Let me test that for you... $ python Python 2.6.8 (unknown, May 18 2012, 11:56:26) [GCC 4.5.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from itertools import chain >>> for i in chain(range(0,5),range(5,10)): ... print i ... 0 1 2 3 4 5 6 7 8 9 >>> Yes, it works in 2.x as well. -- Grant Edwards grant.b.edwardsYow! ... bleakness at ... desolation ... plastic gmail.comforks ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Threads and sockets
On 2012-08-10, loial wrote: > At the moment I do not start to read responses until the data has > been sent to the printer. However it seems I am missing some > responses from the printer whilst sending the data, so I need to be > able to do the 2 things at the same time. > > Can I open a port once and then use 2 different threads, one to write > to the post and one to read the responses)? By "port" I assume you mean a TCP connection using the 'socket' module? If so, then yes you can write using one thread and read using a second thread. I do that all the time. Sometimes it's simpler to use a single thread that uses select or poll, and sometimes it's simpler to use multiple threads. And you never know which way is best until you're half way down the wrong road... -- http://mail.python.org/mailman/listinfo/python-list