[Tutor] reading files

2014-01-29 Thread Gabriele Brambilla
Hi,
how could I read float numbers if the data format is like this (using
readline):

1.0551951.26758123387023-0.314470329249235
-0.293015360064208  6.157957619078221.92919102133526
13.07804596303782.15175351758512e6

the numbers aren't equally spaced and they had not the same number of
figures...

thanks

Gabriele
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] subprocess.Popen help

2014-01-29 Thread Mkhanyisi Madlavana
On 28 January 2014 21:52, leam hall  wrote:

> Python tutorial for 2.6 (using 2.4 -- don't ask), first code blurb under
> 17.1.1
>
>
> http://docs.python.org/2.6/library/subprocess.html?highlight=subprocess#subprocess.Popen
>
> How would you make an ssh to another box put data back in "p"? The
> goal is to run a shell command on a remote box and work with the
> output on the local host.
>

Popen is not meant for that. You should try the paramiko library.
http://www.lag.net/paramiko/
http://jessenoller.com/blog/2009/02/05/ssh-programming-with-paramiko-completely-different

Cheers
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] When is = a copy and when is it an alias

2014-01-29 Thread Denis Heidtmann
On Tue, Jan 28, 2014 at 5:19 PM, Alan Gauld wrote:

> On 28/01/14 19:00, Denis Heidtmann wrote:
>
>> On Tue, Jan 28, 2014 at 12:28 AM, spir >
>
> This is getting confusing with two times Denis!
>
>  > wrote:
>>
>> a = [1,[2,3]]
>>
>
> I think the above line is a mistake. If Denis(spir) had missed
> this out his code would work as he describes, but with it he
> reassigns 'a' to a new list and, as you say breaks the connection.
>
> If you forget about that line and keep a pointing at the original
> [1,[1,2]] list then the following code makes sense.
>
>
>  a[0] = 0
>> b
>>
>> [0, [1, 2]]  # this is where I get lost.
>>
>> a[1] = [0,0]
>> b
>>
>> [0, [0, 0]]
>>
>
>
>  My python gets a different result:
>>
>
> So does mine, and I suspect so does denis' (spir).
> I think he made a mistake with the second assignment to a.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.flickr.com/photos/alangauldphotos


Glad to hear it.  That is what I was hoping, but I did not want to question
a helpful person.

-Denis H.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Code runs in interpreter but won't output to stdout

2014-01-29 Thread scurvy scott
Hi guys, I'm trying to figure out why my code won't output to terminal, but
will run just fine in interpreter.
I'm using python 2.7.3 on Debian Linux/Crunchbang.

Here is my code.

import requests
from bs4 import BeautifulSoup as beautiful
import sys

def dogeScrape(username, password):
payload = {'username': username, 'password': password}
r = requests.post("http://dogehouse.org/index.php?page=login";,
data=payload)
soup = beautiful(r.text)
confirmed = str(soup.findAll('span',{'class':'confirmed'}))
print "Confirmed account balance: " + confirmed[86:98]

dogeScrape("", "")

It will output the "confirmed." part, just not the confirmed variable.
It will output the entire thing in the interpreter.

I initially ran this without being in a function with the username/password
stuff hardcoded to see if the rest of the scraper would run, it still never
output to stdout.

Any help would be appreciated.

Also, as an aside, is there a terminal/command line parsing library someone
could recommend? I've been looking at optparse but maybe some of you will
have other ideas.

thanks a lot,
Scott
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] reading files

2014-01-29 Thread Alan Gauld

On 29/01/14 02:09, Gabriele Brambilla wrote:

how could I read float numbers if the data format is like this (using
readline):

1.0551951.26758123387023-0.314470329249235
-0.293015360064208  6.157957619078221.92919102133526




the numbers aren't equally spaced and they had not the same number of
figures...


Just read the lines as strings and use str.split() to split them on 
whitespace. You will wind up with a list of numeric strings that

can be converted using float()

If you need more info just ask about the specific issue you get
stuck on (reading, splitting, converting etc).

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] reading files

2014-01-29 Thread Mark Lawrence

On 29/01/2014 02:09, Gabriele Brambilla wrote:

Hi,
how could I read float numbers if the data format is like this (using
readline):

1.0551951.26758123387023-0.314470329249235
-0.293015360064208  6.157957619078221.92919102133526
13.07804596303782.15175351758512e6

the numbers aren't equally spaced and they had not the same number of
figures...

thanks

Gabriele



Something like this, untested:-

floats = []
with open('myfile') as infile:
for line in infile:
floats.extend(float(f) for f in line.split())

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


Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] If, elif, else

2014-01-29 Thread Steven D'Aprano
On Tue, Jan 28, 2014 at 07:42:25PM -0500, Dave Angel wrote:
>  "Michael L. Pierre"  Wrote in message:
> > ___
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
> > 
> 
> Start by posting in text form, since this is a text group.  You
>  apparently posted in html. And you doublespaced.

Sorry Dave, your tools are letting you down again. Michael did in fact 
post with plain text. His original email included both a text/plain part 
and a text/html part.

Now I'm no friend of posting in HTML, I think it's a poor idea from both 
a technical and social perspective, but I also realise that the horse 
has bolted on that one. The best we can hope for is for mail clients to 
do the right thing when posting in HTML and also provide a plain text 
version. If your client is unable to deal with that, you need a better 
client.


> Any reason you didn't use the date module?  The code would have
>  been much simpler. 

'Cos he's a newbie and probably doesn't know about the date module :-)



-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] When is = a copy and when is it an alias

2014-01-29 Thread spir

On 01/29/2014 02:34 AM, Denis Heidtmann wrote:

Glad to hear it.  That is what I was hoping, but I did not want to question
a helpful person.


(you could & should, we need helpful feedback too, to improve our skills; i 
mean, as long as it's honest indeed)


d
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] reading files

2014-01-29 Thread Gabriele Brambilla
thanks to everyone, I've used David's method.

Gabriele


2014-01-29 Mark Lawrence 

> On 29/01/2014 02:09, Gabriele Brambilla wrote:
>
>> Hi,
>> how could I read float numbers if the data format is like this (using
>> readline):
>>
>> 1.0551951.26758123387023-0.314470329249235
>> -0.293015360064208  6.157957619078221.92919102133526
>> 13.07804596303782.15175351758512e6
>>
>> the numbers aren't equally spaced and they had not the same number of
>> figures...
>>
>> thanks
>>
>> Gabriele
>>
>>
> Something like this, untested:-
>
> floats = []
> with open('myfile') as infile:
> for line in infile:
> floats.extend(float(f) for f in line.split())
>
> --
> My fellow Pythonistas, ask not what our language can do for you, ask what
> you can do for our language.
>
> Mark Lawrence
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] help with data insert into Access table

2014-01-29 Thread Ahmed, Shakir
Hi,

I am trying to insert a record in the access table, the value has a quote and 
could not insert the record. Any idea how I can insert records like this quotes.

Thanks
S


cursor.execute("INSERT INTO PicsPostInfo(Pics_name) values ('Site Name's 
Harbor.JPG')")
Traceback (most recent call last):
  File "", line 1, in 
ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Microsoft Access Driver] 
Syntax error (missing operator) in query expression ''Site Name's 
Harbor.JPG')'. (-3100) (SQLExecDirectW)")


We value your opinion. Please take a few minutes to share your comments on the 
service you received from the District by clicking on this 
link.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] If, elif, else

2014-01-29 Thread Dave Angel
 Steven D'Aprano  Wrote in message:

> 
> Sorry Dave, your tools are letting you down again. Michael did in fact 
> post with plain text. His original email included both a text/plain part 
> and a text/html part.
> 
> Now I'm no friend of posting in HTML, I think it's a poor idea from both 
> a technical and social perspective, but I also realise that the horse 
> has bolted on that one. The best we can hope for is for mail clients to 
> do the right thing when posting in HTML and also provide a plain text 
> version. If your client is unable to deal with that, you need a better 
> client.
> 
> 

On android,  I'm using "nntp NewsReader". The author already fixed
 two other problems,  but this one is that replies to many
 messages will not copy the quoted part. All that gets copied is
 the tutor boilerplate. 

