Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Steven D'Aprano
Paulo da Silva wrote: > Hi! > > What is the best way to read a file that begins with some few text lines > and whose rest is a binary stream? > > As an exmaple ... files .pnm. > > Thanks for any comments/help on this. A mixed text/binary file is really a binary file that contains some binary

Python Upload and Download file using Flask Web development Not Working

2015-03-09 Thread Shalini Ravishankar
Hello Everyone, I am new to Python Web development. I am creating a Web Page with FLask. The Pages takes input as file (file upload) and the process the file and gives the output as a file(downloading the file) But I am having error. My Python file : from flask import Flask from flask import

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Cameron Simpson
On 10Mar2015 04:01, Paulo da Silva wrote: On 10-03-2015 00:55, Dave Angel wrote: On 03/09/2015 08:45 PM, Paulo da Silva wrote: What is the best way to read a file that begins with some few text lines and whose rest is a binary stream? [...] Generally speaking, you can treat a piece of a bina

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Paulo da Silva
On 10-03-2015 00:56, Chris Angelico wrote: > On Tue, Mar 10, 2015 at 11:45 AM, Paulo da Silva > wrote: >> Hi! >> ... > Read the entire file in binary mode, and figure out which parts are > text and how they're encoded (possibly ASCII or UTF-8). Then take just > those snippets, and decode them. So

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Paulo da Silva
On 10-03-2015 00:55, Dave Angel wrote: > On 03/09/2015 08:45 PM, Paulo da Silva wrote: >> Hi! >> >> What is the best way to read a file that begins with some few text lines >> and whose rest is a binary stream? >> ... > > In which version of Python? there's a huge difference between 2.x and 3.x

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Chris Angelico
On Tue, Mar 10, 2015 at 12:01 PM, Dave Angel wrote: >> data = open("some_file", "rb") > > > You accidentally omitted the part where you read() the data > > data = data.read() You know, that would help... a LOT. :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Dave Angel
On 03/09/2015 08:56 PM, Chris Angelico wrote: On Tue, Mar 10, 2015 at 11:45 AM, Paulo da Silva wrote: Hi! What is the best way to read a file that begins with some few text lines and whose rest is a binary stream? As an exmaple ... files .pnm. Thanks for any comments/help on this. Read the

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Chris Angelico
On Tue, Mar 10, 2015 at 11:45 AM, Paulo da Silva wrote: > Hi! > > What is the best way to read a file that begins with some few text lines > and whose rest is a binary stream? > > As an exmaple ... files .pnm. > > Thanks for any comments/help on this. Read the entire file in binary mode, and figu

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Dave Angel
On 03/09/2015 08:45 PM, Paulo da Silva wrote: Hi! What is the best way to read a file that begins with some few text lines and whose rest is a binary stream? As an exmaple ... files .pnm. Thanks for any comments/help on this. In which version of Python? there's a huge difference between 2.

Python3: Reading a text/binary mixed file

2015-03-09 Thread Paulo da Silva
Hi! What is the best way to read a file that begins with some few text lines and whose rest is a binary stream? As an exmaple ... files .pnm. Thanks for any comments/help on this. -- https://mail.python.org/mailman/listinfo/python-list

Re: Use à Python 2 module with Python 3

2015-03-09 Thread Michael Torrie
On 03/09/2015 05:47 PM, Steven D'Aprano wrote: > Michael Parchet wrote: > >> Hello, >> >> For a new project, a person recommande me to use Python 3 >> >> can I use Python 3 with a Python 2 y module ex : pyQt 4 ? > > Maybe. > > If the module is really only Python 2, then no. If it is pure-Python,

Re: Use à Python 2 module with Python 3

2015-03-09 Thread Steven D'Aprano
Michael Parchet wrote: > Hello, > > For a new project, a person recommande me to use Python 3 > > can I use Python 3 with a Python 2 y module ex : pyQt 4 ? Maybe. If the module is really only Python 2, then no. If it is pure-Python, with no C extensions, then you might be able to fork it and u

