Re: int vs. float

2017-02-10 Thread Dan Sommers
On Fri, 10 Feb 2017 20:46:16 +, Erik wrote: > Python 3.5.2 (default, Nov 17 2016, 17:05:23) > [GCC 5.4.0 20160609] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> 0.5 > 1.0 > >>> f = float("0.5") > >>> i = int(f) >

Re: best way to ensure './' is at beginning of sys.path?

2017-02-04 Thread Dan Sommers
On Sat, 04 Feb 2017 21:19:06 +0200, Marko Rauhamaa wrote: > Now, that's why the distros are careful to place $HOME/bin as the > final entry of PATH; the system commands take precedence over the > user's personal ones. However, the user is free to define the PATH any > way they like. I

Re: best way to ensure './' is at beginning of sys.path?

2017-02-04 Thread Dan Sommers
On Sat, 04 Feb 2017 12:56:58 -0600, Wildman wrote: > On Sat, 04 Feb 2017 18:25:03 +, Grant Edwards wrote: >> It allows a malicous user to put an evil executable someplace public >> like /tmp and have it executed accidentally. For example, let's say >> this executable file was named "sl" and

Re: How an editor can help with block nesting (was Re: How coding in Python is bad for you)

2017-01-24 Thread Dan Sommers
On Wed, 25 Jan 2017 12:31:11 +1100, Steve D'Aprano wrote: > But now I type something which cannot possibly be indented there: > > def func(a, b): > if condition: > spam() > elif something: | > > and hit ENTER again. There's nothing ambiguous about this, and

Re: The hardest problem in computer science...

2017-01-06 Thread Dan Sommers
On Sat, 07 Jan 2017 00:03:37 +1100, Steve D'Aprano wrote: > The *hardest* problem is naming things. > > Fiction > ├─ Fantasy > │ ├─ Terry Pratchett > │ │ ├─ Discworld > │ │ │ ├─ Wyrd Sisters > │ │ │ └─ Carpe Jugulum [...] > what do we call the vertical and

Re: Clickable hyperlinks

2017-01-06 Thread Dan Sommers
On Wed, 04 Jan 2017 16:40:00 +1100, Steven D'Aprano wrote: > On Wednesday 04 January 2017 15:46, Deborah Swanson wrote: > >> Steven D'Aprano wrote, on January 03, 2017 8:04 PM > [...] >>> Of course you have to put quotes around them to enter them in >>> your source code. >>> We don't expect this

Re: Clickable hyperlinks

2017-01-03 Thread Dan Sommers
On Wed, 04 Jan 2017 16:40:00 +1100, Steven D'Aprano wrote: > On Wednesday 04 January 2017 15:46, Deborah Swanson wrote: > >> Steven D'Aprano wrote, on January 03, 2017 8:04 PM > [...] >>> Of course you have to put quotes around them to enter them in >>> your source code. >>> We don't expect this

Re: Access to the caller's globals, not your own

2016-11-16 Thread Dan Sommers
On Thu, 17 Nov 2016 16:17:51 +1100, Steven D'Aprano wrote: > ... factory functions are great. But I'm saying that as the writer of > the library, not the user of the library. Can you imagine expecting > users to do this? > from math import trig > sin = trig.build('sine') > result = sin(0.1) No,

Re: Access to the caller's globals, not your own

2016-11-14 Thread Dan Sommers
On Mon, 14 Nov 2016 16:20:49 +1100, Steven D'Aprano wrote: > import library > SPAMIFY = False # only affects this module, no other modules > result = library.make_spam(99) I must be missing something, because it seems too obvious: import library # only affects this module, no other

Re: Can math.atan2 return INF?

2016-06-22 Thread Dan Sommers
On Thu, 23 Jun 2016 13:59:46 +1000, Steven D'Aprano wrote: > Given: > > x = INF > y = INF > assert x == y > > there is a reason to pick atan2(y, x) = pi/4: > > Since x == y, the answer should be the same as for any other pair of x == y. When x == y == 0, then atan2(y, x) is 0. --

Re: Unexpected NANs in complex arithmetic

2016-06-22 Thread Dan Sommers
On Wed, 22 Jun 2016 16:30:49 +1000, Chris Angelico wrote: > On Wed, Jun 22, 2016 at 4:17 PM, Steven D'Aprano > <steve+comp.lang.pyt...@pearwood.info> wrote: >> On Wednesday 22 June 2016 13:54, Dan Sommers wrote: >> >>> By the time Python returns a result for inf+

Re: Unexpected NANs in complex arithmetic

2016-06-21 Thread Dan Sommers
On Wed, 22 Jun 2016 12:57:55 +1000, Chris Angelico wrote: > On Wed, Jun 22, 2016 at 12:48 PM, Steven D'Aprano wrote: >> I'm doing some arithmetic on complex numbers involving INFs, and getting >> unexpected NANs. >> >> py> INF = float('inf') >> py> z = INF + 3j >> py> z >>