For now I'll just abort my replies when that happens. 


>> 
> 


-- 
DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] reading files

2014-01-29 Thread Mark Lawrence

On 29/01/2014 14:50, Gabriele Brambilla wrote:

thanks to everyone, I've used David's method.

Gabriele

2014-01-29 Mark Lawrence mailto:breamore...@yahoo.co.uk>>

On 29/01/2014 02:09, Gabriele Brambilla wrote:

Hi,
how could I read float numbers if the data format is like this
(using
readline):

1.0551951.26758123387023-0.314470329249235
-0.293015360064208  6.157957619078221.92919102133526
13.07804596303782.15175351758512e6

the numbers aren't equally spaced and they had not the same
number of
figures...

thanks

Gabriele


Something like this, untested:-

floats = []
with open('myfile') as infile:
 for line in infile:
 floats.extend(float(f) for f in line.split())

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

Mark Lawrence



Please don't top post.

FTR what is David's method and who is David?

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


Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with data insert into Access table

2014-01-29 Thread Peter Otten
Ahmed, Shakir wrote:

> I am trying to insert a record in the access table, the value has a quote
> and could not insert the record. Any idea how I can insert records like
> this quotes.

> cursor.execute("INSERT INTO PicsPostInfo(Pics_name) values ('Site Name's
> Harbor.JPG')") Traceback (most recent call last):
>   File "", line 1, in 
> ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Microsoft Access
> Driver] Syntax error (missing operator) in query expression ''Site Name's
> Harbor.JPG')'. (-3100) (SQLExecDirectW)")

Every compliant database module has a paramstyle attribute, e. g. for 
sqlite3:

>>> import sqlite3
>>> sqlite3.paramstyle
'qmark'

"qmark" means that you use "?" instead of the actual value.
http://www.python.org/dev/peps/pep-0249/ has a list of available 
`paramstyle`s.

Assuming that the database driver you are using uses "qmark" your code would 
become

cursor.execute("INSERT INTO PicsPostInfo(Pics_name) VALUES (?)",
   ("Site Name's Harbor.JPG",))

i. e. in addition to the SQL statement there is a tuple (in this case a 1-
tuple, the trailing comma is necessary!) holding the values. This way is the 
only reasonable way to go when the actual data is provided by your users 
because it prevents SQL injection attacks.

See also http://xkcd.com/327/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with data insert into Access table

2014-01-29 Thread Mark Lawrence

On 29/01/2014 16:46, Peter Otten wrote:

Ahmed, Shakir wrote:


I am trying to insert a record in the access table, the value has a quote
and could not insert the record. Any idea how I can insert records like
this quotes.



cursor.execute("INSERT INTO PicsPostInfo(Pics_name) values ('Site Name's
Harbor.JPG')") Traceback (most recent call last):
   File "", line 1, in 
ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Microsoft Access
Driver] Syntax error (missing operator) in query expression ''Site Name's
Harbor.JPG')'. (-3100) (SQLExecDirectW)")


Every compliant database module has a paramstyle attribute, e. g. for
sqlite3:


import sqlite3
sqlite3.paramstyle

'qmark'

"qmark" means that you use "?" instead of the actual value.
http://www.python.org/dev/peps/pep-0249/ has a list of available
`paramstyle`s.

Assuming that the database driver you are using uses "qmark" your code would
become

cursor.execute("INSERT INTO PicsPostInfo(Pics_name) VALUES (?)",
("Site Name's Harbor.JPG",))

i. e. in addition to the SQL statement there is a tuple (in this case a 1-
tuple, the trailing comma is necessary!) holding the values. This way is the
only reasonable way to go when the actual data is provided by your users
because it prevents SQL injection attacks.

See also http://xkcd.com/327/



I think it's worth pointing out that there is a difference here between 
the OP's 'Site Name's Harbor.JPG' and Peter's "Site Name's Harbor.JPG". 
 Left as homework for the newbies :)


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


Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Project directory structure

2014-01-29 Thread Reuben
Hi,

Do we need to follow any particular directory structure for creating any
New projects or could we just randomly create a folder containing the
script of interest?

Regards,
Reuben
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with data insert into Access table

