Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Albert-Jan Roskam via Python-list
On Mar 10, 2024 12:59, Thomas Passin via Python-list wrote: On 3/10/2024 6:17 AM, Barry wrote: > > >> On 8 Mar 2024, at 23:19, Thomas Passin via Python-list wrote: >> >> We just learned a few posts back that it might be specific to Linux; I ran it

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Albert-Jan Roskam via Python-list
On Mar 8, 2024 19:35, Thomas Passin via Python-list wrote: On 3/8/2024 1:03 PM, Albert-Jan Roskam via Python-list wrote: > Hi, > I was replacing some os.path stuff with Pathlib and I discovered this: > Path(256 * "x").i

pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Albert-Jan Roskam via Python-list
Hi, I was replacing some os.path stuff with Pathlib and I discovered this: Path(256 * "x").is_file() # OSError os.path.isfile(256 * "x") # bool Is this intended? Does pathlib try to resemble os.path as closely as possible? Best wishes, Albert-Jan --

Re: Postgresql equivalent of Python's timeit?

2023-09-17 Thread Albert-Jan Roskam via Python-list
On Sep 15, 2023 19:45, "Peter J. Holzer via Python-list" wrote: On 2023-09-15 17:42:06 +0200, Albert-Jan Roskam via Python-list wrote: >    This is more related to Postgresql than to Python, I hope this is ok. >    I want to measure Postgres queries N

Postgresql equivalent of Python's timeit?

2023-09-15 Thread Albert-Jan Roskam via Python-list
Hi, This is more related to Postgresql than to Python, I hope this is ok. I want to measure Postgres queries N times, much like Python timeit (https://docs.python.org/3/library/timeit.html). I know about EXPLAIN ANALYZE and psql \timing, but there's quite a bit of variation in the

Re: LRU cache

2023-02-18 Thread Albert-Jan Roskam
On Feb 18, 2023 17:28, Rob Cliffe via Python-list wrote: On 18/02/2023 15:29, Thomas Passin wrote: > On 2/18/2023 5:38 AM, Albert-Jan Roskam wrote: >>     I sometimes use this trick, which I learnt from a book by Martelli. >>     Instead of try/exc

Re: LRU cache

2023-02-18 Thread Albert-Jan Roskam
I sometimes use this trick, which I learnt from a book by Martelli. Instead of try/except, membership testing with "in" (__contains__) might be faster. Probably "depends". Matter of measuring. def somefunc(arg, _cache={}):     if len(_cache) > 10 ** 5:         _cache.pop()    

Re: Fast lookup of bulky "table"

2023-01-16 Thread Albert-Jan Roskam
On Jan 15, 2023 05:26, Dino wrote: Hello, I have built a PoC service in Python Flask for my work, and - now that the point is made - I need to make it a little more performant (to be honest, chances are that someone else will pick up from where I left off, and implement

Re: How to enter escape character in a positional string argument from the command line?

2022-12-21 Thread Albert-Jan Roskam
On Dec 21, 2022 06:01, Chris Angelico wrote: On Wed, 21 Dec 2022 at 15:28, Jach Feng wrote: > That's what I am taking this path under Windows now, the ultimate solution before Windows has shell similar to bash:-) Technically, Windows DOES have a shell similar to bash.

Re: Keeping a list of records with named fields that can be updated

2022-12-17 Thread Albert-Jan Roskam
On Dec 15, 2022 10:21, Peter Otten <__pete...@web.de> wrote: >>> from collections import namedtuple >>> Row = namedtuple("Row", "foo bar baz") >>> row = Row(1, 2, 3) >>> row._replace(bar=42) Row(foo=1, bar=42, baz=3) Ahh, I always thought these are

Re: Yaml.unsafe_load error

2022-10-19 Thread Albert-Jan Roskam
On Oct 19, 2022 13:02, Albert-Jan Roskam wrote:    Hi,    I am trying to create a celery.schedules.crontab object from an external    yaml file. I can successfully create an instance from a dummy class "Bar",    but the crontab class seems call __setsta

Yaml.unsafe_load error

2022-10-19 Thread Albert-Jan Roskam
Hi, I am trying to create a celery.schedules.crontab object from an external yaml file. I can successfully create an instance from a dummy class "Bar", but the crontab class seems call __setstate__ prior to __init__. I have no idea how to solve this. Any ideas? See code below.

Re: Find the path of a shell command

2022-10-14 Thread Albert-Jan Roskam
On Oct 14, 2022 18:19, "Peter J. Holzer" wrote: On 2022-10-14 07:40:14 -0700, Dan Stromberg wrote: > Alternatively, you can "ps axfwwe" (on Linux) to see environment > variables, and check what the environment of cron (or similar) is.  It > is this environment (mostly)

Book/resource recommendation about Celery?

2022-09-15 Thread Albert-Jan Roskam
Hi, I'm using Flask + Celery + RabbitMQ. Can anyone recommend a good book or other resource about Celery?  Thanks! Albert-Jan -- https://mail.python.org/mailman/listinfo/python-list

Re: Register multiple excepthooks?

2022-08-04 Thread Albert-Jan Roskam
On Aug 1, 2022 19:34, Dieter Maurer wrote: Albert-Jan Roskam wrote at 2022-7-31 11:39 +0200: >   I have a function init_logging.log_uncaught_errors() that I use for >   sys.excepthook. Now I also want to call another function (ffi.dlclose()) >   upon

Register multiple excepthooks?

2022-07-31 Thread Albert-Jan Roskam
Hi, I have a function init_logging.log_uncaught_errors() that I use for sys.excepthook. Now I also want to call another function (ffi.dlclose()) upon abnormal termination. Is it possible to register multiple excepthooks, like with atexit.register? Or should I rename/redefine

Re: Tuple unpacking inside lambda expressions

2022-04-20 Thread Albert-Jan Roskam
On Apr 20, 2022 13:01, Sam Ezeh wrote: I went back to the code recently and I remembered what the problem was. I was using multiprocessing.Pool.pmap which takes a callable (the lambda here) so I wasn't able to use comprehensions or starmap Is there anything for

Re: flask app convert sql query to python plotly.

2022-04-04 Thread Albert-Jan Roskam
On Apr 2, 2022 20:50, Abdellah ALAOUI ISMAILI wrote: i would like to convert in my flask app an SQL query to an plotly pie chart using pandas. this is my code : def query_tickets_status() :     query_result = pd.read_sql ("""     SELECT

Fwd: dict.get_deep()

2022-04-04 Thread Albert-Jan Roskam
-- Forwarded message -- From: Marco Sulla Date: Apr 2, 2022 22:44 Subject: dict.get_deep() To: Python List <> Cc: A proposal. Very often dict are used as a deeply nested carrier of data, usually decoded from JSON. 

Marshmallow: json-to-schema helper?

2022-04-04 Thread Albert-Jan Roskam
Hi, I'm looking for a convenience function to convert a Marshmallow schema into a valid Python class definition. That is, I want to generate python code (class MySchema.. etc) that I could write to a .py file. Does this exist? I tried the code below, but that is not the intended use

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-02-28 Thread Albert-Jan Roskam
On Feb 28, 2022 10:11, Loris Bennett wrote: Hi, I have an SQLAlchemy class for an event:   class UserEvent(Base):   __tablename__ = "user_events"   id = Column('id', Integer, primary_key=True)   date = Column('date', Date, nullable=False)  

Re: One-liner to merge lists?

2022-02-25 Thread Albert-Jan Roskam
If you don't like the idea of 'adding' strings you can 'concat'enate: >>> items = [[1,2,3], [4,5], [6]] >>> functools.reduce(operator.concat, items) [1, 2, 3, 4, 5, 6] >>> functools.reduce(operator.iconcat, items, []) [1, 2, 3, 4, 5, 6] The latter is the

Re: Long running process - how to speed up?

2022-02-19 Thread Albert-Jan Roskam
On Feb 19, 2022 12:28, Shaozhong SHI wrote: I have a cvs file of 932956 row and have to have time.sleep in a Python script.  It takes a long time to process. How can I speed up the processing?  Can I do multi-processing? Perhaps a dask df: 

Re: Error installing requirements

2022-02-19 Thread Albert-Jan Roskam
On Feb 18, 2022 08:23, Saruni David wrote: >> Christian Gohlke's site has a Pillow .whl for python 2.7: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow -- https://mail.python.org/mailman/listinfo/python-list

Re: Pypy with Cython

2022-02-03 Thread Albert-Jan Roskam
On Feb 3, 2022 17:01, Dan Stromberg wrote: > The best answer to "is this slower on > Pypy" is probably to measure. > Sometimes it makes sense to rewrite C > extension modules in pure python for pypy. Hi Dan, thanks. What profiler do you recommend I normally

Pypy with Cython

2022-02-03 Thread Albert-Jan Roskam
Hi, I inherited a fairly large codebase that I need to port to Python 3. Since the program was running quite slow I am also running the unittests against pypy3.8. It's a long running program that does lots of pairwise comparisons of string values in two files. Some parts of the

Re: Waht do you think about my repeated_timer class

2022-02-03 Thread Albert-Jan Roskam
On Feb 2, 2022 23:31, Barry wrote: > On 2 Feb 2022, at 21:12, Marco Sulla wrote: > > You could add a __del__ that calls stop :) Didn't python3 make this non deterministic when del is called? I thought the recommendation is to not rely on __del__ in python3

Re: Gunicorn - HTTP and HTTPS in the same instance?

2022-01-08 Thread Albert-Jan Roskam
I always use NGINX for this. Run Flask/Gunicorn on localhost:5000 and have NGINX rewrite https requests to localhost requests. In nginx.conf I automatically redirect every http request to https. Static files are served by NGINX, not by Gunicorn, which is faster. NGINX also allows you

Re: Call julia from Python: which package?

2021-12-21 Thread Albert-Jan Roskam
Hi all, Thank you very much for your valuable replies! I will definitely do some tracing to see where the bottlenecks really are. It's good to know that pypy is still alive and kicking, I thought it was stuck in py2.7. I will also write a mini program during the holiday to see how

Call julia from Python: which package?

2021-12-17 Thread Albert-Jan Roskam
Hi, I have a Python program that uses Tkinter for its GUI. It's rather slow so I hope to replace many or all of the non-GUI parts by Julia code. Has anybody experience with this? Any packages you can recommend? I found three alternatives: * https://pyjulia.readthedocs.io/en/latest/usage.html#

Re: How to apply a self defined function in Pandas

2021-10-31 Thread Albert-Jan Roskam
> df['URL'] = df.apply(lambda x: connect(df['URL']), axis=1) I think you need axis=0. Or use the Series, df['URL'] = df.URL.apply(connect) -- https://mail.python.org/mailman/listinfo/python-list

Ansible, pip and virtualenv

2021-10-31 Thread Albert-Jan Roskam
Hi I wrote an Ansible .yml to deploy a Flask webapp. I use python 3.6 for the ansible-playbook executable. The yml starts with some yum installs, amongst which python-pip. That installs an ancient pip version (v9). Then I create a virtualenv where I use a requirements.txt for pip

Re: Tracing in a Flask application

2021-08-09 Thread Albert-Jan Roskam
Hi, logging.basicConfig(level="DEBUG") ..in e.g __init__.py AJ On 4 Aug 2021 23:26, Javi D R wrote: Hi I would like to do some tracing in a flask. I have been able to trace request in plain python requests using sys.settrace(), but this doesnt work with

Re: argparse support of/by argparse

2021-07-23 Thread Albert-Jan Roskam
>>> [1] https://pypi.org/project/clize/ I use and like docopt (https://github.com/docopt/docopt). Is clize a better choice? -- https://mail.python.org/mailman/listinfo/python-list

Async code across Python versions

2021-06-03 Thread Albert-Jan Roskam
Hi, I just started using async functions and I was wondering if there are any best practices to deal with developments in this area for Python 3.6 and up. I'm currently using Python 3.6 but I hope I can upgrade to 3.8 soon. Do I have to worry that my code might break? If so, is it

Re: Async requests library with NTLM auth support?

2021-06-03 Thread Albert-Jan Roskam
> Asyncio and httpx [1] look promising but don't seem to support ntlm. Any tips? ==> https://pypi.org/project/httpx-ntlm/ Not sure how I missed this in the first place. :-) -- https://mail.python.org/mailman/listinfo/python-list

Async requests library with NTLM auth support?

2021-06-01 Thread Albert-Jan Roskam
Hi, I need to make thousands of requests that require ntlm authentication so I was hoping to do them asynchronously. With synchronous requests I use requests/requests_ntlm. Asyncio and httpx [1] look promising but don't seem to support ntlm. Any tips? Cheers! Albert-Jan [1]

Re: .title() - annoying mistake

2021-03-21 Thread Albert-Jan Roskam
On 20 Mar 2021 23:47, Cameron Simpson wrote: On 20Mar2021 12:53, Sibylle Koczian wrote: >Am 20.03.2021 um 09:34 schrieb Alan Bawden: >>The real reason Python strings support a .title() method is surely >>because Unicode supports upper, lower, _and_ title case letters, and

Re: Packaging/MANIFEST.in: Incude All, Exclude .gitignore

2021-03-13 Thread Albert-Jan Roskam
you could call a simple bash script in a git hook that syncs your MANIFEST.in with your .gitignore. Something like: echo -n "exclude " > MANIFEST.in cat .gitignore | tr '\n' ' ' >> MANIFEST.in echo "graft $(readlink -f ./keep/this)" >> MANIFEST.in

Re: Win32api problems

2019-10-22 Thread Albert-Jan Roskam
On 22 Oct 2019 11:23, GerritM wrote: > ImportError: DLL load failed: The specified > procedure could not be found. I've had the same error before and I solved it by adding the location where the win32 dlls live to PATH. Maybe PATH gets messed up during the installation of something. --

Re: python2 vs python3

2019-10-21 Thread Albert-Jan Roskam
On 18 Oct 2019 20:36, Chris Angelico wrote: On Sat, Oct 19, 2019 at 5:29 AM Jagga Soorma wrote: > > Hello, > > I am writing my second python script and got it to work using > python2.x. However, realized that I should be using python3 and it > seems to fail with the following message: > >

Re: sqlalchemy & #temp tables

2019-10-11 Thread Albert-Jan Roskam
On 8 Oct 2019 07:49, Frank Millman wrote: On 2019-10-07 5:30 PM, Albert-Jan Roskam wrote: > Hi, > > I am using sqlalchemy (SA) to access a MS SQL Server database (python 3.5, > Win 10). I would like to use a temporary table (preferably #local, but > ##global would al

sqlalchemy & #temp tables

2019-10-07 Thread Albert-Jan Roskam
Hi, I am using sqlalchemy (SA) to access a MS SQL Server database (python 3.5, Win 10). I would like to use a temporary table (preferably #local, but ##global would also be an option) to store results of a time-consuming query. In other queries I'd like to access the temporary table again in

Re: Funny code

2019-09-26 Thread Albert-Jan Roskam
On 26 Sep 2019 10:28, Christian Gollwitzer wrote: Am 26.09.19 um 08:34 schrieb ast: > Hello > > A line of code which produce itself when executed > > >>> s='s=%r;print(s%%s)';print(s%s) > s='s=%r;print(s%%s)';print(s%s) > > Thats funny ! ==> Also impressive, a 128-language quine:

Re: [Tutor] Most efficient way to replace ", " with "." in a array and/or dataframe

2019-09-22 Thread Albert-Jan Roskam
On 22 Sep 2019 04:27, Cameron Simpson wrote: On 21Sep2019 20:42, Markos wrote: >I have a table.csv file with the following structure: > >, Polyarene conc ,, mg L-1 ,,, >Spectrum, Py, Ace, Anth, >1, "0,456", "0,120", "0,168" >2, "0,456", "0,040", "0,280" >3, "0,152", "0,200", "0,280" > >I

Re: Document Entire Apps

2019-09-21 Thread Albert-Jan Roskam
On 15 Sep 2019 07:00, Sinardy Gmail wrote: I understand that we can use pydoc to document procedures how about the relationship between packages and dependencies ? ==》 Check out snakefood to generate dependency graphs: http://furius.ca/snakefood/. Also, did you discover sphinx already?

Re: Creating time stamps

2019-07-22 Thread Albert-Jan Roskam
On 22 Jul 2019 23:12, Skip Montanaro wrote: Assuming you're using Python 3, why not use an f-string? >>> dt = datetime.datetime.now() >>> dt.strftime("%Y-%m-%d %H:%M") '2019-07-22 16:10' >>> f"{dt:%Y-%m-%d %H:%M}" '2019-07-22 16:10' ===》》 Or if you're running < Python 3.6 (no f strings):

Re: Most "pythonic" syntax to use for an API client library

2019-04-29 Thread Albert-Jan Roskam
On 29 Apr 2019 07:18, DL Neil wrote: On 29/04/19 4:52 PM, Chris Angelico wrote: > On Mon, Apr 29, 2019 at 2:43 PM DL Neil > wrote: >> >> On 29/04/19 3:55 PM, Chris Angelico wrote: >>> On Mon, Apr 29, 2019 at 1:43 PM DL Neil >>> wrote: Well, seeing you ask: a more HTTP-ish approach

Re: What Python related git pre-commit hooks are you using?

2018-11-18 Thread Albert-Jan Roskam
On 18 Nov 2018 20:33, Malcolm Greene wrote: >Curious to learn what Python related git >pre-commit hooks people are using? >What >hooks have you found useful and which >hooks have you tried I use Python to reject large commits (pre-commit hook):

[OT] master/slave debate in Python

2018-09-23 Thread Albert-Jan Roskam
*sigh*. I'm with Hettinger on this. https://www.theregister.co.uk/2018/09/11/python_purges_master_and_slave_in_political_pogrom/ -- https://mail.python.org/mailman/listinfo/python-list

Re: python 3.7 - I try to close the thread without closing the GUI is it possible?

2018-09-15 Thread Albert-Jan Roskam
> I try to close the thread without closing the GUI is it possible? Qthread seems to be worth investigating: https://medium.com/@webmamoffice/getting-started-gui-s-with-python-pyqt-qthread-class-1b796203c18c -- https://mail.python.org/mailman/listinfo/python-list

Re: user defined modules

2018-06-09 Thread Albert-Jan Roskam
On 5 Jun 2018 09:32, Steven D'Aprano wrote: On Mon, 04 Jun 2018 20:13:32 -0700, Sharan Basappa wrote: > Is there a specific location where user defined modules need to be kept? > If not, do we need to specify search location so that Python interpreter > can find it? Python modules used as

Re: Extract data from multiple text files

2018-05-15 Thread Albert-Jan Roskam
On May 15, 2018 14:12, mahesh d wrote: import glob,os import errno path = 'C:/Users/A-7993\Desktop/task11/sample emails/' files = glob.glob(path) '''for name in files: print(str(name)) if name.endswith(".txt"): print(name)''' for file in

Re: Extract data

2018-05-15 Thread Albert-Jan Roskam
On May 15, 2018 08:54, Steven D'Aprano wrote: On Tue, 15 May 2018 11:53:47 +0530, mahesh d wrote: > Hii. > > I have folder.in that folder some files .txt and some files .msg files. > . > My requirement is reading those file contents . Extract data in

Re: The basics of the logging module mystify me

2018-04-20 Thread Albert-Jan Roskam
On Apr 19, 2018 03:03, Skip Montanaro wrote: > > > I really don't like the logging module, but it looks like I'm stuck > with it. Why aren't simple/obvious things either simple or obvious? Agreed. One thing that, in my opinion, ought to be added to the docs is sample

Re: RE newbie question

2018-04-18 Thread Albert-Jan Roskam
On Apr 18, 2018 21:42, TUA wrote: > > import re > > compval = 'A123456_8' > regex = '[a-zA-Z]\w{0,7}' > > if re.match(regex, compval): >print('Yes') > else: >print('No') > > > My intention is to implement a max. length of 8 for an input string. The > above works

Flask test generator code review?

2018-04-18 Thread Albert-Jan Roskam
Hi, I am writing my first unittests for a Flask app. First modest goal is to test whether a selected subset of the templates return the expected status 200. I am using a nose test generator in a class for this. Is the code below the correct way to do this? And is there a way to dynamically set

Re: How to write partial of a buffer which was returned from a C function to a file?

2018-04-12 Thread Albert-Jan Roskam
On Apr 12, 2018 09:39, jf...@ms4.hinet.net wrote: > > Chris Angelico於 2018年4月12日星期四 UTC+8下午1時31分35秒寫道: > > On Thu, Apr 12, 2018 at 2:16 PM, wrote: > > > This C function returns a buffer which I declared it as a > > > ctypes.c_char_p. The buffer has size 0x1 bytes long

Re: Pandas, create new column if previous column(s) are not in [None, '', np.nan]

2018-04-11 Thread Albert-Jan Roskam
On Apr 11, 2018 20:52, zljubi...@gmail.com wrote: > > I have a dataframe: > > import pandas as pd > import numpy as np > > df = pd.DataFrame( { 'A' : ['a', 'b', '', None, np.nan], > 'B' : [None, np.nan, 'a', 'b', '']}) > > A B > 0 a None > 1 b NaN > 2

Re: Numpy and Terabyte data

2018-01-03 Thread Albert-Jan Roskam
On Jan 2, 2018 18:27, Rustom Mody wrote: > > Someone who works in hadoop asked me: > > If our data is in terabytes can we do statistical (ie numpy pandas etc) > analysis on it? > > I said: No (I dont think so at least!) ie I expect numpy (pandas etc) > to not work if the

Book recommendation for Spark/Pyspark?

2017-11-13 Thread Albert-Jan Roskam
Hi, Can anybody recommend a good, preferably recent, book about Spark and Pyspark? I am using Pyspark now, but I am looking for a book that also gives a thorough background about Spark itself. I've been looking around on e.g. Amazon but, as the saying goes, one can't judge a book by its

Re: Compare files excel

2017-07-22 Thread Albert-Jan Roskam
(sorry for top posting) Try: df1['difference'] = (df1 == df2).all(axis=1) From: Python-list on behalf of Smith Sent: Saturday, July 22, 2017 7:47:59 AM To: python-list@python.org Subject:

Re: Test 0 and false since false is 0

2017-07-11 Thread Albert-Jan Roskam
From: Python-list on behalf of Dan Sommers Sent: Friday, July 7, 2017 2:46 AM To: python-list@python.org Subject: Re: Test 0 and false since false is 0   On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote:

Re: memory leak with re.match

2017-07-05 Thread Albert-Jan Roskam
From: Python-list on behalf of Mayling ge Sent: Tuesday, July 4, 2017 9:01 AM To: python-list Subject: memory leak with re.match      Hi,    My function is in the following way to handle file line by line. There

Re: Combining 2 data series into one

2017-07-01 Thread Albert-Jan Roskam
ces+sjeik_appie=hotmail@python.org> on behalf of Bhaskar Dhariyal <dhariyalbhas...@gmail.com> Sent: Thursday, June 29, 2017 4:34:56 AM To: python-list@python.org Subject: Re: Combining 2 data series into one On Wednesday, 28 June 2017 23:43:57 UTC+5:30, Albert-Jan Roskam wrote: > (sorry

Re: Combining 2 data series into one

2017-06-28 Thread Albert-Jan Roskam
(sorry for top posting) Yes, I'd try pd.concat([df1, df2]). Or this: df['both_names'] = df.apply(lambda row: row.name + ' ' + row.surname, axis=1) From: Python-list on behalf of Paul Barry

Fw: Unable to convert pandas object to string

2017-06-24 Thread Albert-Jan Roskam
From: Albert-Jan Roskam <sjeik_ap...@hotmail.com> Sent: Saturday, June 24, 2017 11:26:26 AM To: Paul Barry Subject: Re: Unable to convert pandas object to string (sorry for top posting) Try using fillna('') to convert np.nan into empty strings. df

Re: How to get Buttons to work

2017-04-22 Thread Albert-Jan Roskam
(sorry for top-posting). UpdateRecords and the other functions need to be nested so they fall under your class. Right now they are functions, not methods. AJ From: Python-list on behalf of

Re: OrderedDict with kwds

2017-04-22 Thread Albert-Jan Roskam
From: eryk sun <eryk...@gmail.com> Sent: Saturday, April 22, 2017 7:59 AM To: Python Main Cc: Albert-Jan Roskam Subject: Re: OrderedDict with kwds   On Fri, Apr 21, 2017 at 6:08 PM, Albert-Jan Roskam <sjeik_ap...@hotmail.com> wrote: > Would the insertion order be preserved if the

OrderedDict with kwds

2017-04-22 Thread Albert-Jan Roskam
For regular dicts I like to use the dict() function because the code is easier to write and read. But OrderedDict() is not equivalent to dict(): In the docstring of collections.OrderedDict it says "keyword arguments are not recommended because their insertion order is arbitrary"

Re: How coding in Python is bad for you

2017-01-23 Thread Albert-Jan Roskam
sola dosis facit venenum ~ Paracelsus (1493-1541) From: Python-list on behalf of alister Sent: Monday, January 23, 2017 8:32:49 PM To: python-list@python.org Subject: Re: How

Re: Adding colormaps?

2017-01-23 Thread Albert-Jan Roskam
(sorry for top-posting) I does not appear to be possible in matplolibrc (1). But you can use matplotlib.cm.register_cmap to register new cmaps (2) such as these (3). (Note: I did not try this) (1)http://matplotlib.org/1.4.0/users/customizing.html (2)http://matplotlib.org/api/cm_api.html

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-04 Thread Albert-Jan Roskam
(Sorry for top-posting) Yep, part of the baby's hardware. Also, the interface is not limited to visual and auditory information: http://www.scientificamerican.com/article/pheromones-sex-lives/ From: Python-list

RE: re.search - Pattern matching review ( Apologies re sending)

2016-05-28 Thread Albert-Jan Roskam
> Date: Sat, 28 May 2016 23:48:16 +0530 > Subject: re.search - Pattern matching review ( Apologies re sending) > From: ganesh1...@gmail.com > To: python-list@python.org > > Dear Python friends, > > I am on Python 2.7 and Linux . I am trying to extract the address > "1,5,147456:8192" from the

RE: Remove directory tree without following symlinks

2016-04-24 Thread Albert-Jan Roskam
> From: eryk...@gmail.com > Date: Sat, 23 Apr 2016 15:22:35 -0500 > Subject: Re: Remove directory tree without following symlinks > To: python-list@python.org > > On Sat, Apr 23, 2016 at 4:34 AM, Albert-Jan Roskam > wrote: >> >>> From: eryk...@gmail.com >&

RE: Remove directory tree without following symlinks

2016-04-23 Thread Albert-Jan Roskam
> From: eryk...@gmail.com > Date: Fri, 22 Apr 2016 13:28:01 -0500 > Subject: Re: Remove directory tree without following symlinks > To: python-list@python.org > > On Fri, Apr 22, 2016 at 12:39 PM, Albert-Jan Roskam > <sjeik_ap...@hotmail.com> wrote: >

RE: Remove directory tree without following symlinks

2016-04-22 Thread Albert-Jan Roskam
> From: st...@pearwood.info > Subject: Re: Remove directory tree without following symlinks > Date: Sat, 23 Apr 2016 03:14:12 +1000 > To: python-list@python.org > > On Sat, 23 Apr 2016 01:09 am, Random832 wrote: > > > On Fri, Apr 22, 2016, at 10:56, Steven D'Aprano wrote: > >> What should I

RE: read datas from sensors and plotting

2016-04-17 Thread Albert-Jan Roskam
> From: ran...@nospam.it > Subject: read datas from sensors and plotting > Date: Sun, 17 Apr 2016 18:46:25 +0200 > To: python-list@python.org > > I'm reading in python some values from some sensors and I write them in > a csv file. > My problem now is to use this datas to plot a realtime graph

RE: extract rar

2016-04-01 Thread Albert-Jan Roskam
> Date: Fri, 1 Apr 2016 13:22:12 -0600 > Subject: extract rar > From: fanjianl...@gmail.com > To: python-list@python.org > > Hello everyone, > > I am wondering is there any way to extract rar files by python without > WinRAR software? > > I tried Archive() and patool, but seems they required

RE: A tool to add diagrams to sphinx docs

2016-04-01 Thread Albert-Jan Roskam
> Subject: Re: A tool to add diagrams to sphinx docs > From: irmen.nos...@xs4all.nl > Date: Fri, 1 Apr 2016 18:26:48 +0200 > To: python-list@python.org > > On 1-4-2016 17:59, George Trojan - NOAA Federal wrote: > > What graphics editor would you recommend to create diagrams that can be > >

RE: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python

2016-03-25 Thread Albert-Jan Roskam
> To: python-list@python.org > From: __pete...@web.de > Subject: Effects of caching frequently used objects, was Re: Explaining > names vs variables in Python > Date: Wed, 2 Mar 2016 10:12:48 +0100 > > Salvatore DI DIO wrote: > > > Hello, > > > > I know Python does not have variables, but

RE: looping and searching in numpy array

2016-03-13 Thread Albert-Jan Roskam
> From: sjeik_ap...@hotmail.com > To: heml...@gmail.com; python-list@python.org > Subject: RE: looping and searching in numpy array > Date: Sun, 13 Mar 2016 13:51:23 + > > Hi, I suppose you have seen this already (in particular the first link): >

RE: looping and searching in numpy array

2016-03-13 Thread Albert-Jan Roskam
> Date: Thu, 10 Mar 2016 08:48:48 -0800 > Subject: Re: looping and searching in numpy array > From: heml...@gmail.com > To: python-list@python.org > > On Thursday, March 10, 2016 at 2:02:57 PM UTC+1, Peter Otten wrote: > > Heli wrote: > > > > > Dear all, > > > > > > I need to loop over a

RE: reversed(zip(...)) not working as intended

2016-03-06 Thread Albert-Jan Roskam
(Sorry for top-posting) No TypeError here: Python 2.7.2 (default, Nov 2 2015, 01:07:37) [GCC 4.9 20140827 (prerelease)] on linux4 Type "help", "copyright", "credits" or "license" for more information. >>> ten = range(10) >>> reversed(zip(ten, ten)) >>> list(reversed(zip(ten, ten))) [(9, 9),

RE: SQLite

2016-02-21 Thread Albert-Jan Roskam
(Sorry for top posting) IIRC, you have to do sudo apt-get install build-essential python-dev ... then re-compile python > To: python-list@python.org > From: k.d.jant...@mailbox.org > Subject: SQLite > Date: Sun, 21 Feb 2016 18:11:18 +0100 > >Hello, > >I have downloaded Python3.5.1 as

RE: libre office

2016-01-20 Thread Albert-Jan Roskam
> From: ji...@frontier.com > To: python-list@python.org > Subject: libre office > Date: Tue, 19 Jan 2016 17:01:40 -0600 > > How do I get data from libre office using python? Does this help?http://www.openoffice.org/udk/python/python-bridge.html --

RE: Screenshots in Sphinx docs

2015-12-15 Thread Albert-Jan Roskam
> To: python-list@python.org > From: tjre...@udel.edu > Subject: Re: Screenshots in Sphinx docs > Date: Mon, 14 Dec 2015 14:01:03 -0500 > > On 12/14/2015 11:31 AM, Albert-Jan Roskam wrote: > > > I'd like to include up-to-date screenshots (of a tkinter app) >

Screenshots in Sphinx docs

2015-12-14 Thread Albert-Jan Roskam
Hello, I'd like to include up-to-date screenshots (of a tkinter app) into my Sphinx documentation. This looks ok: https://pypi.python.org/pypi/sphinxcontrib-programscreenshot BUT I need something that works on Windows (Python 2.7). Can any recommend an approach? I thought about using PIL:

RE: Unicode failure

2015-12-04 Thread Albert-Jan Roskam
I think you need to use a raw unicode string, ur >>> unicodedata.name(ur'\u2122') 'TRADE MARK SIGN' > Date: Fri, 4 Dec 2015 13:07:38 -0500 > From: da...@vybenetworks.com > To: python-list@python.org > Subject: Unicode failure > > I thought that going to Python 3.4 would solve my Unicode issues

RE: counting unique numpy subarrays

2015-12-04 Thread Albert-Jan Roskam
Hi (Sorry for topposting) numpy.ravel is faster than numpy.flatten (no copy) numpy.empty is faster than numpy.zeros numpy.fromiter might be useful to avoid the loop (just a hunch) Albert-Jan > From: duncan@invalid.invalid > Subject: counting unique numpy subarrays > Date: Fri, 4 Dec 2015

RE: I'm using Sphinx, but is there a UML auto generator

2015-10-02 Thread Albert-Jan Roskam
(Sorry for top-posting, mobile hotmail sie sucks). This is cool, although it's not a Sphinx directive. You use insert the resulting graph in the .rst of course: http://furius.ca/snakefood/ Date: Fri, 2 Oct 2015 11:14:59 -0300 Subject: I'm using Sphinx, but is there a UML auto generator From:

RE: Python CI and CD support available on Semaphore (feedback appreciated)

2015-09-08 Thread Albert-Jan Roskam
> To: python-list@python.org > From: tjre...@udel.edu > Subject: Re: Python CI and CD support available on Semaphore (feedback > appreciated) > Date: Tue, 8 Sep 2015 14:46:28 -0400 > > On 9/8/2015 6:27 AM, Filip Komnenović wrote: > > > We have recently launched Python support on our continuous

RE: -2146826246 in win32com.client for empty #N/A cell in Excel

2015-08-16 Thread Albert-Jan Roskam
Date: Sun, 16 Aug 2015 09:53:32 -0700 Subject: -2146826246 in win32com.client for empty #N/A cell in Excel From: sven.bo...@gmail.com To: python-list@python.org Anyone know how to handle #N/A in Excel from win32com.client. I'm extracting data from an Excel file using win32com.client.

Re: windows and file names 256 bytes

2015-06-26 Thread Albert-Jan Roskam
On Thu, 25 Jun 2015 14:37:55 +0100, Tim Golden wrote: On 25/06/2015 14:35, Michael Torrie wrote: On 06/25/2015 06:34 AM, Tim Golden wrote: On 25/06/2015 13:04, Joonas Liik wrote: It sounds to me more like it is possible to use long file names on windows but it is a pain and in python, on

Re: windows and file names 256 bytes

2015-06-26 Thread Albert-Jan Roskam
snip import os import shutil import sys # create an insanely long directory tree p = os.getenv(TEMP) #p = ur\\server\share\blah\temp tmpdir = p os.chdir(tmpdir) for i in xrange(1000): tmpdir = os.path.join(tmpdir, sub) os.mkdir(?\\ + tmpdir) #os.mkdir(u?\\UNC +

windows and file names 256 bytes

2015-06-25 Thread Albert-Jan Roskam
Hi, Consider the following calls, where very_long_path is more than 256 bytes: [1] os.mkdir(very_long_path) [2] os.getsize(very_long_path) [3] shutil.rmtree(very_long_path) I am using Python 2.7 and [1] and [2] fail under Windows XP [3] fails under Win7 (not sure about XP). It throws:

windows and file names 256 bytes

2015-06-24 Thread Albert-Jan Roskam via Python-list
Hi, Consider the following calls, where very_long_path is more than 256 bytes: [1] os.mkdir(very_long_path) [2] os.getsize(very_long_path) [3] shutil.rmtree(very_long_path) I am using Python 2.7 and [1] and [2] fail under Windows XP [3] fails under Win7 (not sure about XP). This is even when I

Re: How to check in script if Python or Jython is used

2015-06-21 Thread Albert-Jan Roskam via Python-list
Sun, Jun 21, 2015 12:24 PM CEST Cecil Westerhof wrote: On Sunday 21 Jun 2015 11:22 CEST, Laura Creighton wrote: In a message of Sun, 21 Jun 2015 10:12:06 +0200, Cecil Westerhof writes: I installed Jython and will start playing with it. There probably will be

Re: Find in ipython3

2015-06-06 Thread Albert-Jan Roskam via Python-list
quot;To run any command at the system shell, simply prefix it with !quot; See: https://ipython.org/ipython-doc/dev/interactive/tutorial.html-- https://mail.python.org/mailman/listinfo/python-list

Re: What is considered an advanced topic in Python?

2015-05-30 Thread Albert-Jan Roskam via Python-list
Metaclasses, abc, asyncio, ast, some of the dunder methods, eg __del__, weakref, perhaps gc-- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   >