Re: How modules work in Python

2014-11-18 Thread Larry Hudson

First, I'll repeat everybody else:  DON'T TOP POST!!!

On 11/16/2014 04:41 PM, Abdul Abdul wrote:

Dave,

Thanks for your nice explanation. For your answer on one of my questions:

*Modules don't have methods. open is an ordinary function in the module.*

Isn't "method" and "function" used interchangeably? In other words, aren't they 
the same thing?
Or, Python has some naming conventions here?



You've already received answers to this, but a short example might clarify the 
difference:

#---  Code  
#   Define a function
def func1():
print('This is function func1()')

#   Define a class with a method
class Examp:
def func2(self):
print('This is method func2()')

#   Try them out
obj = Examp()  #  Create an object (an instance of class Examp)
func1()#  Call the function
obj.func2()#  Call the method through the object
func2()#  Try to call the method directly -- Error!
#---  /Code  

This code results in the following:

This is function func1()
This is method func2()
Traceback (most recent call last):
  File "fun-meth.py", line 14, in 
func2()
NameError: name 'func2' is not defined

 -=- Larry -=-

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


Re: caught in the import web again

2014-11-18 Thread Charles T. Smith
On Tue, 18 Nov 2014 00:00:42 -0700, Michael Torrie wrote:

> On 11/17/2014 03:45 PM, Steven D'Aprano wrote:
> 
>> Circular dependencies are not just a problem in Python, they are a
>> problem throughout most of software design.
> 
> Personally I find that duck typing eliminates a lot of the circular
> dependency problems.  Class A doesn't necessarily have to know about
> Class B to work with instances of Class B.  All that has to be known is
> what methods are going to be available on those instances.  The
> interface pattern can help here if you wanted a bit more safety (like
> what Zope provides).  Either way it breaks up the dependency cycle
> nicely.
> 
> If Class A needs to instantiate instances of Class B (which depends on
> Class A), then it could call a factory method to do so, perhaps set up
> by a third party after both modules have been imported.
> 
> There are lots of methods of avoiding the issue entirely.
> 
> In the C or C++ world, I find that signalling frameworks can also be
> used to break a dependency cycle.  For example, if Class A needs to call
> a method on an instance of Class B (which in turn depends on Class A),
> that could be done instead as a signal, which is later connected to
> Class B's method after everything is successfully instantiated.  Also
> makes testing a bit easier, because you can simply hook up the signals
> to a test harness.



A bunch of useful thoughts.  Thanks, folks!
-- 
https://mail.python.org/mailman/listinfo/python-list


How to access Qt components loaded from file?

2014-11-18 Thread Juan Christian
I have this simple code that load any Qt Designer .UI file:

from PySide.QtCore import QFile
from PySide.QtGui import QApplication
from PySide.QtUiTools import QUiLoader


def loadui(file_name):
loader = QUiLoader()
uifile = QFile(file_name)
uifile.open(QFile.ReadOnly)
ui = loader.load(uifile)
uifile.close()
return ui


if __name__ == "__main__":
import sys

app = QApplication(sys.argv)
MainWindow = loadui("main.ui")
MainWindow.show()
app.exec_()

Let's say I have a QTextEdit called txtbox. How can I access this txtbox
inside my Python code?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-18 Thread Vincent Vande Vyvre

Le 18/11/2014 13:18, Juan Christian a écrit :

I have this simple code that load any Qt Designer .UI file:

from PySide.QtCore import QFile
from PySide.QtGui import QApplication
from PySide.QtUiTools import QUiLoader


def loadui(file_name):
loader = QUiLoader()
uifile = QFile(file_name)
uifile.open(QFile.ReadOnly)
ui = loader.load(uifile)
uifile.close()
return ui


if __name__ == "__main__":
import sys

app = QApplication(sys.argv)
MainWindow = loadui("main.ui")
MainWindow.show()
app.exec_()

Let's say I have a QTextEdit called txtbox. How can I access this 
txtbox inside my Python code?




How about MainWindow.txtbox  ?
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-18 Thread Juan Christian
Many thanks, worked. The only problem now is that I don't have
auto-complete for anything, because of this approach... I'll have to check
the doc more regularly. ^^

On Tue Nov 18 2014 at 10:48:44 AM Vincent Vande Vyvre <
[email protected]> wrote:

> Le 18/11/2014 13:18, Juan Christian a écrit :
> > I have this simple code that load any Qt Designer .UI file:
> >
> > from PySide.QtCore import QFile
> > from PySide.QtGui import QApplication
> > from PySide.QtUiTools import QUiLoader
> >
> >
> > def loadui(file_name):
> > loader = QUiLoader()
> > uifile = QFile(file_name)
> > uifile.open(QFile.ReadOnly)
> > ui = loader.load(uifile)
> > uifile.close()
> > return ui
> >
> >
> > if __name__ == "__main__":
> > import sys
> >
> > app = QApplication(sys.argv)
> > MainWindow = loadui("main.ui")
> > MainWindow.show()
> > app.exec_()
> >
> > Let's say I have a QTextEdit called txtbox. How can I access this
> > txtbox inside my Python code?
> >
> >
> How about MainWindow.txtbox  ?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: Leo 5.0 beta 2 released

2014-11-18 Thread edreamleo
Leo 5.0b2 is now available at:
http://sourceforge.net/projects/leo/files/Leo/

This release fixes several installation issues
and updates installation instructions for Linux/Ubuntu.

Leo is a PIM, an IDE and an outliner.
Video tutorials: http://leoeditor.com/screencasts.html
Text tutorials: http://leoeditor.com/tutorial.html

The highlights of Leo 5.0
--

* Better compatibility with vim, Emacs, pylint and PyQt:
- Optional native emulation of vim commands.
- Full support for Emacs org-mode outlines.
- Full support for Vim .otl outlines.
- Better support for pylint.
- Support for both PyQt4 and PyQt5.
* Better handling of nodes containing large text:
- Idle time syntax coloring eliminates delay.
- Optional delayed loading of large text.
* Power features:
- Command history for minibuffer commands.
- Leo available via github repository.
- File name completion.
- Cloned nodes expand and contract independently.
- @data nodes can be composed from descendant nodes.
- No need to change Leo's main style sheet:
  it can be customized with @color and @font settings.
- @persistence nodes save data in @auto trees.
- A pluggable architecture for @auto nodes.
- The style-reload command changes Leo's appearance instantly.
* Important new plugins for tagging, display and node evaluation.
* For beginners:
- Leo's default workbook files contains Leo's quickstart guide.
* Hundreds of new/improved features and bug fixes.

Links:
--
Leo:   http://leoeditor.com
Docs:  http://leoeditor.com/leo_toc.html
Tutorials: http://leoeditor.com/tutorial.html
Videos:http://leoeditor.com/screencasts.html
Forum: http://groups.google.com/group/leo-editor
Download:  http://sourceforge.net/projects/leo/files/
Github:https://github.com/leo-editor/leo-editor
Quotes:http://leoeditor.com/testimonials.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-18 Thread Juan Christian
I was doing some tests, then I tried this:

app = QApplication(sys.argv)
MainWindow = loadui("main.ui")
MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test()))

MainWindow.show()
app.exec_()

But I get "RuntimeError: Failed to connect signal clicked().", why?

The syntax is correct, I don't know why it failed, the btn is in the Form
too, it's a QPushButton.

The test func is just a simple func that returns a random text.

On Tue Nov 18 2014 at 11:08:48 AM Juan Christian 
wrote:

> Many thanks, worked. The only problem now is that I don't have
> auto-complete for anything, because of this approach... I'll have to check
> the doc more regularly. ^^
>
> On Tue Nov 18 2014 at 10:48:44 AM Vincent Vande Vyvre <
> [email protected]> wrote:
>
>> Le 18/11/2014 13:18, Juan Christian a écrit :
>> > I have this simple code that load any Qt Designer .UI file:
>> >
>> > from PySide.QtCore import QFile
>> > from PySide.QtGui import QApplication
>> > from PySide.QtUiTools import QUiLoader
>> >
>> >
>> > def loadui(file_name):
>> > loader = QUiLoader()
>> > uifile = QFile(file_name)
>> > uifile.open(QFile.ReadOnly)
>> > ui = loader.load(uifile)
>> > uifile.close()
>> > return ui
>> >
>> >
>> > if __name__ == "__main__":
>> > import sys
>> >
>> > app = QApplication(sys.argv)
>> > MainWindow = loadui("main.ui")
>> > MainWindow.show()
>> > app.exec_()
>> >
>> > Let's say I have a QTextEdit called txtbox. How can I access this
>> > txtbox inside my Python code?
>> >
>> >
>> How about MainWindow.txtbox  ?
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: caught in the import web again

