unabe to import /pyd file.

2017-12-15 Thread supswain
Hi,

I have created one library file "modified_python_automation_tcl.py"..Inside my 
library file I have set of codes as follows.

import sys
import time
from datetime import datetime
import re,sys,os,itertools,datetime,commands,logging,math,time,copy,inspect
from robot.api import logger
import unicodedata
sys.path.append('C:\Python27\Lib\lib-tk')
sys.path.append('C:\Python27\DLLs')
sys.path.append('C:\Python27\libs')
from Tkinter import Tcl
tcl = Tcl()
.
.
.
.
.
.

I am able to run the file from python IDLE.and able to source all kind of .py 
and .pyd file...But the issue is coming when trying through robo framework.


I am using robo-framework and have defined the 
modified_python_automation_tcl.py  file as the library file. and tryuing to 
excute my testcase..but getting the below error..


Someone please help me how to import .pyd files from robo framework




==
Acceptance.Tests
==
Acceptance.Tests.PCC
==
Acceptance.Tests.PCC.Automation 2.0
==
[ ERROR ] Error in file 
'C:\PCCAutomation\src\test\robotframework\acceptance\Tests\PCC\Automation_2.0\Spirent.txt':
 Importing test library 
'C:\Users\supriysw\Desktop\abcd\modified_python_automation_tcl.py' failed: 
ImportError: No module named _tkinter
Traceback (most recent call last):
  File "C:\Users\supriysw\Desktop\abcd\modified_python_automation_tcl.py", line 
15, in 
from Tkinter import Tcl
  File "C:\Python27\Lib\lib-tk\Tkinter.py", line 41, in 
import _tkinter # If this fails your Python may not be configured for Tk
PYTHONPATH:
  C:\PCCAutomation\target\libs\xlrd-0.7.1
  C:\PCCAutomation\target\libs\xlrd-0.7.1\xlrd
  C:\PCCAutomation\target\libs\xlutils-1.5.2
  C:\PCCAutomation\target\libs\xlutils-1.5.2\xlutils
  C:\PCCAutomation\target\libs\xlwt-0.7.4
  C:\PCCAutomation\target\libs\xlwt-0.7.4\xlwt
  C:\PCCAutomation\target\libs\main\com\nokia\epg\automation\ams\lib
  
C:\Users\supriysw\.m2\repository\org\robotframework\robotframework\2.8.7\robotframework-2.8.7.jar\Lib\robot\libraries
  
C:\Users\supriysw\.m2\repository\org\robotframework\robotframework\2.8.7\robotframework-2.8.7.jar\Lib
  C:\Users\supriysw\.m2\repository\org\robotframework\robotframework\2.8.7\Lib
  __classpath__
  __pyclasspath__/
  .
  C:\PCCAutomation
  C:\Python27\Lib\lib-tk
  C:\Python27\DLLs
  C:\Python27\libs
CLASSPATH:
  C:/apache-maven-3.3.9/boot/plexus-classworlds-2.5.2.jar
Acceptance.Tests.PCC.Automation 2.0.Spirent


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


Re: unabe to import /pyd file.

2017-12-15 Thread Tim Golden

On 15/12/2017 09:58, supsw...@gmail.com wrote:

Hi,

I have created one library file
"modified_python_automation_tcl.py"..Inside my library file I have
set of codes as follows.

import sys import time from datetime import datetime import
re,sys,os,itertools,datetime,commands,logging,math,time,copy,inspect 
from robot.api import logger import unicodedata 
sys.path.append('C:\Python27\Lib\lib-tk') 
sys.path.append('C:\Python27\DLLs') 
sys.path.append('C:\Python27\libs') from Tkinter import Tcl tcl =


Apart from anything else these need to be raw strings:

sys.path.append(r'C:\Python27\Lib\lib-tk')

etc.

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


Re: unabe to import /pyd file.

2017-12-15 Thread Steve D'Aprano
On Fri, 15 Dec 2017 09:09 pm, Tim Golden wrote:

> Apart from anything else these need to be raw strings:
> 
> sys.path.append(r'C:\Python27\Lib\lib-tk')

Don't use raw strings for paths. It's a trap:


r'C:\Python27'  # okay

r'C:\Python27\'  # fails


Windows supports / as directory separator. You should use / as the directory
separator in your source code, and let the OS convert them to backslashes.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
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 Steve D'Aprano
On Fri, 15 Dec 2017 09:48 am, Gregory Ewing wrote:

> Rhodri James wrote:
>> Even then there was RiscOS, which divorced file names from file types
>> entirely.
> 
> As did classic MacOS.

