Re: base64.b64encode(data)

2016-06-12 Thread Marko Rauhamaa
Random832 : > base64 characters are *characters*, not *bytes* Ok, I ran into the same surprise just two days ago. But is this a big deal? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: base64.b64encode(data)

2016-06-12 Thread Random832
On Mon, Jun 13, 2016, at 01:16, Steven D'Aprano wrote: > Suppose instead it returned the Unicode string 'AUERFg=='. That's all > well and good, but what are you going to do with it? You can't > transmit it over a serial cable, because that almost surely is going > to expect bytes, so you have to en

Re: base64.b64encode(data)

2016-06-12 Thread Steven D'Aprano
On Mon, 13 Jun 2016 01:20 pm, Random832 wrote: > On Sun, Jun 12, 2016, at 22:22, Steven D'Aprano wrote: >> That's because base64 is a bytes-to-bytes transformation. It has >> nothing to do with unicode encodings. > > Nonsense. base64 is a binary-to-text encoding scheme. The output range > is spec

Re: how to search item in list of list

2016-06-12 Thread Jussi Piitulainen
meInvent bbird writes: > once a nested list have a word "node" then true else false > > def search(current_item): > if isinstance(current_item, list): > if len(current_item)==4: > if [item for item in current_item if item[4] == "node"] != []: > return True

Overriding methods inherited from a superclass with methods from a mixin

2016-06-12 Thread alanqueiros
Hello there. I'm trying to override methods inherited from a superclass by methods defined in a mixin class. Here's an sscce: https://bpaste.net/show/6c7d8d590658 (never expires) I've had problems finding the proper way to do that, since at first the base class wasn't to the right and I've assu

Re: for / while else doesn't make sense

2016-06-12 Thread Rustom Mody
On Monday, June 13, 2016 at 7:42:25 AM UTC+5:30, Steven D'Aprano wrote: > On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: > > > On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano wrote: > > > >> - run the for block > >> - THEN unconditionally run the "else" block > >> > > > > Saying "unconditio

[RELEASE] Python 2.7.12 release candidate 1

2016-06-12 Thread Benjamin Peterson
Python 2.7.12 release candidate 1 is now available for download. This is a preview release of the next bugfix release in the Python 2.7.x series. Assuming no horrible regressions are located, a final release will follow in two weeks. Downloads for 2.7.12rc1 can be found python.org: https://www

how to search item in list of list