2014-01-29 Thread Ahmed, Shakir
Thanks, it worked exactly what I was trying to do so.

-Original Message-
From: Tutor [mailto:tutor-bounces+shahmed=sfwmd@python.org] On Behalf Of 
Peter Otten
Sent: Wednesday, January 29, 2014 11:47 AM
To: tutor@python.org
Subject: Re: [Tutor] help with data insert into Access table

Ahmed, Shakir wrote:

> I am trying to insert a record in the access table, the value has a quote
> and could not insert the record. Any idea how I can insert records like
> this quotes.

> cursor.execute("INSERT INTO PicsPostInfo(Pics_name) values ('Site Name's
> Harbor.JPG')") Traceback (most recent call last):
>   File "", line 1, in 
> ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Microsoft Access
> Driver] Syntax error (missing operator) in query expression ''Site Name's
> Harbor.JPG')'. (-3100) (SQLExecDirectW)")

Every compliant database module has a paramstyle attribute, e. g. for
sqlite3:

>>> import sqlite3
>>> sqlite3.paramstyle
'qmark'

"qmark" means that you use "?" instead of the actual value.
http://www.python.org/dev/peps/pep-0249/ has a list of available
`paramstyle`s.

Assuming that the database driver you are using uses "qmark" your code would
become

cursor.execute("INSERT INTO PicsPostInfo(Pics_name) VALUES (?)",
   ("Site Name's Harbor.JPG",))

i. e. in addition to the SQL statement there is a tuple (in this case a 1-
tuple, the trailing comma is necessary!) holding the values. This way is the
only reasonable way to go when the actual data is provided by your users
because it prevents SQL injection attacks.

See also http://xkcd.com/327/





We value your opinion. Please take a few minutes to share your comments on the 
service you received from the District by clicking on this 
link.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with data insert into Access table

2014-01-29 Thread Keith Winston
On Wed, Jan 29, 2014 at 12:11 PM, Mark Lawrence  wrote:
> I think it's worth pointing out that there is a difference here between the
> OP's 'Site Name's Harbor.JPG' and Peter's "Site Name's Harbor.JPG".  Left as
> homework for the newbies :)


I'll bite. But are you just referring to the tuple issue, reinforced
by the XKCD, that Peter referred to, or have I not finished this
homework?

-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with data insert into Access table

2014-01-29 Thread Mark Lawrence

On 29/01/2014 19:47, Keith Winston wrote:

On Wed, Jan 29, 2014 at 12:11 PM, Mark Lawrence  wrote:

I think it's worth pointing out that there is a difference here between the
OP's 'Site Name's Harbor.JPG' and Peter's "Site Name's Harbor.JPG".  Left as
homework for the newbies :)



I'll bite. But are you just referring to the tuple issue, reinforced
by the XKCD, that Peter referred to, or have I not finished this
homework?



Nothing to do with tuples.  Tools such as syntax checkers or MkI 
eyeballs come in useful here.  Although such tools probably won't pick 
up the incorrect spelling of "harboUr" :)


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


Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with data insert into Access table

2014-01-29 Thread Keith Winston
On Wed, Jan 29, 2014 at 3:03 PM, Mark Lawrence  wrote:
> Nothing to do with tuples.  Tools such as syntax checkers or MkI eyeballs
> come in useful here.  Although such tools probably won't pick up the
> incorrect spelling of "harboUr" :)

Alas, now I'm more confused. I don't see any mispellings in what you
referred to? I had the impression that Peter was employing tuples
because, as an immutable type, it couldn't
inadvertently/inauspiciously be changed by a user. Oh, I see... single
vs. double, eh? Got it.


-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Code runs in interpreter but won't output to stdout

2014-01-29 Thread bob gailer

On 1/28/2014 9:12 PM, scurvy scott wrote:
Hi guys, I'm trying to figure out why my code won't output to 
terminal, but will run just fine in interpreter.

I'm using python 2.7.3 on Debian Linux/Crunchbang.

Here is my code.

import requests
from bs4 import BeautifulSoup as beautiful
import sys

