(any)dbm module lacks a context manager

2013-01-31 Thread python . list
I don't know if this has been remedied in a more recent version than
I've got on my box (Debian Stable), but it seems like it should work
out of the box:

Python 3.1.3 (r313:86834, Nov 28 2010, 10:01:07) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbm
>>> with dbm.open("mydb", 'c') as d:
... d["hello"] = "world"
... 
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: '_dbm.dbm' object has no attribute '__exit__'


I'm guessing it's an easy fix? (or even already fixed)

-tkc



-- 
http://mail.python.org/mailman/listinfo/python-list


Czy dysponujesz dwoma wolnymi godzinami w tygodniu? Oto jak zarobc 185 EUR w tym czasie.

2012-05-24 Thread python-list

Dzien dobry!

Dziekujemy bardzo za zainteresowanie pozycja regionalnego przedstawiciela dostepna obecnie w Polsce i krajach Europy Srodkowej. 


Chcialem by przedstawic, bardzo krotko - nasza wybitna firme.
W.U.G. Inc zostala zalozona w 1992 roku i obecnie stala sie jedna z najbardziej 
uznawanych firm biznesowych, ktore zapewniaja kompleksowa obsluge swoim 
klientom.
Siec przedstawicielstw West Union Group jest reprezentowana w ponad 32 krajach 
i swiadczy uslugi do 46 krajow.
Specjalizujemy sie w doradztwie w zakresie planowania podatkowego, rejestracji 
firm, nadajac rowniez dodatkowe finansowe uslugi wsparcia dla firm 
zagranicznych.
WUG jest dobrze znana w USA, Kanadzie i niektorych panstwach Unii Europejskiej.

Nasza firma nie moze pozwolic na stworzenie regionalnego biura w kazdym kraju z 
powodu wysokich kosztow operacyjnych, z tego powodu pragniemy wynajac 
przedstawiciela regionalnego wypelniac powierzone mu zadania.
Wiekszosc naszych operacji z klientami sa przeprowadzane w Internecie.

Kiedy klient jest gotowy oplacic za korzystanie z naszych uslug, regionalny 
przedstawiciel bedzie musial pomoc mu / jej przetworzyc platnosci i upewnic 
sie, ze fundusze zostaly otrzymane w naleznym czasie.

Regionalny Przedstawiciel bedzie odpowiedzialny za pomoc naszym klientom z 
niektorymi ugodami i przetwarzanie przelewow.

Gwarantujemy wynagrodzenie w wysokosci 2500 EUR miesiecznie wyplacane co dwa 
tygodnie.

Nalezy pamietac, ze duza czesc zadan zostanie przedstawiona w ciagu dziennego 
czasu.
Zwroccie uwage, ze proponujemu pozycje o niepelnym wymiarze godzin, wiec trzeba 
bedzie wydac tylko 2-3 godzin dziennie na tej prace.

WUG Inc zabezpieczy nowego pretendenta w calosci oplacalnym dwutygodniowym 
treningowym okresem.
Otrzymaja Panstwo wszystkie niezbedne informacje na temat szkolen od naszego 
specjalisty po zatrudnieniu.

Jesli znajdujecie to interesujacym, zyczliwie prosimy was podac nam wasze dane 
kontaktowe (naprzyklad numer telefonu, imie i nazwisko), abysmy mogli 
skontaktowac sie z wami dla dalszej komunikacji.
Prosimy nie wahajcie sie z nami skontaktowac w kazdej chwili, jesli macie 
jakiekolwiek dodatkowe pytania dotyczace tej pozycji.

Nasz e-mail: maksymil...@toppolandjobs.com,Najcieplej pozdrawiamy,

Maksymilian Skrzypinski
Menadzer personelu
WUG Inc
--
http://mail.python.org/mailman/listinfo/python-list


look what I've found

2016-05-29 Thread Python-list
Hey,

Look what I've just found on the web, that really cool, yeah, more info here 
<http://tycraxyphe.wisewomanseries.com/aegbd>

My Best, Python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Best Practice Question

2013-02-05 Thread python . list
On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote:
> By the way, did someone ever notice that r'\' fails ? I'm sure
> there's a reason for that... (python 2.5) Anyone knows ?
> 
> r'\'
> SyntaxError: EOL while scanning single-quoted string

I hit this all the time with Vim's path-completion (":help
i_CTRL-X_CTRL-F") on Win32 which puts a trailing "\" on
directory-names.  I just need to remember to remove it, a task made
easier because the syntax highlighting correctly shows how Python
interprets it (i.e., the string is still continued).

-tkc


-- 
http://mail.python.org/mailman/listinfo/python-list


Dead lock in pymat after using threading?

2007-08-28 Thread Python list
"Hi,

I'm having problems using the package pymat after using threading, e.g. the
line:

#
h = pymat.open()
#

is not possible to fully execute after the lines:

#
import threading
from time import sleep

def SlpFcn():
sleep(5)
print "end of sleep"

trd = threading.Thread(target=SlpFcn)
trd.start()
#

MATLAB is started as it should, but the python interpreter does not answer
and has to be shut
down using CTRL+ALT+DEL. After restarting the interpreter it is possible to
use pymat again
without problems (seems to be some kind of memory issue).

What differences between before and after threading are there, that could
cause these problems?
("del trd" or "gc.collect" after the threading, does not solve my problem.)
I'm using Python 2.2 in ControlDesk, Windows XP.

Thanks,
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Embedding the python interpreter

2007-08-28 Thread Python list
Hi,
Do you mean something like py2exe?

http://www.py2exe.org/
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Logging hangs thread after detaching a StreamHandler's terminal

