Re: Plotting the integer-and-fraction remainder of a function value modulo 360

2014-04-09 Thread Kim Plofker
Thanks, the % operator is indeed what I want, but I want to use it with a function expression rather than with numbers alone.  And that seems to create a type error. Here's an example of what goes wrong: t = var('t') L(t) = t*725.5%360.0 This produces the following error message: ... TypeEr

Re: Plotting the integer-and-fraction remainder of a function value modulo 360

2014-04-09 Thread Kim Plofker
Thanks!  As I recently posted in a followup message, Here's an example of what goes wrong: t = var('t') L(t) = t*725.5%360.0 This produces the following error message: ... TypeError: unsupported operand type(s) for %: 'sage.symbolic.expression.Expression' and 'sage.symbolic.expressio

EuroScipy Reminder: call for abstracts closes in 4 days

2014-04-09 Thread Nelle Varoquaux
Hello everyone, Just a quick reminder that the EuroScipy call for abstracts closes on the 14th: don't forget to submit your talk proposal! It is in four days only! In short, EuroScipy is a cross-disciplinary gathering focused on the use and development of the Python language in scientific researc

Re: how to make ["a","b",["c","d"],"e"] into ['a', 'b', 'c', 'd', 'e'] ?

2014-04-09 Thread Rustom Mody
On Thursday, April 10, 2014 10:55:10 AM UTC+5:30, balaji marisetti wrote: > There was long thread discussing flattening of a list on this list :). > See the link below. I dont think that thread is relevant to this question: 1. That (started with) a strange/cute way of using names 2. It does not wo

Re: how to make ["a","b",["c","d"],"e"] into ['a', 'b', 'c', 'd', 'e'] ?

2014-04-09 Thread balaji marisetti
There was long thread discussing flattening of a list on this list :). See the link below. https://mail.python.org/pipermail/python-list/2014-March/669256.html On 10 April 2014 10:44, length power wrote: x=["a","b",["c","d"],"e"] y=x[2] y > ['c', 'd'] x.insert(2,y[0]) x

Re: how to make ["a", "b", ["c", "d"], "e"] into ['a', 'b', 'c', 'd', 'e'] ?

2014-04-09 Thread Ben Finney
length power writes: > maybe there is a more smart way to do. Maybe. But a way to do what, exactly? You start with a list, but what is it exactly that you want to do with that list? >>> x = ["a", "b", ["c", "d"], "e"] If I interpret your request *literally*, I can achieve it in a single s

Re: CommandLine Option in Python for filtering values from Column

2014-04-09 Thread balaji marisetti
sys.argv is itself a list. You can directly access the `quality` field as sys.argv[2]. quality = int(sys.argv[2]) However, if you want to use more command line options, then using `argparse` module is better than accessing arguments using `sys.argv`. Import `argparse` module and create

how to make ["a","b",["c","d"],"e"] into ['a', 'b', 'c', 'd', 'e'] ?

2014-04-09 Thread length power
>>> x=["a","b",["c","d"],"e"] >>> y=x[2] >>> y ['c', 'd'] >>> x.insert(2,y[0]) >>> x ['a', 'b', 'c', ['c', 'd'], 'e'] >>> x.insert(3,y[1]) >>> x ['a', 'b', 'c', 'd', ['c', 'd'], 'e'] >>> del x[4] >>> x ['a', 'b', 'c', 'd', 'e'] >>> maybe there is a more smart way to do. -- https://mail.python.org/

Re: Plotting the integer-and-fraction remainder of a function value modulo 360

2014-04-09 Thread Steven D'Aprano
On Wed, 09 Apr 2014 21:32:27 -0700, Kim Plofker wrote: > How can I get Python to represent a value of a function in degrees, > i.e., with values between 0 and 360, by taking the (non-integer) > function expression mod 360? > > That is, I have a function with non-integer values, called Longitude,

Re: Plotting the integer-and-fraction remainder of a function value modulo 360

2014-04-09 Thread Ben Finney
Kim Plofker writes: > How can I get Python to represent a value of a function in degrees, > i.e., with values between 0 and 360, by taking the (non-integer) > function expression mod 360? In Python, you simply use the modulo (‘%’) operator:: >>> 45.0 % 360 45.0 >>> 700.0 % 360 3