Re: for / while else doesn't make sense

2016-06-07 Thread Dan Sommers
On Tue, 07 Jun 2016 00:53:31 -0700, Lawrence D’Oliveiro wrote: > On Tuesday, June 7, 2016 at 3:34:39 PM UTC+12, Dan Sommers wrote: > >> I used to write a lot of assembly code, for a lot of different CPUs, and >> they all had a common, versatile looping form which

Re: for / while else doesn't make sense

2016-06-06 Thread Dan Sommers
On Mon, 06 Jun 2016 17:51:24 -0700, Lawrence D’Oliveiro wrote: > It is nice to have a common, versatile looping form which can be > arranged in different ways to suit the problem at hand. That’s why I > like the C-style for-statement. [example snipped] I used to write a lot of assembly code,

Re: Summing/combining tuples

2016-05-20 Thread Dan Sommers
On Sat, 21 May 2016 03:19:49 +, Dan Sommers wrote: >> Is there something shorter and sweeter for the summation? > > from itertools import groupby > from operator import itemgetter > > result = [(k, >sum(map(itemgetter(2), v)), >

Re: Summing/combining tuples

2016-05-20 Thread Dan Sommers
On Wed, 18 May 2016 20:59:55 -0400, DFS wrote: > Have aList = [ > ('x','Name1', 1, 85), > ('x','Name2', 3, 219), > ('x','Name2', 1, 21), > ('x','Name3', 6, 169) > ] > > want > > aList = [ > ('Name1', 1, 85), > ('Name2', 4, 240), > ('Name3', 6, 169) > ] [snip] > Is there something shorter and

Re: Is there a reason zip() wipes out data?

2016-05-08 Thread Dan Sommers
On Mon, 09 May 2016 00:22:46 -0400, DFS wrote: > python 2.7.11 docs: "The returned list is truncated in length to the > length of the shortest argument sequence." > > > a = ['who','let','the'] > b = ['dogs','out?'] > c = zip(a,b) > > print c > [('who', 'dogs'), ('let', 'out?')] > > >

Re: pylint woes

2016-05-08 Thread Dan Sommers
On Sun, 08 May 2016 23:01:55 +1000, Chris Angelico wrote: > ... I like to recommend a little thing called "IIDPIO debugging" - If > In Doubt, Print It Out. That means: If you have no idea what a piece > of code is doing, slap in a print() call somewhere. It'll tell you > that (a) the code is

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Dan Sommers
On Fri, 06 May 2016 02:46:22 +, Dan Sommers wrote: > Python 2.7.11+ (default, Apr 17 2016, 14:00:29) > [GCC 5.3.1 20160409] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Dan Sommers
On Thu, 05 May 2016 18:37:11 -0700, Stephen Hansen wrote: > ''.join(x for x in string if x.isupper()) > The difference is, both filter and your list comprehension *build a > list* which is not needed, and wasteful. The above skips building a > list, instead returning a generator ... filter

Re: Python path and append

2016-04-25 Thread Dan Sommers
On Tue, 26 Apr 2016 11:51:23 +1000, Steven D'Aprano wrote: > ... (Possible a few very old operating systems on supercomputers from > the 1970s or 80s may have supported inserting... I seem to recall that > VMS may have allowed that... but don't quote me.) Some [non-supercomputer]

Re: Falsehoods People Believe about PEP 8 (was: Guido sees the light: PEP 8 updated)

2016-04-16 Thread Dan Sommers
On Sun, 17 Apr 2016 11:48:11 +1000, Steven D'Aprano wrote: > On Sun, 17 Apr 2016 09:35 am, Dan Sommers wrote: > >> We (this mailing list, or maybe it was the python-ideas mailing list) >> just had a thread about non-ASCII characters in identifiers. One of >> t

Re: Falsehoods People Believe about PEP 8 (was: Guido sees the light: PEP 8 updated)

2016-04-16 Thread Dan Sommers
On Sun, 17 Apr 2016 07:34:20 +1000, Chris Angelico wrote: > On Sun, Apr 17, 2016 at 7:22 AM, Dan Sommers <d...@tombstonezero.net> wrote: >> On Sat, 16 Apr 2016 16:44:30 -0400, Random832 wrote: >> >>> On Sat, Apr 16, 2016, at 16:21, Ben Finney wrote: >>>&

Re: Falsehoods People Believe about PEP 8 (was: Guido sees the light: PEP 8 updated)

2016-04-16 Thread Dan Sommers
On Sat, 16 Apr 2016 16:44:30 -0400, Random832 wrote: > On Sat, Apr 16, 2016, at 16:21, Ben Finney wrote: >> * Oh, come on, no-one would use U+000C FORM FEED in source code. > > Some text editors have shortcuts to navigate to the previous/next line > that begins with a form feed. Add these to

Re: Convert input to upper case on screen as it is typed

2016-04-13 Thread Dan Sommers
On Thu, 14 Apr 2016 13:25:14 +1000, Ben Finney wrote: > How can my Python program convert the user's keyboard input to upper > case, as though the user has CAPS LOCK enabled? I don't know which OS you're using, but if I run "stty olcuc" in my Linux shell, then the input driver does that for me.

Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask]

