Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread Hansmeet Singh
REMEMBER STEVE On Wed, Oct 5, 2011 at 9:58 PM, Chris Angelico wrote: > On Thu, Oct 6, 2011 at 2:36 PM, alex23 wrote: > > On Oct 5, 11:10 pm, Chris Angelico wrote: > >> The absence from the language doesn't prove that. All it means is > >> that, on those rare occasions when a goto would have be

selenium pyvirtualdisplay script on remote server

2011-10-05 Thread sajuptpm
Hi Friends, Here the isuue is i can't find the "li" element. that is because that element is out of display, so i adjust scroll bar or do focus around that area to get that element via find_element_by_id("loc_opt") I already tested with scroll bar and focus and its working fine in my laptop. But

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Chris Angelico
On Thu, Oct 6, 2011 at 3:39 PM, Greg wrote: > Brilliant! It worked. Thanks! > > Here is the final code for those who are struggling with similar > problems: > > ## open and decode file > # In this case, the encoding comes from the charset argument in a meta > tag > # e.g. > fileContent = fileObj.

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread Chris Angelico
On Thu, Oct 6, 2011 at 2:36 PM, alex23 wrote: > On Oct 5, 11:10 pm, Chris Angelico wrote: >> The absence from the language doesn't prove that. All it means is >> that, on those rare occasions when a goto would have been correct, the >> programmer had to make do with something else :-) > > Like th

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Greg
Brilliant! It worked. Thanks! Here is the final code for those who are struggling with similar problems: ## open and decode file # In this case, the encoding comes from the charset argument in a meta tag # e.g. fileObj = open(filePath,"r").read() fileContent = fileObj.decode("iso-8859-2") fileSo

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread Westley Martínez
On Thu, Oct 06, 2011 at 02:44:33PM +1100, Cameron Simpson wrote: > On 03Oct2011 13:10, rantingrick wrote: > | Also for scoping. > | > | py> count = 0 > | py> def foo(): > | ... global.count += 1 > | py> print count > | 1 > | > | Why? Well because many times i find myself wondering if this or

Re: recommend a graphics library for plotting by the pixel?

2011-10-05 Thread Alec Taylor
Hehe, sure, why not? :P On Wed, Oct 5, 2011 at 2:24 PM, alex23 wrote: > On Oct 5, 12:53 am, Alec Taylor wrote: >> Sounds like a job for Processing... > > Don't you mean PyProcessing? :) > > http://code.google.com/p/pyprocessing/ > -- > http://mail.python.org/mailman/listinfo/python-list > -- h

Re: Convenient filtering in for cycles

2011-10-05 Thread alex23
On Oct 6, 2:55 am, Stefano Maggiolo wrote: > I would like to know if there is a (more) convenient way of doing this > structure: > > ===(1)=== > for x in l: >     if P(x): >         do_stuff(x) > == map(do_stuff, filter(P, l)) -- http://mail.python.org/mailman/listinfo/python-list

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Steven D'Aprano
On Wed, 05 Oct 2011 16:35:59 -0700, Greg wrote: > Hi, I am having some encoding problems when I first parse stuff from a > non-english website using BeautifulSoup and then write the results to a > txt file. If you haven't already read this, you should do so: http://www.joelonsoftware.com/article

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread Cameron Simpson
On 03Oct2011 13:10, rantingrick wrote: | Also for scoping. | | py> count = 0 | py> def foo(): | ... global.count += 1 | py> print count | 1 | | Why? Well because many times i find myself wondering if this or that | variable is local or global -- and when i say "global" i am speaking | of mod

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread alex23
Ben Finney wrote: > This mocking is hurtful to people who identify too strongly with COBOL. > I wonder whether that means it's intentionally hurtful. Far, _far_ less hurtful than COBOL itself... -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread alex23
On Oct 5, 11:10 pm, Chris Angelico wrote: > The absence from the language doesn't prove that. All it means is > that, on those rare occasions when a goto would have been correct, the > programmer had to make do with something else :-) Like the goto module? :) http://entrian.com/goto/ -- http://

Re: Convenient filtering in for cycles

