Re: Variables in a loop, Newby question

2013-12-25 Thread Larry Hudson

On 12/24/2013 08:07 AM, vanommen.rob...@gmail.com wrote:
[snip...]

x = 1
while x <> 10
var x = x
x = x + 1

[snip...]

Besides the other valid answers you have received, I want to add one other minor nit.  The 
symbol <> for unequal is deprecated -- it's better to use != instead.  Although, as was also 
pointed out, in this particular case you want < (less than) rather than unequal.


 -=- Larry -=-

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


Re: Insert NULL into mySQL datetime

2013-12-25 Thread Peter Otten
Igor Korot wrote:

> Hi, ALL,
> I am working on  a script that parses CSV file and after successful
> parsing insert data ino mySQL table.
> One of the fields in CSV holds a date+time value.
> 
> What the script should do is check if the cell has any data, i.e. not
> empty and then make sure that the data is date+time.
> If the validation fails, it should insert NULL into the mySQL datetime
> field, otherwise the actual datetime will be inserted.
> 
> Right now the script uses a placeholder "-00-00 00:00:00.000" if
> the date validation fails (either cell is empty or it has wrong data)
> 
> What I tried so far is:
> 
> C:\Documents and Settings\Igor.FORDANWORK\My
> Documents\GitHub\image_export\Artef acts>python
> Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
 import MySQLdb as mdb
 conn = mdb.connect('127.0.0.1','root','pass')
 cur = conn.cursor()
 a = None
 cur.execute("Use mydb")
> 0L
 cur.execute("Insert Into mytable(datefield) VALUES(STR_TO_DATE(%s))",
 a)

The second argument to execute has to be a tuple. Try

cur.execute("INSERT...", (a,))


> Traceback (most recent call last):
>   File "", line 1, in 
>   File "c:\python27\lib\site-packages\MySQLdb\cursors.py", line 202, in
>   execute
> self.errorhandler(self, exc, value)
>   File "c:\python27\lib\site-packages\MySQLdb\connections.py", line
> 36, in defaulterrorhandler
> raise errorclass, errorvalue
> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL
> syntax ; check the manual that corresponds to your MySQL server version
> for the right syntax to use near '%s))' at line 1")
 a = ""
 cur.execute("Insert Into mytable(datefield) VALUES(STR_TO_DATE(%s))",
 a)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "c:\python27\lib\site-packages\MySQLdb\cursors.py", line 202, in
>   execute
> self.errorhandler(self, exc, value)
>   File "c:\python27\lib\site-packages\MySQLdb\connections.py", line
> 36, in defaulterrorhandler
> raise errorclass, errorvalue
> _mysql_exceptions.OperationalError: (1582, "Incorrect parameter count
> in the call to native function 'STR_TO_DATE'")

> 
> Is it possible to do what I want?
> I'd like to use one query to insert the data into the table.
> 
> Thank you.


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


Re: Airplane mode control using Python?

2013-12-25 Thread rurpy
On 12/23/2013 01:46 AM, Chris Angelico wrote:
> On Mon, Dec 23, 2013 at 5:59 PM,   wrote:
>> On Sunday, December 22, 2013 10:37:35 PM UTC-7, Chris Angelico wrote:
>>> Actually, formatting errors ARE often caused by Google Groups. Maybe
>>> it wasn't in this instance, but I have seen several cases of GG
>>> mangling code formatting, so this was a perfectly reasonable theory.
>>
>> And you have determined format errors are coming from GG how exactly?
>> You would need to know the original contents entered into GG, yes?
>> Perhaps you have done experiments to determine these errors that you
>> could share with us?
> 
> Previous people's posts to this very list. Search the archives, you
> know this to be true!

No I don't.  (To be clear: I and you are not talking 
about the quoting problem but with trashing whitespace 
to a degree greater than other mail/usenet software 
does.)
  
If you don't know what was entered into the posting 
interface how can you say with such certainty that 
what was received was different?

> Why, rurpy, do you continue to support, apologize for, and argue in
> favour of, a piece of software that (a) you know to be buggy, and (b)
> has perfectly viable alternatives?

I have addressed this several times already.  All 
software is buggy.  I even posted long list on the
problems I've had with Thunderbird.  Choosing any 
software is making a tradeoff of one set of features/-
bugs versus another.  For you, with your experience, 
goals and use of the list, there is one tradeoff.  
Others with different experience, goals and use of 
the list may well choose different tradeoffs.

Yet you persist in ignoring that, persist in insisting
that tradeoffs that work for you are best for everyone.

Why do you refuse to see and acknowledge that the work 
involved in subscribing to a list, managing the volume
of mail, and unsubscribing after (to say nothing of 
figuring out arcane usenet), is a lot bigger pain 
than a half dozen mouse clicks to read and post from
GG for many people?

>[...]
> But avoiding Google Groups just means using gmane or
> Thunderbird or python-list, and you get all the same content without
> any loss. So why stick to something that sends mail with mess all over
> it?

