Re: Goto

2017-12-28 Thread breamoreboy
On Friday, December 29, 2017 at 3:28:23 AM UTC, Ben Finney wrote:
> Tim Chase writes:
> 
> > [third-party website]
> > Gives you […]
> 
> So, it's not in Python, it's a third-party (joke) package. Hence is
> probably not what Duram is asking about as “goto in Python”.
> 
> I'm still open to learning what Duram meant by “goto in Python”. Rather
> than everyone else piling on with suggestions, can we let Duram answer?
> 
> -- 
>  \  “Think for yourselves and let others enjoy the privilege to do |
>   `\  so too.” —Voltaire, _Essay On Tolerance_ |
> _o__)  |
> Ben Finney

Did you miss Tim's wink, which you've cut from your reply, or did you get out 
of bed on the wrong side this morning, or what?

--
Kindest regards.

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


Re: Goto

2017-12-28 Thread Ben Finney
Tim Chase  writes:

> [third-party website]
> Gives you […]

So, it's not in Python, it's a third-party (joke) package. Hence is
probably not what Duram is asking about as “goto in Python”.

I'm still open to learning what Duram meant by “goto in Python”. Rather
than everyone else piling on with suggestions, can we let Duram answer?

-- 
 \  “Think for yourselves and let others enjoy the privilege to do |
  `\  so too.” —Voltaire, _Essay On Tolerance_ |
_o__)  |
Ben Finney

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


Re: Goto

2017-12-28 Thread Tim Chase
On 2017-12-29 08:42, Ben Finney wrote:
> Duram  writes:
> 
> > How to use goto in python?  
> 
> Step 0: what is goto in Python?
> 
> Step 1: that's not something that exists in Python. So why are you
> asking how to use something that doesn't exist?

so quick to shoot down a poor soul.

http://entrian.com/goto/

Gives you both GOTO and COMEFROM ;-)

-tkc




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


Re: Goto

2017-12-28 Thread breamoreboy
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.

--
Kindest regards.

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


Re: Goto

2017-12-28 Thread Chris Angelico
On Fri, Dec 29, 2017 at 11:17 AM, bartc  wrote:
> On 28/12/2017 21:42, Ben Finney wrote:
>>
>> Duram  writes:
>>
>>> How to use goto in python?
>>
>>
>> Step 0: what is goto in Python?
>>
>> Step 1: that's not something that exists in Python. So why are you
>> asking how to use something that doesn't exist?
>
>
> Goto exists in the form of the JUMP_ABSOLUTE byte-code.
>
> But it's not accessible from the language.
>

That's an implementation detail in one implementation of Python
(albeit the most popular one). It is not part of the language.

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


Re: Goto

2017-12-28 Thread Ben Finney
bartc  writes:

> But it's not accessible from the language.

Another way to say that (and the way I said the same thing) is: It
doesn't exist in Python.

-- 
 \ “I went to the museum where they had all the heads and arms |
  `\  from the statues that are in all the other museums.” —Steven |
_o__)   Wright |
Ben Finney

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


Re: Goto

2017-12-28 Thread bartc

On 28/12/2017 21:42, Ben Finney wrote:

Duram  writes:


How to use goto in python?


Step 0: what is goto in Python?

Step 1: that's not something that exists in Python. So why are you
asking how to use something that doesn't exist?


Goto exists in the form of the JUMP_ABSOLUTE byte-code.

But it's not accessible from the language.


--
bartc


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


Re: PyWin32 installer question

2017-12-28 Thread Paul Moore
On 28 December 2017 at 17:49, Skip Montanaro  wrote:
> pip install py2exe_py2 pypiwin32 Pillow lockfile
> Collecting py2exe_py2
> Could not find a version that satisfies the requirement py2exe_py2
> (from versions: )
>
> That error message isn't telling me much about why the requirement
> isn't satisfied.
>
> The name of the wheel file suggests that it's architecture-independent:
>
> py2exe_py2-0.6.9-cp27-none-win32.whl
>
> Any idea what it's complaining about?

That's not an architecture-independent file. The Wheel spec gives all
the details, but "cp27" (as opposed to "py27") means it's CPython only
(which usually means it's got a C extension) and "win32" is 32-bit
only ("win_amd64" is the tag for 64-bit Windows). So the problem is
that the py2exe_py2 maintainer doesn't supply a 64-bit build. You
could ask the maintainers if they could supply a 64-bit build. You may
be able to build your own copy, but without a Windows system, doing so
on Appveyor will be a real pain. Another option is to use Christoph
Gohlke's builds, from
https://www.lfd.uci.edu/~gohlke/pythonlibs/#py2exe - you have to
download the wheel file manually (the site doesn't support automated
downloads) and then upload it to Appveyor somehow (maybe by keeping a
copy of the wheel in the project repo). Also the version there is
0.6.10a1 which looks like an alpha rather than the last official
release. So I guess there may be issues with that. Worst case scenario
would be to switch to something other than py2exe - cx_Freeze seems
similar and pretty good, and it *does* ship 64-bit Python 2.7 wheels.
But that's obviously a non-trivial task.

Welcome to the bad old days of trying to find Windows binaries for
Python packages :-( I'd strongly recommend moving to Python 3, as the
situation is immensely improved there - most projects ship Python 3
binary wheels, and "pip install" just works in many cases. But I
appreciate that doesn't help much for you. Sorry - hopefully one of
the other options above will help.

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


Re: Goto

2017-12-28 Thread Ben Finney
Duram  writes:

> How to use goto in python?

Step 0: what is goto in Python?

Step 1: that's not something that exists in Python. So why are you
asking how to use something that doesn't exist?

-- 
 \“[R]ightful liberty is unobstructed action, according to our |
  `\will, within limits drawn around us by the equal rights of |