2016-06-12 Thread meInvent bbird
once a nested list have a word "node" then true else false def search(current_item): if isinstance(current_item, list): if len(current_item)==4: if [item for item in current_item if item[4] == "node"] != []: return True if True in [search(item) for

Re: base64.b64encode(data)

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 22:22, Steven D'Aprano wrote: > That's because base64 is a bytes-to-bytes transformation. It has > nothing to do with unicode encodings. Nonsense. base64 is a binary-to-text encoding scheme. The output range is specifically chosen to be safe to transmit in text protocols.

[RELEASED] Python 3.4.5rc1 and Python 3.5.2rc1 are now available

2016-06-12 Thread Larry Hastings
On behalf of the Python development community and the Python 3.4 and Python 3.5 release teams, I'm pleased to announce the availability of Python 3.4.5rc1 and Python 3.5.2rc1. Python 3.4 is now in "security fixes only" mode. This is the final stage of support for Python 3.4. All changes ma

Re: base64.b64encode(data)

2016-06-12 Thread Steven D'Aprano
On Mon, 13 Jun 2016 04:56 am, Marcin Rak wrote: > Hi to everyone. > > Let's say I have some binary data, be it whatever, in the 'data' variable. > After calling the following line > > b64_encoded_data = base64.b64encode(data) > > my b64_encoded_data variables holds, would you believe it, a str

Re: for / while else doesn't make sense

2016-06-12 Thread Steven D'Aprano
On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: > On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < > steve+comp.lang.pyt...@pearwood.info> wrote: > >> - run the for block >> - THEN unconditionally run the "else" block >> > > Saying "unconditionally" is a bit misleading here. As you say, it's

yatel install error

2016-06-12 Thread meInvent bbird
sudo apt-get install python-dev libatlas-base-dev gfortran pip install yatel Cleaning up... Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_martin/yatel/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exe

how to use yatel with redis?

2016-06-12 Thread meInvent bbird
my code is https://gist.github.com/hoyeunglee/58df4c41a63a2f37e153cbdbc03c16bf would like to apply itertools.combinations to use redis to use hard disk as memory rather than using ram(real memory) as memory def edge_gen(self): # we combine haplotypes by two for hap0, hap1 in itertools.

Re: loading trees...

2016-06-12 Thread Michael Selik
On Sun, Jun 12, 2016 at 3:01 PM Fillmore wrote: > What's my best way to achieve this? > What are your criteria for "best"? > The idea is that I'll receive a bit of data, determine which tree is > suitable for handling it, and dispatch the data to the right tree for > further processing. > How

Re: Indentation example?

2016-06-12 Thread Marc Dietz
On Sun, 12 Jun 2016 08:10:27 -0700 ICT Ezy wrote: > Pl explain with an example the following phase "Indentation cannot be > split over multiple physical lines using backslashes; the whitespace up > to the first backslash determines the indentation" (in 2.1.8. > Indentation of Tutorial.) > I want t

Re: the global keyword:

2016-06-12 Thread BartC
On 12/06/2016 20:25, Ned Batchelder wrote: On Sunday, June 12, 2016 at 3:08:01 PM UTC-4, BartC wrote: On 12/06/2016 00:44, Marcin Rak wrote: from Test import some_function, my_print from Test import test_var some_function() my_print() print(test_var) *

Re: base64.b64encode(data)

2016-06-12 Thread Marko Rauhamaa
Marcin Rak : > b64_encoded_data = base64.b64encode(data) > > my b64_encoded_data variables holds, would you believe it, a string as > bytes!. It doesn't much matter one way or another. The logic is that whenever you encode objects, you typically want the output as bytes. However, it's trivial to

Re: the global keyword:

2016-06-12 Thread Ned Batchelder
On Sunday, June 12, 2016 at 3:08:01 PM UTC-4, BartC wrote: > On 12/06/2016 00:44, Marcin Rak wrote: > > Hi to all. > > > > I have the following file named Solver.py: > > * > > from Test import some_function, my_print > > from Test import test_var > > > > some

Re: how to handle surrogate encoding: read from fs write to database

2016-06-12 Thread Marko Rauhamaa
Random832 : > On Sun, Jun 12, 2016, at 12:50, Steven D'Aprano wrote: >> I think Windows also gets it almost write: NTFS uses UTF-16, and (I >> think) only allow valid Unicode file names. > > Nope. Windows allows any sequence of 16-bit units (except for a dozen or > so ASCII characters) in filename

Re: the global keyword:

2016-06-12 Thread BartC
On 12/06/2016 00:44, Marcin Rak wrote: Hi to all. I have the following file named Solver.py: * from Test import some_function, my_print from Test import test_var some_function() my_print() print(test_var) * and I h

Re: for / while else doesn't make sense

2016-06-12 Thread Michael Selik
On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > - run the for block > - THEN unconditionally run the "else" block > Saying "unconditionally" is a bit misleading here. As you say, it's conditioned on completing the loop without break/return/raise. -

base64.b64encode(data)

2016-06-12 Thread Marcin Rak
Hi to everyone. Let's say I have some binary data, be it whatever, in the 'data' variable. After calling the following line b64_encoded_data = base64.b64encode(data) my b64_encoded_data variables holds, would you believe it, a string as bytes!. That is, the b64_encoded_data variable is of type

loading trees...

2016-06-12 Thread Fillmore
Hi, problem for today. I have a batch file that creates "trees of data". I can save these trees in the form of python code or serialize them with something like pickle. I then need to run a program that loads the whole forest in the form of a dict() where each item will point to a dynamically l

Re: the global keyword:

2016-06-12 Thread Random832
On Sat, Jun 11, 2016, at 23:15, Lawrence D’Oliveiro wrote: > On Sunday, June 12, 2016 at 11:51:11 AM UTC+12, Random832 wrote: > > Importing a variable from a module copies its value into your own > > module's variable. > > Every name in Python is a variable, and can be assigned to to change its >

Re: the global keyword:

2016-06-12 Thread Random832
On Sat, Jun 11, 2016, at 23:15, Lawrence D’Oliveiro wrote: > On Sunday, June 12, 2016 at 11:51:11 AM UTC+12, Random832 wrote: > > Importing a variable from a module copies its value into your own > > module's variable. > > Every name in Python is a variable, and can be assigned to to change its >

Re: the global keyword:

2016-06-12 Thread Marcin Rak
Much thanks to all for their time, but Ned in particular...I learned something new about Python!! On Saturday, 11 June 2016 22:48:32 UTC-5, Ned Batchelder wrote: > On Saturday, June 11, 2016 at 11:38:33 PM UTC-4, Steven D'Aprano wrote: > > On Sun, 12 Jun 2016 11:26 am, Random832 wrote: > > > >

Re: is there a big in python 3.5.1 shell?

2016-06-12 Thread Joel Goldstick
On Sun, Jun 12, 2016 at 11:39 AM, Listo Amugongo wrote: > In my attarchment above is a screenshot of my session. > Screenshot describtion: > In my first elif function (first code block) I deliberately programmed an > indention error.i did it purposely to make my point clear and the point is > P

Re: Altering sys.argv on startup in Python 2

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 13:51, Random832 wrote: > if edit_done: > return this should of course be raise ImportError - an artifact of some refactoring I did on the example. -- https://mail.python.org/mailman/listinfo/python-list

Re: Altering sys.argv on startup in Python 2

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 13:51, Random832 wrote: > if edit_done: > return this should of course be raise ImportError - an artifact of some refactoring I did on the example. -- https://mail.python.org/mailman/listinfo/python-list

Re: how to handle surrogate encoding: read from fs write to database

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 12:50, Steven D'Aprano wrote: > I think Windows also gets it almost write: NTFS uses UTF-16, and (I > think) only allow valid Unicode file names. Nope. Windows allows any sequence of 16-bit units (except for a dozen or so ASCII characters) in filenames. Of course, you're

Re: Altering sys.argv on startup in Python 2

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 08:56, Adam Bartoš wrote: > Hello, > > I'm trying to employ code like > https://code.activestate.com/recipes/572200/ > at Python 2 startup. The problem is that sys.argv isn't polulated yet > when > sitecustomize is executed. Is there any way around? I was thinking about >

is there a big in python 3.5.1 shell?

2016-06-12 Thread Listo Amugongo
In my attarchment above is a screenshot of my session. Screenshot describtion: In my first elif function (first code block) I deliberately programmed an indention error.i did it purposely to make my point clear and the point is Python 3.5.1 shell* gives a synatax error after I run the elif funct

Re: how to handle surrogate encoding: read from fs write to database

2016-06-12 Thread Steven D'Aprano
On Sun, 12 Jun 2016 10:09 pm, Peter Volkov wrote: > Hi, everybody. > > What is a best practice to deal with filenames in python3? The problem is > that os.walk(src_dir), os.listdir(src_dir), ... return "surrogate" strings > as filenames. Can you give an example? > It is impossible to assume t

Re: Indentation example?

2016-06-12 Thread ICT Ezy
On Sunday, June 12, 2016 at 9:36:16 PM UTC+5:30, Steven D'Aprano wrote: > On Mon, 13 Jun 2016 01:10 am, ICT Ezy wrote: > > > Pl explain with an example the following phase > > "Indentation cannot be split over multiple physical lines using > > backslashes; the whitespace up to the first backslash

Re: Indentation example?

2016-06-12 Thread ICT Ezy
On Sunday, June 12, 2016 at 9:46:00 PM UTC+5:30, Ned Batchelder wrote: > On Sunday, June 12, 2016 at 11:10:39 AM UTC-4, ICT Ezy wrote: > > Pl explain with an example the following phase > > "Indentation cannot be split over multiple physical lines using > > backslashes; the whitespace up to the fi

Re: Indentation example?

2016-06-12 Thread ICT Ezy
On Sunday, June 12, 2016 at 9:36:16 PM UTC+5:30, Steven D'Aprano wrote: > On Mon, 13 Jun 2016 01:10 am, ICT Ezy wrote: > > > Pl explain with an example the following phase > > "Indentation cannot be split over multiple physical lines using > > backslashes; the whitespace up to the first backslash

Re: Indentation example?

2016-06-12 Thread Ned Batchelder
On Sunday, June 12, 2016 at 11:10:39 AM UTC-4, ICT Ezy wrote: > Pl explain with an example the following phase > "Indentation cannot be split over multiple physical lines using backslashes; > the whitespace up to the first backslash determines the indentation" (in > 2.1.8. Indentation of Tutorial

Re: Indentation example?

2016-06-12 Thread Steven D'Aprano
On Mon, 13 Jun 2016 01:10 am, ICT Ezy wrote: > Pl explain with an example the following phase > "Indentation cannot be split over multiple physical lines using > backslashes; the whitespace up to the first backslash determines the > indentation" (in 2.1.8. Indentation of Tutorial.) I want to teach

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-12 Thread mad scientist jr
Thanks for your reply! On Saturday, June 11, 2016 at 2:41:39 PM UTC-4, MRAB wrote: > Drop the next 3 comment lines. They add visual clutter, and no useful info. > > ### > > # REFERENCE MODULES > > #

Indentation example?

2016-06-12 Thread ICT Ezy
Pl explain with an example the following phase "Indentation cannot be split over multiple physical lines using backslashes; the whitespace up to the first backslash determines the indentation" (in 2.1.8. Indentation of Tutorial.) I want to teach my student that point using some examples. Pl help

Re: pytz and Python timezones

2016-06-12 Thread Carl Meyer
Hi Johannes, On 06/11/2016 05:37 AM, Johannes Bauer wrote: > I try to create a localized timestamp > in the easiest possible way. So, intuitively, I did this: > > datetime.datetime(2016,1,1,0,0,0,tzinfo=pytz.timezone("Europe/Berlin")) That is indeed intuitive, but unfortunately (due to a misunde

how to handle surrogate encoding: read from fs write to database

2016-06-12 Thread Peter Volkov
Hi, everybody. What is a best practice to deal with filenames in python3? The problem is that os.walk(src_dir), os.listdir(src_dir), ... return "surrogate" strings as filenames. It is impossible to assume that they are normal strings that could be print()'ed on unicode terminal or saved as as stri

Re: the global keyword:

2016-06-12 Thread Lawrence D’Oliveiro
On Sunday, June 12, 2016 at 11:51:11 AM UTC+12, Random832 wrote: > Importing a variable from a module copies its value into your own > module's variable. Every name in Python is a variable, and can be assigned to to change its value at any time. -- https://mail.python.org/mailman/listinfo/python

Re: pytz and Python timezones

2016-06-12 Thread Lawrence D’Oliveiro
On Saturday, June 11, 2016 at 11:37:38 PM UTC+12, Johannes Bauer wrote: > I try to create a localized timestamp in the easiest possible way. Localized timestamps are perhaps not as easy as you think. > So, intuitively, I did this: > > datetime.datetime(2016,1,1,0,0,0,tzinfo=pytz.timezone("Europe

Altering sys.argv on startup in Python 2

2016-06-12 Thread Adam Bartoš
Hello, I'm trying to employ code like https://code.activestate.com/recipes/572200/ at Python 2 startup. The problem is that sys.argv isn't polulated yet when sitecustomize is executed. Is there any way around? I was thinking about something like temporarily chaning sys.modules['sys'] or sys.__dict

Re: for / while else doesn't make sense

2016-06-12 Thread Steven D'Aprano
On Sunday 12 June 2016 17:01, pavlovevide...@gmail.com wrote: > On Thursday, May 19, 2016 at 9:43:56 AM UTC-7, Herkermer Sherwood wrote: >> Most keywords in Python make linguistic sense, but using "else" in for and >> while structures is kludgy and misleading. I am under the assumption that >> thi

Re: AttributeError into a bloc try-except AttributeError

2016-06-12 Thread Vincent Vande Vyvre
Le 12/06/16 09:20, Vincent Vande Vyvre a écrit : Hi, I have a strange behaviour in my code. In an interactive session, the result is as expected: Python 3.4.3 (default, Oct 14 2015, 20:28:29) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> a = No

AttributeError into a bloc try-except AttributeError

2016-06-12 Thread Vincent Vande Vyvre
Hi, I have a strange behaviour in my code. In an interactive session, the result is as expected: Python 3.4.3 (default, Oct 14 2015, 20:28:29) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> a = None >>> try: ... _ = a.value ... except Attribu

Re: for / while else doesn't make sense

2016-06-12 Thread pavlovevidence
On Thursday, May 19, 2016 at 9:43:56 AM UTC-7, Herkermer Sherwood wrote: > Most keywords in Python make linguistic sense, but using "else" in for and > while structures is kludgy and misleading. I am under the assumption that > this was just utilizing an already existing keyword. Adding another lik