2016-04-10 Thread Dan Sommers
On Mon, 11 Apr 2016 01:33:10 +0100, MRAB wrote: > There _is_ one exception though: (). It's the empty tuple (a 0-element > tuple). It doesn't have a comma and the parentheses are mandatory. > There's no other way to write it. The other way to write it is: tuple() --

Re: [beginner] What's wrong?

2016-04-03 Thread Dan Sommers
On Sun, 03 Apr 2016 09:49:03 -0700, Rustom Mody wrote: > On Sunday, April 3, 2016 at 9:41:11 PM UTC+5:30, Dan Sommers wrote: >> On Sun, 03 Apr 2016 08:46:59 -0700, Rustom Mody wrote: >> >> > On Sunday, April 3, 2016 at 8:58:59 PM UTC+5:30, Dan Sommers wrote: >> &g

Re: [beginner] What's wrong?

2016-04-03 Thread Dan Sommers
On Sun, 03 Apr 2016 10:18:45 -0700, Rustom Mody wrote: > On Sunday, April 3, 2016 at 9:56:24 PM UTC+5:30, Dan Sommers wrote: >> On Sun, 03 Apr 2016 08:39:02 -0700, Rustom Mody wrote: >> >> > On Sunday, April 3, 2016 at 8:58:59 PM UTC+5:30, Dan Sommers wrote: >> &

Re: [beginner] What's wrong?

2016-04-03 Thread Dan Sommers
On Sun, 03 Apr 2016 08:39:02 -0700, Rustom Mody wrote: > On Sunday, April 3, 2016 at 8:58:59 PM UTC+5:30, Dan Sommers wrote: >> On Sun, 03 Apr 2016 07:30:47 -0700, Rustom Mody wrote: >> >> > So here are some examples to illustrate what I am saying: >> >&g

Re: [beginner] What's wrong?

2016-04-03 Thread Dan Sommers
On Sun, 03 Apr 2016 08:46:59 -0700, Rustom Mody wrote: > On Sunday, April 3, 2016 at 8:58:59 PM UTC+5:30, Dan Sommers wrote: >> Yes, it's marginally annoying, and a security hole waiting to happen, >> that A and A often look very much alike. > > "A security hole waitin

Re: [beginner] What's wrong?

2016-04-03 Thread Dan Sommers
On Sun, 03 Apr 2016 07:30:47 -0700, Rustom Mody wrote: > So here are some examples to illustrate what I am saying: [A vs a, A vs A, flag vs flag, etc.] Are identifiers text or bytes? or something else entirely that takes natural language rules and the appearance of the glyphs into account? I,

Re: List of Functions

2016-03-28 Thread Dan Sommers
On Mon, 28 Mar 2016 11:58:54 +0300, Marko Rauhamaa wrote: > As for Python, I don't feel a great need for anonymous functions. > However, I keep running into a need for anonymous classes, or, rather, > classless objects. Not a biggie. I just create a one-off inner class > and instantiate it, but I

Re: Why do you use python?

2016-03-20 Thread Dan Sommers
On Mon, 21 Mar 2016 15:13:22 +1100, Chris Angelico wrote: > On Mon, Mar 21, 2016 at 2:59 PM, wrote: >> instead, to be efficient, it is best to combine tools to solve >> problems that contain complexities where there is nothing available >> off the shelve that does the

Re: WP-A: A New URL Shortener

2016-03-19 Thread Dan Sommers
On Thu, 17 Mar 2016 23:08:24 +1100, Chris Angelico wrote: > So you would need to come up with a system that's distributed (such > that one computer's inaccessibility doesn't bring everything down) and > permanent (keep on circulating that information!). It could be a > rather fun problem to

Re: [Still off-top] Physics [was Requests author discusses MentalHealthError exception]

2016-03-04 Thread Dan Sommers
On Fri, 04 Mar 2016 12:38:28 +0200, Marko Rauhamaa wrote: > As for the existence of a negative mass, it is interesting to note > that the (rest) mass of an alpha particle is less than the sum of the > (rest) masses of its constituents. About 1% of the mass is "missing."

Re: How to read from a file to an arbitrary delimiter efficiently?