Plotting the integer-and-fraction remainder of a function value modulo 360

2014-04-09 Thread Kim Plofker
How can I get Python to represent a value of a function in degrees, i.e., with values between 0 and 360, by taking the (non-integer) function expression mod 360? That is, I have a function with non-integer values, called Longitude, which is defined in terms of the variable t. I just want to plo

Re: threading

2014-04-09 Thread Chris Angelico
On Thu, Apr 10, 2014 at 1:44 PM, Steven D'Aprano wrote: >> Now, before i utterly destroy you, we must first *ALL* take a lesson in >> linguistics. > > Oh noes! I'm going to be destroyed by Rick, Super-Genius! I'll send him my business card as a salesman for Acme. Easiest job in the world - just s

Re: threading

2014-04-09 Thread Steven D'Aprano
On Wed, 09 Apr 2014 08:51:09 -0700, Rick Johnson wrote: > On Wednesday, April 9, 2014 8:50:59 AM UTC-5, Neil D. Cerutti wrote: >> [...] >> Plus Rufus Xavier Sasparilla disagrees with it. > > If you think you're going to argue in such an implicit manner as to the > benefits of pronouns, then you s

Re: How to display chinese character in 65001 in pytohn?

2014-04-09 Thread length power
problem solved.if you enter python by python(command line),the problem can't be solved.if you enter python by cmd ,and input python,no problem happen. 2014-04-10 11:05 GMT+08:00 length power : > i tried this way ,and post it in stackoverflow,please see: > maybe it is the best answer. > Codepage

Re: threading

2014-04-09 Thread Chris Angelico
On Thu, Apr 10, 2014 at 12:43 PM, Steven D'Aprano wrote: > You cannot use plane English! Cleared for takeoff... ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: How to display chinese character in 65001 in pytohn?

2014-04-09 Thread length power
i tried this way ,and post it in stackoverflow,please see: maybe it is the best answer. Codepage 65001 is generally broken in binary mode as used by Python 3, since _write calls Win32 WriteFile, which calls WriteConsoleA, which returns the number of characters written instead of the number of bytes

Re: Method(s) called by square brackets, slice objects

2014-04-09 Thread Steven D'Aprano
On Wed, 09 Apr 2014 13:24:32 -0700, John Ladasky wrote: > I would like to build a multi-dimensional array that allows numpy-style > indexing and, ideally, uses Python's familiar square-bracket and slice > notations. > > For example, if I declare a two-dimensional array object, x, then x[4,7] > re

Re: threading

2014-04-09 Thread Steven D'Aprano
On Wed, 09 Apr 2014 19:53:26 -0400, Roy Smith wrote: > Natural language is a wonderfully expressive thing. I open the window, > stick my head out, look up at the sky, and say, "Raining". Forget the > pronoun, I don't even have a verb. And yet everybody understands > exactly what I mean. Not ev

Re: How to display chinese character in 65001 in pytohn?

2014-04-09 Thread MRAB
On 2014-04-10 02:54, length power wrote: I am in win7 +python3.3. import os os.system("chcp 936") fh=open("test.ch ","w",encoding="utf-8") fh.write("你") fh.close() os.system("chcp 65001") fh=open("test.ch ","r",encoding="utf-8")

Re: imaplib: how to specify SSL/TLS protocol version?