_o__) others.” —Thomas Jefferson, 1819 |
Ben Finney

-- 
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: Python Software Installation - Failed

2017-12-28 Thread Kirankumar Reddy Polu
Hi,

I am trying to install Python 3.6.4 in my laptop. I am getting the following 
error. I also attached failure log as well in the mail. I could not change the 
path. It is automatically installing in C drive. Might be, this is restricted 
drive, so we got errors. I am not sure, but let me know as well to do the path 
changes at D drive.

Please suggest me to do the installation steps without failures of the attached 
logs.

[cid:image001.png@01D37FFA.E81295C0]


Regards,
Kiran Polu


Disclaimer:  This message and the information contained herein is proprietary 
and confidential and subject to the Tech Mahindra policy statement, you may 
review the policy at http://www.techmahindra.com/Disclaimer.html 
 externally 
http://tim.techmahindra.com/tim/disclaimer.html 
 internally within 
TechMahindra.


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


Goto

2017-12-28 Thread Duram

How to use goto in python?

---
This email has been checked for viruses by AVG.
http://www.avg.com

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


Re: PyWin32 installer question

2017-12-28 Thread Skip Montanaro
Thanks for the help, Paul.

> When I took a quick look at the code, it seemed to be based on a
> pretty old version of Python. What version are you using?

Yes, last time a Windows installer was created, Python 2.5 was still
in vogue. I switched things to 2.7 with (so far) no obvious problems.

I eventually got past the pywin32 install hassles you referred to when
I stumbled on the pypiwin32 package:

https://pypi.python.org/pypi/pypiwin32/220

On the PyPI site, it does, indeed, look like only Python 3 is
supported, but it seemed to download and install a 2.7 version. This
is from my latest 32-bit build:

pip install py2exe_py2 pypiwin32 Pillow lockfile
Collecting py2exe_py2
Downloading py2exe_py2-0.6.9-cp27-none-win32.whl (134kB)
Collecting pypiwin32
Downloading pypiwin32-219-cp27-none-win32.whl (6.7MB)
Collecting Pillow
Downloading Pillow-4.3.0-cp27-cp27m-win32.whl (1.3MB)
Collecting lockfile
Downloading lockfile-0.12.2-py2.py3-none-any.whl

(I guess it fell back to 219 automatically. Clever tool, that pip...)

So, I'm past that hurdle, and eventually got a successful 32-bit build:

https://ci.appveyor.com/project/smontanaro/spambayes/build/job/5pflj8b6t3qn0naw/artifacts

but now I'm fumbling around with 64-bit (my holy grail, as most
Outlook users are running a 64-bit version, at least based on the
install questions we get on the SpamBayes mailing list):

pip install py2exe_py2 pypiwin32 Pillow lockfile
Collecting py2exe_py2
Could not find a version that satisfies the requirement py2exe_py2
(from versions: )

That error message isn't telling me much about why the requirement
isn't satisfied.