def dogeScrape(username, password):
payload = {'username': username, 'password': password}
r = requests.post("http://dogehouse.org/index.php?page=login";, 
data=payload)

soup = beautiful(r.text)
confirmed = str(soup.findAll('span',{'class':'confirmed'}))
print "Confirmed account balance: " + confirmed[86:98]

dogeScrape("", "")

It will output the "confirmed." part, just not the confirmed 
variable. It will output the entire thing in the interpreter.


Good reminder for everyone: be explicit about behavior. We wasted an 
iteration just to get this clarified.


The expression to be printed is the concatenation of "Confirmed account 
balance: " with a slice of confirmed. Therefore confirmed is less that 
86 characters (or the slice is blank), therefore no output appears. 
Print the entire value of confirmed; that will tell us a lot.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with data insert into Access table

2014-01-29 Thread eryksun
On Wed, Jan 29, 2014 at 3:53 PM, Keith Winston  wrote:
> I had the impression that Peter was employing tuples because,
> as an immutable type, it couldn't inadvertently/inauspiciously
> be changed by a user

Per footnote 5 of PEP 249, the parameters need to be in a type that
supports __getitem__ (sequence or mapping). In addition to the qmark
paramstyle, pysqlite (the development name for the sqlite3 module)
supports named parameters:

http://docs.python.org/3/library/sqlite3#sqlite3.Cursor.execute

For a tuple or list of parameters, pysqlite uses the PyTuple and
PyList concrete APIs, respectively. Else for tuple/list subclasses, or
other sequence types, it uses the abstract PySequence API.

Tuples are the sequence of choice because they're allocated more
efficiently, with deallocated tuples cached by size (up to length 20).
Additionally, a tuple of constants is stored directly in the code
object (allowed because it's immutable), while a list has to be built
each time the code is evaluate. For example:

>>> code = (lambda: ("Site Name's Harbor.JPG",)).__code__

>>> code.co_consts
(None, "Site Name's Harbor.JPG", ("Site Name's Harbor.JPG",))

For a dict with named parameters, pysqlite uses the PyDict concrete
API. For a dict subclass (e.g. defaultdict, OrderedDict) it falls back
on the abstract PyMapping API.

Relevant sqlite3 C APIs:

sqlite3_bind_parameter_count
sqlite3_bind_parameter_name

https://www.sqlite.org/c3ref/bind_parameter_count.html
https://www.sqlite.org/c3ref/bind_parameter_name.html

sqlite3_bind_null
sqlite3_bind_int64
sqlite3_bind_double
sqlite3_bind_text
sqlite3_bind_blob

https://www.sqlite.org/c3ref/bind_blob.html
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] reading files

2014-01-29 Thread David Palao
2014-01-29 Mark Lawrence :
> On 29/01/2014 14:50, Gabriele Brambilla wrote:
>>
>> thanks to everyone, I've used David's method.
>>
>> Gabriele
>>
>> 2014-01-29 Mark Lawrence > >
>>
>>
>> On 29/01/2014 02:09, Gabriele Brambilla wrote:
>>
>> Hi,
>> how could I read float numbers if the data format is like this
>> (using
>> readline):
>>
>> 1.0551951.26758123387023-0.314470329249235
>> -0.293015360064208  6.157957619078221.92919102133526
>> 13.07804596303782.15175351758512e6
>>
>> the numbers aren't equally spaced and they had not the same
>> number of
>> figures...
>>
>> thanks
>>
>> Gabriele
>>
>>
>> Something like this, untested:-
>>
>> floats = []
>> with open('myfile') as infile:
>>  for line in infile:
>>  floats.extend(float(f) for f in line.split())
>>
>> --
>> My fellow Pythonistas, ask not what our language can do for you, ask
>> what you can do for our language.
>>
>> Mark Lawrence
>>
>
> Please don't top post.
>
> FTR what is David's method and who is David?
>
>
> --
> My fellow Pythonistas, ask not what our language can do for you, ask what
> you can do for our language.
>
> Mark Lawrence
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

I guess he refers to my email, the first answer to his question.

Best regards.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: reading files

2014-01-29 Thread David Palao
...that I forgot to send to the mailing list...


