Re: FileNotFoundError thrown due to file name in file, rather than file itself

2024-11-13 Thread Kushal Kumaran via Python-list
On Wed, Nov 13 2024 at 07:36:04 PM, dieter.mau...@online.de wrote: > Loris Bennett wrote at 2024-11-12 10:00 +0100: >> ... >>However, it strikes me as not immediately obvious that the logging file >>must exist at this point. I can imagine a situation in which I want to >>configure a default log fi

Re: Too Broad of an exception

2023-10-25 Thread Kushal Kumaran via Python-list
On Wed, Oct 25 2023 at 11:49:12 AM, rsutton wrote: > On 10/25/2023 11:06 AM, Stefan Ram wrote: >> r...@zedat.fu-berlin.de (Stefan Ram) writes: >>> outer quotation marks) prints some prominent exception types. After >>> manually removing those that do not seem to apply, I am left with: >>> "Asserti

Re: Working with paths

2023-07-16 Thread Kushal Kumaran via Python-list
On Sun, Jul 16 2023 at 03:58:07 PM, Peter Slížik wrote: > Hello, > > I finally had a look at the pathlib module. (Should have done it long ago, > but anyway...). Having in mind the replies from my older thread (File > system path annotations), what is the best way to support all possible path > ty

Re: How to 'ignore' an error in Python?

2023-04-28 Thread Kushal Kumaran
On Fri, Apr 28 2023 at 04:55:41 PM, Chris Green wrote: > I'm sure I'm missing something obvious here but I can't see an elegant > way to do this. I want to create a directory, but if it exists it's > not an error and the code should just continue. > > So, I have:- > > for dirname in listofdir

Re: Which linux distro is more conducive for learning the Python programming language?

2022-08-03 Thread Kushal Kumaran
On Thu, Aug 04 2022 at 10:22:41 AM, Turritopsis Dohrnii Teo En Ming wrote: > Subject: Which linux distro is more conducive for learning the Python > programming language? > > Good day from Singapore, > > May I know which linux distro is more conducive for learning the > Python programming languag

Re: ssl server: how to disable client cert verfication?

2022-02-03 Thread Kushal Kumaran
On Thu, Feb 03 2022 at 01:32:04 PM, Grant Edwards wrote: > On 2022-02-03, Kushal Kumaran wrote: > >> On Thu, Feb 03 2022 at 10:57:56 AM, Grant Edwards >> wrote: >>> I've got a small ssl server app. I want to require a certificate from >>>

Re: ssl server: how to disable client cert verfication?

2022-02-03 Thread Kushal Kumaran
On Thu, Feb 03 2022 at 10:57:56 AM, Grant Edwards wrote: > I've got a small ssl server app. I want to require a certificate from > the client, so I'm using a context with > > context.verify_mode = ssl.CERT_REQUIRED > > But, I want all certificates accepted. How do I disable client > certificate v

Re: ssl: why wrap newly accept()ed connections?

2022-02-03 Thread Kushal Kumaran
On Thu, Feb 03 2022 at 11:17:17 AM, Grant Edwards wrote: > According to the docs, when you accept() an ssl connection, > you need to wrap the new connection: > > https://docs.python.org/3/library/ssl.html?highlight=ssl#ssl-sockets > >When a client connects, you’ll call accept() on the socket

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

2022-01-07 Thread Kushal Kumaran
On Fri, Jan 07 2022 at 12:51:48 PM, Skip Montanaro wrote: > Hopefully some Pythonistas are also Gunicornistas. I've had little success > finding help with a small dilemma in the docs or in other more specific > sources. > > I'm testing out a new, small website. It is just Gunicorn+Flask. I'd like

Re: AttributeError: 'NoneType' object has no attribute 'get'

2022-01-06 Thread Kushal Kumaran
On Tue, Jan 04 2022 at 11:34:20 PM, NArshad wrote: > How to correct what is written below: > > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Users\Dani Brothers\Anaconda3\lib\tkinter\__init__.py", line 1705, > in __call__ > return self.func(*args) > File "D

Re: Getting the exit code of a subprocess