The name of the wheel file suggests that it's architecture-independent:

py2exe_py2-0.6.9-cp27-none-win32.whl

Any idea what it's complaining about?

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


Re: PyWin32 installer question

2017-12-28 Thread Paul Moore
When I took a quick look at the code, it seemed to be based on a
pretty old version of Python. What version are you using? If it's 2.7
(or better still, Python 3!) then you should have pip available. In
which case you may be better off using pypiwin32, which is a
rebundling of pywin32 as a wheel. "python -m pip install pypiwin21"
should work for you. You may need to force the version to be 219, as
there's only Python 3.6 wheels for version 220 (do this as "python -m
pip install pypiwin32==219") - but I don't think you'll need this, pip
should limit itself to compatible wheels.

Unfortunately, pywin32 is one of the worst extensions to install, as
the project doesn't supply official wheels, and some of the COM stuff
needs registration, which in the wininst script is handled by a
post-install step, but I've no idea how you do that with a wheel - you
may need to ask the project maintainers for advice.

Paul

On 27 December 2017 at 14:58, Skip Montanaro  wrote:
> I'm fiddling around with Appveyor, trying to build a Windows installer
> for SpamBayes. This is complicated by two facts:
>
> 1. I don't know squat about Windows.
>
> 2. I don't have access to a Windows command line.
>
> Consequently, every new attempt requires a change to appveyor.yml and
> a git push command. Rather slow going. My latest Appveyor build number
> is 59. Most of the changes were simple fixes for syntax errors.
>
> I got to the point where I (finally!) was able to successfully
> download the appropriate pywin32 installer, but executing it just
> hangs. I sort of assume it's asking os.devnull for something. Alas, I
> couldn't find any sort of command line flags for the installer itself
> in the pywin32 code. I've tried
>
> pywin32.exe /h
>
> but that just sits there (ignores that flag?) and
>
> pywin32.exe /?
>
> which produced some inscrutable output.
>
> Is there some way to coax it into giving me some help and exiting?
>
> Thanks,
>
> Skip
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


win32wnet.WNetAddConnection2 issue

2017-12-28 Thread joanazpeitia
Hi guys,

I've seen a few posts about this topic but could not find the solution. I am 
trying to connect a drive to a network drive using win32wnet.WNetAddConnection2 
but I might be missing something because it does not work.
This is what I have.


import os
import win32api
import win32wnet
import win32netcon,win32wnet


ynetworkPath = 'LAMPSERVER_RB\\resources_server\\'
znetworkPath = 'LAMPSERVER\\lampserver\\_PROJECTS\\'
yDrive = 'Y:'
user='aa'
password='bb'


def mapResourcesDrive():
print ynetworkPath
if (os.path.exists(yDrive)):
print "Y drive is already mapped"
if (os.path.exists(ynetworkPath)):
print ynetworkPath, " is found..."
print "Trying to map ", ynetworkPath, " on to ", yDrive, " ."
try:
win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, yDrive, 
ynetworkPath, None, user, password)
print "connection established succesfully"
except:
print "Unexpected error..."
return -1
print "Mapping successful"
return 1
else:
print "Network path unreachable..."


mapResourcesDrive()


If anyone can give me an idea of why 

win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, yDrive, 
ynetworkPath, None, user, password)

is not working owuld be much appreciatted.
Many thanks,

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


Re: GUI user input to function

2017-12-28 Thread Chris Angelico
On Thu, Dec 28, 2017 at 11:06 PM, Nico Vogeli  wrote:
> Am Donnerstag, 28. Dezember 2017 12:59:24 UTC+1 schrieb Chris Angelico:
>> On Thu, Dec 28, 2017 at 8:38 PM, Nico Vogeli  wrote:
>> > Withs test, this return a correct value for the two x functions:
>> >
>> > from sympy import symbols
>> >
>> > x = symbols('x')
>> > f1 = eval(input('function 1 '))
>> > f2 = eval(input('function 2 '))
>> >
>>
>> What are you typing as input? It's hard to grok your code without knowing 
>> that.
>>
>> ChrisA
>
> I'm sorry! User input would look like this for example: x**2 + 3*x or x**3
>

Cool. That's an expression, but it isn't a function. To make that into
a function, you need to prefix it with the lambda keyword.

So you should be able to construct functions like this:

f1 = eval("lambda x: " + input("function 1: "))

