Re: Timezone in HH:MM Format

2024-06-18 Thread Ivan "Rambius" Ivanov via Python-list
Thank you all for your responses! On Tue, Jun 18, 2024 at 9:54 PM Jon Ribbens via Python-list wrote: > > datetime.now(ZoneInfo("America/New_York")).isoformat() Both .isoformat() and "%:z" work. -- Tangra Mega Rock: http://www.radiotangra.com -- https://mail.python.org/mailman/listinfo/python

Timezone in HH:MM Format

2024-06-18 Thread Ivan "Rambius" Ivanov via Python-list
Hello, How can I convert a date, usually datetime.now(), into a format where the timezone is in hours:minutes format. I was able to get that format in shell: $ date +%Y-%m-%dT%H:%M:%S%:z 2024-06-18T19:24:09-04:00 The closest I got in python is from datetime import datetime from zoneinfo import

Re: A Single Instance of an Object?

2024-03-11 Thread Ivan "Rambius" Ivanov via Python-list
On Mon, Mar 11, 2024 at 5:06 PM dn via Python-list wrote: > > Good question Rambius! > > On 12/03/24 09:53, Ivan "Rambius" Ivanov via Python-list wrote: > > Hello, > > > > I am refactoring some code and I would like to get rid of a global > >

Re: A Single Instance of an Object?

2024-03-11 Thread Ivan "Rambius" Ivanov via Python-list
On Mon, Mar 11, 2024 at 5:01 PM Chris Angelico via Python-list wrote: > > On Tue, 12 Mar 2024 at 07:54, Ivan "Rambius" Ivanov via Python-list > wrote: > > I am refactoring some code and I would like to get rid of a global > > variable. Here is the outline: > &

A Single Instance of an Object?

2024-03-11 Thread Ivan "Rambius" Ivanov via Python-list
to now. I know about the Singleton pattern, but I have never implemented it in Python and I don't know if it is Pythonish. I am looking for the same behaviour as logging.getLogger(name). logging.getLogger("myname") will always return the same object no matter where it is called as

Re: Question about logging.config.dictConfig

2023-02-08 Thread Ivan "Rambius" Ivanov
On Tue, Feb 7, 2023 at 7:35 PM Peter J. Holzer wrote: > > On 2023-02-07 17:58:26 -0500, Ivan "Rambius" Ivanov wrote: > > I am trying to configure my loggers using dictConfig, but they do not > > print anything. Here are more details. > [...] > > from m

Question about logging.config.dictConfig

2023-02-07 Thread Ivan "Rambius" Ivanov
27;, 'formatter': 'default', } }, 'loggers': { '': { 'handlers': ['stdout'], 'level': 'DEBUG' } } } logging.config.dictConfig(config) When I run uselog.py it prints nothing. I am wondering what is wrong with the second configuration. I will appreciate any help. Regards rambius -- Tangra Mega Rock: http://www.radiotangra.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Custom help format for a choice argparse argument

2023-01-27 Thread Ivan "Rambius" Ivanov
Hello Cameron, On Fri, Jan 27, 2023 at 4:45 PM Cameron Simpson wrote: > > On 27Jan2023 15:31, Ivan "Rambius" Ivanov > wrote: > >I am developing a script that accepts a time zone as an option. The > >time zone can be any from pytz.all_timezones. I have &

Re: Custom help format for a choice argparse argument

2023-01-27 Thread Ivan "Rambius" Ivanov
> print(“Invalid timezone”,file=sys.stderr) > This is what I use now. I still wonder if I can mold HelpFormatter to do what I want it to do. > … > > > > > From: Python-list on > behalf of Ivan "Rambius" Ivanov > Date: Frida

Custom help format for a choice argparse argument

2023-01-27 Thread Ivan "Rambius" Ivanov
ArgumentParser(formatter_class=CustomHelpFormatter) parser.add_argument("-z", "--zone", choices=pytz.all_timezones) args = parser.parse_args() print(args) print(f"Specified timezone: {args.zone}") This works, but is there a more elegant way to achieve it? Regards rambi

Resolving Weekday Schedules to Dates

2022-07-21 Thread Ivan "Rambius" Ivanov
Hello, Do you know of a library that resolves schedules like every Wednesday at 3:00pm to absolute time, that is return the datetime of the next occurrence? Regards rambius P.S. -- Tangra Mega Rock: http://www.radiotangra.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Concatenating a Hash to a String

2020-12-01 Thread Ivan "Rambius" Ivanov
e, use parametrised queries, as ChrisA said. I am using sqlite3 and it supports parameterized queries. Overall they are better than constructing the sql statements manually. Regards and thanks rambius -- Tangra Mega Rock: http://www.radiotangra.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Concatenating a Hash to a String

2020-11-30 Thread Ivan "Rambius" Ivanov
On Tue, Dec 1, 2020 at 12:39 AM Chris Angelico wrote: > Don't do this! DO NOT do this! Even if it might happen to work with a > base 64 encoded value, this is a terrible terrible bug just waiting to > happen. Instead, use *parameterized queries* and keep your SQL safe. OK. What are parameterized

Concatenating a Hash to a String

2020-11-30 Thread Ivan "Rambius" Ivanov
+ ehash + "')" TypeError: can only concatenate str (not "bytes") to str Any help on how to concatenate ehash to the sql? Regards rambius -- Tangra Mega Rock: http://www.radiotangra.com -- https://mail.python.org/mailman/listinfo/python-list

Re: EnvironmentError

2020-11-20 Thread Ivan "Rambius" Ivanov
ehind some ssl proxy and it behaves as a man-in-the-middle and replaces the certificate with its own (I was experiencing that in a previous job). You have several choices: 1) pass --trusted-host files.pythonhosted.org to disable the certificate check 2) import the ssl certificate of the ssl prox

Re: answer not correct

2020-11-08 Thread Ivan "Rambius" Ivanov
total = 0 > * for x in numbers:* > * total += 1* Do you mean total += x? Regards rambius > * return total* > *print(add[1999, -672, 64]))* > > *the answer I get is 4 but it should be 1,411* > -- > https://mail.python.org/mailman/listinfo/python-l

Re: System Beep?

2019-03-08 Thread Ivan "Rambius" Ivanov
.Beep #(frequency, duration) > NameError: name 'windsound' is not defined > > Something missing in my code? > You have a typo. It is winsound, not winDsound. Regards rambius > > 98% of lawyers g

Re: what type of application implemented with python?

2017-04-15 Thread Ivan "Rambius" Ivanov
Hello, Python's own website contains a non-exhaustive list of applications implemeted in Python: https://www.python.org/about/apps/ Regards Rambius On Sat, Apr 15, 2017 at 4:13 PM, kondaiah sinha wrote: > what type of application implemented with python?...like by using jav

Re: Getting stdout and stderr from subprocess in correct order

2017-03-04 Thread Ivan "Rambius" Ivanov
Hello, Thank you all for your suggestions. I will see what will apply to my use case. Regards Rambius On Sat, Mar 4, 2017 at 5:37 PM, Piet van Oostrum wrote: > "Ivan \"Rambius\" Ivanov" writes: > >> Dear colleagues, >> >> I using subprocess module

Getting stdout and stderr from subprocess in correct order

2017-03-03 Thread Ivan "Rambius" Ivanov
n I run it through subprc.py, I do get standard out and standard errors streams, but they are separated and not in the order above: $ ./subprc.py b'a\nc\n' b'b\nd\n' How should I use subprocess in order to get the outputs in the correct order? Thank you for your help in

Re: Parametrized Unit Tests

2015-08-27 Thread rambius
Hello, петък, 21 август 2015 г., 21:43:19 UTC-4, Ben Finney написа: > > Is there a better a way to pass the server, the user and the password > > to the test without resolving to global variables? > > The ‘testscenarios’ library is one way to have a set of scenarios > applied at run-time to produ

Parametrized Unit Tests

2015-08-21 Thread rambius
better a way to pass the server, the user and the password to the test without resolving to global variables? Although I developed these tests as unit tests they are more of integration tests. Is there an integration testing framework that supports a more convenient passing of test param

Shipping python modules - best practices?

2012-10-27 Thread rambius
ignore possible test failures? 3) I generate some html documentation with pydoc. How shall I distribute it with the module? Thank you very much in advance. Regards rambius -- http://mail.python.org/mailman/listinfo/python-list

Re: What's wrong with my logging configuration

2010-11-27 Thread rambius
Hello, I found the culprit. Yesterday I added a file called copy.py. It clashed with the python built-in module copy and caused that nasty error. Regards Rambius -- http://mail.python.org/mailman/listinfo/python-list

Re: What's wrong with my logging configuration

2010-11-27 Thread rambius
Hello Ben, On what environment did you try it? On Nov 27, 5:09 pm, Ben Finney wrote: > rambius writes: > > When I run this program the logger statement after 'import optparse' > > does not appear. The first logger statement before optparse does > > appear.

Re: What's wrong with my logging configuration

2010-11-27 Thread rambius
tparse logger.fatal('test2') if __name__ == '__main__': main() When I run this program the logger statement after 'import optparse' does not appear. The first logger statement before optparse does appear. Has anyone experienced similar behaviour? Regards Rambius -- http://mail.python.org/mailman/listinfo/python-list

Re: What's wrong with my logging configuration

2010-11-27 Thread rambius
On Nov 27, 4:07 pm, rambius wrote: > Hello, > > I am using python logging and as of today it stopped working. Here is > my program: > I forgot to give my environment: $ uname -a Darwin arielmac.lan 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov 5 23:20:39 PDT 2010; root:

What's wrong with my logging configuration

2010-11-27 Thread rambius
TSET handlers=console,file Yesterday, it was working and I have not touched it - logging has been working for months. This morning it stopped working and I was debugging it for half a day and I am clueless. It does not the errors neither on the console nor in the log file. I will appreciate any help! Thank you in advance! Regards Rambius -- http://mail.python.org/mailman/listinfo/python-list