It is not (as I just explained to you (yet again) *just*
a matter of using TB or Gmane.  You really need to learn
that your opinion of things is not the gold standard for
the rest of the world.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Google Groups + this list

2013-12-25 Thread rurpy
On 12/23/2013 09:12 AM, Chris Angelico wrote:
> On Mon, Dec 23, 2013 at 5:09 PM,   wrote:
>> On Sunday, December 22, 2013 10:37:35 PM UTC-7, Chris Angelico wrote:
>>> Actually, formatting errors ARE often caused by Google Groups. Maybe
>>> it wasn't in this instance, but I have seen several cases of GG
>>> mangling code formatting, so this was a perfectly reasonable theory.
>>
>> What sort of formatting errors have you seen and how did you
>> determine it was Google Groups fault?  You would need to know
>> what the original message was, wouldn't you?  Perhaps these
>> were experiments you carried out yourself that you could share
>> with us?
> 
> Unless people were lying through their teeth when they said that their
> posted code had worked on their system,

I don't recall many whitespace-broken posts where
the poster claimed it wasn't what they posted.  In 
the cases I remember they are chided about not copying
and pasting and they either do so or don't respond
further.  

As for lying, people sometimes lie because they 
don't want to admit a mistake.  Or they often are 
just genuinely mistaken (memory is a complex and 
unreliable thing).  So your cynical presumption 
that they must be "lying through their teeth" or 
telling the truth is not is not credible.

And there is more than GG involved when you get a
message from GG.  It has long been a criticism of 
Python's significant whitespace that it is easily 
corrupted by message transports and those criticisms
predate GG.

So, assuming I was actually was unlucky enough to 
miss all the OP claims that GG FU'd their posts
that you claim to have seen, there are still plenty 
of other possible reasons for whitespace corruption
beyond GG.

> I can be pretty sure it was
> the fault of the delivery mechanism.

Bad logic.  *You* can be sure on whatever basis you 
want but to convince anyone else not predisposed to 
your biases, you need quite a bit more than your 
handwaving.

For all I know, you may be right.  But you've not
presented any evidence.  I post from GG and I've not 
noticed any whitespace corruption problems.

> Dig through the archive.

Err, no thanks.  I don't have hours to waste chasing 
down your dubious assertions.  How about you do that 
instead?  And show that the rate is much higher from 
GG than other sources proportionally and that difference
is due to GG and not just a difference in the experience
or skill of the posting populations, or gateway problems
etc.  

> Also,
> you haven't answered the other part of the post, the more important
> part.

Refresh my memory please.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Airplane mode control using Python?

2013-12-25 Thread Chris Angelico
On Wed, Dec 25, 2013 at 12:37 PM,   wrote:
> I have addressed this several times already.  All
> software is buggy.  I even posted long list on the
> problems I've had with Thunderbird.  Choosing any
> software is making a tradeoff of one set of features/-
> bugs versus another.  For you, with your experience,
> goals and use of the list, there is one tradeoff.
> Others with different experience, goals and use of
> the list may well choose different tradeoffs.

Give me an example of how Thunderbird's problems force *every other
reader* to suffer under them and maybe I'll believe that it's
equivalent.

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


Re: Google Groups + this list

2013-12-25 Thread Ned Batchelder

On 12/24/13 8:47 PM, ru...@yahoo.com wrote:

On 12/23/2013 09:12 AM, Chris Angelico wrote:


Also,
you haven't answered the other part of the post, the more important
part.


Refresh my memory please.



Ugh, stop!  We get it: you don't think Google Groups is bad.  Or you 
think it can be made to work, or something.  That's fine.  But you are 
going to have to reason a little more subtly than, "all software has bugs."


As Chris has pointed out, the bugs in Google Groups affect every reader 
of the list.  Bugs in other software don't, at least not to the same extent.


Rurpy, you seem to be willfully ignoring the aggravation people are 
experiencing.  And people who hate Google Groups: you seem to be 
overlooking the fact that it's difficult for the users of Google Groups 
to understand its flaws, or to see the effect it has on the list.


I'll repeat my proposal (for everyone):

1) Don't fault newcomers for using Google Groups.  Politely suggest 
alternatives, but only if you are also helping them, or if they have 
already gotten help.


2) Be careful how you rail against Google Groups.  When you call its 
results "crap" (for example), it can sound like an insult to the poster. 
 You mean to refer to Google Groups, but remember you are also 
referring to the poster's words.


3) Don't let's get into protracted internal debates about Google Groups. 
 It is for the moment at least, an unavoidable part of this list.


Do you disagree?

--
Ned Batchelder, http://nedbatchelder.com

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


Re: Google Groups + this list

2013-12-25 Thread Joel Goldstick
On Wed, Dec 25, 2013 at 7:19 AM, Ned Batchelder wrote:

> On 12/24/13 8:47 PM, ru...@yahoo.com wrote:
>
>> On 12/23/2013 09:12 AM, Chris Angelico wrote:
>>
>>  Also,
>>> you haven't answered the other part of the post, the more important
>>> part.
>>>
>>
>> Refresh my memory please.
>>
>>
> Ugh, stop!  We get it: you don't think Google Groups is bad.  Or you think
> it can be made to work, or something.  That's fine.  But you are going to
> have to reason a little more subtly than, "all software has bugs."
>
> As Chris has pointed out, the bugs in Google Groups affect every reader of
> the list.  Bugs in other software don't, at least not to the same extent.
>
> Rurpy, you seem to be willfully ignoring the aggravation people are
> experiencing.  And people who hate Google Groups: you seem to be
> overlooking the fact that it's difficult for the users of Google Groups to
> understand its flaws, or to see the effect it has on the list.
>
> I'll repeat my proposal (for everyone):
>
>
> 1) Don't fault newcomers for using Google Groups.  Politely suggest
> alternatives, but only if you are also helping them, or if they have
> already gotten help.
>
> 2) Be careful how you rail against Google Groups.  When you call its
> results "crap" (for example), it can sound like an insult to the poster.
>  You mean to refer to Google Groups, but remember you are also referring to
> the poster's words.
>
> 3) Don't let's get into protracted internal debates about Google Groups.
>  It is for the moment at least, an unavoidable part of this list.
>
> Do you disagree?
>
>
> --
> Ned Batchelder, http://nedbatchelder.com
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


I'm with Ned.  Ned you do a great job lowering the temperature here.  This
group has lots of signal, but alas lots and lots of noise.

So, even though its not my holiday, Merry Christmas to all of you
knuckleheads, and good people!
-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using asyncio in event-driven network library

2013-12-25 Thread Christian Gollwitzer

Am 24.12.13 16:41, schrieb Tobias M.:

On 23.12.2013 20:59, Terry Reedy wrote:

What would be easiest for user-developers would be if someone were
able to wrap a gui loop in a way to give it the needed interface, so
the gui loop itself replaced and became the asyncio loop.


That's a good idea, maybe I will try this. On the other hand this means
that for every gui toolkit there must be a separate wrapper. I hoped this can
be avoided.


To be done properly, it needs to be adapted for every toolkit. But the 
good news is, that it has already been achieved: IPython is able to 
integrate the readline library into all major GUI toolkits (%gui). Maybe 
you can rip off the code from there.



On 23.12.2013 17:47, Chris Angelico wrote:

while gtk.events_pending(): gtk.main_iteration()

No doubt other toolkits have something similar.

On 23.12.2013 20:59, Terry Reedy wrote:

I think tk(inter) has 'run pending events' or something.


In Tk(inter) it is "update"


I didn't know functions like this exist in gui toolkits. Am I right in
thinking that using these functions you don't have to use the built-in
event loop. Instead you can write your own loop and just call 'run
pending events' continuously?


As Chris already explained, you then lose the advantages of the 
asynchronous operation. The reason behind the toolkits insisting on 
their main loop being run is, that they can wait for an event in a 
blocking way. Typically, under Linux, they call select() and on Windows 
WaitForMultipleObjects(), which blocks (sleeps) until an event arrives. 
Now to integrate your event source, you need to add it to this single 
blocking call.