2016-02-27 Thread Dan Sommers
On Sat, 27 Feb 2016 21:40:17 +1100, Steven D'Aprano wrote: > Thanks for finding the issue, but the solutions given don't suit my > use case. I don't want an iterator that operates on pre-read blocks, I > want something that will read a record from a file, and leave the file > pointer one entry

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Dan Sommers
On Mon, 15 Feb 2016 11:08:52 +1100, Ben Finney wrote: > I am unconcerned with whether there is a real filesystem entry of that > name; the goal entails having no filesystem activity for this. I want > a valid unique filesystem path, without touching the filesystem. That's an odd use case. If

Re: raise None

2016-01-03 Thread Dan Sommers
On Mon, 04 Jan 2016 16:19:51 +1100, Steven D'Aprano wrote: > (1) reminding people that the part of the code which determines the > existence of an error need not be the part of the code which actually > calls raise [...] Do chained exceptions scratch your itch? I don't have experience with

Re: What does “grep” stand for?

2015-11-05 Thread Dan Sommers
On Thu, 05 Nov 2015 19:36:11 -0800, Larry Hudson wrote: > Anyone besides me remember the CP/M editor Mince (Mince Is Not > Complete EMACS)? It was an emacs-like editor, without any e-Lisp or > other way of extending it. I believe it was my first exposure to a > screen-oriented editor. I quite

Re: Regular expressions

2015-11-03 Thread Dan Sommers
On Tue, 03 Nov 2015 19:04:23 -0700, Michael Torrie wrote: > On 11/03/2015 05:33 PM, rurpy--- via Python-list wrote: >> I consider regexs more fundemental. One need not even be a programmer >> to use them: consider grep, sed, a zillion editors, database query >> languages, etc. > > Grep can use

Re: Most Pythonic way to store (small) configuration

2015-08-02 Thread Dan Sommers
On Sun, 02 Aug 2015 16:11:14 -0500, Tim Chase wrote: On 2015-08-02 21:54, Ben Finney wrote: So, both XML and JSON should be considered write-only, and produced only for consumption by a computer; they are a poor choice for presenting to a human. [snip] I second Ben's thoughts against XML

Re: Camelot a good tool for me

2015-05-22 Thread Dan Sommers
On Fri, 22 May 2015 09:59:02 +0200, Cecil Westerhof wrote: Would Camelot be a good tool to get me started, or can I better bite the bullet and just start with Tkinter and SQLAlchemy? Bite the bullet and learn SQL. SQLAlchemy - Database :: Python - Assembly Language. HTH, Dan --

Re: Throw the cat among the pigeons