2014-04-09 Thread Chris Angelico
On Thu, Apr 10, 2014 at 7:10 AM, Grant Edwards wrote: > I left out a relevent fact: I'm not the one calling IMAP4_. > > That's being done by the imapclient library. There's no way to pass > imapclient a custom class to use. It's hard-waired to call either > imaplib.IMAP4_stream(), imaplib.IMAP4(

How to display chinese character in 65001 in pytohn?

2014-04-09 Thread length power
I am in win7 +python3.3. import os os.system("chcp 936") fh=open("test.ch","w",encoding="utf-8") fh.write("你") fh.close() os.system("chcp 65001") fh=open("test.ch","r",encoding="utf-8").read() print(fh) Äã >>> print(fh.encode("utf-8")) b'\xe4\xbd\xa0'

Re: threading

2014-04-09 Thread Chris Angelico
On Thu, Apr 10, 2014 at 9:44 AM, Dennis Lee Bieber wrote: > On Wed, 9 Apr 2014 23:47:04 +1000, Chris Angelico > declaimed the following: > >>won't block. You might think "Duh, how can printing to the screen >>block?!?", but if your program's output is being piped into something >>else, it most ce

Re: [OFF-TOPIC] How do I find a mentor when no one I work with knows what they are doing?

2014-04-09 Thread alex23
On 9/04/2014 6:55 PM, Mark Lawrence wrote: And the worst thing about terrible code is when you first realise just how bad it is and wonder why you wrote it like that in the first place. For me, it's nearly always due to time constraints. Usually caused by a comment like: "we absolutely need th

webapp stuck on 1 cpu

2014-04-09 Thread johannes falcone
do python web frameworks green thread but are stuck on 1 cpu or like aolserver do they use os threads and then maybe a combo of green and events ? so that a webapp can use a 64 cpu machine with out pain? -- https://mail.python.org/mailman/listinfo/python-list

Re: Unpacking U-Boot image file

2014-04-09 Thread Dave Angel
"trewio" Wrote in message: > U-Boot format: hmm, I'm not sure, can someone specify Python script that will > help me deterermine U-boot format used? [for Python for Windows OS] > > Note: I need Python script for Python under Windows OS. > > >> - Original Message - >> From: Rustom Mody

Re:Unpacking U-Boot image file

2014-04-09 Thread Dave Angel
"trewio" Wrote in message: > How to extract files from U-Boot image file, LZMA-compressed? > > Is there a Python script that can do this properly? > Use the lzma module in Python 3.3 for starters -- DaveA -- https://mail.python.org/mailman/listinfo/python-list

Re: threading

2014-04-09 Thread Andrew Berg
On 2014.04.09 18:53, Roy Smith wrote: > It's even more ambiguous in Spanish. Esta lloviendo. Not only do you > get to intuit the referrent, you get to intuit the pronoun too :-) And in this particular instance, you have to figure out that 'está' (verb) was meant instead of 'esta' (adjective). :

Re: threading

2014-04-09 Thread Roy Smith
In article , Gregory Ewing wrote: > > On 2014-04-09 16:51, Rick Johnson wrote: > >> Again we have the pronoun "it" declared as the very first > >> word of the sentence, however, the referent is missing, and > >> instead must be intuited! > > Pronoun referents *always* need to be intuited. There

Re: threading

2014-04-09 Thread Gregory Ewing
On 2014-04-09 16:51, Rick Johnson wrote: Again we have the pronoun "it" declared as the very first word of the sentence, however, the referent is missing, and instead must be intuited! Pronoun referents *always* need to be intuited. There are no mechanical rules for finding the referent of a pr

Re: threading

2014-04-09 Thread Gregory Ewing
Roy Smith wrote: In the old days, all Unix system calls were divided up into two groups, based on whether they were "fast" or "slow". Processes executing a "fast" system call would block, and could not be interrupted; That doesn't really have anything to do with blocking vs. non-blocking, tho

2014 PyCamps

2014-04-09 Thread Chris Calloway
PyCamp is an ultra-low-cost, five-day, intensive Python boot camp program by a user group for user groups. PyCamp has taught Python fundamentals to thousands of beginners for nine years while sponsoring Python regional conferences, symposia, sprints, scholarships, and user groups. You can get u

Re: imaplib: how to specify SSL/TLS protocol version?

2014-04-09 Thread Grant Edwards
On 2014-04-09, Grant Edwards wrote: > On 2014-04-09, Tim Chase wrote: >> On 2014-04-09 20:20, Grant Edwards wrote: >>> I'm not too keen on this approach, but monkey-patching the open() >>> method seems to work: >>> >>> def my_imap4_ssl_open(self, host = '', port = 993): >>> self.host = host

Re: Unpacking U-Boot image file

2014-04-09 Thread laguna-mc
I know about Binwalk, it can run on Linux OS only. I am looking for Python script that can run on Windows too. Thank you. - Original Message - From: Adnan Sadzak Sent: 04/09/14 11:37 PM To: trewio Subject: Re: Unpacking U-Boot image file Oh then see Craig's page [0]. You can find in deep

Re: Method(s) called by square brackets, slice objects

2014-04-09 Thread Ethan Furman
On 04/09/2014 01:24 PM, John Ladasky wrote: I would like to build a multi-dimensional array that allows numpy-style indexing and, ideally, uses Python's familiar square-bracket and slice notations. For example, if I declare a two-dimensional array object, x, then x[4,7] retrieves the element

Re: imaplib: how to specify SSL/TLS protocol version?

2014-04-09 Thread Grant Edwards
On 2014-04-09, Tim Chase wrote: > On 2014-04-09 20:20, Grant Edwards wrote: >> I'm not too keen on this approach, but monkey-patching the open() >> method seems to work: >> >> def my_imap4_ssl_open(self, host = '', port = 993): >> self.host = host >> self.port = port >> self.sock = so

Re: imaplib: how to specify SSL/TLS protocol version?

2014-04-09 Thread Tim Chase
On 2014-04-09 20:20, Grant Edwards wrote: > I'm not too keen on this approach, but monkey-patching the open() > method seems to work: > > def my_imap4_ssl_open(self, host = '', port = 993): > self.host = host > self.port = port > self.sock = socket.create_connection((host, port)) >

Re: imaplib: how to specify SSL/TLS protocol version?

2014-04-09 Thread Tim Chase
On 2014-04-09 20:12, Grant Edwards wrote: > File "/usr/lib64/python2.7/imaplib.py", line 1148, in __init__ >IMAP4.__init__(self, host, port) > SSLError: [Errno 1] _ssl.c:1419: error:1408F10B:SSL > routines:SSL3_GET_RECORD:wrong version number > > Experiments show that when calling ssl.wrap_s

Method(s) called by square brackets, slice objects

2014-04-09 Thread John Ladasky
I would like to build a multi-dimensional array that allows numpy-style indexing and, ideally, uses Python's familiar square-bracket and slice notations. For example, if I declare a two-dimensional array object, x, then x[4,7] retrieves the element located at the 4th row and the 7th column. If

Re: imaplib: how to specify SSL/TLS protocol version?

2014-04-09 Thread Grant Edwards
On 2014-04-09, Grant Edwards wrote: > Connecting to Exchange server fails like this: > > File "/usr/lib64/python2.7/imaplib.py", line 1148, in __init__ >IMAP4.__init__(self, host, port) > SSLError: [Errno 1] _ssl.c:1419: error:1408F10B:SSL > routines:SSL3_GET_RECORD:wrong version number > >

imaplib: how to specify SSL/TLS protocol version?

2014-04-09 Thread Grant Edwards
Connecting to Exchange server fails like this: File "/usr/lib64/python2.7/imaplib.py", line 1148, in __init__ IMAP4.__init__(self, host, port) SSLError: [Errno 1] _ssl.c:1419: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number Experiments show that when calling ssl.wrap_socket

CommandLine Option in Python for filtering values from Column

2014-04-09 Thread rohan bareja
I want to write a function in Python for a tab delimited file I am dealing with,to filter out values from a column, and put that parameter as a command line option while running the script. So,if the limit is 10,the filter out all the rows with values less than 10. Also,I want to check if the nu

Re: Unpacking U-Boot image file

2014-04-09 Thread trewio
U-Boot format: hmm, I'm not sure, can someone specify Python script that will help me deterermine U-boot format used? [for Python for Windows OS] Note: I need Python script for Python under Windows OS. > - Original Message - > From: Rustom Mody > Sent: 04/09/14 08:18 PM > To: python-lis

Re: Unpacking U-Boot image file

2014-04-09 Thread trewio
I need decompress image(modem), and I deciced use some Python script or utility which capable run on Python for Windows OS. > - Original Message - > From: Adnan Sadzak > Sent: 04/09/14 08:33 PM > To: python-list > Subject: Re: Unpacking U-Boot image file > > I belive you are trying t

Re: threading

2014-04-09 Thread Sturla Molden
Chris Angelico wrote: > People with a fear of threaded programming almost certainly never grew > up on OS/2. :) I learned about GUI programming thus: Write your > synchronous message handler to guarantee that it will return in an > absolute maximum of 0.1s, preferably a lot less. If you have any