2014-11-18 Thread Ian Kelly
On Mon, Nov 17, 2014 at 6:20 PM, Dave Angel  wrote:
> Ian Kelly  Wrote in message:
>> On Mon, Nov 17, 2014 at 3:17 PM, Dave Angel  wrote:
>
>>> In a module that might get tangled in a cycle, avoid global code
>>>  that depends on other modules.  Instead of putting such
>>>  initialization at top level, put inside a function that gets
>>>  called after all suspect imports are completed. (That function
>>>  has global keywords ).
>>
>> If the problem is that one of those modules would import the current
>> module, then "after all suspect imports are completed" basically means
>> after the current module has finished importing. So what would be
>> responsible for calling such a function?
>>
>
> If one builds a set of modules that cannot avoid recursive
>  imports, then one can ask the code that imports it to make a call
>  after importing. Or all that is needed to avoid exposing the mess
>  is that the top level not be part of the loops.

This would make the module less reusable though, since the first other
module to import it in one program might still be used in another
program but not be the first other module to import it. Or I suppose
for simplicity it could be required that all importers call the
initialization function, and have the function return immediately if
it's been called previously. However, I don't think there's any way to
do this without ending up with smelly code.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-18 Thread Vincent Vande Vyvre

Le 18/11/2014 15:49, Juan Christian a écrit :

I was doing some tests, then I tried this:

app = QApplication(sys.argv)
MainWindow = loadui("main.ui")
MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test()))

MainWindow.show()
app.exec_()

But I get "RuntimeError: Failed to connect signal clicked().", why?

The syntax is correct, I don't know why it failed, the btn is in the 
Form too, it's a QPushButton.


The test func is just a simple func that returns a random text.

On Tue Nov 18 2014 at 11:08:48 AM Juan Christian 
mailto:[email protected]>> wrote:


Many thanks, worked. The only problem now is that I don't have
auto-complete for anything, because of this approach... I'll have
to check the doc more regularly. ^^



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




You can't have a slot like this:

MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test()))

because that's mean: "connect to the return of 
MainWindow.txtbox.setText(test())" and it's not possible at this stage 
of your program.


Use instead a function:

MainWindow.btn.clicked.connect(my_slot) # No parenthesis !

def my_slot():
MainWindow.txtbox.setText(test())
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-18 Thread Juan Christian
>
> You can't have a slot like this:
>
> MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test()))
>
> because that's mean: "connect to the return of
> MainWindow.txtbox.setText(test())" and it's not possible at this stage
> of your program.
>
> Use instead a function:
>
> MainWindow.btn.clicked.connect(my_slot) # No parenthesis !
>
> def my_slot():
>  MainWindow.txtbox.setText(test())
>

Thanks, it's working. What would be a "professional" approach if I want to
constantly call a URL to get it's content and access this data within the
GUI?

I mean, when I run the program I'm locked in the app.exec_() continuous
loop right? So I can't have a loop to get this data from the web, is there
any special signal/slot regarding this?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: caught in the import web again

2014-11-18 Thread Dave Angel
Ian Kelly  Wrote in message:
> On Mon, Nov 17, 2014 at 6:20 PM, Dave Angel  wrote:
>> Ian Kelly  Wrote in message:
>>> On Mon, Nov 17, 2014 at 3:17 PM, Dave Angel  wrote:
>>
 In a module that might get tangled in a cycle, avoid global code
  that depends on other modules.  Instead of putting such
  initialization at top level, put inside a function that gets
  called after all suspect imports are completed. (That function
  has global keywords ).
>>>
>>> If the problem is that one of those modules would import the current
>>> module, then "after all suspect imports are completed" basically means
>>> after the current module has finished importing. So what would be
>>> responsible for calling such a function?
>>>
>>
>> If one builds a set of modules that cannot avoid recursive
>>  imports, then one can ask the code that imports it to make a call
>>  after importing. Or all that is needed to avoid exposing the mess
>>  is that the top level not be part of the loops.
> 
> This would make the module less reusable though, since the first other
> module to import it in one program might still be used in another
> program but not be the first other module to import it. Or I suppose
> for simplicity it could be required that all importers call the
> initialization function, and have the function return immediately if
> it's been called previously. However, I don't think there's any way to
> do this without ending up with smelly code.
> 

The smelly code happened when the designer "can't" break the
 cycle. I understood the question to be "then what." Two-stage
 initialization is sometimes "needed" in any language and I was
 just showing it's possible in Python. I once worked on (and then
 fixed) a build system that could not complete a build from clean.
 It needed some pieces from a previous build in order to get to
 the point where it was ready to build those pieces. Recursive
 depencies at compile and link time.

-- 
DaveA

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


Re: caught in the import web again

2014-11-18 Thread Chris Angelico
On Wed, Nov 19, 2014 at 6:09 AM, Dave Angel  wrote:
> I once worked on (and then
>  fixed) a build system that could not complete a build from clean.
>  It needed some pieces from a previous build in order to get to
>  the point where it was ready to build those pieces. Recursive
>  depencies at compile and link time.

Sometimes the solution to that is to add intermediate files to the
source code archive. Pike can't be built from source control unless
you already have a reasonably recent Pike installed, but the exported
.tar.gz archive includes all the generated files, so you can build
that, then go to the absolute latest from source control. There are
always ways around a circular dependency.

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


Re: How modules work in Python

2014-11-18 Thread sohcahtoa82
On Tuesday, November 18, 2014 12:14:15 AM UTC-8, Larry Hudson wrote:
> First, I'll repeat everybody else:  DON'T TOP POST!!!
> 
> On 11/16/2014 04:41 PM, Abdul Abdul wrote:
> > Dave,
> >
> > Thanks for your nice explanation. For your answer on one of my questions:
> >
> > *Modules don't have methods. open is an ordinary function in the module.*
> >
> > Isn't "method" and "function" used interchangeably? In other words, aren't 
> > they the same thing?
> > Or, Python has some naming conventions here?
> >
> 
> You've already received answers to this, but a short example might clarify 
> the difference:
> 
> #---  Code  
> #   Define a function
> def func1():
>  print('This is function func1()')
> 
> #   Define a class with a method
> class Examp:
>  def func2(self):
>  print('This is method func2()')
> 
> #   Try them out
> obj = Examp()  #  Create an object (an instance of class Examp)
> func1()#  Call the function
> obj.func2()#  Call the method through the object
> func2()#  Try to call the method directly -- Error!
> #---  /Code  
> 
> This code results in the following:
> 
> This is function func1()
> This is method func2()
> Traceback (most recent call last):
>File "fun-meth.py", line 14, in 
>  func2()
> NameError: name 'func2' is not defined
> 
>   -=- Larry -=-

You COULD have something like this though:

# --- myModule.py ---
def myFunc():
print 'myFunc'


# --- main.py ---
import myModule
myModule.myFunc()


In this case, myFunc LOOKS like a method when it is called from main.py, but it 
is still a function.
-- 
https://mail.python.org/mailman/listinfo/python-list


How do you download and install HTML5TreeBuilder ?

2014-11-18 Thread Simon Evans
Dear Programmers,
I have installed the HTMLParserTreebuilder and LXMLTreeBuilder downloads to my 
Python2.7 console, using the Windows Console 'pip install' procedure.

I downloaded HTML5 files and installed them to my Python2.7 directory, and went 
through the 'pip install' procedure, but this did not work. 

I do not know whether it is because different procedure must be followed for 
HTML5, or that I downloaded the wrong files, the files I downloaded and 
attempted to install were the following three :- 

html5lib-0.999(1).tar.gz

html5lib-0.999.tar.gz

HTMLParser-0.0.2.tar.gz

The  Windows 7.0 Console returned the following in response :- 
 
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Intel Atom>pip install HTML5
Downloading/unpacking HTML5
  Could not find any downloads that satisfy the requirement HTML5
Cleaning up...
No distributions at all found for HTML5
Storing debug log for failure in c:\users\intela~1\appdata\local\temp\tmp4pxazz

C:\Users\Intel Atom>pip install HTML5
Downloading/unpacking HTML5
  Could not find any downloads that satisfy the requirement HTML5
Cleaning up...
No distributions at all found for HTML5
Storing debug log for failure in c:\users\intela~1\appdata\local\temp\tmp81fbka

C:\Users\Intel Atom>pip install HTML5
Downloading/unpacking HTML5
  Could not find any downloads that satisfy the requirement HTML5
