Re: [OT] Posting under ones full name (was: How to uncompress a VOB file? (Win XP))

2012-08-14 Thread Chris Angelico
On Wed, Aug 15, 2012 at 1:43 PM, Steven D'Aprano wrote: > It was a joke, implying that my mother uses the same "truly unique" > handle as you. > > With over 7 billion people on the planet, and no upper limit on the > number of handles anyone can take, together with the lack of any > definitive cen

Re: [OT] Posting under ones full name

2012-08-14 Thread Chris Angelico
On Wed, Aug 15, 2012 at 1:56 PM, Ben Finney wrote: > Chris Angelico writes: > >> On Wed, Aug 15, 2012 at 12:06 PM, Thomas 'PointedEars' Lahn >> wrote: >> > Please use `[...]' or `[…]' to indicate omission instead. I could >> > have writ

Re: [OT] Posting under ones full name

2012-08-15 Thread Chris Angelico
On Wed, Aug 15, 2012 at 5:28 PM, Ian Kelly wrote: > Irrelevant. Why would an author adhering to common principles of > style ever use square-bracketed dots in a statement that he authored > himself? You mean exactly the way he did in the post you quoted me as quoting? ChrisA -- http://mail.pyt

Re: type(None)()

2012-08-16 Thread Chris Angelico
On Thu, Aug 16, 2012 at 10:47 PM, Hans Mulder wrote: > Why doesn't it just return an existing instance of the type, > like bool, int, str and other built-in non-mutable types do? > >> py> type(False)() is False >> True With int and str, it's only an optimization, and not guaranteed to happen. >>

Re: How do I display unicode value stored in a string variable using ord()

2012-08-16 Thread Chris Angelico
On Fri, Aug 17, 2012 at 8:09 AM, Charles Jensen wrote: > How would I use ord() to find the unicode value of a string stored in a > variable? > > So the following 2 lines of code will give me the ascii value of the variable > a. How do I specify ord to give me the unicode value of a? > > a

Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-16 Thread Chris Angelico
On Fri, Aug 17, 2012 at 1:40 AM, Ramchandra Apte wrote: > On 16 August 2012 21:00, Mark Lawrence wrote: >> and "bottom" reads better than "top" >> > Look you are the only person complaining about top-posting. > GMail uses top-posting by default. > I can't help it if you feel irritated by it. I p

Re: remote read eval print loop

2012-08-16 Thread Chris Angelico
onsisting of a command word, then optionally parameters after a space, then a newline. It's easy to debug, easy to read in your code, and makes sense to anyone who's used a command-line interface. Six months from now, when your server still hasn't been compromised, you'l

Re: remote read eval print loop

2012-08-17 Thread Chris Angelico
On Fri, Aug 17, 2012 at 12:27 PM, Steven D'Aprano wrote: > There is already awesome protocols for running Python code remotely over > a network. Please do not re-invent the wheel without good reason. > > See pyro, twisted, rpyc, rpclib, jpc, and probably many others. But they're all tools for bui

Re: remote read eval print loop

2012-08-17 Thread Chris Angelico
On Fri, Aug 17, 2012 at 11:28 PM, Eric Frederich wrote: > Within the debugging console, after importing all of the bindings, there > would be no reason to import anything whatsoever. > With just the bindings I created and the Python language we could do > meaningful debugging. > So if I block the

Re: set and dict iteration

2012-08-17 Thread Chris Angelico
On Sat, Aug 18, 2012 at 4:37 AM, Aaron Brady wrote: > Is there a problem with hacking on the Beta? Nope. Hack on the beta, then when the release arrives, rebase your work onto it. I doubt that anything of this nature will be changed between now and then. ChrisA -- http://mail.python.org/mailman

Re: Regex Question