2006-02-13 Thread python-list . overbored
Apologies, I seem to have sent this to the wrong list. (Though now
that it's out here...any answers would be most welcome. :)

On 2/14/06, I wrote:
> Hi all,
>
> After many hours, I think I've found a bug in the logging module!
>
> If you add a (stdout) StreamHandler to a logger, then detach the
> terminal for that stdout, subsequent calls to log() will hang the
> calling thread.
>
> To reproduce this, write the following scripts (this was a small test
> case I came up with - maybe there's something simpler):
>
> $ cat tryhup.bash
> #!/usr/bin/env bash
> scp hup.* localhost:
> ssh localhost './hup.bash ; while true ; do sleep 1 ; done'
>
> $ cat hup.bash
> #!/usr/bin/env bash
> ./hup.py &
>
> $ cat hup.py
> #!/usr/bin/env python
> import time
> import logging
> f = file( '/tmp/hup.out', 'w' )
> try:
>logging.basicConfig( filename = '/tmp/lup.out', filemode = 'w' )
># XXX PROBLEM LINE BELOW
>logging.getLogger('').addHandler( logging.StreamHandler() )
>while True:
>f.write( '---\n' )
>f.flush()
>logging.critical( '==' )
>time.sleep(1)
> finally:
>f.close()
>
> Run ./tryhup.bash. It will sit in an idle spin. Monitor the files
> /tmp/hup.out and /tmp/lup.out. Hit Ctrl-C on tryhup to kill it. The
> python process is still running, but is stalled (the .out files are no
> longer changing).
>
> If you remove the above labeled line, however, this doesn't happen.
>
> Can anybody please acknowledge this bug? Any temporary workarounds to
> this problem? Thanks in advance for looking into this and for hearing
> me in!
>

-- 
http://mail.python.org/mailman/listinfo/python-list


Logging hangs thread after detaching a StreamHandler's terminal

2006-02-13 Thread python-list . overbored
Hi all,

After many hours, I think I've found a bug in the logging module!

If you add a (stdout) StreamHandler to a logger, then detach the
terminal for that stdout, subsequent calls to log() will hang the
calling thread.

To reproduce this, write the following scripts (this was a small test
case I came up with - maybe there's something simpler):

$ cat tryhup.bash
#!/usr/bin/env bash
scp hup.* localhost:
ssh localhost './hup.bash ; while true ; do sleep 1 ; done'

$ cat hup.bash
#!/usr/bin/env bash
./hup.py &

$ cat hup.py
#!/usr/bin/env python
import time
import logging
f = file( '/tmp/hup.out', 'w' )
try:
logging.basicConfig( filename = '/tmp/lup.out', filemode = 'w' )
# XXX PROBLEM LINE BELOW
logging.getLogger('').addHandler( logging.StreamHandler() )
while True:
f.write( '---\n' )
f.flush()
logging.critical( '==' )
time.sleep(1)
finally:
f.close()

Run ./tryhup.bash. It will sit in an idle spin. Monitor the files
/tmp/hup.out and /tmp/lup.out. Hit Ctrl-C on tryhup to kill it. The
python process is still running, but is stalled (the .out files are no
longer changing).

If you remove the above labeled line, however, this doesn't happen.

Can anybody please acknowledge this bug? Any temporary workarounds to
this problem? Thanks in advance for looking into this and for hearing
me in!

-- 
http://mail.python.org/mailman/listinfo/python-list


Using __init__.py

2017-09-06 Thread Kryptxy via Python-list
I am working on a (cross-platform) project. On linux system, the imprts work 
fine, but in windows I get imort error (I have no idea why. I tried searching 
everywhere, but couldn't get it to work).
Anyways, the issue seem to be resolved by adding project directory to 
sys.path().

I wanted to know that can I use __init__.py file for adding a project directory 
to sys.path (sys.path.insert(0, directory))?
-- 
https://mail.python.org/mailman/listinfo/python-list


non-standard glibc location

2017-09-06 Thread Fetchinson . via Python-list
Hi folks,

I'm trying to install a binary package (tensorflow) which contains
some binary C extensions. Now my system glibc is 2.15 but the binaries
in the C extensions were created (apparently) with glibc 2.17. So I
thought no problemo I installed glibc 2.17 to a custom location, built
python2.7 from source (hopefully using my custom glibc) and installed
pip and everything else using this custom built python. But still when
I try to import tensorflow I get:

ImportError: /lib64/libc.so.6: version `GLIBC_2.17' not found
(required by 
/home/nogradi/fetch/custom/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so)

So apparently it's trying to use my system glibc, not the custom one.

How do I tell this extension to use the custom glibc? Is it even possible?

But maybe I have an even more basic issue: how do I link python not
with the system glibc but with my custom glibc?

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: non-standard glibc location

2017-09-07 Thread Fetchinson . via Python-list
On 9/7/17, Thomas Jollans  wrote:
> On 2017-09-06 16:14, Fetchinson . via Python-list wrote:
>> Hi folks,
>>
>> I'm trying to install a binary package (tensorflow) which contains
>> some binary C extensions. Now my system glibc is 2.15 but the binaries
>> in the C extensions were created (apparently) with glibc 2.17. So I
>> thought no problemo I installed glibc 2.17 to a custom location, built
>> python2.7 from source (hopefully using my custom glibc) and installed
>> pip and everything else using this custom built python. But still when
>> I try to import tensorflow I get:
>>
>> ImportError: /lib64/libc.so.6: version `GLIBC_2.17' not found
>> (required by
>> /home/nogradi/fetch/custom/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so)
>>
>> So apparently it's trying to use my system glibc, not the custom one.
>>
>> How do I tell this extension to use the custom glibc? Is it even
>> possible?
>
> It's going to use the same libc as python, so first of all check which
> libc your python interpreter is actually linked to. Maybe your custom
> build didn't do quite what you wanted.
>
> ldd `which python` # or something like that
>
> Once you've convinced yourself that python has the correct libc, you
> could try building tensorflow from source rather than installing the
> binaries.
>
> Maybe something in here helps:
> https://github.com/tensorflow/tensorflow/issues/53

Thanks a lot for all the comments, my problem was indeed that the
compiled python was still using the system glibc. The solution was to
set the environment variables

p=/path/to/custom/glibc
export CFLAGS=-I${p}/include
export LDFLAGS="-Wl,--rpath=${p}/lib
-Wl,--dynamic-linker=${p}/lib/ld-linux-x86-64.so.2"

And then the compiled python was using the new glibc.

Side note 1 on tensorflow: the compiled tensorflow binary uses unicode
ucs4, so for python I had to ./configure --enable-unicode=ucs4 because
the default is ucs2

Side note 2 on tensorflow: it also depends on libstdc++ and my version
was too old for that as well. Instead of compiling gcc from source
(which includes libstdc++) I copied a binary libstdc++ from a newer
linux distro and it was working fine.

And the reason, if anyone cares, I had to go through the above is that
I couldn't compile tensorflow from source.

Thanks again,
Daniel




>
>>
>> But maybe I have an even more basic issue: how do I link python not
>> with the system glibc but with my custom glibc?
>>
>> Cheers,
>> Daniel
>>
>>
>>
>
>
> --
> Thomas Jollans
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Torrench - Torrent search made simple

2017-09-10 Thread Kryptxy via Python-list
Torrench: Command-line torrent search program (cross-platform). Torrent search 
made quick and simple.

GitHub: https://github.com/kryptxy/torrench

Suggestions/feedbacks are highly appreciated.
-- 
https://mail.python.org/mailman/listinfo/python-list


ttk.Notebook Tabs Question

2017-09-11 Thread Wildman via Python-list
I am working on a program that has a ttk.Notebook with
12 tabs.  Is there a way to determine the total width
of the tabs in pixels.  Just to be clear I am not talking
about width of the nb container.  I am talking about
tabs themselves that contain the text.

I want the program to be resizable but I don't want to
allow the window width to fall below that of the tabs
which would hide them.  Since I can find no way to have
more than one row of tabs, this appears to be my only
option.  Any suggestions would be appreciated.

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] beginning to code

2017-09-12 Thread alister via Python-list
On Tue, 12 Sep 2017 08:03:58 -0700, Rick Johnson wrote:

> Chris Angelico wrote:
>> Rick Johnson wrote:
>> > Ruby:
>> > farray = [1.5, 1.9, 2.0, 1.0]
>> > uniqueIntegers = farray.map{|f| f.to_i()}.uniq.length
>> >
>> > Python:
>> > flist = [1.5, 1.9, 2.0, 1.0]
>> > uniqueIntegers = len(set(map(lambda f:int(f), flist)))
>>
>> Python:
>>
>> floats = [1.5, 1.9, 2.0, 1.0]
>> unique_integers = len(set(int(f) for f in floats))
>>
>> or:
>>
>> unique_integers = len(set(map(int, floats))
>>
>> If you're going to use Python, at least use it right.
> 
> Okay, you've replaced my map function with an implicit list
> comprehension (aka: generator expression)... so how is either more
> "right" than the other? What is your justification that your example is
> "right", and mine is not?
> 
> (1) Is is a speed issue? Then prove it.
> 
> (2) Is it a readability issue? If so, then that's an opinion _you_ get
> to have.
> 
> (3) Is a matter of "python purity"?  If so, then map should be removed
> from the language. And don't forget to remove reduce and filter while
> you're at it. And then, you may want to grab a shield, because the
> functional fanboys will be all over you like white on rice!
> 
> (4) Something else...?

for me the fact that you have had to resort to a lambda when the other 
solutions show it is unnecessary do it for me.

I guess that falls into option 2 but it is an opinion that I can at least 
offer some justification for, especially considering you were using it as 
an example of how ruby was cleaner than python.

were i to be less generous I would suggest that you had deliberately 
picked the worst python method you could think of to make the point



-- 
"jackpot:  you may have an unneccessary change record"
-- message from "diff"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Brainstorming on recursive class definitions

2017-09-12 Thread moogyd--- via Python-list
On Tuesday, September 12, 2017 at 5:37:31 PM UTC+2, Johannes Bauer wrote:
> Hi group,
> 
> so I'm having a problem that I'd like to solve *nicely*. I know plenty
> of ways to solve it, but am curious if there's a solution that allows me
> to write the solution in a way that is most comfortable for the user.
> 
> I'm trying to map registers of a processor. So assume you have a n bit
> address space, the processor might have duplicate units of identical
> functionality mapped at different places in memory. For example, assume
> there's a GPIO unit that has registers FOO, BAR and KOO and two GPIO
> ports GPIOA and GPIOB. I'd like to write code along the lines of this:
> 
> class GpioMap(BaseRegisterMap):
>   FOO = 0x0
>   BAR = 0x4
>   KOO = 0x8
> 
> class CPURegisterMap(BaseRegisterMap):
>   GPIOA = GpioMap(0x1)
>   GPIOB = GpioMap(0x2)
> 
> cpu = CPURegisterMap(0x8000)
> 
> assert(cpu.addr == 0x8000)
> assert(cpu.GPIOA.addr == 0x8000 + 0x1)
> assert(cpu.GPIOB.addr == 0x8000 + 0x2)
> assert(cpu.GPIOA.FOO.addr == 0x8000 + 0x1 + 0x0)
> assert(cpu.GPIOA.KOO.addr == 0x8000 + 0x1 + 0x8)
> assert(cpu.GPIOB.BAR.addr == 0x8000 + 0x2 + 0x4)
> 
> So, obviously, FOO, BAR and KOO are of type "int" without any "addr"
> property, so there would need to be some magic there. Additionally,
> through some way the instanciation of GpioMap() would need the knowledge
> of its parent base, which I'm not sure is even possible. Maybe (that's
> what I'm currently trying to get right) the __getattribute__ would
> propagate the information about the accumulated parent's base address to
> the child during lookup.
> 
> Anyways, I'm looking for your ideas on how to solve such a thing
> "nicely". Note that "BaseRegisterMap" is allowed to do dirty things as
> long as the definition code has a clean look & feel.
> 
> Cheers,
> Joe
> 
> 
> -- 
> >> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> > Zumindest nicht öffentlich!
> Ah, der neueste und bis heute genialste Streich unsere großen
> Kosmologen: Die Geheim-Vorhersage.
>  - Karl Kaos über Rüdiger Thomas in dsa 

A child (e.g. instance of GpioMap) should not have any knowledge of it's own 
base address. This is a function of the GPIORegisyerMap only.
i.e. The GPIORegisyerMap  would do the selection of particular instance.

It may be worth looking at some of the IP-XACT documentation, which defines 
some common terms (IIRC register, address map, address space etc). Having a 
consistent definition here will definitely help moving forward
Although it may seem OTT at the moment, it is something you should consider at 
the outset.
e.g. A single GPIO register may occur at two different addresses, depending on 
the bus master (CPU Core, Debugger, External SPI access).

Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python dress

2017-09-13 Thread alister via Python-list
On Wed, 13 Sep 2017 04:15:26 +, Steven D'Aprano wrote:

> On Wed, 13 Sep 2017 01:12:25 +0100, MRAB wrote:
> 
>>> I don't recall seeing them go into paroxysms of gender confusion when
>>> Prince Charles,
>>> Duke of Edinburgh, appears in public wearing a kilt.
>> 
>> You do know that Prince Charles is the Prince of Wales and that the
>> Duke of Edinburgh is his father, don't you? :-)
> 
> Ah, yes, thanks for the correction. Of course I was thinking about
> Prince Philip, not Charles.

but they both wear kilts so your statement could have said when prince 
charles OR the duke of edinburgh... 



-- 
Madness takes its toll.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python dress

2017-09-13 Thread alister via Python-list
On Wed, 13 Sep 2017 10:15:48 +0200, Thomas Jollans wrote:

> On 2017-09-13 02:12, MRAB wrote:
>> On 2017-09-13 00:32, Steve D'Aprano wrote:
>>> The amusing thing to my mind is that the pro-discrimination,
>>> anti-equality faction also tend to be the most conservative[1]
>>> pro-monarchy faction.
>>> I don't recall seeing them go into paroxysms of gender confusion when
>>> Prince Charles,
>>> Duke of Edinburgh, appears in public wearing a kilt.
>>>
>> You do know that Prince Charles is the Prince of Wales and that the
>> Duke of Edinburgh is his father, don't you? :-)
> 
> Big difference. One will never be king, the other should never be king.

The other will quite correctly be King there is no constitutional reason 
why not
(or are you another one of  the many who try to hide from their own part 
in the death of Diana by blaming the royals).


-- 
Mystics always hope that science will some day overtake them.
-- Booth Tarkington
-- 
https://mail.python.org/mailman/listinfo/python-list


Change project licence?

2017-09-14 Thread Kryptxy via Python-list
Hi,
I have an opensource (python) project under GPL3 licence. I wish switch to MIT 
licence so as to make it more permissive.
I know how to change the licence, but I want to know is it fine and wise to 
change the licence at this point?
(The project already has 19 clones, 250+ GitHub stars. Here: 
https://github.com/kryptxy/torrench)

Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ttk.Notebook Tabs Question

2017-09-15 Thread Wildman via Python-list
On Fri, 15 Sep 2017 06:09:21 +0400, Abdur-Rahmaan Janhangeer wrote:

> try
> widget["width"] it returns string
> then mult by no. of tabs

Since the tabs are displaying text, I believe the width
would be returned as characters or letters like a Button
or Text widget.  I need pixels.

Another problem is that the tabs are different widths.

I am going to experiment with the possibility of using
images in place of the text.  Then I believe the width
would be returned in pixels.

Thanks for the reply.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ttk.Notebook Tabs Question

2017-09-15 Thread Wildman via Python-list
On Fri, 15 Sep 2017 20:45:20 +0100, MRAB wrote:

> On 2017-09-15 16:24, Wildman via Python-list wrote:
>> On Fri, 15 Sep 2017 06:09:21 +0400, Abdur-Rahmaan Janhangeer wrote:
>> 
>>> try
>>> widget["width"] it returns string
>>> then mult by no. of tabs
>> 
>> Since the tabs are displaying text, I believe the width
>> would be returned as characters or letters like a Button
>> or Text widget.  I need pixels.
>> 
> Why assume that the width is returned as characters? Why not try it?

If I set the width of the tabs, the width is in characters
so I expected it to be the same.

style = ttk.Style()
style.theme_create( "MyStyle", parent="alt", settings={
"TNotebook": {"configure": {"tabmargins": [2, 5, 2, 0] } },
"TNotebook.Tab": {"configure": {"padding": [0,0], "width": [7]}, }})
style.theme_use("MyStyle")

Also, I tried "widget["width"] and it returns 0.  Same
for height.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Test Bank for Governing Texas, 3rd Edition by Champagne Harpham

2017-09-17 Thread alister via Python-list
> 
> 
> I am interested in the testbank for this book. What is the price ?


Don't encourage spammers


-- 
California, n.:
From Latin "calor", meaning "heat" (as in English "calorie" or
Spanish "caliente"); and "fornia'" for "sexual intercourse" or
"fornication." Hence: Tierra de California, "the land of hot sex."
-- Ed Moran
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ttk.Notebook Tabs Question

2017-09-17 Thread Wildman via Python-list
On Sun, 17 Sep 2017 08:45:27 +0400, Abdur-Rahmaan Janhangeer wrote:

> by widget["width"] i meant replace widget with your widget

Yes, that is what I did.  It returned 0.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Research paper "Energy Efficiency across Programming Languages: How does energy, time, and memory relate?"

2017-09-20 Thread alister via Python-list
On Tue, 19 Sep 2017 14:40:17 -0400, leam hall wrote:

> On Tue, Sep 19, 2017 at 2:37 PM, Stephan Houben <
> stephan...@gmail.com.invalid> wrote:
> 
>> Op 2017-09-19, Steven D'Aprano schreef > pearwood.info>:
>>
>> > There is a significant chunk of the Python community for whom "just
>> > pip install it" is not easy, legal or even possible. For them, if its
>> > not in the standard library, it might as well not even exist.
>>
>> But numpy *is* in the standard library, provided you download the
>> correct version of Python, namely the one from:
>>
>> https://python-xy.github.io/
>>
>> Stephan
>>
>>
> Many of us can't pip install; it's in the OS supplied vendor repo or it
> doesn't go on the machines.
> 
> Leam

dnf install 
or
apt_get install 

most of the mainstream modules seem to be there (certainly numpy)



-- 
Kliban's First Law of Dining:
Never eat anything bigger than your head.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Research paper "Energy Efficiency across Programming Languages: How does energy, time, and memory relate?"

2017-09-20 Thread alister via Python-list
On Wed, 20 Sep 2017 14:14:24 +0100, Paul Moore wrote:

> On 20 September 2017 at 13:58, alister via Python-list
>  wrote:
>> On Tue, 19 Sep 2017 14:40:17 -0400, leam hall wrote:
>>
>>> On Tue, Sep 19, 2017 at 2:37 PM, Stephan Houben <
>>> stephan...@gmail.com.invalid> wrote:
>>>
>>>> Op 2017-09-19, Steven D'Aprano schreef >>> pearwood.info>:
>>>>
>>>> > There is a significant chunk of the Python community for whom "just
>>>> > pip install it" is not easy, legal or even possible. For them, if
>>>> > its not in the standard library, it might as well not even exist.
>>>>
>>>> But numpy *is* in the standard library, provided you download the
>>>> correct version of Python, namely the one from:
>>>>
>>>> https://python-xy.github.io/
>>>>
>>>> Stephan
>>>>
>>>>
>>> Many of us can't pip install; it's in the OS supplied vendor repo or
>>> it doesn't go on the machines.
>>>
>>> Leam
>>
>> dnf install 
>> or apt_get install 
>>
>> most of the mainstream modules seem to be there (certainly numpy)
> 
> You're missing the point. A significant number of Python users work on
> systems where:
> 
> 1. They have no admin rights 2. Their corporate or other policies
> prohibit installing 3rd party software without approval that is
> typically difficult or impossible to get 3. Quite possibly the system
> has no network access outside of the local intranet 4. The system admins
> may not be able or willing to upgrade or otherwise modify the system
> Python
> 
> Writing code that works only with stdlib modules is basically the only
> option in such environments.
> 
> Having said that, I don't advocate that everything be in the stdlib
> because of this. A lot of things (such as numpy) belong as 3rd party
> packages. But that doesn't mean that "get XYZ off PyPI" (or "install XYZ
> alternative Python distribution/version") is a viable solution to every
> problem.
> 
> Paul

not missing the point you said previously "it's in the OS supplied vendor 
repo or it doesn't go on the machines."

dnf/yum or apt_get install form the "vendor supplied repo"

I fully understand that even this may require various hoops to be jumped 
through before it can happen



-- 
Minnie Mouse is a slow maze learner.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assertions

2017-09-22 Thread alister via Python-list
On Fri, 22 Sep 2017 03:44:59 +1000, Steve D'Aprano wrote:

> On Fri, 22 Sep 2017 02:29 am, Tobiah wrote:
> 
>> Are these completely equivalent?
>> 
>> def foo(thing):
>> 
>> assert(thing > 0), "Thing must be greater than zero"
>> 
>> 
>> def foo(thing):
>> 
>> if not (thing > 0): raise AssertionError("Thing must be greater
>> than zero")
>> 
>> 
>> Other than the fact that the assertion can be turned off with -O?
> 
> As I replied to Ned just now, the two may compile to slightly different
> byte-code. But (apart from the -O optimization) they ought to be
> semantically the same, as far as the interpreter goes. I'd be very
> surprised if the byte-code differences were ever more than trivial.
> 
> But I don't think they are the same as far as the human reader goes. If
> you believe the truism that code is written for other people, and only
> incidentally to be run by computers, then I think we should say that the
> two above are very different.
> 
> The first is an actual assertion. It has to be an assertion, because it
> uses the assert keyword!
> 
> The second is testing a condition, and if need be, raising an exception.
> Which looks like an inappropriate exception. Why AssertionError? It
> looks like it ought to be a ValueError.
> 
> Assertions aren't merely a synonym for testing a condition and raising
> an exception if the condition fails. Assertions have semantics to the
> human reader. I wrote a blog post explaining why you should use
> assertions:
> 
> - you want a checked comment;
> - you have code that can't possibly fail, unless it does;
> - you are testing the program logic;
> - you are checking a contract;
> 
> and when you should not. By using `assert`, you are signalling your
> intent to do one of the above.
> 
> http://import-that.dreamwidth.org/676.html
> 
> But by using an ordinary `if ... raise AssertionError`, the intention is
> ambiguous. If you meant for it to be an assertion, why not use assert?
> If it is not an assertion, then AssertionError is probably the wrong
> exception.
> 
> (It is okay in a testing framework, like unittest, but a bad idea in a
> regular library or an application. Your end-users should never see an
> AssertionError.)
> 
> 
> The bottom line is, if I saw
> 
> if not (thing > 0): raise AssertionError(...)
> 
> in a code review, I'd probably insist that either it be changed to use
> `assert`,
> or the exception be changed to ValueError, whichever better expresses
> the intention of the code.

In a code review I would want the condition changed to be less noisy/
confusing to the reader.

if thing <=0: whatever




-- 
The best thing about growing older is that it takes such a long time.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assertions

2017-09-22 Thread alister via Python-list
On Fri, 22 Sep 2017 21:15:54 +1000, Steve D'Aprano wrote:

> On Fri, 22 Sep 2017 08:50 pm, alister wrote:
> 
>>> The bottom line is, if I saw
>>> 
>>> if not (thing > 0): raise AssertionError(...)
>>> 
>>> in a code review, I'd probably insist that either it be changed to use
>>> `assert`,
>>> or the exception be changed to ValueError, whichever better expresses
>>> the intention of the code.
>> 
>> In a code review I would want the condition changed to be less noisy/
>> confusing to the reader.
>> 
>> if thing <=0: whatever
> 
> Fair point, assuming they are the same.
> 
> Actually, even for floats they're not the same.
> 
> py> not (NAN > 0)
> True py> NAN <= 0 False

I bet those are conditions the original author did not expect 

actually I am not sure how you got them on my system

python 2.7

>>> not (NAN >0)
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'NAN' is not defined

>>> NAN <=0
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'NAN' is not defined


Python 3

Python 3.6.2 (default, Aug 11 2017, 11:59:59) 
[GCC 7.1.1 20170622 (Red Hat 7.1.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> not (NAN > 0)
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'NAN' is not defined
>>> NAN <= 0
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'NAN' is not defined


I would also say that if your examples did indeed return different 
results then pythons logic model has a bug.



-- 
Say "twenty-three-skiddoo" to logout.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Change project licence?

2017-09-23 Thread Kryptxy via Python-list
Thank you all! I opened a ticket about the same (on github).
I got response from most of them, and all are agreeing to the change.
However, one contributor did not respond at all. I tried e-mailing, but no 
response.
Can I still proceed changing the licence? It has been more than a week since 
the ticket was opened.

Sent with [ProtonMail](https://protonmail.com) Secure Email.

>  Original Message 
> Subject: Re: Change project licence?
> Local Time: 15 September 2017 5:54 AM
> UTC Time: 15 September 2017 00:24
> From: ros...@gmail.com
> To: python-list@python.org 
>
> On Fri, Sep 15, 2017 at 10:17 AM, Ben Finney  
> wrote:
>>> I know how to change the licence, but I want to know is it fine and
>>> wise to change the licence at this point? (The project already has 19
>>> clones, 250+ GitHub stars. Here: https://github.com/kryptxy/torrench)
>>
>> Those represent a whole lot of recipients, who received GPLv3-or-later
>> license grant, guaranteeing the freedom of the work for all recipients
>> in all modified forms. I would consider it poor form to allow non-free
>> redistribution at this point.
>
> Those recipients can still do everything they previously could,
> *including redistributing the code under the GPLv3*. They have lost
> nothing.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Change project licence?

2017-09-23 Thread Kryptxy via Python-list
Yep. I will wait for a response. Thank you!

 Original Message 
On 23 Sep 2017, 16:57, Chris Angelico wrote:

> On Sat, Sep 23, 2017 at 7:44 PM, Leam Hall  wrote:
>> Like Chris said, evaluate the level of effort on the code. Wait, or replace.
>> You will be happier when you take the honorable path.
>
> Remembering that that, of course, is Plan B; plan A is to keep trying
> to contact that last contributor.. S/he hasn't refused, so there's
> still every possibility of getting that last okay.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list @gmail.com>
-- 
https://mail.python.org/mailman/listinfo/python-list


Running a GUI program haults the calling program (linux)

2017-09-25 Thread Kryptxy via Python-list
I want to run a GUI program (transmission-gtk) from python. This is what I do:

import subprocess
subprocess.Popen(['transmission-gtk', link], stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)

Where `link` is some magnetic link.

This command opens transmission-gtk, but it haults the calling program, and 
keeps the terminal busy till the time GUI is running.
As soon as GUI is closed, the control goes back to the program.

Is there any way that the GUI program is opened, and immediately the control 
returns to calling program, instead of keeping the terminal busy?

(I know transmission-remote can be used for adding torrents. Looking for a way 
around for transmission-gtk specifically).

Thank you!
Regards.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Running a GUI program haults the calling program (linux)

2017-09-26 Thread Kryptxy via Python-list
Sent with [ProtonMail](https://protonmail.com) Secure Email.

>  Original Message 
> Subject: Re: Running a GUI program haults the calling program (linux)
> Local Time: 26 September 2017 6:20 AM
> UTC Time: 26 September 2017 00:50
> From: ros...@gmail.com
> To: python-list 
>
> On Tue, Sep 26, 2017 at 10:38 AM, Kryptxy via Python-list
>  wrote:
>> I want to run a GUI program (transmission-gtk) from python. This is what I 
>> do:
>>
>> import subprocess
>> subprocess.Popen(["transmission-gtk", link], stdout=subprocess.PIPE, 
>> stderr=subprocess.PIPE)
>>
>> Where `link` is some magnetic link.
>>
>> This command opens transmission-gtk, but it haults the calling program, and 
>> keeps the terminal busy till the time GUI is running.
>> As soon as GUI is closed, the control goes back to the program.
>>
>> Is there any way that the GUI program is opened, and immediately the control 
>> returns to calling program, instead of keeping the terminal busy?
>>
>> (I know transmission-remote can be used for adding torrents. Looking for a 
>> way around for transmission-gtk specifically).
>
> I"m not sure why you can"t signal it, but I"ll take that parenthesized
> comment as an indication that you know about (a) the
> transmission-remote command, and/or (b) the fact that transmission-gtk
> can be remote-controlled fairly effectively. (For instance, I have a
> script that puts Transmission into turtle mode, then does something,
> and then takes Transmission out of turtle mode. It"s two lines of
> shell script to do it.)

Yes I know about transmission-remote. I am trying to figure out a way for 
running transmission-gtk without causing program to hault.

> So, you want to "fire-and-forget" a GUI program. Or more generally,
> _any_ program. My suspicion here is that, since Popen shouldn"t be
> blocking, that you"re filling up one of your pipes. Can you try
> removing the stdout and stderr parameters, and see what that does? You
> should be able to fire off a subprocess and then carry on with the
> program. It might make a lot of noise, if transmission produces a ton
> of output; but if that happens, try std{out,err}=subprocess.DEVNULL
> instead of PIPE - unless you"re specifically trying to read the
> output?

Tried std{out,err}=subprocess.DEVNULL - Did not work. The program still haults.

Also, worth noting that the program haults when transmission-gtk is opened for 
the first time.
Suppose if the GUI windows is already open, and then subprocess.Popen() is run,
the torrent is added successfully, and control goes back to calling program. 
(That is the program does not hault).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Running a GUI program haults the calling program (linux)

2017-09-26 Thread Kryptxy via Python-list
Sent with [ProtonMail](https://protonmail.com) Secure Email.

>  Original Message 
> Subject: Re: Running a GUI program haults the calling program (linux)
> Local Time: 26 September 2017 12:09 PM
> UTC Time: 26 September 2017 06:39
> From: c...@cskk.id.au
> To: Kryptxy 
> python-list 
>
> On 25Sep2017 20:38, Kryptxy  wrote:
>>I want to run a GUI program (transmission-gtk) from python. This is what I do:
>>
>>import subprocess
>>subprocess.Popen(["transmission-gtk", link], stdout=subprocess.PIPE, 
>>stderr=subprocess.PIPE)
>>
>>Where `link` is some magnetic link.
>>
>>This command opens transmission-gtk, but it haults the calling program, and 
>>keeps the terminal busy till the time GUI is running.
>>As soon as GUI is closed, the control goes back to the program.
>
> I do not believe this is all your code. Please post a _complete_ example.
>
> Popen dispatches a process. It does not wait for it to terminate. GUI programs
> are not special. Therefore, if your calling python program is blocking, it is
> blocking somewhere other that this line of code. Please show us where.
>
> Consider putting print() calls through your code to locate where your program
> stalls.
>
> Cheers,
> Cameron Simpson  (formerly c...@zip.com.au)

Here -

p = subprocess.Popen(['transmission-gtk', link], stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
output, error = p.communicate()
error = error.decode('utf-8')
output = output.decode('utf-8')
if error != '':
print("\nUnable to load torrent.")
else:
print("Torrent added successfully!")

Here, transmission-gtk is opened and the program haults (at subprocess.Popen() 
statement).
When I close the GUI window, I get the message "Unable to load torrent".

Error message I get:
`Unable to parse nameserver address 8.8.8.8,`
`(transmission-gtk:3982): GLib-CRITICAL **: g_file_test: assertion 'filename != 
NULL' failed`
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Running a GUI program haults the calling program (linux)

2017-09-26 Thread Kryptxy via Python-list
>  Original Message 
> Subject: Re: Running a GUI program haults the calling program (linux)
> Local Time: 26 September 2017 1:26 PM
> UTC Time: 26 September 2017 07:56
> From: __pete...@web.de
> To: python-list@python.org
>
> Kryptxy via Python-list wrote:
>
>> Sent with [ProtonMail](https://protonmail.com) Secure Email.
>>
>>>  Original Message 
>>> Subject: Re: Running a GUI program haults the calling program (linux)
>>> Local Time: 26 September 2017 12:09 PM
>>> UTC Time: 26 September 2017 06:39
>>> From: c...@cskk.id.au
>>> To: Kryptxy 
>>> python-list 
>>>
>>> On 25Sep2017 20:38, Kryptxy  wrote:
>>>>I want to run a GUI program (transmission-gtk) from python. This is what
>>>>I do:
>>>>
>>>>import subprocess
>>>>subprocess.Popen(["transmission-gtk", link], stdout=subprocess.PIPE,
>>>>stderr=subprocess.PIPE)
>>>>
>>>>Where `link` is some magnetic link.
>>>>
>>>>This command opens transmission-gtk, but it haults the calling program,
>>>>and keeps the terminal busy till the time GUI is running. As soon as GUI
>>>>is closed, the control goes back to the program.
>>>
>>> I do not believe this is all your code. Please post a _complete_ example.
>>>
>>> Popen dispatches a process. It does not wait for it to terminate. GUI
>>> programs are not special. Therefore, if your calling python program is
>>> blocking, it is blocking somewhere other that this line of code. Please
>>> show us where.
>>>
>>> Consider putting print() calls through your code to locate where your
>>> program stalls.
>>>
>>> Cheers,
>>> Cameron Simpson  (formerly c...@zip.com.au)
>>
>> Here -
>>
>> p = subprocess.Popen(["transmission-gtk", link], stdout=subprocess.PIPE,
>> stderr=subprocess.PIPE)
>> output, error = p.communicate()
>
> That"s the problem. communicate() *must* block to collect the program"s
> entire output. You get what you ask for...

Thanks! It worked!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-26 Thread alister via Python-list
On Tue, 26 Sep 2017 14:16:47 +, Grant Edwards wrote:

> On 2017-09-26, Ned Batchelder  wrote:
>> On 9/25/17 10:20 PM, Steve D'Aprano wrote:
>>> On Tue, 26 Sep 2017 02:54 am, Ned Batchelder wrote:
>>> [...]
>>>
>>>
>>>
>> We've been asked nicely by the list mod to stop :)
> 
> Perhaps we could agree on a subject line tag to be used in all threas
> arguing about what to call the Python argument passing scheme?  That way
> the other 99% of us could pre-emptively plonk it?

so you are suggesting a system where we could reject by reference :-)



-- 
hard, adj.:
The quality of your own data; also how it is to believe those
of other people.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Beginners and experts (Batchelder blog post)

2017-09-28 Thread alister via Python-list
On Wed, 27 Sep 2017 18:18:10 -0700, Larry Hudson wrote:

> On 09/27/2017 09:41 AM, leam hall wrote:
>> On Sat, Sep 23, 2017 at 5:26 PM, Ned Batchelder 
>> wrote:
> [snip]
>> 
>> The question is, what should a person "know" when hiring out as a
>> programmer? What is 'know" and what should be "known"? Specifically
>> with Python.
>> 
>> 
> Hopefully NOT like this person...
> (Source:  http://rinkworks.com/stupid/cs_misc.shtml There is no direct
> link to this item, it's about 2/3 the way down in a long web page...)
> 
> 
> Since I teach nights at a local community college, I get a lot of
> professional programmers in my classes upgrading their education. One
> student, who was one such person, attended every lecture and smiled and
> nodded and took notes. But he only turned in his first assignment. The
> results of his first test were horrid. Out of curiosity, I asked my
> wife, who barely knew how to turn a computer on much less program one,
> to take the test (which was mostly true/false and multiple choice
> questions). My wife scored higher than this guy.
> 
> The semester's end came, and he flubbed his final, too. A few weeks
> later, I got a call from him complaining about his 'F'. I pointed out he
> hadn't turned in any of his assignments, and those counted 75% of the
> grade.
> 
> "Did you hear me say something besides what the other students heard?" I
> asked.
> 
> "Well, I thought my test grades would carry me," he replied.
> 
> It had turned out his company had paid for him to take the course. Since
> he failed, it suddenly came to the attention of his employer that he
> didn't know how to program, and now his job was in jeopardy. As I hung
> up the phone, I mused that his company shouldn't fire him. It was a
> perfect match: a programmer who couldn't program and a company that
> couldn't figure out sooner that he couldn't.
> 

the whole page seems to be full of 
"look how dumb this user is because they do no automatically know things 
that I had to learn"



-- 
  After they got rid of capital punishment, they had to hang twice
  as many people as before.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Spam

2017-10-03 Thread alister via Python-list

> They are literally criminals, they use computer viruses and malware to
> hijack people's computers to send their spam, and you want to trust them
> and buy from them?

this was probably a "Drive By" posy to get the original spam more 
attention & possibly bypass spam filters





-- 
Come live with me, and be my love,
And we will some new pleasures prove
Of golden sands, and crystal brooks,
With silken lines, and silver hooks.
-- John Donne
-- 
https://mail.python.org/mailman/listinfo/python-list


Need some help with argparse

2017-10-03 Thread Kryptxy via Python-list
Hi,
I am trying to figure out something with argparse.
Here is a scenario:

I have a group of arguments, say: (-a, -b, -c, -d, -e) [lets call it group1]
I have another group, say: (-z, -y, -x, -w) [lets call it group2]

Code:
import argparse
parser = argparse.ArgumentParser(description="Test this shiz")
group1= parser.add_argument_group("Group 1")
group2= parser.add_argument_group("Group 2")

group1.add_argument('-a', '--extendA', action="store_true", help="HELP")
group1.add_argument('-b', '--extendB', action="store_true", help="HELP")
group1.add_argument('-c', '--extendC', action="store_true", help="HELP")
group1.add_argument('-d', '--extendD', action="store_true", help="HELP")
group1.add_argument('-e', '--extendE', action="store_true", help="HELP")

# Similarly for group 2:
group2.add_argument('-z', '--extendZ', action="store_true", help="HELP")
group2.add_argument('-y', '--extendY', action="store_true", help="HELP")
group2.add_argument('-x', '--extendX', action="store_true", help="HELP")
group2.add_argument('-w', '--extendW', action="store_true", help="HELP")

args = parser.parse_args()

Now I want to get arguments of group1 and group2 separately.
If I print(args) - I get arguments from both the groups.
Also group1.parse_args() does not work (since ArgumentGroup does not have 
parse_args() method)

How can I get all arguments of group 1 ONLY? Same goes for group 2?
I tried subparsers too - but they require a mandatory `positional argument` - 
which is not application's requirement.

Any kind of help is appreciated.
Thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The "loop and a half"

2017-10-04 Thread alister via Python-list
On Wed, 04 Oct 2017 20:16:29 +1300, Gregory Ewing wrote:

> Steve D'Aprano wrote:
>> On Wed, 4 Oct 2017 01:40 pm, Chris Angelico wrote:
>> 
>>>You know, you don't HAVE to economize on letters. It's okay to call
>>>your parameters "prompt" instead of "prmt". Remember, that's part of
>>>your API.
>> 
>> Whn u wste vwels lik that, dn't b srprsd whn u run ot n hav shrtg of
>> vwel wth nt nuff 4 vrybdy.
> 
> I blame the Dutch. They're clearly using more than their fair share of
> the world's vowels.

but that is compensated for by the welsh which don't seem to use any 



-- 
Never trust an operating system.
-- 
https://mail.python.org/mailman/listinfo/python-list


why does memory consumption keep growing?

2017-10-05 Thread Fetchinson . via Python-list
Hi folks,

I have a rather simple program which cycles through a bunch of files,
does some operation on them, and then quits. There are 500 files
involved and each operation takes about 5-10 MB of memory. As you'll
see I tried to make every attempt at removing everything at the end of
each cycle so that memory consumption doesn't grow as the for loop
progresses, but it still does.

import os

for f in os.listdir( '.' ):

x = [ ]

for ( i, line ) in enumerate( open( f ) ):

import mystuff
x.append( mystuff.expensive_stuff( line ) )
del mystuff

import mystuff
mystuff.some_more_expensive_stuff( x )
del mystuff
del x


What can be the reason? I understand that mystuff might be leaky, but
if I delete it, doesn't that mean that whatever memory was allocated
is freed? Similary x is deleted so that can't possibly make the memory
consumption go up.

Any hint would be much appreciated,
Daniel




-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why does memory consumption keep growing?

2017-10-05 Thread Fetchinson . via Python-list
On 10/5/17, Chris Angelico  wrote:
> On Fri, Oct 6, 2017 at 8:06 AM, Fetchinson . via Python-list
>  wrote:
>> Hi folks,
>>
>> I have a rather simple program which cycles through a bunch of files,
>> does some operation on them, and then quits. There are 500 files
>> involved and each operation takes about 5-10 MB of memory. As you'll
>> see I tried to make every attempt at removing everything at the end of
>> each cycle so that memory consumption doesn't grow as the for loop
>> progresses, but it still does.
>>
>> import os
>>
>> for f in os.listdir( '.' ):
>>
>> x = [ ]
>>
>> for ( i, line ) in enumerate( open( f ) ):
>>
>> import mystuff
>> x.append( mystuff.expensive_stuff( line ) )
>> del mystuff
>>
>> import mystuff
>> mystuff.some_more_expensive_stuff( x )
>> del mystuff
>> del x
>>
>>
>> What can be the reason? I understand that mystuff might be leaky, but
>> if I delete it, doesn't that mean that whatever memory was allocated
>> is freed? Similary x is deleted so that can't possibly make the memory
>> consumption go up.
>
> You're not actually deleting anything. When you say "del x", all
> you're doing is removing the *name* x. Especially, deleting an
> imported module basically does nothing; it's a complete waste of time.
> Modules are kept in their own special cache.

Meaning that if mystuff has some leaky stuff in it, there is no way
for me to recover?

Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stop/start windows services -python command

2017-10-06 Thread alister via Python-list
On Thu, 05 Oct 2017 17:37:11 -0700, Prabu T.S. wrote:

> On Thursday, October 5, 2017 at 8:33:02 PM UTC-4, MRAB wrote:
>> On 2017-10-05 23:32, Prabu T.S. wrote:
>> > On Thursday, October 5, 2017 at 6:16:44 PM UTC-4, Prabu T.S. wrote:
>> >> hello all,what is the command to stop and start windows services ? i
>> >> can't install win32serviceutil bec am using latest python version.
>> > 
>> > Please advice on this
>> > 
>> Ask Google: windows services start stop command line
> 
> asking for python.

if you know the command line call to shut down the service then you can 
use the subprocess module to call it



-- 
In the long run, every program becomes rococco, and then rubble.
    -- Alan Perlis
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The "loop and a half"

2017-10-09 Thread alister via Python-list
On Mon, 09 Oct 2017 08:00:34 +0200, Lele Gaifax wrote:

> Chris Angelico  writes:
> 
>>> Or you could use a GUI editor that runs locally and has the capability
>>> to edit files remotely over ssh.
>>
>> That's also a possibility, but I have yet to find one that can SSH to a
>> server as a non-root user and then sudo to edit the files.
> 
> If it's just a matter of "finding one", look no further and try out
> Emacs's TRAMP :-)
> 
> ciao, lele.

or if you want the luxury of a GUI editor simply ssh to the remote 
machine & run the editor there (using X forwarding to route the display 
to you local PC)



-- 
The more you sweat in peace, the less you bleed in war.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The "loop and a half"

2017-10-09 Thread alister via Python-list
On Mon, 09 Oct 2017 17:27:27 +0300, Marko Rauhamaa wrote:

> Grant Edwards :
> 
>> On 2017-10-09, alister via Python-list  wrote:
>>
>>> or if you want the luxury of a GUI editor simply ssh to the remote
>>> machine & run the editor there (using X forwarding to route the
>>> display to you local PC)
>>
>> AFAICT, most modern GUI toolkits are no longer usable via X forwarding
>> at sub-gigabit network speeds. The toolkit designers have botched
>> things up so that even the most trivial operation requires hundreds of
>> round-trips between server and client.
> 
> Yep.
> 
> Funny thing is, xterm runs nicely over a 9,600-baud line, but there's no
> hope to get Firefox, Evince or the like to run over a 1,500,000 bps
> connection.
> 
> Latency is more of an issue than throughput, indicating that those
> round-trips are sequential. X11 was designed to be pipelined but the
> toolkits can't pipeline themselves.
> 
> 
> Marko

works fine over my wifi which is considerably less than gigabit speeds
then again I only run applications remotely that are sensible to run 
remotely such as text editors (geany) & file managers (thunar)
I cant see any reason why I would want to run a web browser remotely

I can see that even this would be too slow on some connections but it 
invariably works better that Remote desktop which seems to be the 
preferred approach in the windows world where they don't have much choice.




-- 
It's very glamorous to raise millions of dollars, until it's time for the
venture capitalist to suck your eyeballs out.
-- Peter Kennedy, chairman of Kraft & Kennedy.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Lies in education [was Re: The "loop and a half"]

2017-10-13 Thread alister via Python-list
On Sat, 14 Oct 2017 01:48:44 +1300, Gregory Ewing wrote:

> Steve D'Aprano wrote:
>> I wasn't questioning where the data came from, but how the compiler can
>> write to READ ONLY MEMORY which might not even be in the same continent
>> as the compiler that generated the code.
> 
> I thought it would be fairly obvious that by "put it in read-only
> memory" I meant "arrange for it to be in a location that is read-only at
> run time". Obviously it can't be read-only at *compile* time, just as a
> physical ROM can't be read-only at manufacture time.

oh yes it can
in the past for large quantitys the data in a ROM chip was part of the 
chip etching mask (unless you consider a blank silicon wafer to be 
"Programmable" by the etching process)rather than prom which used 
programmable fuses or prom which could be erased by UV light (assuming 
the chip was fitted with a window otherwise it was known as one time 
programmable EPROM)

The Apollo lunar lander used a magnetic core store that was hard coded at 
the time it was "Woven" 

I doubt that either process is in widespread usage any longer as most 
manufacturers no incorporate a way to update the firmware of a device 
(usually with flash memory)



-- 
"I am not sure what this is, but an `F' would only dignify it."
-- English Professor
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Heroku (was Re: Lies in education [was Re: The "loop and a half"])

2017-10-14 Thread alister via Python-list
On Sat, 14 Oct 2017 11:41:08 +0200, Peter J. Holzer wrote:

> On 2017-10-13 21:42, Ben Bacarisse  wrote:
>> That's one way to put it.  Another is that to use Python I need to buy
>> a new service that is already configured.
> 
> That's exactly the same for PHP. You can't use that either unless
> somebody configured to server to use it.
> 
> The difference is that lots of providers started configuring their
> servers for use of PHP in the late 1990s, but didn't do that for Python.
> 
>> If that's the way it's done, fine, but this sub-thread started with
>> someone being surprised by the success of PHP.
> 
> Which probably boils down to the question: Why did providers offer PHP
> and not Python? One reason might be that at the time no suitable web
> framework for Python existed (Zope was released in 1999, and I remember
> it to be rather heavy-weight). One reason might be that providers didn't
> see PHP as a "real" programming language and therefore deemed it safer.
> 
> hp

could it have been that it was simply a default Apache module installed 
by whatever version of Linux was being used by the host?



-- 
PENGUINICITY!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to read in the newsreader

2017-10-16 Thread alister via Python-list
On Mon, 16 Oct 2017 08:57:18 +0100, Chris Green wrote:

> Michael Torrie  wrote:
>> On 10/15/2017 08:50 PM, Andrew Z wrote:
>> > Gents,
>> >  how do i get this group in a newsreader? The digest i'm getting is
>> >  not
>> > workable for me - i can't reply , can only read the replies from the
>> > members of the group. Or. maybe, it shouldn't be a news reader
>> > please advise..
>> > 
>> > P.S. Oh the comp.lang.python is a nightmare because of spam...
>> 
>> Regardless of what usenet reader you use, com.lang.python will have the
>> same spam everywhere.  So maybe reading via usenet isn't that useful
>> anyway.
>> 
> The mostly very silly spam is trivial to filter with some very simple
> rules, most newsreaders have easy ways to specify subjects and/or
> senders to ignore.  I have (I think) just three or four rules that
> eliminate just about all the junk.

Although that is the case I ma finding that because of the amount of junk 
in this newsgroup I am rapidly running out of space in /dev/null !



-- 
In Oz, never say "krizzle kroo" to a Woozy.
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem with StreamReaderWriter on 3.6.3?

2017-10-19 Thread Peter via Python-list
I came across this code in Google cpplint.py, a Python script for 
linting C++ code. I was getting funny results with Python 3.6.3, but it 
worked fine under 2.7.13


I've tracked the problem to an issue with StreamReaderWriter; the 
traceback and error never shows under 3. The _cause_ of the error is 
clear (xrange not in Py3), but I need the raised exception to show.


I'm running Python 3.6.3 32bit on Windows 10. I also get the same 
results on Python 3.5.2 on Ubuntu (under WSL)


I'm not super familiar with rebinding stderr with codecs, but I'm 
guessing they are doing it because of some Unicode issue they may have 
been having.


I have a workaround - drop the rebinding - but it seems like there might 
be an error in StreamReaderWriter.

Do other people see the same behaviour?
Is there something I'm not seeing or understanding?
Would I raise it on issue tracker?

Peter

--

import sys
import codecs

sys.stderr = codecs.StreamReaderWriter(
    sys.stderr, codecs.getreader('utf8'), codecs.getwriter('utf8'), 
'replace')


# This should work fine in Py 2, but raise an exception in Py3
# But instead Py3 "swallows" the exception and it is never seen
print(xrange(1, 10))

# Although this line doesn't show in Py 3 (as the script has silently 
crashed)

print("This line doesn't show in Py 3")

------





--
https://mail.python.org/mailman/listinfo/python-list


Re: Re: Problem with StreamReaderWriter on 3.6.3? SOLVED

2017-10-20 Thread Peter via Python-list

Thanks MRAB, your solution works a treat.

I'm replying to the list so others can know that this solution works. 
Note that sys.stderr.detach() is only available in >= 3.1, so one might 
need to do some version checking to get it to work properly in both 
versions. It also can mess up with the buffering and therefore the order 
of the output of stderr vs stdout.


Thanks again.

Peter


On 20/10/2017 10:19 AM, MRAB wrote:

On 2017-10-19 22:46, Peter via Python-list wrote:

I came across this code in Google cpplint.py, a Python script for
linting C++ code. I was getting funny results with Python 3.6.3, but it
worked fine under 2.7.13

I've tracked the problem to an issue with StreamReaderWriter; the
traceback and error never shows under 3. The _cause_ of the error is
clear (xrange not in Py3), but I need the raised exception to show.

I'm running Python 3.6.3 32bit on Windows 10. I also get the same
results on Python 3.5.2 on Ubuntu (under WSL)

I'm not super familiar with rebinding stderr with codecs, but I'm
guessing they are doing it because of some Unicode issue they may have
been having.

I have a workaround - drop the rebinding - but it seems like there might
be an error in StreamReaderWriter.
Do other people see the same behaviour?
Is there something I'm not seeing or understanding?
Would I raise it on issue tracker?

Peter

--

import sys
import codecs

sys.stderr = codecs.StreamReaderWriter(
      sys.stderr, codecs.getreader('utf8'), codecs.getwriter('utf8'),
'replace')

# This should work fine in Py 2, but raise an exception in Py3
# But instead Py3 "swallows" the exception and it is never seen
print(xrange(1, 10))

# Although this line doesn't show in Py 3 (as the script has silently
crashed)
print("This line doesn't show in Py 3")

--

StreamReaderWriter is being passed an encoder which returns bytes 
(UTF-8), but the output stream that is being passed, to which it will 
be writing those butes, i.e. the original sys.stderr, expects str.


I'd get the underlying byte stream of stderr using .detach():

sys.stderr = codecs.StreamReaderWriter(sys.stderr.detach(), 
codecs.getreader('utf8'), codecs.getwriter('utf8'), 'replace')





--
https://mail.python.org/mailman/listinfo/python-list


Re: Compression of random binary data

2017-10-23 Thread alister via Python-list
On Mon, 23 Oct 2017 10:41:55 +0100, Paul Moore wrote:

> On 23 October 2017 at 10:32,   wrote:
>> According to this website. This is an uncompressable stream.
>>
>> https://en.m.wikipedia.org/wiki/Incompressible_string
>>
>> 12344321
>>
>> It only takes seven 8 bit bytes to represent this
> 
> Would you care to provide the seven 8-bit bytes you propose to use?
> Paul

I would suspect he is using BCD & storing 2 values in reach byte
that is not what is meant by you cant compress random data.
his compression is simply removing redundant space from an inefficient 
coding

Can you compress that sequence on paper when you only have the values 0-9 
to work with (forget computer representation & removing un-used bits)


-- 
Old age and treachery will overcome youth and skill.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Compression of random binary data

2017-10-23 Thread alister via Python-list
On Mon, 23 Oct 2017 13:40:59 +, Neil Cerutti wrote:

> On 2017-10-23, Chris Angelico  wrote:
>> On Mon, Oct 23, 2017 at 11:18 PM, alister via Python-list
>> wrote:
>>> On Mon, 23 Oct 2017 10:41:55 +0100, Paul Moore wrote:
>>>
>>>> On 23 October 2017 at 10:32,  
>>>> wrote:
>>>>> According to this website. This is an uncompressable stream.
>>>>>
>>>>> https://en.m.wikipedia.org/wiki/Incompressible_string
>>>>>
>>>>> 12344321
>>>>>
>>>>> It only takes seven 8 bit bytes to represent this
>>>>
>>>> Would you care to provide the seven 8-bit bytes you propose to use?
>>>> Paul
>>>
>>> I would suspect he is using BCD & storing 2 values in reach byte that
>>> is not what is meant by you cant compress random data. his compression
>>> is simply removing redundant space from an inefficient coding
>>
>> I suspect he is using ASCII and storing one value in each byte.
> 
> There's also ZSCII, which stores roughly 3 characters every 2 bytes.
> Since all the digits are in A2, this sequence would take up 7 bytes in
> ZSCII as well.
> 
> http://inform-fiction.org/zmachine/standards/z1point0/sect03.html

not sure how 16 characters can be represented by either ascii or zscii in 
only 8 bytes



-- 
I fear explanations explanatory of things explained.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ideas about how software should behave

2017-11-09 Thread Rurpy via Python-list
On 11/08/2017 08:18 PM, Ben Finney wrote:
> Ned Batchelder  writes:
> [...]
>> Second, now you want us to agree that calling someone arrogant isn't
>> an attack?
> 
> It's one thing to say “this idea is arrogant”, which is what Steve did.
> That's not in any way personal, nor an attack on a person. It criticises
> an idea.
> 
> If instead Steve said “that was an arrogant action”, the person is being
> criticised. But it's still not *characterising* the person; it
> characterises the action. It says nothing about whether the person is
> arrogant.
> 
> If instead of either of those Steve said “you are arrogant”, that would
> warrant the response, in my estimation.
> 
> That it got nowhere near that is why I'm pleading that we stop treating
> criticism of ideas as though it were an attack on a person.

People and their ideas are not separable.  The ideas that
people have and promote are part of what makes them who
they are.  You cannot criticize their ideas without criticizing 
them.  That you make up some pet theory about how people 
*should* be does not change the reality of how people *are*.

And when you apply anthropocentric terms to "an idea" (which 
obviously does not have "behavior" of it's own, the attempts 
of you and Chris to make that claim not withstanding) you 
reinforce the sense that you are talking about the person.
If I said, "that's an idea that an asshole would think up",
there is no one (other than perhaps you and Chris) who wouldn't
recognize that I was calling you an asshole. 

Conversely, while you claim any incivility is allowable 
when criticizing an idea you claim there's a requirement 
to respect a person.  Do you respect the terrorist who 
killed the hostages in Sydney a couple years ago? Or any 
number of other lowlifes?  Or maybe you'll now waffle about 
and limit respect to speech?  Suppose I came here and start
spouting neo-Nazi racist rants.  Do you seriously claim
people should criticize my ideas but not me?  That's so far 
from recognized human behavior that it justifies being called 
a crackpot theory.

If you want to show respect to people whose ideas you disagree 
with or even disrespect you do so by leaving out the insults, 
the innuendos, the aggressive language, completely subjective 
and unprovable non-facts like "arrogant" and "stupid", and just 
make a rational case why the other person is wrong in your 
opinion.  That also shows respect to other readers most of 
whom I bet dont want to read the constant verbal dueling that 
occurs so regularly here.

Nobody is saying not to criticize: it is how it is done that
is the problem.

But of course that is nowhere near as much fun, is it?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ideas about how software should behave

2017-11-09 Thread Rurpy via Python-list
On 11/08/2017 11:29 AM, Chris Angelico wrote:
> [...]
> Please, Jon, accept that we were not deliberately trying
> to put you down. Steve, if you can clearly state your position on this
> (possibly worded in the form of an apology?), it would go a long way
> to clearing this up.
> ChrisA

Are you the same ChrisA who wrote in this very list just a month ago
towards a poster you disagreed with:

 "Yep. Good reasons like that you're a moron." [*]

Maybe you could set an example for Steve?  It would go a long way 
to showing that you, Steven, Ben an a few others aren't setting a duel
standard where favored regular "alpha male" posters can be as rude as
they want but the Code of Conduct is dragged out to whack non-alphas 
when they respond the same way.

[*] https://mail.python.org/pipermail/python-list/2017-October/727190.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ideas about how software should behave

2017-11-09 Thread Rurpy via Python-list
On 11/09/2017 09:33 AM, Chris Angelico wrote:
> On Fri, Nov 10, 2017 at 2:14 AM, Rurpy via Python-list 
>  wrote:
>> On 11/08/2017 11:29 AM, Chris Angelico wrote:
>>> [...]
>>> Please, Jon, accept that we were not deliberately trying
>>> to put you down. Steve, if you can clearly state your position on this
>>> (possibly worded in the form of an apology?), it would go a long way
>>> to clearing this up.
>>> ChrisA
>>
>> Are you the same ChrisA who wrote in this very list just a month ago
>> towards a poster you disagreed with:
>>
>>  "Yep. Good reasons like that you're a moron." [*]
> 
> If I said that, there's more to it than just that I disagreed with the person.

"If"?  You are not sure?  I included a link to your message
in my post which you seem to have cut.  Here it is again:
   https://mail.python.org/pipermail/python-list/2017-October/727190.html
If it is a forgery, maybe the moderators can remove it.  But 
unless you want to categorically deny you wrote it, I think we 
can assume that you did.

I stand by what I've claimed on several occasions: that offensive 
(and CoC violating) posts such as your's and Steven's are regularly 
posted by a handful of regulars here, and not only are there  
typically no objections but other members of the cabal actually 
jump in to defend the bad behavior.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ideas about how software should behave

2017-11-09 Thread Rurpy via Python-list
On 11/09/2017 10:51 AM, Rhodri James wrote:
> On 09/11/17 17:41, Michael Torrie wrote:
>> On 11/09/2017 09:33 AM, Chris Angelico wrote:
>>> On Fri, Nov 10, 2017 at 2:14 AM, Rurpy via Python-list 
>>>  wrote:
>>>> On 11/08/2017 11:29 AM, Chris Angelico wrote:
>>>>> [...] Please, Jon, accept that we were not deliberately
>>>>> trying to put you down. Steve, if you can clearly state your
>>>>> position on this (possibly worded in the form of an
>>>>> apology?), it would go a long way to clearing this up. 
>>>>> ChrisA
>>>> 
>>>> Are you the same ChrisA who wrote in this very list just a
>>>> month ago towards a poster you disagreed with:
>>>> 
>>>> "Yep. Good reasons like that you're a moron." [*]
>>> 
>>> If I said that, there's more to it than just that I disagreed
>>> with the person.
>> 
>> But how does that justify the comment? Sounds like a
>> rationalization to me. A little humility on all our parts goes a
>> long ways.  One can apologize for offense taken, even if none was
>> intended, and even if my own opinion is still strongly held.
> 
> But some people really do behave moronically on this list.  I
> generally killfile them before the urge to insult gets too strong,
> but I do see Chris's point; leaving people with the idea that
> unacceptable behaviour is acceptable is a service to no one.

"unacceptable behavior" being having an opinion different than 
Chris'?  And a response of "you're a moron" is quite acceptable 
in your opinion?  You are obviously not alone in feeling that way 
but if that is the defacto policy here then the CoC should be 
changed to reflect that.  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for/ if against dict - one liner

2017-11-14 Thread alister via Python-list
On Tue, 14 Nov 2017 00:44:18 -0500, Andrew Z wrote:

> Hello,
>  i wonder how do i get the "for" and "if" to work against a dictionary
>  in
> one line?
> 
> basically i want to "squeeze":
>  dct= [ 1 : "one", 2:"two", 3:"three"]
>  for k, val in dct:
>if k >= 2:
>   # do magnificent things
> 
> Thank you AZ

why the need to single line it?
is your computer running out of new line & space characters?
it probably could be done with a dictionary comprehension but will that 
make things easier or harder to read/understand?

"Readability counts"




-- 
(Presuming for the sake of argument that it's even *possible* to design
better code in Perl than in C.  :-)
-- Larry Wall on core code vs. module code design
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to Generate dynamic HTML Report using Python

2017-11-19 Thread Kryptxy via Python-list
I have a piece of code (module) implementing dynamic html page generation. What 
it simply does is writes all the html content (tags + data) to a file, and the 
file is save with a (.html) extension. Served my purpose. Not really sure is 
this is something you are looking for.

You can view the code here: 
https://github.com/kryptxy/torrench/blob/master/torrench/modules/tpb_details.py

Hope this helps.

 Original Message 
On 20 Nov 2017, 6:46 AM, mradul dhakad wrote:

> Hi All ,
>
> I am new to python . I am trying to generate Dynamic HTML report using
> Pyhton based on number of rows selected from query .Do any one can suggest
> some thing for it.
>
> Thanks,
> Mradul
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pros and cons of Python sources?

2017-11-25 Thread alister via Python-list
On Sat, 25 Nov 2017 09:20:44 +, Martin Schöön wrote:

> Some time ago I was advised that having a Python installation based on
> several sources (pip and Debian's repos in my case) is not a good idea.
> I need to tidy up my installation and I don't know what to opt for and
> what to opt out.
> 
> What are the pros and cons of the alternatives including the ones I
> haven't mentioned? Completeness, currency, bugs...
> 
> /Martin

Personally i would always use the Distro repository first & only use a 
3rd party option (including pip) if the package I required was not 
available
this ensures compatibility with the OS.


-- 
I must get out of these wet clothes and into a dry Martini.
-- Alexander Woolcott
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: connect four (game)

2017-11-26 Thread alister via Python-list
On Sat, 25 Nov 2017 12:26:52 -0800, namenobodywants wrote:

> On Friday, November 24, 2017 at 8:07:07 AM UTC-8, Chris Angelico wrote:
> 
>> This is the kind of function that needs a docstring and some comments.
>> What exactly is this doing? What are the "lines" of the board? What's
>> the difference between "linear" and "lines"? What exactly is it
>> returning?
> 
> producing documentation is an extremely difficult task for me, but i've
> come up with the following:
> 
> """
> makelines(length,numrows,numcolumns) IS THE LIST OF ALL LISTS L, WITH
> LENGTH length, OF COORDINATES FROM A numrows x numcolumns MATRIX, SUCH
> THAT THE ENTRIES OF L ALL LIE IN A LINE:
> 
> LET horizontal BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE ENTRIES LIE IN
> A HORIZONTAL LINE LET vertical BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE
> ENTRIES LIE IN A VERTICAL LINE LET downward BE ALL THE
> APPROPRIATE-LENGTH LISTS WHOSE ENTRIES LIE IN A DOWNWARD-SLOPING
> DIAGONAL LINE LET upward BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE
> ENTRIES LIE IN AN UPWARD-SLOPING DIAGONAL LINE THEN
> makelines(length,numrows,numcolumns) IS THE UNION OF ALL THE
> AFOREMENTIONED SETS """
> 
> def makelines(length,numrows,numcolumns):
> horizontal = [[(i, j+k) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)]
> vertical = [[(i+k, j) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)] downward = [[(i+k, j+k)
> for k in range(length)] for i in range(numrows) for j in
> range(numcolumns)]
> upward = [[(i+k, j-k) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)] linear = horizontal +
> vertical + downward + upward return [line for line in linear if
> all(i in range(6) and j in range(7) for (i,j) in line)]
> 
> def getlines(board):
> coordlines = makelines(4,6,7) ## GLOBAL return [[board[square] for
> square in line] for line in coordlines
> 
> 
> i tried to remove all the superfluous spaces from that, but lining up
> code vertically is very helpful to me, so i don't think i can really
> dispense with the practice
> 
> peace stm

the documentation should come after the def statement
that way is becomes a "Doc String" & can be accessed using the help 
function
you may also want to check out the recommended way of structuring a doc 
string, it could help you with your difficulty in writing them (a problem 
shared by many)



-- 
This door is baroquen, please wiggle Handel.
(If I wiggle Handel, will it wiggle Bach?)
-- Found on a door in the MSU music building
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: connect four (game)

2017-11-26 Thread nospam.alister via Python-list
On Sat, 25 Nov 2017 12:26:52 -0800, namenobodywants wrote:

> On Friday, November 24, 2017 at 8:07:07 AM UTC-8, Chris Angelico wrote:
>
>> This is the kind of function that needs a docstring and some comments.
>> What exactly is this doing? What are the "lines" of the board? What's
>> the difference between "linear" and "lines"? What exactly is it
>> returning?
>
> producing documentation is an extremely difficult task for me, but i've
> come up with the following:
>
> """
> makelines(length,numrows,numcolumns) IS THE LIST OF ALL LISTS L, WITH
> LENGTH length, OF COORDINATES FROM A numrows x numcolumns MATRIX, SUCH
> THAT THE ENTRIES OF L ALL LIE IN A LINE:
>
> LET horizontal BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE ENTRIES LIE IN
> A HORIZONTAL LINE LET vertical BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE
> ENTRIES LIE IN A VERTICAL LINE LET downward BE ALL THE
> APPROPRIATE-LENGTH LISTS WHOSE ENTRIES LIE IN A DOWNWARD-SLOPING
> DIAGONAL LINE LET upward BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE
> ENTRIES LIE IN AN UPWARD-SLOPING DIAGONAL LINE THEN
> makelines(length,numrows,numcolumns) IS THE UNION OF ALL THE
> AFOREMENTIONED SETS """
>
> def makelines(length,numrows,numcolumns):
> horizontal = [[(i, j+k) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)]
> vertical = [[(i+k, j) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)] downward = [[(i+k, j+k)
> for k in range(length)] for i in range(numrows) for j in
> range(numcolumns)]
> upward = [[(i+k, j-k) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)] linear = horizontal +
> vertical + downward + upward return [line for line in linear if
> all(i in range(6) and j in range(7) for (i,j) in line)]
>
> def getlines(board):
> coordlines = makelines(4,6,7) ## GLOBAL return [[board[square] for
> square in line] for line in coordlines
>
>
> i tried to remove all the superfluous spaces from that, but lining up
> code vertically is very helpful to me, so i don't think i can really
> dispense with the practice
>
> peace stm

the documentation should come after the def statement that way is becomes a
"Doc String" & can be accessed using the help function
you may also want to check out the recommended way of structuring a doc string,
 it could help you with your difficulty in writing them (a problem shared by
many)



--
This door is baroquen, please wiggle Handel. (If I wiggle Handel, will it
wiggle Bach?)
-- Found on a door in the MSU music building

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: connect four (game)

2017-11-26 Thread nospam.nospam.alister via Python-list
On Sat, 25 Nov 2017 12:26:52 -0800, namenobodywants wrote:

> On Friday, November 24, 2017 at 8:07:07 AM UTC-8, Chris Angelico wrote:
>
>> This is the kind of function that needs a docstring and some comments.
>> What exactly is this doing? What are the "lines" of the board? What's
>> the difference between "linear" and "lines"? What exactly is it
>> returning?
>
> producing documentation is an extremely difficult task for me, but i've
> come up with the following:
>
> """
> makelines(length,numrows,numcolumns) IS THE LIST OF ALL LISTS L, WITH
> LENGTH length, OF COORDINATES FROM A numrows x numcolumns MATRIX, SUCH
> THAT THE ENTRIES OF L ALL LIE IN A LINE:
>
> LET horizontal BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE ENTRIES LIE IN
> A HORIZONTAL LINE LET vertical BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE
> ENTRIES LIE IN A VERTICAL LINE LET downward BE ALL THE
> APPROPRIATE-LENGTH LISTS WHOSE ENTRIES LIE IN A DOWNWARD-SLOPING
> DIAGONAL LINE LET upward BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE
> ENTRIES LIE IN AN UPWARD-SLOPING DIAGONAL LINE THEN
> makelines(length,numrows,numcolumns) IS THE UNION OF ALL THE
> AFOREMENTIONED SETS """
>
> def makelines(length,numrows,numcolumns):
> horizontal = [[(i, j+k) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)]
> vertical = [[(i+k, j) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)] downward = [[(i+k, j+k)
> for k in range(length)] for i in range(numrows) for j in
> range(numcolumns)]
> upward = [[(i+k, j-k) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)] linear = horizontal +
> vertical + downward + upward return [line for line in linear if
> all(i in range(6) and j in range(7) for (i,j) in line)]
>
> def getlines(board):
> coordlines = makelines(4,6,7) ## GLOBAL return [[board[square] for
> square in line] for line in coordlines
>
>
> i tried to remove all the superfluous spaces from that, but lining up
> code vertically is very helpful to me, so i don't think i can really
> dispense with the practice
>
> peace stm

the documentation should come after the def statement that way is becomes a
"Doc String" & can be accessed using the help function you may also want to
check out the recommended way of structuring a doc string,
 it could help you with your difficulty in writing them (a problem shared by
many)



--
This door is baroquen, please wiggle Handel. (If I wiggle Handel, will it
wiggle Bach?)
-- Found on a door in the MSU music building

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: connect four (game)

2017-11-27 Thread nospam.nospam.nospam.alister via Python-list
On Sat, 25 Nov 2017 12:26:52 -0800, namenobodywants wrote:

> On Friday, November 24, 2017 at 8:07:07 AM UTC-8, Chris Angelico wrote:
>
>> This is the kind of function that needs a docstring and some comments.
>> What exactly is this doing? What are the "lines" of the board? What's
>> the difference between "linear" and "lines"? What exactly is it
>> returning?
>
> producing documentation is an extremely difficult task for me, but i've
> come up with the following:
>
> """
> makelines(length,numrows,numcolumns) IS THE LIST OF ALL LISTS L, WITH
> LENGTH length, OF COORDINATES FROM A numrows x numcolumns MATRIX, SUCH
> THAT THE ENTRIES OF L ALL LIE IN A LINE:
>
> LET horizontal BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE ENTRIES LIE IN
> A HORIZONTAL LINE LET vertical BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE
> ENTRIES LIE IN A VERTICAL LINE LET downward BE ALL THE
> APPROPRIATE-LENGTH LISTS WHOSE ENTRIES LIE IN A DOWNWARD-SLOPING
> DIAGONAL LINE LET upward BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE
> ENTRIES LIE IN AN UPWARD-SLOPING DIAGONAL LINE THEN
> makelines(length,numrows,numcolumns) IS THE UNION OF ALL THE
> AFOREMENTIONED SETS """
>
> def makelines(length,numrows,numcolumns):
> horizontal = [[(i, j+k) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)]
> vertical = [[(i+k, j) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)] downward = [[(i+k, j+k)
> for k in range(length)] for i in range(numrows) for j in
> range(numcolumns)]
> upward = [[(i+k, j-k) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)] linear = horizontal +
> vertical + downward + upward return [line for line in linear if
> all(i in range(6) and j in range(7) for (i,j) in line)]
>
> def getlines(board):
> coordlines = makelines(4,6,7) ## GLOBAL return [[board[square] for
> square in line] for line in coordlines
>
>
> i tried to remove all the superfluous spaces from that, but lining up
> code vertically is very helpful to me, so i don't think i can really
> dispense with the practice
>
> peace stm

the documentation should come after the def statement that way is becomes a
"Doc String" & can be accessed using the help function you may also want to
check out the recommended way of structuring a doc string,
 it could help you with your difficulty in writing them (a problem shared by
many)



--
This door is baroquen, please wiggle Handel. (If I wiggle Handel, will it
wiggle Bach?)
-- Found on a door in the MSU music building

-- 
https://mail.python.org/mailman/listinfo/python-list


Python homework

2017-12-05 Thread nick.martinez2--- via Python-list
I have a question on my homework. My homework is to write a program in which 
the computer simulates the rolling of a die 50
times and then prints
(i). the most frequent side of the die
(ii). the average die value of all rolls. 
I wrote the program so it says the most frequent number out of all the rolls 
for example (12,4,6,14,10,4) and will print out "14" instead of 4 like I need.
This is what I have so far:
import random

def rollDie(number):
rolls = [0] * 6
for i in range(0, number):
roll=int(random.randint(1,6))
rolls[roll - 1] += 1
return rolls

if __name__ == "__main__":
result = rollDie(50)
print (result)
print(max(result))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double click

2017-12-09 Thread alister via Python-list
On Wed, 06 Dec 2017 10:35:58 +1200, Steve D'Aprano wrote:

> On Tue, 5 Dec 2017 07:58 pm, Lawrence Dâ ÖOliveiro wrote:
> 
>> On Tuesday, December 5, 2017 at 3:39:26 AM UTC+13, Rick Johnson wrote:
>>>
>>> Sounds like your OS file associations are all botched-up ...
>>
>> Linux doesnâ Öt do â £OS file associationsâ Ø.
> 
> 
> Then how does my Linux box know that when I double-click on a text file,
> it launches kwrite rather than (say) the Gimp or LibreOffice?
> 
> When I right-click on a mp4 video, I get a menu that includes a Open
> With command that shows (amount others) Kaffeine, mplayer and VLC.
> 
> If you mean the Linux *kernel* doesn't do file associations, then you
> should have said so.
> 
> But why do you care about the kernel? Would you think it even the
> *tiniest* useful to claim that "Linux doesn't do email" because it is
> sendmail or postfix
>  (or similar) that sends email rather than the Linux kernel itself?

Linux does not associate by file extn it uses a 'magic' file to analyse 
the content of the file so that it runs the correct application 
regardless of the file extn.

to get a python program to run it simply needs the correct "Shebang" ass 
the 1st line

Usually 

#!/usr/bin/env python
 
or similar




-- 
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favor fire.
But if it had to perish twice,
I think I know enough of hate
To say that for destruction, ice
Is also great
And would suffice.
-- Robert Frost, "Fire and Ice"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: request fails on wikipedia (https) - certificate verify failed (_ssl.c:748)

2017-12-11 Thread Kryptxy via Python-list
Install pyopenssl package and try again?
 Original Message 
On 11 Dec 2017, 16:44, F Massion wrote:

> Hi,
>
> I would like to get information from Wikipedia articles and I am testing the 
> connection to Wikipedia.
>
> I am running Python 3.6.2 on Windows 10.
>
> I get certificate errors for all pages with https.
> Any suggestions are welcome!
>
> Here my code:
>
> import requests, bs4
> from bs4 import BeautifulSoup
> res = requests.get('https://en.wikipedia.org/wiki/Stethoscope')
> type(res)
> res.status_code == requests.codes.ok
> wiki = bs4.BeautifulSoup(res.text)
> type(wiki)
> len(res.text)
> print(res.text[:250])
>
> Here the error message:
>
> Traceback (most recent call last):
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 601, in 
> urlopen
> chunked=chunked)
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 346, in 
> _make_request
> self._validate_conn(conn)
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 850, in 
> _validate_conn
> conn.connect()
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\urllib3\connection.py", line 326, in 
> connect
> ssl_context=context)
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\urllib3\util\ssl_.py", line 329, in 
> ssl_wrap_socket
> return context.wrap_socket(sock, server_hostname=server_hostname)
> File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 401, in wrap_socket
> _context=self, _session=session)
> File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 808, in __init__
> self.do_handshake()
> File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 1061, in 
> do_handshake
> self._sslobj.do_handshake()
> File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 683, in 
> do_handshake
> self._sslobj.do_handshake()
> ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 
> (_ssl.c:748)
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\requests\adapters.py", line 440, in send
> timeout=timeout
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 639, in 
> urlopen
> _stacktrace=sys.exc_info()[2])
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\urllib3\util\retry.py", line 388, in 
> increment
> raise MaxRetryError(_pool, url, error or ResponseError(cause))
> urllib3.exceptions.MaxRetryError: 
> HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded 
> with url: /wiki/Stethoscope (Caused by SSLError(SSLError(1, '[SSL: 
> CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)'),))
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "web_1.py", line 3, in
> res = requests.get('https://en.wikipedia.org/wiki/Stethoscope')
> File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\api.py", 
> line 72, in get
> return request('get', url, params=params, **kwargs)
> File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\api.py", 
> line 58, in request
> return session.request(method=method, url=url, **kwargs)
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\requests\sessions.py", line 508, in 
> request
> resp = self.send(prep, **send_kwargs)
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\requests\sessions.py", line 618, in send
> r = adapter.send(request, **kwargs)
> File "c:\Program Files 
> (x86)\Python36-32\lib\site-packages\requests\adapters.py", line 506, in send
> raise SSLError(e, request=request)
> requests.exceptions.SSLError: HTTPSConnectionPool(host='en.wikipedia.org', 
> port=443): Max retries exceeded with url: /wiki/Stethoscope (Caused by 
> SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify 
> failed (_ssl.c:748)'),))
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double

2017-12-12 Thread alister via Python-list
On Tue, 12 Dec 2017 05:52:41 -0800, Rick Johnson wrote:

> Rustom Mody wrote:
>> This thread is getting like a mini hologram of our current surreal time
>>  If we can put aside who is right and wrong for a moment we see the
>> more frightening spectacle that Repubs and democrats, Remainers and
>> Brexiters and so on all over  by getting more and more shrill are not
>> talking to each other but past each other
> 
> I blame the confirmation bias of social media for the current state of
> dissed-discourse we find ourselves in these days.
> 
>> > [Rick Johnson wrote]
>> > A file with no extension (regardless of the OS or desktop enviroment
>> > that it was created on), is like a sealed box with no label to
>> > indicate the contents.
>> 
>> So to Rick:  Not if you use something like file (magic) My (unschooled)
>> estimate is it gets its detection right 80% of the time
> 
> But this suggestion misses my point entirely. And the point is, we
> shouldn't have to pick-up the "box" (aka: file) and shake it (ook-ook)
> just to "intuit" what is inside. Using file extentions (aka: labels)
> solves this semantical problem much more elegantly. Now, is a perfect
> solution? Of course not! However, it is the most practical solution.
> 
>> And to Chris and others who think file(magic) is a replacement for
>> file-associations. Even assuming that magic works 100% :
>> Say I have an html file.
>> That means its ALSO a text file.
>> So its equally legitimate to set defaults to use:
>> - a plain text editor (of which there are hundreds)
>> - to open it in browser of choice (also plural nowadays)
>> - some sort of html composer - etc
>> 
>> Which means we are beyond the nature of the file per se to the pattern
>> of its usage
> 
> And although an automated "intuitor" could easily determine if a file
> contained a markup language, we would still be force to "shake the box"
> by running it.

Back to the original problem
has the execute bit been set on the file?




-- 
All Hell hadn't been let loose. It was merely Detritus. But from a few 
feet away you couldn't tell the difference.
(The Fifth Elephant)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double

2017-12-15 Thread alister via Python-list
On Fri, 15 Dec 2017 11:48:20 +1300, Gregory Ewing wrote:

> Rhodri James wrote:
>> Even then there was RiscOS, which divorced file names from file types
>> entirely.
> 
> As did classic MacOS.
> 
> I believe MacOSX also has the ability to store a file type as metadata,
> but it doesn't seem to be used much.

Amiga os used a separate file as the ICON & this contained lots of meta 
data including which application to open the file with (usualy the 
application that created it)



-- 
"I'd love to go out with you, but I have to stay home and see if I snore."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-17 Thread alister via Python-list
On Sat, 16 Dec 2017 14:41:00 +1200, Marko Rauhamaa wrote:

> r...@zedat.fu-berlin.de (Stefan Ram):
> 
>> Varun R  writes:
>>>I'm new to programming, can anyone guide me, how to start learning
>>>python programming language
>>
>>   As a start, one should learn:
>>
>> 1.) how to install Python
>> (if not already installed)
>>
>> 2.) how to start the Python console
>> (if not already started)
>>
>> 3.) how to type characters into a line of the
>> console and how to submit the line (using the Enter key) (if
>> this is not already known)
> 
> A good list. Even more important, though, is the installation, use and
> understanding of a text editor. What is the difference of MS Word,
> Notepad and a Python-aware text editor? What text editors are there?
> What is a newline? What is whitespace? (Advanced: what is a TAB.) What
> is the difference between lower case and upper case? What is trailing
> whitespace? What is an underscore?
> What is the difference between a parenthesis, bracket and a brace?
> 
> What is a file? What is a filename? What is a directory/folder? What is
> a pathname? What is a terminal (emulator)? What is standard input? What
> is standard output?
> 
> How do I see the listing of files? How do I erase a file? How do I
> rename a file? What is the current working directory? How do I change it
> and why?
> 
> 
> Marko

you seem to be moving more into knowledge about the operating system 
rather than programming itself.

Still a good pre-requisite you cannot hope to successfully program a 
system you do no know how to use



-- 
Mr Young hadn't had to quiet a screaming baby for years. He'd never been
much good at it to start with. He'd always respected Sir Winston 
Churchill,
and patting small versions of him on the bottom had always seemed
ungracious.
-- (Terry Pratchett & Neil Gaiman, Good Omens)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is wrong with this regex for matching emails?

2017-12-19 Thread alister via Python-list
On Mon, 18 Dec 2017 07:57:27 +1100, Ben Finney wrote:

> Peng Yu  writes:
> 
>> Hi,
>>
>> I would like to extract "a...@efg.hij.xyz". But it only shows ".hij".
> 
> Others have address this question. I'll answer a separate one:
> 
>> Does anybody see what is wrong with it? Thanks.
> 
> One thing that's wrong with it is that it is far too restrictive.
> 
>> email_regex =
>> re.compile('[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)')
> 
> This excludes a great many email addresses that are valid. Please don't
> try to restrict a match for email addresses that will exclude actual
> email addresses.
> 
> For an authoritative guide to matching email addresses, see RFC 3696 §3
> https://tools.ietf.org/html/rfc3696#section-3>.
> 
> A more correct match would boil down to:
> 
> * Match any printable Unicode characters (not just ASCII).
> 
> * Locate the *last* ‘@’ character. (An email address may contain more
>   than one ‘@’ character; you should allow any printable ASCII character
>   in the local part.)
> 
> * Match the domain part as the text after the last ‘@’ character. Match
>   the local part as anything before that character. Reject an address
>   that has either of these empty.
> 
> * Validate the domain by DNS request. Your program is not an authority
>   for what domains are valid; the only authority for that is the DNS.
> 
> * Don't validate the local part at all. Your program is not an authority
>   for what local parts are accepted to the destination host; the only
>   authority for that is the destination mail host.

At which point you have basicaly boiled your test down to 
@. which is rather pointless

there are only 2 reasons why you would want an email anyway

1) Data mining, just to add to your mailing list- in which case even if 
it validates you still don't know if it is a fake address to prevent spam 
so validating is pointless

2) it is part of a registration process, in which case if it is incorrect 
the registration email will not be received & registration cannot be 
completed so self validating without any effort.




-- 
OMNIVERSAL AWARENESS??  Oh, YEH!!  First you need four GALLONS of JELL-O
and a BIG WRENCH!! ... I think you drop th'WRENCH in the JELL-O as if
it was a FLAVOR, or an INGREDIENT ... ... or ... I ... um ... WHERE'S
the WASHING MACHINES?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is wrong with this regex for matching emails?

2017-12-19 Thread alister via Python-list
On Wed, 20 Dec 2017 08:21:02 +1100, Chris Angelico wrote:

> On Wed, Dec 20, 2017 at 7:21 AM, alister via Python-list
>  wrote:
>> On Mon, 18 Dec 2017 07:57:27 +1100, Ben Finney wrote:
>>> A more correct match would boil down to:
>>>
>>> * Match any printable Unicode characters (not just ASCII).
>>>
>>> * Locate the *last* ‘@’ character. (An email address may contain more
>>>   than one ‘@’ character; you should allow any printable ASCII
>>>   character in the local part.)
>>>
>>> * Match the domain part as the text after the last ‘@’ character.
>>> Match
>>>   the local part as anything before that character. Reject an address
>>>   that has either of these empty.
>>>
>>> * Validate the domain by DNS request. Your program is not an authority
>>>   for what domains are valid; the only authority for that is the DNS.
>>>
>>> * Don't validate the local part at all. Your program is not an
>>> authority
>>>   for what local parts are accepted to the destination host; the only
>>>   authority for that is the destination mail host.
>>
>> At which point you have basicaly boiled your test down to
>> @. which is rather pointless
> 
> Not quite. Firstly, I would exclude all whitespace from your matchable
> characters; even though technically you CAN have spaces in email
> addresses, that'll almost never happen, and it's a lot more common to
> delimit with whites. Secondly, there's actually no requirement to have a
> dot in the domain part (and Ben never said so). However, you can
> straight-forwardly validate the domain by attempting a lookup.
> 
> rosuav@sikorsky:~$ dig +short mx ntlworld.com 1
> mx.tb.ukmail.iss.as9143.net.
> 1 mx.mnd.ukmail.iss.as9143.net.
> rosuav@sikorsky:~$ dig +short mx benfinney.id.au 10
> in1-smtp.messagingengine.com.
> 20 in2-smtp.messagingengine.com.
> rosuav@sikorsky:~$ dig +short mx dud.example.off.rosuav.com
> rosuav@sikorsky:~$
> 
> If there are no MX records for a domain, either the domain doesn't
> exist, or it doesn't receive mail. (Remove the "+short" for a more
> verbose report, in which case the failure state is a return code of
> NXDOMAIN.)
> 
>> there are only 2 reasons why you would want an email anyway
>>
>> 1) Data mining, just to add to your mailing list- in which case even if
>> it validates you still don't know if it is a fake address to prevent
>> spam so validating is pointless
>>
>> 2) it is part of a registration process, in which case if it is
>> incorrect the registration email will not be received & registration
>> cannot be completed so self validating without any effort.
> 
> 3) You're building a text display system (forum posts, text chat, etc,
> etc) and want to have web links and email addresses automatically become
> clickable
possible but again if people making the posts want to be contacted & will 
list a working email address, more likely it will be munged to stop the 
spammers from harvesting it. otherwise if an emaikl has to be given they 
will provide a valid looking fake.
> 
> 4) You ask a user to provide "contact information". If s/he provides an
> email address, you automatically send emails; if a phone number, you
> automatically send SMS/text messages; otherwise, you leave it up to a
> human to contact the user.
> 
I can see auto detecting between a Tel no & an email may be a plausible 
desire, you now have 2 problems because not only are email address so 
difficult to validate that it is not worth the effort telephone numbers 
are also to variable to validate reliably (assuming an international 
audience)