Re: threading

2014-04-09 Thread Chris Angelico
On Thu, Apr 10, 2014 at 3:47 AM, MRAB wrote: > On 2014-04-09 16:51, Rick Johnson wrote: >> And the evil incarnation of the IMPLICIT PRONOUN raises >> it's ugly head!!! >> > (And it's "its ugly head", BTW.) Fundamental rule of the internet: If you criticize someone else's spelling or gra

Re: threading

2014-04-09 Thread Chris Angelico
On Thu, Apr 10, 2014 at 3:31 AM, Marko Rauhamaa wrote: > Really, the threading model is only good for a relatively small subset > of programming objectives, and over the lifetime of the solution, you > will often come to realize threading wasn't that good a fit after all. > Namely, in any given st

Re: threading

2014-04-09 Thread MRAB
On 2014-04-09 16:51, Rick Johnson wrote: [snip] 3. It irks me that language designers pay no attention to consistency. And the evil incarnation of the IMPLICIT PRONOUN raises it's ugly head!!! The pronoun isn't implicit, because it's actually present! (And it's "its ug

Re: threading

2014-04-09 Thread Marko Rauhamaa
"Frank Millman" : > I am finding difficulty in understanding the benefit of going async in > my case. If most requests require a blocking handler, it seems that I > might as well stick with each request being handled by a thread, > independent of all other threads. When the underlying facilities