Specifically, in the case of Tcl/Tk: The event loop is intrinsically 
able to wait for asynchronous IO from sockets, pipes, or serial lines to 
implement "fileevent". However, this is probably not useful since Python 
doesn't open files through Tcl's VFS layer. The easiest way is to run 
another thread, which waits in a blocking way, and to raise an event in 
the main thread. This is done from the C side by Tcl_ThreadQueueEvent() 
and Tcl_ThreadAlert() to wake up the event loop, or from the Tcl script 
level by the Threads package and sending a message to the main thread. 
Unfortunately this message queue stuff is quite complicated (it's 
described on the notifier man page 
http://www.tcl.tk/man/tcl/TclLib/Notifier.htm ). Further complication 
might come from the fact that some Linux distributions still ship with a 
Tcl that is not threads enabled. When I needed to add an unrelated event 
source, namely the events from GPIB devices, I simply used 
Tcl_AsyncProc() to do it, but I'm not sure whether this leads to race 
conditions.


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


Re: Google Groups + this list

2013-12-25 Thread Steven D'Aprano
Ned Batchelder wrote:

> 1) Don't fault newcomers for using Google Groups.  Politely suggest
> alternatives, but only if you are also helping them, or if they have
> already gotten help.

+1

The *primary purpose* of this list is to help people with Python, not to
enforce some particular part of netiquette to the exclusion of all else.
The part that often gets forgotten is the part about avoiding rudeness and
flame wars, and encouraging a friendly, helpful, inclusive environment.
Netiquette helps with communication, but it is the communication which is
important, not the netiquette itself.


> 2) Be careful how you rail against Google Groups.  When you call its
> results "crap" (for example), it can sound like an insult to the poster.
> You mean to refer to Google Groups, but remember you are also
> referring to the poster's words.

+1

While it actually isn't true that you catch more flies with honey than with
vinegar, we don't actually want to catch flies. We want to communicate
with, and educate, human beings.


> 3) Don't let's get into protracted internal debates about Google Groups.
> It is for the moment at least, an unavoidable part of this list.

+1

"At the head of all understanding is realizing what is and what cannot be,
and the consoling of what is not in our power to change."
-- Solomon ibn Gabirol


Thank you Ned for saying all this.


-- 
Steven

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


I hope Python can run in my windows phone

2013-12-25 Thread 1011.0011
I can't compiling myself, and I see Python can run in iphone and android phone. 
And I feel little unfair.-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Variables in a loop, Newby question

2013-12-25 Thread Peter Otten
vanommen.rob...@gmail.com wrote:

> Indeed this is code what I found on the web to read temperatures from 10
> DS18B20 singlewire sensors.
> 
> My only programming (little) experience is VBA (Excel mostly).
> 
> avgtemperatures = [] is indeed from the original code where this line
> 
> 'avgtemperatures.append(sum(temperatures) / float(len(temperatures)))'
> 
> was added. i removed it.
> 
> You're right about the line sensorids. There are 10 sensors:
> 
>  sensorids = ["28-054c4932", "28-054c9454", "28-054c9fca",
>  "28-054c4401", "28-054dab99", "28-054cf9b4",
>  "28-054c8a03", "28-054d6780", $00054ccdfa", "28-054c4f9d"]
> 
> 
> In this script i want to read the temperatures and make them available to
> other scripts.
>  
> One script to controll my solar water boiler and other heat exchangers
> connected to this boiler. (fire place for example) And in the future I
> want to make the temperatures available on a website and log them in a
> mysql database online.
> 
> But as I said before, I am just a few days trying to learn how to do it.
> 
> Thanks for your time.
> 
> greetings Robert

(Warning: all untested code -- I don't have a Raspberry Pi)

When you use constants as sensor ids your code will only work for one 
machine, with one configuration. I recommend that you read the sensor ids 
once at startup of the script and then operate with these.

For the code poste below I assume that the output of the sensors looks like 
the examples on this page:

http://www.gtkdb.de/index_7_2035.html

Namely the list of sensors...

pi@raspberrypi ~ $ cat /sys/devices/w1_bus_master1/w1_master_slaves
 10-000801e1799b
 10-000801e17146
 10-000801e17bc6

and the state of a single sensor:

pi@raspberrypi ~ $ cat /sys/devices/w1_bus_master1/10-000801e1799b/w1_slave
 2d 00 4b 46 ff ff 02 10 19 : crc=19 YES
 2d 00 4b 46 ff ff 02 10 19 t=22625

You can then deal with the "lowlevel" stuff in a module like the 
following...

$ cat sensors.py
def read_sensorids():
with open("/sys/devices/w1_bus_master1/w1_master_slaves") as f:
return [line.strip() for line in f]

def read_sensor(sensorid):
with open("/sys/bus/w1/devices/{}/w1_slave".format(sensorid)) as f:
temperature = f.read().rpartition("=")[-1]
return float(temperature) / 1000.0

def read_sensors(sensorids=None):
if sensorids is None:
sensorids = read_sensorids()

temperatures = {}
for sensorid in sensorids:
temperatures[sensorid] = read_sensor(sensorid)

return temperatures

def print_temperatures(sensorids=None):
for k, v in read_sensors(sensorids).items():
print("Sensor {}: {}".format(k, v))

... and use it like so:

$ cat sensors_demo.py
import sensors
import time

def demo1():
print "Demo1: detect sensors and print temperatures"
print "current temperatures:"
sensors.print_temperatures()
print

def demo2():
print "Demo 2, detect available sensors"
print "found the following sensors:"
for sensor in sensors.read_sensorids():
print sensor
print

def demo3():
print "Demo 3, choose a sensor and read its temperature every second"
print "found the following sensors:"
sensorids = sensors.read_sensorids()
for index, sensor in enumerate(sensorids):
print "  {}: {}".format(index, sensor)

index = int(raw_input("Choose an index "))

follow_sensor = sensorids[index]
print "following", follow_sensor
while True:
print sensors.read_sensor(follow_sensor)
time.sleep(1)


if __name__ == "__main__":
demo1()
demo2()
demo3()

A (simulated, as you might guess from the odd variations in temperature) run 
of the above:

$ python sensors_demo.py 
Demo1: detect sensors and print temperatures
current temperatures:
Sensor 10-000801e1799b: 45.052
Sensor 10-000801e17146: 23.841
Sensor 10-000801e17bc6: 45.5

Demo 2, detect available sensors
found the following sensors:
10-000801e1799b
10-000801e17146
10-000801e17bc6

Demo 3, choose a sensor and read its temperature every second
found the following sensors:
  0: 10-000801e1799b
  1: 10-000801e17146
  2: 10-000801e17bc6
Choose an index 1
following 10-000801e17146
12.744
39.557
17.345
16.49
49.73
27.925
35.007
44.142
37.187
10.261
44.359
^CTraceback (most recent call last):
  File "sensors_demo.py", line 36, in 
demo3()
  File "sensors_demo.py", line 30, in demo3
time.sleep(1)
KeyboardInterrupt

Again, as I don't have a machine to test the above some of my assumptions 
may be false -- or worse, true nine times out of ten.

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


Re: Variables in a loop, Newby question

2013-12-25 Thread Denis McMahon
On Wed, 25 Dec 2013 16:42:47 +1100, Cameron Simpson wrote:

> On 25Dec2013 02:54, Denis McMahon  wrote:
>> On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote:
>> > In this script i want to read the temperatures and make them
>> > available to other scripts. [...]
>> If you want this process to provide data to other processes, you might
>> want to look at using a socket so they can request it as needed.
> 
> Or just write it to a file for another process to open and read...

That can cause io sync errors, eg if another process has the file opened 
for read when you try to write, or you are writing when they try to read.

For inter process communication, sockets are generally better than files.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Google Groups + this list

2013-12-25 Thread rurpy
On 12/23/2013 04:48 AM, Ned Batchelder wrote:
> On 12/22/13 11:52 PM, ru...@yahoo.com wrote:
>> Come on Chris, it is just as easy to make typo or copy-and-
>> paste errors in any other software as GG, there is no evidence
>> that it was GG's fault.
> 
> Can we agree that it's not great to respond to a new poster with *just* 
> "please don't use GG, it's bad" and no actual attempt to help them? 
> It's really unfriendly.  In this case, it wasn't difficult to see the 
> code the OP was asking about, and to try to help them.
> 
>>
>> If you want to recommend the mailing list, fine, but please
>> don't make stupid, unfounded, accusatory suggestions.
> 
> Rurpy: you're coming on really strong here.  "Stupid"?  No. 

'Stupid" might not have been the most accurate choice
of words but I have no problem with it's strength.
People come here looking for accurate info.  Posting 
unsubstantiated derogatory claims about something 
because one doesn't like that something should not 
be allowed to pass silently.  

It is also important to point it out because people 
who do that also post authoritatively about other
things and readers should be aware how readily such 
people confuse their own opinions and facts.

> People have 
> had to deal with the result of Google Groups for a long time, and it's 
> not unreasonable to think that the formatting was its fault.
 
I think it is unreasonable when one doesn't have any
evidence to support the claim.

>> Kevin: just for your own info, there are a few people here
>> who despise Google Groups.  I and many other people post
>> from Google Groups regularly and it works fine.
> 
> This is disingenuous.  Google Groups clearly does not work fine.  If you 
> understand its flaws, and care enough to, you can make it work fine. 

OK, that's fair enough.

> But it's a lot of work.

No, it not a "lot" of work (IMO and I use GG for every 
post I make here).  For a poster who expects to post more 
than once or twice (and thus cares about not alienating 
the anti-GG group) but doesn't expect to be a frequent 
poster it may be perfectly reasonable amount of work 
relative to the work involved with any of the other 
options.

The TB/Usenet promoters simply refuse to (or seem to be
incapable of) understanding that figuring out enough about 
usenet/gmane etc to configure a newreader or managing a 
high volume of emails are what is a "lot of work" to
someone who has been using Google Groups.  I for one don't
want my yahoo email account filled with a hundred or more
email messages a day, all of which I have to click a check
box and a delete button to get rid of.  I don't want those
email delivered to a local email account when I find GG 
allows me to quickly scan for messages of interest and
skip the rest without using local resources.  And I find 
GG UI, while flawed, less flawed than many alternatives.

So don't tell *me* it is a lot of work -- the alternatives 
are more so.

And it is not up to you or Chris to decide what is or 
what isn't "a lot of work" for other people.  If it is 
too much work then they won't do it and will decide 
that using usenet or something else is easier.  But what
you and Chris are missing is that that is *their* decision, 
not yours.
 
>> You might want to take a look at
>>   https://wiki.python.org/moin/GoogleGroupsPython
>> for some ways to reduce the annoyance factor for the anti-GG
>> clique here.
> 
> I appreciate the work you put into that page, but those suggestions are 
> far from simple for the average newb here.  I think it's very unlikely 
> that a new poster is going to read, understand, and follow those 
> instructions.

Perhaps.  But it is an option that GG users should be 
aware of.

> Remember that most posters are not looking to "join the group."  They 
> need help with a problem.  They aren't going to put a lot of work into 
> anything having to do with this list.  That's just the way it is.

And yet you want them to go though the subscription process
for the email list and then deal with dozens, perhaps hundreds
of messages from it every day?  And then figure out how to 
get off it when they're done?

If they're unwilling to do a simple edit on a message before
posting why would anyone think they'd be willing to do all 
the above?

(And to pre-address the obvious potential mis-interpretation:
I am talking about only a subset of posters.  Some *will* 
find email or usenet easier, and to repeat what I said in 
most every post on this subject: offering the option is 
fine, ignoring GG posts if you don't like them is fine. 
But making wrong or unsupported claims like GG corrupts 
whitespace (more than other software) or is harder to use 
than usenet or a mailing list, or makes people go blind 
is wrong.

> Google Groups is a blessing and a curse.  1) It provides a simple way 
> for people to ask questions here.  2) It causes a lot of friction with 
> many people on this list.  It won't do any good to pretend that either 
> of these things isn't true.

Re: I hope Python can run in my windows phone

2013-12-25 Thread J.O. Aho

On 25/12/13 15:08, 1011.0011 wrote:

I can't compiling myself, and I see Python can run in iphone and android
phone. And I feel little unfair.



I would suggest you get yourself a Jolla Mobile with SailfishOS, comes 
with python preinstalled.


See shop.jolla.com

Should soon be for sale in main land China.

--

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


Re: How to check the date validity?

2013-12-25 Thread Sibylle Koczian

Am 24.12.2013 01:39, schrieb Chris Angelico:

On Tue, Dec 24, 2013 at 11:30 AM, Igor Korot  wrote:

So, my question is: since there is a simple way of inserting
preformatted string into the datetime field of mySQL, how do I
validate the date string?


Well, the easiest way would be to simply attempt the SQL query. If it
comes back with an error, the date wasn't valid. To protect a
transaction against being broken by an error, you can use a SAVEPOINT
- check the database docs. (I've never actually used savepoints in
MySQL, only PostgreSQL, so things may be a bit different. Check the
docs.)



MySQL used to accept wrong date and datetime formats without error 
messages. Garbage in the database, because validation was (is?) 
considered the job of "the application". Possibly that has changed, but 
I'd look into the docs. It isn't PostgreSQL.


Greetings
Sibylle



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


Re: [OT]Royal pardon for codebreaker Turing

2013-12-25 Thread Tim Johnson
* Steven D'Aprano  [131224 16:19]:
> Tim Johnson wrote:
> 
> > * Steven D'Aprano  [131224 07:05]:
> >> On Tue, 24 Dec 2013 00:32:31 +, Mark Lawrence wrote:
> >> 
> >> > Maybe of interest to some of you
> >> > http://www.bbc.co.uk/news/technology-25495315
> >> 
> >> While I'm happy for Alan Turing, may he rest in peace, I think the
> >> thousands of other homosexuals who have been prosecuted for something
> >> which shouldn't be a crime in the first place might be a bit peeved that
> >> he is singled out for a pardon.
> >  
> >   The LGBTs that I know are happy to hear about it...
> 
> How many of them have been prosecuted themselves? If they have been, did
> they get pardoned as well?
> 
> In case it wasn't obvious, I'm not objecting to Turing being pardoned. I'm
> suggesting that there are probably thousands of people whose lives were
> equally ruined, and they haven't been pardoned. I'm sure that Turing wasn't
> the only person who was forced into taking hormone "therapy", he probably
> wasn't the only person driven to suicide, and I know that he wasn't the
> only one who lost his job and career because of the hateful laws.
> 
> Turing's prosecution was an especially spiteful example, given his role in
> the war effort, but many others suffered equally. Some may even be alive
> today. Where is their royal pardon?

  I'm not sure if you have a cause or if you want an argument.
  You'll get none from me. I - like many others, and perhaps you as
  well - carry the scars of man's inhumanity to man. Justice for
  that has its venue and it isn't on this ML.

  Go find your cause and its venue. I'm done with this.
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to check the date validity?

2013-12-25 Thread Chris Angelico
On Thu, Dec 26, 2013 at 6:03 AM, Sibylle Koczian  wrote:
> MySQL used to accept wrong date and datetime formats without error messages.
> Garbage in the database, because validation was (is?) considered the job of
> "the application". Possibly that has changed, but I'd look into the docs. It
> isn't PostgreSQL.

Nor is it DB2, which is where I grew up, databases-wise. Yes, check
what MySQL will do. I'd forgotten that, or more likely suppressed it
from my mind.

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


Re: Google Groups + this list

2013-12-25 Thread rurpy
On 12/25/2013 05:19 AM, Ned Batchelder wrote:
> On 12/24/13 8:47 PM, ru...@yahoo.com wrote:
>> On 12/23/2013 09:12 AM, Chris Angelico wrote:
>>> Also,
>>> you haven't answered the other part of the post, the more important
>>> part.
>> Refresh my memory please.
> 
> Ugh, stop!  

Stop what?  The context you quote has nothing to do
with what you write below.

> We get it: you don't think Google Groups is bad.  

That's not accurate.  I would never characterize GG
with such simplistic terms as "good" or "bad".

> Or you 
> think it can be made to work,

My own posts demonstrate that.  You don't agree?  Why
would you question that I think so?

> or something.  

"or something"?  In other words you *don't* get it.

> That's fine.  But you are 
> going to have to reason a little more subtly than, "all software has bugs."

I have tried to, both in the previous posts and in posts 
going back any months.  Either I have failed to make myself 
clear or (more likely since you (et.al.) consistently cut 
out context and fail to respond directly to what I wrote) 
you choose not to understand.

> As Chris has pointed out, the bugs in Google Groups affect every reader 
> of the list.  Bugs in other software don't, at least not to the same extent.

I understand that.  But (a hypothetical) *I* have to make 
a tradeoff between the features/misfeatures of GG vs TB 
or any other software.  You assume that the negative value 
you assign to GG apply to me.  Wrong.  While I understand 
(for example) that the FU'd quoting is annoying, I don't 
see why you can't just ignore it or skip reading my entire 
post if necessary.  (The non-hypothetical I actually almost 
never reads quoted stuff anyway -- I only do so rarely when
my memory and the main message leaving me unclear about 
something -- and even then it is often easier to go back 
to the OP given the spotty quality of quote trimming, as 
you demonstrate.)
 
And (as I pointed out, multiple times) you fail to evaluate 
as positively as (hypothetical again) I do the benefits GG 
has for me.  (Evidence: Chris' erroneous insistence that 
subscribing to the email list is as easy as using GG.)  So 
my evaluation of the overall benefit/cost for GG relative 
to some other choice is still positive even though your 
evaluation is otherwise.  And I distrust your evaluation
anyway since I *know* (from personal experience that GG 
is easier to use for me than a mailing list) that part of 
your evaluation is wrong. 

What you are saying is that I should use *your* evaluation
of GG (and other options) in making my tradeoffs.  And you 
get very angry when I won't do what you tell me to.

Secondly, the above is a side issue.  Please go back and 
reread the posts in question.  The main point (which you and
Chris lost or did a good job misdirecting away from) is that 
Chris claimed (and you found reasonable to believe) that GG 
corrupts white space in posts.  I have not seen any such 
effect, Chris' explanations were all handwaving, and so 
pending something more convincing I will offer the alternate
explanation that it is just more unjustified disparagement 
of GG and that it constitutes evidence that much of this 
anti-GG sentiment is driven by a "Lord of the Flies" effect
rather than rationality.

> Rurpy, you seem to be willfully ignoring the aggravation people are 
> experiencing.  

"willfully ignoring"?  For someone portraying himself as
a voice of reason in this discuss that's a pretty sleezy
thing to say.  I'll point out I put a small but significant 
amount of work into a wiki page to try to help reduce the 
aggravation people are experiencing which is more than you
or Chris have done.

> And people who hate Google Groups: you seem to be 
> overlooking the fact that it's difficult for the users of Google Groups 
> to understand its flaws, or to see the effect it has on the list.

And in my opinion, overreacting to GG annoyances.  Despite 
claims to the contrary, reading GG posts *will not* make 
you go blind, and they *can* be easily skipped if too 
annoying.  And from comments posted here, there are people 
who find these incessant GG discussions (and frequent 
troll baiting) far more annoying than posts from GG.

> I'll repeat my proposal (for everyone):
> 
> 1) Don't fault newcomers for using Google Groups.  Politely suggest 
> alternatives, but only if you are also helping them, or if they have 
> already gotten help.
> 
> 2) Be careful how you rail against Google Groups.  When you call its 
> results "crap" (for example), it can sound like an insult to the poster. 
>   You mean to refer to Google Groups, but remember you are also 
> referring to the poster's words.
> 
> 3) Don't let's get into protracted internal debates about Google Groups. 
>   It is for the moment at least, an unavoidable part of this list.
> 
> Do you disagree?