Classic MacOS associated two such pieces of metadata with each file: the
creator and type. Regardless of the optional file type extension, you could
associate different creators with different files of the same type:

https://en.wikipedia.org/wiki/Creator_code


> I believe MacOSX also has the ability to store a file type
> as metadata, but it doesn't seem to be used much.

They are still supported (-ish) by OS X, but have been superseded by Uniform
Type Identifiers.


https://en.wikipedia.org/wiki/Uniform_Type_Identifier



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Problem with timeit

2017-12-15 Thread ast

Hi

Time measurment with module timeit seems to work with some 
statements but not with some other statements on my computer.


Python version 3.6.3

from timeit import Timer


Timer("'-'.join([str(i) for i in range(10)])").timeit(1)

0.179271876732912

Timer("'-'.join([str(i) for i in range(10)])").timeit(10)

1.7445643231192776

It's OK, with 10 more loops I get 10 more execution time.

But with exponentiation, it's a mess


Timer("x=123456**123456").timeit(1)

6.076191311876755e-06

Timer("x=123456**123456").timeit(10)

3.841270313387213e-06

All wrong, the calculation of 123456**123456 is much longer
than 6 microseconds, it takes few seconds, and with 10 loops 
timeit provided a shorter time ...


What happens plz ?

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


Sharing credentials between multiple interactive processes

2017-12-15 Thread Marc Aymerich
I would like to throw at you some problem that I don't know how to best
approach :)

Have an interactive CLI python program that holds credentials entered by
the user. I want users to be able to spawn a new instance of this program
(on another TTY) without the need of reentering credentials. Want to do it
in a secure way, meaning make it very difficult for malicious programs to
gain access to the credentials. Some solutions that I thought of:

1) From another TTY, communicate with the existing process and tell it to
fork and attach to my TTY. Not sure yet how to do it, but I think is doable.

2) Make the program to be able to send credentials through a Unix Domain
Socket to its peers. Not sure is there any way to prevent sending
credentials to any random process pocking at the socket without a
challenge. Maybe is there any way to validate that 2 running python
processes are executing the exact same code (peers)?

any thoughts?


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


Can't start IDLE on mac os x high sierra can't import Tkinter

2017-12-15 Thread ceiussandicus
Hi, I've been trying to get python 3.4.3 (needed for programming course) on my 
mac, running High Sierra.
I've installed python and activetcl 8.5.18 as per instructions. When I start 
IDLE from finder it flashes in the dock and disappears. When I start it from 
terminal, I get the following response: 
** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **
I've googled for the answer but I can't find anything, the closest I got was to 
this https://github.com/pyinstaller/pyinstaller/issues/2665 but I'm not sure if 
it is this issue or not.
Can someone help me get started using python?
Cheers
ceiussandicus
-- 
https://mail.python.org/mailman/listinfo/python-list


Python Learning

2017-12-15 Thread Varun R
Hi All,

I'm new to programming, can anyone guide me, how to start learning python 
programming language,...plz suggest some books also.

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


Pylint 1.8 / Astroid 1.6 released!

2017-12-15 Thread Claudiu Popa
Hi folks!


I'm happy to announce the release of Pylint 1.8, along with Astroid 1.6!

This is going to be the last version that will work on Python 2.
Starting with the
next planned version, 2.0, we are going to support only Python 3.5+.
1.8 will most
likely become a LTS release, with bug fixes backports until 2019-2020.

You can find more details about what's new in this release over here:
https://pylint.readthedocs.io/en/latest/whatsnew/1.8.html


Thanks and enjoy!
Claudiu & all the Pylint contributors
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with timeit

2017-12-15 Thread Thomas Jollans
On 2017-12-15 11:36, ast wrote:
> Hi
> 
> Time measurment with module timeit seems to work with some statements
> but not with some other statements on my computer.
> 
> Python version 3.6.3
> 
> from timeit import Timer
> 
 Timer("'-'.join([str(i) for i in range(10)])").timeit(1)
> 0.179271876732912
 Timer("'-'.join([str(i) for i in range(10)])").timeit(10)
> 1.7445643231192776
> 
> It's OK, with 10 more loops I get 10 more execution time.
> 
> But with exponentiation, it's a mess
> 
 Timer("x=123456**123456").timeit(1)
> 6.076191311876755e-06
 Timer("x=123456**123456").timeit(10)
> 3.841270313387213e-06
> 
> All wrong, the calculation of 123456**123456 is much longer
> than 6 microseconds, it takes few seconds, and with 10 loops timeit
> provided a shorter time ...