2015-05-06 Thread Dan Sommers
On Wed, 06 May 2015 09:12:05 -0400, Dave Angel wrote: Remember the days when you knew how many cycles each assembly instruction took, and could simply add them up to compare algorithms? I do! I do! :-) And then the MC68020 came out, and instruction execution overlapped in weird (but

Re: Python xlrd

2015-05-03 Thread Dan Sommers
On Sun, 03 May 2015 10:33:25 -0700, lbertolotti wrote: lucas@lucas-K55VD:~$ dpkg -l python-xlrd Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name

Re: New to Python - block grouping (spaces)

2015-04-19 Thread Dan Sommers
On Sun, 19 Apr 2015 09:03:23 -0700, Rustom Mody wrote: Now if Thomson and Ritchie (yeah thems the guys) could do it in 1970, why cant we revamp this 45-year old archaic program=textfile system today? Revamp? What's to revamp? C, C++, C#, Java, FORTRAN, Python, Perl, Ruby, POSIX shells,

Re: New to Python - block grouping (spaces)

2015-04-17 Thread Dan Sommers
On Fri, 17 Apr 2015 18:05:52 +0100, BartC wrote: (Actually *I* would quite like to know why languages don't have switchable syntax anyway to allow for people's personal preferences.) You want LISP, the programmable programming language. -- https://mail.python.org/mailman/listinfo/python-list

Re: Auto-completion of Unicode names [was why not module name?]

2015-03-17 Thread Dan Sommers
On Wed, 18 Mar 2015 10:29:53 +1100, Steven D'Aprano wrote: Speaking of tab completion, would anyone be interested in being able to auto-complete \N{...} unicode character names? I'm considering that as an enhancement to my tabhistory module. Only if it's fuzzy. One use case is that opening

Re: Brilliant or insane code?

2015-03-17 Thread Dan Sommers
On Wed, 18 Mar 2015 00:35:42 +, Mark Lawrence wrote: I've just come across this http://www.stavros.io/posts/brilliant-or-insane-code/ as a result of this http://bugs.python.org/issue23695 Any and all opinions welcomed, I'm chickening out and sitting firmly on the fence. According to

Re: Brilliant or insane code?

2015-03-17 Thread Dan Sommers
On Wed, 18 Mar 2015 13:25:45 +1100, Steven D'Aprano wrote: On Wednesday 18 March 2015 12:14, Dan Sommers wrote: According to the article itself, it relies in an implementation detail (the order the zip function iterates over the arrays) to work. Then again, the article also points

Re: Newbie question about text encoding

2015-03-07 Thread Dan Sommers
On Sun, 08 Mar 2015 05:13:09 +1100, Chris Angelico wrote: On Sun, Mar 8, 2015 at 5:02 AM, Dan Sommers d...@tombstonezero.net wrote: On Sun, 08 Mar 2015 04:59:56 +1100, Chris Angelico wrote: On Sun, Mar 8, 2015 at 4:50 AM, Marko Rauhamaa ma...@pacujo.net wrote: Correct. Linux pathnames

Re: Newbie question about text encoding

2015-03-07 Thread Dan Sommers
On Sun, 08 Mar 2015 04:59:56 +1100, Chris Angelico wrote: On Sun, Mar 8, 2015 at 4:50 AM, Marko Rauhamaa ma...@pacujo.net wrote: Correct. Linux pathnames are octet strings regardless of the locale. That's why Linux developers should refer to filenames using bytes. Unfortunately, Python

Re: Newbie question about text encoding

2015-03-07 Thread Dan Sommers
On Sat, 07 Mar 2015 19:00:47 +, Mark Lawrence wrote: Isn't pathlib https://docs.python.org/3/library/pathlib.html#module-pathlib effectively a more recent attempt at smoothing or even removing (some of) the bumps? Has anybody here got experience of it as I've never used it? I almost

Re: Python Worst Practices

2015-02-27 Thread Dan Sommers
On Sat, 28 Feb 2015 12:09:31 +1100, Steven D'Aprano wrote: There's no harm in calling a local variable id, if you don't use the built-in id() inside that function. That's one of the reasons why functions exist, so that the names you use inside a function are distinct from those outside. And

Re: Python Worst Practices

2015-02-27 Thread Dan Sommers
On Sat, 28 Feb 2015 17:36:44 +1100, Steven D'Aprano wrote: Dan Sommers wrote: And thank goodness for that! I've been writing Python code since 1997 and version 1.5.something,¹ and I still do a double take when emacs colors all my ids that faint blue that means builtin. Although

Re: What behavior would you expect?

2015-02-19 Thread Dan Sommers
On Thu, 19 Feb 2015 22:51:57 -0700, Jason Friedman wrote: I'd still advise using my_list.sort() rather than sorted(), as you don't need to retain the original. Hmm. Trying to figure out what that looks like. If I understand correctly, list.sort() returns None. What would I return to

Re: What behavior would you expect?

2015-02-19 Thread Dan Sommers
On Fri, 20 Feb 2015 07:11:13 +1100, Chris Angelico wrote: On Fri, Feb 20, 2015 at 7:03 AM, Denis McMahon denismfmcma...@gmail.com wrote: On the one hand, the return type of a function (when it returns, rather than raising an exception) should be consistent to itself, even if using a

Re: What behavior would you expect?

2015-02-19 Thread Dan Sommers
On Fri, 20 Feb 2015 16:16:50 +1100, Chris Angelico wrote: On Fri, Feb 20, 2015 at 3:54 PM, Dan Sommers d...@tombstonezero.net wrote: if there are no values to return, then return an empty collection. That one makes sense only if you were going to return a collection anyway, though. If you

Re: Python is DOOMED! Again!

2015-01-26 Thread Dan Sommers
On Tue, 27 Jan 2015 11:11:45 +1100, Steven D'Aprano wrote: random...@fastmail.us wrote: (header files in the 1970s didn't even actually include function signature information) - which did not even participate in compilation at all. If C compilers didn't use the header files, what were they

Re: Benchmarking some modules - strange result

2015-01-25 Thread Dan Sommers
On Sun, 25 Jan 2015 13:24:40 +0100, Peter Otten wrote: Dan Stromberg wrote: I've been benchmarking some python modules that are mostly variations on the same theme. For simplicity, let's say I've been running the suite of performance tests within a single interpreter - so I test one

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Dan Sommers
On Sat, 17 Jan 2015 18:44:42 +, Grant Edwards wrote: ... somebody who only knows how to write C++ [though he can do it in several different languages]. +1 QOTW (brilliant phrases in other threads are off topic and are disqualified) I have also suffered through such maintenance, but I have

Re: How can i use a dictionnary

2015-01-13 Thread Dan Sommers
On Tue, 13 Jan 2015 06:56:11 -0800, Novocastrian_Nomad wrote: On Tuesday, January 13, 2015 at 2:03:30 AM UTC-7, brice DORA wrote: i consume a web service that return a element whose the type is instance. but this element seem be a dictionary but when i want to use it like a dictionary, i got

Re: PyWart: Poor Documentation Examples