2012-08-17 Thread Chris Angelico
On Sat, Aug 18, 2012 at 2:41 PM, Frank Koshti wrote: > Hi, > > I'm new to regular expressions. I want to be able to match for tokens > with all their properties in the following examples. I would > appreciate some direction on how to proceed. > > > @foo1 > @foo2() > @foo3(anything could go here)

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Chris Angelico
On Sun, Aug 19, 2012 at 1:07 AM, wrote: > I'm aware of this (and all the blah blah blah you are > explaining). This always the same song. Memory. > > Let me ask. Is Python an 'american" product for us-users > or is it a tool for everybody [*]? > Is there any reason why non ascii users are somehow

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Chris Angelico
On Sun, Aug 19, 2012 at 2:38 AM, wrote: > Sorry guys, I'm not stupid (I think). I can open IDLE with > Py 3.2 ou Py 3.3 and compare strings manipulations. Py 3.3 is > always slower. Period. Ah, but what about all those other operations that use strings under the covers? As mentioned, namespace l

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Chris Angelico
On Sun, Aug 19, 2012 at 4:26 AM, Paul Rubin wrote: > Can you explain the issue of "breaking surrogate pairs apart" a little > more? Switching between encodings based on the string contents seems > silly at first glance. Strings are immutable so I don't understand why > not use UTF-8 or UTF-16 fo

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Chris Angelico
On Sun, Aug 19, 2012 at 12:11 PM, Paul Rubin wrote: > Chris Angelico writes: >> UTF-8 is highly inefficient for indexing. Given a buffer of (say) a >> few thousand bytes, how do you locate the 273rd character? > > How often do you need to do that, as opposed to tra

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Chris Angelico
On Sun, Aug 19, 2012 at 12:35 PM, Paul Rubin wrote: > Chris Angelico writes: >>>>> "asdfqwer"[4:] >> 'qwer' >> >> That's a not uncommon operation when parsing strings or manipulating >> data. You'd need to completely re

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Chris Angelico
On Sun, Aug 19, 2012 at 1:10 PM, Paul Rubin wrote: > Chris Angelico writes: >> I don't have a Python example of parsing a huge string, but I've done >> it in other languages, and when I can depend on indexing being a cheap >> operation, I'll happily do exactly

Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-19 Thread Chris Angelico
On Sun, Aug 19, 2012 at 5:15 PM, Steven D'Aprano wrote: > The software equivalent of somebody handing you a "blank" piece of paper > and turning it around to see if maybe there's something on the back. Straight out of a Goon Show, that is. Heh. ChrisA -- http://mail.python.org/mailman/listinfo/

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Chris Angelico
On Sun, Aug 19, 2012 at 6:11 PM, Paul Rubin wrote: > Steven D'Aprano writes: >> result = text[end:] > > if end not near the end of the original string, then this is O(N) > even with fixed-width representation, because of the char copying. > > if it is near the end, by knowing where the string

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Chris Angelico
On Sun, Aug 19, 2012 at 8:13 PM, lipska the kat wrote: > The date stamp is different but the Python version is the same Check out what 'sys.maxunicode' is in each of those Pythons. It's possible that one is a wide build and the other narrow. ChrisA -- http://mail.python.org/mailman/listinfo/pyt

Re: New internal string format in 3.3

2012-08-19 Thread Chris Angelico
On Sun, Aug 19, 2012 at 8:19 PM, wrote: > This is precicely the weak point of this flexible > representation. It uses latin-1 and latin-1 is for > most users simply unusable. No, it uses Unicode, and as an optimization, attempts to store the codepoints in less than four bytes for most strings. T

Re: New internal string format in 3.3

2012-08-19 Thread Chris Angelico
On Mon, Aug 20, 2012 at 4:09 AM, Mark Lawrence wrote: > On 19/08/2012 18:51, wxjmfa...@gmail.com wrote: >> >> Just for the story. >> >> Five minutes after a closed my interactive interpreters windows, >> the day I tested this stuff. I though: >> "Too bad I did not noted the extremely bad cases I f

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Chris Angelico
On Mon, Aug 20, 2012 at 3:34 AM, Terry Reedy wrote: > On 8/19/2012 4:04 AM, Paul Rubin wrote: >> I realize the folks who designed and implemented PEP 393 are very smart >> cookies and considered stuff carefully, while I'm just an internet user >> posting an immediate impression of something I hadn

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Chris Angelico
On Mon, Aug 20, 2012 at 10:35 AM, Terry Reedy wrote: > On 8/19/2012 6:42 PM, Chris Angelico wrote: >> However, Python goes a bit further by making it VERY clear that this >> is a mere optimization, and that Unicode strings and bytes strings are >> completely different

Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-20 Thread Chris Angelico
On Mon, Aug 20, 2012 at 5:31 PM, rusi wrote: > On Aug 19, 12:15 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> is probably a really great person and kind to small animals and furry >> children, but... > > ROFL! > > The first we're all familiar with. > > Furry children? > > Someth

Re: Does Polymorphism mean python can create object?

2012-08-20 Thread Chris Angelico
On Tue, Aug 21, 2012 at 12:01 AM, Levi Nie wrote: > Does Polymorphism mean python can create object? I'm not sure what your question means. Could you rephrase, please? Also, this document may be useful to you: http://www.catb.org/~esr/faqs/smart-questions.html Chris Angelico

