Having troubles with list methods

2013-08-01 Thread Adam Sweiger
The code: pastebin.com/MyrLB704 I'm working on this program in my Python book, and for some reason it doesn't seem to be working. I've read my code, it seems fine to me. Here's what the book says: The High Scores program uses list methods to create and maintain a list of the user's best scores

Re: Having troubles with list methods

2013-08-01 Thread Adam Sweiger
On Thursday, August 1, 2013 8:11:42 PM UTC-5, Sam Whitehead wrote: > Your indentation is such that the first print statement is the only thing > inside the while loop. I corrected the indentation and it works perfectly now. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-07 Thread adam . preble
We were coming into Python's unittest module from backgrounds in nunit, where they use a decorate to identify tests. So I was hoping to avoid the convention of prepending "test" to the TestClass methods that are to be actually run. I'm sure this comes up all the time, but I mean not to have to

Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-08 Thread adam . preble
On Thursday, August 8, 2013 3:50:47 AM UTC-5, Peter Otten wrote: > Peter Otten wrote: > Oops, that's an odd class name. Fixing the name clash in Types.__new__() is > > left as an exercise... I will do some experiments with a custom test loader since I wasn't aware of that as a viable alternativ

Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-08 Thread adam . preble
On Thursday, August 8, 2013 3:04:30 AM UTC-5, Terry Reedy wrote: > I cannot help but note that this is *more* typing. But anyhow, something It wasn't so much about the typing so much as having "test" in front of everything. It's a problem particular to me since I'm writing code that, well, run

Using sudo to write to a file as root from a script

2013-08-08 Thread Adam Mercer
, 'sudo', 'tee', config_file] p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = p.communicate() But it seems as if this isn't doing anything. I just want to write the contents of the variable channel to the file /opt/ldg/etc/channel.con

Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-08 Thread adam . preble
On Thursday, August 8, 2013 3:50:47 AM UTC-5, Peter Otten wrote: > Peter Otten wrote: > Oops, that's an odd class name. Fixing the name clash in Types.__new__() is > > left as an exercise... Interesting, I got __main__.T, even though I pretty much just tried your code wholesale. For what it's

Resolving import errors reported by PyLint in modules using Python.NET

2013-08-08 Thread adam . preble
PyLint can't figure out imports of .NET code being referenced in my Python scripts that use Python.NET. I can kind of see why; you have to evaluate some clr.AddReference calls for the imports to even succeed. I wonder if I have any recourse. Generally, to import a DLL you have to do a few thi

Re: Using sudo to write to a file as root from a script

2013-08-09 Thread Adam Mercer
uot;echo -n %s | sudo tee %s > /dev/null" % (channel, config_file) try: retcode = subprocess.call(command, shell=True) if retcode < 0: sys.exit('Error: Failed to set channel.conf') except OSError as e: sys.exit('Error: Execution failed "%s"' % e) But I was under the impression that Popen was the preferred approach to running external processes? Cheers Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Using sudo to write to a file as root from a script

2013-08-09 Thread Adam Mercer
On Fri, Aug 9, 2013 at 8:29 AM, Chris Angelico wrote: > You shouldn't need to use 'echo' here. Just provide tee with the text > on its standard input, and don't bother with the pipe at all. Thanks, that's much better! Cheers Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Using sudo to write to a file as root from a script

2013-08-09 Thread Adam Mercer
On Fri, Aug 9, 2013 at 8:42 AM, Antoon Pardon wrote: > That is probably beside the point. I suspect Adam is just giving a > minimal example to show the kind of thing he is trying to do. > > Nit picking the specific example instead of advising on the problem > is likely to be le

Re: Resolving import errors reported by PyLint in modules using Python.NET

2013-08-11 Thread adam . preble
I thought I responded to this. Oh well On Friday, August 9, 2013 12:47:43 AM UTC-5, Benjamin Kaplan wrote: > Are you using Python.NET or IronPython? IronPython is reasonably well > > supported, and it looks like there's a patch you can use to get PyLint > > working on it (see > > http://mail.

Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-11 Thread adam . preble
On Friday, August 9, 2013 1:31:43 AM UTC-5, Peter Otten wrote: > I see I have to fix it myself then... Sorry man, I think in my excitement of seeing the first of your examples to work, that I missed the second example, only seeing your comments about it at the end of the post. I didn't expect s

Re: New to Python - block grouping (spaces)

2015-04-16 Thread Ron Adam
On 04/16/2015 01:41 PM, Steven D'Aprano wrote: >2. Having been an employer, it is difficult to force programmers to use >any particular editor or style. Different editors handle tabs and spaces >differently. This is all a bloody nightmare with Python. Do you really expect us to believe for

Re: Great Math Mystery

2015-04-17 Thread Ron Adam
On 04/17/2015 11:03 AM, Steven D'Aprano wrote: On Fri, 17 Apr 2015 07:47 pm, Fetchinson . wrote: >>>In an altercation with the police, complying with their orders greatly >>>increases your chances of survival. >> >>Ah, the definition of a police state: where ordinary people, whether >>breaki

Re: New to Python - block grouping (spaces)

2015-04-19 Thread Ron Adam
On 04/19/2015 05:42 PM, BartC wrote: So I'm aware of some of the things that are involved. (BTW that project worked reasonably well, but I decided to go in a different direction: turning "J" from a mere syntax into an actual language of its own.) Something you might try with your new langua

An experiment with blocks of object code and other meta ideas.

2015-04-27 Thread Ron Adam
nested lists of object code that can be passed around. Actually programs are nested lists of object codes. It's just the outer most block. These features make it an interesting meta language to experiment with. If you think you may be interested in helping with this project, (It's open

Re: Rule of order for dot operators?

2015-05-18 Thread Ron Adam
On 05/18/2015 09:32 PM, Rustom Mody wrote: >In particular, each .foo() need not return a string - it might return anything, >and the following .bah() will work on that anything. For an arbitrary binary operator ◼ x ◼ y ◼ z can group as (x◼y)◼z or x◼(y◼z) One could (conceivably) apply the same

Re: Rule of order for dot operators?

2015-05-19 Thread Ron Adam
On 05/19/2015 02:25 AM, Chris Angelico wrote: On Tue, May 19, 2015 at 12:43 PM, Ron Adam wrote: >Having just implementing something similar for nested scopes, it turns out >it can't be operators because if it was, then the names y and z would be >resolved in the wrong scope.

Re: Set a flag on the function or a global?

2015-06-15 Thread Ron Adam
On 06/15/2015 08:07 PM, Chris Angelico wrote: On Tue, Jun 16, 2015 at 9:57 AM, Steven D'Aprano wrote: >I have two ideas for this, a module-level global, or a flag set on the >function object itself. Remember that the usual way of using this will be >"from module import edir", there are two o

Re: Set a flag on the function or a global?

2015-06-16 Thread Ron Adam
On 06/16/2015 05:15 AM, Steven D'Aprano wrote: On Tuesday 16 June 2015 10:24, Ron Adam wrote: >Another way is to make it an object with a __call__ method. > >The the attribute can be accessed from both outside and inside dependably. That's what functions are, objects wit

Re: Lawful != Mutable (was Can Python function return multiple data?)

2015-06-21 Thread Ron Adam
On 06/20/2015 10:50 PM, Rustom Mody wrote: Here is Eric Snow: | Keep in mind that by "immutability" I'm talking about*really* | immutable, perhaps going so far as treating the full memory space | associated with an object as frozen. For instance, we'd have to | ensure that "immutable" Python

An asyncio example

2015-07-03 Thread Adam Bartoš
oop.create_task(server_coro) client_task = loop.create_task(client_coro) return client_task loop = asyncio.get_event_loop() task = loop.run_until_complete(connect(loop)) loop.run_until_complete(task) Thank you, Adam Bartoš -- https://mail.python.org/mailman/listinfo/python-list

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
Ian Kelly: >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the loop, >> is that desired behavior? And why? > > I don't think so. When I tried this locally (using Python 3.4.0, so > replacing "async def" with "def" and "await" with "yield from" and > "loop.create_task" with "as

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
>> Marko Rauhamaa: >>> socket.shutdown(socket.SHUT_WR) does the trick. >>> >>> I think the asyncio.StreamWriter.write_eof() is the high-level >>> equivalent. >> >> You are right that writer.write_eof() behaves like >> writer.transport.get_extra_info("socket").shutdown(socket.SHUT_WR) – >> the serve

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš wrote: > Ian Kelly: > > >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the > loop, > >> is that desired behavior? And why? > > > > I don't think so. When I tried this locally (usin

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
> > On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš wrote: >> >>> Ian Kelly: >>> >> >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the >>> loop >>> >> >> is that desired behavior? And why? >>