No, this is right. The calculation takes practically no time; on my
system, it takes some 10 ns. The uncertainty of the timeit result is at
least a few hundred nanoseconds.

Perhaps you entered 123456**123456 at a Python console (which takes a
few seconds), which makes you think the exponentiation should take that
long? In fact, it's printing the result to the console that takes time.
You can convince yourself of this by running

x=123456**123456

(which takes no time at all)

and then typing "x" (which will take seconds)



>>> Timer("x=123456**123456").timeit(10**6)
0.00969144597183913
>>> Timer("print(123456**123456, file=open('/dev/null', 'w'))").timeit(1)
4.949162941076793


-- Thomas


> 
> What happens plz ?
> 

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


Re: Can't start IDLE on mac os x high sierra can't import Tkinter

2017-12-15 Thread Terry Reedy

On 12/15/2017 6:37 AM, ceiussandi...@gmail.com wrote:

Hi, I've been trying to get python 3.4.3 (needed for programming course) on my 
mac, running High Sierra.
I've installed python and activetcl 8.5.18 as per instructions. When I start 
IDLE from finder it flashes in the dock and disappears. When I start it from 
terminal, I get the following response:
** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **
I've googled for the answer but I can't find anything, the closest I got was to 
this https://github.com/pyinstaller/pyinstaller/issues/2665 but I'm not sure if 
it is this issue or not.
Can someone help me get started using python?


I don't have a Mac, but I know that
https://www.python.org/download/mac/tcltk/
has some fairly exacting instructions at the bottom on how to get Python 
to find the newly installed tcl/tk.  You should probably specify rather 
exactly what you did.  There are multiple issues on bugs.python.org and 
questions on stackoverflow.


--
Terry Jan Reedy

--
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: Problem with timeit

2017-12-15 Thread Peter Otten
Thomas Jollans wrote:

> On 2017-12-15 11:36, ast wrote:
>> Hi
>> 
>> Time measurment with module timeit seems to work with some statements
>> but not with some other statements on my computer.
>> 
>> Python version 3.6.3
>> 
>> from timeit import Timer
>> 
> Timer("'-'.join([str(i) for i in range(10)])").timeit(1)
>> 0.179271876732912
> Timer("'-'.join([str(i) for i in range(10)])").timeit(10)
>> 1.7445643231192776
>> 
>> It's OK, with 10 more loops I get 10 more execution time.
>> 
>> But with exponentiation, it's a mess
>> 
> Timer("x=123456**123456").timeit(1)
>> 6.076191311876755e-06
> Timer("x=123456**123456").timeit(10)
>> 3.841270313387213e-06
>> 
>> All wrong, the calculation of 123456**123456 is much longer
>> than 6 microseconds, it takes few seconds, and with 10 loops timeit
>> provided a shorter time ...
> 
> No, this is right. The calculation takes practically no time; on my
> system, it takes some 10 ns. The uncertainty of the timeit result is at
> least a few hundred nanoseconds.
> 
> Perhaps you entered 123456**123456 at a Python console (which takes a
> few seconds), which makes you think the exponentiation should take that
> long? In fact, it's printing the result to the console that takes time.
> You can convince yourself of this by running
> 
> x=123456**123456
> 
> (which takes no time at all)
> 
> and then typing "x" (which will take seconds)
> 
> 
> 
 Timer("x=123456**123456").timeit(10**6)
> 0.00969144597183913
 Timer("print(123456**123456, file=open('/dev/null', 'w'))").timeit(1)
> 4.949162941076793
> 
> 
> -- Thomas
> 
> 
>> 
>> What happens plz ?

What Thomas says. Also, the value 123456**123456 is computed only once, when 
the code is compiled (this is called "constant folding"). Therefore you 
measure name binding only:

$ python3 -m timeit 'x = 123456**123456'
1000 loops, best of 3: 0.0535 usec per loop
$ python3 -m timeit 'x = 123456'
1000 loops, best of 3: 0.0535 usec per loop

Compare that with an actual calculation:

$ python3 -m timeit -s 'a = 123456' 'x = a'
1000 loops, best of 3: 0.0539 usec per loop
$ python3 -m timeit -s 'a = 123456' 'x = a ** a'
10 loops, best of 3: 259 msec per loop


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


Re: Problem with timeit

2017-12-15 Thread Steve D'Aprano
On Fri, 15 Dec 2017 09:36 pm, ast wrote:

[...]
> It's OK, with 10 more loops I get 10 more execution time.
> 
> But with exponentiation, it's a mess
> 
 Timer("x=123456**123456").timeit(1)
> 6.076191311876755e-06
 Timer("x=123456**123456").timeit(10)
> 3.841270313387213e-06
> 
> All wrong, the calculation of 123456**123456 is much longer
> than 6 microseconds, it takes few seconds, and with 10 loops
> timeit provided a shorter time ...
> 
> What happens plz ?


You are not measuring what you think you are measuring. Import the dis command
to disassemble your source code and see what you are measuring. Here is an
example:

py> from dis import dis
py> dis("x=123**123")
  1   0 LOAD_CONST   2
(1143743679346171900998802952280662767462180784518502297758879750523695
04785666896446606568365201542169649974727730628842345343196581134895919
94282087444983721209947664895835902379607854904194900780722062535652692
6729664064846685758382803707100766740220839267)
  3 STORE_NAME   0 (x)
  6 LOAD_CONST   1 (None)
  9 RETURN_VALUE

I simplified the expression to 123**123 instead of 123456**123456, in order to
make the disassembly small enough to read. Otherwise there would be thousands
of digits.

The important thing is that Python's keyhole optimizer is optimizing the
constant expression 123456**123456, calculating it at compile time, so you
are timing the equivalent of:

x = 5374822891...2343545856 # a 628578 digit number


All the expensive work is done once, at compile time (and even that only takes
a second or so). What timeit measures is just repeatedly assigning x to the
pre-defined constant, over and over again.

So in theory, the speed should be **really really fast**. In practice, you are
measuring more-or-less just the overhead of assignment, and the overhead of
timeit itself. That overhead is so small that it is dominated by the random
noise of your computer, which is doing many other things at the same time,
and it is just a fluke that sometimes calling timeit(10) will be shorter than
calling timeit(1).

On my computer, I get results like this:


py> Timer("x=123456**123456").timeit(1)
7.5660645961761475e-06
py> Timer("x=123456**123456").timeit(1)
6.902962923049927e-06
py> Timer("x=123456**123456").timeit(1)
5.256384611129761e-06

The fact that the time taken keeps getting smaller might be a fluke, or it
might have something to do with CPU prediction and caching results. Now look
what happens when I increase the number of iterations:


py> Timer("x=123456**123456").timeit(10)
7.111579179763794e-06
py> Timer("x=123456**123456").timeit(10)
5.822628736495972e-06
py> Timer("x=123456**123456").timeit(10)
5.457550287246704e-06

The time barely changes. My prediction is that this is because the time of the
actual assignment is so small, the measured time is dominated by timeit
itself. I can test this:

py> Timer("pass").timeit(1)
4.108995199203491e-06
py> Timer("pass").timeit(10)
4.8354268074035645e-06


So that is approximately the fastest thing timeit can measure on my computer,
and there is no significant difference between doing it once, and doing it
ten times. The difference is lost in the noise.


The right way to measure this is like this:


py> Timer("x = n**n", "n = 123456").timeit(1)
0.9905387535691261
py> Timer("x = n**n", "n = 123456").timeit(10)
18.006236914545298


As you can see, repeating the calculation 10 times doesn't take exactly ten
times as long as doing the calculation once. That could be because the
garbage collector runs. The more expensive the calculation, the more overhead
there is. Running Python on a modern machine with CPU branch prediction and
caching isn't like running pure assembly on an old, single-process machine
where every run is 100% deterministic.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Problem with timeit

2017-12-15 Thread Steve D'Aprano
On Fri, 15 Dec 2017 10:47 pm, Thomas Jollans wrote:

> On 2017-12-15 11:36, ast wrote:
>> Hi
>> 
>> Time measurment with module timeit seems to work with some statements
>> but not with some other statements on my computer.
>> 
>> Python version 3.6.3
>> 
>> from timeit import Timer
>> 
> Timer("'-'.join([str(i) for i in range(10)])").timeit(1)
>> 0.179271876732912
> Timer("'-'.join([str(i) for i in range(10)])").timeit(10)
>> 1.7445643231192776
>> 
>> It's OK, with 10 more loops I get 10 more execution time.
>> 
>> But with exponentiation, it's a mess
>> 
> Timer("x=123456**123456").timeit(1)
>> 6.076191311876755e-06
> Timer("x=123456**123456").timeit(10)
>> 3.841270313387213e-06
>> 
>> All wrong, the calculation of 123456**123456 is much longer
>> than 6 microseconds, it takes few seconds, and with 10 loops timeit
>> provided a shorter time ...
> 
> No, this is right. The calculation takes practically no time; on my
> system, it takes some 10 ns. The uncertainty of the timeit result is at
> least a few hundred nanoseconds.