Then, when you type "x**3", Python evaluates "lambda x: x**3", which
is a function.

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


Re: Python goto

2017-12-28 Thread Skip Montanaro
Jorge> I would like to know if there is a goto command or something similar that
Jorge> I can use in Python.

Ned> Python does not have a goto statement. You have to use structured
Ned> statements: for, while, try/except, yield, return, etc.

Though it appears some wag has used function decorators to implement
goto statements:

https://pypi.python.org/pypi/goto-statement/1.1

Rather clever, it seems.

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


Re: Python goto

2017-12-28 Thread Ned Batchelder

On 12/28/17 6:43 AM, jorge.conr...@cptec.inpe.br wrote:



Hi,

I would like to know if there is a goto command or something similar 
that I can use in Python.




Python does not have a goto statement. You have to use structured 
statements: for, while, try/except, yield, return, etc.


If you show an example of where you would like to use a goto, we can 
help find a different way.


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


Re: GUI user input to function

2017-12-28 Thread Nico Vogeli
Am Donnerstag, 28. Dezember 2017 12:59:24 UTC+1 schrieb Chris Angelico:
> On Thu, Dec 28, 2017 at 8:38 PM, Nico Vogeli  wrote:
> > Withs test, this return a correct value for the two x functions:
> >
> > from sympy import symbols
> >
> > x = symbols('x')
> > f1 = eval(input('function 1 '))
> > f2 = eval(input('function 2 '))
> >
> 
> What are you typing as input? It's hard to grok your code without knowing 
> that.
> 
> ChrisA

I'm sorry! User input would look like this for example: x**2 + 3*x or x**3

Regards

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


Re: GUI user input to function

2017-12-28 Thread Chris Angelico
On Thu, Dec 28, 2017 at 8:38 PM, Nico Vogeli  wrote:
> Withs test, this return a correct value for the two x functions:
>
> from sympy import symbols
>
> x = symbols('x')
> f1 = eval(input('function 1 '))
> f2 = eval(input('function 2 '))
>

What are you typing as input? It's hard to grok your code without knowing that.

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


Python goto

2017-12-28 Thread jorge . conrado



Hi,

I would like to know if there is a goto command or something similar 
that I can use in Python.


Thanks,

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


GUI user input to function

2017-12-28 Thread Nico Vogeli
Hello again

I think my question got lost in all the others raised, so here I am again :P



So, I tried my best, was looking into the eval and exec function, but still no 
succsess..

Maybe it helps when I provide the code I want to implement:

def newton_verfahren(self):
if self.cB_1.currentText() == 'Newton':
   
x0 = self.newton_x.text()
f1 = self.func_1.text()
f2 = self.func_2.text()
tol = self.newton_tol.text()
n = self.newton_n.text()
k = Numerik_Funktionen.newton(int(x0), eval(f1), eval(f2),
  int(tol), int(n))
k1 = str(k[0])
k2 = str(k[1])
k3 = str(k[2])
self.ausgabe.setText('Startwert -> x0: '+ k1 + "\n" +
  'Anzahl Iterationen: ' + k2 +"\n" +
  'f(x~): ' + k3)  

Notice that cB_1 is a combobox, newton_x, func_1, func_2, newton_tol and 
newton_n are all QLineEdits.

The code above doesn't work, so I've opend a 'test' file to just play around 
with the functions.

Withs test, this return a correct value for the two x functions:

from sympy import symbols

x = symbols('x')
f1 = eval(input('function 1 '))
f2 = eval(input('function 2 '))

But now I get and error from the imported module in the line where the 
abs(f(x)) > tol.

It states that the 'Pow' object is not callable. And now I don't know how to 
proceed, I can't figure out a way to make the call to the imported module:

x = symbols('x')
def newton(x0, f, fx, tol, n = 2):
'''
Näherung zur lösung einer Gleichung mit dem Newton-Verfahren
x0 = Startwert
f = zu lösende Funktion
fx = Ableitung der Funktion
   
'''

   
x = x0
k = 0
   
while n > k and abs(f(x)) > tol:
k += 1
x = x - f(x)/fx(x)
print('x', k, '\n', x)
   
print('Startwert -> x0', '\n', x0)
print('Anzahl Iterationen', '\n', k)
print('f(x~)', '\n', f(x))
print('Näherungswert -> x~', '\n', x)

 
return x0, k, f(x), x

Regards

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