Re: An asyncio example

2015-07-04 Thread Adam Bartoš
On Sat, Jul 4, 2015 at 8:45 AM, Adam Bartoš wrote: > On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš wrote: >>> >>>> Ian Kelly: >>>> >>> >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the >>>> loop >>

Re: An asyncio example

2015-07-04 Thread Adam Bartoš
> > On Fri, Jul 3, 2015 at 9:14 AM, Marko Rauhamaa > wrote: > > > >>> 1) is there a way to close just one direction of the connection? > >> > >> No. SOCK_STREAM sockets are always bidirectional. > > > > socket.shutdown(socket.SHUT_WR) does the trick. > > > > I think the asyncio.StreamWriter.write_

Re: An asyncio example

2015-07-04 Thread Adam Bartoš
On Sat, Jul 4, 2015 at 1:07 PM, Adam Bartoš wrote: > On Fri, Jul 3, 2015 at 9:14 AM, Marko Rauhamaa >> wrote: >> > >> >>> 1) is there a way to close just one direction of the connection? >> >> >> >> No. SOCK_STREAM sockets are always bidi

Re: An asyncio example

2015-07-05 Thread Adam Bartoš
Terry Reedy wrote: > I suggest you post your minimal example there. User interest in an > issue being fixed and willingness to test patches can help motivate. I've done it. Thank you for help. -- https://mail.python.org/mailman/listinfo/python-list

Re: (side-)effects and ...

2015-07-05 Thread Ron Adam
On 07/05/2015 04:29 PM, Stefan Ram wrote: But why do we not have a common and well-known term for the counterpart, that something does not modify the state of the world, but that the state of the world does influence the value (behaviour) of a call such as »datetime.datetime.now

Capturing stdin and stdout using ctypes

2015-07-26 Thread Adam Bartoš
Hello, how can I capture C stdin and stdout file pointers using ctypes in Python 3? I want them to be able to call PyOS_Readline via ctypes. Thank you, Adam Bartoš -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Questions - July 25, 2015

2015-07-26 Thread Adam Bartoš
> How do you actually install Numpy in Windows? In theory, `pip install numpy` should work, but there are currently no wheels for Windows, see https://github.com/numpy/numpy/issues/5479. Try `pip install -i https://pypi.binstar.org/carlkl/simple numpy` (see last posts in the issue). Adam Bar

Python 2.7: _PyLong_NumBits() Segfault

2015-08-14 Thread Adam Meily
I am working on a CPython library that serializes Python objects to disk in a custom format. I'm using _PyLong_NumBits() to determine whether PyLong_AsLong(), PyLong_AsUnsignedLong(), PyLong_AsLongLong(), or PyLong_AsUnsignedLongLong() should be used. In Python 3.x, I'm able to determine how many

Standard way to generate mail/news reply?

2014-06-24 Thread Adam Funk
his in Perl (sorry) years ago, but before I reimplement it in Python, I thought I should ask if there's a "good" way. Thanks, Adam -- A recent study conducted by Harvard University found that the average American walks about 900 miles a year. Another study by the AMA found tha

Re: Standard way to generate mail/news reply?

2014-06-26 Thread Adam Funk
On 2014-06-24, Skip Montanaro wrote: > On Tue, Jun 24, 2014 at 6:46 AM, Adam Funk wrote: >> Is there some standard library or code for taking an e-mail or >> newsgroup message & generating a reply to it? > > You might try searching for "mail reply" on pypi.pyth

Re: How to extract contents of inner text of html tag?

2014-06-27 Thread Jesse Adam
I don't have BeautifulSoup installed so I am unable to tell whether a) for line in all_kbd: processes one line at a time as given in the input, or do you get the clean text in single lines in a list as shown in the example in the doc http://www.crummy.com/software/BeautifulSoup/bs4/doc/#searching

