Re: Best practice for config files?

2025-05-24 Thread Jason H via Python-list
On 22/05/2025 20:59, Michael F. Stemper wrote: I recently wrote a program to do some record-keeping for me. I found myself hard-coding a bunch of different values into it. This didn't seem right, so I made my first use of configparser.ConfigParser(). Created the configuration file and everything

Re: Version of OpenSSl ?

2025-02-09 Thread Jason Friedman via Python-list
> > Trying to compile Python-3.12.9 on Ubuntu-24.04 > > The compilation is complete without errors but I have this message: > > > The necessary bits to build these optional modules were not foun

Re: [RELEASE] Python 3.13.1, 3.12.8, 3.11.11, 3.10.16 and 3.9.21 are now available

2024-12-03 Thread Jason Friedman via Python-list
🙏 On Tue, Dec 3, 2024 at 5:06 PM Thomas Wouters via Python-list < python-list@python.org> wrote: > Another big release day! Python 3.13.1 and 3.12.8 were regularly scheduled > releases, but they do contain a few security fixes. That makes it a nice > time to release the security-fix-only versions

Re: Two python issues

2024-11-05 Thread Jason Friedman via Python-list
> > (a) An error-prone "feature" is returning -1 if a substring is not found > by "find", since -1 currently refers to the last item. An example: > > >>> s = 'qwertyuiop' > >>> s[s.find('r')] > 'r' > >>> s[s.find('p')] > 'p' > >>> s[s.find('a')] > 'p' > >>> > > If "find" is unsuccessful, an er

Re: new here

2024-08-21 Thread Jason Friedman via Python-list
On Wed, Aug 21, 2024 at 4:04 PM Daniel via Python-list < python-list@python.org> wrote: > > An example of use, here's a weather service tied to a finger. Put your > city name as the user. This isn't mine, but it is inspiring. Example: > > finger mi...@graph.no > > For all options, go to the help f

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}/", me

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}/", methods=

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 like

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. Th

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 exec

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 se

Re: Match statement with literal strings

2023-06-07 Thread Jason Friedman via Python-list
3 at 6:01 PM Greg 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

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" MANDATORY

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 jdbc.c

Re: Help on ImportError('Error: Reinit is forbidden')

2023-05-18 Thread Jason Qian via Python-list
String(str_value, "utf-8", "Error ~"); const char **strErrValue* = PyBytes_AS_STRING(pyExcValueStr); //where *strErrValue* = "ImportError('Error: Reinit is forbidden')" ... } What we imported is a Python file which import some pyd libraries. Thanks Jason

Help on ImportError('Error: Reinit is forbidden')

2023-05-17 Thread Jason Qian via Python-list
Import_Import*(pName); Py_DECREF(pName); if (pModule == NULL) { if (*PyErr_Occurred*()) { handleError("PyImport_Import()"); } } } void handleError(const char* msg) { ... "PyImport_Import() - ImportError('Error: Reinit is forbidden')" }

Re: Help on ctypes.POINTER for Python array

2023-05-11 Thread Jason Qian via Python-list
Awesome, thanks! On Thu, May 11, 2023 at 1:47 PM Eryk Sun wrote: > On 5/11/23, Jason Qian via Python-list wrote: > > > > in the Python, I have a array of string > > var_array=["Opt1=DG","Opt1=DG2"] > > I need to call c library and pass var_arra

Help on ctypes.POINTER for Python array

2023-05-11 Thread Jason Qian via Python-list
_int, ctypes.POINTER()] In the c code: int func (void* obj, int index, char** opt) Thanks Jason -- https://mail.python.org/mailman/listinfo/python-list

Re: tksheet - Copy and Paste with headers

2023-04-16 Thread Jason Wang
在 2023/4/15 2:33, angela vales 写道: Hello All, I found this small group in a google search, so not sure if it is still active but giving it a try nonetheless. I have recently created a tkinter app and need the ability to copy and paste data from tksheet table into an Excel file. I do have a bu

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 _tkinter

Re: Getting the exit code of a subprocess

2021-12-15 Thread Jason
On Wed, Dec 15, 2021 at 08:19:16PM -0800, Kushal Kumaran wrote: > On Wed, Dec 15 2021 at 09:38:48 PM, Jason wrote: > > Hello, > > > > How can I find out the exit code of a process when using the > > subprocess module? I am passing an email message to a shell script and

Getting the exit code of a subprocess

2021-12-15 Thread Jason
tried something like this: e_stat = p.communicate(input=msg) but the value of e_stat is always '(None, None)' -- Thanks & best regards, Jason Rissler -- https://mail.python.org/mailman/listinfo/python-list

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 h

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. h

Standarize TOML?