Cleaning up...
No distributions at all found for HTML5
Storing debug log for failure in c:\users\intela~1\appdata\local\temp\tmphaw01m

C:\Users\Intel Atom>

I suppose my main conundrum is from where can I download a version of the 
HTML5 Treebuilder that will install using pip. It doesn't help that HTML5 also 
happens to be the name of some video editing software. 
Thank you for reading.
PS: If anyone is upset about 'one line paragraphs' and other such petulancies, 
then please decline to respond, seeing as far as I'm concerned such 
trivialities are besides the point, and are of no help, so vent your ire 
elsewhere. 
YOurs Simon Evans. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do you download and install HTML5TreeBuilder ?

2014-11-18 Thread John Gordon
In  Simon Evans 
 writes:

> I downloaded HTML5 files and installed them to my Python2.7 directory,
> and went through the 'pip install' procedure, but this did not work. 

> html5lib-0.999(1).tar.gz
> html5lib-0.999.tar.gz
> HTMLParser-0.0.2.tar.gz

Those first two files seem identical.  Did you mean to download the same
file twice?

Where did you place the files?  You say you 'installed' them to your
Python2.7 directory.  Is 'C:\Users\Intel Atom' your Python2.7 directory?

The command transcript appears to be you typing the same command,
'pip install HTML5', three times, with exactly the same result each time.
Did you mean to execute the same command three times over?  If so, did
you expect to get different results the second or third time?

-- 
John Gordon Imagine what it must be like for a real medical doctor to
[email protected] 'House', or a real serial killer to watch 'Dexter'.

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


Re: How do you download and install HTML5TreeBuilder ?

2014-11-18 Thread Mark Lawrence

On 18/11/2014 21:55, Simon Evans wrote:

Dear Programmers,
I have installed the HTMLParserTreebuilder and LXMLTreeBuilder downloads to my 
Python2.7 console, using the Windows Console 'pip install' procedure.

I downloaded HTML5 files and installed them to my Python2.7 directory, and went 
through the 'pip install' procedure, but this did not work.

I do not know whether it is because different procedure must be followed for 
HTML5, or that I downloaded the wrong files, the files I downloaded and 
attempted to install were the following three :-

html5lib-0.999(1).tar.gz

html5lib-0.999.tar.gz

HTMLParser-0.0.2.tar.gz

The  Windows 7.0 Console returned the following in response :-

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Intel Atom>pip install HTML5
Downloading/unpacking HTML5
   Could not find any downloads that satisfy the requirement HTML5
Cleaning up...
No distributions at all found for HTML5
Storing debug log for failure in c:\users\intela~1\appdata\local\temp\tmp4pxazz

C:\Users\Intel Atom>pip install HTML5
Downloading/unpacking HTML5
   Could not find any downloads that satisfy the requirement HTML5
Cleaning up...
No distributions at all found for HTML5
Storing debug log for failure in c:\users\intela~1\appdata\local\temp\tmp81fbka

C:\Users\Intel Atom>pip install HTML5
Downloading/unpacking HTML5
   Could not find any downloads that satisfy the requirement HTML5
Cleaning up...
No distributions at all found for HTML5
Storing debug log for failure in c:\users\intela~1\appdata\local\temp\tmphaw01m

C:\Users\Intel Atom>

I suppose my main conundrum is from where can I download a version of the
HTML5 Treebuilder that will install using pip. It doesn't help that HTML5 also 
happens to be the name of some video editing software.
Thank you for reading.
PS: If anyone is upset about 'one line paragraphs' and other such petulancies, 
then please decline to respond, seeing as far as I'm concerned such 
trivialities are besides the point, and are of no help, so vent your ire 
elsewhere.
YOurs Simon Evans.



I never download files, I just leave the work to pip.  I'm assuming this 
is what you're looking for.


c:\Users\Mark\Cash\Python>pip install html5lib
Downloading/unpacking html5lib
  Running setup.py 
(path:C:\Users\Mark\AppData\Local\Temp\pip_build_Mark\html5lib\setup.py) 
egg_info for package html5lib


Requirement already satisfied (use --upgrade to upgrade): six in 
c:\python34\lib\site-packages (from html5lib)

Installing collected packages: html5lib
  Running setup.py install for html5lib

Successfully installed html5lib
Cleaning up...

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: How to fix those errors?

