Re: code review

2012-06-30 Thread Thomas 'PointedEars' Lahn
Peter Otten wrote: > If you spell it > > def is_valid_password(password): > return mud.minpass <= len(password) <= mud.maxpass > > it is even easier to see that you are performing an interval check. This is probably a tautology around here, but *what* *a* *great* *programming* *language*.

Re: Re: code review

2012-07-01 Thread Thomas &#x27;PointedEars&#x27; Lahn
Evan Driscoll wrote: > On 6/30/2012 19:37, Chris Angelico wrote: >> On Sun, Jul 1, 2012 at 10:08 AM, Ben Finney >> wrote: >>> I know of no programming language that >>> would give a newcomer to Python that expectation. So where is the norm >>> you're referring to? >> >> C, SQL, REXX, and many ot

Re: code review

2012-07-01 Thread Thomas &#x27;PointedEars&#x27; Lahn
Evan Driscoll wrote: > On 6/30/2012 23:45, Evan Driscoll wrote: >> You may also >> want to put Java in there as well, as < is effectively not commutative >> in that language. (I didn't try C#.) > > I guess you could actually put Lua and Ruby into the roughly same > category as Java too. > > But

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Thomas &#x27;PointedEars&#x27; Lahn
Jan Riechers wrote: > I have one very basic question about speed,memory friendly coding, and > coding style of the following easy "if"-statement in Python 2.7, but Im > sure its also the same in Python 3.x > > Block > #-- > if statemente_true: > doSomething() > els

Re: Is Python a commercial proposition ?

2012-07-29 Thread Thomas &#x27;PointedEars&#x27; Lahn
Michael Hrivnak wrote: > Python is used frequently on the server side of web applications for > sites of all sizes, with the UI generally being done in javascript. There is no javascript. -- PointedEars Please do not Cc: me. / Bitte keine Kopien per E-Mail. -- http://mail.python.org/mailman/l

[OT] A short Usenet primer (was: How to uncompress a VOB file? (Win XP))

2012-08-14 Thread Thomas &#x27;PointedEars&#x27; Lahn
Mark Lawrence wrote: > On 14/08/2012 00:00, Xantipius wrote: >> On Aug 13, 3:40 pm, Mark Lawrence wrote: >>> On 13/08/2012 11:18, Xantipius wrote: subj >>> >>> Either >>> >>> a) write some code and when and if it fails give us a small code snippet >>> that demonstates the problem with the co

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

2012-08-14 Thread Thomas &#x27;PointedEars&#x27; Lahn
Mark Lawrence wrote: > On 14/08/2012 04:00, Steven D'Aprano wrote: >> On Tue, 14 Aug 2012 01:34:46 +0100, Mark Lawrence wrote: >>> When did you seek my permission to call me by my forename? >> Sheesh. It's 2012, not 1812. If you sign your posts with your full name, >> you have to expect that peopl

Re: [OT] Posting under ones full name

2012-08-14 Thread Thomas &#x27;PointedEars&#x27; Lahn
Chris Angelico wrote: > Thomas 'PointedEars' Lahn wrote: >> Probably you were asked that so that your postings could be distinguished >> from that of the other potential Marks around here. > > I have my surname in my From address, but I tend to sign my posts &

Re: [OT] Posting under ones full name

2012-08-15 Thread Thomas &#x27;PointedEars&#x27; Lahn
Chris Angelico wrote: > Thomas 'PointedEars' Lahn wrote: >> Chris Angelico wrote: >>> I have my surname in my From address, but I tend to sign my posts >>> "ChrisA" (no relation, btw, to DaveA, though our surnames are >>> similar). That

Re: simple client data base

2012-09-03 Thread Thomas &#x27;PointedEars&#x27; Lahn
Mark R Rivet wrote: > Hello all, I am learning to program in python. I have a need to make a > program that can store, retrieve, add, and delete client data such as > name, address, social, telephone number and similar information. This > would be a small client database for my wife who has a home

Re: python docs search for 'print'

2012-09-04 Thread Thomas &#x27;PointedEars&#x27; Lahn
David Hoese wrote: > A friend made me aware of this: > When a python beginner (2.x) quick searches for "print" on > docs.python.org, the print function doesn't even come up in the top 20 > results. The print statement isn't even listed as far as I can tell. > Is there something that can be done a

Mailergate (was: python docs search for 'print')

2012-09-05 Thread Thomas &#x27;PointedEars&#x27; Lahn
Stephen D'Aprano wrote: > On Tue, 04 Sep 2012 20:27:38 +0200, Thomas 'PointedEars' Lahn wrote: >> ¹ The other mess they created (or allowed to be created) is this mashup >>of newsgroup and mailing list, neither of which works properly, > > In what

Re: simple client data base