2021-05-16 Thread Jason C. McDonald
eason not to adopt pyproject.toml...and the topic thus became weirdly political. I understand that Brett Cannon intends to bring this up at the next language summit, but, ah, might as well put the community two-cents in now, hey? I, for one, feel like this is obvious. -- Jason C. McDonald (CodeMo

Re: OT: Autism in discussion groups (was: Re: Proposal: Disconnect comp.lang.python from python-list)

2021-05-09 Thread Jason C. McDonald
e the aforementioned on further inspection. (But I don't know all cases either.) > I do agree asking people to simply not be stupid doesn't seem to work > these days for whatever reason. I hadn't noticed. ;) -- Jason C. McDonald (CodeMouse92) Author | Speaker | Hacker | Time Lord -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: Autism in discussion groups (was: Re: Proposal: Disconnect comp.lang.python from python-list)

2021-05-08 Thread Jason C. McDonald
SS > person is ever called for any possibly disrespecting words or > behavior. A fluffy cloud echo chamber where everybody just accepts > and respects you for what you are. Does the concept sound familiar? > > > P.S.: *NOT* among the core symptoms of (the high-functioning levels) > of ASS is the inability to learn. Mind that! (And that includes > social norms.) -- Jason C. McDonald (CodeMouse92) Author | Speaker | Hacker | Time Lord -- https://mail.python.org/mailman/listinfo/python-list

Re: Bloody rubbish

2021-05-08 Thread Jason C. McDonald
s open > source on github. > > Claim #2, "he invented smartphones": > > Yes, he did (as part of a team) create the first smartphone, > the Ericsson R380: > > https://en.wikipedia.org/wiki/Ericsson_R380 > > /Toaster -- Jason C. McDonald (CodeMouse92) Author | Speaker | Hacker | Time Lord -- https://mail.python.org/mailman/listinfo/python-list

Re: for the installation of pycharm

2021-05-08 Thread Jason C. McDonald
t; > > > >Sent from [1]Mail for Windows 10 > > > > References > >Visible links > 1. https://go.microsoft.com/fwlink/?LinkId=550986 -- Jason C. McDonald (CodeMouse92) Author | Speaker | Hacker | Time Lord -- https://mail.python.org/mailman/listinfo/python-list

Re: Bloody rubbish

2021-05-08 Thread Jason C. McDonald
on turns out to >> be something other than python? > > And it's bizarre that the OP, since he despises Python so much, and > finds its syntax absurd, would even bother to make any sort of > implementation of it. > -- Jason C. McDonald (CodeMouse92) Author | Speaker | Hacker | Time Lord -- https://mail.python.org/mailman/listinfo/python-list

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? > https://docs.python.org/3/lib

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 + f

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 l

Reading binary data with the CSV module

2020-11-29 Thread Jason Friedman
t_file: reader = csv.DictReader(text_file) for row in reader: print(row) Getting this error: Traceback (most recent call last): File "/home/jason/my_box.py", line 278, in with io.TextIOWrapper(source_file.content(), encoding='utf-8') as text_file: AttributeError: 'bytes'

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

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

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

Re: new feature in Python.

2020-09-30 Thread Jason C. McDonald
ators and abuse them thusly, that's a consenting adults situation. Introducing this new syntax into the language creates a trip hazard for the user. Third, that proposed operator, .=  oww that's hard to see. It looks like a typo, and could easily be typed as one, or overlooked altogether (ag

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: I was really uncomfort with any programming...

2020-06-06 Thread Jason C. McDonald
well, but that doesn't mean they'll necessarily enjoy it. I'm actually rather curious why you *need* to become "efficient" (proficient?) in Python? Work requirement? By the way, you should put your message the the BODY of the email, not in the subject line. Keep subject lin

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

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

fileinput module not yielding expected results

2019-09-07 Thread Jason Friedman
ne: {fileinput.isfirstline()}") I run this: $ python3 program.py ~/Section*.csv > ~/result I get this: $ grep "^Version" ~/result Version: sys.version_info(major=3, minor=7, micro=1, releaselevel='final', serial=0) $ grep "^Files" ~/result Files: ['/home

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

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

how to get string printed by PyErr_Print( )

2018-09-17 Thread Jason Qian via Python-list
Hey, Someone has discussed this issue before. Other than redirect stderr, does the new version python 3.7.0 has other way to retrieve the string whichPyErr_Print( ) ? if (PyErr_Occurred()) PyErr_Print(); //need to retrieve the error to string Thanks -- https://mail.python.org/mailman/listi

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: Help on PyList 3.7.0

2018-09-14 Thread Jason Qian via Python-list
Thanks a lot. On Thu, Sep 13, 2018 at 5:24 PM, MRAB wrote: > On 2018-09-13 21:50, Jason Qian via Python-list wrote: > >> Hey, >> >> Need some help on PyList. >> >> >> #get path >> PyObject *path = PyObject_GetAttrString(sys, &q

Help on PyList 3.7.0

2018-09-13 Thread Jason Qian via Python-list
Hey, Need some help on PyList. #get path PyObject *path = PyObject_GetAttrString(sys, "path"); #new user path PyObject* newPath = PyUnicode_DecodeUTF8(userPath, strlen( userPath ), errors); #append newPath to path PyList_Append(path, newPath); How to check if the newPath is already in the pa

Re: ModuleNotFoundError: No module named 'encodings'

2018-09-07 Thread Jason Qian via Python-list
, Thomas Jollans wrote: > On 09/06/2018 09:46 PM, Jason Qian via Python-list wrote: > >> Hi >> >> Need some help. >> >> I have a C++ application that invokes Python. >> >> ... >> Py_SetPythonHome("python_path"); >> > > This

ModuleNotFoundError: No module named 'encodings'

2018-09-06 Thread Jason Qian via Python-list
stem codec ModuleNotFoundError: No module named 'encodings' Thanks for the help Jason -- https://mail.python.org/mailman/listinfo/python-list

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 a

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 postgr

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 deleting this option > in Python

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 se

Re: How to link to python 3.6.4 library on linux ?

2018-02-19 Thread Jason Qian via Python-list
Thanks Chris, I think I figured it out that when build python on Linux, we need to enable-shared. Thanks again, On Mon, Feb 19, 2018 at 5:04 PM, Chris Angelico wrote: > On Tue, Feb 20, 2018 at 8:07 AM, Jason Qian via Python-list > wrote: > > Hi, > > > > I am

How to link to python 3.6.4 library on linux ?

2018-02-19 Thread Jason Qian via Python-list
Hi, I am calling python from a c application. It compiles and works fine on the windows. How do I compile and link it on the linux for Python 3.6.4 ? Under python dir, it only have a static library, /opt/Python-3.6.4*/lib*/*libpython3.6m.a* * If I link to it, I g

Re: Help on convert PyObject to string (c) Python 3.6

2018-02-19 Thread Jason Qian via Python-list
Thanks a lot and I will take a look Cython, On Mon, Feb 19, 2018 at 3:23 PM, Stefan Behnel wrote: > Jason Qian via Python-list schrieb am 04.02.2018 um 17:52: > >This is the case of calling python from c and the python function > will > > return a string. > > Hi J

Defer, ensure library is loaded

2018-02-13 Thread Jason
I have a variety of scripts that import some large libraries, and rather than create a million little scripts with specific imports, I'd like to so something like psycopg2 = ensure_imported (psycopg2) This way, regardless of invocation I can know psycopg2 is loaded, if it hasn't already been l

Help on PyImport_Import(pNAme)

2018-02-04 Thread Jason Qian via Python-list
Hi, This only works when loading modules from the current directory. Is there a way I can load from somewhere else ? Thanks for help, -- https://mail.python.org/mailman/listinfo/python-list

Re: Help on convert PyObject to string (c) Python 3.6

2018-02-04 Thread Jason Qian via Python-list
Hi Chris, Thanks a lot ! Using PyUnicode_DecodeUTF8 fix the problem. On Sun, Feb 4, 2018 at 12:02 PM, Chris Angelico wrote: > On Mon, Feb 5, 2018 at 3:52 AM, Jason Qian via Python-list > wrote: > > Hi, > > > >This is the case of calling python from c and th

Help on convert PyObject to string (c) Python 3.6

2018-02-04 Thread Jason Qian via Python-list
Hi, This is the case of calling python from c and the python function will return a string. It seems python been called correctly, but got error when convert the python string to c string. -- c -- PyObject* pValue = PyObject_CallObject(pFunc, pArgs); -- python -- import string, ran

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Jason Qian via Python-list
The message type is bytes, this may make different ? print(type(message)) On Sun, Jan 28, 2018 at 8:41 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Sun, 28 Jan 2018 20:31:39 -0500, Jason Qian via Python-list wrote: > > > Thanks a lot :) >

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Jason Qian via Python-list
Thanks Peter, replace print with os.write fixed the problem. On Sun, Jan 28, 2018 at 3:57 AM, Peter Otten <__pete...@web.de> wrote: > Jason Qian via Python-list wrote: > > > HI > > > >I have a string that contains \r\n\t > > > >[L

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Jason Qian via Python-list
Thanks a lot :) os.write(1, message) works ! On Sun, Jan 28, 2018 at 8:04 PM, Dan Stromberg wrote: > How about: > >>> os.write(1, message) > > On Sun, Jan 28, 2018 at 4:51 PM, Jason Qian via Python-list > wrote: > > print(repr(message)) out : >

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Jason Qian via Python-list
99 c %d %c 111 o %d %c 109 m On Sun, Jan 28, 2018 at 9:50 AM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Sat, 27 Jan 2018 21:23:02 -0500, Jason Qian via Python-list wrote: > > > there are 0D 0A 09 > > If your string actually contains CARRIAGE

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 recent

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-27 Thread Jason Qian via Python-list
there are 0D 0A 09 %c %d 116 *%c %d 13%c %d 10%c %d 9* %c %d 97 On Sat, Jan 27, 2018 at 9:05 PM, Dennis Lee Bieber wrote: > On Sat, 27 Jan 2018 20:33:58 -0500, Jason Qian via Python-list > declaimed the following: > > > Ljava.lang.Object; does not exis

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-27 Thread Jason Qian via Python-list
Reedy wrote: > On 1/27/2018 3:15 PM, Jason Qian via Python-list wrote: > >> HI >> >> I am a string that contains \r\n\t >> >> [Ljava.lang.Object; does not exist*\r\n\t*at >> com.livecluster.core.tasklet >> >> >> I would like it p

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-27 Thread Jason Qian via Python-list
st*\r\n\t*at com Thanks On Sat, Jan 27, 2018 at 4:20 PM, Ned Batchelder wrote: > On 1/27/18 3:15 PM, Jason Qian via Python-list wrote: > >> HI >> >> I am a string that contains \r\n\t >> >> [Ljava.lang.Object; does not exist*\r\n\t*at >>

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-27 Thread Jason Qian via Python-list
, 2018 at 3:15 PM, Jason Qian wrote: > HI > >I am a string that contains \r\n\t > >[Ljava.lang.Object; does not exist*\r\n\t*at > com.livecluster.core.tasklet > > >I would like it print as : > > [Ljava.lang.Object; does not exist > tat com.live

Please help on print string that contains 'tab' and 'newline'

2018-01-27 Thread Jason Qian via Python-list
HI I am a string that contains \r\n\t [Ljava.lang.Object; does not exist*\r\n\t*at com.livecluster.core.tasklet I would like it print as : [Ljava.lang.Object; does not exist tat com.livecluster.core.tasklet -- https://mail.python.org/mailman/listinfo/python-list

Re: Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

2018-01-24 Thread Jason Qian via Python-list
Figured it out, Thanks On Wed, Jan 24, 2018 at 4:25 PM, Jason Qian wrote: > Again, thanks for the help. Everything is working fine after the changes. > > Here is one more new issue needs some help. > > On c side, > >The createService function can pass a callb

Re: Python call c pass a callback function on Linux

2018-01-24 Thread Jason Qian via Python-list
HI Dennis, Thanks for the help, After changing WINFUNCTYPE to CFUNCTYPE, the call back function works on the Linux :) Thanks again, Jason On Wed, Jan 24, 2018 at 6:15 PM, Dennis Lee Bieber wrote: > On Wed, 24 Jan 2018 17:16:22 -0500, Jason Qian via Python-list > declaim

Python call c pass a callback function on Linux

2018-01-24 Thread Jason Qian via Python-list
ponse ---') print(message) print(code) class GSPythonDriver(object): def submif(self,methodname) invm_fn = InvocationCB(handleResponse) lib.submit(self.obj,methodname,invm_fn) How can I do this on the Linux ? Thanks for the help Jason -- https://mail.python.org/mailman/listinfo/python-list

Re: Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

2018-01-24 Thread Jason Qian via Python-list
har* serviceName) { //case 1 : //This works fine createService(methodname); //case 2 //This will not working, InvocationCallback serviceCallback; createService(methodname, &serviceCallback); } On Mon, Jan 22, 2018 at 5:58 PM, Jason Qian wrote: > Thank

Re: Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

2018-01-22 Thread Jason Qian via Python-list
Thanks for the help, Jason On Mon, Jan 22, 2018 at 5:41 PM, eryk sun wrote: > On Mon, Jan 22, 2018 at 9:00 PM, Jason Qian via Python-list > wrote: > > > > I am using ctypes on Windows to interface with a dll and it works fine > > on Linux and windows 32-bit python.

Re: Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

2018-01-22 Thread Jason Qian via Python-list
Thanks you very much, fixed the problem :) On Mon, Jan 22, 2018 at 4:28 PM, Random832 wrote: > On Mon, Jan 22, 2018, at 16:00, Jason Qian via Python-list wrote: > > Hello! > > > > I am using ctypes on Windows to interface with a dll and it works fine > > on Linu

  1   2   3   4   5   6   7   8   9   10   >