SQLObject 2.1.1 and 1.7.4

2015-03-09 Thread Oleg Broytman
Hello! I'm pleased to announce minor bugfix releases 2.1.1 and 1.7.4. What's new in SQLObject === * Minor fix in PostgresConnection: close the cursor and connection in _createOrDropDatabase even after an error. Contributor for this release is Gregor Horvath. For a more c

Re: Use à Python 2 module with Python 3

2015-03-09 Thread Mark Lawrence
On 09/03/2015 22:30, Michael Parchet wrote: Hello, For a new project, a person recommande me to use Python 3 can I use Python 3 with a Python 2 y module ex : pyQt 4 ? Tanks for your answer Best regards mparchet Python 2 code can be converted with https://docs.python.org/3/library/2to3.ht

Matplotlib and cx_Freeze

2015-03-09 Thread Rob Gaddi
I'm having serious trouble getting cx_Freeze and matplotlib to agree where the mpl-data folder is on an Ubuntu 14.04 machine. I'm configured with python3-matplotlib 1.3.1 having come from the Ubuntu repositories, and a (now slightly modified) cx_Freeze 4.3.4 from the cheese shop. Originally I

Use à Python 2 module with Python 3

2015-03-09 Thread Michael Parchet
Hello, For a new project, a person recommande me to use Python 3 can I use Python 3 with a Python 2 y module ex : pyQt 4 ? Tanks for your answer Best regards mparchet -- https://mail.python.org/mailman/listinfo/python-list

Re: [RELEASED] Python 3.5.0a2 is now available

2015-03-09 Thread Terry Reedy
On 3/9/2015 5:34 AM, Larry Hastings wrote: On behalf of the Python development community and the Python 3.5 release team, I'm thrilled to announce the availability of Python 3.5.0a2. Python 3.5.0a2 is the second alpha release of Python 3.5, which will be the next major release of Python. Pytho

Re: Mock return_value