2021-12-15 Thread Kushal Kumaran
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 > I need to know whether the shell script threw an error. > > Here is my code: > p = Popen(cmd, stdout

Re: McCabe complexity for just changed files in a commit?

2021-10-04 Thread Kushal Kumaran
On Tue, Oct 05 2021 at 03:55:22 PM, Chris Angelico wrote: > On Tue, Oct 5, 2021 at 3:44 PM Kushal Kumaran wrote: >> >> On Sat, Oct 02 2021 at 09:05:47 PM, Dan Stromberg >> wrote: >> > Hi folks. >> > >> > Is there a way of getting the McCabe Compl

Re: McCabe complexity for just changed files in a commit?

2021-10-04 Thread Kushal Kumaran
On Sat, Oct 02 2021 at 09:05:47 PM, Dan Stromberg wrote: > Hi folks. > > Is there a way of getting the McCabe Complexity of just the functions and > methods (in Python) changed in a git commit? > > I found radon, and it looks good. But I think it wants to do entire files, > no? > Calculate your

Re: combine multiple xlsx files which include dropdown columns in them.

2021-09-08 Thread Kushal Kumaran
On Tue, Sep 07 2021 at 10:05:58 PM, "hongy...@gmail.com" wrote: > I've some xlsx files which include dropdown columns in them. I want to > know whether I can combine all the lines into one xlsx file. Any hints > for doing this job with python programmatically will be highly > appreciated. > The

Re: Determine what the calling program is

2021-04-18 Thread Kushal Kumaran
On Sun, Apr 18 2021 at 07:46:53 AM, Jason Friedman wrote: > 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 fo

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

2021-02-16 Thread Kushal Kumaran
On Tue, Feb 16 2021 at 07:24:30 PM, Jach Feng wrote: > I am experimenting with multithreading-socket these days. I build a > server to handle each client in a separate thread. All are running on > my local PC. It works fine except the listen() method. > > I set listen(2) and expect to see "error"

Re: etree, gzip, and BytesIO

2021-01-21 Thread Kushal Kumaran
On Thu, Jan 21 2021 at 08:22:08 AM, Frank Millman wrote: > Hi all > > This question is mostly to satisfy my curiosity. > > In my app I use xml to represent certain objects, such as form > definitions and process definitions. > > They are stored in a database. I use etree.tostring() when storing >

Re: Converting images to PDF. Final file has blank pages before and after.

2020-11-30 Thread Kushal Kumaran
On Mon, Nov 30 2020 at 05:20:30 PM, Michael Baca wrote: > Hello, new to the group, rather new to programming. > > I'm writing a program that takes images and converts them into PDF's. It > works after quite a few days of trying, however the final file has a blank > page inserted before and afte

Re: A library that converts a type-annotated function into a webpage with HTML forms?

2020-09-30 Thread Kushal Kumaran
On Wed, Sep 30 2020 at 04:45:47 PM, James Lu wrote: > Is there a python library available that converts a type-annotated Python > function into a webpage with HTML forms? > > Something like: > > > def foo(name: str, times: int): > return f"Hello {name}!" * times > > serve_from(foo, host="0.0.0

Re: Having trouble with Mock and exception side effects

2020-08-21 Thread Kushal Kumaran
You could attempt something like what is mentioned in https://docs.python.org/3/library/unittest.mock-examples.html#partial-mocking See below. "Joshua J. Kugler" writes: > Hello! I am using Mock to raise an exception in an function as a side > effect. > However, Mock is completely redefining

Re: Assign Excel cell value from Datepicker widget Selection using Python

2020-06-28 Thread Kushal Kumaran
narenchund...@gmail.com writes: > When I run the python code I should be able to open my Excel and when > I click on one Excel cell I should have my datepicker widget popped up > and I should be able to select any date from my datepicker widget as > my Excel cell value > > Tried below code but in

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread Kushal Kumaran
zljubi...@gmail.com writes: > Hi, > > consider this example: > > from typing import Dict, List > > > class chk_params: > def execute(self, params: Dict[str, List] = None): > if params is None: > params = {} > > for k, v in params.items(): > params[k] = [

Re: ElementNotInteracable Exception for Selenium Chrome webdriver

2020-06-06 Thread Kushal Kumaran
emagnun writes: > I'm using latest python and latest Selenium chrome webdriver. I'm > trying to have a simple code to search in youtube but I'm getting the > below error. Can anyone help me? > > File "search.py", line 8, in searchBox.click() > Selenium.common.exceptions.ElementNotInteractableExce

Re: Enums are Singletons - but not always?

2020-05-23 Thread Kushal Kumaran
"Ralf M." writes: > Hello, > > recently I wrote a small library that uses an Enum. That worked as > expected. Then I added a main() and if __name__ == "__main__" to make > it runable as script. Now Enum members that should be the same aren't > identical any more, there seem to be two instances of

Re: Enums are Singletons - but not always?

2020-05-23 Thread Kushal Kumaran
Richard Damon writes: > On 5/23/20 2:21 PM, Ralf M. wrote: >> Hello, >> >> recently I wrote a small library that uses an Enum. That worked as >> expected. Then I added a main() and if __name__ == "__main__" to make >> it runable as script. Now Enum members that should be the same aren't >> identi

Re: Install GDAL

2020-04-22 Thread Kushal Kumaran
J Conrado writes: > Hi, > > > I'm trying to install GDAL. I used conda and PIP and I didn't have sucess. > > > I used for pip to insatal GDAL3.0.4: > > > pip install GDAL > > > Collecting GDAL >   Using cached GDAL-3.0.4.tar.gz (577 kB) > > > >     cc1plus: warning: command line option "-Wstrict

Re: Testing the data type of a value

2019-05-12 Thread Kushal Kumaran
Luuk writes: > On 12-5-2019 16:07, Piet van Oostrum wrote: >> Luuk writes: >> >>> After thinking about this, (i am prettry new to python), i was doing this: >>> >> print(type(5),type(int),type(5)==type(int),type(5)==int) >>> False True >>> >>> Can someone explain why type(5)==int evalu

Re: python3.7.2 won't compile with SSL support

2019-02-21 Thread Kushal Kumaran
"Felix Lazaro Carbonell" writes: > Hello: > > > > I'm trying to install python3.7.2 from source in debian9.8 but it doesn't > compile with SSL. > > > > I already installed openssl > > > > And ./configure -with-openssl=/usr/include/openssl/ yields: > > > > checking for openssl/ssl.h in /u

Re: Dependency injection: overriding defaults

2018-02-01 Thread Kushal Kumaran
Victor Porton writes: > dieter wrote: > >> Victor Porton writes: >> >>> I am writing a library, a command line utility which uses the library, >>> and a I am going to use dependency_injector package. >>> >>> Consider loggers: >>> >>> For the core library the logger should default to stderr. >>>

Re: sqlite in 2.7 on redhat 6

2017-06-15 Thread Kushal Kumaran
Larry Martell writes: > On Thu, Jun 15, 2017 at 12:20 PM, Kushal Kumaran wrote: >> Larry Martell writes: >> >>> On Thu, Jun 15, 2017 at 10:35 AM, Peter Otten <__pete...@web.de> wrote: >>>> Larry Martell wrote: >>>> >>>>>&g

Re: sqlite in 2.7 on redhat 6

2017-06-15 Thread Kushal Kumaran
Larry Martell writes: > On Thu, Jun 15, 2017 at 10:35 AM, Peter Otten <__pete...@web.de> wrote: >> Larry Martell wrote: >> On linux the system sqlite3 is used. >>> >>> I tried building and installing sqlite from source and that did not >>> solve the problem. >> >> You misunderstood: the prob

Re: Python 3.6 on Centos 6

2016-12-24 Thread Kushal Kumaran
thinkwell writes: > I'm trying to build Python 3.6 on Centos 6, and am successful in doing > so, except for the sqlite3 library. I started with a brand new install > of Centos 6 and installed devtoolset-2 to build with a newer > compiler. But whether with default compiler or 4.82, I get the > fol

Re: [OT] Java generics

2016-04-17 Thread Kushal Kumaran
Chris Angelico writes: > On Mon, Apr 18, 2016 at 8:02 AM, Tim Delaney > wrote: >> I also wouldn't describe Java as a >> "perfectly good language" - it is at best a compromise language that just >> happened to be heavily promoted and accepted at the right time. >> >> Python is *much* closer to my

Re: Calling Python Script from an SQL Proceudre

2015-06-03 Thread Kushal Kumaran
Amit Goutham writes: > Hi All, > I am trying to search on the Internet if i can call a Python Script from an > SQL Procedure. > All the information found on Internet is about connecting to a database > from Python through a Python script.But, i want the other way round. > > Any Help will be appre

Re: Wildly OT: pop-up virtual keyboard for Mac or Linux?

2015-02-10 Thread Kushal Kumaran
Skip Montanaro writes: > I know this is way off-topic for this group, but I figured if anyone > in the online virtual communities I participate in would know the > answer, the Pythonistas would... Google has so far not been my friend > in this realm. > > One of the things I really like about my S

Re: Hashed lookups for tabular data

2015-01-19 Thread Kushal Kumaran
"Joseph L. Casale" writes: >> So presumably your data's small enough to fit into memory, right? If >> it isn't, going back to the database every time would be the best >> option. But if it is, can you simply keep three dictionaries in sync? > > Hi Chris, > Yeah the data can fit in memory and henc

Re: asyncio subprocess PIPE output lost

2014-08-19 Thread Kushal Kumaran
On Tue, Aug 19, 2014 at 1:09 PM, yuzhichang wrote: > Hi all, > I'm new to asyncio introduced by Python 3.4. I created two tasks each > pings a host. I noticed some pieces of output will be lost(see "error: found > icmp_seq gap"). If I changed to run only one task, this problem never occur. >

Re: feedparser error

2014-04-26 Thread Kushal Kumaran
tad na writes: > python 2.7.2 > > The following code has an error and I can not figure out why: > > import feedparser > d = feedparser.parse('http://bl.ocks.org/mbostock.rss') > numb = len(d['entries']) > for post in d.entries: > print post.pubDate+"\n" > > ---

Re: Simple question

2014-04-15 Thread Kushal Kumaran
On April 16, 2014 12:37:53 AM GMT+05:30, Chris Angelico wrote: >On Wed, Apr 16, 2014 at 5:02 AM, Phil Dobbin >wrote: >> On 15/04/2014 19:41, Chris Angelico wrote: >> >>> Recommendation: If you don't understand something, keep it there :) >>> You can just copy and paste from the Python interact

Re: buggy python interpretter or am I missing something here?

2014-01-30 Thread Kushal Kumaran
Steven D'Aprano writes: > On Thu, 30 Jan 2014 18:13:54 +1300, Gregory Ewing wrote: > >> Steven D'Aprano wrote: >>> On Mon, 27 Jan 2014 12:22:22 -0800, Rick Johnson wrote: >>> Why do we even need an "input" function anyway if all it is going to do is read from stdin? >>> >>> That's not a

Re: the Gravity of Python 2

2014-01-09 Thread Kushal Kumaran
Ben Finney writes: > Kushal Kumaran writes: > >> Roy Smith writes: >> > How, in Python, do you get an aware UTC datetime object? >> >> My local copy of the python 3.2.3 docs says: >> >> classmethod datetime.utcnow() >> >> Return

Re: the Gravity of Python 2

2014-01-09 Thread Kushal Kumaran
Roy Smith writes: > In article , > Chris Angelico wrote: > >> On Thu, Jan 9, 2014 at 2:35 PM, Roy Smith wrote: >> >> Yes, it *is* simple. It *is* easy. I've been working with pure-UTC >> >> times (either called time_t, or TIMESTAMP WITH TIME ZONE, or even just >> >> float) for decades. Like wi

Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Kushal Kumaran
rusi writes: > On Wednesday, October 30, 2013 9:05:29 PM UTC+5:30, Jonas Thornval wrote: >> Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence: >> > On 30/10/2013 14:31, Jonas Thornval wrote: >> > Would you please be kind enough to read, digest and action this >> > https:/

Re: PyGLet, 2to3...?

2013-07-26 Thread Kushal Kumaran
John Ladasky writes: > On Thursday, July 25, 2013 3:26:01 PM UTC-7, John Ladasky wrote: >> I'll try again from scratch, and see whether that clears up my problems. > > Nope, that didn't work. > > === > > john@john:~/Desktop/pyglet-1.2alpha1$ sudo python3 setup.

Re: Python3, GUIs, game APIs, PyGLet, 2to3...?

2013-07-25 Thread Kushal Kumaran
John Ladasky writes: > Followup to my own post: I've made progress with PyGLet. I should mention > that I'm using Ubuntu Linux 13.04 64-bit, in case it matters. > > I tried executing "2to3 -w *.py" on just the files in the directory > pyglet-1.2alpha1/pyglet. I then changed back to the pyglet

Re: A certainl part of an if() structure never gets executed.

2013-06-12 Thread Kushal Kumaran
Chris Angelico writes: > On Thu, Jun 13, 2013 at 11:55 AM, Steven D'Aprano > wrote: >> In English: >> >> "the cat is in the box or the cupboard or the kitchen" >> >> means: >> >> "the cat is in the box, or the cat is in the cupboard, or the cat is in >> the kitchen". >> >> >> But that is not how

Re: In defence of 80-char lines

2013-04-04 Thread Kushal Kumaran
Roy Smith writes: > In article , > Jason Swails wrote: > >> The only time I regularly break my rule is for regular expressions (at some >> point I may embrace re.X to allow me to break those up, too). > > re.X is a pretty cool tool for making huge regexes readable. But, it > turns out that py

Re: select.epoll question

2013-02-07 Thread Kushal Kumaran
Paul Rubin writes: > Chris Angelico writes: >> Yeah, I figured fileno() probably wouldn't be news to you. I don't >> suppose there's anything convenient in the rest of your application >> that makes such a list/dict plausible? > > In fact it's rather annoying, sockets are created and destroyed

Re: Any built-in ishashable method ?

2013-01-18 Thread Kushal Kumaran
Peter Otten <__pete...@web.de> writes: > Jean-Michel Pichavant wrote: > >> That brings me to another question, is there any valid test case where >> key1 != key2 and hash(key1) == hash(key2) ? Or is it some kind of design >> flaw ? > > I don't think there is a use case for such a behaviour other t

Re: Vote tallying...

2013-01-18 Thread Kushal Kumaran
Chris Angelico writes: > On Sat, Jan 19, 2013 at 7:24 AM, Ben Finney > wrote: >> * MySQL's development has suffered under Sun, and become virtually >> moribund under Oracle. They operate as a closed shop, occasionally >> tossing GPL-licensed releases over the wall, with very little input >>

Re: Why does os.stat() tell me that my file-group has no members?

2012-12-19 Thread Kushal Kumaran
saqib.ali...@gmail.com writes: > Thanks!! This was very helpful. It worked perfectly. > I had no clue about the intricacies of how python represents the group data > from the underlying OS. > > This page doesn't go into to detailed explanation like you did: > http://docs.python.org/2/library/grp

Re: how to pass "echo t | " input to subprocess.check_output() method

2012-11-26 Thread Kushal Kumaran
dacha...@gmail.com writes: > On Monday, 26 November 2012 16:32:22 UTC+5:30, Kushal Kumaran wrote: >> dacha...@gmail.com writes: >> >> >> >> > Hi all, >> >> > >> >> > I want to list the repositories in svn usin

Re: how to pass "echo t | " input to subprocess.check_output() method

2012-11-26 Thread Kushal Kumaran
dacha...@gmail.com writes: > Hi all, > > I want to list the repositories in svn using python. For this i have used > below command, > " res = subprocess.check_output(["svn.exe", "list", > "Https://127.0.0.1:443/svn/Repos"], stderr=subprocess.STDOUT) " > > but it throws an exception, since it req

Re: Subprocess puzzle and two questions

2012-11-14 Thread Kushal Kumaran
Chris Angelico writes: > On Thu, Nov 15, 2012 at 12:49 PM, Roy Smith wrote: >> In article , >> Chris Angelico wrote: >> >>> I'm slightly surprised that there's no way with the Python stdlib to >>> point a DNS query at a specific server >> >> Me too, including the "only slightly" part. The nor

Re: creating size-limited tar files

2012-11-14 Thread Kushal Kumaran
Ian Kelly writes: > On Tue, Nov 13, 2012 at 11:05 PM, Kushal Kumaran > wrote: >> Or, you could just change the p1's stderr to an io.BytesIO instance. >> Then call p2.communicate *first*. > > This doesn't seem to work. > >>>> b = io.BytesIO()

Re: Subprocess puzzle and two questions

2012-11-13 Thread Kushal Kumaran
w...@mac.com writes: > I need to time the operation of a command-line utility (specifically > nslookup) from within a python program I'm writing. I don't want to use > python's timeit function because I'd like to avoid python's subprocess > creation overhead. That leads me to the standard UNI

Re: creating size-limited tar files

2012-11-13 Thread Kushal Kumaran
Ian Kelly writes: > On Tue, Nov 13, 2012 at 3:31 AM, andrea crotti > wrote: >> but it's a bit ugly. I wonder if I can use the subprocess PIPEs to do >> the same thing, is it going to be as fast and work in the same way?? > > It'll look something like this: > p1 = subprocess.Popen(cmd1, she

RE: Obnoxious postings from Google Groups

2012-11-07 Thread Kushal Kumaran
"Prasad, Ramit" writes: > Steven D'Aprano wrote: >> >> On Tue, 06 Nov 2012 17:16:44 +, Prasad, Ramit wrote: >> >> >> To enter the newline, I typed Ctrl-Q to tell bash to treat the next >> >> character as a literal, and then typed Ctrl-J to get a newline. >> > >> > That sounds complicated, m

Re: PIL and requests don't get along

2012-10-23 Thread Kushal Kumaran
On 23 Oct 2012 14:06:59 -0400, r...@panix.com (Roy Smith) wrote: > I have a url from which I can get an image. I want to use PIL to > manipulate that image. Getting the image is easy: > > >>> import requests > >>> r = requests.get(url) > > There's a bunch of factory functions for Image, but non

Re: how to run shell command like "<

2012-09-29 Thread Kushal Kumaran
On Sat, Sep 29, 2012 at 6:18 AM, 叶佑群 wrote: > 于 2012-9-28 16:16, Kushal Kumaran 写道: >> >> On Fri, Sep 28, 2012 at 1:15 PM, 叶佑群 wrote: >> >>> Hi, all, >>> >>> I have the shell command like this: >>> >>> sfdisk -uM /dev/sdb&

Re: how to run shell command like "<

2012-09-28 Thread Kushal Kumaran
On Fri, Sep 28, 2012 at 1:15 PM, 叶佑群 wrote: > Hi, all, > > I have the shell command like this: > > sfdisk -uM /dev/sdb << EOT > ,1000,83 > ,,83 > EOT > > > I have tried subprocess.Popen, pexpect.spawn and os.popen, but none of > these works, but when I type this shell command in shell, it

Re: google api and oauth2

2012-09-26 Thread Kushal Kumaran
On Wed, Sep 26, 2012 at 11:45 AM, Demian Brecht wrote: >> >> If you are writing a desktop application, read this: >> https://developers.google.com/accounts/docs/OAuth2#clientside > > > You mean https://developers.google.com/accounts/docs/OAuth2#installed? Your > link discusses client side browser

Re: google api and oauth2

2012-09-25 Thread Kushal Kumaran
(making no attempt to fix messed up quoting, please take a look at your mail client configuration) On Wed, Sep 26, 2012 at 1:52 AM, Littlefield, Tyler wrote: > On 9/25/2012 2:05 PM, Demian Brecht wrote: > > This is a shameless plug, but if you want a much easier to understand method > of accessin

Re: How to queue functions

2012-09-18 Thread Kushal Kumaran
On Tue, Sep 18, 2012 at 10:26 AM, Dhananjay wrote: > Dear all, > > I am trying to use multiprocessing module. > I have 5 functions and 2000 input files. > > First, I want to make sure that these 5 functions execute one after the > other. > Is there any way that I could queue these 5 functions with

Re: forked processes and testing

2012-09-12 Thread Kushal Kumaran
On Wed, Sep 12, 2012 at 3:50 PM, andrea crotti wrote: > I wrote a decorator that takes a function, run it in a forked process > and return the PID: > > def on_forked_process(func): > from os import fork > """Decorator that forks the process, runs the function and gives > back control t

Re: Python Interview Questions

2012-09-05 Thread Kushal Kumaran
On Wed, Sep 5, 2012 at 3:11 PM, Stephen Anto wrote: > On Wed, Sep 5, 2012 at 2:10 PM, Kushal Kumaran > wrote: >> >> On Wed, Sep 5, 2012 at 12:20 PM, wrote: >> > On Tuesday, October 30, 2007 11:44:01 PM UTC+5:30, Krypto wrote: >> >> Hi, >> >>

Re: Python Interview Questions

2012-09-05 Thread Kushal Kumaran
On Wed, Sep 5, 2012 at 12:20 PM, wrote: > On Tuesday, October 30, 2007 11:44:01 PM UTC+5:30, Krypto wrote: >> Hi, >> >> I have used Python for a couple of projects last year and I found it >> extremely useful. I could write two middle size projects in 2-3 months >> (part time). Right now I am a b

Re: properly catch SIGTERM

2012-07-20 Thread Kushal Kumaran
On Fri, Jul 20, 2012 at 11:39 AM, Dieter Maurer wrote: > Eric Frederich writes: >> ... >> This seems to work okay but just now I got this while hitting ctrl-c >> It seems to have caught the signal at or in the middle of a call to >> sys.stdout.flush() >> --- Caught SIGTERM; Attempting to quit gra

Re: Let child process to run while parent is out (multiprocessing)

2012-07-20 Thread Kushal Kumaran
On Fri, Jul 20, 2012 at 2:04 AM, John Wong wrote: > def main(...): > build_id = create_build_id(...) > build_stuff > return build_id > > Suppose build_stuff compiles a C program. It could take days to finish, and > notify users their builds are ready. I was thinking about using > mutli

Re: code review

2012-07-03 Thread kushal . kumaran+python
Ian Kelly wrote: >On Tue, Jul 3, 2012 at 11:53 AM, Kushal Kumaran > wrote: >> On Sat, Jun 30, 2012 at 3:34 PM, Alister >wrote: >>> On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote: >>> >>>> On 6/29/2012 1:31 AM, Steven D'Aprano wrote

Re: code review

2012-07-03 Thread Kushal Kumaran
On Sat, Jun 30, 2012 at 3:34 PM, Alister wrote: > On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote: > >> On 6/29/2012 1:31 AM, Steven D'Aprano wrote: >>> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote: >>> On Jun 29, 12:57 pm, "Littlefield, Tyler" wrote: > I was curious if

Re: 回复: how can I implement "cd" like shell in Python?

2012-06-28 Thread Kushal Kumaran
Alex chen wrote: >I just want to write a python program,it can be called in the linux >terminal like the command "cd" to change the directory of the shell >terminal > This cannot be done. Shells implement cd as a builtin, rather than a command such as /usr/bin/cd because there is no way to cha

Re: How does python bytecode works?

2012-06-17 Thread Kushal Kumaran
On Mon, Jun 18, 2012 at 1:23 AM, Devin Jeanpierre wrote: > On Sun, Jun 17, 2012 at 5:54 AM, gmspro wrote: >> >> We know python is written in C. >> C is not portable. > > Badly written C is not portable. But C is probably the most portable > language on the planet, by virtue of basically every sys

Re: Pytz error: unpack requires a string argument of length 44

2012-06-13 Thread Kushal Kumaran
On Thu, Jun 14, 2012 at 6:35 AM, Daniel Klein wrote: > The windows box is my development box, it's not where the script will be > running in the end. It'll be running on a Linux box where I don't have root > so python setup.py install isn't an option (to my understanding). > You might want to u

Re: Use a locally built Tk for Python?

2012-06-04 Thread Kushal Kumaran
On Mon, Jun 4, 2012 at 12:51 PM, Mark Summerfield wrote: > Thanks for your thoughtful replies. > > I don't use altinstall because using --prefix is sufficient to get a > locally built Python. > > Both your suggestions require root (or sudo) and changing the system > itself. Whereas I was hoping to

Re: Need to get Tags and Values from Dom

2012-05-13 Thread Kushal Kumaran
On Mon, May 14, 2012 at 6:20 AM, TommyVee wrote: > I have a very simple XML document that I need to "walk", and I'm using > xml.dom.minidom.  No attributes, just lots of nested tags and associated > values.  All I'm looking to do is iterate through each of the highest > sibling nodes, check what t

Re: Looking for video/slides from PyCon 2011...

2012-05-13 Thread Kushal Kumaran
On Fri, May 11, 2012 at 5:42 AM, Monte Milanuk wrote: > ...specifically the two lectures on creating GUI applications with Python + > QT > > http://us.pycon.org/2011/schedule/presentations/207/ > > Various searches on the 'Net don't seem to be turning up much... kinda > curious as to why? > > Anyo

Re: c-based version of pyPdf?

2012-05-03 Thread Kushal Kumaran
On Thu, May 3, 2012 at 8:23 PM, Chris Curvey wrote: > I'm a long-time user of the pyPdf library, but now I'm having to work with > bigger volumes -- larger PDFs and thousands of them at a shot.  So > performance is starting to become a problem. > > Does anyone know of an analogue to pyPdf that i

Re: bus errors when the network interface is reset?

2012-05-02 Thread Kushal Kumaran
On Tue, May 1, 2012 at 7:31 PM, David M Chess wrote: > > We have a system running Python 2.6.6 under RHEL 6.1.  A bunch of processes > spend most of their time sitting in a BaseHTTPServer.HTTPServer waiting for > requests. > > Last night an update pushed out via xcat whimsically restarted all of t

Re: How can I read streaming output of a subprocess

2012-05-02 Thread Kushal Kumaran
On Wed, May 2, 2012 at 4:38 PM, Damjan Georgievski wrote: > I want to read the stream of an external process that I start with Python. > From what I've seen that's not possible with the subprocess module? > > I want to read the output of "ip monitor neigh" which will show changes in > the ARP tabl

Re: help

2012-04-29 Thread Kushal Kumaran
On Mon, Apr 30, 2012 at 11:43 AM, viral shah wrote: > I want to print below matrix. > > can any one suggest me the method for the same > > 1 2   3 > 4 5   6 > 7 8   9 > In general, for homework questions, you should present your attempt at a solutio

Re: Same code cause the different result.

2012-04-25 Thread Kushal Kumaran
On Wed, Apr 25, 2012 at 12:21 PM, 叶佑群 wrote: > Hi, all > >    I have code as: > >     pobj = subprocess.Popen (["smbpasswd", user], stdin > =subprocess.PIPE) >     password += "\n" >     pobj.stdin.write (password) >     pobj.stdin.write (password) > >     the comma

Re: finding a regular expression in a file

2012-04-24 Thread Kushal Kumaran
On Apr 24, 2012 6:32 PM, "S.B" wrote: > > Hello friends. > > Newb question here. > I'm trying to find an efficient way to "grep" a file with python. > The problem is that all the solutions I find on the web read a line at a time from the file with a "for line in" loop and check each line for the R

Re: pipe into preallocated buffer?

2012-01-11 Thread Kushal Kumaran
On Wed, Jan 4, 2012 at 8:05 PM, Mihai Badoiu wrote: > is there a way to pipe directly into a preallocated buffer? >  (subprocessing.pipe.stdout) > Does io.StringIO fit your needs? http://docs.python.org/py3k/library/io.html#io.StringIO -- regards, kushal -- http://mail.python.org/mailman/list

Re: Stucked with python logging module

2011-11-15 Thread Kushal Kumaran
On Wed, Nov 16, 2011 at 8:58 AM, sword wrote: > I just scaned through the beginer's guide of logging module, but I > can't get anything from console. The demo just like this: > > import logging > logging.debug("This is a demo") > > Maybe I should do sth to put the log to stdout in basicConfig firs

Re: Environment variables not visible from Python

2011-09-21 Thread Kushal Kumaran
On Thu, Sep 22, 2011 at 11:42 AM, Steven D'Aprano wrote: > I don't understand why some environment variables are not visible from > Python. > > [steve@wow-wow ~]$ echo $LINES $COLUMNS $TERM > 30 140 xterm > [steve@wow-wow ~]$ python2.6 > Python 2.6.6 (r266:84292, Dec 21 2010, 18:12:50) > [GCC 4.1.

Re: help regarding re.search

2011-09-14 Thread Kushal Kumaran
On Thu, Sep 15, 2011 at 10:11 AM, Sagar Neve wrote: > Here is the code > > > url="http://xy.yz.com/us/r1000/012/Purple/b1/c6/e2/mzm.dxkjsfbl..d2.dpkg.ipa"; > > Man_Param="/us/r1000" > Opt_Param1="Purple" > Opt_Param2="dpkg.ipa" > > if (Opt_Param2 in url): >     print "hello." > else: >     print "

Re: send string to input of another process

2011-09-13 Thread Kushal Kumaran
On 13 Sep 2011 17:53, "Alex Naumov" wrote: > > Hello everybody, > > I'm looking for some solution, maybe someone of you can help me. > > I call another process via os.system("process") and it waits for some input. I have to write a comment (for example, like using svn or git), and after that to cl

Re: Deadlock problem using multiprocessing

2011-09-11 Thread Kushal Kumaran
2011/9/11 蓝色基因 : > This is my first touch on the multiprocessing module, and I admit not > having a deep understanding of parallel programming, forgive me if > there's any obvious error. This is my test code: > > # deadlock.py > > import multiprocessing > > class MPTask: >        def __init__(self)

Re: A bit of a boggle about subprocess.poll() and the codes it receives from a process

2011-09-10 Thread Kushal Kumaran
On Fri, Sep 9, 2011 at 11:02 PM, J wrote: > Hi, > I need a bit of help sorting this out... > I have a memory test script that is a bit of compiled C.  The test itself > can only ever return a 0 or 1 exit code, this is explicitly coded and there > are no other options. > I also have a wrapper test

Re: How to daemonize a HTTPServer

2011-08-31 Thread Kushal Kumaran
On 1 Sep 2011 08:54, "babbu Pehlwan" wrote: > > I have written a http server using BaseHTTPServer module. Now I want > to instantiate it through another python script. The issue here is > after instantiate the control doesn't come back till the server is > running. Please suggest. What did a web

Re: Hardlink sub-directories and files

2011-08-02 Thread Kushal Kumaran
On Wed, Aug 3, 2011 at 7:29 AM, Dan Stromberg wrote: > > On Tue, Aug 2, 2011 at 3:13 AM, Thomas Jollans wrote: >> >> On 02/08/11 11:32, loial wrote: >> > I am trying to hardlink all files in a directory structure using >> > os.link. >> > >> > However I do not think it is possible to hard link dir

Re: Notifications when process is killed

2011-08-02 Thread Kushal Kumaran
On Tue, Aug 2, 2011 at 1:56 PM, Thomas Rachel wrote: > Am 02.08.2011 09:30 schrieb AndDM: > >> The function works for SIGHUP and SIGINT, but it doesn't work for >> SIGTERM. I've tried with simple killall and with -15 option. >> Have you some ideas? > > SIGTERM cannot be caught - it kills the proce

Re: Seeking an example on using Queue to update variable while threading

2011-07-28 Thread Kushal Kumaran
On Thu, Jul 28, 2011 at 11:13 AM, Danny Wong (dannwong) wrote: > Hi Python experts, >        I'm trying to use a dict structure to store and update information > from X number of threads. How do I share this dict structure between threads? > I heard of using a queue, but I'm not familiar with ho

Re: urllib, urlretrieve method, how to get headers?

2011-07-01 Thread Kushal Kumaran
On Fri, Jul 1, 2011 at 2:23 PM, Даниил Рыжков wrote: > Hello again! > Another question: urlopen() reads full file's content, but how can I > get page by small parts? > Set the Range header for HTTP requests. The format is specified here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec

Re: New member intro and question

2011-06-17 Thread Kushal Kumaran
Hi Anthony, Welcome to the python users mailing list. On Sat, Jun 18, 2011 at 9:32 AM, Anthony Papillion wrote: > Hi Everyone, > > > I'm a new list member from the United States. Long time programmer, > fairly new to Python and absolutely loving it so far! I'm 36, live in > Oklahoma, and own a

Re: The pythonic way equal to "whoami"

2011-06-07 Thread Kushal Kumaran
On Tue, Jun 7, 2011 at 7:54 PM, TheSaint wrote: > Hello, > I was trying to find out whose the program launcher, but os.environ['USER'] > returns the user whom owns the desktop environment, regardless the program > is called by root. > I'd like to know it, so the program will run with the right pri

Re: How to import data from MySQL db into excel sheet -- Very Urgent

2011-06-03 Thread Kushal Kumaran
On Fri, Jun 3, 2011 at 5:52 PM, hisan wrote: > Task i need to achieve here is: > I need to write a python script which fetches all the data from the > MySQL database and dumps into an excel sheet. since i was not able to > dump the data into excel sheet i used CSV file which looks similar to > exc

Re: how to get PID from subprocess library

2011-05-22 Thread Kushal Kumaran
On Sat, May 21, 2011 at 6:20 PM, TheSaint wrote: > Kushal Kumaran wrote: > >> That's how it is able to give you the status.  So, if you >> are using getstatusoutput, you will have only one instance of your >> command running. > > My intent is to launch only on

Re: how to get PID from subprocess library

2011-05-20 Thread Kushal Kumaran
On Thu, May 19, 2011 at 9:32 PM, TheSaint wrote: > hello, > > I'm using to launch a program by subprocess.getstatusoutput. I'd like to > know whether I can get the program ID, in order to avoid another launch. > > For clarity sake, I'm calling aria2 (the download manager for linux) and I > wouldn'

  1   2   3   >