2011-10-05 Thread Steven D'Aprano
On Wed, 05 Oct 2011 18:55:53 +0200, Stefano Maggiolo wrote: > Dear all, > > I would like to know if there is a (more) convenient way of doing this > structure: > > ===(1)=== > for x in l: > if P(x): > do_stuff(x) > == That seems pretty convenient to me. It's simple, obvious and

Re: syntax enhancement

2011-10-05 Thread Steven D'Aprano
On Wed, 05 Oct 2011 13:31:41 -0500, Tim Chase wrote: > I'm very -1 on the initial proposal with parens, but I wouldn't object > to generators growing a method (__getitem__?) to do slices via > itertools, something like > >gen = (a for a in iterator if test(a)) >for thing in gen[4::2]: >

Re: Writing file out to another machine

2011-10-05 Thread Terry Reedy
On 10/5/2011 5:31 PM, Chris Angelico wrote: On Thu, Oct 6, 2011 at 8:22 AM, John Gordon wrote: I assume he intended "S:" to indicate a remote server. The most obvious understanding of it is a drive letter (ie Windows box). More exactly, a remote server filesystem 'mounted' (not sure of the

encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Greg
Hi, I am having some encoding problems when I first parse stuff from a non-english website using BeautifulSoup and then write the results to a txt file. I have the text both as a normal (text) and as a unicode string (utext): print repr(text) 'Branie zak\xc2\xb3adnik\xc3\xb3w' print repr(utext) u

Re: syntax enhancement

2011-10-05 Thread Ian Kelly
On Wed, Oct 5, 2011 at 3:28 PM, Westley Martínez wrote: > Wait, how would this work fundamentally?  A list can be sliced because > all the values are there.  A generator does not have all its value at > once (it generates each value as requested).  I don't like change so I > look at these kinds of

Re: Writing file out to another machine

2011-10-05 Thread Chris Angelico
On Thu, Oct 6, 2011 at 8:22 AM, John Gordon wrote: > I assume he intended "S:" to indicate a remote server. > The most obvious understanding of it is a drive letter (ie Windows box). But if not, more clarification is needed. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax enhancement

2011-10-05 Thread Westley Martínez
On Wed, Oct 05, 2011 at 01:31:41PM -0500, Tim Chase wrote: > On 10/04/11 20:45, Terry Reedy wrote: > >On 10/4/2011 9:50 AM, Valiev Sergey wrote: > > > >>- `[]` - used for list comprehension, > >>- `()` - used for generators, > >>- `[start:stop]` / `[start:stop:step]` - used for slices. > >>The idea

Re: Writing file out to another machine

2011-10-05 Thread John Gordon
In Terry Reedy writes: > On 10/5/2011 10:34 AM, RVince wrote: > > I have a project whereby I need it to write out a file to a different > > server (that the originating server has write access to). So, say I > > need to write out from myserver1, where my app is running, onto, say > > S:/IT/tmp

Re: Writing file out to another machine

2011-10-05 Thread Terry Reedy
On 10/5/2011 10:34 AM, RVince wrote: I have a project whereby I need it to write out a file to a different server (that the originating server has write access to). So, say I need to write out from myserver1, where my app is running, onto, say S:/IT/tmp how can I specify/do this? Thanks, RVince

Re: syntax enhancement

2011-10-05 Thread Terry Reedy
On 10/5/2011 2:31 PM, Tim Chase wrote: On 10/04/11 20:45, Terry Reedy wrote: On 10/4/2011 9:50 AM, Valiev Sergey wrote: - `[]` - used for list comprehension, - `()` - used for generators, - `[start:stop]` / `[start:stop:step]` - used for slices. The idea is to use `(start:stop)` / `(start:stop

Re: syntax enhancement

2011-10-05 Thread Tim Chase
On 10/04/11 20:45, Terry Reedy wrote: On 10/4/2011 9:50 AM, Valiev Sergey wrote: - `[]` - used for list comprehension, - `()` - used for generators, - `[start:stop]` / `[start:stop:step]` - used for slices. The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy evaluated' slices (like

Re: Convenient filtering in for cycles

2011-10-05 Thread Stefano Maggiolo
Dear Ian, thank you for you kind response. I was pretty confident the issue had already been discussed, but I was unable to look it up. I suppose your "filter" syntax is the best given the options (I always forget about map and filter...) and definitely I see that the work needed to add such a fe

Re: Convenient filtering in for cycles

2011-10-05 Thread Ian Kelly
On Wed, Oct 5, 2011 at 11:24 AM, Ian Kelly wrote: >> Is there some better and valid construction I missed? If not, is there >> a reason why (2) is not in the language? > > I guess because, as you helpfully enumerated, there are already plenty > of options for iterating with a condition.  Syntax is

Re: Convenient filtering in for cycles

2011-10-05 Thread Ian Kelly
On Wed, Oct 5, 2011 at 10:55 AM, Stefano Maggiolo wrote: > Dear all, > > I would like to know if there is a (more) convenient way of doing this > structure: > > ===(1)=== > for x in l: >    if P(x): >        do_stuff(x) > == > > Let's say that my dream syntax would be > > ===(2)=== > for x in

Convenient filtering in for cycles

2011-10-05 Thread Stefano Maggiolo
Dear all, I would like to know if there is a (more) convenient way of doing this structure: ===(1)=== for x in l: if P(x): do_stuff(x) == Let's say that my dream syntax would be ===(2)=== for x in l if P(x): do_stuff(x) == as if it was the second part of a list comprehe

Re: recommend a graphics library for plotting by the pixel?

2011-10-05 Thread Westley Martínez
On Wed, Oct 05, 2011 at 02:29:38PM +0100, Adam Funk wrote: > On 2011-10-04, Derek Simkowiak wrote: > > > If this is strictly for 2D pixel graphics, I recommend using PyGame > > (aka SDL). Why do you not think it's the way to go? It was built for > > this type of thing. > > I only know Py

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread Westley Martínez
On Tue, Oct 04, 2011 at 08:20:34PM -0700, alex23 wrote: > Steven D'Aprano wrote: > > Imported modules are variables like any other, and as they usually exist > > in the global scope, so they will all need to be explicitly referenced as > > global. This will get tiresome very quickly, and is a cure

Re: Writing file out to another machine

2011-10-05 Thread John Gordon
In <0d795922-d946-480d-8f41-95656e56f...@g23g2000vbz.googlegroups.com> RVince writes: > I have a project whereby I need it to write out a file to a different > server (that the originating server has write access to). So, say I > need to write out from myserver1, where my app is running, onto, s

A tuple in order to pass returned values ?

2011-10-05 Thread faucheuse
Hi, (new to python and first message here \o/) I was wondering something : when you do : return value1, value2, value3 It returns a tuple. So if I want to pass these value to a function, the function have to look like : def function(self,(value1, value2, value3)) #self because i'm working with cl

Re: A tuple in order to pass returned values ?

2011-10-05 Thread Ulrich Eckhardt
Am 05.10.2011 15:33, schrieb faucheuse: I was wondering something : when you do : return value1, value2, value3 It returns a tuple. Right. So if I want to pass these value to a function, the function have to look like : def function(self,(value1, value2, value3)) [...] No, you don't have to

Re: A tuple in order to pass returned values ?

2011-10-05 Thread Dave Angel
On 01/-10/-28163 02:59 PM, faucheuse wrote: Hi, (new to python and first message here \o/) I was wondering something : when you do : return value1, value2, value3 It returns a tuple. So if I want to pass these value to a function, the function have to look like : def function(self,(value1, valu

Re: issue with pexpect

2011-10-05 Thread Daniel
Okey i figure it out how to do the job in fedora i added slight delay before sending each command either by the delaybeforesend attribute or by the time module ;) cheers On Wed, 2011-10-05 at 14:47 +0200, Nizamov Shawkat wrote: > 2011/10/5 Daniel <5960...@gmail.com>: > > Hello, > > For about wee

Re: A tuple in order to pass returned values ?

2011-10-05 Thread Daniel Dorani
this feature has been removed in python3 in accordance to the PEP 3113 (http://www.python.org/dev/peps/pep-3113/), you should consider using the * operator http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists . -- http://mail.python.org/mailman/listinfo/python-list

Re: eggbasket

2011-10-05 Thread Andrea Crotti
Well it was easy, apparently sqlalchemy.exceptions doesn't exist but sqlalchemy.exc does, and that's the correct one, maybe a version problem... I get another problem right after File "/home/andrea/PSI_refactor/test_local_pypi/lib/python2.7/site-packages/EggBasket-0.6.1b-py2.7.egg/eggbasket/c

Re: issue with pexpect

2011-10-05 Thread Daniel
there is no such implementation in fedora you can su as a root .. i can su from regular user to root with no problems the problem come when i use the pexpect module On Wed, 2011-10-05 at 14:47 +0200, Nizamov Shawkat wrote: > 2011/10/5 Daniel <5960...@gmail.com>: > > Hello, > > For about week i am

A tuple in order to pass returned values ?

2011-10-05 Thread faucheuse
Hi, (new to python and first message here \o/) I was wondering something : when you do : return value1, value2, value3 It returns a tuple. So if I want to pass these value to a function, the function have to look like : def function(self,(value1, value2, value3)) #self because i'm working with cl

httplib2 download forbidden

2011-10-05 Thread Mauro Zaccariotto
Hi! does anyone know what's happening here http://code.google.com/p/httplib2/ ? I get this: "403. That’s an error. Your client does not have permission to get URL /p/httplib2/ from this server. That’s all we know." It seems like the httplib2 googlecode project is preventing from accessing the proje

Re: recommend a graphics library for plotting by the pixel?

2011-10-05 Thread Adam Funk
On 2011-10-04, Derek Simkowiak wrote: > If this is strictly for 2D pixel graphics, I recommend using PyGame > (aka SDL). Why do you not think it's the way to go? It was built for > this type of thing. I only know PyGame because we did an exercise in recreating the old breakout game and m

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread Chris Angelico
On Wed, Oct 5, 2011 at 11:57 PM, Roy Smith wrote: > In article , >  Chris Angelico wrote: > >> Definitely. There's always a right time to do the wrong thing, just as >> much as there's a wrong time to do the right thing. Even the >> much-maligned goto has its place. > > Not in python, it doesn't

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread Roy Smith
In article , Chris Angelico wrote: > Definitely. There's always a right time to do the wrong thing, just as > much as there's a wrong time to do the right thing. Even the > much-maligned goto has its place. Not in python, it doesn't :-) But, yes, I agree that in languages that support it, it c

issue with pexpect

2011-10-05 Thread Daniel
Hello, For about week i am experiencing a problem with pexpect that's why i hope you can help me :). Following is my code which tries to remove some files from the root dir and the code works on linux debian and freebsd but with no success on linux fedora .. any idea why this happen only in fedora

socket.getsockname is returning junk!!

2011-10-05 Thread Wong Wah Meng-R32813
Hello guys, I am migrating my application from python 1.5.2 to 2.7.1. One of the existing code breaks. The getsockname method from socket object somehow returns me with some number which I deem as junk, rather than the listening port as I would have expected in the older python. Has anyone seen

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread Ben Finney
Steven D'Aprano writes: > import the module called 'math' into the current namespace and bind > that module to the name 'math' in the current namespace > > bind the name 'x' in the current namespace to the return result of > calling the attribute named 'sin' in the object currently bound to the >

issue with pexpect

2011-10-05 Thread Daniel
Hello, For about week i am experiencing a problem with pexpect that's why i hope you can help me :). Following is my code which tries to remove some files from the root dir and the code works on linux debian and freebsd but with no success on linux fedora .. any idea why this happen only in fedora

ImportError: No module named _sha256

2011-10-05 Thread Wong Wah Meng-R32813
Hello there, In migrating my application from python 1.5.2 to 2.7.1, I encountered an issue modules which utilizes _sha256 cannot be loaded. This includes hashlib, random and tempfile. I think this should be related to the build of my python 64-bit on HP11.31 using HP-UX compiler. I have tried

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-05 Thread Chris Angelico
On Wed, Oct 5, 2011 at 12:22 PM, Alan Meyer wrote: > Of course you'll need to be fair in evaluating the students comparisons. >  Some bright students are likely to come up with good reasons for using > globals in some situations, and they might even be right.  Or if they're not > completely right,