OK I give up.  You never even bothered to read what you're
responding to.  I specifically wrote regarding the above,
immediately following where you wro

Re: [OT]Royal pardon for codebreaker Turing

2013-12-25 Thread Steven D'Aprano
Tim Johnson wrote:

> I'm not sure if you have a cause or if you want an argument.

I thought we were having a conversation.

Not every exchange of messages on the internet is best understood as a
dispute between opposing views. Apologies if you thought I was arguing with
you. I thought I was just clarifying my position to avoid
misunderstandings. How ironic that I apparently was doing the opposite :(


-- 
Steven

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


Re: [OT]Royal pardon for codebreaker Turing

2013-12-25 Thread Roy Smith
In article <52bb64d7$0$29973$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> Tim Johnson wrote:
> 
> > I'm not sure if you have a cause or if you want an argument.
> 
> I thought we were having a conversation.
> 
> Not every exchange of messages on the internet is best understood as a
> dispute between opposing views.

Is too!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT]Royal pardon for codebreaker Turing

2013-12-25 Thread Chris Angelico
On Thu, Dec 26, 2013 at 11:20 AM, Roy Smith  wrote:
> In article <52bb64d7$0$29973$c3e8da3$54964...@news.astraweb.com>,
>  Steven D'Aprano  wrote:
>
>> Tim Johnson wrote:
>>
>> > I'm not sure if you have a cause or if you want an argument.
>>
>> I thought we were having a conversation.
>>
>> Not every exchange of messages on the internet is best understood as a
>> dispute between opposing views.
>
> Is too!

