Re: can't get utf8 / unicode strings from embedded python

2013-08-23 Thread David M. Cotter
> I see you are using Python 2 correct > Firstly, in Python 2, the compiler assumes that the source code is encoded in > ASCII gar, i must have been looking at doc for v3, as i thought it was all assumed to be utf8 > # -*- coding: utf-8 -*- okay, did that, still no change > you need to use u"

Exception Handling Practices / Patterns

2013-08-23 Thread snarf
Greetings, As I tread through my journey of OO I am trying to determine if there is a good approach for exception handling within classes. >From my readings and gatherings - it seems I have found a common theme, but I >am trying to solicit from the experts. Here is what I have found (I may be

Fast conversion of numbers to numerator/denominator pairs

2013-08-23 Thread Steven D'Aprano
I have a need to convert arbitrary non-complex numbers into numerator/ denominator pairs. Numbers could be ints, floats, Fractions or Decimals. For example: 2 => (2, 1) 0.25 => (1, 4) Fraction(2, 3) => (2, 3) Decimal("0.5") => (1, 2) The first three cases are easy and fast: # ints and Fraction

Re: Conversion Issue in Converting code of 2.7 to 3

2013-08-23 Thread MRAB
On 24/08/2013 03:10, shankha wrote: Hi, I am trying to run the following piece of code: https://greyhat.gatech.edu/wiki/index.php?title=Java_Bytecode_Tutorial/Getting_Started python Krakatau/assemble.py minimal.j. The scripts are written for 2.7. I want to convert them to 3.3. I am struck wit

Re: Python script help

2013-08-23 Thread Piet van Oostrum
cool1...@gmail.com writes: > Here are some scripts, how do I put them together to create the script > I want? (to search a online document and download all the links in it) > p.s: can I set a destination folder for the downloads? You can use os.chdir to go to the desired folder. > > urllib.urlope

Conversion Issue in Converting code of 2.7 to 3

2013-08-23 Thread shankha
Hi, I am trying to run the following piece of code: https://greyhat.gatech.edu/wiki/index.php?title=Java_Bytecode_Tutorial/Getting_Started python Krakatau/assemble.py minimal.j. The scripts are written for 2.7. I want to convert them to 3.3. I am struck with the following error: []$ python Kra

Re: can't get utf8 / unicode strings from embedded python

2013-08-23 Thread Steven D'Aprano
On Fri, 23 Aug 2013 13:49:23 -0700, David M. Cotter wrote: > note everything works great if i use Ascii, but: > > in my utf8-encoded script i have this: > >> print "frøânçïé" I see you are using Python 2, in which case there are probably two or three errors being made here. Firstly, in

Re: Setting the value of True

2013-08-23 Thread Steven D'Aprano
On Fri, 23 Aug 2013 16:38:43 -0700, jeangawron wrote: > Python allows you set the value of True > True = 1.3 Only in older versions of Python. This is for historical reasons: True and False were added as built-ins relatively late in Python's history (2.2, I think) and so there is still ol

Re: Using PyQT with QT Designer

2013-08-23 Thread tausciam
Thank you... I found my problem class MainWindow(QMainWindow, Ui_MainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) That seems to take care of it... if I comment out everything else, I get my pristine form I do

Re: Using PyQT with QT Designer

2013-08-23 Thread Lee Harr
> That's the problem though. It is exactly how I want it in designer. It's > perfect as it is in designer when I preview it. Here is a screenshot of the > preview: http://i.imgur.com/ULRolq8.png That's not a preview. That's just the regular design view. (you can tell by the little dots in the back

Re: Setting the value of True

2013-08-23 Thread Terry Reedy
On 8/23/2013 7:38 PM, jeangaw...@gmail.com wrote: Python allows you set the value of True Unqualified 'Python', used in the present tense, refers to the latest release or repository version. >>> True = 1.3 SyntaxError: assignment to keyword True = 1.3 Now this is consistent with the deci

Re: Setting the value of True

2013-08-23 Thread Gary Herron
On 08/23/2013 04:38 PM, jeangaw...@gmail.com wrote: Python allows you set the value of True True = 1.3 Now this is consistent with the decision to let you set the value of various builtin names. But why is this case different: None = 1.3 File "", line 1 SyntaxError: cannot assign to Non

Re: Using PyQT with QT Designer

2013-08-23 Thread tausciam
Thank you. I just deleted all of them, reran pyuic4 on window.ui and regenerated window.py just to make sure. Unfortunately, I get the same problem. I've got the GUI perfectly designed just like I want it in window.py... just can't figure out how to use it in my program. On Friday, August 23, 2

Setting the value of True

2013-08-23 Thread jeangawron
Python allows you set the value of True >>> True = 1.3 Now this is consistent with the decision to let you set the value of various builtin names. But why is this case different: >>> None = 1.3 File "", line 1 SyntaxError: cannot assign to None Mark Gawron -- http://mail.python.org/mailman/

can't get utf8 / unicode strings from embedded python

2013-08-23 Thread David M. Cotter
note everything works great if i use Ascii, but: in my utf8-encoded script i have this: > print "frøânçïé" in my embedded C++ i have this: PyObject* CPython_Script::print(PyObject *args) { PyObject*resultObjP = NULL; const char *utf8_

Re: How to add additional font face to Python 3.3.2 IDLE?

2013-08-23 Thread maildragons1
23 август 2013, петък, 19:33:41 UTC+3, Terry Reedy написа: > On 8/23/2013 11:49 AM, maildrago...@gmail.com wrote: > > > How can I add for example Droid Sans Mono to python 3.3.2 IDLE? I'm not > > very familliar with font faces, really. > > > > I suspect that Idle just looks in the standard fon

Re: Using PyQT with QT Designer

2013-08-23 Thread Dave Angel
Michael Staggs wrote: > > That's the problem though. It is exactly how I want it in designer. It's > perfect as it is in designer when I preview it. Here is a screenshot of the > preview: http://i.imgur.com/ULRolq8.png > > The problem isn't that I can't design it in QT Designer. It is designed >

Arpex Capital seleciona: Desenvolvedor Python / SP

2013-08-23 Thread zughumancapital
Arpex Capital seleciona para uma de suas empresas: Desenvolvedor Python Objetivo geral da Posição: Desenvolver software estável e de primeira linha, que será incorporado à plataforma de WiFi mais moderna atualmente. Responsabilidades: escrever software que rodará tanto no backend (Python) quan

Re: Can a child access parent attributes if that child added post-hoc as an attribute to the parent?

2013-08-23 Thread Bitswapper
On Thursday, August 22, 2013 4:59:17 PM UTC-5, Ian wrote: > On Thu, Aug 22, 2013 at 3:26 PM, Prasad, Ramit > > <> wrote: > > > Bitswapper wrote: > > >> > > >> So I have a parent and child class: > > >> > > >> > > >> class Map(object): > > >> def __init__(self, name=''): > > >>

Re: Using PyQT with QT Designer

2013-08-23 Thread Michael Staggs
Again thoughI'm finished with QT Designer. I have the finished product I want exactly like I want it. But, as ive shown in the screenshots, I'm doing exactly what ive seen in zetcode and other tutorials but It doesn't seem to incorporate and act upon that ui file. The first thing you notice is

Re: Using PyQT with QT Designer

2013-08-23 Thread Michael Staggs
Thanks for the manual. I will look into it but all the examples are probably c++. Ive tried zetcode and some of the other tutorials. That's the problem though. It is exactly how I want it in designer. It's perfect as it is in designer when I preview it. Here is a screenshot of the preview: http://

Re: Using PyQT with QT Designer

2013-08-23 Thread Phil Thompson
On Fri, 23 Aug 2013 12:30:41 -0500, Michael Staggs wrote: > Right. I know that if I redesign it I have to run pyuic4 again and that I > shouldn't change that file...let qt designer do its job. > > But, that's exactly what I'm having the problem with...incorporating the > file pyuic4 gave me... an

Re: Using PyQT with QT Designer

2013-08-23 Thread Michael Staggs
Right. I know that if I redesign it I have to run pyuic4 again and that I shouldn't change that file...let qt designer do its job. But, that's exactly what I'm having the problem with...incorporating the file pyuic4 gave me... and why I posted here. If you can point me towards something I need to

Re: Using PyQT with QT Designer

2013-08-23 Thread Phil Thompson
On Fri, 23 Aug 2013 08:00:29 -0500, Michael Staggs wrote: > I tried that this morning and it destroyed my form. So, right now, that's > probably not what I'm looking for. > > But, if you look at that picture, the app isn't resized to 800x600 like it > says in the ui file. The pixmaps aren't on th

Re: Running a command line program and reading the result as it runs

2013-08-23 Thread Peter Otten
random...@fastmail.us wrote: > On Fri, Aug 23, 2013, at 7:14, Peter Otten wrote: >> The following works on my linux system: >> >> instream = iter(p.stdout.readline, "") >> >> for line in instream: >> print line.rstrip() >> >> I don't have Windows available to test, but if it works t

Re: How to add additional font face to Python 3.3.2 IDLE?

2013-08-23 Thread Terry Reedy
On 8/23/2013 11:49 AM, maildrago...@gmail.com wrote: How can I add for example Droid Sans Mono to python 3.3.2 IDLE? I'm not very familliar with font faces, really. I suspect that Idle just looks in the standard font directory of your system to make the list of available fonts that it display

Re: Python and mysql 3 tier programming

2013-08-23 Thread Jason Friedman
> System Debian Wheezy Linux > Python 2.7 > Mysql 5.5.31 > Apache Server > > I am somewhat conversant with html, css, SQL, mysql, Apache and Debian > Linux. Actually I have been using Debian for over 10 year. I spent over 5 > year, prior to retirement, programming database based applications in > F

Re: Python variable as a string

2013-08-23 Thread Vlastimil Brom
2013/8/23 Jake Angulo : > Sorry this is a very basic question. > > I have a list var which after some evaluation I need to refer to var as a > string. > > Pseudocode: > > var = ['a', 'b' , 'c' , 'd'] > adict = dict(var='string', anothervar='anotherstring') > anotherdict = dict() > if : > anothe

Re: Running a command line program and reading the result as it runs

2013-08-23 Thread random832
On Fri, Aug 23, 2013, at 7:14, Peter Otten wrote: > The following works on my linux system: > > instream = iter(p.stdout.readline, "") > > for line in instream: > print line.rstrip() > > I don't have Windows available to test, but if it works there, too, the > problem is the interna

Re: right adjusted strings containing umlauts

2013-08-23 Thread Kurt Mueller
Am 08.08.2013 18:37, schrieb Chris Angelico: > On Thu, Aug 8, 2013 at 5:16 PM, Kurt Mueller > wrote: >> Am 08.08.2013 17:44, schrieb Peter Otten: >>> Kurt Mueller wrote: What do I do, when input_strings/output_list has other codings like iso-8859-1? >>> You have to know the actual encodi

Re: Basic Python Query

2013-08-23 Thread Chris Angelico
On Fri, Aug 23, 2013 at 5:12 PM, Ulrich Eckhardt wrote: > Am 23.08.2013 05:28, schrieb Steven D'Aprano: >> >> On Thu, 22 Aug 2013 13:54:14 +0200, Ulrich Eckhardt wrote: >>> >>> When the Python object goes away, it doesn't necessarily affect >>> thethread or file it represents. >> >> >> That's cert

How to add additional font face to Python 3.3.2 IDLE?

2013-08-23 Thread maildragons1
How can I add for example Droid Sans Mono to python 3.3.2 IDLE? I'm not very familliar with font faces, really. Thank's! -- http://mail.python.org/mailman/listinfo/python-list

python interface to iMacros

2013-08-23 Thread inq1ltd
Python help, I am running iMacros from linux/firefox and doing most of what I want. But, there are times when I want to do something of the net and then back to the iMacros script. Are there any projects out there that will connect python to imacros, something on the order of pexpect? The

Re: How to send broadcast IP address to network?

2013-08-23 Thread Chris Angelico
On Fri, Aug 23, 2013 at 10:32 PM, wrote: > I want to send a broadcast packet to all the computers connected to my home > router. > > The following 2 lines of code do not work; > host="192.168.0.102" > s.connect((host, port)) > > Can someone advise? You can't establish a TCP socket with a broadc

Re: Can a child access parent attributes if that child added post-hoc as an attribute to the parent?

2013-08-23 Thread Bitswapper
On Thursday, August 22, 2013 5:00:38 PM UTC-5, Bitswapper wrote: > On Thursday, August 22, 2013 4:26:24 PM UTC-5, Prasad, Ramit wrote: > > > Bitswapper wrote: > > > > > > > > > > > > > > So I have a parent and child class: > > > > > > > > > > > > > > > > > > > > > class Map(object):

Re: What does sys.stdout.flush() do?

2013-08-23 Thread John Gordon
In "D. Xenakis" writes: > Can someone post here a script example with sys.stdout.flush(), where in > case i commented that i could understand what the difference really would > be? Depending what sys.stdout is connected to (a file, the screen, a pipe, etc.), data doesn't necessarily get writte

Re: Running a command line program and reading the result as it runs

2013-08-23 Thread Grant Edwards
On 2013-08-22, Chris Angelico wrote: > On Fri, Aug 23, 2013 at 1:26 AM, Ian Simcock > wrote: >> Chris Angelico wrote: >>> >>> Is the program actually producing output progressively? I just tried >>> your exact code with "dir /ad /s /b" and it worked fine, producing >>> output while the dir was sti

Re: Python variable as a string

2013-08-23 Thread Steven D'Aprano
On Fri, 23 Aug 2013 21:40:06 +1000, Jake Angulo wrote: > Sorry this is a very basic question. Not so much "basic" as confusing. > I have a list *var* which after some evaluation I need to refer to *var* > as a string. > > Pseudocode: > > var = ['a', 'b' , 'c' , 'd'] > adict = dict(var='string'

Re: Python variable as a string

2013-08-23 Thread Neil Cerutti
On 2013-08-23, Jake Angulo wrote: > I have a list *var* which after some evaluation I need to refer > to *var* as a string. You must make a str version of var. > Pseudocode: > > var = ['a', 'b' , 'c' , 'd'] > adict = dict(var='string', anothervar='anotherstring') > anotherdict = dict() > if : >

Re: PEPs should be included with the documentation download

2013-08-23 Thread Neil Cerutti
On 2013-08-23, Chris Angelico wrote: > I'm aware of that. However, I'm also aware that many people > still read things online, even with a less-than-reliable > internet connection. Hence the question: How many people > actually do use the downloaded docs? Maybe it'd turn out to be > quite high, bu

Re: How to send broadcast IP address to network?

2013-08-23 Thread Neil Cerutti
On 2013-08-23, lightai...@gmail.com wrote: >> The following 2 lines of code do not work; >> >> host="192.168.0.255" >> host="192.168.0.102" >> s.connect((host, port)) Traceback (most recent call last): File "", line 1, in NameError: name 's' is not defined I bet that's not the same traceback

Re: Using PyQT with QT Designer

2013-08-23 Thread Michael Staggs
I tried that this morning and it destroyed my form. So, right now, that's probably not what I'm looking for. But, if you look at that picture, the app isn't resized to 800x600 like it says in the ui file. The pixmaps aren't on the buttons like I set them up in the ui file. It's not using the ui fi

Re: How to send broadcast IP address to network?

2013-08-23 Thread lightaiyee
Some typo mistake. Should be host="192.168.0.255", not "192.168.0.102" On Friday, August 23, 2013 8:32:10 PM UTC+8, light...@gmail.com wrote: > I want to send a broadcast packet to all the computers connected to my home > router. > > > > The following 2 lines of code do not work; > > host="

How to send broadcast IP address to network?

2013-08-23 Thread lightaiyee
I want to send a broadcast packet to all the computers connected to my home router. The following 2 lines of code do not work; host="192.168.0.102" s.connect((host, port)) Can someone advise? Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: What does sys.stdout.flush() do?

2013-08-23 Thread Peter Otten
D. Xenakis wrote: > Somewhere i read.. > sys.stdout.flush(): Flush on a file object pushes out all the data that > has been buffered to that point. > > Can someone post here a script example with sys.stdout.flush(), where in > case i commented that i could understand what the difference really wo

Re: Running a command line program and reading the result as it runs

2013-08-23 Thread Gertjan Klein
Peter Otten wrote: The following works on my linux system: import subprocess p = subprocess.Popen( ["ping", "google.com"], stdout=subprocess.PIPE) instream = iter(p.stdout.readline, "") for line in instream: print line.rstrip() I don't have Windows available to test, but if i

What does sys.stdout.flush() do?

2013-08-23 Thread D. Xenakis
Somewhere i read.. sys.stdout.flush(): Flush on a file object pushes out all the data that has been buffered to that point. Can someone post here a script example with sys.stdout.flush(), where in case i commented that i could understand what the difference really would be? Whenever i try to re

Python variable as a string

2013-08-23 Thread Jake Angulo
Sorry this is a very basic question. I have a list *var* which after some evaluation I need to refer to *var* as a string. Pseudocode: var = ['a', 'b' , 'c' , 'd'] adict = dict(var='string', anothervar='anotherstring') anotherdict = dict() if : anotherdict[akey] = adict['var'] Basically im

Re: Running a command line program and reading the result as it runs

2013-08-23 Thread Peter Otten
Ian Simcock wrote: > Greetings all. > > I'm using Python 2.7 under Windows and am trying to run a command line > program and process the programs output as it is running. A number of > web searches have indicated that the following code would work. > > import subprocess > > p = subprocess.Popen

RE: Running a command line program and reading the result as it runs

2013-08-23 Thread Joseph L. Casale
> >> I'm using Python 2.7 under Windows and am trying to run a command line > >> program and process the programs output as it is running. A number of > >> web searches have indicated that the following code would work. > >> > >> import subprocess > >> > >> p = subprocess.Popen("D:\Python\Python27\

Re: Running a command line program and reading the result as it runs

2013-08-23 Thread Antoon Pardon
Op 23-08-13 11:53, Antoon Pardon schreef: > Op 22-08-13 07:51, Ian Simcock schreef: >> Greetings all. >> >> I'm using Python 2.7 under Windows and am trying to run a command line >> program and process the programs output as it is running. A number of >> web searches have indicated that the followi

Re: Running a command line program and reading the result as it runs

2013-08-23 Thread Antoon Pardon
Op 22-08-13 07:51, Ian Simcock schreef: > Greetings all. > > I'm using Python 2.7 under Windows and am trying to run a command line > program and process the programs output as it is running. A number of > web searches have indicated that the following code would work. > > import subprocess > >

Re: Running a command line program and reading the result as it runs

2013-08-23 Thread Gertjan Klein
Ian Simcock wrote: When I use this code I can see that the Popen works, any code between the Popen and the for will run straight away, but as soon as it gets to the for and tries to read p.stdout the code blocks until the command line program completes, then all of the lines are returned. Does

Re: PEPs should be included with the documentation download

2013-08-23 Thread Ben Finney
Ned Deily writes: > In article <7wvc2xkjvz@benfinney.id.au>, > Ben Finney wrote: > > Chris Angelico writes: > > > Hence the question: How many people actually do use the downloaded > > > docs? Maybe it'd turn out to be quite high, but it's not an > > > unreasonable question. > > > > I thi

Who run the Python for Google Native Client?

2013-08-23 Thread sepatan
Maybe someone from the Python community tried to run Python (with a possible set of standard library modules) under the Google Native Client in browser? If you have a positive experience, can share? -- http://mail.python.org/mailman/listinfo/python-list

Sergei Ivachev

2013-08-23 Thread sepatan
Maybe someone from the Python community tried to run Python (with a possible set of standard library modules) under the Google Native Client in browser? If you have a positive experience, can share? -- http://mail.python.org/mailman/listinfo/python-list

Re: PEPs should be included with the documentation download

2013-08-23 Thread Ned Deily
In article <7wvc2xkjvz@benfinney.id.au>, Ben Finney wrote: > Chris Angelico writes: > > Hence the question: How many people actually do use the downloaded > > docs? Maybe it'd turn out to be quite high, but it's not an > > unreasonable question. > > I think it's an unreasonable question. Wh

Re: Using PyQT with QT Designer

2013-08-23 Thread Phil Thompson
On Thu, 22 Aug 2013 18:08:14 -0700 (PDT), tausc...@gmail.com wrote: > On Thursday, August 22, 2013 3:26:17 AM UTC-5, Phil Thompson wrote: > >> It looks like you aren't using a layout to arrange your widgets. >> >> Explicitly specifying geometries is a bad idea. >> >> >> >> Phil > > Thanks.QT

Re: Basic Python Query

2013-08-23 Thread Ulrich Eckhardt
Am 23.08.2013 05:28, schrieb Steven D'Aprano: On Thu, 22 Aug 2013 13:54:14 +0200, Ulrich Eckhardt wrote: When the Python object goes away, it doesn't necessarily affect thethread or file it represents. > That's certainly not true with file objects. When the file object goes out of scope, the u

Re: Running a command line program and reading the result as it runs

2013-08-23 Thread Ian Simcock
Rob Wolfe wrote: Ian Simcock writes: When file object is used in a for loop it works like an iterator and then it uses a hidden read-ahead buffer. It might cause this kind of blocking. You can read more details here (description of method ``next``): http://docs.python.org/lib/bltin-file-objects