Re: Unpacking U-Boot image file

2014-04-09 Thread Adnan Sadzak
I belive you are trying to decompress some router images or router backup/config files? Check if maybe LZS. Rustom gave You starting point. On Wed, Apr 9, 2014 at 7:18 PM, Rustom Mody wrote: > On Wednesday, April 9, 2014 9:36:40 PM UTC+5:30, trewio wrote: > > How to extract files from U-Boot

Re: Unpacking U-Boot image file

2014-04-09 Thread Rustom Mody
On Wednesday, April 9, 2014 9:36:40 PM UTC+5:30, trewio wrote: > How to extract files from U-Boot image file, LZMA-compressed? > > Is there a Python script that can do this properly? For lzma theres this (recent) python library https://docs.python.org/dev/library/lzma.html Though you might just

Re: threading

2014-04-09 Thread Marko Rauhamaa
"Frank Millman" : > Does reading from disk count as blocking? Strictly speaking I would > have thought 'yes'. You have touched upon a very interesting topic there. I can't speak for Windows, but linux doesn't really let you control the blocking of disk access. In fact, linux doesn't really let y

Re: threading

2014-04-09 Thread Sturla Molden
Sturla Molden wrote: > 3. It is nice to be able to abort a read or write that hangs (for whatever > reason). Killing a thread with pthread_cancel or TerminateThread is not > recommended. While "graceful timeout" is easy to do on Unix, using fcntl.fcntl or signal.alarm, on Windows it requires ov

Re: threading

2014-04-09 Thread Chris Angelico
On Thu, Apr 10, 2014 at 2:14 AM, Terry Reedy wrote: > On 4/9/2014 10:30 AM, Frank Millman wrote: > >> In other words, non-blocking implies that everything required to pass off >> the request to a handler and be ready to deal with the next one must >> already >> be in memory, and it must not rely o

Unpacking U-Boot image file

2014-04-09 Thread trewio
How to extract files from U-Boot image file, LZMA-compressed? Is there a Python script that can do this properly? -- https://mail.python.org/mailman/listinfo/python-list

Re: threading

2014-04-09 Thread Terry Reedy
On 4/9/2014 10:30 AM, Frank Millman wrote: In other words, non-blocking implies that everything required to pass off the request to a handler and be ready to deal with the next one must already be in memory, and it must not rely on communicating with any outside resource at all. Is this correct?

Re: threading