2015-01-11 Thread Dan Sommers
Should that go into the doc?? Absolutely. :-) If the docs had explained that reduce is actually a finite state machine framework, then I wouldn't have written my such framework. I'll leave that to somebody else whose name starts with 'R' :-) Uh, oh. Sorry. -- Dan Sommers, neither of which

Re: Generate jpg files using line length (pixels) and orientation (degrees)

2015-01-09 Thread Dan Sommers
Unfortunately getting a new error. Traceback (most recent call last): File C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w corr.py, line 68, in module makeimg(length, orientation) File C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w corr.py,

Re: Logger not logging

2015-01-01 Thread Dan Sommers
On Thu, 01 Jan 2015 10:09:13 -0700, Jason Friedman wrote: What am I missing? I expect logger.info(hello) to emit. $ python Python 3.4.0 (default, Apr 18 2014, 19:16:28) [GCC 4.8.1] on linux Type help, copyright, credits or license for more information. import logging logger =

Re: dict turn to list unexpected at runtime???

2014-12-04 Thread Dan Sommers
On Fri, 05 Dec 2014 15:01:51 +0800, telnetgm...@gmail.com wrote: Why the following code gives me errors??? And why the print statement run 2 times? ... addrnum_dict = {'a':1,'b':2} def orderaddrtimes(): global addrnum_dict print type(addrnum_dict) addrnum_dict =

Re: I have no class

2014-11-24 Thread Dan Sommers
On Mon, 24 Nov 2014 16:11:32 +1100, Chris Angelico wrote: On Mon, Nov 24, 2014 at 3:21 PM, Steven D'Aprano st...@pearwood.info wrote: On Sun, 23 Nov 2014 09:02:57 -0800, Rustom Mody wrote: Python is a bit odd in the OO-world in that it prioritizes Explicit is better than implicit over

Re: Classes

2014-11-02 Thread Dan Sommers
On Mon, 03 Nov 2014 03:12:32 +, Denis McMahon wrote: Quadrilateral Parallelogram Square Rectangle Rhombus Diamond (4 sides eq) Trapezoid Arrowhead What's the difference between a Diamond and a Rhombus? Is an arrowhead a trapezoid?

Re: Status of side-effecting functions in python

2014-10-26 Thread Dan Sommers
On Sun, 26 Oct 2014 00:45:49 -0700, wxjmfauth wrote: Ditto for fileobj.write(). Why should it return something ? with open('z.txt', 'w') as f: ... f.write('abc') ... 3 OTOH, why shouldn't it return something? In this case, it returns the length of the string written. This value

Re: Status of side-effecting functions in python

2014-10-25 Thread Dan Sommers
On Sat, 25 Oct 2014 23:41:52 +0200, Wolfgang Maier wrote: ... It may be rare to use an expression both for its side-effects and its return value ... A lot of concurrency-related operations work that way. In the old days, it was CPU-level Test and Set (or Compare and Set) instructions. These

Re: Storing instances using jsonpickle

2014-09-04 Thread Dan Sommers
On Thu, 04 Sep 2014 15:17:17 +1000, Chris Angelico wrote: On Thu, Sep 4, 2014 at 9:39 AM, MRAB pyt...@mrabarnett.plus.com wrote: The key of a dict could also be int, float, or tuple. Yes! Yes! DEFINITELY do this!! Ahem. Calm down a little, it's not that outlandish an idea... Using floats

Re: PEP8 and 4 spaces