Re: How to set the socket type and the protocol of a socket using create_connection?

2012-08-20 Thread Chris Angelico
On Mon, Aug 20, 2012 at 11:38 PM, Hans Mulder wrote: > Why are you trying to reimplement ping? > > All OS'es I am aware of come with a working ping implementation. For some definition of "working", at least. I've never managed to get MS Windows to ping broadcast, for instance. A Google search fo

Re: Abuse of Big Oh notation

2012-08-20 Thread Chris Angelico
On Tue, Aug 21, 2012 at 2:01 AM, Paul Rubin wrote: > Analogy: how big a box is required to hold a pair of shoes? In a purely > theoretical sense we might say O(S) where S is the shoe size, treating > shoe size as an arbitrary independent variable. But in the real world, > shoe size is controlled

Re: Does Polymorphism mean python can create object?

2012-08-21 Thread Chris Angelico
On Tue, Aug 21, 2012 at 10:20 AM, alex23 wrote: > On Tue, Aug 21, 2012 at 12:01 AM, Levi Nie wrote: >> Does Polymorphism mean python can create object? > > No. This isn't D&D. Polymorphism has a distinct meaning in computer science, > one which you would've found in less time searching Wikipedia

Re: Books?

2012-08-21 Thread Chris Angelico
On Wed, Aug 22, 2012 at 11:39 AM, Roy Smith wrote: > In article > <5203ee16-5a80-4cd9-9434-ee2efb645...@kg10g2000pbc.googlegroups.com>, > Anonymous Group wrote: > >> What books do you recomend for learning python? Preferably free and/or >> online. > > I would start with http://docs.python.org/tu

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Chris Angelico
ome: words = [(word.capitalize if len(word.strip(punctuation)) > 3 else word) for word in line.split(' ')] The parentheses are optional, but may help you see how the interpreter parses that. Code looks pretty good though, and again, a big thank you for making your question so clear :) It's a pleasure to help you. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Chris Angelico
On Wed, Aug 22, 2012 at 8:28 PM, Kamil Kuduk wrote: >> Purpose of the script: >> To capitalize the first letter of any word in a given file, leaving >> words which have 3 or less letters. > > First or all? If first and this is the only purpose of the script you > can easily use sed: > less file.tx

Re: Objects in Python

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 1:25 AM, shaun wrote: > def breakuparray(self): > for row in self.array: > mer = row[0].ljust(25, ' ') > merc = row[1].ljust(13, ' ') > mertype = row[2] >

Re: Objects in Python

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 5:03 AM, lipska the kat wrote: > On 22/08/12 19:15, Ian Kelly wrote: >> >> You're conflating "strong typing" with "static typing". Strong typing >> does not refer to restrictions on what type of data can be stored >> where, but to restrictions on how operations on that dat

Re: Objects in Python

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 2:11 PM, Steven D'Aprano wrote: > On Thu, 23 Aug 2012 12:02:16 +1000, Chris Angelico wrote: > >> 2) Related to the above, you can infinitely nest scopes. There's nothing >> wrong with having six variables called 'q'; you always use th

Re: Re: Objects in Python

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 2:49 PM, Evan Driscoll wrote: > On 8/22/2012 18:58, Ben Finney wrote: >> You haven't discovered anything about types; what you have discovered is >> that Python name bindings are not variables. >> >> In fact, Python doesn't have variables – not as C or Java programmers >> w

Re: Guarding arithmetic

2012-08-23 Thread Chris Angelico
On Thu, Aug 23, 2012 at 7:05 PM, Mark Carter wrote: > Suppose I want to define a function "safe", which returns the argument passed > if there is no error, and 42 if there is one. So the setup is something like: > > def safe(x): ># WHAT WOULD DEFINE HERE? > > print safe(666) # prints 666 > pr

Re: Guarding arithmetic

2012-08-23 Thread Chris Angelico
On Thu, Aug 23, 2012 at 7:22 PM, Mark Carter wrote: > OK, so it looks like a solution doesn't exist to the problem as specified. I > guess it's something that only a language with macros could accommodate. You're asking for a function to prevent the evaluation of its arguments from throwing an e

Re: Guarding arithmetic

2012-08-23 Thread Chris Angelico
On Thu, Aug 23, 2012 at 7:28 PM, Laszlo Nagy wrote: >> That can work ONLY if the division of 1/0 doesn't raise an exception. >> This is why the concept of NaN exists; I'm not sure if there's a way >> to tell Python to return NaN instead of bombing, but it's most likely >> only possible with floati

Re: Guarding arithmetic