2012-09-11 Thread Thomas &#x27;PointedEars&#x27; Lahn
Mark R Rivet wrote: > Thomas 'PointedEars' Lahn wrote: >> Mark R Rivet wrote: >>> Hello all, I am learning to program in python. I have a need to make a >>> program that can store, retrieve, add, and delete client data such as >>> name, address, so

Re: global vars across modules

2012-04-25 Thread Thomas &#x27;PointedEars&#x27; Lahn
John Nagle wrote: > On 4/22/2012 12:39 PM, [email protected] wrote: >> Question: >> How can I access to the global 'a' in file_2 without resorting to the >> whole name 'file_1.a' ? > > Actually, it's better to use the fully qualified name "file_1.a". > Using "import *" brings in everythin

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Thomas &#x27;PointedEars&#x27; Lahn
Marco wrote: > Hi all, because > > "There should be one-- and preferably only one --obvious way to do it", > > there should be a difference between the two methods in the subject, but > I can't find it: > > >>> '123'.isdecimal(), '123'.isdigit() > (True, True) > >>> print('\u0660123') > ٠123

Re: Rant on web browsers

2011-06-22 Thread Thomas &#x27;PointedEars&#x27; Lahn
[I am biting only because this is my field of expertise, and I am really getting tired reading from people not having a shadow of a trace of a minimum clue what these languages that I like can and can't do.] Chris Angelico wrote: > Random rant and not very on-topic. Feel free to hit Delete and

Re: writable iterators?

2011-06-22 Thread Thomas &#x27;PointedEars&#x27; Lahn
Mel wrote: > Steven D'Aprano wrote: >> I *guess* that what you mean by "writable iterators" is that rebinding e >> should change seq in place, i.e. you would expect that seq should now >> equal [42, 42]. Is that what you mean? It's not clear. >> >> Fortunately, that's not how it works, and far fr

Re: writable iterators?

2011-06-23 Thread Thomas &#x27;PointedEars&#x27; Lahn
[Sorry for over-quoting, I am not sure how to trim this properly] Steven D'Aprano wrote: > On Thu, 23 Jun 2011 09:30 am Thomas 'PointedEars' Lahn wrote: >> Mel wrote: >>> Steven D'Aprano wrote: >>>> I *guess* that what you mean by "writabl

Re: What does "shell introspection" mean?

2011-06-26 Thread Thomas &#x27;PointedEars&#x27; Lahn
Juan Kinunt wrote: > In the PyDev installation documentation you see this sentence: > > "The Forced builtin libs are the libraries that are built-in the > interpreter, such as __builtin__, sha, etc or libraries that should > forcefully analyzed through shell introspection (the other option to > a

Re: Is the Usenet to mailing list gateway borked?

2011-06-29 Thread Thomas &#x27;PointedEars&#x27; Lahn
Andrew Berg wrote: > […] As for your question in the Subject, I do not know since I am reading the newsgroup. Therefore, however, I can tell you that the mailing list to Usenet gateway is seriously borked, as missing References header fields are not generated by the gateway. As a result, the

Re: Is the Usenet to mailing list gateway borked?

2011-06-30 Thread Thomas &#x27;PointedEars&#x27; Lahn
Thomas Guettler wrote: > On 30.06.2011 03:24, Thomas 'PointedEars' Lahn wrote: >> Andrew Berg wrote: >>> […] >> >> As for your question in the Subject, I do not know since I am reading the >> newsgroup. >> >> Therefore, however, I

Re: Is the Usenet to mailing list gateway borked?

2011-07-02 Thread Thomas &#x27;PointedEars&#x27; Lahn
TP wrote: > Thomas 'PointedEars' Lahn wrote: >> [Why are threads broken in the newsgroup?] > > Not sure if this is relevant. I use mail.google.com to follow mailing > lists and a large proportion of python-list traffic ends up in my > gmail spam folder for some re

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Thomas &#x27;PointedEars&#x27; Lahn
Thorsten Kampe wrote: > * Andrew Berg (Sun, 17 Jul 2011 05:02:22 -0500) >> I still don't understand. Whitespace to the left of an assignment to >> signify an indent and whitespace around operators to align values (in >> a multi-line assignment) are not the same. > > When I'm (consistently, of cou

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Thomas &#x27;PointedEars&#x27; Lahn
Dotan Cohen wrote: > On Sat, Jul 16, 2011 at 19:51, rantingrick wrote: >> -- >> Evidence: Tabs ARE superior! >> -- > > I am also a recent spaces-to-tabs convert. One of the reasons is that > I've disc

Re: a little parsing challenge ☺

2011-07-17 Thread Thomas &#x27;PointedEars&#x27; Lahn
Chris Angelico wrote: > On Sun, Jul 17, 2011 at 5:47 PM, Xah Lee wrote: >> the problem is to write a script that can check a dir of text files >> (and all subdirs) and reports if a file has any mismatched matching >> brackets. > > I wonder will it be possible to code the whole thing as a single

Re: Ordered list question

2011-07-17 Thread Thomas &#x27;PointedEars&#x27; Lahn
[email protected] wrote: ^^ Something is missing there. > I'm currently working on a project where I'm looping through xml elements, > pulling the 'id' attribute (which will be coerced to a number) No, usually it won't. > as well as the element tag. That's element _type name_.

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Thomas &#x27;PointedEars&#x27; Lahn
Thorsten Kampe wrote: > * Thomas 'PointedEars' Lahn (Sun, 17 Jul 2011 14:35:15 +0200) >> Thorsten Kampe wrote: >> > * Andrew Berg (Sun, 17 Jul 2011 05:02:22 -0500) >> >> I still don't understand. Whitespace to the left of an assignment >> >>

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Thomas &#x27;PointedEars&#x27; Lahn
Anders J. Munch wrote: > Steven D'Aprano wrote: >> I can't fathom why 8 position tabs were *ever* the default, let alone >> why they are still the default. > > That's because they were not invented as a means for programmers to vary > indentation. > > Originally, tabs were a navigation device: W

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Thomas &#x27;PointedEars&#x27; Lahn
Dotan Cohen wrote: > On Sun, Jul 17, 2011 at 15:53, Thomas 'PointedEars' Lahn >> […] I do not understand how you can consider using a non-fixed-width >> font in programming "a real pleasure" as many them show a lot of >> ambiguities in source code. T

Re: a little parsing challenge ☺

2011-07-17 Thread Thomas &#x27;PointedEars&#x27; Lahn
Raymond Hettinger wrote: > Thomas 'PointedEars' Lahn wrote: >> Did you notice the excessive crosspost? Please do not feed the troll. > > IMO, this was a legitimate cross post since it is for a multi-language > programming challenge and everyone can learn from compa

Re: a little parsing challenge ☺

2011-07-17 Thread Thomas &#x27;PointedEars&#x27; Lahn
Thomas 'PointedEars' Lahn wrote: > It is possible [to parse the parentheses language], with Perl-compatible > Regular Expressions (PCRE), provided that you have enough memory, to use > such an extended Regular Expression (not to be confused with EREs³)⁴: > > \((([^()

Re: a little parsing challenge ☺

2011-07-18 Thread Thomas &#x27;PointedEars&#x27; Lahn
Rouslan Korneychuk wrote: > I don't know why, but I just had to try it (even though I don't usually > use Perl and had to look up a lot of stuff). I came up with this: I don't know why … you replied to my posting/e-mail (but quoted nothing from it, much less referred to its content), and posted

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-18 Thread Thomas &#x27;PointedEars&#x27; Lahn
Gregory Ewing wrote: > Anders J. Munch wrote: >> > Cameron Simpson wrote: >> >> Personally, I like to use the tab _key_ as an input device, but to >> >> have my editor write real spaces to the file in consequence. >> Just like in the old days:) > > Most editors can be configured to do that. T

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-18 Thread Thomas &#x27;PointedEars&#x27; Lahn
Anssi Saari wrote: > Thorsten Kampe writes: >> The "perfect programming font" is just the one that looks so good that >> you would also use it for writing email. Dejavu Sans Mono is pretty >> good. Consolas looks also looks good but it is Windows only. > > How is Consolas Windows only? Not that

Re: a little parsing challenge ☺

2011-07-18 Thread Thomas &#x27;PointedEars&#x27; Lahn
rsed the order in the report line as I think it is more natural this way. I have tested the code superficially with a directory containing a single text file. Watch for word-wrap: # encoding: utf-8 ''' Created on 2011-07-18 @author: Thomas 'PointedEars' L

Re: Partial Function Application -- Advantages over normal function?

2011-07-18 Thread Thomas &#x27;PointedEars&#x27; Lahn
Dave Angel wrote: > On 01/-10/-28163 02:59 PM, Terry Reedy wrote: >> def makeadder(y) >> def _add(x): return x+y >> add2 = makeadder(2) > > A couple of typos in that code: > > > def makeaddr(y): > def _add(x): return x+y > return _add I agree about the `return' statement, but not

Re: Partial Function Application -- Advantages over normal function?

2011-07-18 Thread Thomas &#x27;PointedEars&#x27; Lahn
Thomas 'PointedEars' Lahn wrote: > Dave Angel wrote: >> On 01/-10/-28163 02:59 PM, Terry Reedy wrote: >>> def makeadder(y) >>> def _add(x): return x+y >>> add2 = makeadder(2) >> >> A couple of typos in that code: >> >>

Re: a little parsing challenge ☺

2011-07-18 Thread Thomas &#x27;PointedEars&#x27; Lahn
Thomas 'PointedEars' Lahn wrote: > with open(os.path.join(dirpath, name), 'r') as f: SHOULD be with open(os.path.join(dirpath, name), 'rb') as f: (as in the original), else the some code units might not be read properly. -- PointedEa

Re: os.path.isdir do not work for Foder named '2011-07-03'

2011-07-18 Thread Thomas &#x27;PointedEars&#x27; Lahn
Steven D'Aprano wrote: > Nulpum wrote: >> I want to make sure that folder exists. >> >> '2011-07-03' is really exists. but 'os.path.isdir' say false >> >> Does anyone know why? > > Yes. > print "logs/2011-07-03" > logs/2011-07-03 print "logs\2011-07-03" > logs�1-07-03 > > Don't use

Re: PEP 8 and extraneous whitespace

2011-07-21 Thread Thomas &#x27;PointedEars&#x27; Lahn
Dan Sommers wrote: > [email protected] wrote: >> 1/ you can consider the equal sign ('=') is the "binding operator". >> >> 2/ since {'key':'val'} is equivalent to dict(key=val), you can consider >> colons as a binding operator here > > But PEP 8 (under Other Recommendations) indicate

Re: Convert '165.0' to int

2011-07-21 Thread Thomas &#x27;PointedEars&#x27; Lahn
Billy Mays wrote: > On 07/21/2011 08:46 AM, Web Dreamer wrote: >> If you do not want to use 'float()' try: >> >> int(x.split('.')[0]) > > This is right. Assuming that the value of `x' is in the proper format, of course. Else you might easily cut to the first one to three digits of a string rep

Re: A little complex usage of Beautiful Soup Parsing Help!

2011-07-21 Thread Thomas &#x27;PointedEars&#x27; Lahn
SAKTHEESH wrote: > I am using Beautiful Soup to parse a html to find all text that is Not > contained inside any anchor elements > > I came up with this code which finds all links within href _anchors_ _with_ `href' _attribute_ (commonly: links.) > but not the other way around. What would tha

Re: Convert '165.0' to int

2011-07-24 Thread Thomas &#x27;PointedEars&#x27; Lahn
Billy Mays wrote: > On 7/21/2011 10:40 PM, Thomas 'PointedEars' Lahn wrote: >> Billy Mays wrote: >>> On 07/21/2011 08:46 AM, Web Dreamer wrote: >>>> If you do not want to use 'float()' try: >>>> >>>> int(x.split('.

Re: can I use element tree for handling special characters in xml text?

2011-07-27 Thread Thomas &#x27;PointedEars&#x27; Lahn
hackingKK wrote: > I have been waiting a lot to ask this question and I did ask some days > back but probably could not put it the proper way. You still can't. But to spare everyone yet another try: > I want to know how I can safely include

Re: PEP 8 and extraneous whitespace

2011-07-27 Thread Thomas &#x27;PointedEars&#x27; Lahn
Chris Rebert wrote: > John Gordon wrote: >> Neil Cerutti writes: >>> You can fit much more code per unit of horizontal space with a >>> proportionally spaced font. As a result, that issue, while valid, >>> is significantly reduced. >> >> Is it? I assume one major reason for the 80-character limit

Re: Pipe in the "return" statement

2011-07-27 Thread Thomas &#x27;PointedEars&#x27; Lahn
Ethan Furman wrote: > Billy Mays wrote: >> On 07/25/2011 10:16 AM, Archard Lias wrote: >>> On Jul 25, 2:03 pm, Ian Collins wrote: On 07/26/11 12:00 AM, Archard Lias wrote: > Still I dont get how I am supposed to understand the pipe and its > task/ idea/influece on control flow, of: >

Re: PEP 8 and extraneous whitespace

2011-08-01 Thread Thomas &#x27;PointedEars&#x27; Lahn
OKB (not okblacke) wrote: > Thomas 'PointedEars' Lahn wrote: >> Automatic word-wrap, where available, really is not a solution; it >> is a bad workaround to a problem caused by the original author of >> the source code that can be easily avoided by them t

Re: string to unicode

2011-08-15 Thread Thomas &#x27;PointedEars&#x27; Lahn
thon-is-there-a-way-to- determine-the-encoding-of-text-file> Improving Billy Mays' "matching brackets" checker, chardet worked for me (the test file was UTF-8-encoded). Watch for word-wrap: --- # encoding

Re: Design principles: no bool arguments

2011-08-25 Thread Thomas &#x27;PointedEars&#x27; Lahn
Stefan Behnel wrote: > Maarten, 25.08.2011 09:52: >> On Aug 25, 9:13 am, Steven D'Aprano wrote: >>> One design principle often mentioned here (with a certain degree of >>> disagreement[1]) is the idea that as a general rule, you shouldn't write >>> functions that take a bool argument to switch bet

Re: Design principles: no bool arguments

2011-08-25 Thread Thomas &#x27;PointedEars&#x27; Lahn
Stefan Behnel wrote: > Thomas 'PointedEars' Lahn, 25.08.2011 11:29: >> Stefan Behnel wrote: >>> It's totally unreadable to find this in the code: >>> >>> data1.merge_with(data2, true); >>> >>> Requires you to either a

Re: Design principles: no bool arguments

2011-08-26 Thread Thomas &#x27;PointedEars&#x27; Lahn
Ian Kelly wrote: > Thomas 'PointedEars' Lahn wrote: >> Both variants work (even in Py3) if you only define [a named argument]. >> You have to define [a keyword argument, e.g. `kwargs']. >> >> so that >> >> data1.merge_with(data2, True); &

Re: Python IDE/Eclipse

2011-08-26 Thread Thomas &#x27;PointedEars&#x27; Lahn
Dave Boland wrote: > I'm looking for a good IDE -- easy to setup, easy to use -- for Python. > Any suggestions? PyDev (currently 2.2.1.2011073123, from the Aptana Studio 3.0.4 Plugin; but I can see that 2.2.2 has been released). > I use Eclipse for other projects and have no problem with usin

Re: Installing WebDAV server

2011-08-30 Thread Thomas &#x27;PointedEars&#x27; Lahn
Fokke Nauta wrote: > I'm running a PC with XP Pro32, […] > To do some research with some calender systems and to share the Outlook > calendar I need a WebDAV server. After googling I found the Python WebDAV > server. > I installed Python 3.2.1 and extracted the packages PyWebDAV and PyXML. > Now I

Re: Installing WebDAV server

2011-08-30 Thread Thomas &#x27;PointedEars&#x27; Lahn
Fokke Nauta wrote: > "Thomas 'PointedEars' Lahn" wrote in message > news:[email protected]... It's attribution _line_, not attribution novel. Your quotes are hardly legible, too → <http://insideoe.com/> >> Fokke Nauta wrote: >>

Re: Installing WebDAV server

2011-09-03 Thread Thomas &#x27;PointedEars&#x27; Lahn
Fokke Nauta wrote: > "Thomas 'PointedEars' Lahn" […]: >> Fokke Nauta wrote: >>> "Thomas 'PointedEars' Lahn" […] wrote: >>>> The Python shell executes Python code. The above obviously is not >>>> Python >>&g

Re: Installing WebDAV server

2011-09-04 Thread Thomas &#x27;PointedEars&#x27; Lahn
Fokke Nauta wrote: > "Thomas 'PointedEars' Lahn" wrote in message > news:[email protected]... > > > > If you don't have anything better to contribute, please stop answering. > > Es gen�gt schon. I should have

Re: Floating point multiplication in python

2011-09-06 Thread Thomas &#x27;PointedEars&#x27; Lahn
Thomas Rachel wrote: > Now if you multiply two values with an error, the error also propagates > into the result - PLUs the result can have its own error source - in the > same order of magnitude. > > (a+e) * (a+e) = a*a + 2*a*e + e*e. So your new error term is 2*a*e + e*e > or (2*a + e) * e. Yo

Re: detecting newline character

2011-04-23 Thread Thomas &#x27;PointedEars&#x27; Lahn
Daniel Geržo wrote: > I need to detect the newline characters used in the file I am reading. > For this purpose I am using the following code: > > def _read_lines(self): > with contextlib.closing(codecs.open(self.path, "rU")) as fobj: > fobj.readlines() > if isinstance(fobj

Re: detecting newline character

2011-04-23 Thread Thomas &#x27;PointedEars&#x27; Lahn
Chris Rebert wrote: > On Sat, Apr 23, 2011 at 11:09 AM, Daniel Geržo wrote: >> I need to detect the newline characters used in the file I am reading. >> For this purpose I am using the following code: >> >> def _read_lines(self): >> with contextlib.closing(codecs.open(self.path, "rU")) as fob

Re: detecting newline character

2011-04-23 Thread Thomas &#x27;PointedEars&#x27; Lahn
Daniel Geržo wrote: > Thomas 'PointedEars' Lahn wrote: >> Chris Rebert wrote: >>> Daniel Geržo wrote: >>>> [f.newlines is None after f.readlines() >>>> when f = codecs.open(…, mode='rU', encoding='ascii'), >>>>

Re: detecting newline character

2011-04-24 Thread Thomas &#x27;PointedEars&#x27; Lahn
Daniel Geržo wrote: > On 24.4.2011 9:05, jmfauth wrote: >> Use the io module. > > For the record, when I use io.open(file=self.path, mode="rt", > encoding=enc)) as fobj: > > my tests are passing and everything seems to work fine. > > That indicates there is a bug with codecs module and universa

Re: detecting newline character

2011-04-24 Thread Thomas &#x27;PointedEars&#x27; Lahn
Daniel Geržo wrote: > Thomas 'PointedEars' Lahn wrote: >> It is clear now that codecs.open() would not support universal newlines >> from at least Python 2.6 forward as it is *documented* that it opens >> files in *binary mode* only. The source code that I have po

[SOLVED] detecting newline character

2011-04-24 Thread Thomas &#x27;PointedEars&#x27; Lahn
Daniel Geržo wrote: > On 23.4.2011 21:18, Thomas 'PointedEars' Lahn wrote: >> Daniel Geržo wrote: >>> [f = codecs.open(…, mode='rU', encoding='ascii') and f.newlines] >> >> […] >> The only reason I can think of for this not

Re: Reliably call code after object no longer exists or is "unreachable"?

2011-04-27 Thread Thomas &#x27;PointedEars&#x27; Lahn
Jack Bates wrote: > Python's __del__ or destructor method works (above) - but only in the > absence of reference cycles (below). An object, with a __del__ method, > in a reference cycle, causes all objects in the cycle to be > "uncollectable". This can cause memory leaks and because the object is

Re: use of index (beginner's question)

2011-04-27 Thread Thomas &#x27;PointedEars&#x27; Lahn
Chris Angelico wrote: > Rusty Scalf wrote: >> list1 = ['pig', 'horse', 'moose'] >> list2 = ['62327', '49123', '79115'] >> n = 2 >> s2 = "list" + `n` I would prefer the clearer s2 = "list" + str(n) or s2 = "list%s" % n >> a = s2[list1.index('horse')] >> print a > > s2 is a string with th

Re: Zope with mySQL

2011-04-30 Thread Thomas &#x27;PointedEars&#x27; Lahn
harryjatt wrote: > Hi, i am doing web development with Zope. My connected database is mySQL. > I am new to this combination.I have to upload the files to mySQL with > programming in zope and then downloading them via zope.Can you help me in > this regard? Perhaps. > I will be very thankfull to y

Re: Python competitions and learnings

2011-05-01 Thread Thomas &#x27;PointedEars&#x27; Lahn
harrismh777 wrote: > Terry Reedy wrote: >>> And Im looking for feedback from peoples who best in python. Here I >>> make some video tutorial about this service http://checkio.blip.tv/ >>> >>> What do you think about it? >> >> Pretty impressive. My main disappointment is that you are using 2.7 >>

Re: Customize help output from optparse (or argparse)

2011-05-12 Thread Thomas &#x27;PointedEars&#x27; Lahn
Thorsten Kampe wrote: > I'm using optparse for a little Python script. > > 1. The output from "--help" is: > """ > Usage: script.py > > script.py does something > > Options: > -h, --help show this help message and exit > """ > > I would prefer to have the description before the usage, lik

Re: list equal to subclass of list?

2011-05-12 Thread Thomas &#x27;PointedEars&#x27; Lahn
Ethan Furman wrote: > PS > I have a broken sense of humor -- sometimes it works, sometimes it > doesn't. My apologies in advance if my attempt at humor was not funny. Now that was very unpythonic. Know where your roots are! :) -- PointedEars Bitte keine Kopien per E-Mail. / Please do not Cc:

Re: Need Assistance on this program.

2011-05-12 Thread Thomas &#x27;PointedEars&#x27; Lahn
vijay swaminathan wrote: > I have already done that. But for some reason my response went > as a new thread. Attaching the code again. JFYI: Please DO NOT post attachments in a non-binary newsgroup or to a mailing list (are there binary ones at all?) again. TIA. -- PointedEars Bitte keine Kop

Re: connect SIGINT to custom interrupt handler

2011-05-15 Thread Thomas &#x27;PointedEars&#x27; Lahn
Christoph Scheingraber wrote: > I now have signal.siginterrupt(signal.SIGINT, False) in the line > below signal.signal(signal.SIGINT, interrupt_handler) > > Unfortunately, pressing ^c still results in the same interrupt error. I > also tried putting signal.siginterrupt into the interrupt_handler

Re: connect SIGINT to custom interrupt handler

2011-05-20 Thread Thomas &#x27;PointedEars&#x27; Lahn
Christoph Scheingraber wrote: > On 2011-05-15, Thomas 'PointedEars' Lahn wrote: >> Obviously. `signal' refers to an `int' object, probably by something >> like >> >> signal = 42 >> >> before. E.g. `print' or a debugger will te

Re: and becomes or and or becomes and

2011-05-22 Thread Thomas &#x27;PointedEars&#x27; Lahn
Stef Mientki wrote: > must of us will not use single bits these days, > but at first sight, this looks funny : > a=2 b=6 a and b > 6 a & b > 2 a or b > 2 a | b > 6 Change the order of the operands and see what happens. -- PointedEars Bitte keine Kopien per E-Mail

Re: Weird problem matching with REs

2011-05-29 Thread Thomas &#x27;PointedEars&#x27; Lahn
Andrew Berg wrote: > On 2011.05.29 10:19 AM, Roy Smith wrote: >> Named after the governor of Tarsus IV? > Judging by the graphic at http://kodos.sourceforge.net/help/kodos.html , > it's named after the Simpsons character. I don't think that's a coincidence; both are from other planets and both

Re: manually sorting images?

2016-09-04 Thread Thomas &#x27;PointedEars&#x27; Lahn
Ulli Horlacher wrote: > I need to sort images (*.jpg), visually, not by file name. > It looks, there is no standard UNIX tool for this job? Depends. What are the sort keys? -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. -- https://mail.python.org/

Re: Expression can be simplified on list

2016-09-12 Thread Thomas &#x27;PointedEars&#x27; Lahn
Chris Angelico wrote: > On Mon, Sep 12, 2016 at 9:14 PM, Daiyue Weng wrote: >> Hi, I found that when I tried to make an equality test on empty like, >> >> if errors == []: >> >> PyCharm always warns me, >> >> Expression can be simplified. >> >> I am wondering what's wrong and how to fix this? >>

Re: How to extend a tuple of tuples?

2016-09-13 Thread Thomas &#x27;PointedEars&#x27; Lahn
John Gordon wrote: > […] Thomas 'PointedEars' Lahn […] writes: It is supposed to be an attribution *line*, _not_ an attribution novel. >> >> The obvious way does not work - >> >> >> >> a += (5, 6) >> ^^ >>

Re: Expression can be simplified on list

2016-09-13 Thread Thomas &#x27;PointedEars&#x27; Lahn
Chris Angelico wrote: > […] Thomas 'PointedEars' Lahn […] wrote: >> If I knew that it is always going to be a list or a tuple, I would check >> its length instead: >> >> if len(errors) == 0: > > I wouldn't. I'd use boolification here too.

Re: correct way to catch exception with Python 'with' statement

2016-11-28 Thread Thomas &#x27;PointedEars&#x27; Lahn
Ganesh Pal wrote: > I am using Python 2.7 and Linux As a rule of thumb¹, use at least Python 3.3 for new programs. > What will be the best way to catch the exception in the above program ? > Can we replace both the with statement in the above program with > something like below > > try: >

Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Thomas &#x27;PointedEars&#x27; Lahn
Juan C. wrote: > I'm watching a Python course and was presented a topic regarding classes. > One of the examples were: > > box.py > > class Box: > serial = 100 > > def __init__(self, from_addr, to_addr): > self.from_addr = from_addr > self.to_addr = to_addr > sel

Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Thomas &#x27;PointedEars&#x27; Lahn
Thomas 'PointedEars' Lahn wrote: > Note that (AIUI) in this example the instances of the class referred by > “C” do not have an *own* “foo” property in the beginning, so until bar() > is called on them, they inherit that property (and its value) from that > class

Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Thomas &#x27;PointedEars&#x27; Lahn
Juan C. wrote: > On Mon, Dec 12, 2016 at 12:34 PM, Thomas 'PointedEars' Lahn > wrote: >> To call something means generally in programming, and in Python, to >> execute it as a function instead: In the code above, the class object >> referred to by “Box” is ca

Re: Python constructors have particular semantics, and ‘Foo.__init__’ doesn't qualify

2016-12-15 Thread Thomas &#x27;PointedEars&#x27; Lahn
Ben Finney wrote: > Chris Angelico writes: >> On Tue, Dec 13, 2016 at 10:17 AM, Ben Finney >> wrote: >> > If the differences didn't matter I would agree that “overly >> > pedantic” is fair. But those differences trip up newcomers. Thinking >> > of ‘Foo.__init__’ leads people to wonder where the

Re: The right way to 'call' a class attribute inside the same class

2016-12-19 Thread Thomas &#x27;PointedEars&#x27; Lahn
Chris Angelico wrote: > On Mon, Dec 19, 2016 at 9:52 AM, Erik wrote: >> 1) Method call: >>"obj.foo(1, 2, 3)" is syntactic sugar for "obj.foo(obj, 1, 2, 3)". > > And the bit you have to be REALLY careful of when working with both > Python and JS is that you have to have "obj.foo(...)" as a si

Reviews of book on introductory Python (was: Need reviews for my book on introductory python)

2017-01-28 Thread Thomas &#x27;PointedEars&#x27; Lahn
mm0fmf wrote: > […] Python, the name of the language, is a proper noun and should be > captialised. In the few pages I read, Python appears as "python" and > "Python", randomly losing the capital letter. Lacking capitalisation > would suggest to me that some or all words are consistently written >

Re: [beginner] What's wrong?

2016-04-02 Thread Thomas &#x27;PointedEars&#x27; Lahn
Marko Rauhamaa wrote: > Steven D'Aprano : >> So you're saying that learning to be a fluent speaker of English is a >> pre-requisite of being a programmer? > > No more than learning Latin is a prerequisite of being a doctor. Full ACK. Probably starting with the Industrial Revolution enabled by t

Re: writing to command line thru python gui

2016-04-02 Thread Thomas &#x27;PointedEars&#x27; Lahn
A. ElKader wrote: > I posted this question, no reply : > > Any advice : > > http://unix.stackexchange.com/questions/273573/write-to-terminal-in-tkinter-gui I do not think that this newsgroup/mailing list is meant as an advertisement board to get your questions answered on Q&A forums on the Web

Re: [beginner] What's wrong?

2016-04-03 Thread Thomas &#x27;PointedEars&#x27; Lahn
Michael Torrie wrote: > Mark, your messages are showing up to the list as being from "python," > at least on my email. Any reason for this? Depends on which Mark you are addressing and how you are reading e-mail. The messages of Mark Lawrence, for example, appear to me as technically correct a

Re: [beginner] What's wrong?

2016-04-03 Thread Thomas &#x27;PointedEars&#x27; Lahn
Rustom Mody wrote: > On Saturday, April 2, 2016 at 10:42:27 PM UTC+5:30, Thomas 'PointedEars' > Lahn wrote: >> Marko Rauhamaa wrote: >> > Steven D'Aprano : >> >> So you're saying that learning to be a fluent speaker of English is a >>

Re: Import graphics error

2016-04-05 Thread Thomas &#x27;PointedEars&#x27; Lahn
Nicolae Morkov wrote: > […] > *Following the instructions I copied The graphic modules by John Zelle in > Python folder in Lib folder * > **And when I installed graphic library the error was :* * > > Traceback (most recent call last): > File > "C:/Users/Nicolae/AppData/Local/Programs/Python/Pytho

Re: WP-A: A New URL Shortener

2016-04-06 Thread Thomas &#x27;PointedEars&#x27; Lahn
Chris Angelico wrote: > In other words, you are assuming that the string escaping *in the > module* is buggy. Well, duh. This is exactly what I said about not > having stupid bugs. The developer of a MySQL binding library should > know the *entire* rules for escaping, and, duh, that's going to > i

Re: [beginner] What's wrong?

2016-04-06 Thread Thomas &#x27;PointedEars&#x27; Lahn
Rustom Mody wrote: > On Sunday, April 3, 2016 at 5:17:36 PM UTC+5:30, Thomas 'PointedEars' Lahn > wrote: >> Rustom Mody wrote: >> > When python went to full unicode identifers it should have also added >> > pragmas for which blocks the programmer intended

Re: function to remove and punctuation

2016-04-10 Thread Thomas &#x27;PointedEars&#x27; Lahn
Peter Otten wrote: > [email protected] wrote: >> how to write a function taking a string parameter, which returns it after >> you delete the spaces, punctuation marks, accented characters in python ? > > Looks like you want to remove more characters than you want to keep. In > this case I'd decid

String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?)

2016-05-08 Thread Thomas &#x27;PointedEars&#x27; Lahn
DFS wrote: > sSQL = "line 1\n" > sSQL += "line 2\n" > sSQL += "line 3" What is wrong with it in Python is that it is unnecessarily inefficient. Python has implicit string concatenation if all operands are string literals: #-

Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-10 Thread Thomas &#x27;PointedEars&#x27; Lahn
DFS wrote: > On 5/8/2016 8:44 PM, Thomas 'PointedEars' Lahn wrote: >> DFS wrote: >>> sSQL = "line 1\n" >>> sSQL += "line 2\n" >>> sSQL += "line 3" >> >> […] >> #

Re: making executables smaller

2016-07-27 Thread Thomas &#x27;PointedEars&#x27; Lahn
Carter Temm wrote: > I’m writing a couple different projects at the moment, and when I compile > it into a single executable using pyinstaller, it becomes extremely large. > I’m guessing this is because of the modules used. Because I’m not that > skilled at python, I put stuff like for example, im

Re: use import *

2016-08-01 Thread Thomas &#x27;PointedEars&#x27; Lahn
Ganesh Pal wrote: > is it a good programming practice to use [from … ] import * ? No; but it is not as harmful as one would think either. > if answer is "NO " then are there situation where you are forced to use > impo

Re: if else python

2015-11-25 Thread Thomas &#x27;PointedEars&#x27; Lahn
Scott Montreuil wrote: > I have an if statement which seems to run both commands and I cannot > figure out why. (just learning so I may be missing something obvious) Any > ideas? Use a Python IDE and debugger. I recommend PyDev, but YMMV. > while True: > global latit,longt,jlatit,jlongt

Re: Accessing container's methods

2015-12-07 Thread Thomas &#x27;PointedEars&#x27; Lahn
Tony van der Hoff wrote: > I have a class A, containing embedded embedded classes, which need to > access methods from A. Let the name of the "embedded class" (which is not embedded at all in your example code) be E. You could either store the information in the E instance upon or after constr

Re: Accessing container's methods

2015-12-07 Thread Thomas &#x27;PointedEars&#x27; Lahn
Michael Torrie wrote: > On 12/07/2015 11:10 AM, Tony van der Hoff wrote: >> I have a class A, containing embedded embedded classes, which need to >> access methods from A. >> . >> A highly contrived example, where I'm setting up an outer class in a >> Has-a relationship, containing a number of Act

  1   2   3   >