You've misdiagnosed Ast's problem, and fallen for the same Gotcha he has.
You're not measuring what you think you measured:

 Timer("x=123456**123456").timeit(10**6)
> 0.00969144597183913

Calculating BigInt exponentiation is fast, but its not that fast once you get
to hundreds of thousands of digits.

That calculates the 600,000+ digit number 123456**123456 once, at compile
time, then simply assigns that huge number to x a million times. So you would
likely get almost the same result by running:

Timer("x=17").timeit(10**6)




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Can't start IDLE on mac os x high sierra can't import Tkinter

2017-12-15 Thread Cei Sanderson
On Friday, December 15, 2017 at 12:44:14 PM UTC, Terry Reedy wrote:
> On 12/15/2017 6:37 AM, ceiussandi...@gmail.com wrote:
> > Hi, I've been trying to get python 3.4.3 (needed for programming course) on 
> > my mac, running High Sierra.
> > I've installed python and activetcl 8.5.18 as per instructions. When I 
> > start IDLE from finder it flashes in the dock and disappears. When I start 
> > it from terminal, I get the following response:
> > ** IDLE can't import Tkinter.
> > Your Python may not be configured for Tk. **
> > I've googled for the answer but I can't find anything, the closest I got 
> > was to this https://github.com/pyinstaller/pyinstaller/issues/2665 but I'm 
> > not sure if it is this issue or not.
> > Can someone help me get started using python?
> 
> I don't have a Mac, but I know that
> https://www.python.org/download/mac/tcltk/
> has some fairly exacting instructions at the bottom on how to get Python 
> to find the newly installed tcl/tk.  You should probably specify rather 
> exactly what you did.  There are multiple issues on bugs.python.org and 
> questions on stackoverflow.
> 
> -- 
> Terry Jan Reedy

Thanks Terry,
I posted on here because I've struggled after trawling through Google
and following the instructions on that page.
I have installed:
ActiveTcl 8.5.18.0
then I installed
Python 3.4.3
I've found the issue by continuing to trawl a bit more, the course download for 
python (a few years old) pointed to the python install for 10.5 onwards not 
10.6 onwards. Installed the right python and working.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with timeit

2017-12-15 Thread ast


"Thomas Jollans"  a écrit dans le message de 
news:mailman.74.1513341235.14074.python-l...@python.org...

On 2017-12-15 11:36, ast wrote:




No, this is right. The calculation takes practically no time; on my
system, it takes some 10 ns. The uncertainty of the timeit result is at
least a few hundred nanoseconds.


There are more than 10 multiplications to perform on a
soaring size integer. I have some doubts "x=123456**123456 "
only takes 10 ns on your system.

On my computer it takes roughtly 4 s, mesured with a watch.
I can't do "len(str(x))" to know the size, I have to kill the process
But x.bit_length() answers 2088091, so x should have about
60 digits

If I measure execution time:


t=time(); x=123456**123456; print(time()-t)

0.0

There is still something wrong

I suppose that my computer CPU goes to 100% busy and
that the timer used by timeit or time no longer works.






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


Re: Problem with timeit

2017-12-15 Thread Steve D'Aprano
On Sat, 16 Dec 2017 12:25 am, ast wrote:

> 
> "Thomas Jollans"  a écrit dans le message de
> news:mailman.74.1513341235.14074.python-l...@python.org...
>> On 2017-12-15 11:36, ast wrote:
> 
> 
>> No, this is right. The calculation takes practically no time; on my
>> system, it takes some 10 ns. The uncertainty of the timeit result is at
>> least a few hundred nanoseconds.
> 
> There are more than 10 multiplications to perform on a
> soaring size integer. I have some doubts "x=123456**123456 "
> only takes 10 ns on your system.

You would be right.

My computer appears to be about a thousand times slower than Thomas' computer.
On my computer, it takes about a second to calculate 123456**123456, so I
predict his will take about a millisecond.


> On my computer it takes roughtly 4 s, mesured with a watch.

That's not a very accurate way to measure it. You are measuring your own
reaction time, the time it takes the interactive interpreter to parse the
text of the code, compile it, execute the code, then print a new prompt, and
then your reaction time again. The actual execution time is drowned in the
rest of the noise.

> I can't do "len(str(x))" to know the size, I have to kill the process

On my computer, that took about five minutes or so. I wasn't really paying
attention on precisely how long it took, but it was around that.


> But x.bit_length() answers 2088091, so x should have about
> 60 digits

py> x = 123456**123456
py> s = str(x)
py> len(s)
628578



