Re: Finding where to store application data portably

2005-09-21 Thread Ron Adam
Steven D'Aprano wrote: > On Wed, 21 Sep 2005 20:07:54 +0100, Tony Houghton wrote: > > >> > I wish the Linux Standard Base folks would specify that settings files >> > should all go into a subdirectory like ~/settings rather than filling up >> > the home directory with cruft. That was acceptable

Re: Finding where to store application data portably

2005-09-21 Thread Ron Adam
Tony Houghton wrote: > > I'm using pygame to write a game called Bombz which needs to save some > data in a directory associated with it. In Unix/Linux I'd probably use > "~/.bombz", in Windows something like > "C:\Documents And Settings\\Applicacation Data\Bombz". > > There are plenty of message

Re: Question About Logic In Python

2005-09-22 Thread Ron Adam
Steve Holden wrote: > Ron Adam wrote: >> >> 2. Expressions that will be used in a calculation or another >> expression. >> > By which you appear to mean "expressions in which Boolean values are > used as numbers". Or compared to other types, wh

Re: Finding where to store application data portably

2005-09-22 Thread Ron Adam
Steve Holden wrote: > Ron Adam wrote: > >> Tony Houghton wrote: >> >>> I'm using pygame to write a game called Bombz which needs to save some >>> data in a directory associated with it. In Unix/Linux I'd probably use >>> "~/.bomb

Re: Finding where to store application data portably

2005-09-22 Thread Ron Adam
Tony Houghton wrote: > > This works on Win XP. Not sure if it will work on Linux. > > > > import os > > > > parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0] > > file = parent + os.sep + '.bombz' > > Ooh, no, I don't want saved data to go in the installation directory. In > genera

Re: bytecode obfuscation

2005-02-06 Thread Adam DePrince
On Sun, 2005-02-06 at 08:19, Philippe Fremy wrote: > Adam DePrince wrote: > > No amount of obfuscation is going to help you. > > Theorically, that's true. Anything obfuscated can be broken, just like > the non obfuscated version. However it takes more skills and time to

Re: pickle/marshal internal format 'life expectancy'/backward compatibility

2005-02-06 Thread Adam DePrince
e sure that the data you are reading into your python application was written by you as a hedge against malicious data. Can I, as a user of said card, change the data in the pickle? If so, when you load the pickle back into python you need to confirm that it is a sane pickle that you wrote earlier.

Re: "Collapsing" a list into a list of changes

2005-02-07 Thread Adam Przybyla
.append(n) > > return collapsed > > Is there an elegant way to do this, or should I just stick with the code > above? >>> p=[1,1,1,1,1,4,4,4,8,8,9] >>> filter(lambda y: y>0, map(lambda x,y: x==y and -1 or x,[0]+p,p+[0])) [1, 4, 8, 9] >>> Z

Re: Python versus Perl ?