I didn't come here for a parameter!

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


Re: Variables in a loop, Newby question

2013-12-25 Thread Cameron Simpson
On 25Dec2013 15:27, Denis McMahon  wrote:
> On Wed, 25 Dec 2013 16:42:47 +1100, Cameron Simpson wrote:
> > On 25Dec2013 02:54, Denis McMahon  wrote:
> >> On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote:
> >> > In this script i want to read the temperatures and make them
> >> > available to other scripts. [...]
> >> If you want this process to provide data to other processes, you might
> >> want to look at using a socket so they can request it as needed.
> > 
> > Or just write it to a file for another process to open and read...
> 
> That can cause io sync errors, eg if another process has the file opened 
> for read when you try to write, or you are writing when they try to read.

Well, obviously synchronisation of some kind is needed. The easiest
is write-new-file-with-temp-name followed by rename(). Atomic. Lock
files are also not too hard, etc.

> For inter process communication, sockets are generally better than files.

Except for agreement about the ports etc etc, and the need to write
a (possible trite) protocol. At least the filesystem gives great
and ergonomic flexibility about naming the communication point, and
offers file permissions to control who can access stuff instead of
needing some kind of authentication protocol. And of course a file
needs no connect/listen/accept daemon/thread to facilitate
communication.

Of course, a named pipe or UNIX cdomain socket may give the best of both
worlds, depending on the use case.

Cheers,
-- 
Cameron Simpson 

In any event, this is a straw herring for debate.
- solo...@netcom.com (Andrew Solovay)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Variables in a loop, Newby question

2013-12-25 Thread Chris Angelico
On Thu, Dec 26, 2013 at 12:01 PM, Cameron Simpson  wrote:
> On 25Dec2013 15:27, Denis McMahon  wrote:
>> On Wed, 25 Dec 2013 16:42:47 +1100, Cameron Simpson wrote:
>> > On 25Dec2013 02:54, Denis McMahon  wrote:
>> >> On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote:
>> >> > In this script i want to read the temperatures and make them
>> >> > available to other scripts. [...]
>> >> If you want this process to provide data to other processes, you might
>> >> want to look at using a socket so they can request it as needed.
>> >
>> > Or just write it to a file for another process to open and read...
>>
>> That can cause io sync errors, eg if another process has the file opened
>> for read when you try to write, or you are writing when they try to read.
>
> Well, obviously synchronisation of some kind is needed. The easiest
> is write-new-file-with-temp-name followed by rename(). Atomic. Lock
> files are also not too hard, etc.

Does anyone else have the vague feeling that the OP's problem might be
better served by simply importing the script (thus making those values
available to another Python script) than by any of these rather more
complicated theories?

Of course, this requires a little more clarification from the OP, but
I'd rather posit the simple idea and see it knocked down before going
on to the complex :)

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


Re: Google Groups + this list

2013-12-25 Thread Rustom Mody
On Thu, Dec 26, 2013 at 3:39 AM,  wrote:
>
> On 12/25/2013 05:19 AM, Ned Batchelder wrote:
> > On 12/24/13 8:47 PM, ru...@yahoo.com wrote:
> >> On 12/23/2013 09:12 AM, Chris Angelico wrote:
> >>> Also,
> >>> you haven't answered the other part of the post, the more important
> >>> part.
> >> Refresh my memory please.
> >
> > Ugh, stop!
>
> Stop what?  The context you quote has nothing to do
> with what you write below.


This is a test mail

I seem to have been kicked off something or other --
First thought it was google groups -- then saw some mails from Steven
describing similar 'non-reaching' problems.

Anyway for the last couple of days I'm getting mail bounces after
about 24 hours to all my posts (via GG)

So trying a different route -- Does this reach?

[And if it does... Merry Christmas!]


--
Heres the kind of bounce message I get (with emails crossed out)


On Wed, Dec 25, 2013 at 11:09 AM, Mail Delivery Subsystem
 wrote:
>
> Delivery to the following recipient failed permanently:
>
>  comp.lang.python AT usenet.google.com
>
> - Original message -
>
> X-Received: by 10.50.34.161 with SMTP id a1mr486436igj.5.1387860004581; Mon,
>  23 Dec 2013 20:40:04 -0800 (PST)
> Path: glegroupsg2000goo.googlegroups.com!not-for-mail
> Newsgroups: comp.lang.python
> Date: Mon, 23 Dec 2013 20:40:04 -0800 (PST)
> In-Reply-To: 
> Complaints-To: groups-abuse...
> Injection-Info: glegroupsg2000goo.googlegroups.com; 
> posting-host=59.95.49.205; posting-account=mBpa7woGLEWUUKpmbxm-Quu5D8ui
> NNTP-Posting-Host: 59.95.49.205
> References: <52b788bb$0$6599$c3e8da3$54964...@news.astraweb.com>