2014-07-06 Thread Dan Sommers
On Mon, 07 Jul 2014 11:00:59 +1000, Ben Finney wrote: The makefile syntax is one of the excellent examples of why it's a terrible idea to use tab characters in source code. It's also an excellent example of how a poor design decision (a line beginning with U+0020 SPACE is semantically

Re: PEP8 and 4 spaces

2014-07-05 Thread Dan Sommers
On Sun, 06 Jul 2014 09:27:59 +1000, Chris Angelico wrote: How often do you ever have multiple consecutive blank lines? My newlines are either single (line end) or in pairs (one blank line), and I don't remember having anything else (at least, not intentionally). Greater separation than a

Re: Python's numeric tower

2014-06-15 Thread Dan Sommers
On Sun, 15 Jun 2014 22:17:57 -0400, Roy Smith wrote: I don't believe HandGrenade implements throw(). It does, however, implement lobbeth(). And therein lies the problem with Object Oriented Programming: instances of HandGrenade neither throw nor lobbeth. One, Two, Five'ly yours, Dan --

Re: Python's re module and genealogy problem

2014-06-13 Thread Dan Sommers
On Fri, 13 Jun 2014 17:17:06 +0200, BrJohan wrote: Or to put the namevariants in some sequence of sets having elements like: (Kristina, Christina, Cristine, Kristine) Matching is then just applying the 'in' operator. That's definitely a better approach, for the reasons you mentioned.

[OT] Re: Is MVC Design Pattern good enough?

2014-06-01 Thread Dan Sommers
On Sun, 01 Jun 2014 10:37:24 -0700, Ernest Bonat, Ph.D. wrote: ... MVC design pattern ... defined the Model layer as the data management of the application domain and business logic implementation ... Can we implement the application business logic in another layer? Yes or no? Why? Explain?

Re: hashing strings to integers

2014-05-27 Thread Dan Sommers
On Tue, 27 May 2014 17:02:50 +, Steven D'Aprano wrote: - rather than zillions of them, there are few enough of them that the chances of an MD5 collision is insignificant; (Any MD5 collision is going to play havoc with your strategy of using hashes as a proxy for the real string.)

Re: The “does Python have variables?” debate

2014-05-07 Thread Dan Sommers
On Thu, 08 May 2014 01:27:08 +, Steven D'Aprano wrote: If I have understood correctly, and I welcome confirmation or correction, one can have any combination of: * dynamic typing and name binding (e.g. Python and Ruby); * static typing and name binding (e.g. Java); * dynamic typing and

Re: how to insert the elements in a list properly?

2014-04-09 Thread Dan Sommers
On Wed, 09 Apr 2014 21:09:37 +0800, length power wrote: words = [x1, x2, x3, x4, x5] words.append(words.pop(2)) words.append(words.pop(2)) words ['x1', 'x2', 'x5', 'x3', 'x4'] why i can't write it as: [words.append(words.pop(2)) for i in range(0,2)] [words.append(words.pop(2)) for i

Re: Python to be replaced by the new language called Cookie !

2014-04-01 Thread Dan Sommers
On Wed, 02 Apr 2014 02:19:38 +1100, Chris Angelico wrote: These improvements are absolutely critical to the language, and should be made in Python 2.5.7, 2.6.9, and 3.0.2. Anyone using a newer version of Python is paying the price for early adoption, and should back-level immediately to a

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Dan Sommers
On Thu, 27 Mar 2014 00:16:57 +, Steven D'Aprano wrote: py divmod(-30, 24) (-2, 18) If an event happened 30 hours ago, it is correct to say that it occurred 18 hours after 2 days ago, but who talks that way? Well, not *exactly*, but: If today happens to be Wednesday, and an event

Re: Github down?

2014-03-21 Thread Dan Sommers
On Fri, 21 Mar 2014 14:51:54 +0100, Chris “Kwpolska” Warrick wrote: (though GitHub could qualify as social media for some…) +1 QOTW -- https://mail.python.org/mailman/listinfo/python-list

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread Dan Sommers
On Sun, 09 Mar 2014 03:50:49 +, Steven D'Aprano wrote: ... UTF-16 ... the letter A is stored as two bytes 0x0041 (or 0x4100 depending on your platform's byte order) ... At the risk of being pedantic, the two bytes are 0x00 and 0x41, and the order in which they appear in memory depends on

Re: Python programming

2014-03-05 Thread Dan Sommers
On Wed, 05 Mar 2014 20:19:56 -0800, Beowulf wrote: Once you master one language it is easy to understand other ... Once you master one language, the next one is hard. After that, they get easier. -- https://mail.python.org/mailman/listinfo/python-list

Re: exec and locals

2014-02-26 Thread Dan Sommers
On Thu, 27 Feb 2014 00:25:45 +, Steven D'Aprano wrote: By the way, if anyone cares what my actual use-case is, I have a function that needs to work under Python 2.4 through 3.4, and it uses a with statement. With statements are not available in 2.4 (or 2.5, unless you give a from

Re: Python programming

2014-02-12 Thread Dan Sommers
On Wed, 12 Feb 2014 22:56:56 -0500, William Ray Wing wrote: OK, and how many of you remember the original version of the tongue-in-cheek essay Real Programmers Don't Use Pascal from the back page of Datamation? And the April issue of Compubyte (or something like that) with a cover showing two

Re: how to reduce bugs due to incorrect indentation

