Re: [Tutor] Pickles and Shelves Concept

2019-06-07 Thread Martin A. Brown
ted libraries to make your job easier, as are many of these other data serialization libraries. I hope the above was helpful in explaining some of the concepts. -Martin [0] https://en.wikipedia.org/wiki/Serialization#Pickle [1] Please note, there are probably better places to read about J

Re: [Tutor] Setting Command Line Arguments in IDLE

2019-05-26 Thread Martin A. Brown
did anything with environment variables, I would add that here. You will also see that I don't mess with sys.stderr. In general, I like to stay away from redirecting that unless there's a strong need. Benefits: * you can call cli() in your testing programs with different lists

Re: [Tutor] Local variable look up outside the function and method

2019-05-12 Thread Martin A. Brown
-- warning, we are about to change the value for Foo.x') print() Foo.x = 6.022141e-23 print('# -- f.x retrieves class value, f.y instance value') print('f.x = %s, f.y = %s, Foo.x = %s' % (f.x, f.y, Foo.x)) print() f.removeinstancex() print('# --

Re: [Tutor] How to find optimisations for code

2018-10-19 Thread Pat Martin
So should we always use sets or dictionaries if possible? Are these more efficient because of not keeping track of their position? On Fri, Oct 19, 2018 at 10:47 AM Pat Martin wrote: > That's correct sorry, I reassigned with replace back to string2, I forgot > that in my retyping of

Re: [Tutor] How to find optimisations for code

2018-10-19 Thread Pat Martin
Mats Wichmann wrote: > > > On 10/19/2018 10:12 AM, Pat Martin wrote: > >> Sorry my first email didn't have a subject line > >> > >> TLDR; How do you figure out if code is inefficient (if it isn't > >> necessarily obvious) and how do you find

[Tutor] How to find optimisations for code

2018-10-19 Thread Pat Martin
Sorry my first email didn't have a subject line TLDR; How do you figure out if code is inefficient (if it isn't necessarily obvious) and how do you find a more efficient solution? I use code wars sometimes to get some practice with Python, there was a challenge to compare two strings and if strin

[Tutor] (no subject)

2018-10-19 Thread Pat Martin
TLDR; How do you figure out if code is inefficient (if it isn't necessarily obvious) and how do you find a more efficient solution? I use code wars sometimes to get some practice with Python, there was a challenge to compare two strings and if string1 had enough characters to be rearranged to make

Re: [Tutor] How can I find a group of characters in a list of strings?

2018-07-25 Thread Martin A. Brown
7;MIBMMCCO', 'YOWHHOY', 'OFHCMLIP', 'OFHCMLIPZ', 'FHCMLIP', 'NEGBQJKR'] needle = set('OFHCMLIP') for haystack in farm: partial = needle.intersection(haystack) exact = needle.intersection(haystack) == needle prin

[Tutor] Storing passwords and version control

2018-05-27 Thread Pat Martin
Hello all, I am writing a script that will be using an API to connect to some systems to pull info for a search. Since it will be a script I will be running through cron I won't be able to type the password at time of running. I also am going to be putting this in source control, using git specifi

Re: [Tutor] pythonic

2018-03-30 Thread Pat Martin
Thank you all for the ideas and comments, it is appreciated. I have some refactoring to do now. On Fri, Mar 30, 2018 at 2:22 AM, Peter Otten <__pete...@web.de> wrote: > Pat Martin wrote: > > > I have written the following program. It generates a template for Pelican &

[Tutor] pythonic

2018-03-29 Thread Pat Martin
st', metavar="") parser.add_argument("-t", "--tags", type=str, required=True, help="Tags for post", metavar="") parser.add_argument("-a", "--author", type=str, default="Pat Martin",

[Tutor] Graphical/web program

2018-01-12 Thread Pat Martin
Hello, I have recently written a program to add switches and hosts to my ssh config file, I use argparse for some switches like user name and such and it has been working pretty well. I was thinking of turning this into a web app (one that is just run on my local machine) something like have a f

Re: [Tutor] double ended queue

2017-11-04 Thread Martin A. Brown
user types '0r' it will be removed from the beginning of the >queue. Once you have the addition of items to the queue and the looping worked out to your satisfaction, maybe you could share your progress and there might be somebody to provide a bit mor

Re: [Tutor] Select a string

2017-09-06 Thread Pat Martin
t and have written a couple useful scripts but still very much a beginner and there are definite holes in my knowledge. Hoping this class fills in some of the holes. Thanks again all for the suggestions and the tips. On Wed, Sep 6, 2017 at 8:01 AM, Pat Martin wrote: > I knew it was an assi

Re: [Tutor] Select a string

2017-09-06 Thread Pat Martin
s for that as well. The reason I haven't used regex/methods/etc is it hasn't been covered yet, we have only covered basic types, for, while and if statements. On Wed, Sep 6, 2017 at 1:54 AM, Alan Gauld via Tutor wrote: > On 06/09/17 06:34, Pat Martin wrote: > > > but my s

[Tutor] Select a string

2017-09-05 Thread Pat Martin
Hello all, I am trying to write a program for a programming class that finds the number of a specific string (bob) in a string of characters. I am using one of the sample strings they give me and it should find 2 instances of bob but my script returns 0. Since they want it to find 2 from the bobob

Re: [Tutor] Fwd: Re: "Path tree"

2017-08-14 Thread Martin A. Brown
o find a path? What does the path (through this graph) tell you? What do (x, y) represent in that picture? Good luck, Michael, in exploring Python for playing with graphs. I think you may find that networkx will address almost anything you can throw at it for quite some time. And, we

Re: [Tutor] How to write the __str__ function

2017-05-14 Thread Martin A. Brown
mind that you are creating a tuple when you include the comma in the line that ends with: (self.ucc), I have, therefore, a few small suggestions: 1. Put all of the variables replacements at the end. thing = ("var x=%s\nvar y=%s" % (x,y)) 2. When creating the replacements,

Re: [Tutor] Another set question

2017-04-28 Thread Martin A. Brown
ample of using "in": >In other words, why is the data such that you *need* to know whether it >is a set versus a string, before using it? Can the data be handled >differently such that the condition you describe isn't a prerequisite? And, this is the key question. Good luc

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-18 Thread Martin A. Brown
Greetings, >Thank you very much Martin; you filled in a lot of details. I had an >overall understanding of what unittest does, but you have now enhanced >that understanding substantially. Happy to help! I'll introduce you to my little menagerie below! >I'm still iffy

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-16 Thread Martin A. Brown
from the class >TestFuncAcceptsSequenceMixin, those classes don't have any methods >that they call on that class, so how does its code get run? I suspect >that the mixin's concepts is where I am stumbling. I have yet to find >a reference that is making things clear to me,

Re: [Tutor] Validating String contains IP address

2017-04-03 Thread Martin A. Brown
untrust IP ''"Example > 172.20.2.3/28"'':') You might try using the ipaddress library in the following way: >>> i = ipaddress.ip_interface(u'172.20.2.3/28') >>> i.ip IPv4Address(u'172.20.2.3') >>

Re: [Tutor] Validating String contains IP address

2017-03-31 Thread Martin A. Brown
.256 is not an IP. 192.v.12.7 is not an IP. text is not an IP. fe80::a64e:31ff:fe94:a160 is an IP. 255.255.255.255 is an IP. 0.0.0.0 is an IP. Basically, I'm lazy. I let somebody else do the hard work of validation! Good luck and happy IParsing! -Martin [0] http://python

Re: [Tutor] Puzzling case of assertRaises not running properly

2016-12-30 Thread Martin A. Brown
(__main__.BillTest) ... ok >test_input_not_float_raises_ValueError (__main__.BillTest) ... Not a float >FAIL Good luck! -Martin -- Martin A. Brown http://linux-ip.net/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] (regular expression)

2016-12-10 Thread Martin A. Brown
matches = re.findall(pattern, bodytext) * report to the end user: Finally, print it out print('Found "engineering" (case-insensitive) %d times.' % (len(matches),)) Good luck and enjoy Python, -Martin [0] http://docs.python-requests.org/en/master/ url =

Re: [Tutor] Variables

2016-08-02 Thread Martin A. Brown
(2 + 20) # python proggie.py stored-variable.txt 20 # -- increment by 20 # -- increment by 20 and sleep 1 second between read/write cycle #first time should get 42, then 62 # python proggie.py stored-variable.txt 20 1 # -- sleep Enjoy, and I hope this little program is instructive,

Re: [Tutor] Sorting a list in ascending order

2016-04-29 Thread Martin A. Brown
fied_nums ['05', '11', '41', '44', '53'] Lastly, let's print the stringified_nums; do you want to print them with colons separating the numbers, semicolons, commas, a hyphen? >>> ':'.join(stringified_nums) '05:

Re: [Tutor] python equivalents for perl list operators?

2016-04-23 Thread Martin A. Brown
in Perl vs. thinking in Python. (This is something that I found strange and occasionally quite convenient in Perl.) Perl will flatten your lists when you pass them into functions. If you pass two lists into a function. &some_func(@a, @b) In some_func, there's just a list of argume

Re: [Tutor] Understanding error in recursive function

2016-04-08 Thread Martin A. Brown
ine that on my box, I can only handle 988 calls to the same function before triggering the maxmimum recursion depth exceeded error. Given that your question was recursion, I chose to focus on that, but I would recommend using the simplest tool for the job, and in this case that wou

Re: [Tutor] Removing Content from Lines....

2016-03-24 Thread Martin A. Brown
icontrol') You should see the name 'uicontrol' and the contents of each tag, stripped of all surrounding context. The above snippet is really just an example to show you how easy it is (from a coding perspective) to use lxml. You still have to make the investment to understand how lx

Re: [Tutor] Help with recursion

2016-03-22 Thread Martin A. Brown
puter science examples demonstrating recursion (and the limits of recursion) is a function implementing the Fibonacci sequence. https://technobeans.wordpress.com/2012/04/16/5-ways-of-fibonacci-in-python/ But, if you have a more specific question about recursion, then please send it along. Wel

Re: [Tutor] library terminology and importing

2016-02-21 Thread Martin A. Brown
ss. >but I get an error if I try > >from datetime.datetime import now, strftime If you are mostly interested in shortening your import statement, I have seen people use this sort of technique: >>> from datetime import datetime as dt >>> now = dt.now() >>> now.strftime('%F-%T') '2016-02-21-18:30:37' Good luck and enjoy, -Martin -- Martin A. Brown http://linux-ip.net/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] declare a variable inside a class

2016-02-11 Thread Martin A. Brown
>Thanks for the reply Martin, and in this instance I cannot post the >actual code (company rules). That's often the case. I think most of us understand that you may not be able to post the original code. >What I can do is say that with the xslt variable defined within the >

Re: [Tutor] declare a variable inside a class

2016-02-11 Thread Martin A. Brown
ether it is running or not, along with any error messages (pasted, please). This is just a reminder, that this reduces the guesswork on the part of the members of the list. I think your problem is simply not knowing the name of the variable you called 'xslt'. Perhaps the below exam

Re: [Tutor] Help with date range

2016-02-09 Thread Martin A. Brown
ggest that you convert the serialized representation of the data (a string) into an object or datatype in memory that allows you to perform the desired sorting, computation, calculation or range-finding. Also, if you have a smaller block of code and data, we may find it easier to make spe

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread Martin A. Brown
just want an individual thingy that that behaves like a file, but >> can be constructed in memory, use StringIO (or cStringIO). > >Isn't option D what Danny was using to make option B? Or are you >saying keep things even simpler? Oh dear--yes. Apologies, Danny and

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread Martin A. Brown
ess concerned about filesystem interactions and really just want an individual thingy that that behaves like a file, but can be constructed in memory, use StringIO (or cStringIO). Good luck! -Martin -- Martin A. Brown http://linux-ip.net/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to call the path of an input file

2016-01-21 Thread Martin A. Brown
path(sys.argv[1]) >y = map(str.lower, path.split()) Next question: What exactly are you trying to do with that third line? It looks confused. Good luck, -Martin [0] https://docs.python.org/3/library/os.path.html#os.path.abspath -- Martin A. Brown h

Re: [Tutor] Simultaneous read and write on file

2016-01-18 Thread Martin A. Brown
situ modification magic tricks, they (and you) will have no guarantees about what data they will receive. That will be left up to the operating system (i.e. kernel). So, take control of the data back into your own hands by taking adavantage of the beauty of the filesystem. Filesystem at

Re: [Tutor] Simultaneous read and write on file

2016-01-18 Thread Martin A. Brown
xperienced Windows/POSIX user trying to understand open() in Python if it were available in the standard documentation. Thanks for mapping this to common operating systems. I had inferred this already, but this is a great summary. -Martin -- Martin A. Brown http://linux-ip.net/

Re: [Tutor] Hi Tutor

2016-01-09 Thread Martin A. Brown
;s my answer: from random import choice def dish(options): return choice(options) Then, the function dish() will return exactly one element from the options. Since each of soup, salads, main and beverage are lists with string elements, the dish() function will return a string. I would like to have some Onion soup, the Crab cake, Rum and a Caesar, please. Good luck, -Martin -- Martin A. Brown http://linux-ip.net/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] looping generator

2016-01-07 Thread Martin A. Brown
ng all of that unprocessed data in the variable 'data' in the dataRecv function. Specifically, your problem is about breaking the data apart and using it all. You might benefit from studying techniques for breaking a text apart by paragraph. Think about how this applies to your problem: http://code.activestate.com/recipes/66063-read-a-text-file-by-paragraph/#c1 N.B. The code example may not be utterly perfect, but it is precisely the same problem that you are having. Good luck and enjoy, -Martin -- Martin A. Brown http://linux-ip.net/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to get Key from multiple value dictionary search

2016-01-06 Thread Martin A. Brown
77'], 'key4': ['value77', 'value1']} What would you expect to be returned here: keys_of_interest = get_all_keys_if_value(newdic, 'value77') Well, they should be: ['key3', 'key2', 'key4'] # -- keys_of_intere

Re: [Tutor] OT: How best to use Git for multi-directory projects?

2015-12-29 Thread Martin A. Brown
are different strategies depending on what you are doing with the software and the environment in which you are working. Good luck and have fun with Python in 2016, since you have arrived there before the rest of us, -Martin P.S. Two questions: should I buy some some YHOO stock and should I

Re: [Tutor] MemoryError

2015-12-29 Thread Martin A. Brown
5 # -- stops with four lines of output python wuzzyluzy.py 262144 # -- stops with many lines of output python wuzzyluzy.py 17 # -- never stops python wuzzyluzy.py 19 # -- never stops Good luck in your hunt for the wily factors, -Martin import fractions import math # CFRA

Re: [Tutor] Plotting with python

2015-10-30 Thread Martin A. Brown
, if all of your values (temperature) are within the range you want to display, you don't need to mess with the axes. See their tutorial: http://matplotlib.org/users/pyplot_tutorial.html Good luck and enjoy! -Martin [0] http://ipython.org/ [1] http://ipython.org/notebook.html -- Mar

Re: [Tutor] For Loop

2015-10-30 Thread Martin A. Brown
ttps://docs.python.org/3/tutorial/ https://docs.python.org/3/tutorial/controlflow.html If you have more specific details on what you are trying to accomplish and/or learn, then send along those questions! Good luck as you get started, -Martin -- Martin A. Brown http://linux-ip.net/

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Martin A. Brown
first position. A minor improvement would be to only prepend the PYTHONPATH and required colon if there's a value to PYTHONPATH already. So, this little beautifully obnoxious bash parameter expansion gem will accomplish that for you: PYTHONPATH="${PYTH

Re: [Tutor] File operation query

2015-10-16 Thread Martin A. Brown
quot;check.txt", "r+") I would, therefore write your program like this: input1 = raw_input("Input1:") f = open("check.txt", "w") f.write(input1 + "\n") f.close() f = open("check.txt",

Re: [Tutor] 0 > "0" --> is there a "from __future__ import to make this raise a TypeError?

2015-10-13 Thread Martin A. Brown
l. There is the benefit, then, of your code being agnostic (or extensible) to the serialization tool. By the way, did you know that pandas.to_csv() [0] also exists? -Martin [0] http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_csv.html -- Martin A.

Re: [Tutor] How to read all integers from a binary file?

2015-10-09 Thread Martin A. Brown
array.array() is probably the easiest path for you. Good luck and have fun! -Martin from __future__ import print_function import sys import struct def write_data(f, size, datatype): data = gen_data(size) fmt = str(len(data)) + datatype s = struct.pack(fmt, *data) f.write(s)

Re: [Tutor] Creating lists with 3 (later4) items occuring only once

2015-09-27 Thread Martin A. Brown
rst exactly his task to be accomplished. But my knowledge goes only as far as "Python for Infomatics" (by MOOC/Coursera) and "Practical Programming" . I know there are a myriad of other modules and tools etc. and there I need the help of "Pythonistas". To where should I

Re: [Tutor] mathematical and statistical functions in Python

2015-09-27 Thread Martin A. Brown
-statistics Thggere are other, richer tools in third-party libraries if you are looking for more advanced tools. But, perhaps you only need to start with the above. Good luck, -Martin -- Martin A. Brown http://linux-ip.net/ ___ Tutor maillist - Tutor

Re: [Tutor] Creating lists with 3 (later4) items occuring only once

2015-09-26 Thread Martin A. Brown
he] Python language. You will always benefit from thinking deeply about what you hope to accomplish before starting to code. (I have known quite a few programmers with decades of experience who will not touch the computer until they have written a description of the problem on paper.) Also: There is

Re: [Tutor] Creating lists with 3 (later4) items occuring only once

2015-09-21 Thread Martin A. Brown
same round. (Simple arithmetic determines the minimum number of players.) If your question is Problem A, then I wonder if you know anybody who knows combinatorics? I do not. -Martin [0] https://mail.python.org/pipermail/tutor/2015-September/106820.html #! /usr/bin/python fr

Re: [Tutor] Creating lists with 3 (later4) items occuring only once

2015-09-21 Thread Martin A. Brown
;ab', 'bc', 'cd'), ('ab', 'bd', 'cd'), ('ac', 'ad', 'bc'), ('ac', 'ad', 'bd'), ('ac', 'ad', 'cd'), ('ac', 'bc', 'bd&#

Re: [Tutor] ftp socket.error

2015-09-12 Thread Martin A. Brown
etail, Robert! -Martin Strictly speaking, it's no Python question, but... good ol' FTP. socket.error: [Errno 113] No route to host Your program is receiving an EHOSTUNREACH. >>> import errno >>> errno.errorcode[113] 'EHOSTUNREACH' This occurs at preci

Re: [Tutor] ftp socket.error

2015-09-11 Thread Martin A. Brown
it's anonymous access, use HTTP. If authenticated access, use ssh/scp/sftp. Good luck, -Martin [0] http://www.networksorcery.com/enp/protocol/icmp/msg3.htm -- Martin A. Brown http://linux-ip.net/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] 2 vs 3

2015-09-07 Thread Grady Martin
On 2015年09月05日 23時33分, Alan Gauld wrote: Once you get used to it - and it is a big jump, don't underestimate the learning time - v3 is superior. This is the first I've heard someone describe the learning curve from 2 to 3 in anything but negligible terms. What makes the jump big?

Re: [Tutor] Creating lists with definite (n) items without repetitions

2015-09-03 Thread Martin A. Brown
ted items from the input list? The random module provides random.sample() to select n items from a sequence. If so, try this out at the intercative prompt. Perhaps this is what you are looking for? >>> import random >>> import string >>> l = list(string.l

Re: [Tutor] How should my code handle db connections? Should my db manager module use OOP?

2015-08-26 Thread Martin A. Brown
the beginnings...a SQLite DB is a fine place to start if you have only one thread/user/program accessing the data at any time. Don't host it on a network(ed) file system if you have the choice. If your application grows so much in usage or volume that it needs a new and different DB, consider

Re: [Tutor] Problem using lxml

2015-08-22 Thread Martin A. Brown
x27;d recommend playing with the data in an interactive console session. You will be able to figure out exactly which xpath gets you the data you would like, and then you can drop it into your script. Good luck, -Martin -- Martin A. Brown http://linux-ip.net/ _

Re: [Tutor] for loop for long numbers

2015-08-03 Thread Martin A. Brown
oop in Python 2.7.3. None at all. I also gave Python 3.3.0 a try, by running this: for i in range(0, 90): x = 0 This also ran without a hitch So, perhaps you are having some sort of other problem. Would you like to provide more detail? -Martin P.S. I wrote a little fu

Re: [Tutor] String Attribute

2015-07-31 Thread Martin A. Brown
building function for append? Question no. 3: If all else fails, i.e., append & set, my only option is the slice the data set? I do not understand these two questions. Good luck. -Martin P.S. By the way, Alan Gauld has also responded to your message, with a differently-phrased answer, but,

Re: [Tutor] line error on no. 7

2015-07-28 Thread Martin A. Brown
m to the list # called 'lst'. # -- now, outside the loop, I would suggest printing the list print lst Once you can run your program and get something other than an empty list, you know you have made progress. Good luck with your iambic pentameter, -Martin The sample data i

Re: [Tutor] Help Command Question

2015-07-28 Thread Martin A. Brown
Hi there, In [1]: help list File "", line 1 help list ^ SyntaxError: invalid syntax.' Question: What is the correct help command? Try: help(list) Snipped from my ipython session: In [1]: help(list) Good luck, -Martin -- Martin A. Brown http

Re: [Tutor] Socket Module

2015-07-26 Thread Martin A. Brown
hly, there are many things that can go wrong in the network and on an end host which can cause transient errors during DNS lookups, and it is possible that you have already encountered some of these problems (even though I would not expect to hit very many errors looking up PTR records for only

Re: [Tutor] How to return a list in an exception object?

2015-06-17 Thread Martin A. Brown
only, b_only # -- and now to use it import random a = random.sample(range(17), 10) b = random.sample(range(17), 10) same, a_only, b_only = differing(a, b) If you wanted to make sure that there were no extra files, you could: assert 0 == len(b_only) Anyway, there are many ways to

Re: [Tutor] Integrating TDD into my current project work-flows

2015-05-04 Thread Martin A. Brown
f the lines in the code under test which are NOT yet tested; handy! Good luck, -Martin -- Martin A. Brown http://linux-ip.net/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Pun panic, was Re: calling a method directly

2015-04-21 Thread Martin A. Brown
a lowering cow. to lower (v.i.), to be or become dark, gloomy, and threatening (which is cognate to the contemporary German word 'lauern') And, I dairy not chase this pun any further.... -Martin [0] http://www.merriam-webster.com/dictionary/lower -- Martin A. Brown http://l

Re: [Tutor] lists, name semantics

2015-04-17 Thread Martin A. Brown
out nuance, I would point out that this is no nuance but a significant feature which can surprise you later if you do not understand what is happening with the slicing notation. Best of luck and enjoy a fried slice of Python! -Martin [0] https://docs.python.org/3/library/stdtypes.h

Re: [Tutor] Hi

2015-04-11 Thread Martin A. Brown
Greetings Steven, Much great advice snipped. Is it possible (using U+1F600 through U+1F64F or otherwise) to offer a standing ovation for such a relevant, thorough, competent and well-written reply? Thank you, as always, -Martin (You know, Steven, we had gotten so accustomed to your

Re: [Tutor] Feedback on Script for Pandas DataFrame Written into XML

2015-03-30 Thread Martin A. Brown
the DataFrame? For understanding and using a DataFrame, you'd probably be better off asking on the pandas mailing list. ... or maybe the Pandas mailing list: https://groups.google.com/forum/#!forum/pydata May the Python never release you from its grip! -Martin -- Martin A.

Re: [Tutor] Feedback on Script for Pandas DataFrame Written into XML

2015-03-29 Thread Martin A. Brown
Tree) mailing list ... https://mailman-mail5.webfaction.com/listinfo/lxml ... or maybe the Pandas mailing list: https://groups.google.com/forum/#!forum/pydata Best of luck, -Martin -- Martin A. Brown http://linux-ip.net/ ___ Tutor maillist - Tutor@

Re: [Tutor] Advice on Strategy for Attacking IO Program

2015-03-29 Thread Martin A. Brown
at some sort of file-naming strategy to avoid overwriting evidence of earlier failures. File naming is a tricky thing. See the tempfile module [1] and the Maildir naming scheme to see two different types of solutions to the problem of choosing a unique filename. Good luck w

Re: [Tutor] UPDATE: Is there a 'hook' to capture all exits from a python program?

2015-03-20 Thread Martin A. Brown
l, as it is commonly understood (in the sysadmin world) to mean things like 're-read your config file' or 'restart a certain routine activity'. So, it may surprise some folk if a process died after receiving a HUP. This may be desirable--it depends entirely on what you

Re: [Tutor] SQLAlchemy

2015-01-26 Thread Martin A. Brown
pect that you are calling sqlalchemy.engine.create_engine() at some point. When you are doing that, you can/should pass your desired user credentials into this function. http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html Good luck, -Martin [0] http://www.sqlalchemy.or

Re: [Tutor] about multiprocessing performance

2014-12-15 Thread Luis San Martin
I made a silly mistake as Jerry points its working above the same performance. Kind regards On Fri, Dec 12, 2014 at 8:27 PM, Alan Gauld wrote: > On 12/12/14 14:20, Luis San Martin wrote: >> >> Dear fellows, >> >> I'm learning about on multiprocessing module o

[Tutor] about multiprocessing performance

2014-12-12 Thread Luis San Martin
Dear fellows, I'm learning about on multiprocessing module on python. So far I've enjoyed it though regarding performance I got some doubts. There is not that much difference[0] when running it on Mac OS X on the contrary to Linux. [0] http://codepad.org/lNDHNhof Kind regards ___

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Martin A. Brown
, because there is a module called array, and I may #(one day) want to use it. >>> arr {'name': 'Joe', 'address': '111 Street'} # -- OK, but I'm lazy, I don't want to have to type all of my #JSON into strings. OK. So

Re: [Tutor] Would somebody kindly...

2014-10-30 Thread Martin A. Brown
this was fixed. Apologies! -Martin -- Martin A. Brown http://linux-ip.net/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Would somebody kindly...

2014-10-30 Thread Martin A. Brown
')] Hey! We flipped the position of the number and the alphachar in the tuple! That was fun. Game #4: Drop a function into the output expression. Not only can you perform simple sleight of hand like manipulating tuples, but you can perform function calls. So multiply the second e

Re: [Tutor] (no subject)

2014-10-09 Thread Martin A. Brown
tem python 2.7.8 please help? One other issue I might point out. The semicolon at the end of the line (statement) is a feature of other programming languages with which you may be familiar (C, Java, Perl), but it is not necessary and, in fact, discouraged in Python. So, rid yourself of the

Re: [Tutor] How best to structure a plain text data file for use in program(s) and later updating with new data?

2014-10-08 Thread Martin A. Brown
then maybe that's a better option for you. If you can not do so, then take this older version of simplejson. You are at that place of last resort to which the simplejson authors allude. How do you like it at that resort? Would I want to go on vacation there? -Martin -- Martin A.

Re: [Tutor] How best to structure a plain text data file for use in program(s) and later updating with new data?

2014-10-08 Thread Martin A. Brown
import json except ImportError: # -- Python-2.4, simplejson import simplejson as json And, then the rest of the program can operate just the same, regardless of which one you used. Good luck, -Martin [0] https://pypi.python.org/pypi/simplejson/ [1] http://stackoverflow.com/ques

Re: [Tutor] search/match file position q

2014-10-07 Thread Martin A. Brown
I will check out beautiful soup as suggested !> in a subsequent mail; I'd still like to finish this process:<}} !Do you say that when someone points out that you are eating your shoe? Depends on the flavor of the shoe:<))) Root beer float. -Martin [0] If you really, really want

Re: [Tutor] Suggestions Please

2014-10-06 Thread Martin A. Brown
ophistication. I still reach for SQL for many reasons, but I like the flexibility, richness and tools that Python offers me. -Martin P.S. The Python online documentation is pretty good.though the language changed very little between Python-2.x and Python-3.x, there are a few stum

Re: [Tutor] printing all text that begins with "25"

2014-10-02 Thread Martin A. Brown
ys.argv[1], sys.argv[2:]) I happen to be the sort of person who always wants to point out the IP-related tools available in Python hence my reply to your post. Happy trails and good luck, -Martin [0] https://apps.db.ripe.net/search/query.html?searchtext=25.0.0.0/8&source=RIPE#resultsAncho

[Tutor] Trouble with making a chart

2014-09-29 Thread Martin Skåreby
Hello!So i'm having trouble with a task i got from my teacher in a book. I'm supposed to create a chart which shows the converted numbers between Celsius and Fahrenheit. They want the Celsius to range from 40 to -40. I also get to know that Fahrenheit = 32+celsius*9/5. Now I managed to write th

Re: [Tutor] Development of administration utility

2014-08-21 Thread Martin A. Brown
x27;s paramiko. https://pypi.python.org/pypi/paramiko/ : Any feedback on any of the points above would be greatly appreciated. I don't know if this is the sort of feedback that you were looking for, so I'll just stop there. Good luck, -Martin __

Re: [Tutor] Modules to work with curl.

2014-07-17 Thread Martin A. Brown
f calling subprocess. * If after that, you discover that your bottleneck is mostly network, consider a task parallelizing solution. One option could be multiprocessing [1]. There are doubtless others. -Martin [0] http://docs.python-requests.org/en/latest/ [1] https://docs.

Re: [Tutor] Real world experience

2014-05-12 Thread Martin A. Brown
obody (Oh! I need to go eat!), -Martin [0] For these purposes, mine was IP networking. [1] What!?! Not Python?! Why? There are reasons to choose something else. Do not be blind to those resaons. [2] Find people who are motivated as you are and are working on similar problems.

Re: [Tutor] preferred httprequest library

2014-05-08 Thread Martin A. Brown
tandard library tools (urllib, and urllib2) unless you need that finer control. This has a nice abstraction and, from your description, I think this would be a good fit: http://docs.python-requests.org/en/latest/ -Martin -- Martin A. Brown http

Re: [Tutor] some things work in IDLE but not a command prompt and vice versa

2014-04-25 Thread Martin
On 24/04/2014 10:41, Alan Gauld wrote: On 24/04/14 00:14, Martin wrote: If I run from a command prompt, however, I get C:\Users\Martin\Documents\College\python>python pickle.py You have called your file pickle.py. So when you try to import pickle the interpreter sees your file first

[Tutor] some things work in IDLE but not a command prompt and vice versa

2014-04-24 Thread Martin
7;pickle.dat','rb') contents = pickle.load(file3) print(contents) input('\nPress Enter to finish') This works as expected when run under the IDLE. first.txt is just a small text file. If I run from a command prompt, however, I get C:\Users\Martin\Documents\College\python>

Re: [Tutor] improving speed using and recalling C functions

2014-04-10 Thread Martin A. Brown
ing so newer .debug lines #are not shown logger.setLevel(logging.INFO) logger.debug("debug example %d", 3) OK, so why is this useful? Well, timestamps in log lines is one reason. Another reason is the typical diagnostic technique "What is the value of variable x, y,

Re: [Tutor] improving speed using and recalling C functions

2014-04-10 Thread Martin A. Brown
admittedly brain-dead function, there's not a performance bottleneck. If you can find the parts of your skymaps5.py code that are the bottleneck, then you could post it here. I hadn't thought of using interpolate, myself, as I didn't even know it existed. Thanks an

Re: [Tutor] improving speed using and recalling C functions

2014-04-10 Thread Martin A. Brown
dations on which avenue to take--but if you are asking, you may already have the tools you need to assess for yourself. There is, however, quite a bit of experience loitering around this list, so perhaps somebody else will have a suggestion. -Martin [0] http://www.numpy.org/ [1] http://www

Re: [Tutor] How to get file permissions (Python 2.4)?

2014-03-19 Thread Martin A. Brown
at.S_IRWXU & os.stat('/usr/bin/python').st_mode Better yet? Let os.access() [1] do the bitmath for you: os.access('/usr/bin/python', os.X_OK) Good luck, -Martin [0] http://docs.python.org/2/library/stat.html [1] http://d

Re: [Tutor] Assigning a variable to an FTP directory listing

2013-12-12 Thread Pat Martin
help. On Wed, Dec 11, 2013 at 4:22 PM, Steven D'Aprano wrote: > On Wed, Dec 11, 2013 at 03:55:50PM -0800, Pat Martin wrote: >> Hello, >> >> I am writing a program that needs to pull all of the files from a >> specific directory. I have a few lines written that gi

  1   2   3   4   >