> Plenty of possibilities beyond those two. Don't assume there's nothing
> else that can be done just because your imagination can't come up with
> anything :)

Indeed the most obvious other reason is scraping web pages Newsgroups & 
forums for email addresses to spam & I am sure no-one wants to help with 
that

> 
> ChrisA





-- 
I know you believe you understand what you think this fortune says, but
I'm not sure you realize that what you are reading is not what it means.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Goto

2017-12-28 Thread alister via Python-list
On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:

> How to use goto in python?
> 
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com

Dont!
actually you cant - there isn't one*

*at least not in the core language no doubt some sick person will have 
manager to hack together some sort of dodgy code to simulate it if you 
look hard enough)



-- 
Bigmac's brother was reliably believed to be in the job of moving video
recorders around in an informal way.
(Only You Can Save Mankind)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Goto

2017-12-29 Thread alister via Python-list
On Thu, 28 Dec 2017 18:54:31 -0800, breamoreboy wrote:

> On Thursday, December 28, 2017 at 7:40:14 PM UTC, alister wrote:
>> On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:
>> 
>> > How to use goto in python?
>> > 
>> > ---
>> > This email has been checked for viruses by AVG.
>> > http://www.avg.com
>> 
>> Dont!
>> actually you cant - there isn't one*
>> 
>> *at least not in the core language no doubt some sick person will have
>> manager to hack together some sort of dodgy code to simulate it if you
>> look hard enough)
>> 
>> 
> This http://entrian.com/goto/ has been around for almost 14 years.