2014-04-09 Thread Rick Johnson
On Wednesday, April 9, 2014 8:50:59 AM UTC-5, Neil D. Cerutti wrote: > [...] > Plus Rufus Xavier Sasparilla disagrees with it. If you think you're going to argue in such an implicit manner as to the benefits of pronouns, then you should expect that an astute logician such as myself will tear you t

Re: "Latching" variables in function

2014-04-09 Thread alister
On Wed, 09 Apr 2014 08:53:19 -0500, Mark H Harris wrote: > On 4/8/14 3:09 PM, Grawburg wrote: > >> I have a N/O pushbutton that I want to "latch" a value to a variable >> when it's been pressed. >> I need button_value to become '1' when the button is pressed and to >> remain '1' until ... > >> W

Re: threading

2014-04-09 Thread Sturla Molden
"Frank Millman" wrote: > If I have understood correctly, then is there any benefit at all in my going > async? I might as well just stick with threads for the request handling as > well as the database handling. 1. There is a scalability issue with threads, particularly if you don't have enoug

Re: threading

2014-04-09 Thread Roy Smith
In article , "Frank Millman" wrote: > "Chris Angelico" wrote in message > news:captjjmqwhb8o8vq84mmtv+-rkc3ff1aqdxe5cs8y5gy02kh...@mail.gmail.com... > > On Wed, Apr 9, 2014 at 11:23 PM, Frank Millman wrote: > > > >> How does one distinguish betwen 'blocking' and 'non-blocking'? Is it > >> eit

Re: threading

2014-04-09 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87lhveobeq@elektro.pacujo.net... > "Frank Millman" : > >> I understand that, if one uses threading, each thread *can* block >> without affecting other threads, whereas if one uses the async >> approach, a request handler must *not* block, otherwise it w

Re: threading

2014-04-09 Thread Roy Smith
In article , Chris Angelico wrote: > For instance, the above code assumes that print() won't block. You > might think "Duh, how can printing to the screen block?!?", but if > your program's output is being piped into something else, it most > certainly can :) Heh. One day, a long time ago

Re: threading

2014-04-09 Thread Chris Angelico
On Thu, Apr 10, 2014 at 12:30 AM, Frank Millman wrote: > > "Chris Angelico" wrote in message > news:captjjmqwhb8o8vq84mmtv+-rkc3ff1aqdxe5cs8y5gy02kh...@mail.gmail.com... >> On Wed, Apr 9, 2014 at 11:23 PM, Frank Millman wrote: >> >>> How does one distinguish betwen 'blocking' and 'non-blocking'?

Re: threading

2014-04-09 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmqwhb8o8vq84mmtv+-rkc3ff1aqdxe5cs8y5gy02kh...@mail.gmail.com... > On Wed, Apr 9, 2014 at 11:23 PM, Frank Millman wrote: > >> How does one distinguish betwen 'blocking' and 'non-blocking'? Is it >> either/or, or is it some arbitrary timeout - if a han

Re: threading

2014-04-09 Thread Marko Rauhamaa
"Frank Millman" : > I understand that, if one uses threading, each thread *can* block > without affecting other threads, whereas if one uses the async > approach, a request handler must *not* block, otherwise it will hold > up the entire process and not allow other requests to be handled. Yes. >

Re: threading

2014-04-09 Thread Chris Angelico
On Wed, Apr 9, 2014 at 11:23 PM, Frank Millman wrote: > Can I ask a newbie question here? You certainly can! > I understand that, if one uses threading, each thread *can* block without > affecting other threads, whereas if one uses the async approach, a request > handler must *not* block, otherw

Re: "Latching" variables in function

2014-04-09 Thread Mark H Harris
On 4/8/14 3:09 PM, Grawburg wrote: I have a N/O pushbutton that I want to "latch" a value to a variable when it's been pressed. I need button_value to become '1' when the button is pressed and to remain '1' until ... What do I use to 'latch' button_value? Philosophically speaking buttons

Re: threading

2014-04-09 Thread Neil D. Cerutti
On 4/8/2014 9:09 PM, Rick Johnson wrote: I warn you that not only will "it" impede the interpretation of your ideas, "it" will also degrade your ability to think clearly when expressing yourself and slow (or completely halt) your linguistic evolution. HAVE YOU NOTICED THAT YOUR INNER MONOLO