2005-02-08 Thread Adam DePrince
> discussion). Otherwise the debate will go south real quick. Not only most speed be an issue, but the economics must be such that any alternative is better than throwing more hardware at the problem. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-15 Thread Adam DePrince
empts such a feat and possibly organize unfathomable resources in the attendance of such a lofty goal. Make us proud Ilias. But whatever you do, don't beg. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-15 Thread Adam DePrince
On Tue, 2005-02-15 at 14:25, Ilias Lazaridis wrote: > Adam DePrince wrote: > > On Tue, 2005-02-15 at 13:29, Ilias Lazaridis wrote: > >>Mike Meyer wrote: > >>>Ilias Lazaridis <[EMAIL PROTECTED]> writes: > [...] > >>MinGW compatibility is not [onl

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-15 Thread Adam DePrince
On Tue, 2005-02-15 at 17:24, Jeff Shannon wrote: > Ilias Lazaridis wrote: > > > Adam DePrince wrote: > > [...] > >> You're on it. You drive a car? You have to treat it right to get what > >> you want, right? Same here. Ask correctly, and y

Re: image fourier transform

2005-02-15 Thread Adam DePrince
gt; To do a 2D FFT on a matrix X, you do 1D FFTs on all the rows, producing X', > then you do 1D FFTs on all the columns of X'. > So, for a 32x32 2D FFT, you'll end up doing 64 1D FFTs. FFTW: http://www.fftw.org/ Python bindings for it: http://pylab.sourceforge.net/ Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterator / Iteratable confusion

2005-02-15 Thread Adam DePrince
ators, reiterables, and other. I think this is > didactically useful. Spencerators are reiterables. > Iter(iterator) returning iterator unchanged makes iterator a fixed point of > iter. It ends any chain of objects returned by repeated iter calls. > Spencerators prolong any iter chain, making it infinite instead of finite. > Essential? Repeat the paragraph above with 'a fixed point' substituted for > 'minimal'. How is spencerator different than itertools.tee? Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question convert C to python

2005-02-15 Thread Adam DePrince
. Treat it as you would such a creature in C ... vTable[0][0] = 1 or whatever you want to do. I've seen this question before. Lot in the archives for the subject "2D array" from Dec 7th 2004 - Dec 10th 2004. Steven and I recommended roughly opposite solutions at the time :-) Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: yield_all needed in Python

2005-03-01 Thread Adam Przybyla
n x(): print k, ... 0 1 2 3 4 5 6 7 8 9 >>> for k in x(): print k, ... 0 1 2 3 4 5 6 7 8 9 >>> yield_all=[k for k in x()] >>> yield_all [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> Regards Adam Przybyla -- http://mail.python.org/mailman/listinfo/python-list

Mail System Error - Returned Mail

2005-03-02 Thread imre . adam
The original message was received at Wed, 2 Mar 2005 20:06:59 +0100 from 87.26.243.56 - The following addresses had permanent fatal errors - - Transcript of session follows - ... while talking to python.org.: 554 Service unavailable; [188.60.170.174] blocked using relays.osirusof

Re: efficient intersection of lists with rounding

2004-12-02 Thread Adam DePrince
a] ) >>> set_b = Set( [(i,round(j)) for i,j in b] ) >>> set_a.intersection( set_b ) Set([(123, 2.0), (123, 1.0), (123, 8.0)]) Or you could say ... >>> set_a, set_b = [[Set((i,round(j))) for i,j in s] for s in (a,b )] Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: PySQLLite Speed

2004-12-02 Thread Adam DePrince
tead of data[i] > > > > > __ > Do you Yahoo!? > Yahoo! Mail - You care about security. So do we. > http://promotions.yahoo.com/new_mail Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie alert !

2004-12-03 Thread Adam DePrince
imilar functions before to draw lines, rectangles and whatever > else with success. Because Button creates a button on the screen and moves on. Would it be correct to say that you want the program to block on the creation of each button until it was pressed? Typically, GUI's rely on

Re: Newbie alert !

2004-12-03 Thread Adam DePrince
een and moves on. Would it be > correct to say that you want the program to block on the creation of > each button until it was pressed? > > Typically, GUI's rely on the notion of a callback. You create a widget, > assign some function to be called when something happens and then enter > your "mainloop" where you wait. If you want your rings to be created > with button presses then you should be creating them in the button > callbacks ... > > - Adam > > > > Using Python 2.3, IDLE and Win2k. > > > > Thanks for your time > > > > Jean Montambeault > Adam DePrince Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: distinction between float & int

2004-12-03 Thread Adam DePrince
isting object. When strings are compiled, they are interned, so ... >>> "abc" is "abc" True >>> "abc" is ("ab" + "c") False >>> "abc" == ( "ab" + "c" ) True >>> "abc&q

Re: 2D array

2004-12-08 Thread Adam DePrince
der using a dictionary where the key is a tuple representing the coordinates. a = {} a[(0,0)] = 0 a[(0,1)] = 1 a[(1,0)] = 2 a[(1,1)] = 3 a[(2,0)] = 4 a[(2,1)] = 5 a[(3,0)] = 6 a[(3,1)] = 7 a[(4,0)] = 8 a[(4,1)] = 9 >>> a.get( (3,0), None ) 6 >>> print a.get( (5,0), None ) None Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursive list comprehension

2004-12-08 Thread Adam DePrince
er(['F']) ]) def flatten( i ): try: i = i.__iter__() while 1: j = flatten( i.next() ) try: while 1: yield j.next() except StopIteration: pass except AttributeError: yield i if __n

Re: Sorting in huge files

2004-12-08 Thread Adam DePrince
t it up Friday night and take the weekend off. Just make sure you plug your laptop into the wall before you go home. > > Is this reasonnable to do on 10^8 elements with repeats in the keys? I > guess I should just try and see for myself. Repeats in the keys don't matter. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursive list comprehension

2004-12-08 Thread Adam DePrince
On Wed, 2004-12-08 at 15:02, Steven Bethard wrote: > Adam DePrince wrote: > > def flatten( i ): > > try: > > i = i.__iter__() > > while 1: > > j = flatten( i.next() ) > > try: > >

Re: 2D array

2004-12-08 Thread Adam DePrince
On Wed, 2004-12-08 at 15:06, Steven Bethard wrote: > Adam DePrince wrote: > > If your data is sparse you might want to consider using a dictionary > > where the key is a tuple representing the coordinates. > > > > a = {} > > a[(0,0)] = 0 > > a[(0,1)] = 1

Re: 2D array

2004-12-10 Thread Adam DePrince
On Wed, 2004-12-08 at 16:22, Steven Bethard wrote: > Adam DePrince wrote: > > The use of None as the default parameter was on purpose; the lack of > > "magic" in python is often cited in religious wars between python and > > perl aficionados. Use of get(something,

Re: Deadlock detection

2004-12-10 Thread Adam DePrince
x27;t have any mutex operations. You get the idea. Unless mutex calls are rare, or your code simple, you might spend a while. Largely this problem is intractable, even with simplifications, but it is done which is why safety critical programs are (well, should be) small and their languages not

Re: newbie questions

2004-12-10 Thread Adam DePrince
Now promise me that you will never, ever do this in code you consider yourself proud of. Realize I'm sharing this in the same spirit that kids in a drivers ed class might view gory accident pictures. Fortunately for you, lists are mutable. Assigning to a auto-magically makes it part of yo

Re: sources for DOS-16bit

2004-12-10 Thread Adam DePrince
K * X + Y for some unsigned 4 bit value; on the V20-V30 it was an undefined operation. What this an accident? I don't know, but a lot of assembly coders came to depend on the one or two CPU cycles it would save over a proper mul and add. One or two cycles per array reference was a big thing back then ... Anyhow, sorry about babbling on about this non-python related nonsense and good luck. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie questions

2004-12-13 Thread Adam DePrince
both, then: def a(): something = 1 somethingelse = 2 return something,somethingelse x,y = a() This makes the code clear and easy to understand. Navré je ne pas répondre en français. - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: how do I "peek" into the next line?

2004-12-13 Thread Adam DePrince
pipes in Windows NT Pipes in Unix Comx: where x is your com port in DOS Sockets gzip and zlib file objects; this file was described as being *so* large that it should not be read into memory. IIRC seek operations are linear; while it is correct you can seek backwards, I don't think you woul

Re: how do I "peek" into the next line?

2004-12-13 Thread Adam DePrince
t line, f.unreadline( line ) line = f.readline() print line, line = f.readline() print line, Running this prints: a b c c d Hope this helps. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Python mascot proposal

2004-12-13 Thread Adam DePrince
ves. When I think of Python in emotional terms. A plush toy like Tux is more appealing. As for python2.png ... does the snake get all smushed up in the gear if it turns? Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: lies about OOP

2004-12-13 Thread Adam DePrince
s weaknesses with respect to complexity and the ability to partition knowledge. Forget goggle. Go to Amazon and get some texts on OOPL. Learn C++, Java, Python for that matter. Practice casting problems as classes in Python and submit them here for praise and criticism. Lastly, Perl is a

Re: How do I convert characters into integers?

2004-12-15 Thread Adam DePrince
ython. You might find this weird, but ... "anystring"[0] == "anysring"[0][0][0][0][0] is always true. Taking an element returns the character as a string of length 1. Think in terms of maping here. Don't say ... for ... Think ... message = map( ord, message ) or message = [chr( (ord( x ) + 3 )%256) for x in message] Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-15 Thread Adam DePrince
lature and behavior similar to existing mathematical constructs. Doing this will afford you the opportunity to stand upon the shoulders of giants as you go about your work. And to properly stand upon those shoulders, we must match the theoretical models used. That means we need more, not fewer, immutable counterparts to most of our datatypes. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: lies about OOP

2004-12-15 Thread Adam DePrince
ts in the JVM, limiting the size of your procedural program masquerading as a class. Perhaps that is a good thing. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: BASIC vs Python

2004-12-16 Thread Adam DePrince
e word each is (scatological, sexual, religious, etc.) But you are forced to memorize the same list of curse words over and over again in order. This is the BASIC way of learning to program. Don't do it, unless your goal is simply to embarrass and insult programmers. Adam DePrince

Re: lies about OOP

2004-12-16 Thread Adam DePrince
of hockey games... ;) When I read that I parsed it as reading "I'm Danish; my spouse plays a mean game of hockey." Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: BASIC vs Python

2004-12-16 Thread Adam DePrince
preted lang if it's similar to BASIC. > > > > > > > > Is a Ferrari similar to a horse-wagon? Yes, they both have 4 wheels. No, it is not better than a horse. The horse is more reliable and on any given day you can count on it going further before it needs service.

Re: os.walk bug?

2004-12-16 Thread Adam DePrince
ay of writing what you are tring to write is as follows: test.py contains: for root, dirs, files in os.walk('t:\'): if root(-4:-2) == "20": continue # Do stuff [EMAIL PROTECTED] help]$ python test.py . ./dir1 ./dir1/content ./dir2 ./dir2/content ./dir2/templates Oh, and my directory structure is ... # bash -c 'mkdir -p dir1/200{0,1} dir1/content \ dir2/200{0,1,2,3,4} dir2/{content,templates}' Does this help? - Adam > Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: BASIC vs Python

2004-12-17 Thread Adam DePrince
On Fri, 2004-12-17 at 01:49, Andrew Dalke wrote: > Adam DePrince > > During the 1980's BASIC was the language to embedd into the ROM's of the > > computers of the day. This was in a misguided effort to make computers > > understandable to their target audien

Re: BASIC vs Python

2004-12-17 Thread Adam DePrince
Excel in 2 > > minutes. What you describe is a political, not technical, challenge. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: BASIC vs Python

2004-12-17 Thread Adam DePrince
wandering onto [EMAIL PROTECTED] and having strong opinions in favor of BASIC is sort of like wandering into a Hasidim temple on Yom Kippur and talking about the salvation of Jesus while munching on a ham and cheese sandwich? Don't be surprised if you have trouble making friends. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: BASIC vs Python

2004-12-17 Thread Adam DePrince
quot;enterprise" class? The same was true 20 years ago - but it was the mere presence of the computer that served a similar role. If you were really enterprise class, you used COBOL. And if you were in the wannabe category, you got yourself a PET 20 and told it what to do in BASIC. > (mumbles into beard and drools quietly in the corner). Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Create linear spaced vector?

2004-12-17 Thread Adam DePrince
uot;__main__": print linear_space( 1.0, 2.0, 10 ) Running it gives you: [1.0, 1.1001, 1.2, 1.3, 1.3999, 1.5, 1.6001, 1.7002, 1.8, 1.8999, 2.0] Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-15 Thread Adam DePrince
you go about your work.  And to properly stand upon those shoulders, we must match the theoetical models used.  That means we need more, not fewer, inmutable counterparts to most of our datatypes. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-15 Thread Adam DePrince
ash value, but yours are different. A hash value is simply a probabilistic mechanism to quickly determine if two objects must be different, or to select a bin in a hash table. Two different objects are allowed to have the same hash value, but two objects that are the same must have the same

Writev

2004-12-19 Thread Adam DePrince
024 items, so to accommodate users who don't want to peel off and hold in memory 1024 iteration.next()'s, you can set an optional parameter to a smaller value. I'm not sure where to take this as a "next step." It seems too small a change for a PEP. Any ideas?

Re: Writev

2004-12-19 Thread Adam DePrince
On Sun, 2004-12-19 at 23:43, Jp Calderone wrote: > On Sun, 19 Dec 2004 23:12:27 -0500, Adam DePrince <[EMAIL PROTECTED]> wrote: > > [snip] [snip] to free the memory, of course. > > The support of iterators is a cool idea, but I'm not sure > it is actually useful.

Re: Writev

2004-12-19 Thread Adam DePrince
On Mon, 2004-12-20 at 00:30, Steven Bethard wrote: > Adam DePrince wrote: > > Many other programmers have faced a similar issue; cStringIO, > > ''.join([mydata]), map( file.write, [mydata]) are but some attempts at > > making this process more efficient by jamming t

Re: Writev

2004-12-20 Thread Adam DePrince
On Mon, 2004-12-20 at 02:18, Steven Bethard wrote: > Adam DePrince wrote: > > file.writelines( seq ) and map( file.write, seq ) are the same; the > > former is syntactic sugar for the later. > > Well, that's not exactly true. For one thing, map(file.write, seq) > r

Re: Writev

2004-12-21 Thread Adam DePrince
On Sun, 2004-12-19 at 23:43, Jp Calderone wrote: > On Sun, 19 Dec 2004 23:12:27 -0500, Adam DePrince <[EMAIL PROTECTED]> wrote: > > [snip] > > > > Of course, to take advantage of this requires that writev be exposed. I > > have an implementation of writev.

Re: Can'r run BLT twice?

2005-04-29 Thread Ron Adam
did to solve it. :-( It is fixable though. I know that's not much help. I'll look at how I use it in my program and see if that rings any bells. Ron Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Can'r run BLT twice?

2005-04-29 Thread Ron Adam
ly using the free version of EditPad Pro, the full version has a spelling checker built in. It's loads up fast and can run external programs on the current document and capture the results and the errors in separate panels. It also supports syntax highlighting for pthon (and a dozen other languages). Cheers, Ron Adam -- http://mail.python.org/mailman/listinfo/python-list

getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Adam Funk
I'm having trouble with some input files that are almost all proper UTF-8 but with a couple of troublesome characters mixed in, which I'd like to ignore instead of throwing ValueError. I've found the openhook for the encoding for line in fileinput.input(options.files, openhook=fileinput.hook_enc

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Adam Funk
On 2015-12-03, Adam Funk wrote: > I'm having trouble with some input files that are almost all proper > UTF-8 but with a couple of troublesome characters mixed in, which I'd > like to ignore instead of throwing ValueError. I've found the > openhook for t

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Adam Funk
On 2015-12-03, Peter Otten wrote: > def my_hook_encoded(encoding, errors=None): > import io > def openhook(filename, mode): > mode = mode.replace('U', '').replace('b', '') or 'r' > return io.open( > filename, mode, > encoding=encoding, newline='',

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Adam Funk
On 2015-12-03, Terry Reedy wrote: > fileinput is an ancient module that predates iterators (and generators) > and context managers. Since by 2.7 open files are both context managers > and line iterators, you can easily write your own multi-file line > iteration that does exactly what you want.

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Adam Funk
On 2015-12-03, Laura Creighton wrote: > In a message of Thu, 03 Dec 2015 15:12:15 +0000, Adam Funk writes: >>I'm having trouble with some input files that are almost all proper >>UTF-8 but with a couple of troublesome characters mixed in, which I'd >>like to ignore

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-07 Thread Adam Funk
On 2015-12-04, Oscar Benjamin wrote: > Or you can use fileinput which is designed to be exactly this kind of > context manager and to be used in this way. Although fileinput is slightly > awkward in defaulting to reading stdin. That default is what I specifically like about fileinput --- it's a n

writing an email.message.Message in UTF-8

2015-12-07 Thread Adam Funk
I'm trying to write an instance of email.message.Message, whose body contains unicode characters, to a UTF-8 file. (Python 2.7.3 & 2.7.10 again.) reply = email.message.Message() reply.set_charset('utf-8') ... # set various headers reply.set_payload('\n'.join(body_lines) + '\n')

Re: writing an email.message.Message in UTF-8

2015-12-07 Thread Adam Funk
On 2015-12-07, Adam Funk wrote: > I'm trying to write an instance of email.message.Message, whose body > contains unicode characters, to a UTF-8 file. (Python 2.7.3 & 2.7.10 > again.) > > reply = email.message.Message() > reply.set_charset('utf-8&#

Re: writing an email.message.Message in UTF-8

2015-12-08 Thread Adam Funk
On 2015-12-08, dieter wrote: > Adam Funk writes: > >> I'm trying to write an instance of email.message.Message, whose body >> contains unicode characters, to a UTF-8 file. (Python 2.7.3 & 2.7.10 >> again.) >> >> reply = email.mess

Re: writing an email.message.Message in UTF-8

2015-12-08 Thread Adam Funk
On 2015-12-07, Terry Reedy wrote: > On 12/7/2015 9:57 AM, Adam Funk wrote: >> I'm trying to write an instance of email.message.Message, whose body >> contains unicode characters, to a UTF-8 file. (Python 2.7.3 & 2.7.10 >> again.) > > The email package w

trying to force stdout to utf-8 with errors='ignore' or 'replace'

2015-12-11 Thread Adam Funk
I'm fiddling with a program that reads articles in the news spool using email.parser (standard library) & email_reply_parser.EmailReplyParser (installed with pip). Reading is fine, & I don't get any errors writing output extracted from article bodies *until* I try to suppress invalid characters.

Re: trying to force stdout to utf-8 with errors='ignore' or 'replace'

2015-12-11 Thread Adam Funk
On 2015-12-11, Peter Otten wrote: > Adam Funk wrote: >> but with either or both of those, I get the dreaded >> "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position >> 562: ordinal not in range(128)". How can I force the output

Re: Converting py files to .exe and .dmg

2015-12-28 Thread Adam M
On Monday, December 28, 2015 at 10:35:41 AM UTC-5, Brian Simms wrote: > Hi there, > > I have done a lot of looking around online to find out how to convert Python > files to .exe and .dmg files, but I am confused. Could someone provide > pointers/advice as to how I can turn a Python file into a

Testing whether the VPN is running?

2016-02-18 Thread Adam Funk
I'd like to test (inside a python 3 program) whether the VPN is running or not. The only thing I can think of so far is to use subprocess to run the 'ifconfig' command, then check its output for 'tun0'. Is there a better way? Thanks. -- Nam Sibbyllam quidem Cumis ego ipse oculis meis vidi in

Re: Testing whether the VPN is running?

2016-02-18 Thread Adam Funk
On 2016-02-18, Ervin Hegedüs wrote: > Hi Adam, > > On Thu, Feb 18, 2016 at 09:26:58AM +0000, Adam Funk wrote: >> I'd like to test (inside a python 3 program) whether the VPN is >> running or not. The only thing I can think of so far is to use >> subprocess to

Re: Testing whether the VPN is running?

2016-02-25 Thread Adam Funk
On 2016-02-23, Cameron Simpson wrote: > On 18Feb2016 10:03, Adam Funk wrote: >>On 2016-02-18, Ervin Hegedüs wrote: >>> I think that the psutil modul could be better for you for this >>> task: >>> https://pypi.python.org/pypi/psutil/ >>> >>

Re: file -SAS

2016-03-19 Thread Adam M
y." | > _o__)--Christopher Hitchens | > Ben Finney I think he meant this: https://pypi.python.org/pypi/sas7bdat And here is what SAS7DAT is https://cran.r-project.org/web/packages/sas7bdat/vignettes/sas7bdat.pdf Judging by name it seams be related to SAS language. Regards Adam M. -- https://mail.python.org/mailman/listinfo/python-list

Re: Permissions on files installed by pip?

2014-10-22 Thread Adam Funk
On 2014-10-17, Jean-Michel Pichavant wrote: > - Original Message - >> From: "Adam Funk" >> To: python-list@python.org >> Sent: Thursday, 16 October, 2014 9:29:46 PM >> Subject: Permissions on files installed by pip? >> >> I've be

Why does argparse return None instead of [] if an append action isn't used?

2015-01-09 Thread Adam Funk
I noticed in use that if an option with the 'append' action isn't used, argparse assigns None to it rather than an empty list, & confirmed this interactively: #v+ >>> import argparse >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', action='append') _AppendAction(option_strin

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-09 Thread Adam Funk
On 2015-01-09, Skip Montanaro wrote: >> I noticed in use that if an option with the 'append' action isn't >> used, argparse assigns None to it rather than an empty list, & >> confirmed this interactively: > > I don't use argparse (or optparse), being a getopt Luddite myself, but > can you set the

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Adam Funk
On 2015-01-09, Wolfgang Maier wrote: > On 01/09/2015 03:44 PM, Adam Funk wrote: >> I noticed in use that if an option with the 'append' action isn't >> used, argparse assigns None to it rather than an empty list, & >> confirmed this interactively: >

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Adam Funk
On 2015-01-09, Ned Batchelder wrote: > On 1/9/15 9:44 AM, Adam Funk wrote: >> This makes it a bit more trouble to use: >> >>if options.bar: >> for b in options:bar >> do_stuff(b) >> >> instead of >> >>for b in options

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Adam Funk
On 2015-01-26, Peter Otten wrote: > Adam Funk wrote: > >> On 2015-01-09, Ned Batchelder wrote: >> >>> On 1/9/15 9:44 AM, Adam Funk wrote: >>>> This makes it a bit more trouble to use: >>>> >>>>if options.bar: >>>>

Re: sqlite3 and dates

2015-02-19 Thread Adam Funk
On 2015-02-18, Johannes Bauer wrote: > On 18.02.2015 12:21, Chris Angelico wrote: > >> SQLite3 is fine for something that's basically just a more structured >> version of a flat file. You assume that nobody but you has the file >> open, and you manipulate it just the same as if it were a big fat b

Re: sqlite3 and dates

2015-02-19 Thread Adam Funk
On 2015-02-18, Chris Angelico wrote: > On Thu, Feb 19, 2015 at 9:17 AM, wrote: >>> SQLite3 is fine for something that's basically just a more structured >>> version of a flat file. You assume that nobody but you has the file >>> open, and you manipulate it just the same as if it were a big fat b

Re: Significant digits in a float?

2014-04-29 Thread Adam Funk
On 2014-04-29, Roy Smith wrote: > Another possibility is that they're latitude/longitude coordinates, some > of which are given to the whole degree, some of which are given to > greater precision, all the way down to the ten-thousandth of a degree. That makes sense. 1° of longitude is about 11

Re: Off-topic circumnavigating the earth in a mile or less

2014-05-01 Thread Adam Funk
On 2014-05-01, Terry Reedy wrote: > On 4/30/2014 7:46 PM, Ian Kelly wrote: > >> It also works if your starting point is (precisely) the north pole. I >> believe that's the canonical answer to the riddle, since there are no >> bears in Antarctica. > > For the most part, there are no bears within a

Re: Significant digits in a float?

2014-05-01 Thread Adam Funk
On 2014-05-01, Dennis Lee Bieber wrote: > On Tue, 29 Apr 2014 20:42:33 -0400, Roy Smith declaimed the > following: > >>In article , >> Dennis Lee Bieber wrote: >>> (one reason slide-rules were acceptable for so long -- and even my high >>> school trig course only required slide-rule significanc

Re: Off-topic circumnavigating the earth in a mile or less

2014-05-01 Thread Adam Funk
On 2014-04-30, Ethan Furman wrote: > Wow. It's amazing how writing something down, wrongly (I originally had > north and south reversed), correcting it, > letting some time pass (enough to post the message so one can be properly > embarrassed ;), and then rereading it later > can make somethi

Re: Significant digits in a float?

2014-05-01 Thread Adam Funk
On 2014-05-01, Larry Hudson wrote: > On 05/01/2014 05:56 AM, Roy Smith wrote: >> For those who have no idea what we're talking about, take a look at >> http://www.ted.com/talks/clifford_stoll_on_everything. If you just want >> to see what you do with a slide rule, fast forward to 14:20, but you

Re: Significant digits in a float?

2014-05-08 Thread Adam Funk
On 2014-05-02, Dennis Lee Bieber wrote: > On Thu, 01 May 2014 21:55:20 +0100, Adam Funk > declaimed the following: > >>On 2014-05-01, Dennis Lee Bieber wrote: >>> Math teacher was selling them in my 10th grade... Actually I already >>> owned a Faber-Castell

hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
7;m not worried about someone trying to create a hash collision.) Thanks, Adam -- "It is the role of librarians to keep government running in difficult times," replied Dramoren. "Librarians are the last line of defence against chaos." (

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
On 2014-05-22, Peter Otten wrote: > Adam Funk wrote: > >> I'm using Python 3.3 and the sqlite3 module in the standard library. >> I'm processing a lot of strings from input files (among other things, >> values of headers in e-mail & news messages) and supp

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
On 2014-05-22, Chris Angelico wrote: > On Thu, May 22, 2014 at 9:47 PM, Adam Funk wrote: >> I'm using Python 3.3 and the sqlite3 module in the standard library. >> I'm processing a lot of strings from input files (among other things, >> values of headers

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
On 2014-05-22, Tim Chase wrote: > On 2014-05-22 12:47, Adam Funk wrote: >> I'm using Python 3.3 and the sqlite3 module in the standard library. >> I'm processing a lot of strings from input files (among other >> things, values of headers in e-mail & news mess

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
On 2014-05-22, Chris Angelico wrote: > On Thu, May 22, 2014 at 11:41 PM, Adam Funk wrote: >> On further reflection, I think I asked for that. In fact, the table >> I'm using only has one column for the hashes --- I wasn't going to >> store the strings at all in

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
On 2014-05-22, Chris Angelico wrote: > On Thu, May 22, 2014 at 11:54 PM, Adam Funk wrote: >> That ties in with a related question I've been wondering about lately >> (using MD5s & SHAs for other things) --- getting a hash value (which >> is internally numeric, rath

hashing strings to integers (was: hashing strings to integers for sqlite3 keys)

2014-05-23 Thread Adam Funk
On 2014-05-22, Peter Otten wrote: > Adam Funk wrote: >> Well, J*v* returns a byte array, so I used to do this: >> >> digester = MessageDigest.getInstance("MD5"); >> ... >> digester.reset(); >> byte[] digest = digester.diges

Re: hashing strings to integers

2014-05-23 Thread Adam Funk
On 2014-05-23, Adam Funk wrote: > On 2014-05-22, Peter Otten wrote: >> In Python 3 there's int.from_bytes() >> >>>>> h = hashlib.sha1(b"Hello world") >>>>> int.from_bytes(h.digest(), "little") >> 53805907168366771184661

Re: hashing strings to integers

2014-05-27 Thread Adam Funk
On 2014-05-23, Chris Angelico wrote: > On Fri, May 23, 2014 at 8:27 PM, Adam Funk wrote: >> I've also used hashes of strings for other things involving >> deduplication or fast lookups (because integer equality is faster than >> string equality). I guess if it's

Re: hashing strings to integers

2014-05-27 Thread Adam Funk
On 2014-05-23, Terry Reedy wrote: > On 5/23/2014 6:27 AM, Adam Funk wrote: > >> that. The only thing that really bugs me in Python 3 is that execfile >> has been removed (I find it useful for testing things interactively). > > The spelling has been changed to exec(open(.

Re: hashing strings to integers

2014-06-03 Thread Adam Funk
On 2014-05-28, Dan Sommers wrote: > On Tue, 27 May 2014 17:02:50 +, Steven D'Aprano wrote: > >> - rather than "zillions" of them, there are few enough of them that >> the chances of an MD5 collision is insignificant; > >> (Any MD5 collision is going to play havoc with your strategy of >>

Re: hashing strings to integers

2014-06-03 Thread Adam Funk
On 2014-05-27, Steven D'Aprano wrote: > On Tue, 27 May 2014 16:13:46 +0100, Adam Funk wrote: >> Well, here's the way it works in my mind: >> >>I can store a set of a zillion strings (or a dict with a zillion >>string keys), but every time

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