2012-08-23 Thread Chris Angelico
On Fri, Aug 24, 2012 at 4:49 AM, Dennis Lee Bieber wrote: > By the time you wrap the equation with a lambda all, named, terms, > AND supply the named terms after the lambda, you might as well just wrap > the equation in a plain try/except block. But closures spare you that hassle. >>> a=

Re: Objects in Python

2012-08-23 Thread Chris Angelico
On Fri, Aug 24, 2012 at 3:56 AM, Steven D'Aprano wrote: > But name bindings are a kind of variable. Named memory locations are a > *different* kind of variable. The behaviour of C variables and Python > variables do not follow the Liskov Substitution Principle -- you can't > rip out the entire "na

Re: Variables vs names [was: Objects in Python]

2012-08-23 Thread Chris Angelico
On Fri, Aug 24, 2012 at 5:22 AM, Evan Driscoll wrote: > In Python--, any time you use a name, you have to prefix it with the > word 'variable': > variable x = 4 > print(variable x) That gets really unwieldy. You should shorten it to a single symbol. And your language could be called Python Hy

Re: Objects in Python

2012-08-23 Thread Chris Angelico
On Fri, Aug 24, 2012 at 9:54 AM, Dennis Lee Bieber wrote: > On Fri, 24 Aug 2012 08:00:59 +1000, Chris Angelico > declaimed the following in gmane.comp.python.general: > >> >> But again, that probably doesn't help explain the variables. Unless >> you've c

Re: Objects in Python

2012-08-23 Thread Chris Angelico
On Fri, Aug 24, 2012 at 10:36 AM, Roy Smith wrote: > In fact, I can even write it that way and everything works: > globals()["a"] = 42 a > 42 > > Even id() thinks they're the same thing: > id(a) > 1755402140 id(globals()["a"]) > 1755402140 Ah, no. What you have there is actual

python-list@python.org

2012-08-24 Thread Chris Angelico
On Fri, Aug 24, 2012 at 11:53 PM, Prasad, Ramit wrote: > Ulrich Eckhardt wrote: >> BTW: You omitted the attribution line for the text you quoted, whom do >> you blame for that? That said, "Nonsense" is a strong enough word to >> start a flamewar... not nice. > Fair enough. I typically leave off at

Re: Looking for duplicate modules

2012-08-24 Thread Chris Angelico
On Fri, Aug 24, 2012 at 1:30 AM, Roy Smith wrote: > I'm working on a tool which scans all the directories in sys.path and finds > any modules which appear multiple times in the path. It'll also call out any > .pyc's it finds without matching py's. > This is why I love high level languages. The

Re: Objects in Python

2012-08-24 Thread Chris Angelico
On Fri, Aug 24, 2012 at 11:27 PM, Grant Edwards wrote: > Ah, but as we are always fond of saying in this group "that's an > implementation detail, and not part of the language definition". The > model where a compiler is "keeping notes about it in Narnia" is also > perfectly valid. However, RAM i

Re: Objects in Python

2012-08-24 Thread Chris Angelico
On Sat, Aug 25, 2012 at 1:04 PM, Steven D'Aprano wrote: > You're confusing two different levels of explanation here. On the one > hand, you're talking about C semantics, where you are explicitly > responsible for managing unnamed data via indirection (pointers). > Typically, the *pointers* get giv

Re: Objects in Python

2012-08-25 Thread Chris Angelico
On Sat, Aug 25, 2012 at 6:55 PM, Mark Lawrence wrote: > I'm just wondering out aloud if the number of times this type of thread has > been debated here will fit into a Python long or float? Well, when I have to store currency information, I like to store it as an integer, using the native currenc

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Chris Angelico
On Sat, Aug 25, 2012 at 7:46 PM, Frank Millman wrote: > Therefore, I think he is saying that he would have preferred that python > standardise on 4-byte characters, on the grounds that the saving in memory > does not justify the performance overhead. If that's indeed the argument, then at least i

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Chris Angelico
On Sat, Aug 25, 2012 at 9:05 PM, Mark Lawrence wrote: > I thought Terry Reedy had shot down any claims about performance overhead, > and that the memory savings in many cases must be substantial and therefore > worthwhile. Or have I misread something? Or what? My reading of the thread(s) is/are

Re: Objects in Python

2012-08-25 Thread Chris Angelico
On Sun, Aug 26, 2012 at 5:56 AM, Dennis Lee Bieber wrote: > On Sat, 25 Aug 2012 09:55:27 +0100, Mark Lawrence > declaimed the following in > gmane.comp.python.general: > >> >> I'm just wondering out aloud if the number of times this type of thread >> has been debated here will fit into a Python l