2015-03-09 Thread Daniel
On Monday, March 9, 2015 at 10:28:20 AM UTC-5, Daniel wrote: > I have a dao.py module with a dao class declared and I want to use mock to > set a return value for a dao function, dao.execute_ldap_search(). > > import mock > import unittest > import model, dao > > class TestPeopleDAO(unittest.Tes

Re: HELP!! How to ask a girl out with a simple witty Python code??

2015-03-09 Thread Albert-Jan Roskam
- Original Message - > From: Jonas Wielicki > To: python-list@python.org > Cc: > Sent: Monday, March 9, 2015 8:12 PM > Subject: Re: HELP!! How to ask a girl out with a simple witty Python code?? > > On 09.03.2015 14:39, Omar Abou Mrad wrote: >> On Thu, Mar 5, 2015 at 3:34 AM, Xrrific

Re: HELP!! How to ask a girl out with a simple witty Python code??

2015-03-09 Thread Jonas Wielicki
On 09.03.2015 14:39, Omar Abou Mrad wrote: > On Thu, Mar 5, 2015 at 3:34 AM, Xrrific wrote: > >> Guys, please Help!!! >> >> I am trying to impress a girl who is learning python and want ask her out >> at the same time. >> >> Could you please come up with something witty incorporating a simple >>

Re: Mock return_value

2015-03-09 Thread Ben Finney
Daniel writes: > I have a dao.py module with a dao class declared and I want to use > mock to set a return value for a dao function, > dao.execute_ldap_search(). You have found a change which worked, but you might not have understood why yet. The documentation for the ‘unittest.mock’ library co

Re: A strange statement in the bisect documentation?

2015-03-09 Thread Dmitry Chichkov
Steven, I'm somewhat argeeing with you, regarding the general analysisn, yet I'm not quite sure about your analysis of the repeated bisect call code. In particular, in the sample that you've given: data = [i/100 for i in range(1, 701, 7)] data.sort(key=str) keyed_data = [str(x) for x in dat

Re: Letter class in re

2015-03-09 Thread Steven D'Aprano
Antoon Pardon wrote: > I am using PLY for a parsing task which uses re for the lexical > analysis. Does anyone > know what regular expression to use for a sequence of letters? There is > a class for alphanumerics but I can't find one for just letters, which I > find odd. > > I am using python 3.4

Re: Letter class in re

2015-03-09 Thread Tim Chase
On 2015-03-09 15:29, Antoon Pardon wrote: > Op 09-03-15 om 13:50 schreef Tim Chase: > >> (?:(?!_|\d)\w)\w+ > > If you don't have to treat it as an atom, you can simplify that to > > just > > > > (?!_|\d)\w+ > > > > which just means that the first character can't be an underscore > > or digit. >

Re: Letter class in re

2015-03-09 Thread Antoon Pardon
Op 09-03-15 om 14:33 schreef Albert-Jan Roskam: > I was going to make the same remark, but with a slightly different solution: > In [1]: repr(re.search("[a-zA-Z]", "é")) > Out[1]: 'None' > > In [2]: repr(re.search(u"[^\d\W_]+", u"é", re.I | re.U)) > Out[2]: '<_sre.SRE_Match object at 0x027CDB10>

Re: Mock return_value

2015-03-09 Thread Daniel
I found that the following change worked: @mock.patch('dao.dao.execute_ldap_search') def test_find_by_last_first_comma(self, mock_dao): # setup the mock mock_dao.return_value = self.ldap_person_response Daniel On Monday, March 9, 2015 at 10:28:20 AM UTC-5, Daniel wrote: >

Mock return_value

2015-03-09 Thread Daniel
I have a dao.py module with a dao class declared and I want to use mock to set a return value for a dao function, dao.execute_ldap_search(). import mock import unittest import model, dao class TestPeopleDAO(unittest.TestCase): ldap_person_response = SOME_DICT @mock.patch('dao.dao')

Re: Letter class in re

2015-03-09 Thread Antoon Pardon
Op 09-03-15 om 15:44 schreef Chris Angelico: > On Tue, Mar 10, 2015 at 1:41 AM, Antoon Pardon > wrote: >> Op 09-03-15 om 14:35 schreef Chris Angelico: >>> On Mon, Mar 9, 2015 at 11:26 PM, Antoon Pardon >>> wrote: It seems odd that one should need such an ugly expression for something t

Re: Letter class in re

2015-03-09 Thread Antoon Pardon
Op 09-03-15 om 15:39 schreef Chris Angelico: > On Tue, Mar 10, 2015 at 1:34 AM, Antoon Pardon > wrote: >>> There is str.isidentifier, which returns True if something is a valid >>> identifier name: >>> >> '℮'.isidentifier() >>> True >> Which is not very usefull in a context of lexical analysis

Re: Letter class in re

2015-03-09 Thread Chris Angelico
On Tue, Mar 10, 2015 at 1:41 AM, Antoon Pardon wrote: > Op 09-03-15 om 14:35 schreef Chris Angelico: >> On Mon, Mar 9, 2015 at 11:26 PM, Antoon Pardon >> wrote: >>> It seems odd that one should need such an ugly expression for something >>> that is >>> used rather frequently for parsing computer

Re: Letter class in re

2015-03-09 Thread Antoon Pardon
Op 09-03-15 om 14:35 schreef Chris Angelico: > On Mon, Mar 9, 2015 at 11:26 PM, Antoon Pardon > wrote: >> It seems odd that one should need such an ugly expression for something that >> is >> used rather frequently for parsing computer languages and the like. > Possibly because computer language

Re: Letter class in re

2015-03-09 Thread Chris Angelico
On Tue, Mar 10, 2015 at 1:34 AM, Antoon Pardon wrote: >> There is str.isidentifier, which returns True if something is a valid >> identifier name: >> >> >>> '℮'.isidentifier() >> True > > Which is not very usefull in a context of lexical analysis. I don't need to > know > if a particular string i

Re: Letter class in re

2015-03-09 Thread Antoon Pardon
Op 09-03-15 om 14:32 schreef Wolfgang Maier: ... > >> It seems odd that one should need such an ugly expression for >> something that is >> used rather frequently for parsing computer languages and the like. >> > > There is str.isidentifier, which returns True if something is a valid > identifier

Re: Letter class in re

2015-03-09 Thread Antoon Pardon
Op 09-03-15 om 13:50 schreef Tim Chase: > On 2015-03-09 13:26, Antoon Pardon wrote: >> Op 09-03-15 om 12:17 schreef Tim Chase: >>> (?:(?!_|\d)\w) >> So if I understand correctly the following should be a regular >> expression for a python3 identifier. >> >> (?:(?!_|\d)\w)\w+ > If you don't have

Re: Idle - ImportError: No module named numpy

2015-03-09 Thread Tim Golden
On 09/03/2015 14:15, Dave Angel wrote: > On 03/07/2015 02:15 PM, Markos wrote: >> Hi, >> >> I'm beginning to study the numpy. >> >> When I open a terminal (Debian Squeeze) and run the python interpreter >> the command "import numpy as np" run without errors. >> >> But when I run the same command on

Re: Idle - ImportError: No module named numpy

2015-03-09 Thread Dave Angel
On 03/07/2015 02:15 PM, Markos wrote: Hi, I'm beginning to study the numpy. When I open a terminal (Debian Squeeze) and run the python interpreter the command "import numpy as np" run without errors. But when I run the same command on idle3 the following error appears. import numpy as np T

Re: Letter class in re

2015-03-09 Thread Wolfgang Maier
On 03/09/2015 03:04 PM, Wolfgang Maier wrote: On 03/09/2015 02:33 PM, Albert-Jan Roskam wrote: On Mon, 3/9/15, Tim Chase wrote: "[^\d\W_]+" means something like "one or more (+) of 'not (a digit, a non-word, an underscore)'. interesting (using Py

Re: Letter class in re

2015-03-09 Thread Tim Chase
On 2015-03-09 13:26, Antoon Pardon wrote: > Op 09-03-15 om 12:17 schreef Tim Chase: >> (?:(?!_|\d)\w) > > So if I understand correctly the following should be a regular > expression for a python3 identifier. > > (?:(?!_|\d)\w)\w+ If you don't have to treat it as an atom, you can simplify tha

Re: Letter class in re

2015-03-09 Thread Wolfgang Maier
On 03/09/2015 02:33 PM, Albert-Jan Roskam wrote: On Mon, 3/9/15, Tim Chase wrote: "[^\d\W_]+" means something like "one or more (+) of 'not (a digit, a non-word, an underscore)'. interesting (using Python3.4 and U+2188 ROMAN NUMERAL ONE HUNDRED

Re: HELP!! How to ask a girl out with a simple witty Python code??

2015-03-09 Thread Omar Abou Mrad
On Thu, Mar 5, 2015 at 3:34 AM, Xrrific wrote: > Guys, please Help!!! > > I am trying to impress a girl who is learning python and want ask her out > at the same time. > > Could you please come up with something witty incorporating a simple > python line like If...then... but..etc. > > You will m

Re: Letter class in re

2015-03-09 Thread Serhiy Storchaka
On 09.03.15 14:26, Antoon Pardon wrote: So if I understand correctly the following should be a regular expression for a python3 identifier. (?:(?!_|\d)\w)\w+ It seems odd that one should need such an ugly expression for something that is used rather frequently for parsing computer languages

Re: Letter class in re

2015-03-09 Thread Albert-Jan Roskam
On Mon, 3/9/15, Tim Chase wrote: Subject: Re: Letter class in re To: python-list@python.org Date: Monday, March 9, 2015, 12:17 PM On 2015-03-09 11:37, Wolfgang Maier wrote: > On 03/09/2015 11:23 AM, Antoon Pardon wrote: >> Does anyone know w

Re: Letter class in re

2015-03-09 Thread Chris Angelico
On Mon, Mar 9, 2015 at 11:26 PM, Antoon Pardon wrote: > It seems odd that one should need such an ugly expression for something that > is > used rather frequently for parsing computer languages and the like. Possibly because computer language parsers don't use regular expressions. :) ChrisA --

Re: Letter class in re

2015-03-09 Thread Wolfgang Maier
On 03/09/2015 01:26 PM, Antoon Pardon wrote: Op 09-03-15 om 12:17 schreef Tim Chase: On 2015-03-09 11:37, Wolfgang Maier wrote: On 03/09/2015 11:23 AM, Antoon Pardon wrote: Does anyone know what regular expression to use for a sequence of letters? There is a class for alphanumerics but I can't

Re: HELP!! How to ask a girl out with a simple witty Python code??

2015-03-09 Thread Tim
On Wednesday, March 4, 2015 at 8:34:16 PM UTC-5, Xrrific wrote: > Guys, please Help!!! > > I am trying to impress a girl who is learning python and want ask her out at > the same time. > > Could you please come up with something witty incorporating a simple python > line like If...then... but..

Re: Newbie question about text encoding

2015-03-09 Thread Rustom Mody
On Monday, March 9, 2015 at 12:05:05 PM UTC+5:30, Steven D'Aprano wrote: > Chris Angelico wrote: > > > As to the notion of rejecting the construction of strings containing > > these invalid codepoints, I'm not sure. Are there any languages out > > there that have a Unicode string type that require

Re: Letter class in re

2015-03-09 Thread Antoon Pardon
Op 09-03-15 om 12:17 schreef Tim Chase: > On 2015-03-09 11:37, Wolfgang Maier wrote: >> On 03/09/2015 11:23 AM, Antoon Pardon wrote: >>> Does anyone know what regular expression to use for a sequence of >>> letters? There is a class for alphanumerics but I can't find one >>> for just letters, which

Re: Letter class in re

2015-03-09 Thread Tim Chase
On 2015-03-09 11:37, Wolfgang Maier wrote: > On 03/09/2015 11:23 AM, Antoon Pardon wrote: >> Does anyone know what regular expression to use for a sequence of >> letters? There is a class for alphanumerics but I can't find one >> for just letters, which I find odd. > > how about [a-zA-Z] ? That b

Re: Letter class in re

2015-03-09 Thread Antoon Pardon
Op 09-03-15 om 11:37 schreef Wolfgang Maier: > On 03/09/2015 11:23 AM, Antoon Pardon wrote: >> I am using PLY for a parsing task which uses re for the lexical >> analysis. Does anyone >> know what regular expression to use for a sequence of letters? There is >> a class for alphanumerics but I can't

Re: Installed Python 3 on Mac OS X Yosemite but its still Python 2.7

2015-03-09 Thread Cem Karan
On Mar 7, 2015, at 6:39 PM, James Dekker wrote: > I am currently running OS X Yosemite (10.10.2) on my MacBook Pro... By > default, Apple ships Python 2.7.6 on Yosemite. > > Just downloaded and ran this installer for Python 3: > > python-3.4.3-macosx10.6.pkg > > When I opened up my Terminal

Django-DMARC making it easier to manage DMARC reports - Beta 0.1.3 on PyPI

2015-03-09 Thread Alan Hicks
With defending reputations as important as receiving email I'm pleased to announce another beta of django-dmarc 0.1.3 is released to PyPI. https://pypi.python.org/pypi/django-dmarc The Django DMARC project aims to help with implementing DMARC "Domain-based Message Authentication, Reporting & C

Re: Letter class in re

2015-03-09 Thread Wolfgang Maier
On 03/09/2015 11:23 AM, Antoon Pardon wrote: I am using PLY for a parsing task which uses re for the lexical analysis. Does anyone know what regular expression to use for a sequence of letters? There is a class for alphanumerics but I can't find one for just letters, which I find odd. I am using

Letter class in re

2015-03-09 Thread Antoon Pardon
I am using PLY for a parsing task which uses re for the lexical analysis. Does anyone know what regular expression to use for a sequence of letters? There is a class for alphanumerics but I can't find one for just letters, which I find odd. I am using python 3.4 -- Antoon Pardon -- https://mail

Re: Python 3.4 and 2.7 installation no Script folder and pip installation failed

2015-03-09 Thread Tim Golden
On 07/03/2015 12:55, Daiyue Weng wrote: [... snip pip-related problems with installing 2.7.9 on Windows ...] The OP has raised this as issue23604. I've responded over there because it's a duplicate of a known issue (issue22028). http://bugs.python.org/issue23604#msg237628 TJG -- https://mail.p

conditional sys.excepthook (outside of the interactive interpreter)?

2015-03-09 Thread Vlastimil Brom
Hi all, I'd like to as for advise about posibilities of redirecting error traceback via sys.excepthook in a gui (wxpython in my case) with a requirement, that the errors from the code typed in the interactive interpreter (as part of my app) are printed there directly and are not catched from the ex

Visual calendar like korganizer or evolution calendaar (outlook calendar) a print priview and enventualy an adressbook

2015-03-09 Thread Michael Parchet
> > Hello, > I am working with pyqt framework and i'm looking for a calendar (organizer) > like korganizer, evolution or outlook calendar that is OS indépendent with > recurrence event. writting in python with an UI framework (ex pyqt, pygtk, > wkpython, tkinter or other ui framwork) Where c

Installed Python 3 on Mac OS X Yosemite but its still Python 2.7

2015-03-09 Thread James Dekker
I am currently running OS X Yosemite (10.10.2) on my MacBook Pro... By default, Apple ships Python 2.7.6 on Yosemite. Just downloaded and ran this installer for Python 3: python-3.4.3-macosx10.6.pkg When I opened up my Terminal and typed in python, this is what came up: Python 2.7.6 (default, S

Visual kalendar like korganizer or evolution calendaar (outlook calendar) a print priview and enventualy an adressbook

2015-03-09 Thread Michael Parchet
Hello, I am working with pyqt framework and i'm looking for a calendar (organizer) like korganizer, evolution or outlook calendar that is OS indépendent with recurrence event. writting in python with an UI framework (ex pyqt, pygtk, wkpython, tkinter or other ui framwork) Where could I fin

Idle - ImportError: No module named numpy

2015-03-09 Thread Markos
Hi, I'm beginning to study the numpy. When I open a terminal (Debian Squeeze) and run the python interpreter the command "import numpy as np" run without errors. But when I run the same command on idle3 the following error appears. import numpy as np Traceback (most recent call last): Fil

How to install i1636

2015-03-09 Thread Markos
Please, How to install the ia636 library on Debian (Squeeze) with Python 2.6? Thank you, Markos -- https://mail.python.org/mailman/listinfo/python-list

Python 3.4 and 2.7 installation no Script folder and pip installation failed

2015-03-09 Thread Daiyue Weng
Hi, I was doing a fresh installation for Python 2.7.9 (32 bit) and 3.4.3 (32 bit) (downloaded from PSF) on Win7 X64 today, and I found that there is no 'Script' folder in 'Python27' and 'Python34' folder as first child level folder, but there is one in Tools. However, I couldn't find pip within tha

[RELEASED] Python 3.5.0a2 is now available

2015-03-09 Thread Larry Hastings
On behalf of the Python development community and the Python 3.5 release team, I'm thrilled to announce the availability of Python 3.5.0a2. Python 3.5.0a2 is the second alpha release of Python 3.5, which will be the next major release of Python. Python 3.5 is still under heavy development