Re: threading

2014-04-09 Thread Mark Lawrence
On 08/04/2014 17:38, Paul Rubin wrote: Sturla Molden writes: As it turns out, if you try hard enough, you can always construct a race condition, deadlock or a livelock. If you need to guard against it, there is paradigms like BSP, but not everything fits in. a BSP design. Software transaction

Re: how to insert the elements in a list properly?

2014-04-09 Thread Dan Sommers
On Wed, 09 Apr 2014 21:09:37 +0800, length power wrote: > words = ["x1", "x2", "x3", "x4", "x5"] > words.append(words.pop(2)) > words.append(words.pop(2)) > words > ['x1', 'x2', 'x5', 'x3', 'x4'] > why i can't write it as: > > [words.append(words.pop(2)) for i in range(0,2)] > [words.append

Re: how to insert the elements in a list properly?

2014-04-09 Thread length power
words = ["x1", "x2", "x3", "x4", "x5"] words.append(words.pop(2)) words.append(words.pop(2)) words ['x1', 'x2', 'x5', 'x3', 'x4'] why i can't write it as: [words.append(words.pop(2)) for i in range(0,2)] >>> [words.append(words.pop(2)) for i in range(0,2)] [None, None] 2014-04-09 18:46 GMT+08:0

Re: "Latching" variables in function

2014-04-09 Thread Tim Chase
On 2014-04-08 16:09, Grawburg wrote: > def button(): >    pushbutton = 0 >   button_value = 0 >    pushbutton=bus.read_byte_data(address,GPIOB) >    if pushbutton > 0: >         button_value = 1 >    return button_value > > I need button_value to become '1' when the button is pressed and to > rema

Re: threading

2014-04-09 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:877g70wg8p@elektro.pacujo.net... > Dennis Lee Bieber : > >> That's been my experience too... Threading works for me... My >> attempts at so called asyncio (whatever language) have always led to >> my having to worry about losing data if some handler tak

Re: "Latching" variables in function

2014-04-09 Thread William Ray Wing
On Apr 9, 2014, at 12:35 AM, Terry Reedy wrote: > On 4/8/2014 4:09 PM, Grawburg wrote: >> >> I've probably used the wrong term - I'm thinking of what I do when writing >> PLC code - so I can't find how to do this in my reference books. >> This is part of a project I'm working on with a Raspberr

Re: [OFF-TOPIC] How do I find a mentor when no one I work with knows what they are doing?

2014-04-09 Thread Antoon Pardon
On 08-04-14 15:58, alister wrote: > On Tue, 08 Apr 2014 13:47:12 +, Grant Edwards wrote: > >> On 2014-04-08, Chris Angelico wrote: >>> On Tue, Apr 8, 2014 at 5:07 PM, James Brewer wrote: >>> Basically, I want to be a better engineer. Where can I find someone willing to point me in t

Re: is there more simple way to do?