> User-Agent: G2/1.0
> X-Google-Web-Client: true
> X-Google-IP: 59.95.49.205
> MIME-Version: 1.0
> Message-ID: <5125ea95-14cb-43af-bddd-2da87552550f at googlegroups.com>
> Subject: Re: testing
> From: Rusi <>
> To: comp.lang.python AT ...
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Monday, December 23, 2013 6:56:56 AM UTC+5:30, Roy Smith wrote:
> >  Steven D'Aprano  wrote:
>
> > > Is this thing still working?
>
> > Yes.  Do you want to know how many times your previous message was
> > posted? :-)
>
>
> Last couple of days I seem to be kicked off the list
> Just checking whether this gets in
>
> [And if it does, sorry for noise!]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Google Groups + this list

2013-12-25 Thread Ned Batchelder

On 12/24/13 8:44 PM, ru...@yahoo.com wrote:

On 12/23/2013 04:48 AM, Ned Batchelder wrote:

On 12/22/13 11:52 PM, ru...@yahoo.com wrote:

Come on Chris, it is just as easy to make typo or copy-and-
paste errors in any other software as GG, there is no evidence
that it was GG's fault.


Can we agree that it's not great to respond to a new poster with *just*
"please don't use GG, it's bad" and no actual attempt to help them?
It's really unfriendly.  In this case, it wasn't difficult to see the
code the OP was asking about, and to try to help them.



If you want to recommend the mailing list, fine, but please
don't make stupid, unfounded, accusatory suggestions.


Rurpy: you're coming on really strong here.  "Stupid"?  No.


'Stupid" might not have been the most accurate choice
of words but I have no problem with it's strength.
People come here looking for accurate info.  Posting
unsubstantiated derogatory claims about something
because one doesn't like that something should not
be allowed to pass silently.


Chris actually said, "You seem to be posting from Google Groups, which 
may be why it's messed up; I recommend switching to something else, like 
Mozilla Thunderbird, or subscribing instead to the mailing list (with 
all the same content)"


This is pretty gentle, and includes words like "may" and "recommend".

Also, let's be clear: I didn't like Chris' message, because it didn't 
attempt to help the OP.


I'm not taking the "don't use Google Groups" side in this debate.  You 
seem to think I am, but I'm not.  My point is, "talk about Python, not 
about Google Groups."




It is also important to point it out because people
who do that also post authoritatively about other
things and readers should be aware how readily such
people confuse their own opinions and facts.


People have
had to deal with the result of Google Groups for a long time, and it's
not unreasonable to think that the formatting was its fault.


I think it is unreasonable when one doesn't have any
evidence to support the claim.


Kevin: just for your own info, there are a few people here
who despise Google Groups.  I and many other people post
from Google Groups regularly and it works fine.


This is disingenuous.  Google Groups clearly does not work fine.  If you
understand its flaws, and care enough to, you can make it work fine.


OK, that's fair enough.


But it's a lot of work.


No, it not a "lot" of work (IMO and I use GG for every
post I make here).  For a poster who expects to post more
than once or twice (and thus cares about not alienating
the anti-GG group) but doesn't expect to be a frequent
poster it may be perfectly reasonable amount of work
relative to the work involved with any of the other
options.


Yes, that's a point I've also been trying to make: we're in agreement here.



The TB/Usenet promoters simply refuse to (or seem to be
incapable of) understanding that figuring out enough about
usenet/gmane etc to configure a newreader or managing a
high volume of emails are what is a "lot of work" to
someone who has been using Google Groups.  I for one don't
want my yahoo email account filled with a hundred or more
email messages a day, all of which I have to click a check
box and a delete button to get rid of.  I don't want those
email delivered to a local email account when I find GG
allows me to quickly scan for messages of interest and
skip the rest without using local resources.  And I find
GG UI, while flawed, less flawed than many alternatives.

So don't tell *me* it is a lot of work -- the alternatives
are more so.

And it is not up to you or Chris to decide what is or
what isn't "a lot of work" for other people.  If it is
too much work then they won't do it and will decide
that using usenet or something else is easier.  But what
you and Chris are missing is that that is *their* decision,
not yours.


I'm not telling people not to use Google Groups.  In fact, I've said 
twice now in this thread that we have to accept Google Groups postings 
as part of this list.  My point is simply that we have to take care not 
to turn this list into a list about Google Groups, one way or the other.


Kevin started this thread by asking a question.  Chris responded without 
helping the OP, and talked about Google Groups instead.  That's not 
good.  Then you responded to Chris, not helping the OP, and talking 
about Google Groups instead.  That's also not good.


I have found some of the anti-GG responses off-putting, and I wish they 
would stop.  Words like "crap" aren't making anyone feel welcome.  In 
this thread, I felt like your attempts to correct those responses were 
also crossing a line.


That's why I'd personally prefer that everyone tone down the rhetoric on 
both sides of the debate.  For the most part, it will be impossible to 
get anyone to change how they access the list.  The best we can do is a 
polite suggestion that Google Groups puts some people off, and that more 
responses will likely result from using ano

Re: Google Groups + this list

2013-12-25 Thread Chris Angelico
On Thu, Dec 26, 2013 at 3:11 PM, Ned Batchelder  wrote:
> Kevin started this thread by asking a question.  Chris responded without
> helping the OP, and talked about Google Groups instead.  That's not good.

The only reason I didn't directly help the OP was because the code was
misformatted and it was necessary to request that it be reposted.
Perhaps I should have been clearer in saying "Please repost your code
with correct formatting", but there wasn't much else I could have
done.

Or maybe I should have just filtered everything from Google Groups
into the bit bucket, because responding just creates threads like
this. Do you honestly think that would be better? No response at all
if the post comes from GG?

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


Re: Google Groups + this list

2013-12-25 Thread Rustom Mody
On Thu, Dec 26, 2013 at 9:47 AM, Chris Angelico  wrote:
> On Thu, Dec 26, 2013 at 3:11 PM, Ned Batchelder  
> wrote:
>> Kevin started this thread by asking a question.  Chris responded without
>> helping the OP, and talked about Google Groups instead.  That's not good.
>
> The only reason I didn't directly help the OP was because the code was
> misformatted and it was necessary to request that it be reposted.
> Perhaps I should have been clearer in saying "Please repost your code
> with correct formatting", but there wasn't much else I could have
> done.
>
> Or maybe I should have just filtered everything from Google Groups
> into the bit bucket, because responding just creates threads like
> this. Do you honestly think that would be better? No response at all
> if the post comes from GG?