Re: multiprocessing in a while loop?

2014-06-27 Thread Jesse Adam
Could you post a) what the output looks like now (sans the logging part) b) what output do you expect In any event, this routine does not look right to me: def consume_queue(queue_name): conn = boto.connect_sqs() q = conn.get_queue(queue_name) m = q.read() while m is not None: yiel

Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-01 Thread Adam Funk
I have some code that reads files in a leafnode2 news spool & needs to check for new files periodically. The full paths are all like '/var/spool/news/message.id/345/<123...@example.com>' with a 3-digit subdirectory & a Message-ID for the filename itself. I'm using Python 3 & sqlite3 in the standa

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-01 Thread Adam Funk
On 2014-07-01, Chris Angelico wrote: > On Tue, Jul 1, 2014 at 9:26 PM, Adam Funk wrote: >> cursor.execute('SELECT filename FROM files WHERE filename IS ?', >> (filename,)) > > Shouldn't this be an equality check rather than IS, which normally I'd

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-02 Thread Adam Funk
On 2014-07-01, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 1:15 AM, Adam Funk wrote: >> On 2014-07-01, Chris Angelico wrote: >> >>> On Tue, Jul 1, 2014 at 9:26 PM, Adam Funk wrote: >>>> cursor.execute('SELECT filename FROM fi

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-02 Thread Adam Funk
On 2014-07-01, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 1:15 AM, Adam Funk wrote: >> On 2014-07-01, Chris Angelico wrote: >>> There is one critical consideration, though. What happens if the >>> directory name contains an underscore or percent sign? Or can y

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-02 Thread Adam Funk
On 2014-07-02, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 7:32 PM, Adam Funk wrote: >> Well, I've changed it to the following anyway. >> >> subdir_glob = subdir + '/*' >> cursor.execute('SELECT filename FROM files WHERE filename

Online Python Channel

2014-07-26 Thread Adam Nowak
To whom it may concern We at Eyn2k (Everything you need to know) have dedicated our time to create a free educational channel. Our first subject being Python Programming. Soon excercises will be added, progressing to a graphics calculator and 2D vector collisions. Would it be possible to get a me

Test failure while building cpython

2014-08-20 Thread Adam Bishop
use it to fail? I don't see how the CFLAGS used in the build process could change during the test run. Other details: CentOS 7 x86_64, GCC 4.8.2, Python 3.3.2, mock 1.1.41 [1] https://github.com/python/cpython/blob/edc966f9c5bc9291d2b7009f600e243142cf8a22/Lib/distutils/tests/test_sysconfig.p

Re: Test failure while building cpython

2014-08-20 Thread Adam Bishop
ompiled on > CentOS will run tests without failure. It's possible... I've got a full RHEL license somewhere here, so I might see if I can reproduce it there. Thanks for pointing me in the right direction. Regards, Adam Bishop gpg: 0x6609D460 Janet, the UK's research

Re: How to create python web framework for ERP

2014-09-09 Thread Adam Nešpůrek
I would say you can still use Django. See django-oscar for instance, it is 'ecommerce framework', based od Django. I would highly recommend to stick around Django, because of its huge ecosystem. You can still add/write some missing parts yourself. Can you be more specific, why Django does not suit

Permissions on files installed by pip?

2014-10-16 Thread Adam Funk
I've been using the python-nltk package on Ubuntu, but I need ntlk 3.0 now. I used 'sudo aptitude purge python-nltk' to get rid of my existing installation, & followed instructions on the nltk website [1] starting at step 4 (since I already have python-pip & python-numpy packages installed). $ su

Re: [Python-ideas] relaxing keyword usage restrictions

2011-09-08 Thread Adam Jorgensen
About the only keyword I can think of this being even slightly useful for would be class and even then I think that clazz is a pretty acceptable substitute. -- http://mail.python.org/mailman/listinfo/python-list

Re: What do you guys think about adding a method "to_json"

2011-09-11 Thread Adam Jorgensen
Perhaps an actual use-case would clarify the need for this? 2011/9/12 Chris Rebert > 2011/9/11 Juan Pablo Romero Méndez : > > Hello, > > > > What do you guys think about adding a method "to_json" to dictionaries > > and sequence types? Perhaps through a module import? > > Why? We already have js

Re: Killing threads (was Re: Cancel or timeout a long running regular expression)

2011-09-18 Thread Adam Jorgensen
The point of the Java thread.stop() being deprecated seems to have very little to do with undeclared exceptions being raised and a lot to do with objects being left in a potentially damaged state. As Ian said, it's a lot more complex than just adding try/catches. Killing a thread in the middle of

Re: Need A script to open a excel file and extract the data using autofilter

2011-10-03 Thread Adam Przybyla
/ Regards Adam Przybyla -- http://mail.python.org/mailman/listinfo/python-list

recommend a graphics library for plotting by the pixel?

2011-10-04 Thread Adam Funk
I'd like to create a window with a "pause" button and a large plotting area, in which I'd like to draw a polygon, detect the pixel coördinates of a mouse click, and then start setting the colors of pixels by (x,y) coördinates. (This is just for my own amusement, to play with some formulas for gene

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

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

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

2011-10-07 Thread Adam Funk
On 2011-10-04, Ian Kelly wrote: > On Tue, Oct 4, 2011 at 3:56 AM, Adam Funk wrote: >> I'd like to create a window with a "pause" button and a large plotting >> area, in which I'd like to draw a polygon, detect the pixel >> coördinates of a mouse cl

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

2011-10-07 Thread Adam Funk
On 2011-10-05, Westley Martínez wrote: > On Wed, Oct 05, 2011 at 02:29:38PM +0100, Adam Funk wrote: >> I only know PyGame because we did an exercise in recreating the old >> breakout game and messing around with it at a local Python group. >> >> I was under the mi

suppressing bad characters in output PCDATA (converting JSON to XML)

2011-11-25 Thread Adam Funk
I'm converting JSON data to XML using the standard library's json and xml.dom.minidom modules. I get the input this way: input_source = codecs.open(input_file, 'rb', encoding='UTF-8', errors='replace') big_json = json.load(input_source) input_source.close() Then I recurse through the contents of

Re: suppressing bad characters in output PCDATA (converting JSON to XML)

2011-11-29 Thread Adam Funk
On 2011-11-28, Stefan Behnel wrote: > Adam Funk, 25.11.2011 14:50: >> I'm converting JSON data to XML using the standard library's json and >> xml.dom.minidom modules. I get the input this way: >> >> input_source = codecs.open(input_file, 'rb',

Re: suppressing bad characters in output PCDATA (converting JSON to XML)

2011-11-29 Thread Adam Funk
On 2011-11-28, Steven D'Aprano wrote: > On Fri, 25 Nov 2011 13:50:01 +0000, Adam Funk wrote: > >> I'm converting JSON data to XML using the standard library's json and >> xml.dom.minidom modules. I get the input this way: >> >> input_source =

Re: suppressing bad characters in output PCDATA (converting JSON to XML)

2011-12-02 Thread Adam Funk
On 2011-11-29, Stefan Behnel wrote: > Adam Funk, 29.11.2011 13:57: >> On 2011-11-28, Stefan Behnel wrote: >>> If the name "big_json" is supposed to hint at a large set of data, you may >>> want to use something other than minidom. Take a look at the >

mutually exclusive arguments to a constructor

2011-12-30 Thread Adam Funk
(Warning: this question obviously reflects the fact that I am more accustomed to using Java than Python.) Suppose I'm creating a class that represents a bearing or azimuth, created either from a string of traditional bearing notation ("N24d30mE") or from a number indicating the angle in degrees as

Re: mutually exclusive arguments to a constructor

2011-12-31 Thread Adam Funk
On 2011-12-30, Roy Smith wrote: > "But!", some C++/Java type bondage addicts might cry, "there's nothing > to prevent somebody from creating a DirectionIndicatingThingie directly, > bypassing the factory functions. There's no way to make the constructor > private!". To which the free-willed p

Re: mutually exclusive arguments to a constructor

2011-12-31 Thread Adam Funk
On 2011-12-30, Günther Dietrich wrote: > Adam Funk wrote: > >>Suppose I'm creating a class that represents a bearing or azimuth, >>created either from a string of traditional bearing notation >>("N24d30mE") or from a number indicating the angle in degree

Re: Avoid race condition with Popen.send_signal

2012-01-02 Thread Adam Skutt
ondition cannot be removed nor avoided. Ideally, avoid the need to send the subprocess a signal in the first place. If it cannot be avoided, then trap the exception. Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Avoid race condition with Popen.send_signal

2012-01-02 Thread Adam Skutt
e child process is dead". Hence why you should avoid sending the signal in the first place: the situations where you don't run the risk of possibly killing an innocent bystander are pretty narrow. While unlikely on modern UNiX and Linux, IMO it's best to avoid the issue altogether when

Re: Avoid race condition with Popen.send_signal

2012-01-03 Thread Adam Skutt
On Jan 3, 7:31 am, Heiko Wundram wrote: > Am 03.01.2012 02:19, schrieb Adam Skutt: > > > On Jan 2, 6:09 pm, Jérôme  wrote: > >> What is the clean way to avoid this race condition ? > > > The fundamental race condition cannot be removed nor avoided. Ideally,

Re: Avoid race condition with Popen.send_signal

2012-01-03 Thread Adam Skutt
On Jan 3, 3:44 am, Jérôme wrote: > Mon, 2 Jan 2012 19:16:50 -0800 (PST) > Adam Skutt a écrit: > > > No. It is possible (however unlikely) for EPERM to be legitimately > > returned in this case.  Anything other than EINVAL should be > > interpreted as "The child

Re: Avoid race condition with Popen.send_signal

2012-01-03 Thread Adam Skutt
n your child processes becoming zombies and kill being called only when the child is alive or a zombie, then you should not be calling kill(2) at all. Killing an unrelated process will be considered as a bug by users. Hence why I find it easier just to avoid the problem altogether if I can. Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Avoid race condition with Popen.send_signal

2012-01-03 Thread Adam Skutt
On Jan 2, 11:53 pm, Cameron Simpson wrote: > On 02Jan2012 19:16, Adam Skutt wrote: > | On Jan 2, 8:44 pm, Cameron Simpson wrote: > | > On 02Jan2012 20:31, Devin Jeanpierre wrote: > | > | > I think that catching the exception is probably the most Pythonic way. > | &

Re: Avoid race condition with Popen.send_signal

2012-01-03 Thread Adam Skutt
quot;process doesn't exist" which both return ESRCH. This is certainly possible with careful coding but I'm not sure I would bother except in the simplest programs. Too many libraries do too many questionable things with signal handlers so I find it much safer and easier just to avoid the damn things whenever possible. Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Avoid race condition with Popen.send_signal

2012-01-03 Thread Adam Skutt
On Jan 3, 10:09 am, Jérôme wrote: > Tue, 3 Jan 2012 06:12:59 -0800 (PST) > Adam Skutt a écrit: > > > The conservative approach is to use another IPC mechanism to talk to > > the process, such as a pipe or a socket.  Why are you trying to send > > the child proces

UnicodeEncodeError when piping stdout, but not when printing directly to the console

2012-01-04 Thread Adam Funk
ollowing (for example): UnicodeEncodeError: 'ascii' codec can't encode character u'\u0107' in position 21: ordinal not in range(128) How can I force python (preferably within my python program, rather than having to set something externally) to treat stdout as UTF-8? T

Re: UnicodeEncodeError when piping stdout, but not when printing directly to the console

2012-01-06 Thread Adam Funk
On 2012-01-04, Peter Otten wrote: > Adam Funk wrote: >> How can I force python (preferably within my python program, rather >> than having to set something externally) to treat stdout as UTF-8? > > > $ cat force_utf8.py > # -*- coding: utf-8 -*- > import sys >

Re: UnicodeEncodeError when piping stdout, but not when printing directly to the console

2012-01-06 Thread Adam Funk
On 2012-01-06, Peter Otten wrote: > Adam Funk wrote: > >> On 2012-01-04, Peter Otten wrote: >> >>> Adam Funk wrote: >> >>>> How can I force python (preferably within my python program, rather >>>> than having to set something externally)

Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-05 Thread Adam Funk
? [1] <http://csil-web.cs.surrey.sfu.ca/cmpt120fall2010/wiki/IntroToEventHandling/> Thanks, Adam -- But the government always tries to coax well-known writers into the Establishment; it makes them feel educated. [Robert Graves] -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-05 Thread Adam Funk
On 2013-02-05, woo...@gmail.com wrote: > Note that the code you posted does not call onclick(). It does, actually, but I accidentally snipped it when C&Ping code into my original post. Sorry! > Globals are > confusing IMHO. Code becomes cleaner and easier to write and read > when you becom

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-05 Thread Adam Funk
On 2013-02-05, Adam Funk wrote: > I'm trying to get a program to do some plotting with turtle graphics, > then wait for the user to click on the graphics window, then do some > more plotting, &c. So far I have the following, which doesn't work: > > #v+ > wait

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-06 Thread Adam Funk
On 2013-02-05, Dave Angel wrote: > I'm no fan of Java. But it's not about a "main" method, it's about > sharing data between functions. Most of the time non-constant globals > are a mistake. If the data can't be passed as an argument, then it > should probably be part of the instance data of

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-06 Thread Adam Funk
On 2013-02-05, Dennis Lee Bieber wrote: > I'll echo the "Ugh" about the use of global AND ADD a dislike of the > busy loop that only exits if some other return sets a value. If the busy > loop were performing some action that changed the test state within the > loop itself, okay... TBH, I w

using urllib on a more complex site

2013-02-24 Thread Adam W.
I'm trying to write a simple script to scrape http://www.vudu.com/movies/#tag/99centOfTheDay/99c%20Rental%20of%20the%20day in order to send myself an email every day of the 99c movie of the day. However, using a simple command like (in Python 3.0): urllib.request.urlopen('http://www.vudu.com/mo

Re: using urllib on a more complex site

2013-02-24 Thread Adam W.
On Sunday, February 24, 2013 7:30:00 PM UTC-5, Dave Angel wrote: > On 02/24/2013 07:02 PM, Adam W. wrote: > > > I'm trying to write a simple script to scrape > > http://www.vudu.com/movies/#tag/99centOfTheDay/99c%20Rental%20of%20the%20day > > > > > > i

Re: using urllib on a more complex site

2013-02-24 Thread Adam W.
On Sunday, February 24, 2013 7:27:54 PM UTC-5, Chris Rebert wrote: > On Sunday, February 24, 2013, Adam W. wrote: > I'm trying to write a simple script to scrape > http://www.vudu.com/movies/#tag/99centOfTheDay/99c%20Rental%20of%20the%20day > > > > > in order

stmplib MIMEText charset weirdness

2013-02-25 Thread Adam W.
Can someone explain to me why I can't set the charset after the fact and still have it work. For example: >>> text = MIMEText('❤¥'.encode('utf-8'), 'html') >>> text.set_charset('utf-8') >>> text.as_string() Traceback (most recent call last): File "", line 1, in text.as_string() File "C:\

Re: stmplib MIMEText charset weirdness

2013-02-26 Thread Adam W.
On Tuesday, February 26, 2013 2:10:28 AM UTC-5, Steven D'Aprano wrote: > On Mon, 25 Feb 2013 20:00:24 -0800, Adam W. wrote: > > The documentation for MIMEText is rather terse, but it implies that the > > parameter given should be a string, not bytes: > > >

Re: Do you feel bad because of the Python docs?

2013-02-26 Thread Adam W.
I think learning a language from the documentation is an unreasonable expectation and burden for the authors. Buy a book, take a class, they are designed to provide you with a path from start to finish in a sensible manner, the documentation in my opinion is supposed to be a reference and a ref

Re: help needed

2013-04-08 Thread Adam Mesha
e/directory". If you're on Windows it's the same idea, you run the "cmd" program, but you would have to specify the full path to the python interpreter instead of just "python", or follow the directions that have been offered for fixing Windows. Adam www.mesha.org -- http://mail.python.org/mailman/listinfo/python-list

How to avoid PEP8 'imported but unused'

2013-05-05 Thread Adam Jiang
e views.py. It seems to me that the code is okay because Django requires all functions serve as 'view' is typically go into views.py. 'import' is about get 'signup' function into module 'views.py'. Or, I am totally wrong? Is there a proper way to avoid this w

Re: How to avoid PEP8 'imported but unused'

2013-05-05 Thread Adam Jiang
Thanks. It works very well. One more question. In this particular case it seems 'assert' should be safe as a workaround, doesn't it? 'assert' will check if the symbol is imported and not NULL. Is there side effect if I just applied this rule as a generic one. /Adam On S

Re: How to avoid PEP8 'imported but unused'

2013-05-05 Thread Adam Jiang
Thank you. Problem solved. /Adam On Sun, May 05, 2013 at 06:27:44PM +0100, Fábio Santos wrote: > That assert will never fail. If the symbol is not imported, the import > statement raises ImportError. And actually "assert" makes sure that > the value is not false-ish, not Non

Re: Fastest Way To Loop Through Every Pixel

2006-07-29 Thread Ron Adam
Chaos wrote: > As my first attempt to loop through every pixel of an image, I used > > for thisY in range(0, thisHeight): > for thisX in range(0, thisWidth): > #Actions here for Pixel thisX, thisY > > But it takes 450-1000 milliseconds > > I want speeds less

ImportError raised in script, not interactive session.

2006-07-31 Thread Adam Blinkinsop
I'm writing a set of modules to monitor remote system services, and I'm having a problem running my test scripts. When I pass the scripts into python, like so: -- $ PYTHONPATH="${TARGET_DIR}" python test.py -- I get an ImportError: -- Traceback (most recent call last): File "./test.py", line

Re: ImportError raised in script, not interactive session.

2006-07-31 Thread Adam Blinkinsop
Jordan R McCoy wrote: > If this isn't the case, what are you using for TARGET_DIR? ${TARGET_DIR} = /home/blinks/projects/overwatch/target/lib/python I've started the interactive session from several different directories, and never had a problem. My make output (note the second item in sys.path):

Re: String.digits help!!!

2006-08-09 Thread Ron Adam
[EMAIL PROTECTED] wrote: > Simon Forman: > >> accessing it from a >> module (perhaps math.. math.infinity, math.epsilon, etc., just like >> math.pi and math.e.) > > It too looks acceptable. > > >> I look forward to hearing your thoughts an the subject. > > Thank you, but I am not expert enoug

Easy Validators

2006-08-20 Thread Ron Adam
Sometimes it's good to check things while working on them. This seems like a good way to do that. You could probably put these in a module and just import them. from validators import * I'm interested if anyone can think of ways to improve this further. Each validator consists of an as

Re: Add users to directory/folder and set permissions in Windows

2006-08-21 Thread Adam Jones
Gallagher, Tim (NE) wrote: > I was wondering if there was a way to add a user in active directory to > a folder and set the permissions. It should be possible. If you can use VBScript or JScript it will be easier to find resources for those. You will probably need, at the least, the win32 extensi

Re: Painless way to do 3D visualization

2006-10-08 Thread Ron Adam
Peter Beattie wrote: > Hey folks, > > I need to do the following relatively simple 3D programming: > > I want to convert data from four-item tuples into 3D co-ordinates in a > regular tetrahedron. Co-ordinates come in sequences of 10 to 20, and the > individual dots in the tetrahedron need to be

Re: 3D Vector Type Line-Drawing Program

2006-10-10 Thread Ron Adam
Scott David Daniels wrote: > James Stroud wrote: >>> I'm looking for a program to do line-drawings in 3d, with output to >>> postscript or svg or pdf, etc. I would like to describe a scene with >>> certain 1-3d elements oriented in 3d space with dashed or colored >>> lines and filled or transpar

Re: 3D Vector Type Line-Drawing Program

2006-10-12 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: >> Scott David Daniels wrote: >>> James Stroud wrote: >>>>> I'm looking for a program to do line-drawings in 3d, with output to >>>>> postscript or svg or pdf, etc. I would like to describe a scene

Alphabetical sorts

2006-10-16 Thread Ron Adam
I have several applications where I want to sort lists in alphabetical order. Most examples of sorting usually sort on the ord() order of the character set as an approximation. But that is not always what you want. The solution of converting everything to lowercase or uppercase is closer, but

<    2   3   4   5   6   7   8   9   10   11   >