2014-11-18 Thread Steven D'Aprano
Roy Smith wrote:

> In article <[email protected]>,
>  Steven D'Aprano  wrote:
> 
>> Chris Angelico wrote:
>> 
>> > You should be able to use two semicolons, that's equivalent to one
>> > colon right?
>> > 
>> > ChrisA
>> > (No, it isn't, so don't take this advice. Thanks.)
>> 
>> 
>> Oooh! Python-ideas territory!
>> 
>> I think the parser should allow two consecutive semi-colons, or four
>> commas, as an alias for a colon. Then we could write code like:
>> 
>> 
>> def spam(arg);;
>> for x in seq
>> pass
> 
> Wouldn't it make more sense to use four periods?
> 
> def spam(arg)
> for x in seq
> pass
> 
> First, 2 colons is 4 dots, so it's conservation of punctuation.  Second,
> it reads pretty well.


Four periods  is already legal, it is ellipsis followed by dot:

py> __class__



(Try it in Python 3, it actually works!)



-- 
Steven

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


Re: caught in the import web again

2014-11-18 Thread Dave Angel
Chris Angelico  Wrote in message:
> On Wed, Nov 19, 2014 at 6:09 AM, Dave Angel  wrote:
>> I once worked on (and then
>>  fixed) a build system that could not complete a build from clean.
>>  It needed some pieces from a previous build in order to get to
>>  the point where it was ready to build those pieces. Recursive
>>  depencies at compile and link time.
> 
> Sometimes the solution to that is to add intermediate files to the
> source code archive. Pike can't be built from source control unless
> you already have a reasonably recent Pike installed, but the exported
> .tar.gz archive includes all the generated files, so you can build
> that, then go to the absolute latest from source control. There are
> always ways around a circular dependency.
> 

Exactly. In the case I was talking about there was a somewhat
 related problem.  The build broke every time,  and the fixups
 were very manual.  Nobody even knew if the results depended on
 the order of applying the fixups. The build lady spent about two
 days each week fixing stuff up.

-- 
DaveA

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


Re: How do you download and install HTML5TreeBuilder ?

2014-11-18 Thread Simon Evans
re: 

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Intel Atom>pip install html5lib
Downloading/unpacking html5lib
  Running setup.py (path:c:\users\intela~1\appdata\local\temp\pip_build_Intel At
om\html5lib\setup.py) egg_info for package html5lib

Downloading/unpacking six (from html5lib)
  Downloading six-1.8.0-py2.py3-none-any.whl
Installing collected packages: html5lib, six
  Running setup.py install for html5lib

Successfully installed html5lib six
Cleaning up...

C:\Users\Intel Atom>


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


Re: How to access Qt components loaded from file?

2014-11-18 Thread Chris Angelico
On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian
 wrote:
>
> Thanks, it's working. What would be a "professional" approach if I want to
> constantly call a URL to get it's content and access this data within the
> GUI?
>

