Re: Hello World

2015-01-17 Thread Tim Chase
On 2015-01-17 22:18, Roy Smith wrote: > Tell me about it. I have an E-Trade ATM card. When I first got > it, I set it up with a 6 digit PIN. I was shocked to discover some > time later that it actually only looks at the first 4 digits. And, > no, I'm not talking *characters*, I'm talking *digit

Re: Trees

2015-01-19 Thread Tim Chase
On 2015-01-19 16:19, Michael Torrie wrote: > On 01/19/2015 04:08 PM, Steven D'Aprano wrote: > > Zachary Gilmartin wrote: > >> Why aren't there trees in the python standard library? > > > > Possibly because they aren't needed? Under what circumstances > > would you use a tree instead of a list or a

Re: Trees

2015-01-21 Thread Tim Chase
2015, 21:48:07) > [GCC 4.7.2] on linux > Type "help", "copyright", "credits" or "license" for more > information. > >>> type({1,2,3}) > > >>> > > Looks like {1,2,3} works for me. That hasn't always worked: tim

Re: Trees

2015-01-21 Thread Tim Chase
On 2015-01-22 00:01, Chris Angelico wrote: > On Wed, Jan 21, 2015 at 11:55 PM, Tim Chase >>> Looks like {1,2,3} works for me. >> >> That hasn't always worked: > > the argument's still fairly weak when it's alongside a pipe-dream > desire to use sp

Re: What killed Smalltalk could kill Python

2015-01-21 Thread Tim Chase
On 2015-01-22 03:34, Steven D'Aprano wrote: > In 2009, Robert Martin gave a talk at RailsConf titled "What Killed > Smalltalk Could Kill Ruby". Holy pacing, Batman. Watching it at 2x leaves me wondering how much of the stage was worn off during the presentation. > And now it's all but dead. Why

Re: What killed Smalltalk could kill Python

2015-01-21 Thread Tim Daneliuk
es/How-To-Pick-A-Programming-Language -- ---- Tim Daneliuk tun...@tundraware.com PGP Key: http://www.tundraware.com/PGP/ -- https://mail.python.org/mailman/listinfo/python-list

Re: What killed Smalltalk could kill Python

2015-01-21 Thread Tim Chase
On 2015-01-21 23:10, Grant Edwards wrote: > I happily ignored PHP until a couple years back when we decided to > use PHP for the web site on a small embedded Linux system. [snip] > I briefly considered trying to switch to Python, but the Python > footprint is just too big... Interesting that your

Re: What killed Smalltalk could kill Python

2015-01-23 Thread Tim Daneliuk
On 01/21/2015 05:55 PM, Chris Angelico wrote: > On Thu, Jan 22, 2015 at 10:37 AM, Tim Daneliuk wrote: >> I find these kinds of discussions sort of silly. Once there is a critical >> mass of installed base, no language EVER dies. > > Not sure about that. Back in the 1990

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Tim Chase
On 2015-01-24 17:28, Chris Angelico wrote: > but this is hardly generic. There's no convenient way to give an > argument to a decorator that says "please assign this here", short > of using some stupid eval hack... is there? > > (Incidentally, for a non-generic dispatch table, a callable dict > su

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Tim Chase
On 2015-01-24 17:21, Steven D'Aprano wrote: > # Cobra > def sqroot(i as int) as float > > # Python > def sqroot(i:int)->float: > > > Cobra's use of "as" clashes with Python. In Python, "as" is used for > name-binding: > > import module as name > with open('file') as f > except Exception as e >

Re: Python is DOOMED! Again!

2015-01-24 Thread Tim Chase
On 2015-01-25 04:31, Steven D'Aprano wrote: > Of course we don't have $1/3 dollar coins, but I do have a pair of > tin-snips and can easily cut a $1 coin into three equal pieces. I'm impressed that you can use tin-snips to cut it into exactly three equal pieces with greater precision than the floa

Re: What killed Smalltalk could kill Python

2015-01-26 Thread Tim Daneliuk
On 01/23/2015 04:57 PM, Chris Angelico wrote: > On Sat, Jan 24, 2015 at 9:51 AM, Tim Daneliuk wrote: >> On 01/21/2015 05:55 PM, Chris Angelico wrote: >>> On Thu, Jan 22, 2015 at 10:37 AM, Tim Daneliuk >>> wrote: >>>> I find these kinds of discussions s

Re: parsing tree from excel sheet