I think Ned is being exceptionally helpful in keeping this list in order
And you are being inflammatory in the above given that Ned just said:

> I'm not telling people not to use Google Groups.  In fact, I've said twice 
> now in
> this thread that we have to accept Google Groups postings as part of this 
> list.
> My point is simply that we have to take care not to turn this list into a list
> about Google Groups, one way or the other.

You are of course free to filter out GG posts if you wish -- thats a
separable question.

[And I reiterate my request to check why I have been kicked off from
GG and have to use mail. As rurpy said I cant handle a mailing list
volume of this scale for too long]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Google Groups + this list

2013-12-25 Thread Steven D'Aprano
Rustom Mody wrote:

> I seem to have been kicked off something or other --
> First thought it was google groups -- then saw some mails from Steven
> describing similar 'non-reaching' problems.

I don't think you can actually be kicked off Google Groups. Isn't it open to
anyone with an account? If you have an account, can you log in? 

(I could be wrong -- I don't actually use it for various reasons which I'm
happy to share if anyone cares but aren't actually germane to the issue at
hand.)

My issues were different. I'm posting via Usenet, and my ISP piggy-backs off
some other Usenet hosting company. Occasionally they have temporary issues
with posts being broken, either permanently or (in the most recent case)
temporarily.


> Anyway for the last couple of days I'm getting mail bounces after
> about 24 hours to all my posts (via GG)

Sounds like a problem with GG, probably some temporary misconfiguration with
one of their servers which will be attended to once Google get a round
tuit.


> So trying a different route -- Does this reach?
>
> [And if it does... Merry Christmas!]

Got it, thanks!


> Heres the kind of bounce message I get (with emails crossed out)
> 
> 
> On Wed, Dec 25, 2013 at 11:09 AM, Mail Delivery Subsystem
>  wrote:
>>
>> Delivery to the following recipient failed permanently:
>>
>>  comp.lang.python AT usenet.google.com

Looks like Google implements their Usenet mirror via email, instead of using
a News server. I have no idea if that's a good thing or a bad thing, but
its a thing.



-- 
Steven

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


Re: Variables in a loop, Newby question

2013-12-25 Thread Steven D'Aprano
Chris Angelico wrote:

> Does anyone else have the vague feeling that the OP's problem might be
> better served by simply importing the script (thus making those values
> available to another Python script) than by any of these rather more
> complicated theories?

Damn yes!



-- 
Steven

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


Apache restart after source changes

2013-12-25 Thread Fredrik Bertilsson
I am evaluating Python for web development and just found out that I need to 
restart Apache after source changes on windows. Using linux the situation is 
better but I still have to touch the wsgi file. Is it only me that finds this 
being a major drawback compared to PHP?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting updates and restarting a long running url request.

2013-12-25 Thread Jason Friedman
> I am using the following code to submit the query/
> def get_BLAST(taxid, queryseq, args=None):
> '''
> Input taxid to BLAST queryseq against
> '''
> e_query = "txid" + taxid + " [ORGN]"
> #, other_advanced='-G 4 -E 1'
> blast_result = NCBIWWW.qblast("blastn", "nt", queryseq, megablast=True,
> entrez_query=e_query, word_size='11', other_advanced='-G 5 -E 2')
> return NCBIXML.read(blast_result)

Could you keep track of success?

result_dict = dict()
for id in taxid_list:
result_dict[id] = False
while not all(result_dict.values()): # continue if not every ID was successful
for id in taxid_list:
if result_dict[id]:
continue # We were already successful with this ID
try:
this_result = get_BLAST(id)
result_dict[id] = True
except:
print("A warning.")
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Apache restart after source changes

2013-12-25 Thread Eduardo A . Bustamante López
On Wed, Dec 25, 2013 at 09:57:42PM -0800, Fredrik Bertilsson wrote:
> I am evaluating Python for web development and just found out that I need to 
> restart Apache after source changes on windows. Using linux the situation is 
> better but I still have to touch the wsgi file. Is it only me that finds this 
> being a major drawback compared to PHP?
How is it a «major drawback». «Oh, god, I have to touch that file!
This is unbearable! It's unbeliavable!!! How awful».

Also, it's not a python issue, it's an issue with your particular
stack. Other stacks do automatic reloading (for example, the web
server that Django uses).

-- 
Eduardo Alan Bustamante López
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Apache restart after source changes

2013-12-25 Thread Fredrik Bertilsson
> Also, it's not a python issue, it's an issue with your particular
> stack. Other stacks do automatic reloading (for example, the web
> server that Django uses).

Which web server do you suggest instead of Apache, which doesn't have this 
problem? (I am not planning to use Django)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Variables in a loop, Newby question

2013-12-25 Thread Michael Torrie
On 12/24/2013 11:27 AM, vanommen.rob...@gmail.com wrote:
> Indeed this is code what I found on the web to read temperatures from
> 10 DS18B20 singlewire sensors.
> 
> My only programming (little) experience is VBA (Excel mostly).
> 

Definitely you'll want to learn python before you go much farther in
this project.  Check out the online docs, tutorials, etc.

> In this script i want to read the temperatures and make them
> available to other scripts.

Here's some almost runnable code that might help you get down the right
track.  You'll have to fill in some of the stuff.

temperatures.py:
import time
sensorids = [...] #fill in these with your ids

def _read_sensor(id):
  # open /sys/bus/w1/deevices/id/slave
  text = ''
  while text.split("\n")[0].find("YES") == -1:
tfile = open("/sys/bus/w1/devices/"+ id +"/w1_slave")
text = tfile.read()
tfile.close()
time.sleep(0.1)
  temperaturedata = text.split("\n")[1].split(" ")[9]it(" ")[9]
  temperature = float(temperaturedata [2:]) / 1000
  return temperature

def get_temperatures():
  # not using list comprehensions but we could
  temps = []
  for sensor in sensorids:
temps.append(_read_sensor(sensor))

Then in your other python modules (scripts):

import temperatures

print temperatures.get_temperatures() # should print a list

Hope this gives you a bit of structure you can use.  All the code you
need to fill in can come from the code you posted previously.
-- 
https://mail.python.org/mailman/listinfo/python-list