ok ill admit i didn't look at all (because goto is a silly idea & 
unnecessary)



-- 
The sunlights differ, but there is only one darkness.
-- Ursula K. LeGuin, "The Dispossessed"
-- 
https://mail.python.org/mailman/listinfo/python-list


Humble Book Bundle: Python by Packt

2018-01-01 Thread beliavsky--- via Python-list
One can purchase the following Python books and videos published by Packt for 
$15 at https://www.humblebundle.com/books/python-by-packt-book-bundle for about 
the next two weeks.

Python Data Analysis Cookbook
Mastering Python, Second Edition
Learning Robotics using Python
Python Programming with Raspberry Pi
Web Development with Django Cookbook
Expert Python Programming, Second Edition
Learning Python Web Penetration Testing (Video)
Python Data Science Essentials, Second Edition
Learning Concurrency in Python
Python Data Structures and Algorithms
Beginning Python (Video)
Building RESTful Python Web Services
Mastering Python Networking
Artificial Intelligence with Python
Deep Learning with Python (Video)
Python Machine Learning Projects (Video)
Python Machine Learning
Python Microservices Development
Python Design Patterns (Video)
Software Architecture with Python
Modern Python Cookbook
Python High Performance, Second Edition
Python GUI Programming Cookbook, Second Edition
Mastering Python (Video)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: : ✨🍰✨ python 2018 wiki - a piece of cake ✨🍰✨ --- 🙄🙄🙄

2018-01-08 Thread alister via Python-list
On Mon, 08 Jan 2018 15:55:00 +, user net wrote:

> Abdur-Rahmaan Janhangeer:
>> there is a language called python by guido
>> 
>> you can ask your questions here !
> 
> 
> 
> ✨🍰✨  python - a piece of cake  ✨🍰✨
> 
> 
> when u read this post in thunderbird or torBrowser, you see colored
> emoji font
> 
> in other newsreaders, like XPN, pan, etc., it is black & white only.
> 
> how to get colored emoji icons  - like the above cake -   everywhere ?

I am using Pan & it is in colour - not that i would loose any sleep if it 
wasn't 
💩




-- 
Wrinkles should merely indicate where smiles have been.
    -- Mark Twain
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing "kitchen" module

2018-01-22 Thread alister via Python-list
On Mon, 22 Jan 2018 08:19:51 -0800, codydaviestv wrote:

> On Tuesday, 23 January 2018 02:41:04 UTC+10:30, bream...@gmail.com 
> wrote:
>> On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com
>> wrote:
>> > So here's the situation. I am unfamiliar with Python but need it to
>> > export a wiki, so I have been following this tutorial, using the
>> > latest version of Python 2 on Windows 7:
>> > 
>> > https://github.com/WikiTeam/wikiteam/wiki/
Tutorial#I_have_no_shell_access_to_server
>> > 
>> > I have everything working up to the point where I run it and it tells
>> > me this:
>> > 
>> > "Please install the Kitchen module.
>> > Please install or update the Requests module."
>> > 
>> > One suggestion was that I try "import kitchen", but that gives me
>> > this error:
>> > 
>> > "Traceback :
>> >   File "", line 1, in 
>> > ImportError: No module named kitchen"
>> > 
>> > So I went to https://pypi.python.org/pypi/kitchen/ to download it,
>> > but that hasn't helped. Maybe it needs to be in a specific folder to
>> > work?
>> > 
>> > Any help would be appreciated.
>> > 
>> > P.S. Here is someone else running into the same problem but they
>> > seemed to have fixed it through a solution that didn't work for me
>> > (it doesn't recognise a command called sudo in the first place when I
>> > type it): https://github.com/WikiTeam/wikiteam/issues/252
>> 
>> Forget sudo as that's a *nix command.  From the command line you should
>> be able to run:-
>> 
>> pip install kitchen pip install requests
>> 
>> --
>> Kindest regards.
>> 
>> Mark Lawrence.
> 
> Here's what I see when I try that. Maybe I'm missing some kind of
> initial setup? https://i.imgur.com/XQHO19W.png

run it from the windows command line not the Python prompt



-- 
Scientists will study your brain to learn more about your distant cousin, 
Man.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: error from Popen only when run from cron

2018-01-27 Thread Wildman via Python-list
On Sat, 27 Jan 2018 10:58:36 -0500, Larry Martell wrote:

> I have a script that does this:
> 
> subprocess.Popen(['service', 'some_service', 'status'],
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
> 
> When I run it from the command line it works fine. When I run it from
> cron I get:
> 
> subprocess.Popen(['service', 'some_service', 'status'],
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
>   File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
> errread, errwrite)
>   File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
> raise child_exception
> OSError: [Errno 2] No such file or directory
> 
> Anyone have any clue as to what file it's complaining about? Or how I
> can debug this further?

Cron provides this as $PATH:  /usr/bin;/usr/sbin

>From within a terminal enter:  whereis service

If service is not in Cron's $PATH, that is your problem.
Adding the complete path to 'service' in the script
should fix things.

If service is in Cron's $PATH, I have no further ideas.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Wildman via Python-list
On Sun, 28 Jan 2018 15:04:26 +, Steven D'Aprano wrote:

> I'm seeing this annoying practice more and more often. Even for trivial 
> pieces of text, a few lines, people post screenshots instead of copying 
> the code.
> 
> Where has this meme come from? It seems to be one which inconveniences 
> *everyone* involved:
> 
> - for the sender, instead of a simple copy and paste, they have to take a 
> screen shot, possibly trim the image to remove any bits of the screen 
> they don't want to show, attach it to their email or upload it to an 
> image hosting site;
> 
> - for the receiver, you are reliant on a forum which doesn't strip 
> attachments, or displays externally hosted images; the visually impaired 
> are excluded from using a screen reader; and nobody can copy or edit the 
> given text.
> 
> It is as if people are deliberately inconveniencing themselves in order 
> to inconvenience the people they are asking to help them.
> 
> With the exception of one *exceedingly* overrated advantage, namely the 
> ability to annotate the image with coloured lines and circles and 
> squiggles or other graphics (which most people don't bother to do), this 
> seems to me to be 100% counter-productive for everyone involved. Why has 
> it spread and why do people keep doing it?
> 
> I don't want to be the old man yelling "Get Of My Lawn!" to the cool 
> kids, but is this just another sign of the downward spiral of programming 
> talent? Convince me that there is *some* justification for this practice. 
> Even a tiny one.
> 
> (The day a programmer posts a WAV file of themselves reading their code 
> out aloud, is the day I turn my modem off and leave the internet forever.)

I can think of no justification for it.

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Issues while using CallerLookup Package

2018-01-29 Thread Mark.luther0987 via Python-list
I accessed the CallerLookup package from below link
https://pypi.python.org/pypi/CallerLookup

and faced the following issue-
>>>
RESTART: 
C:\Users\hp\Desktop\CallerLookup-1.2.94\CallerLookup-1.2.94\CallerLookup\Main.py

Traceback (most recent call last):
  File 
"C:\Users\hp\Desktop\CallerLookup-1.2.94\CallerLookup-1.2.94\CallerLookup\Main.py",
 line 6, in 
from CallerLookup.Responses import *
  File "C:\Python27\lib\site-packages\CallerLookup\__init__.py", line 6, in 

from CallerLookup.Main import lookup_number
  File "C:\Python27\lib\site-packages\CallerLookup\Main.py", line 6, in 
from CallerLookup.Responses import *
  File "C:\Python27\lib\site-packages\CallerLookup\Responses.py", line 7, in 

from CallerLookup.Utils.Logs import format_exception
ImportError: No module named Utils.Logs

I tried on python 2.7.14. Please help to resolve this issue.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-29 Thread alister via Python-list
On Sun, 28 Jan 2018 22:11:12 +, Stefan Ram wrote:

> Tim Delaney  writes:
>>These are support people who are employed by the company I'm contracted
>>to.
>>Doesn't matter how often I try to train them otherwise, this type of
>>thing keeps happening.
> 
>   That might be more a problem of power.

I would simply repeatedly reject the fault report until the user provided 
the information in the requested format




-- 
Work smarter, not harder, and be careful of your speling.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-29 Thread alister via Python-list
On Mon, 29 Jan 2018 15:20:06 +0100, Jugurtha Hadjar wrote:

> On 01/28/2018 04:43 PM, Skip Montanaro wrote:
>> I've never been a Windows user, but at my current job, Windows is core
>> to just about everything, so I am forced to use it for a lot of stuff
>> (Outlook, SQL Server, Excel, etc).
> 
> I was hired at a startup which made a good impression on me and I was
> eager to start working. I checked in for my first day, signed the
> paperwork, then the CTO showed me around and told me "Here's your
> laptop, you can install Windows and I'll check in with you later". Life
> started draining out of my body and my mind was racing in all directions
> before he even finished his sentence. I felt tricked: I was hired based
> on a test and the file I've received was a *.tar.gz* and it made me
> happy because I assumed they were a NIX shop..
> 
> I was considering how I should go about quitting gracefully. I have
> stopped using Windows in 2008 for psychological reasons for it made me
> really anxious, irritable, angry, and tense to the point of abusing
> hardware with low kicks and punches which was not very healthy or sane.
> It was only when I switched OS that this behavior stopped. There was no
> way I would be going back to my bully.
> 
> The CTO then said "Sorry.. I meant Ubuntu." and seeing my pale face, he
> said in a reassuring tone "Don't be afraid, there are no Windows
> machines here." which brought me back to life.
> 
> I hope to be as brave as you some day.

Any Vacancies
whatever they do I am sure I can learn :-)



-- 
The ideas of economists and political philosophers, both when they
are right and when they are wrong, are more powerful than is generally
understood.  Indeed, the world is ruled by little else.
-- John Maynard Keyes
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-29 Thread alister via Python-list
On Mon, 29 Jan 2018 12:17:39 +1300, Gregory Ewing wrote:

> Steven D'Aprano wrote:
>> (The day a programmer posts a WAV file of themselves reading their code
>> out aloud, is the day I turn my modem off and leave the internet
>> forever.)
> 
> Shh! Don't give them ideas!

just wait, once they realise you cant send pictures to a text only news 
group they take the screen shot, print it place it on a wooden table*, 
photograph it & then convert the JPeg to base64 encoding so they can 
paste it in!


* credit to thedailywtf.com


-- 
You look tired.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-30 Thread alister via Python-list
On Tue, 30 Jan 2018 07:28:58 +, Steven D'Aprano wrote:

> On Mon, 29 Jan 2018 21:32:11 -0800, Rustom Mody wrote:
> 
>> On Sunday, January 28, 2018 at 8:37:11 PM UTC+5:30, Steven D'Aprano
>> wrote:
>>> I'm seeing this annoying practice more and more often. Even for
>>> trivial pieces of text, a few lines, people post screenshots instead
>>> of copying the code.
>>> 
>>> Where has this meme come from? It seems to be one which inconveniences
>>> *everyone* involved:
>> 
>> Have you heard of the “Dutch Reach¨?
>> http://www.telegraph.co.uk/travel/news/the-dutch-reach-how-opening-car-
> door-like-the-dutch-could-save-lives-cycling/
> 
> Ah, yes, the Dutch Reach. That would be like the French Pox (which isn't
> French), the Spanish Flu (that didn't start in Spain), the Jerusalem
> artichoke (which is neither an artichoke nor from Jerusalem), and the
> turkey (the bird, which has nothing to do with Turkey, the country).
> 
> This technique is neither taught nor commonly used used by the Dutch:
> apparently some Americans decided that because the Netherlands has a lot
> of cyclists, they'll say its Dutch.
> 
The British TV show QI seemed to think this is actually part of the Dutch 
driving test although they have been known to make mistakes

> https://en.wikipedia.org/wiki/Dooring
> 
> So let me see if I understand the logic...
> 
> Rather than teach people to *explicitly* check their mirror to make sure
> it is safe before opening the car door, teach them a difficult, awkward
> maneuver which they're guaranteed to stop using the second the driving
> test is over, that merely points their head more-or-less vaguely in the
> right direction to *maybe* notice on-coming cyclists *if and only if*
> they're actually paying attention.
> 
> I can see this falls under the problem solving technique, "We must do
> something, this is something, therefore we must do it!"
> 
on this I can agree with you.
Personally I tend to "crack" the door a little & then look down the road 
Before opening fully. i am pretty sure I also (at least subconsciously) 
check the mirror.
Then again many* cyclists tend to be in the blind spot, dressed in dark 
clothing & have no lights & ride with zero regard to the rules of the 
road.

> The sorts of people who can't remember to check their mirror before
> opening the car door aren't the sort who will remember to use this
> awkward technique. And for those who can remember to do so, it is
> simpler and more effective to explicitly check your mirror (as the Dutch
> actually do).
> 
> 
>> Presumably it goes beyond the 'inconvenience' of images-instead-of-text
>> to the saving-of-lives…
> 
> I have no idea what connection you think is between this and emailing
> pictures of source code in place of source code.

* not all, some do appear have a desire to live.



-- 
The pollution's at that awkward stage.  Too thick to navigate and too
thin to cultivate.
-- Doug Sneyd
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-31 Thread alister via Python-list
On Tue, 30 Jan 2018 21:22:39 +0100, Jugurtha Hadjar wrote:

> On 01/29/2018 03:48 PM, alister via Python-list wrote:
>> On Mon, 29 Jan 2018 15:20:06 +0100, Jugurtha Hadjar wrote:
>>
>>> On 01/28/2018 04:43 PM, Skip Montanaro wrote:
>>>> I've never been a Windows user, but at my current job, Windows is
>>>> core to just about everything, so I am forced to use it for a lot of
>>>> stuff (Outlook, SQL Server, Excel, etc).
>>> I was hired at a startup which made a good impression on me and I was
>>> eager to start working. I checked in for my first day, signed the
>>> paperwork, then the CTO showed me around and told me "Here's your
>>> laptop, you can install Windows and I'll check in with you later".
>>> Life started draining out of my body and my mind was racing in all
>>> directions before he even finished his sentence. I felt tricked: I was
>>> hired based on a test and the file I've received was a *.tar.gz* and
>>> it made me happy because I assumed they were a NIX shop..
>>>
>>> I was considering how I should go about quitting gracefully. I have
>>> stopped using Windows in 2008 for psychological reasons for it made me
>>> really anxious, irritable, angry, and tense to the point of abusing
>>> hardware with low kicks and punches which was not very healthy or
>>> sane. It was only when I switched OS that this behavior stopped. There
>>> was no way I would be going back to my bully.
>>>
>>> The CTO then said "Sorry.. I meant Ubuntu." and seeing my pale face,
>>> he said in a reassuring tone "Don't be afraid, there are no Windows
>>> machines here." which brought me back to life.
>>>
>>> I hope to be as brave as you some day.
>> Any Vacancies whatever they do I am sure I can learn :-)
>>
>>
>>
>>
> We're hiring all the good (technical and human side) people we can
> find/afford. It's a small startup that helps its clients improve
> business using machine learning. We're in Algiers, Algeria and Paris,
> France.

bit of a commute from Sevenage in UK



-- 
A pencil with no point needs no eraser.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread alister via Python-list
On Thu, 01 Feb 2018 06:48:03 +1100, Chris Angelico wrote:

> On Thu, Feb 1, 2018 at 6:41 AM, Victor Porton  wrote:
>> wxjmfa...@gmail.com wrote:
>>
>>> Le mercredi 31 janvier 2018 20:13:06 UTC+1, Chris Angelico a écrit :
>>>> On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton 
>>>> wrote:
>>>> > LibComCom is a C library which passes a string as stdin of an OS
>>>> > command and stores its stdout in another string.
>>>>
>>>> Something like the built-in subprocess module does?
>>>>
>>>> ChrisA
>>>
>>> Do you mean the buggy subprocess module (coding of characters) ?
>>
>> Please elaborate: which bugs it has? in which versions?
>>
>>> Yes, there is a working workaround : QtCore.QProcess().
> 
> Ignore jmf, he wouldn't know a bug if he were eating it for dinner. His
> posts are blocked on the mailing list, and you'd do well to just plonk
> him in your newsreader.
> 
> ChrisA


I disagree jmf's posts are worth reading, if you find yourself agreeing 
with him you know you have got something wrong.


-- 
Bernard Shaw is an excellent man; he has not an enemy in the world, and
none of his friends like him either.
-- Oscar Wilde
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: This newsgroup (comp.lang.python) may soon be blocked by Google Groups

2018-02-01 Thread alister via Python-list
On Thu, 01 Feb 2018 09:01:35 -0800, superchromix wrote:

> Our own programming discussion newsgroup, located at
> comp.lang.idl-pvwave, started receiving spam messages several months
> ago.
> 
> Two weeks ago, access to comp.lang.idl-pvwave was blocked by Google
> Groups.
> 
> When trying to access comp.lang.idl-pvwave, a message is now displayed,
> stating that the group owner needs to remove the spam, and can then
> apply to Google in order to have access reinstated.
> 
> However, old public Usenet groups like this have no owner.  The
> comp.lang.idl-pvwave group is more than 20 years old.  Hence, there is
> no way to unblock the group.
> 
> This is a serious problem, since the entire collection of postings going
> back many years has been blocked, no just the spam.  This resource is
> frequently used by IDL programmers.
> 
> Seeing the spam postings in this newsgroup, I expect something similar
> may happen to comp.lang.python, soon.

simple solution stop using google groups & use either the mailing list or 
a news server with an NNTP client



-- 
Your wig steers the gig.
    -- Lord Buckley
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: This newsgroup (comp.lang.python) may soon be blocked by Google Groups

2018-02-03 Thread alister via Python-list
On Sun, 04 Feb 2018 06:49:57 +1100, Chris Angelico wrote:

> On Sun, Feb 4, 2018 at 6:34 AM, Mark Lawrence 
> wrote:
>> On 03/02/18 17:56, Peter J. Holzer wrote:
>>> You seem to confuse the mailing-list and the newsgroup. The
>>> mailing-list doesn't have a spam problem, and it is already (lightly)
>>> moderated.
>>>
>>> The newsgroup does have a spam problem (as well as a few other
>>> problems,
>>> like gmane mangling message-ids and breaking threads). Google groups
>>> is an interface to the newsgroup.
>>>
>>> There is a bi-directional gateway between them, but they aren't the
>>> same thing.
>>>
>>>  hp
>>>
>>>
>> No, they are one and the same thing, except that this is automatically
>> blocked by the numpty moderators, whereas some things that I state on
>> gg are passed, other things aren't.  It is quite clear that the
>> moderators are biased against people such as myself who are autistic
> 
> No, the moderators are biased against people who are constantly rude.
> Did you know that, autistic or not, you have the power to choose the
> tone of the words you type?
> 
> ChrisA

indeed my son is mildly autistic. I always explained to him that that 
diagnosis did not give him an excuse, it simply gave him an explanation 
of why things were harder for him.


-- 
If it's worth doing, it's worth doing for money.
-- 
https://mail.python.org/mailman/listinfo/python-list


Can't load Python program on my HP ENVY computer

2018-02-04 Thread Bernard via Python-list



I have an HP ENVY TouchSmart 17 Notebook PC.
Windows 8.1.
Intel(R) Core(TM) i7-4700 mQ cpu @ 2.40 ghz 2.40ghz
64-bit operation system x64 based processor
Full Windows touch support with 10 touch points

Can you send me the link to the correct Python version that will run on this 
computer.  I have tried to install Python several times and it just keeps 
hanging up in the initialization phase.

Thanks,
B

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "None" and "pass"

2018-02-06 Thread alister via Python-list
On Tue, 06 Feb 2018 08:55:35 +1100, Chris Angelico wrote:

> On Tue, Feb 6, 2018 at 8:39 AM, Ben Finney 
> wrote:
>> Chris Angelico  writes:
>>
>>> As one special case, I would accept this sort of code:
>>>
>>> def f():
>>> ...
>>>
>>> (three dots representing the special value Ellipsis)
>>>
>>> It's a great short-hand for "stub".
>>
>> I would not accept that.
>>
>> An even better way to write a stub function is to write a docstring:
>>
>> def frobnicate():
>> """ Frobnicate the spangule. """
>>
>> A docstring, like any bare expression, is also a valid statement.
>> Writing a docstring can be done immediately, because if you're writing
>> a stub function you at least know the external interface of that
>> function.
>>
>>
> This is true, but I'd rather have something _under_ the docstring if
> possible, and "..." works well for that. A docstring with nothing
> underneath doesn't look like a stub - it looks like a failed edit or
> something. Having a placeholder shows that it's intentional.
> 
> ChrisA

indeed and pass was implemented for precisely this usage
why even think about possible alternatives



-- 
Use an accordion.  Go to jail.
-- KFOG, San Francisco
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: This newsgroup (comp.lang.python) may soon be blocked by Google

2018-02-11 Thread alister via Python-list
On Sat, 10 Feb 2018 17:12:54 +1200, mm0fmf wrote:

> On 09/02/2018 21:05, codewiz...@gmail.com wrote:
>> On Friday, February 9, 2018 at 2:48:17 PM UTC-5, Chris Green wrote:
>>> codew...@gmail.com wrote:
>>>> On Saturday, February 3, 2018 at 7:15:16 PM UTC-5, pyotr filipivich
>>>> wrote:
>>>>> [snip]
>>>>>  Those of us who do not use google-groups may not notice the
>>>>>  loss
>>>>> of the google groupies.
>>>>
>>>> I use GG to read comp.lang.python because of the following
>>>> combination of factors. I would definitely be happier if there was
>>>> another way to do this, so that I wouldn't have to wade through lots
>>>> of spam.
>>>>
>>>>- I read it from both home and work.
>>>>
>>>>- I can't install any additional software at work.
>>>>
>>>>- There is no newsgroup reader software available at work.
>>>>
>>>>- GG tracks read/unread status of every post. This is shared
>>>>  between work and home through my Google account.
>>>>
>>>>- When I (very rarely) post from work, I can't
>>>>  do it by email, since outgoing email is blocked.
>>>>
>>> Alternative approach, what I do:-
>>>
>>>  Run a text mode (but very capable and mouse aware) newsreader on
>>>  my home system, read news locally using that.
>>>
>>>  Use ssh (is that available at worK?) to connect from work to home
>>>  and run the same newsreader in the same environment. If you can't
>>>  even ssh from work then you can always use an 'ssh from the web'
>>>  app from your wenb browser.
>>>
>>> The newsreader I use is tin by the way.
>>>
>>> --
>>> Chris Green â·
>>
>> ssh would be even a bigger problem here. As I mentioned, I can't even
>> email from work to the outside! All web sites that provide remote
>> connectivity tools are blocked.
>>
>> Regards,
>> Igor.
>>
> If they take such restrictive practices then maybe should consider
> *just* doing your job when at work and leave the browsing to your own
> time?


I would also suggest that you consider the above statement ha snot been 
made out of malice but is trying to protect you.  if the restrictions are 
as strict as you say and you get seen you will probably loose your job.



-- 
Xerox does it again and again and again and ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Regex on a Dictionary

2018-02-13 Thread alister via Python-list
On Tue, 13 Feb 2018 13:42:08 +, Rhodri James wrote:

> On 13/02/18 13:11, Stanley Denman wrote:
>> I am trying to performance a regex on a "string" of text that python
>> isinstance is telling me is a dictionary.  When I run the code I get
>> the following error:
>> 
>> {'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.: 
>> 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0),
>> '/Type': '/FitB'}
>> 
>> Traceback (most recent call last):
>>File "C:\Users\stand\Desktop\PythonSublimeText.py", line 9, in
>>
>>  x=MyRegex.findall(MyDict)
>> TypeError: expected string or bytes-like object
>> 
>> Here is the "string" of code I am working with:
>> 
>> {'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.: 
>> 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0),
>> '/Type': '/FitB'}
>> 
>> I want to grab the name "MILANI, JOHN C" and the last date
>> "-mm/dd/" as a pair such that if I have  X numbers of string like
>> the above I will end out with N pairs of values (name and date)/  Here
>> is my code:
>>   
>> import PyPDF2,re pdfFileObj=open('x.pdf','rb')
>> pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
>> Result=pdfReader.getOutlines()
>> MyDict=(Result[-1][0])
>> print(MyDict)
>> print(isinstance(MyDict,dict))
>> MyRegex=re.compile(r"MILANI,")
>> x=MyRegex.findall(MyDict)
>> print(x)
> 
> As the error message says, re.findall() expects a string.  A dictionary
> is in no sense a string, so passing it in whole like that won't work.
> If you know that the name will always show up in the title field, you
> can pass just the title:
> 
>x = MyRegex.findall(MyDict['/Title'])
> 
> Otherwise you will have to loop through all the entries in the
> dictionary:
> 
>for entry in MyDict.values():
>  x = MyRegex.findall(entry) # ...and do something with x
> 
> I rather suspect you are going to find that the titles aren't in a very
> systematic format, though.

for what purpose are you trying to run this regex anyway?
it is almost certainly the wrong approach for your task



-- 
Larkinson's Law:
All laws are basically false.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Respam levels.

2018-02-13 Thread alister via Python-list
On Tue, 13 Feb 2018 12:49:26 +, C W Rose wrote:

> Having run a check for straightforward spam, I now find that there's a
> site editing and reposting non-spam posts.  An example of the changed
> headers follows:
> 
> Original post headers:
>>
>> From c...@seckford.org Sun Feb 11 23:23:22 2018 Path:
>> eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-
mail
>> Message-ID: <4sd3le-ct4@tanner.seckford.org>
>> From: C W Rose 
>> Newsgroups: comp.lang.python Subject: Spam levels.
>> Date: Sat, 10 Feb 2018 14:57:40 + Lines: 49 Organization: None
>> Injection-Info: reader02.eternal-september.org;
>> posting-host="208e6410f66c7dd789dea67159b51bb7";
>>  logging-data="6406"; mail-complaints-to="abuse@eternal-
september.org";
>>  posting-account="U2FsdGVkX18su+yG7dqCpnqChqoPIY0JNXRwgNWzvcs="
>> User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX)
>> (Linux/3.10.79-gentoo-1 (i686))
>> Cancel-Lock: sha1:H7zOidR0ivbNjqiWUB6DSoMMYu8=
>> Xref: tanner.seckford.org comp.lang.python:139461
>> 
>> 
> Repost headers:
>>
>> From C Sun Feb 11 23:22:54 2018 Path:
>> eternal-september.org!reader02.eternal-september.org!feeder.eternal-
september.org!aioe.org!news.bbs.geek.nz!.POSTED.agency.bbs.geek.nz!not-
for-mail
>> Message-ID: <847574...@f38.n261.z1.binkp.net>
>> From: C W Rose  (C W Rose)
>> Newsgroups: comp.lang.python Subject: Spam levels.
>> Date: Sat, 10 Feb 2018 14:57:40 +1200 Organization: fsxNet Usenet
>> Gateway | bbs.nz/#fsxNet Mime-Version: 1.0 Content-Type: text/plain;
>> charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info:
>> news.bbs.geek.nz;
>> posting-host="M6YmRdZYyc42DJk0lNlt/X4dpP4dzvceBNabSmESN3E";
>>  logging-data="24378"; mail-complaints-to="ab...@news.bbs.geek.nz"
>> User-Agent: VSoup v1.2.9.47Beta [95/NT]
>> X-MailConverter: SoupGate-Win32 v1.05 X-Comment-To: All Xref:
>> tanner.seckford.org comp.lang.python:139479
> 
> Looking at my current comp.lang.python news spool, 182 out of 683
> messages have been reposted by news.bbs.geek.nz; I haven't checked if
> they are all duplicates.  The reformatting of the body of message is to
> date trivial, just a reduction in line length.
> 
> This may be the result of a misconfigured spam filter, or an actual spam
> attack; anyway, I've now filtered news.bbs.geek.nz from my feed.
> 
> Will

many thanks for the effort 
/dev/null on my laptop is now almost full with this junk :-)



-- 
Let's do it.
-- Gary Gilmore, to his firing squad
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 2 to 3 Conversion

2018-02-16 Thread Wildman via Python-list
I have a bit of code I found on the web that will return
the ip address of the named network interface.  The code
is for Python 2 and it runs fine.  But, I want to use the
code with Python 3.  Below is the code followed by the error
message.  Suggestions appreciated.

#!/usr/bin/env python3

import socket
import fcntl
import struct

def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915,  # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])
print(get_ip_address("eth0"))
print(get_ip_address("lo"))


Traceback (most recent call last):
  File "./test.py", line 14, in 
print(get_ip_address("eth0"))
  File "./test.py", line 12, in get_ip_address
struct.pack('256s', ifname[:15])
struct.error: argument for 's' must be a bytes object

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-18 Thread Wildman via Python-list
Thanks to Chris and Ben.  Your suggestions were slightly
different but both worked equally well, although I don't
understand how that can be so.

> struct.pack('256s', ifname[:15].encode('ascii'))
> struct.pack('256s', ifname.encode('ascii'))

I was looking for a reliable way to determine the IP addy
for a given network adapter.  That is what the code does
but I don't understand how it does it either.

Thanks again.  I will continue to research and study the
code in the hope I will understand it.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-18 Thread Wildman via Python-list
On Sun, 18 Feb 2018 20:51:18 +1100, Chris Angelico wrote:

> On Sun, Feb 18, 2018 at 4:35 AM, Wildman via Python-list
>  wrote:
>> Thanks to Chris and Ben.  Your suggestions were slightly
>> different but both worked equally well, although I don't
>> understand how that can be so.
>>
>>> struct.pack('256s', ifname[:15].encode('ascii'))
>>> struct.pack('256s', ifname.encode('ascii'))
> 
> Those two will be identical for short interface names, but the first
> form will truncate a longer name before encoding. I don't know what
> the ioctl will do with a really long ifname, so it's probably worth
> hanging onto the [:15] slicing.

Since the interfaces are named by the (Linux) system,
I don't think long interface names will be a problem.
Names are used like lo, eth0, wlan0, ppp0, vmnet8, etc.
But, I will keep the [:15} slicing just in case.

>> I was looking for a reliable way to determine the IP addy
>> for a given network adapter.  That is what the code does
>> but I don't understand how it does it either.
>>
>> Thanks again.  I will continue to research and study the
>> code in the hope I will understand it.
> 
> Ah, makes sense. I'd probably do something like this:
> 
>>>> import socket
>>>> s = socket.socket(type=socket.SOCK_DGRAM)
>>>> s.connect(("8.8.8.8", 53))
>>>> s.getsockname()[0]
> '192.168.0.19'

Brief background...  I am working on a project that reports
Linux system info and lan is part of it.  To start with I
was using code similar to the above but, with the help of
a few testers in some of the Linux newsgroups, I found it
did not work correctly in all situations such as 'live'
sessions.  So I started looking for an alternative.

> But that's only going to show one (uplink) address. If I needed to get
> ALL addresses for ALL network adapters, I'd either look for a library,
> and if one wasn't easily found, I'd shell out to the "ip" command and
> parse its output. :)
> 
> ChrisA

I considered using the "ip" command but I prefer not to
depend on external programs if I can get around it.  I
know that might be considered silly but that's just me.

Thanks for your input.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-19 Thread Wildman via Python-list
On Mon, 19 Feb 2018 12:32:49 +, Rhodri James wrote:

> On 18/02/18 16:18, Wildman via Python-list wrote:
>>> But that's only going to show one (uplink) address. If I needed to get
>>> ALL addresses for ALL network adapters, I'd either look for a library,
>>> and if one wasn't easily found, I'd shell out to the "ip" command and
>>> parse its output.:)
>>>
>> I considered using the "ip" command but I prefer not to
>> depend on external programs if I can get around it.  I
>> know that might be considered silly but that's just me.
> 
> It's not silly at all, but for Linux networking it might be the best 
> idea.  I believe in theory you are supposed to use libnl (in some 
> suitable wrapping), but my experience with that is that it is badly 
> documented and horrendously unreliable.

It looks like libnl would do what I want but there is
a problem.  When finished, my program will be released
in the form of a Debian (*.deb) package and used by,
for the most part, 'average' Linux users.  These are
people that know their way around Linux but know
nothing or very little about Python.  Installing a
package using pip by them is pretty much out of the
question.  The system's package manager must be able
to handle the program's dependencies so third-party
packages are out of the question.

But thanks for the suggestion.

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary... and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-19 Thread Wildman via Python-list
On Tue, 20 Feb 2018 02:26:19 +1100, Chris Angelico wrote:

> * Opaque IOCTLs

Would you mind to elaborate a little about your
concerns?

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary... and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-19 Thread Wildman via Python-list
On Tue, 20 Feb 2018 05:39:15 +1100, Chris Angelico wrote:

> On Tue, Feb 20, 2018 at 3:53 AM, Wildman via Python-list
>  wrote:
>> On Tue, 20 Feb 2018 02:26:19 +1100, Chris Angelico wrote:
>>
>>> * Opaque IOCTLs
>>
>> Would you mind to elaborate a little about your
>> concerns?
> 
> Look at your original code: it's impossible to figure out what it's
> doing or whether it's doing it correctly. "Opaque" in this context
> means that you can't grok the code without external help. This is a
> code smell, and a strong indication that you're "fiddling" in stuff
> way lower level than you normally want to be working with. It's
> usable, but it's dirty and leaves everything up to you (do you know
> for sure, for instance, if this is backward compatible?
> Cross-platform?), and that makes it comparable to depending on an
> external program.
> 
> ChrisA

I understand and I agree for the most part.  It does concern
me that I don't understand the code.  Anytime in Linux you
start poking around things at kernel level, you need your
eyes to be wide open.  However, to me it looks like the
code is only quarying ioctl and not trying to change any-
thing.  If this is true, there is no problem.

For the issue of backward compatibility, there are good
people on a few of the Linux newsgroups that are willing
to test code snippets for me.  I can get a wide range of
distros, desktops and kernel versions.  And of course
different python3 versions.  I know it is impossible
to write code that will be guaranteed to run on all
conditions.  But the test results I get will or should
let me know right off if there are glaring problems.

As far as cross-platform goes, that is not an issue.
Every thing I do is targeted for the Linux platform.

I will keep "ip" in mind as a backup plan.  As a novice
Python programmer, I am looking at the amount of code
it will take to parse ip's output compared to the few
lines of code it takes to call ioctl.

I really appreciate your insight.  Thank you.

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary... and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-19 Thread Wildman via Python-list
On Tue, 20 Feb 2018 05:31:27 +1100, Chris Angelico wrote:

> On Tue, Feb 20, 2018 at 3:49 AM, Wildman via Python-list
>  wrote:
>> On Mon, 19 Feb 2018 12:32:49 +, Rhodri James wrote:
>>
>>> On 18/02/18 16:18, Wildman via Python-list wrote:
>>>>> But that's only going to show one (uplink) address. If I needed to get
>>>>> ALL addresses for ALL network adapters, I'd either look for a library,
>>>>> and if one wasn't easily found, I'd shell out to the "ip" command and
>>>>> parse its output.:)
>>>>>
>>>> I considered using the "ip" command but I prefer not to
>>>> depend on external programs if I can get around it.  I
>>>> know that might be considered silly but that's just me.
>>>
>>> It's not silly at all, but for Linux networking it might be the best
>>> idea.  I believe in theory you are supposed to use libnl (in some
>>> suitable wrapping), but my experience with that is that it is badly
>>> documented and horrendously unreliable.
>>
>> It looks like libnl would do what I want but there is
>> a problem.  When finished, my program will be released
>> in the form of a Debian (*.deb) package and used by,
>> for the most part, 'average' Linux users.  These are
>> people that know their way around Linux but know
>> nothing or very little about Python.  Installing a
>> package using pip by them is pretty much out of the
>> question.  The system's package manager must be able
>> to handle the program's dependencies so third-party
>> packages are out of the question.
>>
>> But thanks for the suggestion.
> 
> If you're distributing it as a .deb, you don't want to use pip to grab
> additional libraries. Ideally, you'd want the library to *also* be
> available through the package manager, which would mean you can simply
> record it as a dependency. If it's not... it's not gonna be easy.
> 
> ChrisA

Yes, you are correct.  Third-party pip packages are always
a no-no.

Speaking of which, there is a library called Netifaces that
will easily do exactly what I want with a few lines of code.
But, it is not to be found in any Linux distro's repository
that I can find.  Oh well...

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary... and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-19 Thread Wildman via Python-list
On Tue, 20 Feb 2018 10:55:28 +1100, Chris Angelico wrote:

> The given homepage URL is
> http://alastairs-place.net/projects/netifaces/ - is that the right
> one?
> 
> ChrisA

Yes, that is the right one.  Now I'm feeling a little stupid.
I should have remembered that many python library package
names start with python- or python3-. 

Problem solved.  A thousand thank-you's.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: py2exe maintainer abandoned the project; is there any replacements? Or, anyone willing to continue the work?

2018-02-21 Thread Kryptxy via Python-list
I like pyinstaller. It's one-file exe creation is pretty good. You can give it 
a try.

 Original Message 
On 21 Feb 2018, 23:00, MGHSM wrote:

> Am 21.02.18 um 18:30 schrieb MGHSM: > Thomas Heller himself says he's 
> "retiring" from py2exe in 
> https://sourceforge.net/p/py2exe/mailman/message/36033869/ > > Is there any 
> suitable replacement with similar or better capabilities? > There is 
> PyInstaller, which works on all major OS: http://www.pyinstaller.org/ 
> Christian -- https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to make Python run as fast (or faster) than Julia

2018-02-23 Thread alister via Python-list
On Fri, 23 Feb 2018 03:11:36 -0500, Terry Reedy wrote:

> On 2/22/2018 10:31 PM, Python wrote:
> 
>>> Why do you care about the 50 million calls? That's crazy -- the
>>> important thing is *calculating the Fibonacci numbers as efficiently
>>> as possible*.
> 
>> If you are writing practical programs, that's true.  But the Julia
>> benchmarks are not practical programs; they are designed to compare the
>> performance of various language features across a range of languages.
> 
> If that were so, then the comparison should use the fastest *Python*
> implementation.  Which is what the article discussed here did.  But the
> comparison is a lie when the comparison is compiled machine code versus
> bytecode interpreted by crippled cpython*.  And people use this sort of
> benchmark to choose a language for *practical programs*, and don't know
> that they are not seeing *Python* times, but *crippled cpython* times.

Benchmarks are completely pointless anyway.
the question when choosing a language should not be 'How fast it is', it 
should always be 'Is it fast enough'.
once you have a choice of languages that are fast enough other criteria 
for suitability become important (such as readability & ease of debugging)


-- 
If you're going to do something tonight that you'll be sorry for tomorrow
morning, sleep late.
-- Henny Youngman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to only get \n for newline without the single quotes?

2018-02-24 Thread Wildman via Python-list
On Sat, 24 Feb 2018 11:41:32 -0600, Peng Yu wrote:

> I would like to just get the escaped string without the single quotes.
> Is there a way to do so? Thanks.
> 
>>>> x='\n'
>>>> print repr(x)
> '\n'

Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x='/n'
>>> print(repr(x))
'/n'
>>> print(repr(x).strip("'"))
/n
>>> 

Python 2.7.13 (default, Nov 24 2017, 17:33:09) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x='/n'
>>> print repr(x)
'/n'
>>> print repr(x).strip("'")
/n
>>> 

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary... and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >