Re: Help

2023-11-06 Thread Jason Friedman via Python-list
On Sun, Nov 5, 2023 at 1:23 PM office officce via Python-list < python-list@python.org> wrote: > which python version is better to be used and how to make sure it works on > my window 10 because i downloaded it and it never worked so I uninstall to > do that again please can you give me the steps

Re: Generating documentation with Sphinx

2023-08-28 Thread Jason Friedman via Python-list
def construct_response(exit_code: int, message: str) -> Response: >> """ >> Construct a Flask-suitable response >> >> :param exit_code: 0 or something else >> :param message: something useful >> :return: a Flask-suitable response >> """ >> >> >> @app.route(f"/{version}/",

Re: Generating documentation with Sphinx

2023-08-28 Thread Jason Friedman via Python-list
And I can answer my own Question 2: :func:`my_project.main_application.construct_response` On Mon, Aug 28, 2023 at 1:39 PM Jason Friedman wrote: > def construct_response(exit_code: int, message: str) -> Response: >> """ >> Construct a Flask-suitable re

Re: Generating documentation with Sphinx

2023-08-28 Thread Jason Friedman via Python-list
> > def construct_response(exit_code: int, message: str) -> Response: > """ > Construct a Flask-suitable response > > :param exit_code: 0 or something else > :param message: something useful > :return: a Flask-suitable response > """ > > > @app.route(f"/{version}/",

Generating documentation with Sphinx

2023-08-28 Thread Jason Friedman via Python-list
I have two questions, please (this is after reading https://docs.readthedocs.io/en/stable/guides/cross-referencing-with-sphinx.html#automatically-label-sections ). This is my project structure: my_project api stuff1.py stuff2.py lib stuff3.py stuff4.py main_application.py

Context manager for database connection

2023-08-23 Thread Jason Friedman via Python-list
I want to be able to write code like this: with Database() as mydb: conn = mydb.get_connection() cursor = conn.get_cursor() cursor.execute("update table1 set x = 1 where y = 2") cursor.close() cursor = conn.get_cursor() cursor.execute("update table2 set a = 1 where b = 2") cursor.close() I'd

Re: How to find the full class name for a frame

2023-08-04 Thread Jason Friedman via Python-list
> > Jason Friedman wrote at 2023-8-3 21:34 -0600: > > ... > >my_frame = inspect.currentframe() > > ... > >My question is: let's say I wanted to add a type hint for my_frame. > > `my_frame` will be an instance of `Types.FrameType`. > Confirmed. Thank y

Re: How to find the full class name for a frame

2023-08-04 Thread Jason Friedman via Python-list
> My question is: let's say I wanted to add a type hint for my_frame. > > > > my_frame: some_class_name = inspect.currentframe() > > > > What would I put for some_class_name? > > "frame" (without quotations) is not recognized, > > Nor is inspect.frame. > > We know Python code is executed in an

How to find the full class name for a frame

2023-08-03 Thread Jason Friedman via Python-list
import inspect def my_example(arg1, arg2): print(inspect.stack()[0][3]) my_frame = inspect.currentframe() args,_,_,values = inspect.getargvalues(my_frame) args_rendered = [f"{x}: {values[x]}" for x in args] print(args_rendered) my_example("a", 1) The above "works" in the sense it prints what I

Trouble with defaults and timeout decorator

2023-06-24 Thread Jason Friedman via Python-list
I'm writing a database connectivity module to be used by other modules and leveraging the jaydebeapi module. >From what I can tell jaydebeapi contains no built-in timeout capability, so then I turned to https://pypi.org/project/timeout-decorator/. My goal is to have a default timeout of, say, 10

Re: Match statement with literal strings

2023-06-07 Thread Jason Friedman via Python-list
eg Ewing via Python-list < python-list@python.org> wrote: > On 8/06/23 10:18 am, Jason Friedman wrote: > > SyntaxError: name capture 'RANGE' makes remaining patterns unreachable > > The bytecode compiler doesn't know that you intend RANGE > to be a constant -- it thinks it's

Match statement with literal strings

2023-06-07 Thread Jason Friedman via Python-list
This gives the expected results: with open(data_file, newline="") as reader: csvreader = csv.DictReader(reader) for row in csvreader: #print(row) match row[RULE_TYPE]: case "RANGE": print("range") case "MANDATORY": print("mandatory") case _: print("nothing to do") This: RANGE = "RANGE"

Best practice for database connection

2023-05-31 Thread Jason Friedman
I'm trying to reconcile two best practices which seem to conflict. 1) Use a _with_ clause when connecting to a database so the connection is closed in case of premature exit. class_name = 'oracle.jdbc.OracleDriver' url = f"jdbc:oracle:thin:@//{host_name}:{port_number}/{database_name}" with

Re: Python 3.11.0 installation and Tkinter does not work

2022-11-23 Thread Jason Friedman
> > I want learn python for 4 weeks and have problems, installing Tkinter. If > I installed 3.11.0 for my windows 8.1 from python.org and type > > >>> import _tkinter > > Traceback (most recent call last): > >File "", line 1, in > > ImportError: DLL load failed while importing

Re: Set git config credential.helper cache and timeout via python

2021-12-11 Thread Jason Friedman
> > > Hey All, > > I have a set of bash and python scripts that all interact with a remote > git repository. > > > https://gitpython.readthedocs.io/en/stable/reference.html?highlight=cache#git.index.fun.read_cache > https://pypi.org/project/git-credential-helpers/ > > But neither means appears to

Re: Set git config credential.helper cache and timeout via python

2021-12-11 Thread Jason Friedman
> Hey All, > > I have a set of bash and python scripts that all interact with a remote > git repository. > This does not exactly answer your question, but whenever I have wanted to interact with (popular) software via Python I have checked to see if someone has already written that code for me.

Determine what the calling program is

2021-04-18 Thread Jason Friedman
I should state at the start that I have a solution to my problem. I am writing to see if there is a better solution. I have a program that runs via crontab every five minutes. It polls a Box.com folder for files and, if any are found, it copies them locally and performs a computation on them that

Re: What's the meaning the "backlog" in the socket.listen(backlog) is?

2021-02-16 Thread Jason Friedman
> > I set listen(2) and expect to see "error" when more clients than "the > maximum number of queued connections" trying to connect the server. But, no > error!! Even 4 clients can run normally without problem. > > Am I misunderstanding the meaning of this argument? >

Re: For example: Question, moving a folder (T061RR7N1) containing a Specific file (ReadCMI), to folder: C:\\...\DUT0

2021-01-27 Thread Jason Friedman
> > > for path, dir, files in os.walk(myDestinationFolder): > # for path, dir, files in os.walk(destfolder): > print('The path is %s: ', path) > print(files) > os.chdir(mySourceFolder) > if not os.path.isfile(myDestinationFolder + file): > # if not os.path.isfile(destfolder +

Re: Copying column values up based on other column values

2021-01-03 Thread Jason Friedman
> > import numpy as np > import pandas as pd > from numpy.random import randn > df=pd.DataFrame(randn(5,4),['A','B','C','D','E'],['W','X','Y','Z']) > > W X Y Z > A -0.183141 -0.398652 0.909746 0.332105 > B -0.587611 -2.046930 1.446886 0.167606 > C 1.142661 -0.861617 -0.180631 1.650463 > D 1.174805

Re: Reading binary data with the CSV module

2020-11-29 Thread Jason Friedman
> > csv.DictReader appears to be happy with a list of strings representing > the lines. > > Try this: > > contents = source_file.content() > > for row in csv.DictReader(contents.decode('utf-8').splitlines()): > print(row) > Works great, thank you! Question ... will this form potentially use

Reading binary data with the CSV module

2020-11-29 Thread Jason Friedman
Using the Box API: print(source_file.content()) returns b'First Name,Last Name,Email Address,Company,Position,Connected On\nPeter,van (and more data, not pasted here) Trying to read it via: with io.TextIOWrapper(source_file.content(), encoding='utf-8') as text_file: reader =

Re: filtering out warnings

2020-11-29 Thread Jason Friedman
> > The Box API is noisy ... very helpful for diagnosing, and yet for > production code I'd like less noise. > > I tried this: > > warnings.filterwarnings( > action='ignore', > # category=Warning, > # module=r'boxsdk.*' > ) > > but I still see this: > >

filtering out warnings

2020-11-27 Thread Jason Friedman
The Box API is noisy ... very helpful for diagnosing, and yet for production code I'd like less noise. I tried this: warnings.filterwarnings( action='ignore', # category=Warning, # module=r'boxsdk.*' ) but I still see this: WARNING:boxsdk.network.default_network:"POST

Re: try/except in loop

2020-11-27 Thread Jason Friedman
> > >> I'm using the Box API ( >> https://developer.box.com/guides/tooling/sdks/python/). >> I can get an access token, though it expires after a certain amount of >> time. My plan is to store the access token on the filesystem and use it >> until it expires, then fetch a new one. In the example

try/except in loop

2020-11-27 Thread Jason Friedman
I'm using the Box API (https://developer.box.com/guides/tooling/sdks/python/). I can get an access token, though it expires after a certain amount of time. My plan is to store the access token on the filesystem and use it until it expires, then fetch a new one. In the example below assume I have

Re: MERGE SQL in cx_Oracle executemany

2020-10-17 Thread Jason Friedman
> > I'm looking to insert values into an oracle table (my_table) using the > query below. The insert query works when the PROJECT is not NULL/empty > (""). However when PROJECT is an empty string(''), the query creates a new > duplicate row every time the code is executed (with project value >

Re: importlib: import X as Y; from A import B

2020-08-10 Thread Jason Friedman
> > import pandas; pd = pandas > > >df = pd.from_csv (...) > >from selenium import webdriver > > import selenium.webdriver; webdriver = selenium.webdriver > Thank you, this works. -- https://mail.python.org/mailman/listinfo/python-list

importlib: import X as Y; from A import B

2020-08-08 Thread Jason Friedman
I have some code I'm going to share with my team, many of whom are not yet familiar with Python. They may not have 3rd-party libraries such as pandas or selenium installed. Yes I can instruct them how to install, but the path of least resistance is to have my code to check for missing dependencies

Re: Consumer trait recognition

2020-05-04 Thread Jason Friedman
> > I constructed a lexicon for words that show how different words are linked > to consumer traits and motivations (e.g. Achievement and Power Motivation). > Now I have collected a large amount of online customer reviews and want to > match each review with the word definitions of the consumer

Re: TensorFlow with 3.8.1

2020-01-21 Thread Jason Friedman
You have another thread on this list that refers to general Python installation issues, so you'll need to work through that. I'm writing in this thread to say that tensorflow does not (today) support Python 3.8, you'll want to try 3.7, assuming that tensorflow is a critical piece for you:

Re: Grepping words for match in a file

2019-12-28 Thread Jason Friedman
> > > I have some lines in a text file like > ADD R1, R2 > ADD3 R4, R5, R6 > ADD.MOV R1, R2, [0x10] > Actually I want to get 2 matches. ADD R1, R2 and ADD.MOV R1, R2, [0x10] > because these two lines are actually "ADD" instructions. However, "ADD3" is > something else. > >>> s = """ADD R1,

Re: Logistic Regression Define X and Y for Prediction

2019-11-13 Thread Jason Friedman
> > > When I define the X and Y values for prediction in the train and test > data, should I capture all the columns that has been "OneHotEncoded" (that > is all columns with 0 and 1) for the X and Y values??? > You might have better luck asking on Stackoverflow, per the Pandas instructions:

Re: Congratulations to @Chris

2019-10-26 Thread Jason Friedman
> > Chris Angelico: [PSF's] 2019 Q2 Community Service Award Winner > http://pyfound.blogspot.com/2019/10/chris-angelico-2019-q2-community.html > > ...and for the many assistances and pearls of wisdom he has contributed > 'here'! > -- > Regards, > =dn > > Agreed. --

Re: fileinput module not yielding expected results

2019-09-07 Thread Jason Friedman
> > If you're certain that the headers are the same in each file, > then there's no harm and much simplicity in reading them each > time they come up. > > with fileinput ...: > for line in f: > if fileinput.isfirstline(): > headers =

fileinput module not yielding expected results

2019-09-07 Thread Jason Friedman
import csv import fileinput import sys print("Version: " + str(sys.version_info)) print("Files: " + str(sys.argv[1:])) with fileinput.input(sys.argv[1:]) as f: for line in f: print(f"File number: {fileinput.fileno()}") print(f"Is first line: {fileinput.isfirstline()}") I

Re: How to use regex to search string between {}?

2019-08-28 Thread Jason Friedman
> > If I have path: /home/admin/hello/yo/{h1,h2,h3,h4} > > import re > r = re.search('{.}', path) > # r should be ['h1,h2,h3,h4'] but I fail > > Why always search nothing? > A site like http://www.pyregex.com/ allows you to check your regex with slightly fewer clicks and keystrokes than editing

Re: The Mailing List Digest Project

2019-03-29 Thread Jason Friedman
> > Pretty cool. FYI, the index page (now containing 4 articles) with Google >> Chrome 72.0.3626.x prompts me to translate to French. The articles >> themselves do not. >> > > I'm now getting the translation offer on other web pages with Chrome, not just this one. Thus, please ignore my prior

Re: The Mailing List Digest Project

2019-03-27 Thread Jason Friedman
On Mon, Mar 25, 2019 at 11:03 PM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > As proposed on python-ideas, i setup a repo to turn mail threads into > articles. > > i included a script to build .md to .html (with syntax highlighting) here > is the index > >

Re: Not Defined error in basic code

2019-03-14 Thread Jason Friedman
On Thu, Mar 14, 2019 at 8:07 AM Jack Dangler wrote: > > > class weapon: > weaponId > manufacturerName > > def printWeaponInfo(self): > infoString = "ID: %d Mfg: %s Model: %s" % (self.weaponId, > self.manufacturerName) > return infoString > > > > import

Re: Python Packages Survey

2019-01-19 Thread Jason Friedman
On Fri, Jan 18, 2019 at 5:22 PM Cameron Davidson-Pilon < cam.davidson.pi...@gmail.com> wrote: > Hello! I invite you to participate in the Python Packages Survey - it takes > less than a minute to complete, and will help open source developers > understand their users' better. Thanks for

Re: namedtuples anamoly

2018-10-18 Thread Jason Friedman
> > So now the real question is: What were you trying to accomplish with > the assignment? Tell us, and let's see if we can find a way to > accomplish yor goal without wrecking the internals of the Grade class. > > And depending on your answer to that question, the new Data Classes feature in

Re: Add header at top with email.message

2018-09-15 Thread Jason Friedman
> > the EmailMessage class of email.message provides the methods > add_header() and __setitem__() to add a header to a message. > add_header() effectively calls __setitem__(), which does > `self._headers.append(self.policy.header_store_parse(name, val))`. This > inserts the header at the bottom.

Re: Bottle framework references

2018-08-24 Thread Jason Friedman
> > > > On 22 Aug 2018, at 8:38 am, Jason Friedman wrote: > > > >> > >> I am building up the microsite based on Bottle framework now. > >> Any references/books? I am unfamiliar with this framework yet. > >> > >> I have used it with

Re: Bottle framework references

2018-08-21 Thread Jason Friedman
> > I am building up the microsite based on Bottle framework now. > Any references/books? I am unfamiliar with this framework yet. > > I have used it with success. The online documentation was sufficient for my needs, at least. -- https://mail.python.org/mailman/listinfo/python-list

defaultdict and datetime

2018-08-18 Thread Jason Friedman
$ python3 Python 3.6.1 (default, Apr 8 2017, 09:56:20) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import collections, datetime >>> x = collections.defaultdict(int) >>> x['something'] 0 >>> x = collections.defaultdict(datetime.datetime)

Re: how to set timeout for os.popen

2018-04-15 Thread Jason Friedman
> > while 1: > runner = os.popen("tracert -d www.hello.com") > o=runner.read() > print(o) > runner.close() > runner = os.popen("tracert -d www.hello.com") > o=runner.read() > print(o) > runner.close() > runner = os.popen("tracert -d www.hello.com") > o=runner.read() > print(o) > runner.close() > >

Re: # of Months between two dates

2018-04-06 Thread Jason Friedman
> > >> > It's probably better to write the function yourself according to what > >> > makes sense in your use-case, and document its behaviour clearly. > >> > >> > > I suggest using the dateutil module ( > > https://pypi.python.org/pypi/python-dateutil) before writing your own. > > I'm not seeing

Re: # of Months between two dates

2018-04-05 Thread Jason Friedman
> > > > I've written a function to return the months between date1 and date2 > but > > > I'd like to know if anyone is aware of anything in the standard library > > > to do the same? For bonus points, does anyone know if postgres can do > > > the same (we use a lot of date/time funcitons in

Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Jason Friedman
On Tue, Mar 6, 2018 at 1:52 AM, Kirill Balunov wrote: > > I propose to delete all references in the `filter` documentation that the > first argument can be `None`, with possible depreciation of `None` as the > the first argument - FutureWarning in Python 3.8+ and

Re: APPLICATION NOT RUNNING.

2018-03-02 Thread Jason Friedman
> > I try to run an application with the latest version of python that is > python 3.6.4 (32-bit) ., instead of running the application it only shows > feel free to mail python-list@python.org if you continue to encounter > issues,Please help me out thanks. > Hello, you might have more success if

Re: Any users of statistics.mode() here?

2018-02-20 Thread Jason Friedman
> statistics.mode() currently raises an exception if there is more than one > mode. > I am an infrequent user of this package and this function. My two cents: * Leave the current behavior as-is. * Continue to throw an exception for no data. * Add an argument, named perhaps mutli=False, that if

Re: Sending Email using examples From Tutorials

2018-01-27 Thread Jason Friedman
> > import smtplib > server = smtplib.SMTP('localhost') > server.sendmail('gg77gal...@yahoo.com', > """To: gg.gal...@gmail.com > From: gg77gal...@yahoo.com > > Beware the Ides of March. > """) > server.quit() > > when running this I get the following message. Please help: > > Traceback (most

Re: Nested Loop Triangle

2017-05-25 Thread Jason Friedman
> > I need the triangle to be in reverse. The assignment requires a nested > loop to generate a triangle with the user input of how many lines. > > Currently, I get answers such as: (A) > > OOO > OO > O > > When I actually need it to be like this: (B) > > OOO >OO > O > Try the

Re: No module named vtkCommonCorePython

2017-05-20 Thread Jason Friedman
> > I have a problem to finding file in Python path,Anybody knows how to solve > it? > > Unexpected error: > Traceback (most recent call last): > File > "/home/nurzat/Documents/vmtk-build/Install/bin/vmtklevelsetsegmentation", > line 20, in > from vmtk import pypeserver > File

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2017-05-12 Thread Jason Friedman
> > >> The first section does not do what I think you want: a list with 7 > options. It makes a list with one option, then overwrites it with a new > list with one option, and so on. You want something like: > menu_list = [ > "O - open account" > "L - load details" > "D - display

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2017-05-12 Thread Jason Friedman
> > menu_list = ["O -open account"] > menu_list =["l - load details"] > menu_list =["D- display details"] > menu_list =["A - Make deposit"] > menu_list =["W- Make withdraw",] > menu_list =["S - save"] > menu_list =["Q - quit"] > > command = input("command:") > if command.upper() == "O": > open_()

Not understanding itertools.dropwhile()

2017-04-29 Thread Jason Friedman
< start code > import itertools data = """Line1 Line2 Line4 Line5""" def test_to_start(s): return "2" in s for line in itertools.dropwhile(test_to_start, data.splitlines()): print(line) < end code > I expect: $ python3 dropwhile.py Line2 Line4 Line5 I get: $

Re: TIC TAE TOE's problem(i am beginner)

2017-04-15 Thread Jason Friedman
> > P=input("X/O:") > if P=="X": > my_func1() > else: > my_func2() > > > > why cant function to print X or O win... > As a beginner I'd try to code using Python idioms rather than writing Python using BASIC idioms. Try to understand how this code works:

Re: homework confusion

2017-04-12 Thread Jason Friedman
> > The example command is: Lockable("diary", "under Sam's bed", tiny_key, > True) > > And I keep getting a NameError: tiny_key is not defined. > > What do I do? > Without knowing what your professor intends this is a guess: define tiny_key. For example tiny_key = "some string" thing =

Re: Moderating the list [was: Python and the need for speed]

2017-04-12 Thread Jason Friedman
> > However, it's simply a technical fact: the thing which we moderate is the >> mailing list. We can control which posts make it through from the newsgroup >> by blocking them at the gateway. But the posts will continue to appear on >> comp.lang.python which is, as the description says,

Re: Python Command Line Arguments

2017-04-12 Thread Jason Friedman
> > I have this code which I got from https://www.tutorialspoint. > com/python/python_command_line_arguments.htm The example works fine but > when I modify it to what I need, it only half works. The problem is the > try/except. If you don't specify an input/output, they are blank at the end > but

Re: Online Python Editor with Live Syntax Checking

2017-03-05 Thread Jason Friedman
> > I made a tool called PythonBuddy (http://pythonbuddy.com/). > > I made this so that MOOCs like edX or codecademy could easily embed and > use this on their courses so students wouldn't have to go through the > frustrations of setting up a Python environment and jump right into Python >

Re: List comprehension

2016-12-30 Thread Jason Friedman
> data = ( >> ... (1,2), >> ... (3,4), >> ... ) >> > [x,y for a in data] >> File "", line 1 >> [x,y for a in data] >>^ >> SyntaxError: invalid syntax >> >> I expected: >> [(1, 2), (3, 4)] > > > Why would you expect that? I would expect the global variables x and y, or >

List comprehension

2016-12-30 Thread Jason Friedman
$ python Python 3.6.0 (default, Dec 26 2016, 18:23:08) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> data = ( ... (1,2), ... (3,4), ... ) >>> [a for a in data] [(1, 2), (3, 4)] Now, this puzzles me: >>> [x,y for a in data] File "", line 1

Re: Options for stdin and stdout when using pdb debugger

2016-11-25 Thread Jason Friedman
> I would like to use pdb in an application where it isn't possible to use > sys.stdin for input. I've read in the documentation for pdb.Pdb that a file > object can be used instead of sys.stdin. Unfortunately, I'm not clear about > my options for the file object. > > I've looked at rpdb on

Re: passing a variable to cmd

2016-11-06 Thread Jason Friedman
> > import subprocess > import shlex > > domname = raw_input("Enter your domain name: "); > print "Your domain name is: ", domname > > print "\n" > > # cmd='dig @4.2.2.2 nbc.com ns +short' > cmd="dig @4.2.2.2 %s ns +short", % (domname) >

Re: Internet Data Handling » mailbox

2016-10-23 Thread Jason Friedman
> > for message in mailbox.mbox(sys.argv[1]): > if message.has_key("From") and message.has_key("To"): > addrs = message.get_all("From") > addrs.extend(message.get_all("To")) > for addr in addrs: > addrl = addr.lower()

Re: Stompy

2016-09-25 Thread Jason Friedman
> > My error: >> Traceback (most recent call last): >> File "temp.py", line 8, in >> my_stomp.connect(AMQ_USERNAME, AMQ_PASSWORD) >> File "/lclapps/oppen/thirdparty/stompy/stomp.py", line 48, in connect >> self.frame.connect(self.sock, username=username, password=password, >>

Stompy

2016-09-25 Thread Jason Friedman
My goal is to send messages to an AMQ server using Python 3.3. I found Stompy and performed 2to3-3.3 before building. I am open to non-Stompy solutions. My code: from stompy.stomp import Stomp my_stomp = Stomp(AMQ_HOST, AMQ_PORT) my_stomp.connect(AMQ_USERNAME, AMQ_PASSWORD) My error:

Re: Is Activestate's Python recipes broken?

2016-08-04 Thread Jason Friedman
> > Log in to Activestate: > > https://code.activestate.com/recipes/langs/python/new/ > > and click "Add a Recipe". I get > > > Forbidden > > You don't have permission to access /recipes/add/ on this server. > Apache Server at code.activestate.com Port 443 > > > > Broken for everyone, or just for

Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Jason Friedman
> > +1 for consistency, but I'm just fine with the short names. It's in the > statistics module after all, so the context is very narrow and clear and > people who don't know which to use or what the one does that they find in a > given piece of code will have to read the docs and maybe fresh up

Re: python parsing suggestion

2016-05-30 Thread Jason Friedman
> > Trying to extract the '1,1,114688:8192' pattern form the below output. > > pdb>stdout: > '3aae5d0-1: Parent Block for 1,1,19169280:8192 (block 1,1,114688:8192) > --\n3aae5d0-1: > magic 0xdeaff2fe mark_cookie > 0x\ngpal-3aae5d0-1: super.status > 3

Re: How can I debug silent failure - print no output

2016-05-27 Thread Jason Friedman
> > def GetArgs(): > '''parse XML from command line''' > parser = argparse.ArgumentParser() > > parser.add_argument("path", nargs="+") > parser.add_argument('-e', '--extension', default='', > help='File extension to filter by.') > args =

Re: Why online forums have bad behaviour (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?)

2016-05-12 Thread Jason Friedman
> TL;DR: because we're all human, and human behaviour needs either > immediate face-to-face feedback or social enforcement to correct > selfishness and abrasiveness. Where face-to-face feedback is lacking, > social enforcement needs to take more of the load. > > > Many people have a false sense of

Re: Python,ping,csv

2016-04-11 Thread Jason Friedman
> I added a line. > I would need to put the output into a csv file which contained the > results of the hosts up and down. > Can you help me? > > import subprocess > from ipaddress import IPv4Network > for address in IPv4Network('10.24.59.0/24').hosts(): > a = str(address) > res =

Re: Python,ping,csv

2016-04-11 Thread Jason Friedman
> I added a line. > I would need to put the output into a csv file which contained the results > of the hosts up and down. > Can you help me? > > > import subprocess > from ipaddress import IPv4Network > for address in IPv4Network('10.24.59.0/24').hosts(): > a = str(address) > res

Re: Python,ping,csv

2016-04-09 Thread Jason Friedman
> for ping in range(1,254): > address = "10.24.59." + str(ping) > res = subprocess.call(['ping', '-c', '3', address]) > if res == 0: > print ("ping to", address, "OK") > elif res == 2: > print ("no response from", address) > else: > print ("ping to",

Re: i cant seem to figure out the error

2016-04-03 Thread Jason Friedman
> def deposit(self, amount): > self.amount=amount > self.balance += amount > return self.balance > > > def withdraw(self, amount): > self.amount=amount > if(amount > self.balance): > return ("Amount greater than available balance.") > else: > self.balance -=

Re: i cant seem to figure out the error

2016-04-03 Thread Jason Friedman
> >- Create a method called `withdraw` that takes in cash withdrawal amount >and updates the balance accordingly. if amount is greater than balance >return `"invalid transaction"` > > def withdraw(self, amount): > self.amount=amount > if(amount > self.balance): > return

Re: [Off-topic] Requests author discusses MentalHealthError exception

2016-02-27 Thread Jason Friedman
Yes, thank you for sharing. Stories from people we know, or know of, leads to normalization: mental illness is a routine illness like Type I diabetes or appendicitis. On Sat, Feb 27, 2016 at 2:37 AM, Steven D'Aprano wrote: > The author of Requests, Kenneth Reitz, discusses

Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Jason Friedman
>> I have a hunch that you do not want to write the program, nor do you >> want to see exactly how a programmer would write it? >> >> The question is more like asking a heart surgeon how she performs >> heart surgery: you don't plan to do it yourself, but you want a >> general idea of how it is

Re: Python and multiple user access via super cool fancy website

2015-12-24 Thread Jason Friedman
> I am not sure if this is the correct venue for my question, but I'd like to > submit my question just in case. I am not a programmer but I do have an > incredible interest in it, so please excuse my lack of understanding if my > question isn't very thorough. > > As an example, a website backend

Re: Exclude text within quotation marks and words beginning with a capital letter

2015-12-04 Thread Jason Friedman
> > I am working on a program that is written in Python 2.7 to be compatible > with the POS tagger that I import from Pattern. The tagger identifies all > the nouns in a text. I need to exclude from the tagger any text that is > within quotation marks, and also any word that begins with an upper

Re: reading from a txt file

2015-11-26 Thread Jason Friedman
> > Hey, I'm wondering how to read individual strings in a text file. I can > read a text file by lines with .readlines() , > but I need to read specifically by strings, not including spaces. Thanks > in advance > How about: for a_string in open("/path/to/file").read().split():

Re: teacher need help!

2015-10-18 Thread Jason Friedman
> Can I suggest you find the turtle.py module in c:\windows\system32, move it > to somewhere more suitable and try the code again? Or, copy it, rather than move it? It may be that for some students turtle.py is in a terrific place already. -- https://mail.python.org/mailman/listinfo/python-list

Address field [was: Integers with leading zeroes]

2015-07-21 Thread Jason Friedman
Of course, most of the time, I advocate a single multi-line text field Address, and let people key them in free-form. No postcode field whatsoever. I'm curious about that statement. I could see accepting input as you describe above, but I'm thinking you'd want to *store* a postcode field. --

Re: bottle app crashes

2015-07-06 Thread Jason Friedman
Last summer I fumbled together a small appplication that calculates both LASK and Elo ratings for chess. I managed to webify it using Bottle. This works nicely on my laptop for testing. Once I log off (or my user session times out) my server where I've started the application with python3

decorators and alarms

2015-05-22 Thread Jason Friedman
I have the following code to run a shell command and kill it if it does not return within a certain amount of time: def run_with_time_limit(command, limit): Run the given command via a shell. Kill the command, and raise an exception, if the execution time exceeds limit seconds.

Re: decorators and alarms

2015-05-22 Thread Jason Friedman
But, I'd like to expand this to take some generic code, not just a shell command, and terminate it if it does not return quickly. @time_limiter def generic_function(arg1, arg2, time_limit=10): do_some_stuff() do_some_other_stuff() return val1, val2 If generic_function does

Re: How to deploy a custom common module?

2015-05-16 Thread Jason Friedman
When I deploy test.py on another computer, I put (rsync) both test.py and cmn_funcs.py in the same remote directory. If I create another python project (test2.py) in new directory, that needs common functions, what should I do with cmn_funcs.py? I put my shared code in a separate folder,

Re: Setuptools: no module named 'html.entities'

2015-03-16 Thread Jason Friedman
On Mon, Mar 16, 2015 at 7:10 AM, Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de wrote: On 03/16/2015 12:53 AM, Jason Friedman wrote: Hello, This is Python 3.3.2 on Linux. I downloaded Setuptools (https://pypi.python.org/packages/source/s/setuptools/ setuptools-14.3.tar.gz

Setuptools: no module named 'html.entities'

2015-03-15 Thread Jason Friedman
Hello, This is Python 3.3.2 on Linux. I downloaded Setuptools ( https://pypi.python.org/packages/source/s/setuptools/setuptools-14.3.tar.gz), exploded the tarball, and I get: python setup.py build Traceback (most recent call last): File frozen importlib._bootstrap, line 1521, in

Re: Append a file

2015-03-06 Thread Jason Friedman
On Fri, Mar 6, 2015 at 2:55 PM, Jason Venneri jv92...@gmail.com wrote: Hello, I'm using the urllib.urlretrieve command to retrieve a couple of lines of data. I want to combine the two results into one file not two. Any suggestions? Sample

Re: Sort list of dictionaries

2015-03-03 Thread Jason Friedman
On Tue, Mar 3, 2015 at 12:07 AM, Chris Angelico ros...@gmail.com wrote: Heh, I think that mght be a bit abusive :) I'm not sure that you want to depend on the version numbers fitting inside the rules for IP addresses, especially given that the example has a component of 2214.

Re: Sort list of dictionaries

2015-03-02 Thread Jason Friedman
This is what I was trying but LooseVersion() was not sorting version numbers like I thought it would. You will notice that Chrome version 40.0.2214.111 is higher than 40.0.2214.91 but in the end result it's not sorting it that way. Because it's a string they're sorted lexicographically,

Re: requesting you all to please guide me , which tutorials is best to learn redis database

2015-02-27 Thread Jason Friedman
i want to learn redis database and its use via python , please guide me which tutorials i should be study, so that i can learn it in good way How about https://pypi.python.org/pypi/redis/? -- https://mail.python.org/mailman/listinfo/python-list

Re: What behavior would you expect?

2015-02-22 Thread Jason Friedman
If you're going to call listdir, you probably want to use fnmatch directly. fnmatch seems to be silent on non-existent directories: python -c 'import fnmatch; fnmatch.fnmatch(/no/such/path, *)' -- https://mail.python.org/mailman/listinfo/python-list

Re: What behavior would you expect?

2015-02-19 Thread Jason Friedman
def order_matching_files(a_path, a_glob=*): Search a path for files whose names match a_glob and return a list of the full path to such files, in descending order of modification time. Ignore directories. previous_dir = os.getcwd() os.chdir(a_path) return_list =

Re: What behavior would you expect?

2015-02-19 Thread Jason Friedman
I have need to search a directory and return the name of the most recent file matching a given pattern. Given a directory with these files and timestamps, q.pattern1.abc Feb 13 r.pattern1.cdf Feb 12 s.pattern1.efg Feb 10 t.pattern2.abc Feb 13 u.pattern2.xyz Feb 14 v.pattern2.efg Feb

  1   2   3   >