doubt loading pages
hello everyone,
Im trying to make a program that takes an archive from pdb (for instance this
link http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=5HXY
after reading it I want it to save in a list only this part of the archive:
MGSSHHSSGLVPRGSHMASMTGGQQMGRGSMPAETNEYLSRFVEYMTGERKSRYTIKEYRFLVDQFLSFMNKKPDEITPMDIERYKNFLAVKKRYSKTSQYLAIKAVKLFYKALDLRVPINLTPPKRPSHMPVYLSEDEAKRLIEAASSDTRMYAIVSVLAYTGVRVGELCNLKISDVDLQESIINVRSGKGDKDRIVIMAEECVKALGSYLDLRLSMDTDNDYLFVSNRRVRFDTSTIERMIRDLGKKAGIQKKVTPHVLRHTFATSVLRNGGDIRFIQQILGHASVATTQIYTHLNDSALREMYTQHRPRY
I have written this:
import urllib2
seq=raw_input("Introduce pdb code \n")
seq =
urllib2.urlopen("http://www.rcsb.org/pdb/files/fasta.txt?structureIdList="+seq)
print seq.read()
seq.close()
My question is, how do I save this into a python list?
Thank you!
--
https://mail.python.org/mailman/listinfo/python-list
Re: doubt loading pages
José Manuel Suárez Sierra wrote:
> hello everyone,
> Im trying to make a program that takes an archive from pdb (for instance
> this link http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=5HXY
>
> after reading it I want it to save in a list only this part of the
> archive:
>
> MGSSHHSSGLVPRGSHMASMTGGQQ...IRFIQQILGHASVATTQIYTHLNDSALREMYTQHRPRY
>
> I have written this:
>
> import urllib2
>
>
> seq=raw_input("Introduce pdb code \n")
>
>
>
> seq =
> urllib2.urlopen(
> "http://www.rcsb.org/pdb/files/fasta.txt?structureIdList="+seq)
> print seq.read()
>
>
> seq.close()
>
>
> My question is, how do I save this into a python list?
While you could cook up something yourself it's probably better to use an
existing library like biopython.
$ cat retrieve_fasta.py
import urllib2
import Bio.SeqIO
seq = raw_input("Introduce pdb code \n")
seq = urllib2.urlopen(
"http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=";
+ seq
)
for record in Bio.SeqIO.parse(seq, "fasta"):
seq_list = list(record.seq.tostring())
break # stop after the first iteration
print seq_list
$ python retrieve_fasta.py
Introduce pdb code
5HXY
['M', 'G', 'S', 'S', 'H', 'H', 'H', 'H', 'H', 'H', 'S', 'S', 'G', 'L', 'V',
...
'R', 'Y']
See .
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python3.6 tkinter bug?
On 2/1/2017 1:37 AM, Christian Gollwitzer wrote: Am 01.02.17 um 00:02 schrieb MRAB: On 2017-01-31 22:34, Christian Gollwitzer wrote: .!frame.!checkbutton .!frame.!checkbutton2 .!frame2.!checkbutton .!frame2.!checkbutton2 Perhaps someone who knows Tcl and tk can tell me, but I notice that in the first example, the second part of the widget names are unique, whereas in the second example, the second part of the widget names are the reused (both "!checkbutton" and "!checkbutton2" occur twice). It is indeed the reason, but it has some strange legacy cause: the default name for the checkbutton-linked variable is the name of the button inside the parent. Therefore creating a checkbutton has the side effect of creating a variable with the button's name. In this case, the first buttons in the frames are linked to a variable called "!checkbutton" and the other two are linked to "!checkbutton2". (a variable name in Tcl can be anything apart from the empty string). This can also be demonstrated by this Tcl script: package require Tk pack [frame .f1] pack [frame .f2] pack [checkbutton .f1.c1 -text "A" ] pack [checkbutton .f1.c2 -text "B" ] pack [checkbutton .f2.c1 -text "C" ] pack [checkbutton .f2.c2 -text "D" ] which is equivalent to the Python code above. Note that this surprising behaviour was corrected for the (modern) ttk widgets, so if "checkbutton" is replaced by "ttk::checkbutton", they are not any longer linked. In Python, that would be from tkinter import ttk ... w = ttk.Checkbutton() (Personally, I'm not using the legacy widgets any longer) Christian, could you repeat any relevant parts of your comments on the tracker, especially any ideas on how we might fix tkinter? https://bugs.python.org/issue29402 Do the names need to be: .!frame.!checkbutton .!frame.!checkbutton2 .!frame2.!checkbutton3 .!frame2.!checkbutton4 Serhiy considered that but, not knowing that this would cause a regression, we both liked numbering within parent better. There is a similar issue with radiobuttons on ttk.OptionMenus that existed *before* the 3.6 name changes. https://bugs.python.org/issue25684 So there seems to be a systematic issue with tk or how we are (mis)using it. Good question. Maybe there should be unique variable names? I.e., if the script is changed into package require Tk pack [frame .f1] pack [frame .f2] pack [checkbutton .f1.c1 -text "A" -variable v1] pack [checkbutton .f1.c2 -text "B" -variable v2] pack [checkbutton .f2.c1 -text "C" -variable v3] pack [checkbutton .f2.c2 -text "D" -variable v4] then they are also not linked. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: doubt loading pages
El miércoles, 1 de febrero de 2017, 11:55:11 (UTC+1), José Manuel Suárez Sierra
escribió:
> hello everyone,
> Im trying to make a program that takes an archive from pdb (for instance this
> link http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=5HXY
>
> after reading it I want it to save in a list only this part of the archive:
>
> MGSSHHSSGLVPRGSHMASMTGGQQMGRGSMPAETNEYLSRFVEYMTGERKSRYTIKEYRFLVDQFLSFMNKKPDEITPMDIERYKNFLAVKKRYSKTSQYLAIKAVKLFYKALDLRVPINLTPPKRPSHMPVYLSEDEAKRLIEAASSDTRMYAIVSVLAYTGVRVGELCNLKISDVDLQESIINVRSGKGDKDRIVIMAEECVKALGSYLDLRLSMDTDNDYLFVSNRRVRFDTSTIERMIRDLGKKAGIQKKVTPHVLRHTFATSVLRNGGDIRFIQQILGHASVATTQIYTHLNDSALREMYTQHRPRY
>
> I have written this:
>
> import urllib2
>
>
> seq=raw_input("Introduce pdb code \n")
>
>
>
> seq =
> urllib2.urlopen("http://www.rcsb.org/pdb/files/fasta.txt?structureIdList="+seq)
> print seq.read()
>
>
> seq.close()
>
>
> My question is, how do I save this into a python list?
>
> Thank you!
What I need is to convert the whole archive into a list, how could I do it?
--
https://mail.python.org/mailman/listinfo/python-list
Re: doubt loading pages
José Manuel Suárez Sierra wrote:
> El miércoles, 1 de febrero de 2017, 11:55:11 (UTC+1), José Manuel Suárez
> Sierra escribió:
>> hello everyone,
>> Im trying to make a program that takes an archive from pdb (for instance
>> this link http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=5HXY
>>
>> after reading it I want it to save in a list only this part of the
>> archive:
>>
>> MGSSHHSSG...
>>
>> I have written this:
>>
>> import urllib2
>>
>>
>> seq=raw_input("Introduce pdb code \n")
>>
>>
>>
>> seq =
>>
urllib2.urlopen("http://www.rcsb.org/pdb/files/fasta.txt?structureIdList="+seq)
>> print seq.read()
>>
>>
>> seq.close()
>>
>>
>> My question is, how do I save this into a python list?
>>
>> Thank you!
>
> What I need is to convert the whole archive into a list, how could I do
> it?
Dunno. Perhaps
$ cat retrieve_fasta2.py
import urllib2
import Bio.SeqIO
seq = raw_input("Introduce pdb code \n")
seq = urllib2.urlopen(
"http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=";
+ seq
)
seqs = [record.seq.tostring() for record in Bio.SeqIO.parse(seq, "fasta")]
print seqs
$ python retrieve_fasta2.py
Introduce pdb code
5HXY
['MGS...PRY',
'MGS...PRY',
'MGS...PRY',
'MGS...PRY',
'MGS...PRY',
'MGS...PRY']
--
https://mail.python.org/mailman/listinfo/python-list
The use of sys.exc_info for catching exceptions
Hi, I've came to a problem where I want to keep backwards and forwards compatibility with an exception syntax. And I mean by backwards going further down to Python 2.5. I was pointed to this option from a stack overflow answer[1] that works forward and backwards, I rewrite the solution here: import sys try: pr.update() except (ConfigurationException,): e = sys.exc_info()[1] returnString = "%s %s" % (e.line, e.errormsg) I understand that there has been a discussion about deprecating sys.exc_info() on [1] and in section "Possible Future Compatible Changes" on [2]. Aside of deprecating this function, what could be other possible issues if I use the solution above? Performance overhead or any known case that could cause problems? [1] - http://stackoverflow.com/a/2513890¬ [2] - https://www.python.org/dev/peps/pep-3110/#open-issues [3] - https://www.python.org/dev/peps/pep-3134/ Thanks! -- Tiago signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Python3 using requests to grab HTTP Auth Data
# Give user the file requested url = "http://superhost.gr/data/files/%s"; % realfile user, password = 'user', 'passwd' r = requests.get( url, auth = (user, password) ) # send auth unconditionally r.raise_for_status() == How can i ASK the user for http auth data and store them isntead of giving them to the script? -- https://mail.python.org/mailman/listinfo/python-list
Call for Volunteers at PythonFOSDEM 2017
# Introduction The Python Community will be represented during FOSDEM 2017 with the Python Devrooms. This year, we will have two devrooms, the first one for 150 people on Saturday and the second one for 450 people on Sunday, it's really cool because we had accepted 24 talks instead of 16. This is the official call for sessions for the [Python devroom](https://www.python-fosdem.org) at [FOSDEM 2017](https://fosdem.org/2017) from **4th** to **5th** February 2017. FOSDEM is the Free and Open source Software Developer's European Meeting, a free and non-commercial two-day week-end that offers open source contributors a place to meet, share ideas and collaborate. It's the biggest event in Europe with +5000 hackers, +400 speakers. For this edition, Python will be represented by its Community. If you want to discuss with a lot of Python Users, it's the place to be! But we have an issue, we need some volunteers because on the week-end, we will only be 4 volunteers. If you think you can help us, please fill this [Google Form](https://goo.gl/forms/IOmGbEgFLVnmUGjO2) Thank you so much for your help Stephane -- Stéphane Wirtel - http://wirtel.be - @matrixise -- https://mail.python.org/mailman/listinfo/python-list
Python doesn't catch exceptions ?
Hi all,
I have a curious problem with Python exceptions.
The following code doesn't catch HttpError:
```
from server.libs.googleapiclient.errors import HttpError
[..]
try:
OAuth.backoffExec(request)
return True
except HttpError as e:
return e.resp.status == 404
except Exception as e:
import inspect
import os
logging.error("caught exception: {}, defined in {}. we are in
{}".format(
e.__class__.__name__,
inspect.getfile(e.__class__),
os.getcwd()
))
logging.error("processed exception: {}, defined in {}.".format(
HttpError.__name__,
inspect.getfile(HttpError)
))
logging.error('e is an HttpError? {}'.format(isinstance(e,
HttpError)))
```
This code generates instead the messages:
```
ERROR 47.135[bigquery.py.create_table:362] caught exception: HttpError,
defined in server/libs/googleapiclient/errors.pyc. we are in
/Users/nilleb/dev/gae-sample-project/app
ERROR 47.135[bigquery.py.create_table:366] processed exception: HttpError,
defined in
/Users/nilleb/dev/gae-sample-project/app/server/libs/googleapiclient/errors.pyc.
ERROR 47.136[bigquery.py.create_table:368] e is an HttpError? False
```
I haven't joined the paths in the messages above, but they are identical if
I do that manually:
```
/Users/nilleb/dev/gae-sample-project/app/server/libs/googleapiclient/errors.pyc
/Users/nilleb/dev/gae-sample-project/app/server/libs/googleapiclient/errors.pyc
```
Any ideas about how to diagnostic what's going wrong?
Thanks in advance,
nilleb
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python doesn't catch exceptions ?
Ivo Bellin Salarin wrote:
> Hi all,
>
> I have a curious problem with Python exceptions.
>
> The following code doesn't catch HttpError:
> ```
> from server.libs.googleapiclient.errors import HttpError
> [..]
> try:
> OAuth.backoffExec(request)
> return True
> except HttpError as e:
> return e.resp.status == 404
> except Exception as e:
> import inspect
> import os
> logging.error("caught exception: {}, defined in {}. we are in
> {}".format(
> e.__class__.__name__,
> inspect.getfile(e.__class__),
> os.getcwd()
> ))
> logging.error("processed exception: {}, defined in {}.".format(
> HttpError.__name__,
> inspect.getfile(HttpError)
> ))
> logging.error('e is an HttpError? {}'.format(isinstance(e,
> HttpError)))
> ```
>
> This code generates instead the messages:
> ```
> ERROR 47.135[bigquery.py.create_table:362] caught exception: HttpError,
> defined in server/libs/googleapiclient/errors.pyc. we are in
> /Users/nilleb/dev/gae-sample-project/app
> ERROR 47.135[bigquery.py.create_table:366] processed exception: HttpError,
> defined in
> /Users/nilleb/dev/gae-sample-
project/app/server/libs/googleapiclient/errors.pyc.
> ERROR 47.136[bigquery.py.create_table:368] e is an HttpError? False
> ```
>
> I haven't joined the paths in the messages above, but they are identical
> if I do that manually:
>
> ```
> /Users/nilleb/dev/gae-sample-
project/app/server/libs/googleapiclient/errors.pyc
> /Users/nilleb/dev/gae-sample-
project/app/server/libs/googleapiclient/errors.pyc
> ```
>
> Any ideas about how to diagnostic what's going wrong?
Make sure your program starts from scratch. There may be a "helpful"
reload() that leaves the server in an inconsistent state. Here's a demo:
$ cat reload_demo.py
import binhex
from binhex import Error
for message in ["first", "second"]:
try:
raise Error(message)
except binhex.Error as err:
print "caught", err
reload(binhex) # this creates a new Error class which will not be caught
$ python reload_demo.py
caught first
Traceback (most recent call last):
File "reload_demo.py", line 6, in
raise Error(message)
binhex.Error: second
--
https://mail.python.org/mailman/listinfo/python-list
How to know what to install (Ubuntu/Debian) for a given import?
I'm often hitting this problem, how does one find out what package to install to provide what a give import needs? Currently I'm modifying some code which has 'import gtk', I want to migrate from Python 2 to Python 3 if I can but at the moment the import fails in Python 3. There are dozens of packages in the Ubuntu repositories which *might* provide what I need I don't want to try them all! So, is there an easy way to find out? ... and while I'm here, can someone tell me what package I need? -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: Python doesn't catch exceptions ?
On Wed, Feb 1, 2017 at 8:11 AM, Ivo Bellin Salarin wrote: > This code generates instead the messages: > ``` > ERROR 47.135[bigquery.py.create_table:362] caught exception: HttpError, > defined in server/libs/googleapiclient/errors.pyc. we are in > /Users/nilleb/dev/gae-sample-project/app > ERROR 47.135[bigquery.py.create_table:366] processed exception: HttpError, > defined in > /Users/nilleb/dev/gae-sample-project/app/server/libs/googleapiclient/errors.pyc. > ERROR 47.136[bigquery.py.create_table:368] e is an HttpError? False > ``` > > I haven't joined the paths in the messages above, but they are identical if > I do that manually: The fact that the paths are two different strings to begin with although you're using the same function to produce them suggests that the module is being imported twice. Make sure that this directory isn't being included more than once in your sys.path. In particular note that Python adds the directory containing the script to the path (or '' if interactive) and since the working directory is a parent directory of the file in question I'd take a close look at that. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to know what to install (Ubuntu/Debian) for a given import?
On Wed, 01 Feb 2017 17:12:26 +, Chris Green wrote:
> I'm often hitting this problem, how does one find out what package to
> install to provide what a give import needs?
>
> Currently I'm modifying some code which has 'import gtk', I want to
> migrate from Python 2 to Python 3 if I can but at the moment the
> import fails in Python 3.
>
> There are dozens of packages in the Ubuntu repositories which *might*
> provide what I need I don't want to try them all! So, is there an
> easy way to find out?
>
> ... and while I'm here, can someone tell me what package I need?
Try this:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
--
GNU/Linux user #557453
The cow died so I don't need your bull!
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python3 using requests to grab HTTP Auth Data
On Wed, 1 Feb 2017 07:10:39 -0800 (PST), Νίκος Βέργος wrote:
> # Give user the file requested
> url = "http://superhost.gr/data/files/%s"; % realfile
>
> user, password = 'user', 'passwd'
>
> r = requests.get( url, auth = (user, password) ) # send auth unconditionally
> r.raise_for_status()
>==
>
> How can i ASK the user for http auth data and store them isntead of
> giving them to the script?
Maybe like this?
user = raw_input("User: ")
password = raw_input("Password: ")
--
To email me, substitute nowhere->runbox, invalid->com.
--
https://mail.python.org/mailman/listinfo/python-list
Re: How to know what to install (Ubuntu/Debian) for a given import?
Wildman wrote:
> On Wed, 01 Feb 2017 17:12:26 +, Chris Green wrote:
>
> > I'm often hitting this problem, how does one find out what package to
> > install to provide what a give import needs?
> >
> > Currently I'm modifying some code which has 'import gtk', I want to
> > migrate from Python 2 to Python 3 if I can but at the moment the
> > import fails in Python 3.
> >
> > There are dozens of packages in the Ubuntu repositories which *might*
> > provide what I need I don't want to try them all! So, is there an
> > easy way to find out?
> >
> > ... and while I'm here, can someone tell me what package I need?
>
> Try this:
>
> import gi
> gi.require_version('Gtk', '3.0')
> from gi.repository import Gtk
>
That works but it's a workaround rather than the proper way to do it
isn't it? ... and doesn't it need an internet connection?
--
Chris Green
·
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python3 using requests to grab HTTP Auth Data
On Thu, Feb 2, 2017 at 2:10 AM, Νίκος Βέργος wrote: > # Give user the file requested > url = "http://superhost.gr/data/files/%s"; % realfile > > user, password = 'user', 'passwd' > > r = requests.get( url, auth = (user, password) ) # send auth unconditionally > r.raise_for_status() > == > > How can i ASK the user for http auth data and store them isntead of giving > them to the script? You should use the input() function (called raw_input() in Python 2) for a user name, and the getpass module for the password: https://docs.python.org/3/library/getpass.html ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Why doesn't module finalization delete names as expected?
I'm developing a C module with the help of SWIG. My library manages objects with reference counting, much like Python, except that it's deterministic: there's no GC. I'm using Python 3.5.2. I create two Python objects like this: bakery = Bakery() bread = bakery.create_bread() Behind the scenes, the situation looks like this: ++ | UserBread obj (Py) | +--^---+-+ | : | : | : +--++-+---V---+ | Bakery obj (lib) <+ Bread obj (lib) | +^---+-++^+ | : | | : | ++---V+ ++---+ | Bakery obj (Py) | | Bread obj (Py) | +-^---+ +--^-+ || || ++ bakerybread A pipe link means one "strong" reference and a colon link means one borrowed/weak reference. I have some ownership inversion magic for the Bakery lib. and Python objects to always coexist. So here it's pretty clear what can happen. I don't know which reference gets deleted first, but let's assume it's `bakery`. Then the situation looks like this: ++ | UserBread obj (Py) | +--^---+-+ | : | : | : +--++-+---V---+ | Bakery obj (lib) <+ Bread obj (lib) | +^---+-++^+ : | | : | | ++---V+ ++---+ | Bakery obj (Py) | | Bread obj (Py) | +-+ +--^-+ | | + bread The Bakery Python object's __del__() drops the reference to its library object, but first its reference count is incremented during this call (so it's not really destroyed) and it's marked as only owned by the library object from now on. When `bread` gets deleted: 1. The Bread Python object's __del__() method gets called: the reference to its library object is dropped. 2. The Bread library object's destroy function drops its reference to the Bakery library object. 3. The Bakery library object's destroy function drops its reference to the Bakery Python object. 4. The Bakery Python object's __del__() method does nothing this time, since the object is marked as only owned by its library object (inverted ownership). 5. The Bread library object's destroy function then drops its reference to the UserBread Python object. In the end, everything is correctly destroyed and released. This also works if `bread` is deleted before `bakery`. My problem is that this works as expected when used like this: def func(): bakery = Bakery() bread = bakery.create_bread() if __name__ == '__main__': func() but NOTHING is destroyed when used like this: bakery = Bakery() bread = bakery.create_bread() That is, directly during the module's initialization. It works, however, if I delete `bread` manually: bakery = Bakery() bread = bakery.create_bread() del bread It also works with `bakery` only: bakery = Bakery() My question is: what could explain this? My guess is that my logic is correct since it works fine in the function call situation. It feels like `bread` is never deleted in the module initialization situation, but I don't know why: the only reference to the Bread Python object is this `bread` name in the module... what could prevent this object's __del__() method to be called? It works when I call `del bread` manually: I would expect that the module finalization does the exact same thing? Am I missing anything? Thanks, Phil -- https://mail.python.org/mailman/listinfo/python-list
Re: How to know what to install (Ubuntu/Debian) for a given import?
On Wed, 01 Feb 2017 19:15:13 +, Chris Green wrote:
> Wildman wrote:
>> On Wed, 01 Feb 2017 17:12:26 +, Chris Green wrote:
>>
>> > I'm often hitting this problem, how does one find out what package to
>> > install to provide what a give import needs?
>> >
>> > Currently I'm modifying some code which has 'import gtk', I want to
>> > migrate from Python 2 to Python 3 if I can but at the moment the
>> > import fails in Python 3.
>> >
>> > There are dozens of packages in the Ubuntu repositories which *might*
>> > provide what I need I don't want to try them all! So, is there an
>> > easy way to find out?
>> >
>> > ... and while I'm here, can someone tell me what package I need?
>>
>> Try this:
>>
>> import gi
>> gi.require_version('Gtk', '3.0')
>> from gi.repository import Gtk
>>
> That works but it's a workaround rather than the proper way to do it
> isn't it?
It is the proper way. This page helps explain it.
http://askubuntu.com/questions/784068/what-is-gi-repository-in-python
> ... and doesn't it need an internet connection?
No.
--
GNU/Linux user #557453
The cow died so I don't need your bull!
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python3 using requests to grab HTTP Auth Data
In Peter Pearson
writes:
> > How can i ASK the user for http auth data and store them isntead of
> > giving them to the script?
> Maybe like this?
> user = raw_input("User: ")
> password = raw_input("Password: ")
If it doesn't need to be interactive, you could require that the user
supply a file in the current directory containing the username and
password.
--
John Gordon A is for Amy, who fell down the stairs
[email protected] B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python3 using requests to grab HTTP Auth Data
Τη Τετάρτη, 1 Φεβρουαρίου 2017 - 9:22:46 μ.μ. UTC+2, ο χρήστης Chris > You should use the input() function (called raw_input() in Python 2) > for a user name, and the getpass module for the password: i have just tried: # Give user the file requested url = "http://superhost.gr/data/files/%s"; % realfile username = getpass.getuser() password = getpass.getpass() r = requests.get( url, auth = (username, password) )# ask user for authentication data r.raise_for_status() -- https://mail.python.org/mailman/listinfo/python-list
Re: Python3 using requests to grab HTTP Auth Data
Τη Τετάρτη, 1 Φεβρουαρίου 2017 - 9:22:46 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: > You should use the input() function (called raw_input() in Python 2) > for a user name, and the getpass module for the password: I have just tried === # Give user the file requested url = "http://superhost.gr/data/files/%s"; % realfile username = getpass.getuser() password = getpass.getpass() r = requests.get( url, auth = (username, password) )# ask user for authentication data r.raise_for_status() === as well as input() for both user & pass combo but iam not getting in chrome the basic pop-up HTTP auth window. Any idea why? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python3 using requests to grab HTTP Auth Data
On 02/01/2017 01:51 PM, Νίκος Βέργος wrote: > as well as input() for both user & pass combo but iam not getting in chrome > the basic pop-up HTTP auth window. > > Any idea why? What you're describing is not something you can do with an interactive Python script. HTTP-level authentication is requested of your browser by the web server itself. On Apache there are numerous methods you can use. Individual users can use .htaccess directives to add authentication to a directory, for example. You'll need to learn about it: https://www.google.com/search?q=apache+http+authentication If you're using a framework like Django, there are mechanisms for checking the username and password against a Python method. Again, google for http authentication and whatever framework you're using. I once used a special python script that was called by an Apache module to verify users against a customized LDAP filter. Again, that involves server cooperation though a module. In general, the browser pops up the username and password box in response to a request from the web server. It's not something your CGI script can just do without some cooperation from the web server. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to know what to install (Ubuntu/Debian) for a given import?
On 02/01/2017 01:03 PM, Wildman via Python-list wrote: > > It is the proper way. This page helps explain it. > > http://askubuntu.com/questions/784068/what-is-gi-repository-in-python > >> ... and doesn't it need an internet connection? > > No. However the gi module provides access to GTK+3, and it's quite likely Chris's project requires GTK+2, and would probably take some work to port from GTK+2 to GTK+3, though in the long run it's worth the effort. Anyway the GTK+2 module for python is usually called pygtk in the repos. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python3 using requests to grab HTTP Auth Data
Τη Τετάρτη, 1 Φεβρουαρίου 2017 - 11:41:28 μ.μ. UTC+2, ο χρήστης Michael Torrie έγραψε: > On 02/01/2017 01:51 PM, Νίκος Βέργος wrote: > > as well as input() for both user & pass combo but iam not getting in chrome > > the basic pop-up HTTP auth window. > > > > Any idea why? > > What you're describing is not something you can do with an interactive > Python script. HTTP-level authentication is requested of your browser > by the web server itself. On Apache there are numerous methods you can > use. Individual users can use .htaccess directives to add > authentication to a directory, for example. You'll need to learn about it: > https://www.google.com/search?q=apache+http+authentication > > If you're using a framework like Django, there are mechanisms for > checking the username and password against a Python method. Again, > google for http authentication and whatever framework you're using. > > I once used a special python script that was called by an Apache module > to verify users against a customized LDAP filter. Again, that involves > server cooperation though a module. > > In general, the browser pops up the username and password box in > response to a request from the web server. It's not something your CGI > script can just do without some cooperation from the web server. I used to have this workaround solution for triggering the web server to pop-up the HTTP Auth window print '''http://superhost.gr/data/files/%s";>''' % file_requested and i have tried to read the the login auth name that user entered by using authuser = os.environ.get( 'REMOTE_USER', 'Άγνωστος' ) unfortunately it always failes to receive it that's why i'm trying to do the trick with the requests module. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to know what to install (Ubuntu/Debian) for a given import?
Wildman wrote:
> On Wed, 01 Feb 2017 19:15:13 +, Chris Green wrote:
>
> > Wildman wrote:
> >> On Wed, 01 Feb 2017 17:12:26 +, Chris Green wrote:
> >>
> >> > I'm often hitting this problem, how does one find out what package to
> >> > install to provide what a give import needs?
> >> >
> >> > Currently I'm modifying some code which has 'import gtk', I want to
> >> > migrate from Python 2 to Python 3 if I can but at the moment the
> >> > import fails in Python 3.
> >> >
> >> > There are dozens of packages in the Ubuntu repositories which *might*
> >> > provide what I need I don't want to try them all! So, is there an
> >> > easy way to find out?
> >> >
> >> > ... and while I'm here, can someone tell me what package I need?
> >>
> >> Try this:
> >>
> >> import gi
> >> gi.require_version('Gtk', '3.0')
> >> from gi.repository import Gtk
> >>
> > That works but it's a workaround rather than the proper way to do it
> > isn't it?
>
> It is the proper way. This page helps explain it.
>
> http://askubuntu.com/questions/784068/what-is-gi-repository-in-python
>
OK, thank you, what a strange way to do it.
> > ... and doesn't it need an internet connection?
>
> No.
>
OK, no problem, but isn't it very non-portable?
--
Chris Green
·
--
https://mail.python.org/mailman/listinfo/python-list
Re: How to know what to install (Ubuntu/Debian) for a given import?
On Wed, 01 Feb 2017 21:29:00 +, Chris Green wrote:
> Wildman wrote:
>> On Wed, 01 Feb 2017 19:15:13 +, Chris Green wrote:
>>
>> > Wildman wrote:
>> >> On Wed, 01 Feb 2017 17:12:26 +, Chris Green wrote:
>> >>
>> >> > I'm often hitting this problem, how does one find out what package to
>> >> > install to provide what a give import needs?
>> >> >
>> >> > Currently I'm modifying some code which has 'import gtk', I want to
>> >> > migrate from Python 2 to Python 3 if I can but at the moment the
>> >> > import fails in Python 3.
>> >> >
>> >> > There are dozens of packages in the Ubuntu repositories which *might*
>> >> > provide what I need I don't want to try them all! So, is there an
>> >> > easy way to find out?
>> >> >
>> >> > ... and while I'm here, can someone tell me what package I need?
>> >>
>> >> Try this:
>> >>
>> >> import gi
>> >> gi.require_version('Gtk', '3.0')
>> >> from gi.repository import Gtk
>> >>
>> > That works but it's a workaround rather than the proper way to do it
>> > isn't it?
>>
>> It is the proper way. This page helps explain it.
>>
>> http://askubuntu.com/questions/784068/what-is-gi-repository-in-python
>>
> OK, thank you, what a strange way to do it.
I am sure there is a reason and I believe it has
something to do with the fact that GTK3 is a recent
addition. Things might change in the future.
>> > ... and doesn't it need an internet connection?
>>
>> No.
>>
> OK, no problem, but isn't it very non-portable?
I don't see why not. It should work on any system
that has Python3 installed, at least that is my
understanding. I'm sure someone will correct me
if I'm wrong.
OTOH if you want in insure 100% portability with any
script, you can use pyinstaller.
To install for Python2:
pip install pyinstaller
For Python3:
pip3 install pyinstaller
http://www.pyinstaller.org/
--
GNU/Linux user #557453
The cow died so I don't need your bull!
--
https://mail.python.org/mailman/listinfo/python-list
Re: How coding in Python is bad for you
On 30/01/17 02:14, Steve D'Aprano wrote:
On Mon, 30 Jan 2017 10:52 am, Erik wrote:
It would be even better if it was "else if not break:" to make the
meaning clearer.
break is not the only way to exit the for loop
Fine - "else if not break or raise or return:", then ;) [that is not a
serious suggestion]
You're conflating two types of exit though. One is a way of exiting the
innermost loop construct and nothing more. The others are ways of
exiting a separate, outer construct (be that a try block or a
function/method).
I'm specifically talking about the interaction between 'break' and
'else'. The other things are at a different level.
I would agree that it would be even better than that if
it was "then if not break:" (apart from needing the new keyword ;)), as
then the conditional aspect is explicit.
But it isn't conditional.
Yes it is. When one reads the code, the statements in the "else:" (or
your theoretical "then:") block will be executed only if a "break" was
not executed in the loop statements the "then:" is associated with. How
is that NOT conditional?
Your syntax implies that the interpreter keeps
some sort of flag did_we_reach_the_end_of_the_loop_without_break or
something, and then it checks the state of that flag. There is no such
flag.
You are correct and I never said there was - you're now arguing against
a point that you have made and I didn't!
I have written more than my fair share of assembly code in the past and
can identify the "for/while" vs "else" construct as a loop with two exit
targets that are jumped to unconditionally. In fact, that was one of the
"oh, nice!" moments when I first learned Python - I'd never seen a high
level language do that before (even C doesn't have it!).
All I have said is that the *spelling* of "else:" could be "else if not
break:" or - because you mentioned it and I think it actually reads
better - "then if not break:".
They hoped to use the same flag the for-loop used.
Well, _logically_ there is a flag (in as much as it could be thought of
like that to make it easy to understand - and in C, that's pretty much
what you have to actually do unless you really want to use 'goto').
Not a single condition to be seen, anywhere. Its all unconditional jumps.
To anticipate a possible objection: it is possible that the FOR_ITER
bytecode is implemented with a conditional test, but even so, all that
tests for is whether to enter the main body of the for-loop (10
STORE_NAME ...) or jump to (18 LOAD_NAME ...).
Again, you're arguing against something I didn't say. I never suggested
"if not break" (whether following "else" or "then") should generate code
that dynamically tests some sort of flag. It's just a different way of
spelling exactly the same construct we have today, generating exactly
the same bytecode.
I can see what you're trying to say, but a naked "then:" really doesn't
do it for me.
while 1:
break
then:
print ("Yes!")
while 1:
break
then if not break:
print ("Yes!")
It would be interesting to know what novices thought those meant. Maybe
"if not break:" is not the answer either. I just don't think "then:" is ;)
E.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python3 using requests to grab HTTP Auth Data
On Wed, Feb 1, 2017 at 2:51 PM, Νίκος Βέργος wrote: > Τη Τετάρτη, 1 Φεβρουαρίου 2017 - 11:41:28 μ.μ. UTC+2, ο χρήστης Michael > Torrie έγραψε: >> On 02/01/2017 01:51 PM, Νίκος Βέργος wrote: >> > as well as input() for both user & pass combo but iam not getting in >> > chrome the basic pop-up HTTP auth window. >> > >> > Any idea why? >> >> What you're describing is not something you can do with an interactive >> Python script. HTTP-level authentication is requested of your browser >> by the web server itself. On Apache there are numerous methods you can >> use. Individual users can use .htaccess directives to add >> authentication to a directory, for example. You'll need to learn about it: >> https://www.google.com/search?q=apache+http+authentication >> >> If you're using a framework like Django, there are mechanisms for >> checking the username and password against a Python method. Again, >> google for http authentication and whatever framework you're using. >> >> I once used a special python script that was called by an Apache module >> to verify users against a customized LDAP filter. Again, that involves >> server cooperation though a module. >> >> In general, the browser pops up the username and password box in >> response to a request from the web server. It's not something your CGI >> script can just do without some cooperation from the web server. > > I used to have this workaround solution for triggering the web server to > pop-up the HTTP Auth window > > print ''' content="2;url=http://superhost.gr/data/files/%s";>''' % file_requested > > and i have tried to read the the login auth name that user entered by using > > authuser = os.environ.get( 'REMOTE_USER', 'Άγνωστος' ) > > unfortunately it always failes to receive it that's why i'm trying to do the > trick with the requests module. Fails how? It doesn't ask the user, or the environment variable is empty? requests is an HTTP client library. It's not very useful server-side unless you're talking to other servers. It is, in any case, nonsensical to send an HTTP request to the browser. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python3 using requests to grab HTTP Auth Data
Τη Πέμπτη, 2 Φεβρουαρίου 2017 - 1:51:52 π.μ. UTC+2, ο χρήστης Ian έγραψε: > On Wed, Feb 1, 2017 at 2:51 PM, Νίκος Βέργος wrote: > > Τη Τετάρτη, 1 Φεβρουαρίου 2017 - 11:41:28 μ.μ. UTC+2, ο χρήστης Michael > > Torrie έγραψε: > >> On 02/01/2017 01:51 PM, Νίκος Βέργος wrote: > >> > as well as input() for both user & pass combo but iam not getting in > >> > chrome the basic pop-up HTTP auth window. > >> > > >> > Any idea why? > >> > >> What you're describing is not something you can do with an interactive > >> Python script. HTTP-level authentication is requested of your browser > >> by the web server itself. On Apache there are numerous methods you can > >> use. Individual users can use .htaccess directives to add > >> authentication to a directory, for example. You'll need to learn about it: > >> https://www.google.com/search?q=apache+http+authentication > >> > >> If you're using a framework like Django, there are mechanisms for > >> checking the username and password against a Python method. Again, > >> google for http authentication and whatever framework you're using. > >> > >> I once used a special python script that was called by an Apache module > >> to verify users against a customized LDAP filter. Again, that involves > >> server cooperation though a module. > >> > >> In general, the browser pops up the username and password box in > >> response to a request from the web server. It's not something your CGI > >> script can just do without some cooperation from the web server. > > > > I used to have this workaround solution for triggering the web server to > > pop-up the HTTP Auth window > > > > print ''' > content="2;url=http://superhost.gr/data/files/%s";>''' % file_requested > > > > and i have tried to read the the login auth name that user entered by using > > > > authuser = os.environ.get( 'REMOTE_USER', 'Άγνωστος' ) > > > > unfortunately it always failes to receive it that's why i'm trying to do > > the trick with the requests module. > > Fails how? It doesn't ask the user, or the environment variable is empty? > > requests is an HTTP client library. It's not very useful server-side > unless you're talking to other servers. It is, in any case, > nonsensical to send an HTTP request to the browser. triggers the http auth windows, so the user can enter the auth info, i just cant seem to grab the auth username back. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to know what to install (Ubuntu/Debian) for a given import?
On 01/02/17 23:20, Wildman via Python-list wrote: On Wed, 01 Feb 2017 21:29:00 +, Chris Green wrote: Wildman wrote: On Wed, 01 Feb 2017 19:15:13 +, Chris Green wrote: OK, no problem, but isn't it very non-portable? I don't see why not. It should work on any system that has Python3 installed, at least that is my understanding. I'm sure someone will correct me if I'm wrong. OTOH if you want in insure 100% portability with any script, you can use pyinstaller. To install for Python2: pip install pyinstaller For Python3: pip3 install pyinstaller Out of interest (as someone who grew up on the great 1.5.7 ;)) - is there a definitive resource that explains all of the various packaging and installation options that exist for Python modules these days (both for an author and a user)? A lot of Linux distributions have Python-related packages (other than the language itself) which can be installed using the system installer. Then there's "pip", which is an installer which is installed using the system installer. Now, apparently, there's "pyinstaller" which can be installed using the "pip" installer! I'd like to understand the differences and how this all fits together. Thanks, E. -- https://mail.python.org/mailman/listinfo/python-list
Re: Rename file without overwriting existing files
On Tue, 31 Jan 2017 02:56 am, Grant Edwards wrote: > On 2017-01-30, Terry Reedy wrote: >> On 1/30/2017 8:58 AM, Peter Otten wrote: >>> Jussi Piitulainen wrote: >> It doesn't seem to be documented. >>> >>> For functions with a C equivalent a look into the man page is usually >>> helpful. >> >> Man pages do not exist on Windows. I suspect that there are more >> individual Python programs on Windows than *nix. I am more sure of this >> as applied to beginners, most of whom have no idea what a 'man' page is >> (sexist docs? ;-). > > IMO, beginners shouldn't be using the os module. Do you mean beginners to Python or beginners to programming, or both? [...] > I always found the first sentence to be a bit funny: > > This module provides a portable way of using operating system > dependent functionality. > > I understand whay they're tying to say, but I always found it amusing > to say you're going to provide a portable way to do something > non-portable. Fortunately, as Python has matured as a language, it has moved away from that simplistic "dumb interface to OS specific functions". For example, os.urandom: - calls the getrandom() syscall if available; - fall back on /dev/urandom if not; - calls CryptGenRandom() on Windows; - and getentropy() on BSD. https://docs.python.org/3.6/library/os.html#os.urandom Similarly, quite a few os functions either come in a pair of flavours, one returning a string, the other returning bytes, or they take either a byte argument or a string argument. Some even accept pathlib path objects. Python is a high-level, platform-independent language, and the more platform-independent wrappers around platform-dependent functions, the better. -- 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: Python3 using requests to grab HTTP Auth Data
# Give user the file requested
print('''http://superhost.gr/data/files/%s";>''' % realfile)
authuser = os.environ.get( 'REMOTE_USER', 'Άγνωστος' )
print( authuser )
Trying this, feels liek i'm almost there except that when printing the value of
authuser variable it default to "Άγνωστος" meaning not there.
is there any other way i can grab what the user gave a auth login info?
--
https://mail.python.org/mailman/listinfo/python-list
Re: Is shutil.get_terminal_size useless?
On Sun, 29 Jan 2017 04:58 am, Chris Angelico wrote: > On Sun, Jan 29, 2017 at 3:15 AM, Steve D'Aprano > wrote: >> On Sat, 28 Jan 2017 10:50 pm, Chris Angelico wrote: >> >>> On Sat, Jan 28, 2017 at 9:49 PM, Steve D'Aprano >>> wrote: The terminal size doesn't change just because I'm piping output to another process. Using the terminal size as a proxy for "being piped" is sheer insanity. >>> >>> In a sense, there _is no_ terminal size when you're being piped to >>> another process. >> >> In which sense, and why do you think it is relevant? >> >> There clearly is a terminal, because that's where I'm running the code. >> Regardless of whether I pipe it to grep or cat or something else, the >> output from *that* process still ends up in the same terminal that I >> typed the command in. > > No, not automatically. I've written plenty of programs that accept > input via a pipe and don't display any of it. Well of course if your program doesn't produce any output, the output doesn't go to stdout. Because there is none. > Just because someone > types "command1 | command2", you can't assume that the terminal > command2 is outputting to is the same size as the one command1 should > be outputting to. I'm not assuming anything of the sort. Obviously command2 can send output where it likes, including /dev/null, or simply not produce any output. And as I've *repeatedly* acknowledged, there are circumstances where there is no terminal at all. And shutil does the wrong thing then too: it returns an arbitrary size, instead of raising. (Of course we should be able to explicitly pass a default to shutil.get_terminal_size() if we wish.) > >>> etc, etc, etc, etc. It's >>> not a proxy for "being piped" - it's that when your output isn't going >>> to a terminal, asking "what is my terminal size" isn't particularly >>> productive. >> >> Then explain why os.get_terminal_size() returns the correct answer. No answer Chris? You've spent a lot of time telling me that asking for the terminal size doesn't even make sense for the exact circumstances where os.get_terminal_size() not only returns a size, but the *correct* size. And, of course, it also correctly raises an exception in those unusual cases where there truly is no terminal, or it is unknowable. >> The output might not be going to a terminal (not directly at least) but >> the question isn't "what's the size of the terminal that output is going >> to". The question is "what's the size of the terminal that this process >> is running in", and that has an answer regardless of where output is >> piped. > > Processes aren't always running "in" terminals, though. That's my > point. A terminal is not a fundamental feature of a process. And I have acknowledged this, oh, about a million times. But when the processes *are* running in terminals, shutil should return the size of the terminal, not some arbitrary made up size. Otherwise it is useless. >>> Would you expect a cronjob to use the terminal size when you >>> most recently edited crontab? No. >> >> Of course not -- the terminal where you edited crontab is not where the >> process is running. Why would it be the least bit relevant? > > So where *is* that process running? What terminal is it in? There isn't one. > Don't you > see how similar this is to the pipe situation No. os.get_terminal_size() is correctly able to return the terminal size in the pipe situation, even in a *double* pipe situation (you need to look at stderr rather than stdin or stout). I'm not sure if it is able to cope with situations where all three of std[in|out|err] are redirected, but that's okay. I'm a realist: if there are scenarios where the terminal size is unknowable, then so be it. But a simple pipe is not one of those cases. > - sure, there might be a > terminal that the program was invoked from, but it's utterly > irrelevant to how the program actually runs. Except that in the pipe situation, "how the program actually runs" *is* in a terminal. > >> You might well be a completely background process. >> >> And if that background process is running in a terminal? What's your >> point? > > Background processes don't have terminal access. Really? I think you are wrong: [steve@ando ~]$ cat bkg.py from os import get_terminal_size print(get_terminal_size(0)) [steve@ando ~]$ python3.5 bkg.py & [1] 13776 [steve@ando ~]$ os.terminal_size(columns=116, lines=29) [1]+ Donepython3.5 bkg.py [steve@ando ~]$ Looks like the background process is perfectly able to return the terminal size, and not an arbitrary number either, it has the correct size. > Whether it's a daemon > or something started as "commandname >/dev/null 2>/dev/null &" from bash, it doesn't have access to a terminal. As I've repeatedly said, if there are situations where the terminal size is genuinely unknowable, then so be it. But shutil fails even when the terminal size *is* knowable. How is this useful? > Please don't
Re: How to know what to install (Ubuntu/Debian) for a given import?
On 02/01/2017 02:29 PM, Chris Green wrote: > OK, thank you, what a strange way to do it. Why is it strange? Essentially, python bindings for any GObject-based library are now fully automatic via this gi module. No longer do we need custom bindings for each component of a glib-based library. This means even your own custom libraries, if they use gobject, can be bound dynamically to Python with no work on your part. So lots of gnome libraries are accessible this way, as well as GTK3. This does come at a cost though: since the bindings are dynamic and based on gobject types, they aren't quite as pythonic as PyGTK used to be. AT least that's what I've been told. Some of the GObject stuff leaks into the python side of things, whereas PyGTK would custom wrap them and try to wrap some types in more familiar Python versions. > OK, no problem, but isn't it very non-portable? Not inherently, no. Should work on OS X and Windows. -- https://mail.python.org/mailman/listinfo/python-list
Re: Is shutil.get_terminal_size useless?
On Sat, 28 Jan 2017 11:53 pm, Peter Otten wrote: [...] >> I see that as "Hey look, we can fool shutil into returning >> absolute garbage instead of the terminal size!" > > There are valid reasons for temporarily altering the number of columns, > like writing to a file or preparing a code sample. Hmmm... I hadn't thought of that. You're right that there are scenarios where you might wish to tell a process to use a different number of columns (or even lines). Good point. I'm not sure that the given API is a good one, but I accept that the COLUMNS + LINES environment variables could be used to override the actual terminal size. -- 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: Is shutil.get_terminal_size useless?
On Thu, Feb 2, 2017 at 12:24 PM, Steve D'Aprano wrote: etc, etc, etc, etc. It's not a proxy for "being piped" - it's that when your output isn't going to a terminal, asking "what is my terminal size" isn't particularly productive. >>> >>> Then explain why os.get_terminal_size() returns the correct answer. > > No answer Chris? > > You've spent a lot of time telling me that asking for the terminal size > doesn't even make sense for the exact circumstances where > os.get_terminal_size() not only returns a size, but the *correct* size. > Because you've already decided in your own mind that one answer is THE correct one, and nothing I say will possibly change that. In my very first post on this subject, I pointed out that shutil and os were returning *different* answers, *both* of which are useful. You persist in insisting that only one of them is useful and correct, and so there's no point responding. Let me redirect this discussion slightly. How do you calculate the square root of a number? >>> (-1) ** 0.5 (6.123233995736766e-17+1j) >>> math.sqrt(-1) Traceback (most recent call last): File "", line 1, in ValueError: math domain error >>> cmath.sqrt(-1) 1j Why does only one of these give the correct answer? If you absolutely INSIST that one is correct, how can anyone argue as to why the others exist? Or is it possible that there are times when you want ValueError and times when you want a complex result? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How coding in Python is bad for you
On Thu, Feb 2, 2017 at 10:49 AM, Erik wrote: > Well, _logically_ there is a flag (in as much as it could be thought of like > that to make it easy to understand - and in C, that's pretty much what you > have to actually do unless you really want to use 'goto'). The last time I wanted a for-else in C, I used a goto. And no velociraptor came and ate me. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How coding in Python is bad for you
On 2017-02-01 23:49, Erik wrote: On 30/01/17 02:14, Steve D'Aprano wrote: On Mon, 30 Jan 2017 10:52 am, Erik wrote: It would be even better if it was "else if not break:" to make the meaning clearer. break is not the only way to exit the for loop Fine - "else if not break or raise or return:", then ;) [that is not a serious suggestion] [snip] Both suggestions are a little long-winded. Couldn't we just abbreviate them to "else:"? :-) -- https://mail.python.org/mailman/listinfo/python-list
Re: How coding in Python is bad for you
On 02/02/17 02:05, MRAB wrote: Both suggestions are a little long-winded. Couldn't we just abbreviate them to "else:"? :-) You are not wrong ;) E. -- https://mail.python.org/mailman/listinfo/python-list
Re: How coding in Python is bad for you
On 02/02/17 01:41, Chris Angelico wrote: On Thu, Feb 2, 2017 at 10:49 AM, Erik wrote: Well, _logically_ there is a flag (in as much as it could be thought of like that to make it easy to understand - and in C, that's pretty much what you have to actually do unless you really want to use 'goto'). The last time I wanted a for-else in C, I used a goto. And no velociraptor came and ate me. Thanks for your input. E. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to know what to install (Ubuntu/Debian) for a given import?
On Thursday, February 2, 2017 at 5:44:51 AM UTC+5:30, Erik wrote: > On 01/02/17 23:20, Wildman via Python-list wrote: > > On Wed, 01 Feb 2017 21:29:00 +, Chris Green wrote: > > > >> Wildman wrote: > >>> On Wed, 01 Feb 2017 19:15:13 +, Chris Green wrote: > >> OK, no problem, but isn't it very non-portable? > > > > I don't see why not. It should work on any system > > that has Python3 installed, at least that is my > > understanding. I'm sure someone will correct me > > if I'm wrong. > > > > OTOH if you want in insure 100% portability with any > > script, you can use pyinstaller. > > > > To install for Python2: > > pip install pyinstaller > > > > For Python3: > > > > pip3 install pyinstaller > > Out of interest (as someone who grew up on the great 1.5.7 ;)) - is > there a definitive resource that explains all of the various packaging > and installation options that exist for Python modules these days (both > for an author and a user)? > > A lot of Linux distributions have Python-related packages (other than > the language itself) which can be installed using the system installer. > > Then there's "pip", which is an installer which is installed using the > system installer. > > Now, apparently, there's "pyinstaller" which can be installed using the > "pip" installer! > > I'd like to understand the differences and how this all fits together. +10 From me for this question My impression is that this question is signally badly addressed because it falls between OS-language stools: ie in the larger Linux-Python ecosystem some things are naturally addressed as Linux docs, some as python docs. This (and such issues) seems to be a buck that loves to be passed around -- https://mail.python.org/mailman/listinfo/python-list
