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 th

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 m

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 participat

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 class_wea

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 > > https://abdur-rahmaanj.githu

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 po

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 yo

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 run

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 = extract_headers(line)

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. -- https://mail.python.org/mailman/

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: https

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, R

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: https://

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 tra

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: 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

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 > popu

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 an

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 be

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 https://api.bo

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: > > WARNING:boxsdk.network.default_ne

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 = csv.DictRead

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 l

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: Suggest an open-source issue tracker, with github integration and kanban boards?

2013-11-15 Thread Jason Friedman
> Can you recommend an open source project (or two) written in Python; > which covers multi project + sub project issue tracking linked across > github repositories? > Why does it need to be written in Python? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python project

2013-11-30 Thread Jason Friedman
> To be perfectly honest, this is much too large a project for you. First > read some python tutorials and learn how to code in python. If you work it > every day, maybe you can kind of understand what its about in a very > superficial sense in a month. However, if you are having fun learning, t

Re: multiprocessing: child process share changes to global variable

2013-12-03 Thread Jason Friedman
> #--- temp.py - > #run at Python 2.7 command prompt > import time > import multiprocessing as mp > lst = [] > lstlst = [] > > def alist(x): > lst.append(x) > lstlst.append(lst) > print "a" > return lst > > if __name__=='__main__': > pool = mp

Re: Using Python inside Programming Without Coding Technology (PWCT) environment.

2013-12-13 Thread Jason Friedman
> > http://www.codeproject.com/Articles/693408/Using-Python-inside-Programming-Without-Coding-Tec > That page references a license file at http://www.codeproject.com/info/cpol10.aspx but _that_ page would display for me. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to check the date validity?

2013-12-23 Thread Jason Friedman
> In this file I have 3 different kind of fields: one consist of the > sole date, one - sole time and one - datetime. The time includes > milliseconds, i.e. "12:55:55.705" > All fields of the file including those 3 I am reading as the string. > All those strings after validating will go into mySQL

Re: Getting updates and restarting a long running url request.

2013-12-25 Thread Jason Friedman
> I am using the following code to submit the query/ > def get_BLAST(taxid, queryseq, args=None): > ''' > Input taxid to BLAST queryseq against > ''' > e_query = "txid" + taxid + " [ORGN]" > #, other_advanced='-G 4 -E 1' > blast_result = NCBIWWW.qblast("blastn", "nt", querys

Re: Getting updates and restarting a long running url request.

2013-12-26 Thread Jason Friedman
> Would this not keep requesting/submitting additional (duplicate) BLAST > queries? >> >> try: >> this_result = get_BLAST(id) >> result_dict[id] = True > I assumed that NCBIWWW.qblast waits for a response from the server. Are you saying that instead it queues a request, a

Re: lookup xpath (other?) to value in html

2013-12-31 Thread Jason Friedman
> I have a about 255 data fields that I am trying to verify on thousands of > webpages. > For example: > value: 255,000 > sqft: 1800 > > Since I have the correct answer for several pages I would like to lookup get > the location (xpath?) of the data/field value in the page so that I can > chec

Re: lookup xpath (other?) to value in html

2013-12-31 Thread Jason Friedman
> For example this URL; > http://jeffco.us/ats/displaygeneral.do?sch=001690 > The the land sqft is 11082. > Google Chrome gives me the xpath to that data as; > //*[@id="content"]/p[1]/table[4]/tbody/tr[2]/td[8] > > What I would like to do (using python) is given 11082 at what xpath can that > be fo

Flip a graph

2014-01-04 Thread Jason Friedman
I am teaching Python to a class of six-graders as part of an after-school enrichment. These are average students. We wrote a non-GUI "rocket lander" program: you have a rocket some distance above the ground, a limited amount of fuel and a limited burn rate, and the goal is to have the rocket tou

Re: Process datafeed in one MySql table and output to another MySql table

2014-01-16 Thread Jason Friedman
> > I have a datafeed which is constantly sent to a MySql table. The table > grows constantly as the data feeds in. I would like to write a python > script which process the data in this table and output the processed data > to another table in another MySql database in real-time. > > Which are the

Re: Unwanted Spaces and Iterative Loop

2014-01-26 Thread Jason Friedman
> > > outHandler.write("FarmID\tAddress\tStreetNum\tStreetName\tSufType\tDir\tCity\tProvince\tPostalCode") > > ... > FarmID Address > 1 1067 Niagara Stone Rd, Niagara-On-The-Lake, ON L0S 1J0 > 2 4260 Mountainview Rd, Lincoln, ON L0R 1B2 > 3 25 Hunter Rd, Grimsby, ON L3M 4A3 > 4

Re: Unwanted Spaces and Iterative Loop

2014-01-26 Thread Jason Friedman
> > I`m not reading and writing to the same file, I just changed the actual > paths to directory. > > This is for a school assignment, and we haven`t been taught any of the > stuff you`re talking about. Although I appreciate your help, everything > needs to stay as is and I just need to create the

Google API and Python 2

2014-02-09 Thread Jason Friedman
I started Python programming in the last few years and so I started with version 3 and 99% of my code is in version 3. Much of Google API Python code seems to be Python 2. I can convert the occasional file to version 3 with 2to3, but for an entire 3rd-party library, could it be as simple as using

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(): print(a_stri

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 ca

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: 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 do

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 his recent recovery fr

Re: Python Script to convert firewall rules

2014-12-11 Thread Jason Friedman
> I am network engineer and not expert in programming. I would like to make > one python script to convert juniper netscreen firewall configuration into > juniper SRX firewall configuration. > Looks pretty tricky, do you have a specification for each format containing all the possible keywords/val

Re: Python Script to convert firewall rules

2014-12-12 Thread Jason Friedman
> > > Thanks for the reply. Yes I can make the all possible keywords/values for > both formate. But after that what gonna be the logic to convert one format > to other format. Like to convert one line below are the keywords: > > set interface ethernet2/5 ip 10.17.10.1/24 (format 1) > set interfaces

Re: Python Script to convert firewall rules

2014-12-13 Thread Jason Friedman
> Thanks for the reply. I am learning python using CBT nuggets for python. But > If you can refer me some good course, that should be practical then it would > be great. > > For my requirement, if you can give me the best approach to start with or > high level steps or give me some sample cod, I

Re: Python Script to convert firewall rules

2014-12-14 Thread Jason Friedman
> Thank you very much. Appreciated ! But the first requirement was to convert > format1 to format2 as below: > > set interface ethernet2/5 ip 10.17.10.1/24 (format 1) > set interfaces ge-0/0/0 unit 0 family inet address 10.17.10.1/24 (format 2) > (set, interface, ip) = (set, interfaces, family inet

Logger not logging

2015-01-01 Thread Jason Friedman
What am I missing? I expect logger.info("hello") to emit. $ python Python 3.4.0 (default, Apr 18 2014, 19:16:28) [GCC 4.8.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import logging >>> logger = logging.getLogger() >>> logger.setLevel(logging.INFO) >>> lo

Re: Logger not logging

2015-01-01 Thread Jason Friedman
>> Python 3.4.0 (default, Apr 18 2014, 19:16:28) >> [GCC 4.8.1] on linux >> Type "help", "copyright", "credits" or "license" for more information. > import logging > logger = logging.getLogger() > logger.setLevel(logging.INFO) > logger.info("hello") > logger.warn("hello") >> hel

Re: surprise - byte in set

2015-01-03 Thread Jason Friedman
sys.version > '3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit > (Intel)]' 'b' in 'abc' > True b'b' in b'abc' > True 'b' in set('abc') > True b'b' in set(b'abc') > False > > I was surprised by the last result. What happened? > (Examples simplified; I w

Re: Begginer Question , what i need for web app and site

2015-01-09 Thread Jason Friedman
> Hello all > coming from java and c++ now going with python > what setup do i need to run full python stack for web application . > what i need is web framework and back-end . > what usually be in the java world tomcat and servlets or jsp and pure java > backend for processing data . > what will

Re: Array of hash table

2015-01-12 Thread Jason Friedman
>Can any one tell me how to create >graph={ > "nodes": [ > { > "id": "n0", > "label": "A node", > "x": 0, [ ... elided ... ] > } > ] > } Taking a guess and guessing that graphviz might be useful for you: https://code.google.com/p/pydot/. -- https://mail.pyth

Re: Track down SIGABRT

2015-01-12 Thread Jason Friedman
> I have a long-running python/CherryPy Web App server process that I am > running on Mac OS X 10.8.5. Python 2.7.2 running in 32-bit mode (for now, I > have the code in place to change over to 64 bit, but need to schedule the > downtime to do it). On the 6th of this month, during normal operation

Re: Hello World

2015-01-18 Thread Jason Friedman
> > > Password maximum age is the wrong solution to a few problems, and is > itself a problem. Don't do it. > > Bruce Schneier (mostly) agrees with you: https://www.schneier.com/blog/archives/2010/11/changing_passwo.html. -- https://mail.python.org/mailman/listinfo/python-list

Re: Storing dataset from Condtional FreqDist

2015-01-19 Thread Jason Friedman
> Hello i have trying to store information in arff file but i has been really. > Any ideas of how can i do that? > > > with open('fileids3.txt', 'r') as f: > > genres=[word.strip() for word in f.next().split(',')] > > with open('adjectifs2.txt', 'r') as g: > adj = [word.strip() for

Re: Create dictionary based of x items per key from two lists

2015-01-31 Thread Jason Friedman
> I have two lists > > l1 = ["a","b","c","d","e","f","g","h","i","j"] > l2 = ["aR","bR","cR"] > > l2 will always be smaller or equal to l1 > > numL1PerL2 = len(l1)/len(l2) > > I want to create a dictionary that has key from l1 and value from l2 based on > numL1PerL2 > > So > > { > a:aR, > b:aR, >

What behavior would you expect?

2015-02-18 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 10 calli

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

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) > retu

Re: What behavior would you expect?

2015-02-19 Thread Jason Friedman
I think I came in a little late, and saw "2. no files match the given > pattern," in which case I'm sticking to my story and returning an empty > list. > > The original problem was "to search a directory and return the name of > the most recent file matching a given pattern." I'd still prefer an >

Re: What behavior would you expect?

2015-02-19 Thread Jason Friedman
> > I'd still advise using my_list.sort() rather than sorted(), as you > don't need to retain the original. > > Hmm. Trying to figure out what that looks like. If I understand correctly, list.sort() returns None. What would I return to the caller? > If you're going to call listdir, you probably

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: How to extract contents of inner text of html tag?

2014-03-08 Thread Jason Friedman
> for line in all_kbd: >if line.string == None: I modified your code slightly: for line in all_kbd: print(line) sys.exit() if line.string == None: Running the new script yields: $ python shibly.py cp -v --remove-destination /usr/share/zoneinfo/ \ /etc/localtim

Re: writing reading from a csv or txt file

2014-03-30 Thread Jason Friedman
> > I am trying to compare the files. cutting out items in list list. ie:- > first file (rainfall2012.csv)rainfall, duration,time of day,wind > speed,date. > first file (rainfall2013.csv)rainfall, duration,time of day,wind > speed,date. > I would like to pick out maybe rainfalls and duration's and

Re: realtime plot

2014-04-01 Thread Jason Friedman
> > I want to plot serial data from Arduino by Chaco. Could you help me and > guide me about that. > I found this: http://www.blendedtechnologies.com/realtime-plot-of-arduino-serial-data-using-python/231 . -- https://mail.python.org/mailman/listinfo/python-list

Re: writing reading from a csv or txt file

2014-04-01 Thread Jason Friedman
> > Hi jason thanks for replying.Below is a typical file return.To you I've no > doubt this is a simple problem but,to a beginner like me it just seems I > lack the understanding of how to split out the items in a list.Thanks again > for looking at it. > Rainfall,duration,TimeStart,windspeed,Date >

Elegant compare

2013-08-10 Thread Jason Friedman
class my_class: def __init__(self, attr1, attr2): self.attr1 = attr1 #string self.attr2 = attr2 #string def __lt__(self, other): if self.attr1 < other.attr1: return True else: return self.attr2 < other.attr2 I will run into problems i

Re: Elegant compare

2013-08-11 Thread Jason Friedman
> This is a hard question to answer, because your code snippet isn't > clearly extensible to the case where you have ten attributes. What's the > rule for combining them? If instance A has five attributes less than > those of instance B, and five attributes greater than those of instance > B, which

Re: Could you verify this, Oh Great Unicode Experts of the Python-List?

2013-08-12 Thread Jason Friedman
>>> I've always wondered if the 160 character limit or whatever it is is a >>> hard limit in their system, or if it's just a variable they could tweak >>> if they felt like it. I thought it was 140 characters? https://twitter.com/about -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 450 Adding a statistics module to Python

2013-08-17 Thread Jason Friedman
> NumPy and SciPy are not available for many Python users, including those > using a Python implementation for which there is no Numpy support > http://new.scipy.org/faq.html#python-version-support> and those for > whom large, dependency-heavy third-party packages are too much burden. > > See the R

Re: Python and mysql 3 tier programming

2013-08-23 Thread Jason Friedman
> System Debian Wheezy Linux > Python 2.7 > Mysql 5.5.31 > Apache Server > > I am somewhat conversant with html, css, SQL, mysql, Apache and Debian > Linux. Actually I have been using Debian for over 10 year. I spent over 5 > year, prior to retirement, programming database based applications in > F

Weighted choices

2013-09-07 Thread Jason Friedman
choices = dict() choices["apple"] = 10 choices["pear"] = 20 choices["banana"] = 15 choices["orange"] = 25 choices["kiwi"] = 30 I want to pick sets of fruit, three in a set, where the chance of selecting a given fruit is proportional to its weight. In the example above, pears should appear twice a

Re: Weighted choices

2013-09-09 Thread Jason Friedman
>> I coach a flag football team of 11-year-olds. A stated goal of the >> league is that every player should get nearly equal playing time and >> that winning is of secondary importance. That said, some players just >> can't throw the ball at all, and having a quarterback who cannot throw >> is no

Inter-process locking

2013-10-11 Thread Jason Friedman
I have a 3rd-party process that runs for about a minute and supports only a single execution at a time. $ deploy If I want to launch a second process I have to wait until the first finishes. Having two users wanting to run at the same time might happen a few times a day. But, these users will n

Re: Inter-process locking

2013-10-12 Thread Jason Friedman
The lockfile solution seems to be working, thank you. On Fri, Oct 11, 2013 at 10:15 PM, Piet van Oostrum wrote: > Jason Friedman writes: > >> I have a 3rd-party process that runs for about a minute and supports >> only a single execution at a time. >> >> $ depl

Re: OT: looking for best solutions for tracking projects and skills

2013-10-13 Thread Jason Friedman
I highly recommend JIRA, free for non-profit use: https://www.atlassian.com/software/jira. On Fri, Oct 11, 2013 at 9:09 PM, Jason Hsu wrote: > I realize this is off-topic, but I'm not sure what forum is best for asking > about this. I figure that at least a few of you are involved in civic > h

Re: Inter-process locking

2013-10-18 Thread Jason Friedman
> There is one caveat, however. If a process that has the lock crashes without > releasing the lock, the lock file will stay around and prevent other > processes to acquire it. Then you will have to manually remove it. I > generally prefer a solution where the pid of the locking process is writt

Mail client wrapping

2013-10-29 Thread Jason Friedman
I am receiving lines like this: Accordingly, this element has largely given way in modern cases to a less = rigid formulation: that the evidence eliminates, to a sufficient degree, = other responsible causes (including the conduct of the plaintiff and third= parties). For example, in New York Sta

Re: Debugging decorator

2013-11-03 Thread Jason Friedman
> I wrote this decorator: https://gist.github.com/yasar11732/7163528 > > I ran it with Python 2 and thought it was neat. Most of my work is Python 3. I ran 2to3-3.3 against it and I am getting this error: $ ./simple.py Traceback (most recent call last): File "./simple.py", line 3, in @debug

Re: Parsing multiple lines from text file using regex

2013-11-03 Thread Jason Friedman
> Hi, > I am having an issue with something that would seem to have an easy > solution, but which escapes me. I have configuration files that I would > like to parse. The data I am having issue with is a multi-line attribute > that has the following structure: > > banner > Banner text > Banner

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: 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 lexicog

Re: Sort list of dictionaries

2015-03-03 Thread Jason Friedman
On Tue, Mar 3, 2015 at 12:07 AM, Chris Angelico 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". > Indeed, I was mi

Re: Append a file

2015-03-06 Thread Jason Friedman
On Fri, Mar 6, 2015 at 2:55 PM, Jason Venneri 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 > urllib.urlretrieve('http://www.airplanes.com/data/boeing1.htm

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 "", line 1521, in _find_and_load_unlocked AttributeError:

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/p

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 folde

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 seconds. Else

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_functio

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 pyt

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: 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

Ubuntu "3" (was Adding thread module support to Ubuntu 3 for Python3)

2014-06-23 Thread Jason Friedman
>> OT and FWIW: I gave up on Ubuntu when they switched to Unity -- I find that >> very awkward to use. Just personal opinion, of course, and I know there are >> others who like it -- that's fine with me as well. (But I switched to >> Mint.) > > Likewise, though with me it was Debian I went to, w

Re: subprocess can not kill when app exit()

2014-06-25 Thread Jason Friedman
> code in below, when close the app window. the two ping process can not kill > auto and keep in the windows 7 task list. > > During running, ping process under Python.exe as two thread. When app exit, > this two process move the system process and keep running there. > > could someone help to

Re: finditer

2014-07-07 Thread Jason Friedman
On Mon, Jul 7, 2014 at 1:19 AM, gintare wrote: > If smbd has time, maybe you could advice how to accomplish this task in > faster way. > > I have a text = """ word{vb} > wordtransl {vb} > > sent1. > > sent1trans. > > sent2 > > sent2trans... """ > > I need to match once wordtransl, and than many t

Re: Review Python site with useful code snippets

2011-10-29 Thread Jason Friedman
On Wed, Oct 26, 2011 at 3:51 PM, Chris Hall wrote: > I am looking to get reviews, comments, code snippet suggestions, and > feature requests for my site. > I intend to grow out this site with all kinds of real world code > examples to learn from and use in everyday coding. > The site is: > > http:

Re: merging argparse parsers

2011-12-23 Thread Jason Friedman
> I would like to have something like > > merged_parser = LoggingParser() + OtherParser() > > Which should create an argument parser with all the options composed. > I have used parent parsers. http://docs.python.org/py3k/library/argparse.html#parents I think in your case merged_parser would bec

Re: modifying a time.struct_time

2011-12-23 Thread Jason Friedman
On Fri, Dec 16, 2011 at 10:44 AM, Chris Angelico wrote: > On Fri, Dec 16, 2011 at 8:45 PM, Ulrich Eckhardt > wrote: >> I'm trying to create a struct_time that is e.g. one year ahead or a month >> back in order to test some parsing/formatting code with different dates. > > Do you need it to be one

Re: Regular expressions

2011-12-26 Thread Jason Friedman
> On Tue, Dec 27, 2011 at 10:45 AM, mauricel...@acm.org > wrote: >> Hi >> >> I am trying to change to . >> >> Can anyone help me with the regular expressions needed? > > A regular expression defines a string based on rules. Without seeing a > lot more strings, we can't know what possibilities the

Re: Regular expressions

2011-12-26 Thread Jason Friedman
> Thanks a lot everyone. > > Can anyone suggest a good place to learn REs? Start with the manual: http://docs.python.org/py3k/library/re.html#module-re -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   >