-- Forwarded message --
From: David Palao 
Date: 2014-01-29
Subject: Re: [Tutor] reading files
To: Gabriele Brambilla 


Hi,
One possibility I can think of: If you make one string with one line
of your input, like
s = "1.0551951.26758123387023
-0.314470329249235 -0.293015360064208  6.15795761907822
1.92919102133526 13.07804596303782.15175351758512e6"
then
L = [float(i) for i in s.split()]
is a list of the floats you are looking for.

Best.

2014-01-29 Gabriele Brambilla :
> Hi,
> how could I read float numbers if the data format is like this (using
> readline):
>
> 1.0551951.26758123387023-0.314470329249235
> -0.293015360064208  6.157957619078221.92919102133526
> 13.07804596303782.15175351758512e6
>
> the numbers aren't equally spaced and they had not the same number of
> figures...
>
> thanks
>
> Gabriele
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] imaplib and mutt flags

2014-01-29 Thread Bill Campbell
I'm writing a python script which uses imaplib to select all
unseen messages from a mail folder to process some messages
flagging them as seen, and leaving others as unseen so they can
be manually processed using the 'mutt' mail client.

After some trial and error, I've figured out how to remove the
\Seen flag from messages I want to look at manually, but I still
have a bit of a problem in that when I open the folder with mutt
using direct access to the Maildir folder in the file system,
mutt flags these parsed but unseen messages with the 'O' instead
of 'N' which is uses for new messages.

I would like to have the script restore the 'N' status flag that
mutt uses instead of 'O'.

The mail server is using courier-imap with Maildir stores on
CentOS Linux.  Mutt access is direct on the file system, not via
IMAP.

Bill
-- 
INTERNET:   b...@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:  (206) 236-1676  Mercer Island, WA 98040-0820
Fax:(206) 232-9186  Skype: jwccsllc (206) 855-5792

Political language... is designed to make lies sound truthful and
murder respectable, and to give an appearance of solidity to pure
wind. -- George Orwell
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python shell wont open IDLE or an exisiting .py files

2014-01-29 Thread Ben Finney
Terry Reedy  writes:

> On 1/29/2014 6:26 PM, shangonich...@sbcglobal.net wrote:
> >  > If I launch the Python GUI it opens a Python Shell fine. But as
> >  > soon as I try to open a file (including a "new" file), it closes
> >  > the Shell.
>
> This I do not. What is 'Python GUI'? What is 'Python Shell'?

Those are (part of) the names of menu entries created by the Python
installer for MS Windows. I am not sure exactly what programs they
invoke.

-- 
 \   “… whoever claims any right that he is unwilling to accord to |
  `\ his fellow-men is dishonest and infamous.” —Robert G. |
_o__)   Ingersoll, _The Liberty of Man, Woman and Child_, 1877 |
Ben Finney

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python shell wont open IDLE or an exisiting .py files

2014-01-29 Thread eryksun
On Wed, Jan 29, 2014 at 11:16 PM, Ben Finney  wrote:
> Terry Reedy  writes:
>
>> This I do not. What is 'Python GUI'? What is 'Python Shell'?
>
> Those are (part of) the names of menu entries created by the Python
> installer for MS Windows. I am not sure exactly what programs they
> invoke.

The above reply was cross-posted from the following thread on python-list:

https://mail.python.org/pipermail/python-list/2014-January/thread.html#665549

The Windows start menu has a shortcut for "IDLE (Python GUI)" that
runs the idle.pyw script. The file extension .pyw is associated with
either pythonw.exe or the launcher pyw.exe, which are both linked as
GUI programs. That means the process is created without an attached
console (one can be allocated or attached later using Windows API
calls).

idle.pyw imports idlelib.PyShell and calls its `main`. The shell
itself is implemented by the PyShell class, for which the window title
is

"Python " + platform.python_version() + " Shell"

http://hg.python.org/cpython/file/c3896275c0f6/Lib/idlelib/PyShell.py#l829

Also, the editor window's run menu has a "Python Shell" item:

('run', [('Python Shell', '<>')])

http://hg.python.org/cpython/file/c3896275c0f6/Lib/idlelib/Bindings.py#l59
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor