Re: Making Classes Subclassable

2016-07-05 Thread Lawrence D’Oliveiro
On Tuesday, July 5, 2016 at 5:27:01 PM UTC+12, Michael Selik wrote: > On Mon, Jul 4, 2016, 4:36 AM Lawrence D’Oliveiro wrote: > >> On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: >>> >>> --> "type(obj)" or "obj.__class__" (there are small differences) >>> give you the type/class of "ob

Re: Making Classes Subclassable

2016-07-05 Thread dieter
Lawrence D’Oliveiro writes: > On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: >> --> "type(obj)" or "obj.__class__" (there are small differences) >> give you the type/class of "obj". > > When would it not be the same? Special proxy objects, i.e. objects that try to behave as much as

Re: Need help compiling Python-devel

2016-07-05 Thread dieter
TM writes: > I have successfully compiled Python-2.7.12 on AIX 6.1 TL09, using steps > below. However I need the python-devel library/headers. How do I compile > Python, so that I can use this? The distinction between "python" and "python-devel" is not a Python notion but one of package manageme

Re: How well do you know Python?

2016-07-05 Thread Steven D'Aprano
On Tuesday 05 July 2016 16:38, Chris Angelico wrote: > On Tue, Jul 5, 2016 at 4:33 PM, Steven D'Aprano > wrote: >> What happens in this code snippet? >> >> L = [1] >> t = (L,) >> t[0] += 1 >> >> Explain what value t has, and why. > > Not sure you have that question right, because it

Re: Making Classes Subclassable

2016-07-05 Thread Steven D'Aprano
On Monday 04 July 2016 18:34, Lawrence D’Oliveiro wrote: > On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: >> --> "type(obj)" or "obj.__class__" (there are small differences) >> give you the type/class of "obj". > > When would it not be the same? class X(object): def __getattrib

Re: How well do you know Python?

2016-07-05 Thread Peter Otten
Chris Angelico wrote: > After some discussion with a Ruby on Rails programmer about where Ruby > ends and where Rails begins (and it's definitely not where I'd have > expected... Rails does a ton of monkey-patching, including of built-in > types, to provide functionality that is strangely absent f

A nestedmodule decorator (Re: Namespaces are one honking great idea)

2016-07-05 Thread Gregory Ewing
Steven D'Aprano wrote: There's only so far I can go without support from the compiler. It turns out one can go surprisingly far. Here's something I cooked up that seems to meet almost all the requirements. The only shortcoming I can think of is that a nestedmodule inside another nestedmodule wo

Re: How well do you know Python?

2016-07-05 Thread Christian Gollwitzer
Am 05.07.16 um 10:22 schrieb Steven D'Aprano: On Tuesday 05 July 2016 16:38, Chris Angelico wrote: On Tue, Jul 5, 2016 at 4:33 PM, Steven D'Aprano wrote: What happens in this code snippet? L = [1] t = (L,) t[0] += 1 Explain what value t has, and why. Not sure you have that que

Re: How well do you know Python?

2016-07-05 Thread Chris Angelico
On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten <__pete...@web.de> wrote: > What will > > $ cat foo.py > import foo > class A: pass > print(isinstance(foo.A(), A)) > $ python -c 'import foo' > ... > $ python foo.py > ... > > print? I refuse to play around with isinstance and old-style classes. Particu

Re: How well do you know Python?

2016-07-05 Thread Chris Angelico
On Tue, Jul 5, 2016 at 4:33 PM, Steven D'Aprano wrote: > > Got any other tricky questions to add? S P O I L E R S P A C E A N D A B I T M O R E [Thanks Steven, I just copied and pasted your space. See? You can copy and paste blank space and use it over and over. Could be a useful tip for t

Improved nestedmodule decorator implementation

2016-07-05 Thread Gregory Ewing
I wrote: The only shortcoming I can think of is that a nestedmodule inside another nestedmodule won't be able to see the names in the outer nestedmodule Actually, that's not correct -- the version I posted before actually crashes if you try to refer to a name in an outer nestedmodule from an in

Re: How well do you know Python?

2016-07-05 Thread Jussi Piitulainen
Chris Angelico writes: > On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten wrote: >> It looks like >> >> $ python3 -c 'print({1, 2})' >> {1, 2} >> $ python3 -c 'print({2, 1})' >> {1, 2} >> >> will always print the same output. Can you construct a set from two small >> integers where this is not the case

Re: How well do you know Python?

2016-07-05 Thread Steven D'Aprano
On Tue, 5 Jul 2016 06:36 pm, Peter Otten wrote: > It looks like > > $ python3 -c 'print({1, 2})' > {1, 2} > $ python3 -c 'print({2, 1})' > {1, 2} > > will always print the same output. Can you construct a set from two small > integers where this is not the case? What's the difference? Define "s

Re: How well do you know Python?

2016-07-05 Thread Steven D'Aprano
On Tue, 5 Jul 2016 07:51 pm, Jussi Piitulainen wrote: > Chris Angelico writes: > >> On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten wrote: >>> It looks like >>> >>> $ python3 -c 'print({1, 2})' >>> {1, 2} >>> $ python3 -c 'print({2, 1})' >>> {1, 2} >>> >>> will always print the same output. Can you c

Re: Improved nestedmodule decorator implementation

2016-07-05 Thread Steven D'Aprano
On Tue, 5 Jul 2016 07:31 pm, Gregory Ewing wrote: > I wrote: >> The only shortcoming I can think of is that a nestedmodule >> inside another nestedmodule won't be able to see the names >> in the outer nestedmodule > > Actually, that's not correct -- the version I posted before > actually crashes

Re: How well do you know Python?

2016-07-05 Thread Peter Otten
Chris Angelico wrote: > On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten <__pete...@web.de> wrote: >> What will >> >> $ cat foo.py >> import foo >> class A: pass >> print(isinstance(foo.A(), A)) >> $ python -c 'import foo' >> ... >> $ python foo.py >> ... >> >> print? > > I refuse to play around with

Re: How well do you know Python?

2016-07-05 Thread Chris Angelico
On Tue, Jul 5, 2016 at 9:33 PM, Peter Otten <__pete...@web.de> wrote: > Chris Angelico wrote: > >> On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten <__pete...@web.de> wrote: >>> What will >>> >>> $ cat foo.py >>> import foo >>> class A: pass >>> print(isinstance(foo.A(), A)) >>> $ python -c 'import foo'

Re: Nested class doesn't see class scope

2016-07-05 Thread eryk sun
On Tue, Jul 5, 2016 at 5:40 AM, Steven D'Aprano wrote: > On Tuesday 05 July 2016 14:41, Ian Kelly wrote: > >> Class definitions don't create closures like functions do. When Python >> executes a class definition, the metaclass creates a dict, and then >> the interpreter execs the class body using

Re: Making Classes Subclassable

2016-07-05 Thread Ian Kelly
On Tue, Jul 5, 2016 at 2:31 AM, Steven D'Aprano wrote: > On Monday 04 July 2016 18:34, Lawrence D’Oliveiro wrote: > >> On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: >>> --> "type(obj)" or "obj.__class__" (there are small differences) >>> give you the type/class of "obj". >> >> When w

Two curious errors when function globals are manipulated

2016-07-05 Thread Steven D'Aprano
I've come across two curious behaviours of a function using custom globals. In both cases, I have a function where __globals__ is set to a ChainMap. In the first, the builtin __import__ appears to both exist and not-exist at the same time: I can see the __import__ builtin, but the `import` stateme

Re: Making Classes Subclassable

2016-07-05 Thread Ian Kelly
On Mon, Jul 4, 2016 at 1:57 AM, dieter wrote: > Lawrence D’Oliveiro writes: > >> Some of the classes in Qahirah, my Cairo binding >> I found handy to reuse elsewhere, for >> example in my binding for Pixman . >> Subclassing

Re: Making Classes Subclassable

2016-07-05 Thread Ian Kelly
On Mon, Jul 4, 2016 at 2:34 AM, Lawrence D’Oliveiro wrote: > On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: >> --> "type(obj)" or "obj.__class__" (there are small differences) >> give you the type/class of "obj". > > When would it not be the same? I think the only remaining differenc

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread eryk sun
On Tue, Jul 5, 2016 at 2:46 PM, Steven D'Aprano wrote: > I've come across two curious behaviours of a function using custom globals. > In both cases, I have a function where __globals__ is set to a ChainMap. ChainMap implements the MutableMapping abstract base class. But CPython needs globals to

Re: Making Classes Subclassable

2016-07-05 Thread Steven D'Aprano
On Wed, 6 Jul 2016 12:41 am, Ian Kelly wrote: > On Tue, Jul 5, 2016 at 2:31 AM, Steven D'Aprano > wrote: >> On Monday 04 July 2016 18:34, Lawrence D’Oliveiro wrote: >> >>> On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: --> "type(obj)" or "obj.__class__" (there are small differen

Re: Making Classes Subclassable

2016-07-05 Thread Steven D'Aprano
On Wed, 6 Jul 2016 01:02 am, Ian Kelly wrote: > On Mon, Jul 4, 2016 at 2:34 AM, Lawrence D’Oliveiro > wrote: >> On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: >>> --> "type(obj)" or "obj.__class__" (there are small differences) >>> give you the type/class of "obj". >> >> When would i

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread eryk sun
On Tue, Jul 5, 2016 at 3:27 PM, eryk sun wrote: > ChainMap implements the MutableMapping abstract base class. But > CPython needs globals to be a dict. In the current implementation, > LOAD_GLOBAL calls _PyDict_LoadGlobal, and STORE_GLOBAL calls > PyDict_SetItem. They don't fall back on the abstra

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread Steven D'Aprano
On Wed, 6 Jul 2016 01:27 am, eryk sun wrote: > On Tue, Jul 5, 2016 at 2:46 PM, Steven D'Aprano > wrote: >> I've come across two curious behaviours of a function using custom >> globals. In both cases, I have a function where __globals__ is set to a >> ChainMap. > > ChainMap implements the Mutabl

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread eryk sun
On Tue, Jul 5, 2016 at 3:37 PM, eryk sun wrote: > In CPython 3.6, LOAD_GLOBAL does fall back on PyObject_GetItem I did some digging to find when this changed in 3.3: https://hg.python.org/cpython/diff/e3ab8aa0216c/Python/ceval.c Notice in the last comment on issue 14385 that Martijn wanted to u

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread Random832
On Tue, Jul 5, 2016, at 11:50, Steven D'Aprano wrote: > If PyDict_SetItem expects an actual dict (accept no substitutes or > subclasses), why is there no error? I would have expected a segfault at > worst or at least an exception. Subclasses are fine. Sort of. In general if you pass a *subclass* o

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread eryk sun
On Tue, Jul 5, 2016 at 3:50 PM, Steven D'Aprano wrote: > It works with exec: > > py> from collections import ChainMap > py> class ChainDict(ChainMap, dict): > ... pass > ... > py> m = ChainDict() > py> exec("x = 1", m, m) > py> m['x'] > 1 > > (Tested in both 3.3 and 3.6.) No, actually it does

Re: How well do you know Python?

2016-07-05 Thread Carl Meyer
On 07/05/2016 05:50 AM, Chris Angelico wrote: > On Tue, Jul 5, 2016 at 9:33 PM, Peter Otten <__pete...@web.de> wrote: >> Chris Angelico wrote: >> >>> On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten <__pete...@web.de> wrote: What will $ cat foo.py import foo class A: pass p

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread eryk sun
On Tue, Jul 5, 2016 at 4:12 PM, Random832 wrote: > So any special logic in your own __setitem__, which may have > included e.g. copying it to an alternate place, changing the key or > value, or simply refusing to add the item to the dictionary at all, will > be ignored, and your object may end up

Re: Need help compiling Python-devel

2016-07-05 Thread TM
This option is not straight forward. There are too many dependencies. Easier in Linux not so easy in AIX. Is it possible to copy the python executable (ie the code below)? # cp -p python python-devel Thanks, Tony On Tue, Jul 5, 2016 at 12:12 PM, Dieter Maurer wrote: > TM wrote at 2016-7-5 11

Help: Python unit testing

2016-07-05 Thread Harsh Gupta
Hello All, I have been trying to write a test framework for a pretty simple command server application in python. I have not been able to figure out how to test the socket server. I would really appreciate if you could help me out in testing this application using unittest. I'm new to this. Ple

Help: Python socket unit test framework

2016-07-05 Thread Harsh Gupta
Hello All, I have been trying to write a test framework for a pretty simple command server application in python. I have not been able to figure out how to test the socket server. I would really appreciate if you could help me out in testing this application using unittest. Please kindly revie

Re: py2exe crashes on simple program

2016-07-05 Thread John Nagle
On 7/4/2016 11:13 PM, Steven D'Aprano wrote: > If you change it to "library.exe" does it work? Also, I consider this > a bug in py2exe: - it's an abuse of assert, using it to check > user-supplied input; - it's a failing assertion, which by definition > is a bug. I'm not trying to build "librar

Appending an asterisk to the end of each line

2016-07-05 Thread Seymore4Head
import os f_in = open('win.txt', 'r') f_out = open('win_new.txt', 'w') for line in f_in.read().splitlines(): f_out.write(line + " *\n") f_in.close() f_out.close() os.rename('win.txt', 'win_old.txt') os.rename('win_new.txt', 'win.txt') I just tried to reuse this program that was posted se

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Joel Goldstick
On Tue, Jul 5, 2016 at 6:05 PM, Seymore4Head wrote: > import os > > f_in = open('win.txt', 'r') > f_out = open('win_new.txt', 'w') > > for line in f_in.read().splitlines(): > f_out.write(line + " *\n") > > f_in.close() > f_out.close() > > os.rename('win.txt', 'win_old.txt') > os.rename('win_ne

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Seymore4Head
On Tue, 5 Jul 2016 18:27:25 -0400, Joel Goldstick wrote: >On Tue, Jul 5, 2016 at 6:05 PM, Seymore4Head > wrote: >> import os >> >> f_in = open('win.txt', 'r') >> f_out = open('win_new.txt', 'w') >> >> for line in f_in.read().splitlines(): >> f_out.write(line + " *\n") >> >> f_in.close() >> f_

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Joel Goldstick
On Tue, Jul 5, 2016 at 6:29 PM, Seymore4Head wrote: > On Tue, 5 Jul 2016 18:27:25 -0400, Joel Goldstick > wrote: > >>On Tue, Jul 5, 2016 at 6:05 PM, Seymore4Head >> wrote: >>> import os >>> >>> f_in = open('win.txt', 'r') >>> f_out = open('win_new.txt', 'w') >>> >>> for line in f_in.read().splitl

Re: Appending an asterisk to the end of each line

2016-07-05 Thread MRAB
On 2016-07-05 23:05, Seymore4Head wrote: import os f_in = open('win.txt', 'r') f_out = open('win_new.txt', 'w') for line in f_in.read().splitlines(): f_out.write(line + " *\n") f_in.close() f_out.close() os.rename('win.txt', 'win_old.txt') os.rename('win_new.txt', 'win.txt') I just trie

Re: Need help compiling Python-devel

2016-07-05 Thread Michael Torrie
On 07/05/2016 10:35 AM, TM wrote: > This option is not straight forward. There are too many dependencies. > Easier in Linux not so easy in AIX. > > Is it possible to copy the python executable (ie the code below)? > # cp -p python python-devel What is this python-devel thing? You said you wanted

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Seymore4Head
On Tue, 5 Jul 2016 18:40:51 -0400, Joel Goldstick wrote: >On Tue, Jul 5, 2016 at 6:29 PM, Seymore4Head > wrote: >> On Tue, 5 Jul 2016 18:27:25 -0400, Joel Goldstick >> wrote: >> >>>On Tue, Jul 5, 2016 at 6:05 PM, Seymore4Head >>> wrote: import os f_in = open('win.txt', 'r') f

Re: Need help compiling Python-devel

2016-07-05 Thread Lawrence D’Oliveiro
On Wednesday, July 6, 2016 at 4:35:54 AM UTC+12, TM wrote: > > This option is not straight forward. There are too many dependencies. > Easier in Linux not so easy in AIX. POWER hardware? It might be easier and quicker to get Linux running on the machine, and figure it out there, than to try it u

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Joel Goldstick
On Tue, Jul 5, 2016 at 7:03 PM, MRAB wrote: > On 2016-07-05 23:05, Seymore4Head wrote: >> >> import os >> >> f_in = open('win.txt', 'r') >> f_out = open('win_new.txt', 'w') >> >> for line in f_in.read().splitlines(): >> f_out.write(line + " *\n") >> >> f_in.close() >> f_out.close() >> >> os.re

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Seymore4Head
On Wed, 6 Jul 2016 00:03:29 +0100, MRAB wrote: >On 2016-07-05 23:05, Seymore4Head wrote: >> import os >> >> f_in = open('win.txt', 'r') >> f_out = open('win_new.txt', 'w') >> >> for line in f_in.read().splitlines(): >> f_out.write(line + " *\n") >> >> f_in.close() >> f_out.close() >> >> os.re

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Chris Angelico
On Wed, Jul 6, 2016 at 9:04 AM, Seymore4Head wrote: > I am using XP and launching the program from another drive/folder than > the boot drive. > > The program has .py extension and the icon shows it is associated with > Python. > > I tried "start run" and then typed python and it did show the dos

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Seymore4Head
On Tue, 5 Jul 2016 19:15:23 -0400, Joel Goldstick wrote: >On Tue, Jul 5, 2016 at 7:03 PM, MRAB wrote: >> On 2016-07-05 23:05, Seymore4Head wrote: >>> >>> import os >>> >>> f_in = open('win.txt', 'r') >>> f_out = open('win_new.txt', 'w') >>> >>> for line in f_in.read().splitlines(): >>> f_out

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Seymore4Head
On Tue, 05 Jul 2016 19:29:21 -0400, Seymore4Head wrote: >On Tue, 5 Jul 2016 19:15:23 -0400, Joel Goldstick > wrote: > >>On Tue, Jul 5, 2016 at 7:03 PM, MRAB wrote: >>> On 2016-07-05 23:05, Seymore4Head wrote: import os f_in = open('win.txt', 'r') f_out = open('win_new.tx

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Seymore4Head
On Wed, 6 Jul 2016 09:38:47 +1000, Chris Angelico wrote: >On Wed, Jul 6, 2016 at 9:04 AM, Seymore4Head > wrote: >> I am using XP and launching the program from another drive/folder than >> the boot drive. >> >> The program has .py extension and the icon shows it is associated with >> Python. >> >

Re: Appending an asterisk to the end of each line

2016-07-05 Thread MRAB
On 2016-07-06 00:45, Seymore4Head wrote: On Tue, 05 Jul 2016 19:29:21 -0400, Seymore4Head wrote: On Tue, 5 Jul 2016 19:15:23 -0400, Joel Goldstick wrote: On Tue, Jul 5, 2016 at 7:03 PM, MRAB wrote: On 2016-07-05 23:05, Seymore4Head wrote: import os f_in = open('win.txt', 'r') f_out = o

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Seymore4Head
On Wed, 6 Jul 2016 01:05:12 +0100, MRAB wrote: >On 2016-07-06 00:45, Seymore4Head wrote: >> On Tue, 05 Jul 2016 19:29:21 -0400, Seymore4Head >> wrote: >> >>>On Tue, 5 Jul 2016 19:15:23 -0400, Joel Goldstick >>> wrote: >>> On Tue, Jul 5, 2016 at 7:03 PM, MRAB wrote: > On 2016-07-05 23:05

Re: Creating a calculator

2016-07-05 Thread BartC
On 02/07/2016 01:16, DFS wrote: On 7/1/2016 5:34 AM, Pierre-Alain Dorange wrote: More reduced : -- u=raw_input('Enter calculation:") print eval(u) -- works and compute : 1+2+3+4-1+4*2 2+3.0/2-0.5 Perform better and shorter, but l

Re: Appending an asterisk to the end of each line

2016-07-05 Thread MRAB
On 2016-07-06 01:05, Seymore4Head wrote: On Wed, 6 Jul 2016 01:05:12 +0100, MRAB wrote: On 2016-07-06 00:45, Seymore4Head wrote: On Tue, 05 Jul 2016 19:29:21 -0400, Seymore4Head wrote: On Tue, 5 Jul 2016 19:15:23 -0400, Joel Goldstick wrote: On Tue, Jul 5, 2016 at 7:03 PM, MRAB wrote:

Re: Making Classes Subclassable

2016-07-05 Thread Lawrence D’Oliveiro
On Wednesday, July 6, 2016 at 3:03:26 AM UTC+12, Ian wrote: > > On Mon, Jul 4, 2016 at 2:34 AM, Lawrence D’Oliveiro wrote: >> >> On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: >>> --> "type(obj)" or "obj.__class__" (there are small differences) >>> give you the type/class of "obj". >>

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Steven D'Aprano
On Wed, 6 Jul 2016 10:05 am, Seymore4Head wrote: > On Wed, 6 Jul 2016 01:05:12 +0100, MRAB > wrote: >>That suggests to me that it's an encoding problem (the traceback >>would've indicated that). >> >>Specify an encoding when you open the files: >> >>f_in = open('win.txt', 'r', encoding='utf-8')

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread Steven D'Aprano
On Wed, 6 Jul 2016 02:13 am, eryk sun wrote: > On Tue, Jul 5, 2016 at 3:50 PM, Steven D'Aprano > wrote: >> It works with exec: [...] > No, actually it doesn't work. Remember that when you store to a > variable, it's implicitly a local variable, for which CPython uses > STORE_NAME in unoptimized c

Re: Making Classes Subclassable

2016-07-05 Thread Lawrence D’Oliveiro
On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: > > Lawrence D’Oliveiro writes: > > > Some of the classes in Qahirah, my Cairo binding > I found handy to reuse elsewhere, for > example in my binding for Pixman . > S

Re: How well do you know Python?

2016-07-05 Thread Lawrence D’Oliveiro
On Tuesday, July 5, 2016 at 9:51:21 PM UTC+12, Jussi Piitulainen wrote: > > Chris Angelico writes: > >> Then hash randomization kicks in, and you can run the exact same line >> of code multiple times and get different results. It's a coin toss. > > Oh, nice, a new way to generate random bits in s

Re: Spot the bug: getoptquestion.py

2016-07-05 Thread Lawrence D’Oliveiro
On Tuesday, July 5, 2016 at 1:42:42 AM UTC+12, Chris Angelico wrote: > The getopt module is designed to match the C getopt function, which I've > never used; for my command-line parsing, I use argparse instead > (usually via some wrapper that cuts down the duplication, like clize). getopt seems s

Re: Spot the bug: getoptquestion.py

2016-07-05 Thread Chris Angelico
On Wed, Jul 6, 2016 at 2:04 PM, Lawrence D’Oliveiro wrote: > On Tuesday, July 5, 2016 at 1:42:42 AM UTC+12, Chris Angelico wrote: > >> The getopt module is designed to match the C getopt function, which I've >> never used; for my command-line parsing, I use argparse instead >> (usually via some wr

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Larry Hudson via Python-list
On 07/05/2016 03:05 PM, Seymore4Head wrote: import os f_in = open('win.txt', 'r') f_out = open('win_new.txt', 'w') for line in f_in.read().splitlines(): f_out.write(line + " *\n") f_in.close() f_out.close() os.rename('win.txt', 'win_old.txt') os.rename('win_new.txt', 'win.txt') I just

Re: Appending an asterisk to the end of each line

2016-07-05 Thread cs
On 05Jul2016 21:37, Python List wrote: On 07/05/2016 03:05 PM, Seymore4Head wrote: import os f_in = open('win.txt', 'r') f_out = open('win_new.txt', 'w') for line in f_in.read().splitlines(): f_out.write(line + " *\n") f_in.close() f_out.close() os.rename('win.txt', 'win_old.txt') os.re

Re: How well do you know Python?

2016-07-05 Thread Jussi Piitulainen
Steven D'Aprano writes: > On Tue, 5 Jul 2016 07:51 pm, Jussi Piitulainen wrote: > >> Chris Angelico writes: >> >>> On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten wrote: It looks like $ python3 -c 'print({1, 2})' {1, 2} $ python3 -c 'print({2, 1})' {1, 2} will

Learn Python + Swift 3 by creating a comprehensive system with web app and iOS app

2016-07-05 Thread Leo Trieu
Guys, we're from Code4Startup team and we're running a KickStarter campaign for the next awesome course to bring best value to Python and Swift community. In this course, you will learn how to use Python and Swift 3 by cloning cool startup apps like UberEats, Doordash or Postmates. In case you'