2014-04-09 Thread Peter Otten
length power wrote: > x='name,sex,birthday\n\nx1,male,1948/05/28\n\nx2,female,1952/03/27 > \n\nx3,female,1994/12/09' > x.replace("\n\n","\n").splitlines() > > is there more simple way to replace `x.replace("\n\n","\n").splitlines()` > ? One alternative that ignores all empty lines is [line for

Re: how to insert the elements in a list properly?

2014-04-09 Thread Peter Otten
length power wrote: > word=["x1","x2","x3","x4","x5"] > w=word[-2:] > del word[-2:] > word.insert(2,w) > word > ['x1', 'x2', ['x4', 'x5'], 'x3'] > > what i want to get is > ['x1', 'x2', 'x4', 'x5', 'x3'] > > how can i insert them ? Make the left-hand side an empty slice: >>> words = ["x1", "x2

how to insert the elements in a list properly?

2014-04-09 Thread length power
word=["x1","x2","x3","x4","x5"] w=word[-2:] del word[-2:] word.insert(2,w) word ['x1', 'x2', ['x4', 'x5'], 'x3'] what i want to get is ['x1', 'x2', 'x4', 'x5', 'x3'] how can i insert them ? -- https://mail.python.org/mailman/listinfo/python-list

is there more simple way to do?

2014-04-09 Thread length power
x='name,sex,birthday\n\nx1,male,1948/05/28\n\nx2,female,1952/03/27 \n\nx3,female,1994/12/09' x.replace("\n\n","\n").splitlines() is there more simple way to replace `x.replace("\n\n","\n").splitlines()` ? -- https://mail.python.org/mailman/listinfo/python-list

Re: Keeping track of things with dictionaries

2014-04-09 Thread Gene Heskett
On Wednesday 09 April 2014 05:47:37 Ian Kelly did opine: > On Tue, Apr 8, 2014 at 9:31 PM, Gene Heskett wrote: > >> 'Pneumonoultramicroscopicsilicovolcanoconiosis' has them all beat. > > > > Source citation please? > > http://en.wikipedia.org/wiki/Pneumonoultramicroscopicsilicovolcanoconios > i

Re: Python and Unicode

2014-04-09 Thread Steve Hayes
On Wed, 9 Apr 2014 01:07:20 -0700 (PDT), wxjmfa...@gmail.com wrote: >Well, there is a (serious) problem somewhere... As there is with pandas and infertility. -- Terms and conditions apply. Steve Hayes hayesm...@hotmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: [OFF-TOPIC] How do I find a mentor when no one I work with knows what they are doing?

2014-04-09 Thread Mark Lawrence
On 09/04/2014 01:02, alex23 wrote: On 9/04/2014 3:29 AM, Chris Angelico wrote: My code would make for terrible PHP. :) Don't feel bad about that. It's a truism for every language, including PHP. Yep. And the worst thing about terrible code is when you first realise just how bad it is and w

Re: Python and Unicode

2014-04-09 Thread Mark Lawrence
On 09/04/2014 09:07, wxjmfa...@gmail.com wrote: Well, there is a (serious) problem somewhere... jmf Look in a mirror and you'll see it as it'll be staring you in the face. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawren

Re: [OFF-TOPIC] How do I find a mentor when no one I work with knows what they are doing?

2014-04-09 Thread Mark Lawrence
On 08/04/2014 21:19, James Brewer wrote: On Tue, Apr 8, 2014 at 12:47 PM, Rick Johnson mailto:rantingrickjohn...@gmail.com>> wrote: You're an interesting fellow. Also, I didn't graduate; I dropped out. try: print('rr is okay when discussing IDLE or tkinter') except TrollingError: prin

Python and Unicode

2014-04-09 Thread wxjmfauth
Well, there is a (serious) problem somewhere... jmf -- https://mail.python.org/mailman/listinfo/python-list

Re: [OFF-TOPIC] How do I find a mentor when no one I work with knows what they are doing?

2014-04-09 Thread Larry Hudson
On 04/08/2014 08:02 AM, Chris Angelico wrote: On Wed, Apr 9, 2014 at 12:28 AM, Larry Martell wrote: I've worked at places where: Add to that list: - Some of the programmers really aren't programmers, but the boss just hasn't figured it out yet. That was my last job, until said non-programme

Re: solutions manual and test banks

2014-04-09 Thread Chris Angelico
On Wed, Apr 9, 2014 at 5:47 PM, Carlin Li wrote: > Approximately how much do you charge for these solutions manuals? > You're responding to a spambot. I advise against it :) Most of us didn't even see the original post (I certainly didn't), and you really don't want to be inviting more spam. Chr

Re: [OFF-TOPIC] How do I find a mentor when no one I work with knows what they are doing?

2014-04-09 Thread James Brewer
On Tue, Apr 8, 2014 at 7:19 PM, Chris Angelico wrote: > On Wed, Apr 9, 2014 at 6:19 AM, James Brewer wrote: > > You're an interesting fellow. > > Rick's one of our resident... uhh... characters. Don't take his words to > heart. > > > Also, I didn't graduate; I dropped out. > > I dropped out of h

Re: solutions manual and test banks

2014-04-09 Thread Carlin Li
Approximately how much do you charge for these solutions manuals? -- https://mail.python.org/mailman/listinfo/python-list