"Constantly" doesn't make much sense when you're talking about network
operations. There are two basic approaches: either you re-fetch
periodically and update the GUI (in which case you have to decide how
frequently), or you re-fetch on some trigger (when it's changed, or
when the user's about to need it, or something). Either way, you have
to balance network traffic versus promptness of update, and it's
nearly impossible to pick perfectly. But if you don't mind it being a
little clunky, you should be able to pick something fairly simple and
deploy it, and then maybe refine it a bit afterward.

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


scipy shape

2014-11-18 Thread Abdul Abdul
I came across an example that starts as follows:

from scipy.ndimage import filters
img = zeros(im.shape)

What does the second line mean here? Is it setting the image pixels to
zero? What is "shape" here?

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


Re: scipy shape

2014-11-18 Thread MRAB

On 2014-11-19 02:30, Abdul Abdul wrote:

I came across an example that starts as follows:

from scipy.ndimage import filters
img = zeros(im.shape)

What does the second line mean here? Is it setting the image pixels to
zero? What is "shape" here?


It looks like it might be using numpy.

If 'im' is a numpy array representing an image, then its .shape
attribute is giving its 'shape' (a tuple of the sizes of its
dimensions).

numpy.zeros(...) will when return a numpy array of the same shape.

So, it's not setting the image pixels to 0, but creating a new image of
the same shape in which the pixels are 0.
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to fix those errors?

2014-11-18 Thread alex23

On 17/11/2014 1:06 PM, Chris Angelico wrote:

You could then name it in Hebrew: Paamayim Nekudotayim. There is
excellent precedent for this - it's done by a language in whose
footsteps Python strives to follow.


The first time I got a T_PAAMAYIM_NEKUDOTAYIM error, I just about 
flipped my desk in rage.

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


Re: Trouble getting full response content from PATCH request

2014-11-18 Thread Cameron Simpson

On 17Nov2014 20:26, John Gordon  wrote:

I'm working with a third-party API and I'm seeing some behavior that I
can't explain.

The API uses the HTTP PATCH operation to set user passwords, and in
case of unacceptable passwords, the response is supposed to be an HTML
document containing a diagnostic message in the  tag.

When I submit my test data via a functional testing tool (SoapUI), it
behaves as expected.

However, when I submit test data from Python code, the response content
consists only of the diagnostic message, with no enclosing  or 
tags.

[...]

You need a "SOAPAction: " HTTP header with SOAP requests. It may be that 
simple.


Cheers,
Cameron Simpson 

Glendower: I can call monsters from the vasty deeps.
Hotspur:   Why, so can I, or so can any man. But will they come when you do
  call them?
- Henry IV, part 1
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to fix those errors?

2014-11-18 Thread Chris Angelico
On Wed, Nov 19, 2014 at 2:02 PM, alex23  wrote:
> On 17/11/2014 1:06 PM, Chris Angelico wrote:
>>
>> You could then name it in Hebrew: Paamayim Nekudotayim. There is
>> excellent precedent for this - it's done by a language in whose
>> footsteps Python strives to follow.
>
>
> The first time I got a T_PAAMAYIM_NEKUDOTAYIM error, I just about flipped my
> desk in rage.

If that were Hebrew for "scope resolution operator", would it be less
rage-inducing?

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


Re:scipy shape

2014-11-18 Thread Dave Angel
Abdul Abdul  Wrote in message:
> I came across an example that starts as follows:
> 
> from scipy.ndimage import filters
> img = zeros(im.shape)
> 
> What does the second line mean here? Is it setting the image pixels to zero? 
> What is "shape" here?
> 

This example is incomplete. Neither zeros nor im are defined in
 the python versions I have installed,  and shape is an attribute
 of im, whatever type that is.

Your example needs at least another import, probably like

from numpy import zeros


 http://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html

But I can't guess what im might be, unless it's some numpy instance. 

The other thing missing from the example is the python version. 

-- 
DaveA

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


Re: How modules work in Python

2014-11-18 Thread Larry Hudson

On 11/18/2014 12:59 PM, [email protected] wrote:

On Tuesday, November 18, 2014 12:14:15 AM UTC-8, Larry Hudson wrote:

First, I'll repeat everybody else:  DON'T TOP POST!!!

On 11/16/2014 04:41 PM, Abdul Abdul wrote:

Dave,

Thanks for your nice explanation. For your answer on one of my questions:

*Modules don't have methods. open is an ordinary function in the module.*

Isn't "method" and "function" used interchangeably? In other words, aren't they 
the same thing?
Or, Python has some naming conventions here?



You've already received answers to this, but a short example might clarify the 
difference:

#---  Code  
#   Define a function
def func1():
  print('This is function func1()')

#   Define a class with a method
class Examp:
  def func2(self):
  print('This is method func2()')

#   Try them out
obj = Examp()  #  Create an object (an instance of class Examp)
func1()#  Call the function
obj.func2()#  Call the method through the object
func2()#  Try to call the method directly -- Error!
#---  /Code  

This code results in the following:

This is function func1()
This is method func2()
Traceback (most recent call last):
File "fun-meth.py", line 14, in 
  func2()
NameError: name 'func2' is not defined

   -=- Larry -=-


You COULD have something like this though:

# --- myModule.py ---
def myFunc():
 print 'myFunc'


# --- main.py ---
import myModule
myModule.myFunc()


In this case, myFunc LOOKS like a method when it is called from main.py, but it 
is still a function.



My purpose was to give a _simple_ example of the difference in the two terms:  that a function 
is called directly and a method is called through an object.


Your example may _look_ the same (it uses the same dot syntax), but here it is to resolve a 
namespace -- a module is not an object.  So yes, this is still a function and not a method.  But 
we're getting rather pedantic here.


 -=- Larry -=-

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