2014-02-05 Thread Dan Sommers
On Wed, 05 Feb 2014 19:02:09 -0800, msustik wrote: My changes were elsewhere and I did not notice the above one line change when I looked at the diffs before commit. I should have noticed it... It was rare that a was 1 and therefore the problem did not show up for a while. (I know I should

Re: Calculator Problem

2014-02-04 Thread Dan Sommers
On Tue, 04 Feb 2014 19:53:52 -0500, Roy Smith wrote: In article ed1c2ddd-f704-4d58-a5a4-aef13de88...@googlegroups.com, David Hutto dwightdhu...@gmail.com wrote: Can anyone point out how using an int as a var is possible one = 42 (ducking and running) int = 42 (ducking lower and

Re: pytz question: GMT vs. UTC

2014-01-31 Thread Dan Sommers
On Fri, 31 Jan 2014 17:42:30 +1100, Chris Angelico wrote: On Fri, Jan 31, 2014 at 5:28 PM, Dan Sommers d...@tombstonezero.net wrote: ObPython: My program retrieves temperatures (in Kelvins) from an external device (the details of which I am not at liberty to discuss) and stores them

Re: Another surprise from the datetime module

2014-01-30 Thread Dan Sommers
On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote: However, the existing ‘replace’ methods ‘datetime.date.replace’, ‘datetime.datetime.replace’, ‘datetime.time.replace’ already work this way: they create a new value and return it, without modifying the original object. That's how

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Dan Sommers
On Thu, 30 Jan 2014 15:21:35 +, Grant Edwards wrote: On 2014-01-30, wxjmfa...@gmail.com wxjmfa...@gmail.com wrote: The temperature unit is the Kelvin, not the Degree Kelvin. One writes: 0 K, 275.15 K And remember to say Kelvins not Kelvin when speaking about temperatures other than 1

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Dan Sommers
On Fri, 31 Jan 2014 04:37:16 +, Steven D'Aprano wrote: On Fri, 31 Jan 2014 04:08:46 +, Dan Sommers wrote about temperatures: And -1 K. You josh, but there are negative temperatures in Kelvin. They're hotter than infinitely hot. http://en.wikipedia.org/wiki/Negative_temperature

Re: buggy python interpretter or am I missing something here?

2014-01-27 Thread Dan Sommers
On Mon, 27 Jan 2014 10:23:49 -0600, Zachary Ware wrote: Understood, except that some parameters take multiple elements...thus why I manually reference the indexes. Try this on for size, then: a_iter = iter(a) for arg in a_iter: print('current', arg) if arg == '-#':

Re: Case insensitive exists()?

2014-01-22 Thread Dan Sommers
On Wed, 22 Jan 2014 18:18:32 -0700, Larry Martell wrote: The issue is that I run a database query and get back rows, each with a file path (each in a different dir). And I have to check to see if that file exists. Each is a separate search with no correlation to the others. I have the full

Re: Can post a code but afraid of plagiarism

2014-01-21 Thread Dan Sommers
On Tue, 21 Jan 2014 10:32:13 +, Oscar Benjamin wrote: ... When you set assignments the students will usually learn more if they work in groups. However at some point you need to try and assess how much they've individually learned. I find in practice that it's easy to tell when a student

Re: the Gravity of Python 2

2014-01-09 Thread Dan Sommers
On Thu, 09 Jan 2014 09:14:22 -0500, Roy Smith wrote: Oh, and another thing I can do with a datetime that I can't do with a unix timestamp. I can represent the day I was born. At the risk of dating myself, the day I was born is -231094800. Dan --

Re: any use case of logging.config.listen()?

2013-12-03 Thread Dan Sommers
On Wed, 04 Dec 2013 09:34:13 +0800, Zhang Weiwu wrote: Why would anyone use [logging.config.listen()]? I can't think of use cases when one need to change logging configuration dynamically through socket, but not needing the same flexibility on overall configuration for his application

Re: Python Front-end to GCC

2013-10-25 Thread Dan Sommers
On Fri, 25 Oct 2013 04:55:43 -0700, Mark Janssen wrote: On Thu, Oct 24, 2013 at 8:40 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 22/10/2013 18:37, Oscar Benjamin wrote: OTOH why in particular would you want to initialise them with zeros? I often initialise arrays to nan which is

Re: Database engine bindings for Python (was: Database statements via python but database left intact)

2013-10-06 Thread Dan Sommers
On Sun, 06 Oct 2013 12:19:13 +1100, Chris Angelico wrote: On Sun, Oct 6, 2013 at 12:05 PM, Ben Finney wrote: [ ... ] With a separately-installed, far more complex database engine like MySQL or PostgreSQL, the Python bindings will only work if they are compiled against the correct client

Re: user interfaces python3.x

2013-09-02 Thread Dan Sommers
On Mon, 02 Sep 2013 16:08:04 +, Steven D'Aprano wrote: (If you think text is not a proper interface, you're going to have a bad time as a programmer. 99% of your programming time will be writing.) I'm a programmer, and I spend way more than 1% of my programming time drawing, even taking

Re: pydoc vs. non-def'd methods

2013-08-22 Thread Dan Sommers
On Thu, 22 Aug 2013 06:39:48 +, Steven D'Aprano wrote: On Thu, 22 Aug 2013 05:13:03 +, Dan Sommers wrote: class Spam1: def eggs(self): '''Return the Meaning of Life.''' return 42 ham = eggs help(Spam1) shows that ham = eggs(self), which isn't all

<    1   2   3   4   5   >