> If I measure execution time:
> 
 t=time(); x=123456**123456; print(time()-t)
> 0.0
> 
> There is still something wrong

The interpreter first computes the big int 123456**123456 while it is
compiling the entire command line, so that happens *before* the time starts.
The assignment is so fast that the three statements:

t = time()
x = 5...6  # huge number, pre-calculated
print(time() - t)

essentially occurs faster than the resolution of time.time() on your machine.

Try using time.perf_counter instead.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Problem with timeit

2017-12-15 Thread Paul Moore
On 15 December 2017 at 13:25, ast  wrote:
> On my computer it takes roughtly 4 s, mesured with a watch.

Is your computer particularly old? On my PC, the time it takes to run
x=123456**123456 at the Python interpreter prompt is barely
noticeable.

> I can't do "len(str(x))" to know the size, I have to kill the process

Took a few seconds (5-10s) on my PC, and returned 628578.

> But x.bit_length() answers 2088091, so x should have about
> 60 digits

Yep, that's what I get

>
> If I measure execution time:
>
 t=time(); x=123456**123456; print(time()-t)
>
> 0.0

Same here.

> There is still something wrong

As far as I can see, it's in your manual measurement. All of the code
you've provided gives the same results on my PC as on yours, but your
manual measurements differ drastically from mine (and my manual
measurements match what I'd expect given results of timeit/time.time
whereas yours don't...).

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


Re: Problem with timeit

2017-12-15 Thread ast


"ast"  a écrit dans le message de 
news:5a33a5aa$0$10195$426a7...@news.free.fr...

Ty Peter and Steve, I would never have found that
explanation myself 


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


Re: Python Learning

2017-12-15 Thread Michael Biondi
I've been slowly reading through "Learning Python: Powerful 
Object-Oriented Programming" - ( 
https://www.amazon.com/Learning-Python-Powerful-Object-Oriented-Programming-ebook/dp/B00DDZPC9S/ref=sr_1_2?ie=UTF8&qid=1513350446&sr=8-2&keywords=learning+python+powerful+object-oriented+programming 
)


It's a huge read and not a great book if you just want to get started 
right away, but I've found it to be very helpful in explaining the 
nuances of the language.  I'm interested to see what other people find 
useful.


Thanks,

Michael


On 12/15/2017 6:49 AM, Varun R wrote:

Hi All,

I'm new to programming, can anyone guide me, how to start learning python 
programming language,...plz suggest some books also.

Thanks all


--
--
Michael Biondi
Generic Network Systems, LLC
(212) 268-4722 ext. 215

--
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 Grant Edwards
On 2017-12-15, Steve D'Aprano  wrote:
> On Fri, 15 Dec 2017 09:48 am, Gregory Ewing wrote:
[...]
> Classic MacOS associated two such pieces of metadata with each file: the
> creator and type. [...]
>
> https://en.wikipedia.org/wiki/Creator_code
>
>> I believe MacOSX also has the ability to store a file type as
>> metadata, but it doesn't seem to be used much.
>
> They are still supported (-ish) by OS X, but have been superseded by Uniform
> Type Identifiers.

Where are the UTIs stored?  Do OS X filesystems still have a "resource
fork"?

-- 
Grant Edwards   grant.b.edwardsYow! I smell like a wet
  at   reducing clinic on Columbus
  gmail.comDay!

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


Re: Problem with timeit

2017-12-15 Thread Bob van der Poel
I get a very short delay when doing the calculation.  1.90734863281e-06 to
be precise.

But, printing the result takes much longer. 4.82930707932 seconds.


On Fri, Dec 15, 2017 at 6:47 AM, Paul Moore  wrote:

> On 15 December 2017 at 13:25, ast  wrote:
> > On my computer it takes roughtly 4 s, mesured with a watch.
>
> Is your computer particularly old? On my PC, the time it takes to run
> x=123456**123456 at the Python interpreter prompt is barely
> noticeable.
>
> > I can't do "len(str(x))" to know the size, I have to kill the process
>
> Took a few seconds (5-10s) on my PC, and returned 628578.
>
> > But x.bit_length() answers 2088091, so x should have about
> > 60 digits
>
> Yep, that's what I get
>
> >
> > If I measure execution time:
> >
>  t=time(); x=123456**123456; print(time()-t)
> >
> > 0.0
>
> Same here.
>
> > There is still something wrong
>
> As far as I can see, it's in your manual measurement. All of the code
> you've provided gives the same results on my PC as on yours, but your
> manual measurements differ drastically from mine (and my manual
> measurements match what I'd expect given results of timeit/time.time
> whereas yours don't...).
>
> Paul
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 

 Listen to my FREE CD at http://www.mellowood.ca/music/cedars 
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: b...@mellowood.ca
WWW:   http://www.mellowood.ca
-- 
https://mail.python.org/mailman/listinfo/python-list


Automated distribution building tools to support SpamBayes

2017-12-15 Thread Skip Montanaro
SpamBayes (http://www.spambayes.org/) has languished for quite awhile,
in part because nobody is around who can put together a Windows
installer. Unfortunately, most users are on Windows and have to work
around problems caused by the march of time and consequent beefing up
of Windows security.

I don't do Windows, but I wonder... Can one of the various continuous
integration tools out there be enlisted to build Windows installers?
The SB code is written in Python, uses the Win32 extension, and is
hosted on GitHub (https://github.com/smontanaro/spambayes), so
something which plays nice with that environment would be a plus. I'm
slowly gaining familiarity at work with Bamboo (very, very slowly), so
the general idea of what CI tools can do is starting to sink in. Since
I'm a captive Atlassian customer at work, though, I don't know what
limitations I might encounter trying to use it in an open source
environment.

Any feedback appreciated. As this is only Python-related in the sense
that SpamBayes is written in Python, feel free to reply off-list.

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


ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol

2017-12-15 Thread Piyush Verma
Getting SSL error while connecting from httplib.HTTPSConnection.

Any help would be appreciated.

self.connection.request(method, request, payload, self.headers)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 1053, in request
self._send_request(method, url, body, headers)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 1093, in _send_request
self.endheaders(body)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 1049, in endheaders
self._send_output(message_body)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 893, in _send_output
self.send(msg)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 855, in send
self.connect()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 1274, in connect
server_hostname=server_hostname)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py",
line 352, in wrap_socket
_context=self)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py",
line 579, in __init__
self.do_handshake()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py",
line 808, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

Regards,
~Piyush
Facebook  Twitter

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


Re: Python Learning

2017-12-15 Thread Bill

Varun R wrote:

Hi All,

I'm new to programming, can anyone guide me, how to start learning python 
programming language,...plz suggest some books also.

Thanks all


Are you sure you want to learn Python first?
Python does enough things "behind the scene"
that it makes me question the wisdom of that.
Other points of view are welcome, of course.
Learning the primitives of C++ first, may make for an easier transition.
Surely this has been discussed before?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-15 Thread Chris Angelico
On Sat, Dec 16, 2017 at 8:51 AM, Bill  wrote:
> Varun R wrote:
>>
>> Hi All,
>>
>> I'm new to programming, can anyone guide me, how to start learning python
>> programming language,...plz suggest some books also.
>>
>> Thanks all
>
>
> Are you sure you want to learn Python first?
> Python does enough things "behind the scene"
> that it makes me question the wisdom of that.
> Other points of view are welcome, of course.
> Learning the primitives of C++ first, may make for an easier transition.
> Surely this has been discussed before?

On the contrary, that makes Python an *excellent* first language. We
don't force people to learn about the chemistry of petrochemical
combustion before letting them learn how to drive a car; we don't make
people understand TCP/IP networking before they're allowed to type
something into Google. And if you DO want people to start off with a
lower-level language, why C++? Why not machine code (or at least
assembly code), since that's what the CPU actually executes? Or wait -
let's start off by teaching people the electrical engineering that
underlies all of the CPU's operation. And at least a bit of quantum
physics, since that governs stuff once you get to the level of
miniaturization of modern CPUs. No; it's far better to start out by
treating Python as its own thing, powered by magic. Later on, you can
peel back the layers and learn about what's behind everything - at
your own pace.

ChrisA
-- 
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 Gregory Ewing

Steve D'Aprano wrote:


They are still supported (-ish) by OS X, but have been superseded by Uniform
Type Identifiers.

https://en.wikipedia.org/wiki/Uniform_Type_Identifier


I know, what I'm not sure about is how much those are used
by apps these days, with so much of the widely used software
being multi-platform.

The Finder doesn't make it easy to tell -- it just shows
you which app is the default one for a file, without any
details as to how it's determining that.

And if you change the default app for a file, it asks
"Do you want to open all file like this with ?",
but it's not very clear what "like" means for a given file.
It could mean "having the same suffix", "having the same
UTI", or "having the same legacy type code".

--
Greg
--
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 Gregory Ewing

Grant Edwards wrote:

Where are the UTIs stored?  Do OS X filesystems still have a "resource
fork"?


UTIs are stored as extended attributes.

Resource forks still exist, but they're deprecated. Things that
used to be kept in resource forks are now usually just files in
the application bundle -- which is just a specially marked
directory as far as the OS is concerned.

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


Re: Automated distribution building tools to support SpamBayes

2017-12-15 Thread Ned Batchelder

On 12/15/17 2:03 PM, Skip Montanaro wrote:

SpamBayes (http://www.spambayes.org/) has languished for quite awhile,
in part because nobody is around who can put together a Windows
installer. Unfortunately, most users are on Windows and have to work
around problems caused by the march of time and consequent beefing up
of Windows security.

I don't do Windows, but I wonder... Can one of the various continuous
integration tools out there be enlisted to build Windows installers?
The SB code is written in Python, uses the Win32 extension, and is
hosted on GitHub (https://github.com/smontanaro/spambayes), so
something which plays nice with that environment would be a plus. I'm
slowly gaining familiarity at work with Bamboo (very, very slowly), so
the general idea of what CI tools can do is starting to sink in. Since
I'm a captive Atlassian customer at work, though, I don't know what
limitations I might encounter trying to use it in an open source
environment.

Any feedback appreciated. As this is only Python-related in the sense
that SpamBayes is written in Python, feel free to reply off-list.

Skip


I use AppVeyor CI to build Windows installers for coverage.py.  It's not 
straightforward though, there are Powershell scripts, etc. The config 
file is here: 
https://github.com/nedbat/coveragepy/blob/master/appveyor.yml with other 
necessities in the ci folder.


Hope that helps,

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


Repeated Names (Repeated Names)

2017-12-15 Thread Gregory Ewing

Anyone else now getting duplicate posts with the sender's
name repeated in parentheses?

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


Re: Repeated Names (Repeated Names)

2017-12-15 Thread MRAB

On 2017-12-15 23:56, Gregory Ewing wrote:

Anyone else now getting duplicate posts with the sender's
name repeated in parentheses?


It's happened twice before, but I haven't had any today.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-15 Thread Bill

Chris Angelico wrote:

On Sat, Dec 16, 2017 at 8:51 AM, Bill  wrote:

Varun R wrote:

Hi All,

I'm new to programming, can anyone guide me, how to start learning python
programming language,...plz suggest some books also.

Thanks all


Are you sure you want to learn Python first?
Python does enough things "behind the scene"
that it makes me question the wisdom of that.
Other points of view are welcome, of course.
Learning the primitives of C++ first, may make for an easier transition.
Surely this has been discussed before?

On the contrary, that makes Python an *excellent* first language. We
don't force people to learn about the chemistry of petrochemical
combustion before letting them learn how to drive a car; we don't make
people understand TCP/IP networking before they're allowed to type
something into Google. And if you DO want people to start off with a
lower-level language, why C++? Why not machine code (or at least
assembly code), since that's what the CPU actually executes?


Most decent introductions to C++ discuss machine language (it helps make 
sense of compilation).
As you indirectly suggest, learning is something of a circular process, 
so it really doesn't make that much difference where one starts, just 
"Do It!".  :  )


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


Re: Python Learning

2017-12-15 Thread Rustom Mody
On Saturday, December 16, 2017 at 9:45:17 AM UTC+5:30, Bill wrote:
> Chris Angelico wrote:
> > On Sat, Dec 16, 2017 at 8:51 AM, Bill wrote:
> >> Varun R wrote:
> >>> Hi All,
> >>>
> >>> I'm new to programming, can anyone guide me, how to start learning python
> >>> programming language,...plz suggest some books also.
> >>>
> >>> Thanks all
> >>
> >> Are you sure you want to learn Python first?
> >> Python does enough things "behind the scene"
> >> that it makes me question the wisdom of that.
> >> Other points of view are welcome, of course.
> >> Learning the primitives of C++ first, may make for an easier transition.
> >> Surely this has been discussed before?
> > On the contrary, that makes Python an *excellent* first language. We
> > don't force people to learn about the chemistry of petrochemical
> > combustion before letting them learn how to drive a car; we don't make
> > people understand TCP/IP networking before they're allowed to type
> > something into Google. And if you DO want people to start off with a
> > lower-level language, why C++? Why not machine code (or at least
> > assembly code), since that's what the CPU actually executes?
> 
> Most decent introductions to C++ discuss machine language (it helps make 
> sense of compilation).
> As you indirectly suggest, learning is something of a circular process, 
> so it really doesn't make that much difference where one starts, just 
> "Do It!".  :  )

Really¿? 
https://en.wikipedia.org/wiki/Principles_of_learning#Primacy
-- 
https://mail.python.org/mailman/listinfo/python-list