2015-01-28 Thread Tim Chase
On 2015-01-28 10:12, alb wrote: > I've a document structure which is extremely simple and represented > on a spreadsheet in the following way (a made up example): > > subsystem | chapter | section | subsection | subsubsec | > A | | || | > | f

Re: Open file in default app and exit in Windows

2015-01-28 Thread Tim Golden
On 28/01/2015 15:50, stephen.bou...@gmail.com wrote: > I am using the following to open a file in its default application in > Windows 7: > > from subprocess import call > > filename = 'my file.csv' call('"%s"' % filename, shell=True) > > This still leaves a python process hanging around until t

Re: Open file in default app and exit in Windows

2015-01-28 Thread Tim Chase
On 2015-01-28 07:50, stephen.bou...@gmail.com wrote: > I am using the following to open a file in its default application > in Windows 7: > > from subprocess import call > > filename = 'my file.csv' > call('"%s"' % filename, shell=True) You can try import os filename = 'my file.csv' os.st

Re: The Most Diabolical Python Antipattern

2015-01-29 Thread Tim Chase
On 2015-01-29 17:17, Mark Lawrence wrote: > The author is quite clear on his views here > https://realpython.com/blog/python/the-most-diabolical-python-antipattern/ > but what do you guys and gals think? I just read that earlier today and agree for the most part. The only exception (pun only pa

Re: help() function screen output

2015-01-31 Thread Tim Golden
On 31/01/2015 08:17, Jacob Kruger wrote: Using python 3.4 32 bit on windows 7 64 bit machine, and when, for example, type in something like the following in interpreter window: help(str) It will populate the screen with one full screen of information, with a prompt of --more-- to hit enter, or so

Re: meaning of: line, =

2015-02-05 Thread Tim Chase
On 2015-02-05 08:45, Rustom Mody wrote: > > >>> def f(a, (b, c)): > > ... print a, b, c > > What the hell is that?! > First I am hearing/seeing it. > Whats it called? "tuple parameter unpacking", removed in Py3 https://www.python.org/dev/peps/pep-3113/ -tkc -- https://mail.python.org/ma

Re: meaning of: line, =

2015-02-05 Thread Tim Chase
On 2015-02-05 09:08, Ian Kelly wrote: > > Got an example where you can use a,b but not [a,b] or (a,b)? > > >>> def f(a, (b, c)): > ... print a, b, c > ... Interesting. I knew that at one point you could do this with lambdas but never thought to do it with regular functions. There are ti

Re: Wildly OT: pop-up virtual keyboard for Mac or Linux?