Re: Re: Objects in Python

2012-08-25 Thread Chris Angelico
On Sun, Aug 26, 2012 at 3:45 PM, Evan Driscoll wrote: > Third, and more wackily, you could technically create a C implementation > that works like Python, where it stores variables (whose addresses aren't > taken) in a dict keyed by name, and generates code that on a variable access > looks up the

Re: Objects in Python

2012-08-26 Thread Chris Angelico
On Sun, Aug 26, 2012 at 10:02 PM, Steven D'Aprano wrote: > On Sun, 26 Aug 2012 16:22:05 +1000, Chris Angelico wrote: > >> On Sun, Aug 26, 2012 at 3:45 PM, Evan Driscoll >> wrote: >>> Third, and more wackily, you could technically create a C >>> implem

Re: Objects in Python

2012-08-26 Thread Chris Angelico
On Sun, Aug 26, 2012 at 11:43 PM, Steven D'Aprano wrote: > It gets worse: Python has multiple namespaces that are searched. > > "Go to the Excelsior Hotel and ask the concierge for Mr Smith. If Mr > Smith isn't staying there, go across the road to the Windsor Hotel and > ask there. If he's not the

Re: Objects in Python

2012-08-26 Thread Chris Angelico
On Mon, Aug 27, 2012 at 12:02 AM, Mark Lawrence wrote: > On 26/08/2012 14:34, Chris Angelico wrote: >> >> Okay, that may be a bit of a fairy tale ending and completely illogical. >> >> ChrisA > > Then stick to the thread about flexible string representation,

Re: Objects in Python

2012-08-26 Thread Chris Angelico
On Mon, Aug 27, 2012 at 12:02 AM, Roy Smith wrote: > In article <503a2804$0$6574$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > The mapping of name:address is part of the *compilation* process -- the compiler knows that variable 'x' corresponds to location 1234567

Re: Objects in Python

2012-08-26 Thread Chris Angelico
On Mon, Aug 27, 2012 at 12:18 AM, Steven D'Aprano wrote: > Also, built-ins require a name lookup too. As you point out, locals are > special, but Python will search an arbitrarily deep set of nested > nonlocal scopes, then globals, then builtins. Ah, builtins, forgot that. So yes, global scope in

Re: What do I do to read html files on my pc?

2012-08-27 Thread Chris Angelico
On Mon, Aug 27, 2012 at 8:59 PM, mikcec82 wrote: > Hallo, > > I have an html file on my pc and I want to read it to extract some text. > Can you help on which libs I have to use and how can I do it? > > thank you so much. Try BeautifulSoup. You can find it at the opposite end of a web search. No

Re: What do I do to read html files on my pc?

2012-08-27 Thread Chris Angelico
On Mon, Aug 27, 2012 at 11:51 PM, mikcec82 wrote: > I have this html data and I want to check if it is present a string "" > or/and a string "NOT PASSED": Start by scribbling down some notes in your native language (that is, don't bother trying to write code yet), defining exactly what you'r

Re: Flexible string representation, unicode, typography, ...

2012-08-28 Thread Chris Angelico
On Wed, Aug 29, 2012 at 12:42 PM, rusi wrote: > Clearly there are 3 string-engines in the python 3 world: > - 3.2 narrow > - 3.2 wide > - 3.3 (flexible) > > How difficult would it be to giving the choice of string engine as a > command-line flag? > This would avoid the nuisance of having two binar

Re: Flexible string representation, unicode, typography, ...

2012-08-29 Thread Chris Angelico
On Wed, Aug 29, 2012 at 9:40 PM, wrote: > For a given coding scheme, all code points/characters are > equivalent. Expecting to handle a sub-range in a coding > scheme without shaking that coding scheme is impossible. Not all codepoints are equally likely. That's the whole point behind variable-l

Re: Flexible string representation, unicode, typography, ...

2012-08-29 Thread Chris Angelico
On Thu, Aug 30, 2012 at 1:43 AM, wrote: > If "Python" has found a new way to cover the set > of the Unicode characters, why not proposing it > to the Unicode consortium? Python's open source. If some other language wants to borrow the idea, they can look at the code, or alternatively, just read

Re: Flexible string representation, unicode, typography, ...

2012-08-30 Thread Chris Angelico
On Thu, Aug 30, 2012 at 6:51 PM, wrote: > Pick up a random text and see the probability this > text match the most optimized case 1 char / 1 byte, > practically never. Only if you talk about a huge document. Try, instead, every string ever used in a Python script. Practically always. But I'm w

Re: Beginners question

2012-08-30 Thread Chris Angelico
On Thu, Aug 30, 2012 at 9:54 PM, wrote: > What sort of object is posix.stat_result? Its not a dictionary or list or a > class object as far as I can tell. Thanks for any help. There's some cool things you can do here. (Note that I'm testing this on a Windows box, so it's marginally different.)

Re: Beginners question

2012-08-30 Thread Chris Angelico
On Thu, Aug 30, 2012 at 10:50 PM, wrote: > On Thu, 30 Aug 2012 13:14:57 +0100 > MRAB wrote: >>What don't you ask Python? I'm sure you'' get something like this: >> >> >>> type(s) >> > > Umm , no I don't. > type(s) > > > Which isn't terrible helpful. That's actually the same thing, except

Re: get return or locals from "exec" str in "environment"

2012-08-30 Thread Chris Angelico
On Fri, Aug 31, 2012 at 8:11 AM, lucas wrote: > and i can see my executed function in there as a type function, and local and > global vars, but i can not access or find "harry" or "rtn" the variables > within the function lucas53. i do not know how to access the local variables > within lucas

Re: get return or locals from "exec" str in "environment"

2012-08-30 Thread Chris Angelico
On Fri, Aug 31, 2012 at 8:25 AM, lucas wrote: >> Far as I can see, you never actually called that function anywhere. >> ChrisA > > doesn't the exec command call the function? (Side point: You don't have to post to both comp.lang.python and python-list - they mirror each other.) What you executed

Re: get return or locals from "exec" str in "environment"

2012-08-30 Thread Chris Angelico
On Fri, Aug 31, 2012 at 9:54 AM, lucas wrote: > oh, yeah that was perfect. got it working and it is graceful too. sorry > about the double post, i thought i was only posting to this one. Hehe, you're still posting to both. I don't see the duplicates myself, but I'm sure others do. Just pick on

Re: to know binary

2012-08-31 Thread Chris Angelico
On Sat, Sep 1, 2012 at 2:15 PM, contro opinion wrote: > there is a only line in the file nanmed test: > 1234 > when i open it whit xxd > xxd test > what i get is : > 000: 3132 3334 0a 1234. > can you explain it ? I would explain it as a file with one line named

Re: interfacing with x86_64 assembler

2012-09-01 Thread Chris Angelico
On Sun, Sep 2, 2012 at 10:10 AM, John Ladasky wrote: > I haven't seen this joke on the Net in years, does anyone still remember it? > > "C combines the power of assembly language with the readability and > maintainability of assembly language." Seen it, and it has validity. But I'd rather work w

Re: Changing a Value in List of lists

2012-09-02 Thread Chris Angelico
On Sun, Sep 2, 2012 at 7:44 PM, Rishabh Dixit wrote: > > Hi all, > > I have a doubt regarding how the list work in following case- > ls=[[0]*5]*5 ls[1][1]+=1 ls > [[0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, > 0, 0, 0]] > > > Here, according to me only

Re: newbie ``print`` question

2012-09-02 Thread Chris Angelico
On Mon, Sep 3, 2012 at 7:18 AM, gwhite wrote: > Thanks again, Terry. There is a lot to the language, I am finding > out. I am a HW engineer, not really a programmer. Python seems a lot > more sophisticated than MATLAB. > > I'm kinda thinking `write` is likely to be a little more "stable" than >

Re: newbie ``print`` question

2012-09-02 Thread Chris Angelico
On Mon, Sep 3, 2012 at 9:20 AM, gwhite wrote: > I guess you're saying 3.x will just ignore: > > from __future__ import print_function > > I'll risk being silly, and thus ask: but what if when I get to 3.x > there is no __future__, as it is now "present?" Do I need to strip > out the line? > > Wha

Re: simple client data base

2012-09-03 Thread Chris Angelico
On Tue, Sep 4, 2012 at 12:12 AM, Mark R Rivet wrote: > I have been reading about lists, tuples, and dictionary data > structures in python and I am confused as to which would be more > appropriate for a simple database. I think you're looking at this backwards. A database is for storing informati

Re: Comparing strings from the back?

2012-09-03 Thread Chris Angelico
On Tue, Sep 4, 2012 at 11:54 AM, Roy Smith wrote: > I'm wondering if it might be faster to start at the ends of the strings > instead of at the beginning? > I'm also not sure how this work with all the possible UCS/UTF encodings. > With some of them, you may get the encoding semantics wrong if yo

Re: Comparing strings from the back?

2012-09-04 Thread Chris Angelico
On Wed, Sep 5, 2012 at 2:32 AM, Johannes Bauer wrote: > How do you arrive at that conclusion? When comparing two random strings, > I just derived > > n = (256 / 255) * (1 - 256 ^ (-c)) > > where n is the average number of character comparisons and c. The > rationale as follows: The first character

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Chris Angelico
On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy wrote: > io.open depends on a function the returns an open file descriptor. opener > exposes that dependency so it can be replaced. I skimmed the bug report comments but didn't find an answer to this: Why not just monkey-patch? When a module function ca

Re: How to tell people to ask questions the smart way

2012-09-04 Thread Chris Angelico
On Wed, Sep 5, 2012 at 9:28 AM, Mark Lawrence wrote: > On 05/09/2012 00:05, Ben Finney wrote: >> >>> Look there: >>> http://www.catb.org/esr/faqs/smart-questions.html#forum >> >> The “how to ask question the smart way” essay is not a blunt instrument >> for beating people over the head with, and i

Re: Comparing strings from the back?

2012-09-05 Thread Chris Angelico
On Wed, Sep 5, 2012 at 6:29 PM, Peter Otten <__pete...@web.de> wrote: > comparing every pair in a sample of 1000 8-char words > taken from '/usr/share/dict/words' > > head > 1: 477222 > 2: 18870 ** > ... Not understanding this. What are

Re: sockets,threads and interupts

2012-09-05 Thread Chris Angelico
On Wed, Sep 5, 2012 at 10:54 PM, Ramchandra Apte wrote: > At least on Linux, if you kill a process using sockets, it takes about 10 > seconds for socket to be closed. A program should try to close all resources. > OS'es may take a long time to close a unclosed socket automatically. Err, that's

Re: why did the WindowsError occur?

2012-09-05 Thread Chris Angelico
On Wed, Sep 5, 2012 at 10:51 PM, Ramchandra Apte wrote: > On Wednesday, 5 September 2012 13:21:58 UTC+5:30, Mark Lawrence wrote: >> Because you've done something wrong. If you'd like to tell us what >> you've done to find out where the problem is, we are far more likely to >> help. Please remem

Re: Python Interview Questions

2012-09-05 Thread Chris Angelico
On Thu, Sep 6, 2012 at 12:21 AM, Peter Otten <__pete...@web.de> wrote: > charvigro...@gmail.com wrote: > >> Finally I have decided to put best interview question and answers. >> >> Please visit http://***/web/CorePython/ for core python >> and http://***/web/PythonAdvanced/ for advanced python > >

Re: Python Interview Questions

2012-09-05 Thread Chris Angelico
On Thu, Sep 6, 2012 at 12:34 AM, Chris Angelico wrote: > However, this strikes me as encouraging some really > inefficient code, like iterating over all the rows in a table with N+1 > queries (one to get the length, then a separate query for each row). Huh. And then I scroll down, a

Re: Python Interview Questions

2012-09-05 Thread Chris Angelico
On Thu, Sep 6, 2012 at 1:22 AM, Ian Kelly wrote: > The lack of an ORDER BY is the least of the problems with that SQL. > He's also using LIMIT without OFFSET, so the only thing that the > 'item' argument changes is how many rows are returned (all but one of > which are ignored), not which one is a

Re: Python Interview Questions

2012-09-05 Thread Chris Angelico
On Thu, Sep 6, 2012 at 2:40 AM, Ian Kelly wrote: > On Wed, Sep 5, 2012 at 9:34 AM, Chris Angelico wrote: >> On Thu, Sep 6, 2012 at 1:22 AM, Ian Kelly wrote: >>> The lack of an ORDER BY is the least of the problems with that SQL. >>> He's also using LIMIT withou

Re: is implemented with id ?

2012-09-06 Thread Chris Angelico
On Thu, Sep 6, 2012 at 6:26 PM, Ramchandra Apte wrote: > the is statement could be made into a function It's not a statement, it's an operator; and functions have far more overhead than direct operators. There's little benefit in making 'is' into a function, and high cost; unlike 'print', whose c

Re: is implemented with id ?

2012-09-06 Thread Chris Angelico
On Thu, Sep 6, 2012 at 7:34 PM, Duncan Booth wrote: > Steven D'Aprano wrote: > >> But at any moment, any object has a specific >> location, and no other object can have that same location. Two objects >> cannot both be at the same memory address at the same time. >> > > It is however perfectly po

Re: Need help fixing this error please:NameError: global name is not defined

2012-09-06 Thread Chris Angelico
On Thu, Sep 6, 2012 at 8:45 PM, shaun wrote: > CODE/// > > def databasebatchcall(self,tid, bid): > > con=cx_Oracle.connect('user/user...@odb4.dcc.company/ODB4TEST.COMPANY.COM') > cur = con.cursor() > cur.execute("SELECT * FROM name) >

Re: Need help fixing this error please:NameError: global name is not defined

2012-09-06 Thread Chris Angelico
On Thu, Sep 6, 2012 at 9:37 PM, shaun wrote: > class StringCall: > results=[] > def databasebatchcall(self,termid, batchid): > con = > cx_Oracle.connect('user/user...@odb4.dcc.company.ie/ODB4TEST.COMPANY.IE') > cur = con.cursor() > c

Re: Comparing strings from the back?

2012-09-06 Thread Chris Angelico
n Thu, Sep 6, 2012 at 10:13 PM, Roy Smith wrote: > In article <50485fca$0$29977$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> In any case, the *worst* case for string equality >> testing is certainly O(N) (every character must be looked at), and the >> *best* case is O(1) ob

Re: Need help fixing this error please:NameError: global name is not defined

2012-09-06 Thread Chris Angelico
On Thu, Sep 6, 2012 at 10:07 PM, shaun wrote: > Hi Chris, > > I'm changing it into multiple classes because the script is going to get > much larger its more for maintainability reasons rather than functionality > reasons. Doesn't necessarily have to be multiple classes. Python gives you t

Re: Comparing strings from the back?

2012-09-06 Thread Chris Angelico
On Thu, Sep 6, 2012 at 11:37 PM, Johannes Bauer wrote: > Not in my original post. If you read it again, you will clearly see that > I was talking about purely random strings. And since you like to > nitpick, I'll clarify further: I'm talking about bitstrings in which > every bit of every character

Re: A Python class

2012-09-06 Thread Chris Angelico
On Fri, Sep 7, 2012 at 3:30 AM, Terry Reedy wrote: > On 9/6/2012 11:08 AM, Yves S. Garret wrote: > >> I'd like to know if there are any online Python classes offered >> online from reliable institutions that you would recommend. > > Google 'online programming course python' for taught courses.

Re: Function for examine content of directory

2012-09-06 Thread Chris Angelico
On Fri, Sep 7, 2012 at 12:56 AM, Tigerstyle wrote: > I'm trying to write a module containing a function to examine the contents of > the current working directory and print out a count of how many files have > each extension (".txt", ".doc", etc.) If you haven't already, look into the Python 'd

Re: Accessing dll

2012-09-07 Thread Chris Angelico
On Fri, Sep 7, 2012 at 1:44 AM, Helpful person wrote: > FYI > > My Python version is 2.5.4 You may wish to upgrade, that's quite an old version. Unless something's binding you to version 2.x, I would strongly recommend migrating to 3.2 or 3.3. ChrisA -- http://mail.python.org/mailman/listinfo/p

Re: Division help in python

2012-09-07 Thread Chris Angelico
On Fri, Sep 7, 2012 at 10:53 PM, Ramyasri Dodla wrote: > I am brand new to python. checking over basic stuff. I came across the > problem while doing so. If any body aware of the problem, kindly respond me. > 5/10 > 0 - 5/10 > -1 > > The second case also should yield a 'zero' but it is g

Re: Accessing dll

2012-09-08 Thread Chris Angelico
On Sat, Sep 8, 2012 at 3:27 AM, Helpful person wrote: > On Sep 7, 5:16 am, Chris Angelico wrote: >> On Fri, Sep 7, 2012 at 1:44 AM, Helpful person wrote: >> > FYI >> >> > My Python version is 2.5.4 >> >> You may wish to upgrade, that's quite an

Re: Is there a unique method in python to unique a list?

2012-09-08 Thread Chris Angelico
On Sun, Sep 9, 2012 at 3:43 PM, Token Type wrote: > Is there a unique method in python to unique a list? thanks I don't believe there's a method for that, but if you don't care about order, try turning your list into a set and then back into a list. ChrisA -- http://mail.python.org/mailman/list

Re: Is there a unique method in python to unique a list?

2012-09-08 Thread Chris Angelico
On Sun, Sep 9, 2012 at 4:29 PM, John H. Li wrote: > However, if I don't put list(set(lemma_list)) to a variable name, it works > much faster. Try backdenting that statement. You're currently doing it at every iteration of the loop - that's why it's so much slower. But you'll probably find it b

<    5   6   7   8   9   10   11   12   13   14   >