2015-02-10 Thread Tim Chase
On 2015-02-10 15:05, Skip Montanaro wrote: > For instance, If I press and hold the "d" key, I see these choices > (ignore the capitalization of the first letter - my mistake sending > a text message to myself from my phone, and I can't seem to convert > it to lower case): Đ|¦&dðď > > I haven't t

Re: Wildly OT: pop-up virtual keyboard for Mac or Linux?

2015-02-11 Thread Tim Chase
On 2015-02-10 19:37, Ned Deily wrote: > On OS X, the system provides both a "Character Viewer" (which > allows the selection of any Unicode character Windows also provides charmap.exe which provides similar functionality, though last I checked it, it still had the feel of a Win3.1 app (usability w

Re: function inclusion problem

2015-02-11 Thread Tim Chase
On 2015-02-11 10:07, Dave Angel wrote: > if there are tons of them, you do NOT want to pollute your local > namespace with them, and should do: > > import mydef > > x = mydef.func2() # or whatever or, if that's verbose, you can give a shorter alias: import Tkinter as tk root = tk.Tk()

Re: warnings building 3.5 on Windows

2015-02-11 Thread Tim Golden
On 11/02/2015 22:31, Chris Angelico wrote: On Thu, Feb 12, 2015 at 9:17 AM, Mark Lawrence wrote: 26> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winsock2.h(3623) : see declaration of 'WSAStringToAddressA' To clarify, are you building a 32-bit or 64-bit Python here? Also, what

Re: Odd version scheme

2015-02-12 Thread Tim Chase
On 2015-02-12 17:45, Gisle Vanem wrote: > I tried using Interactive Python with a PyQt4 console: >"IPython.exe qtconsole" > > But got a >"ImportError: IPython requires PyQT4 >= 4.7, found 4.10.4" > > Looking at Ipython's check (in > site-packages\IPython\external\qt.py): if QtCore.PYQT_VE

Re: Odd version scheme

2015-02-12 Thread Tim Chase
On 2015-02-12 18:37, Gisle Vanem wrote: > Tim Chase wrote:> So the test should actually be something like > > >if LooseVersion(QtCore.PYQT_VERSION_STR) < > > LooseVersion("4.10"): balk() > > That's exactly what they do now in IPython/utils/vers

Re: Odd version scheme

2015-02-12 Thread Tim Chase
On 2015-02-12 12:16, Ian Kelly wrote: > >> It still becomes an issue when we get to Python 10. > >> > > Just call it Python X! :-) > > Things break down again when we get to Python XIX. > > >>> 'XVIII' < 'XIX' > False You know what this sub-thread gives me? The icks. https://www.youtube.com/wat

Re: Download multiple xls files using Python

2015-02-12 Thread Tim Chase
On 2015-02-13 11:19, Chris Angelico wrote: > On Fri, Feb 13, 2015 at 11:07 AM, wrote: > > Here is an example of my problem. I have for the moment a CSV > > file named "Stars" saved on my windows desktop containing around > > 50.000 different links that directly starts downloading a xls > > file w

Re: Parsing and comparing version strings (was: Odd version scheme)

2015-02-12 Thread Tim Chase
On 2015-02-13 12:20, Ben Finney wrote: > > Not sure why this is "ridiculous". > > Right, versions are effectively a special type [0], specifically > *because* they intentionally don't compare as scalar numbers or > strings. It's not “ridiculous” to need custom comparisons when > that's the case. >

Re: pickle error by multiprocessing

2015-02-14 Thread Tim Golden
On 14/02/2015 13:19, Martijn Millecamp wrote: for a schoolproject we had to build a robot and control this robot with a gui to follow a path We use multiprocessing and in our group 2 people can run the code but if i run the code, i got a pickle error I have a windows 7 and use python 2.7 just lik

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread Tim Chase
On 2015-02-19 05:32, Mark Lawrence wrote: > On 19/02/2015 00:08, Mario Figueiredo wrote: > > Parameterized queries is just a pet peeve of mine that I wish to > > include here. SQLite misses it and I miss the fact SQLite misses > > it. The less SQL one needs to write in their code, the happier > > o

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread Tim Chase
On 2015-02-19 15:04, Mark Lawrence wrote: > On 19/02/2015 14:17, Tim Chase wrote: >>>> Parameterized queries is just a pet peeve of mine that I wish to >>>> include here. SQLite misses it and I miss the fact SQLite misses >>>> it. The less SQL one needs to wr

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread Tim Chase
On 2015-02-18 20:05, ru...@yahoo.com.dmarc.invalid wrote: > Sqlite offers concurrent access already. > What Sqlite doesn't offer is high performance concurrent write > access. That is, it locks the entire database for the duration > of a write operation. Given that most such operations are pre

Re: Accessible tools

2015-02-19 Thread Tim Chase
While not blind, I have an interest in accessibility and answer a number of questions on the Blinux (Blind Linux Users) mailing list. On 2015-02-19 08:33, Bryan Duarte wrote: > A professor and I have been throwing around the idea of developing > a completely text based IDE. There are a lot of reas

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-20 Thread Tim Chase
On 2015-02-20 13:17, Paul Rubin wrote: > For stuff like browser bookmarks or other typical embedded database > purposes, I don't see why SQL or relations are needed. Berkeley DB > is a transactional key-value store that's been around for decades > and is way simpler than SQLite, and there's other

Re: Accessible tools

2015-02-21 Thread Tim Chase
On 2015-02-21 10:21, Bryan Duarte wrote: > those of us who rely on screen readers to interact with our > computers have a few things we do, and tend to not do. [snip] While my experience has shown most of your items to be true, I'd contend that >• Do not, have access to debugging tools. is mist

Re: What behavior would you expect?

2015-02-22 Thread Tim Chase
On 2015-02-19 22:55, Jason Friedman wrote: > > If you're going to call listdir, you probably want to use fnmatch > > directly. > > > > fnmatch seems to be silent on non-existent directories: > python -c 'import fnmatch; fnmatch.fnmatch("/no/such/path", "*")' a better test would be glob.glob as f

Re: Accessible tools

2015-02-22 Thread Tim Chase
On 2015-02-22 20:29, Jacob Kruger wrote: > jaws, doesn't always cooperate perfectly with command line/console > interface I've heard that on multiple occasions. Since I mostly work with Linux, the only terminal-with-screen-reader hints I've heard involve using TeraTerm as the SSH client with NVDA

Re: calling subprocess

2015-02-22 Thread Tim Golden
On 22/02/2015 22:06, jkuplin...@gmail.com wrote: Hi, I thought this would be easy: for subprocess import call call (['cd', r'C:\apps'], shell = True) It doesn't work -- tried with/without prefix r, escaped backslashes, triple quotes, str(), .. nothing seems to work (it doesn't complain, but

Re: Python shell: Arrow keys not working in PuTTY

2015-02-23 Thread Tim Chase
On 2015-02-23 13:44, David Aldrich wrote: > I want to use the Python 3.4 interpreter interactively, via a PuTTY > ssh session. Python is running on Centos 5. > > Currently, the arrow keys do not work: [snip] > sudo apt-get install libreadline-dev > > followed by a rebuild of Python > > or > >

Re: Python Silent Install

2015-02-23 Thread Tim Golden
On 23/02/2015 13:57, Colin Atkinson wrote: > I am deploying Python to hundreds of machines using SCCM 2012. I am > using the below command to install: > > Msiexec /i “python.msi” TARGETDIR=”C:\Program Files\Python” > ALLUSERS=1 /qn > > Even though I am using /qn, a command prompt still appears

Re: Concatenate list values

2015-02-23 Thread Tim Chase
On 2015-02-23 07:58, loial wrote: > Is there a quick way to concatenate all the values in a list into a > string, except the first value? > > I want this to work with variable length lists. > > All values in list will be strings. Using "".join(my_list[1:]) should work. If it is an arbitrary

Re: Python Silent Install

2015-02-23 Thread Tim Golden
On 23/02/2015 15:29, Tim Golden wrote: > On 23/02/2015 13:57, Colin Atkinson wrote: >> I am deploying Python to hundreds of machines using SCCM 2012. I am >> using the below command to install: >> >> Msiexec /i “python.msi” TARGETDIR=”C:\Program Files\Python” >>

Re: Python Silent Install

2015-02-25 Thread Tim Golden
[... re installing with ensurepip disabled ...] On 24/02/2015 23:05, Albert-Jan Roskam wrote: > Personally I find that Python is incomplete without pip and setuptools. Of course; that's why the ensurepip was added to the installers. But there are other ways of installing pip after the event. Incl

Re: Python Silent Install

2015-02-25 Thread Tim Golden
On 25/02/2015 16:40, Mark Lawrence wrote: > On 25/02/2015 08:26, Tim Golden wrote: >> [... re installing with ensurepip disabled ...] >> >> On 24/02/2015 23:05, Albert-Jan Roskam wrote: >>> Personally I find that Python is incomplete without pip and setuptools. &

Re: Python programming

2014-02-12 Thread Tim Delaney
w to be more than just a programmer; came out the other end a senior developer/technical lead and effective communicator. And that's how I learned to program. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: Newcomer Help

2014-02-12 Thread Tim Delaney
;s worth the effort, but it can be really hard when you've got an already existing top-posted email thread with people using bizarre fonts and colours throughout. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: Wait... WHAT?

2014-02-12 Thread Tim Chase
On 2014-02-12 14:35, Ian Kelly wrote: > You can't write lists directly to files. You can only write strings > to files. To write and read a list, you'll need to first serialize > it and later deserialize it. To be pedantic, you can only write *bytes* to files, so you need to serialize your list

Re: Python programming

2014-02-12 Thread Tim Delaney
On 13 February 2014 08:02, Tim Delaney wrote: > I received a copy of "The Beginners Computer Handbook: Understanding & > programming the micro" (Judy Tatchell and Bill Bennet, edited by Lisa Watts > - ISBN 0860206947) > I should have noted that the examples were all B

Re: singleton ... again

2014-02-12 Thread Tim Delaney
hon, because Python either already has various patterns implemented, or obviates the need for them. For example, if you really need a singleton (answer - you don't) just use a module attribute. Functions as objects and iterators being so pervasive means that visitor and related patterns are just a normal style of programming, instead of having to be explicit. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: Wait... WHAT?

2014-02-12 Thread Tim Chase
On 2014-02-12 23:36, Mark Lawrence wrote: > On 12/02/2014 22:14, Tim Chase wrote: > > > > To be pedantic, you can only write *bytes* to files, so you need > > to serialize your lists (or other objects) to strings and then > > encode those to bytes; or skip the stri

Re: Wait... WHAT?

2014-02-12 Thread Tim Chase
On 2014-02-13 00:59, Mark Lawrence wrote: > s = "\u3141" # HANGUL LETTER MIEUM > f = open('test.txt', 'w') > f.write("\u3141") > > Traceback (most recent call last): > >File "", line 1, in > > UnicodeEncodeError: 'ascii' codec can't encode character '\u3141' > > in position 0:

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-13 Thread Tim Chase
On 2014-02-13 04:11, Steven D'Aprano wrote: > give_me_an_even_number() > => returns 42 > give_me_an_even_number() > => returns 23 > > Hmmm. There's a bug in give_me_an_even_number(). How do I reproduce > that bug? What arguments do I pass? Oh, the same no-arguments as > for the working call. > >

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-13 Thread Tim Chase
On 2014-02-13 05:39, Tim Chase wrote: > def age(self, as_of=None): > if as_of is None: > as_of = datetime.date.today() > return as_of = self.dob and of course I mean return as_of - self.dob which is what I get for typing in the dark and the "-" and

Re: Install python 2 and 3 in the "wrong" order

2014-02-13 Thread Tim Golden
On 13/02/2014 11:53, Nagy László Zsolt wrote: > I have Python 3.3 installed on my Windows 7 x64 box. Today I had to > install Python 2.7 for an older app of mine. > > Here is my problem: although "#!/usr/bin/env python3" is given in the > file and "py -3" program works fine, apparently the install

Re: AttributeError: '' object has no attribute 'SeriesCollection'

2014-02-13 Thread Tim Golden
On 13/02/2014 11:58, Jaydeep Patil wrote: > Just consider that you have chart object & you need to add data series for > that chart. How you can add this? Jaydeep: you're writing to a general Python list. Few of the people here run on Windows; fewer still will use Python to automate Excel via COM

Re: Install python 2 and 3 in the "wrong" order

2014-02-13 Thread Tim Golden
On 13/02/2014 12:03, Nagy László Zsolt wrote: > >> From a cmd window: >> >> ftype python.file="C:\Windows\py.exe" "%1" %* >> >> ftype python.noconfile="C:\Windows\pyw.exe" "%1" %* >> >> TJG > Thank you. It worked. Although I must note that it only works if you > start the cmd.exe as administrator

Re: singleton ... again

2014-02-13 Thread Tim Delaney
machinery - no need to reinvent the wheel. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: A curious bit of code...

2014-02-13 Thread Tim Chase
On 2014-02-13 10:37, forman.si...@gmail.com wrote: > I ran across this and I thought there must be a better way of doing > it, but then after further consideration I wasn't so sure. > > Some possibilities that occurred to me: > > if key.startswith('<') and key.endswith('>'): ... This is my fav

Re: Pythonwin forum?

2014-02-14 Thread Tim Golden
On 14/02/2014 03:17, John Doe wrote: > What's the best place for asking questions about the Pythonwin > IDE? > > I'm a novice programmer, so in an effort to be more clear I'm > talking about the program at this path on my hard drive... > > C:\Python27\Lib\site-packages\pythonwin\Pythonwin.exe

random.sample with large weighted sample-sets?

2014-02-15 Thread Tim Chase
I'm not coming up with the right keywords to find what I'm hunting. I'd like to randomly sample a modestly compact list with weighted distributions, so I might have data = ( ("apple", 20), ("orange", 50), ("grape", 30), ) and I'd like to random.sample() it as if it was a 100-ele

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread Tim Chase
On 2014-02-16 04:12, Terry Reedy wrote: > On 2/15/2014 11:41 PM, Tim Chase wrote: > >data = ( > > ("apple", 20), > > ("orange", 50), > > ("grape", 30), > > ) To Ben, yes, this was just some sample data; the or

Re: random.sample with large weighted sample-sets? [SOLVED]

2014-02-16 Thread Tim Chase
On 2014-02-16 14:47, Terry Reedy wrote: > > 2) the data has to be sorted for bisect to work > > cumulative sums are automatically sorted. Ah, that they were *cumulative* was the key that I missed in my understanding. It makes sense now and works like a charm. Thanks to all who offered a hand

Re: Dictionary help

2014-02-18 Thread Tim Chase
On 2014-02-18 10:30, kjaku...@gmail.com wrote: > So let's say I have a file and it looks like this: > Title 1: item > Title 2: item > etc > > Is it possible to use a dictionary for something like the input > above? Because I want to be able to use the input above to delete > the "Title 1" and "T

Re: Import order question

2014-02-18 Thread Tim Chase
On 2014-02-19 08:49, Chris Angelico wrote: > > Are you telling me you're willing to search through a single > > file containing 3,734 lines of code (yes, Tkinter) looking > > for a method named "destroy" of a class named "OptionMenu" > > At my last job, I had a single C++ file of roughly 5K line

Re: Remove comma from tuples in python.

2014-02-21 Thread Tim Chase
On 2014-02-21 09:29, Alister wrote: > >>>> seriesxlist1 = ((0.0,), (0.01,), (0.02,)) > >>>> x2 = [x*x for (x,) in seriesxlist1] > > > > I tend to omit those parentheses and use just the comma: > > > >>>> x2 = [x*x for x, in seriesxlist1] > > I had not though of using unpacking

Re: Remove comma from tuples in python.

2014-02-21 Thread Tim Chase
On 2014-02-21 09:48, Travis Griggs wrote: > I’ve used the comma form with struct.unpack() frequently: > > count, = struct.unpack(‘!I’, self.packet) This is *especially* one of those places I want extra parens to make sure I see what's happening. I've been stung too many times by the easy-to-miss

Re: Install python 2 and 3 in the "wrong" order

2014-02-24 Thread Tim Golden
ct ftype confiiguration you're describing, behaves as you would expect. c:\Users\tim>assoc .py .py=Python.File c:\Users\tim>ftype python.file python.file="C:\Windows\py.exe" "%1" %* c:\Users\tim>t.py 1 2 3 ['C:\\Users\\tim\\t.py', '

Re: Coding a simple state machine in python

2014-02-24 Thread Tim Daneliuk
pact ways - to do this, but this is the general idea. Now - go do your own homework :) -- Tim Daneliuk tun...@tundraware.com PGP Key: http://www.tundraware.com/PGP/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Coding a simple state machine in python

2014-02-24 Thread Tim Daneliuk
oice Bill Now you're making it TOO easy Bill ;) -- ---- Tim Daneliuk tun...@tundraware.com PGP Key: http://www.tundraware.com/PGP/ -- https://mail.python.org/mailman/listinfo/python-list

Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Tim Chase
On 2014-02-25 14:40, Skip Montanaro wrote: > What's the correct result of evaluating this expression? > > {'A': 1} | {'A': 2} > > I can see (at least) two possible "correct" answers. I would propose at least four: {'A': 1} # choose the LHS {'A': 2} # choose the RHS {'A': (1,2)} # a re

Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Tim Chase
On 2014-02-25 22:54, Peter Otten wrote: > Tim Chase wrote: > > If dicts were to support set ops, > > They do in 2.7 and 3.x. > > >>> a.viewkeys() - b.viewkeys() > set(['a']) > >>> a.viewkeys() & b.viewkeys() > set(['b'

Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Tim Chase
On 2014-02-25 22:21, Duncan Booth wrote: > > It would save some space if I didn't have to duplicate all the > > keys into sets (on the order of 10-100k small strings), instead > > being able to directly perform the set-ops on the dicts. But > > otherwise, it was pretty readable & straight-forward.

Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Tim Chase
On 2014-02-25 22:21, Duncan Booth wrote: > > It would save some space if I didn't have to duplicate all the > > keys into sets (on the order of 10-100k small strings), instead > > being able to directly perform the set-ops on the dicts. But > > otherwise, it was pretty readable & straight-forward.

Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Tim Chase
On 2014-02-25 23:10, Steven D'Aprano wrote: > On Tue, 25 Feb 2014 15:03:51 -0600, Tim Chase wrote: > > > On 2014-02-25 14:40, Skip Montanaro wrote: > >> What's the correct result of evaluating this expression? > >> > >> {'A': 1} | {&#

Re: posting code snippets

2014-02-27 Thread Tim Chase
On 2014-02-27 04:13, Mark H. Harris wrote: > are there rules here about posting code snippets, or length > considerations, and so forth? Seems like there was a place to share > code snips outside of the message area? This is the internet, so you're welcome to post code as you please. However, b

Re: Extracting parts of string between anchor points

2014-02-27 Thread Tim Chase
On 2014-02-27 20:07, Jignesh Sutar wrote: > I've kind of got this working but my code is very ugly. I'm sure > it's regular expression I need to achieve this more but not very > familiar with use regex, particularly retaining part of the string > that is being searched/matched for. While I suppose

Re: Extracting parts of string between anchor points

2014-02-27 Thread Tim Chase
On 2014-02-27 15:45, Tim Chase wrote: > >>> r = re.compile(r"^([^:]*)(?::((?:(?!-:-).)*)(?:-:-(.*))?)?") If you want to compare both the re method and the string method, here's a test-harness to play with: import re examples = [ ("", (None, None, N

Re: Password validation security issue

2014-03-01 Thread Tim Chase
On 2014-03-02 05:11, Chris Angelico wrote: > On Sun, Mar 2, 2014 at 4:49 AM, Renato wrote: > > My question is: is there a way of preventing the user from > > reading the script's content? Not really. It might be a bit obfuscated, but >> Is there any strategy I could use to hide the passwords f

Re: why indentation should be part of the syntax

2014-03-02 Thread Tim Chase
On 2014-03-03 01:08, Chris Angelico wrote: > > if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) > > { goto fail; > > goto fail; > > } > > Put it this way: If I saw two gotos in a row like that, with or > without braces, I would be firing up gitk or git gui blame or > s

Re: Reference

2014-03-03 Thread Tim Chase
On 2014-03-04 08:10, Ben Finney wrote: > > Long answer: > > http://www.beyondwilber.ca/healing-thinking/non-identity-korzybski.html > > Interesting, but mostly a distraction for the querent here. > > Short answer: Use ‘use’ any time you need to compare object > identity. You usually do not need

Re: Reference

2014-03-03 Thread Tim Chase
On 2014-03-03 21:35, Mark Lawrence wrote: > I'd just like to know why people are so obsessed with identities, > I've never thought to use them in 10+ years of writing Python. Do > I use the KISS principle too often? There are a couple use-cases I've encountered where "is" matters: 1) the most po

Re: How do I process this?

2014-03-03 Thread Tim Chase
On 2014-03-03 20:03, Igor Korot wrote: > Hi, ALL, > I have a csv file which depending on how it was produced gives 2 > different strings as shown in the example below (test1 and test2). > I am only interested in the first field in test1 and obviously in > the whole string of test2. > > So, I tried

Re: OT Sine Rule [was Re: Functional programming]

2014-03-04 Thread Tim Chase
On 2014-03-04 14:25, Steven D'Aprano wrote: > Ask-me-about-versine-and-haversine-ly y'rs, More interested in a karosine, cuisine, and a limousine. ;-) -tkc -- https://mail.python.org/mailman/listinfo/python-list

Re: OT Sine Rule [was Re: Functional programming]

2014-03-04 Thread Tim Chase
On 2014-03-04 14:42, Mark Lawrence wrote: > What do you get if you differentiate versines, haversines, > karosines, cuisines and limosines? Well, with cuisines, you can usually differentiate by seasoning: your Tex/Mex is spicier and tends to have chili & cumin, while your Indian tends to lean more

Re: Reference

2014-03-05 Thread Tim Chase
On 2014-03-05 17:26, Ben Finney wrote: > > "Jython is an imitation of Cpython and does a good job but not > > quite as in the case of 'id'" > > Wrong. Jython and CPython both adhere to the guarantees of object > identity. Both implementations follow the language reference, and > neither implemen

Re: Reference

2014-03-05 Thread Tim Chase
On 2014-03-05 09:40, Rustom Mody wrote: > Every object has an identity, a type and a value. An object's > identity never changes once it has been created; you may think of > it as the object's address in memory. The 'is' operator compares > the identity of two objects; the id() function returns an

Re: Reference

2014-03-05 Thread Tim Chase
On 2014-03-05 23:14, Marko Rauhamaa wrote: > When I talk about an object's memory address, I'm not referring to > what might be revealed by gdb, for example. That is, I'm not > talking about the process's virtual address space, nor am I talking > about the physical address on the address bus. I can

Re: Program Python

2014-03-05 Thread Tim Chase
On 2014-03-05 22:41, Luciano Trespidi wrote: > I'm very grateful if anyone can helpme to find a good program to > develop in python lenguage. Thanks This reminds me of the old joke: Q: Why are you scratching yourself? A: Because I'm the only one who knows where I itch! The best place to find

Re: Python programming

2014-03-06 Thread Tim Chase
On 2014-03-06 06:17, Steven D'Aprano wrote: > On Wed, 05 Mar 2014 20:19:56 -0800, Beowulf wrote: > > > Once you master one language it is easy to understand other. > > Depends on the languages. Learning Forth doesn't make it easier to > learn Perl. Learning Pascal doesn't make Smalltalk easier.

Re: Ternary operator associativity

2014-03-06 Thread Tim Chase
On 2014-03-06 03:34, candide wrote: > According to the official documentation, the ternary operator has > left-to-right associativity > > >>> left_to_right = (0 if 1 else 0) if 0 else 1 > >>> right_to_left = 0 if 1 else (0 if 0 else 1) I'd never want to rely on my own ability to remember the lang

Re: Python performance

2014-03-08 Thread Tim Chase
On 2014-03-08 04:53, JCosta wrote: > I did some work in c# and java and I converted some application to > Python; I noticed Python is much slower than the other languages. > > Is this normal ? It depends. Did you write C#/Java in Python (i.e., use C# or Java idioms in Python), or did you write P

Re: Windows installation problem with 3.3.5

2014-03-10 Thread Tim Golden
On 10/03/2014 03:16, Mark Lawrence wrote: > It looks as if the upgrade from 3.3.4 to 3.3.5 has stolen my copies of > py.exe and pyw.exe from c:\windows. Before I raise an issue on the bug > tracker could someone please confirm this, as it wouldn't be the first > time I've managed to screw somethin

Re: Windows installation problem with 3.3.5

2014-03-10 Thread Tim Golden
On 10/03/2014 03:16, Mark Lawrence wrote: > It looks as if the upgrade from 3.3.4 to 3.3.5 has stolen my copies of > py.exe and pyw.exe from c:\windows. Before I raise an issue on the bug > tracker could someone please confirm this, as it wouldn't be the first > time I've managed to screw somethin

Re: Balanced trees

2014-03-10 Thread Tim Chase
On 2014-03-11 03:24, Chris Angelico wrote: > Imagine, worst case, all one million records have the same > song/user/add_time and you need to do twenty comparisons involving > four fields. That's gotta be worse than one hashing of five fields. And if you have one million songs that are indistinguis

Re: Save to a file, but avoid overwriting an existing file

2014-03-12 Thread Tim Chase
On 2014-03-12 13:29, zoom wrote: > 2. Alternatively, a unique string could be generated to assure that > no same file exists. I can see one approach to this is to include > date and time in the file name. But this seems to me a bit clumsy, > and is not unique, i.e. it could happen (at least in theo

Re: which async framework?

2014-03-13 Thread Tim Chase
On 2014-03-14 00:25, Chris Withers wrote: > I've been pleasantly surprised by the succinct, well reasoned and > respectful replies from each of the communities! As one who doesn't lurk on the other lists, is there a nice executive summary of their responses? -tkc -- https://mail.python.org/m

Clearing out handlers in logging?

2014-03-15 Thread Tim Chase
The current (2.7; maybe 3.x?) logging module doesn't have any sort of "clear out all the current handlers" method. I can hack it by doing log = logging.getLogger() # get the root logger del log.handlers[:]# reach inside and nuke 'em log.addHandler(...)# install the one(s) I

Re: Clearing out handlers in logging?

2014-03-16 Thread Tim Chase
On 2014-03-16 09:39, Gunther Dietrich wrote: > Tim Chase wrote: > > >The current (2.7; maybe 3.x?) logging module doesn't have any sort > >of "clear out all the current handlers" method. > > Indeed, THERE IS a removeHandler() method. Yes, I'

Re: Clearing out handlers in logging?

2014-03-16 Thread Tim Chase
On 2014-03-16 19:29, Gunther Dietrich wrote: > >> Indeed, THERE IS a removeHandler() method. > > > >Yes, I'm aware of it, having read the source & docs. However, the > >signature is > > Sorry, your original article lacks information about what you > already know/tried and what not. So it is a

Re: Question about Source Control

2014-03-18 Thread Tim Chase
On 2014-03-18 21:38, Terry Reedy wrote: > At least with hg, one should best test the code in the working > directory *before* committing to the local repository. I don't know if this is a hg-vs-git way of thinking, but I tend to frequently commit things on a private development branch regardless

<    17   18   19   20   21   22   23   24   25   26   >