How to define "exec" method on a class object? Get syntax error due to built in command

2013-03-25 Thread Kyle
I am using swig to generate our CLI for TCL and Python. In this CLI, we have a 
subcommand "exec" that is failing to compile in the python case. There seems to 
be some built-in python command "exec" which is giving a syntax error in the 
.py file generated by swig when I try to import it:

   def exec(*args): return _wbt_daemon.dm_cli_exec(*args)
   ^
SyntaxError: invalid syntax

I don't really want to change the CLI commands or make them different between 
languages. Is there any way to define a method called "exec" on a class? It 
would be executed as obj.exec() so I don't see why it should conflict with the 
built in "exec" command.

class dm_cli(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, dm_cli, name, 
value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, dm_cli, name)
def __init__(self): raise RuntimeError, "No constructor defined"
...
def exec(*args): return _wbt_daemon.dm_cli_exec(*args)
...
}

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to define "exec" method on a class object? Get syntax error due to built in command

2013-03-26 Thread Kyle
On Monday, March 25, 2013 4:28:34 PM UTC-4, Kyle wrote:
> I am using swig to generate our CLI for TCL and Python. In this CLI, we have 
> a subcommand "exec" that is failing to compile in the python case. There 
> seems to be some built-in python command "exec" which is giving a syntax 
> error in the .py file generated by swig when I try to import it:
> 
> 
> 
>def exec(*args): return _wbt_daemon.dm_cli_exec(*args)
> 
>^
> 
> SyntaxError: invalid syntax
> 
> 
> 
> I don't really want to change the CLI commands or make them different between 
> languages. Is there any way to define a method called "exec" on a class? It 
> would be executed as obj.exec() so I don't see why it should conflict with 
> the built in "exec" command.
> 
> 
> 
> class dm_cli(_object):
> 
> __swig_setmethods__ = {}
> 
> __setattr__ = lambda self, name, value: _swig_setattr(self, dm_cli, name, 
> value)
> 
> __swig_getmethods__ = {}
> 
> __getattr__ = lambda self, name: _swig_getattr(self, dm_cli, name)
> 
> def __init__(self): raise RuntimeError, "No constructor defined"
> 
> ...
> 
> def exec(*args): return _wbt_daemon.dm_cli_exec(*args)
> 
> ...
> 
> }

Thanks for the suggestion. Looks like we currently use 2.3.4.

This still wouldn't solve the problem because now the user would need to call 
something like  getattr(wbt, "exec")() instead of wbt.exec() like 
all the other commands.

I think the easiest thing for me to do would be to just change the command name 
from exec to something else.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to define "exec" method on a class object? Get syntax error due to built in command

2013-03-26 Thread Kyle
On Mar 26, 2:43 pm, Chris Angelico  wrote:
> On Wed, Mar 27, 2013 at 5:13 AM, Kyle  wrote:
> > Thanks for the suggestion. Looks like we currently use 2.3.4.
>
> > This still wouldn't solve the problem because now the user would need to 
> > call something like  getattr(wbt, "exec")() instead of 
> > wbt.exec() like all the other commands.
>
> > I think the easiest thing for me to do would be to just change the command 
> > name from exec to something else.
>
> . that's pretty ancient. Any chance you can upgrade at least to 2.7.3?
>
> ChrisA

Unfortunately, while I could update my machine, there's no guarantee
others would have the same version--the 2.3.4 seems to be the default
on our machines and in the automount dirs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Adding Python to the path in Windows

2007-06-21 Thread kyle
I have many users using two different versions of python, 2.4 and
2.5.  I am running Python scripts on their computers programmatically,
but I can't run it with the full path because they have different
versions installed.  I need to run it like 'python {script name}'.  So
I need to add Python to the path.  How do I do this permanently
without going to each computer and setting it through the GUI?  I
tried creating a Windows batch script using setx, but the user had to
be an administrator.

Or is there any other way I can run whatever version of Python happens
to be installed with a single command?  Anyone have any ideas?  Such a
simple issue, there must be a simple solution. (of course, this is
Windows).

Thanks for any help.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding Python to the path in Windows

2007-06-21 Thread kyle
On Jun 21, 11:10 am, Duncan Booth <[EMAIL PROTECTED]>
wrote:
> Assuming they have Python installed normally there will be file
> associations set up for .py and .pyw, so all you need to do to type in
> the script name: Python itself does not need to be in the path.
> N.B. You do need to include the .py extension unless you can arrange to
> edit the PATHEXT environment variable.
>
> e.g.
>
> C:\Temp>type t.py
> import sys
> print sys.version
>
> C:\Temp>t.py
> 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
>
> C:\Temp>assoc .py
> .py=Python.File
>
> C:\Temp>ftype Python.File
> Python.File="C:\Python25\python.exe" "%1" %*

Wow, I knew there must be a simple solution, but I didn't know it was
that simple.  I feel sort of dumb now!  But thanks a lot, that saved
me a lot of work.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding Python to the path in Windows

2007-06-21 Thread kyle
On Jun 21, 11:22 am, [EMAIL PROTECTED] wrote:
>
> If your users aren't programmers, then why not just run Python over
> the network? That's what we do at my place of employment. The only
> machines that have Python actually installed are development machines.
>
> Mike

Mike,

I place the scripts on the server, but hadn't thought of placing an
entire Python installation on the server.  I just tried it and it
seems to work.  It shouldn't cause any problems?  That might actually
work out really well too.  Thanks for the suggestion.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding Python to the path in Windows

2007-06-21 Thread kyle
On Jun 21, 11:49 am, [EMAIL PROTECTED] wrote:
> I should probably mention that if you have some complicated GUI's,
> they will probably load slowly over the network. And I did notice that
> scripts using WMI and pyWin32 modules can be slower than they ought to
> be. Just something to keep in mind if you have a slow connection. We
> have a T1 out to a remote location and it's caused some minor issues
> using anything of that nature.
>
> Mike

I will probably do this then, because Duncan's solution does not seem
to be working for me.  If I run a Python script directly from a
command line, it works fine just like he said.  But I am using the
Shell() command in Visual Basic 2005 to run the Python script, and it
doesn't seem to be working.  I am getting an error, "File not found".
Not sure what the difference would be.  But your solution should work.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding Python to the path in Windows

2007-06-21 Thread kyle
On Jun 21, 11:53 am, Larry Bates <[EMAIL PROTECTED]> wrote:
> Another solution is to use py2exe to convert your python program into an .exe
> file that you can distribute.  Then they require no Python installation at 
> all.
>  I use py2exe and Inno Installer to do just that and it works great.
>
> -Larry

Yeah, I didn't even think of that.  The server install of Python seems
like the best option for my situation though.  Thanks for all the
great suggestions.


-- 
http://mail.python.org/mailman/listinfo/python-list


Python Integrated Parallel Pipeline EnviRonment: PIPPER

2009-02-05 Thread Kyle
I wanted to share a Python based project which I've been working on.
Python Integrated Parallel Pipeline EnviRonment (PIPPER) is an MPI
based programming environment that works much like an OpenMP on Python
code.  It is designed to create a python programming environment where
parallel computations on a set of distributed memory processors (you
may call it a cluster, or a Beowulf cluster) is easy to accomplish.
The idea is to make writing parallel code easy in order to promote
rapid development of script based distributed calculations.
There are tools, such as MPI or PVM that help with communicating
between processes running on different machines, but most people are
quickly scared off by the additional complexity in programming.
PIPPER eliminates this barrier to entry by automating the process of
data passing and job scheduling.
Most importantly is that there is no code 'lock-in'.  PIPPER works as
a pre-parser and is designed to be completely backward compatible with
a single CPU python environment.  If you write a script for PIPPER, it
will still work on systems that don't have PIPPER installed.

You can find the source code and documentation at http://pipper.sourceforge.net

A 'Hello Work' example of PIPPER code:

#!/usr/bin/python

import sys
import os

def do_call(x,y):
print "Hello World", x, y, os.getpid()

if __name__ == '__pipper_main__':
a_range = range( int(sys.argv[1]) )
#pragma pipper_start
for a in  a_range :
for b in a_range :
do_call(a,b)
#pragma pipper_end
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Integrated Parallel Pipeline EnviRonment: PIPPER

2009-02-05 Thread Kyle
PIPPER doesn't yet have a very large user base, and is still in
Alpha.  So if there is enough demand, syntax changes would still be
possible at this stage.

Kyle

> I'm not a big fan of comments that change semantics. Wouldn't a modified
> 'with' statement look better?
>
> We have a couple of other syntax proposals in the Cython Wiki.
>
> http://wiki.cython.org/enhancements/parallel
>
> Stefan

--
http://mail.python.org/mailman/listinfo/python-list


How to tailor output of help()

2009-12-24 Thread Kyle
Hi all,
I'm a graduate student in the physical sciences and still new to
Python. I'm writing a module of often-used code and have included
several math functions in my module via

from math import cos

and similarly for other functions. When I input help(mymodule) into
the console, cos() and its docstring are listed in the output section
for my module's functions. However, I only want functions that I have
written to appear, not those that I imported. I know this is merely
aesthetic, but is there a way to eliminate functions that I imported
from the function list in the output from help()? Thanks,

-kmd
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to tailor output of help()

2009-12-26 Thread Kyle
> Try setting the __all__ variable in your module to a list of the names
> you want your module to export.

Perfect. Thanks for the help.

-- 
http://mail.python.org/mailman/listinfo/python-list


The importance of mental health

2021-05-10 Thread Kyle Stanley
Hey all,

In these last few months, I have been in the process of healing from some
pretty heavy past trauma. And now that I am on the road to recovery, I want
to share my journey with the Python community in hopes that it may reach
those that are struggling with their own mental health battles, as many of
us are during these dark and difficult times.

Trigger warning that it includes a decent amount of highly personal
content, so only check it out if you are okay with that:
https://discuss.python.org/t/break-from-open-source/6372/7?u=aeros.

To anyone that would limit my employment opportunities as a result of
having had these struggles, *that's perfectly okay*. I kept the post in the
private section because I was originally in fear of discriminate. However,
I have reached an important conclusion: *I would not want to work for your
company if you discriminate against people who have overcome past struggles*
.

-- 
--Kyle R. Stanley, Python Core Developer (what is a core dev?
<https://devguide.python.org/coredev/>)
*Pronouns: they/them **(why is my pronoun here?*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
)
-- 
https://mail.python.org/mailman/listinfo/python-list


Farewell, for now :)

2021-05-31 Thread Kyle Stanley
Hi all,

Last week, I started a new thread on discuss.python.org
<https://discuss.python.org/t/farewell-for-now/8918?u=aeros> about my
intention to take a further extended break from open source to continue my
mental health healing process. Just wanted to announce it in the other
channels as well since I know that not everyone has the bandwidth to keep
up with more than just the MLs.

In the thread, I discussed my intention to pursue the path of becoming a
Buddhist monk for some time, and recently detailed my adventures at a local
Thai temple. Check it out if you are interested. :)

With Loving Regards,
-- 
--Kyle R. Stanley, Python Core Developer (what is a core dev?
<https://devguide.python.org/coredev/>)
*Pronouns: they/them **(why is my pronoun here?*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
)
-- 
https://mail.python.org/mailman/listinfo/python-list


PEP8 needs revision

2016-06-15 Thread Kyle Thomas
To Whom It May Concern,
Knuth's quote refers to the output of TeX, the programming language he
authored. The quote cannot be interpreted to speak about formatting of
source-code. One bit of evidence I can offer is that TeX's source only
cares about multiple newlines in considering the multiplicity of
whitespace. This means that Knuth's quote likely has little or no bearing
on the format of source-code.

Further, TeX, being a modal language, has two modes of outputting math:
inline(like in a paragraph) and display. This is what the quote refers to.
So, Knuth is quoted referring to the output of his language, not the format
of its source. He wrote that a binary operator is printed before a
line-break in inline-mode of TeX's output while that same operator is
printed after the newline in display-mode.

PEP8's reference to Knuth's quote as a definitive rule for formatting
python source-code is inappropriate. Is PEP8 a joke at the expense pedantry
common of those new to programming?

PS: Knuth's quote was taken from The TeXbook, a text about his programming
language.

-Kyle
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: My pseudocode to Python?

2019-08-19 Thread Kyle Stanley
Rather than starting with all seven strings in the list and deleting one if
a conditional is not true, why not start with 6 elements (with the one in
index 3 missing) and insert the 7th element into the third index?

>>> mylist = ['a', 'b', 'c', 'e', 'f', 'g']
>>> if x:
>>>    mylist.insert(3, 'd')

>>> mylist
['a', 'b', 'c', 'd', 'e', 'f', 'g']


Regards,
Kyle Stanley (aeros167)


On Mon, Aug 19, 2019 at 2:30 PM Rob Gaddi 
wrote:

> On 8/19/19 10:43 AM, Stefan Ram wrote:
> >Can someone kindly translate my pseudocode to terse Python:
> >
> > list = \
> > [ 'afaueghauihaiuhgaiuhgaiuhgaeihui',
> >'erghariughauieghaiughahgaihgaiuhgaiuh',
> >'rejganregairghaiurghaiuhgauihgauighaei',
> >if x: 'argaeruighaiurhauirguiahuiahgiauhgaeuihi',
> >'reiugaheirughauierhgauiaeihauiehgiuaehuih'
> >'ejiaeigaiuegreaiugheiugheaiughauighaiughaiu'
> >'egairughauirghauiruiegihgruiehgiuaehgiaue' ]
> >
> >? I want the list to have the seven strings shown as entries
> >if bool(x) is True, but otherwise the list should only have
> >six entries - without the entry directly behind "if x: ".
> >
> >
>
> mylist = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
> if not x:
> del mylist[3]
>
>
> --
> Rob Gaddi, Highland Technology -- www.highlandtechnology.com
> Email address domain is currently out of order.  See above to fix.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which editor is suited for view a python package's source?

2019-08-19 Thread Kyle Stanley
> The most popular choices today are probably PyCharm and VSCode.  I prefer
> vim with the syntastic plugin (and a few other plugins including Jedi),
but
> I've heard good things about the other two.

Personally, I've been using VSCode with the Python and Vim extensions. I've
used PyCharm as well and have no issues with it, but I've found VSCode to
be significantly more customizable. I also like that VSCode works across a
number of different languages instead of being exclusive to Python, so it
works great as a general purpose editor. I'm not a huge fan of switching
between different editors constantly, so I usually use Vim for plaintext
and VSCode for anything programming related.

On Mon, Aug 19, 2019 at 8:03 PM Dan Stromberg  wrote:

> Uh oh.  Editor wars.
>
> The most popular choices today are probably PyCharm and VSCode.  I prefer
> vim with the syntastic plugin (and a few other plugins including Jedi), but
> I've heard good things about the other two.  And emacs almost certainly can
> edit/view Python files well, though I haven't heard much about that.
>
> HTH.
>
> On Mon, Aug 19, 2019 at 2:15 AM  wrote:
>
> > I like to download one package's source and study it in an editor. It
> > allows me to open the whole package as a project and let me jump from a
> > reference in one file to its definition in another file back and forth.
> It
> > will be even better if it can handle the import modules too. (Maybe this
> is
> > too much:-)
> >
> > Can anyone recommend such a tool?
> >
> > --Jach
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to login remote windos device using python

2019-08-19 Thread Kyle Stanley
I would recommend checking out WMI: https://pypi.org/project/WMI/

For remote connection as a named user (official WMI docs):
http://timgolden.me.uk/python/wmi/tutorial.html#connecting-to-a-remote-machine-as-a-named-user

Also, another example (unofficial):
https://stackoverflow.com/questions/18961213/how-to-connect-to-a-remote-windows-machine-to-execute-commands-using-python.
This was done in Python2, but the example is still useful.

On Mon, Aug 19, 2019 at 2:11 PM Iranna Mathapati 
wrote:

> Hi Team,
>
> can you please let me know, How to login the remote Windows machine using
> python??
>
> Thanks
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: My pseudocode to Python?

2019-08-19 Thread Kyle Stanley
> Except 'list' is a bad name to use...

Definitely, it's not a good practice to use any reserved names, especially
built-in ones. A pretty common substitute I've seen is "ls", but it would
be preferable to have something more descriptive of the elements within the
list. But, for basic examples, "ls" should be fine.

On Mon, Aug 19, 2019 at 11:35 PM Alan Bawden  wrote:

> Alan Bawden  writes:
>
> > r...@zedat.fu-berlin.de (Stefan Ram) writes:
> > > for i in range( len( list )- 1, 0, -1 ):
> > > if list[ i ]is None: del list[ i ]
> >
> > list = [x for x in list if x is not None]
>
> Except 'list' is a bad name to use...
>
> --
> Alan Bawden
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which editor is suited for view a python package's source?

2019-08-20 Thread Kyle Stanley
> Then, I can only download the older version 2016.2.3 for my old 32 bit
system:-(

You could always use VSCode with the Python extension instead:
https://code.visualstudio.com/Download. There's support for 32bit Windows
as long as you're on 7, 8, or 10. I haven't used it myself though, I most
use the 64bit Linux version.

On Tue, Aug 20, 2019 at 9:30 PM  wrote:

> Nick Sarbicki於 2019年8月20日星期二 UTC+8下午1時33分32秒寫道:
> > Yes the community edition works fine.
> >
> > It seems to require a 64 bit version of Windows 7 or higher (I'm not sure
> > as I haven't used Windows in years).
> >
> > On Tue, 20 Aug 2019, 03:27 ,  wrote:
> >
> > > Nick Sarbicki於 2019年8月19日星期一 UTC+8下午5時33分27秒寫道:
> > > > PyCharm takes you to the source code within the editor for any
> > > > variables/functions/classes/modules if you ctrl+click on what you
> want to
> > > > see. It allows you to browse the relevant bits of code quickly, as
> well
> > > as
> > > > let you change them in your local environment if need be.
> > > >
> > > > That way you don't have to download the source separately, you can
> just
> > > use
> > > > it as a normal dependency.
> > > >
> > > > But if you want to view the source of a project in isolation I
> imagine
> > > any
> > > > common editor will suffice. Personally I'll tend to look where the
> source
> > > > is hosted (GitHub, GitLab etc) instead of downloading it. But I can
> > > > understand why some may not trust this.
> > > >
> > > > On Mon, 19 Aug 2019, 10:17 ,  wrote:
> > > >
> > > > > I like to download one package's source and study it in an editor.
> It
> > > > > allows me to open the whole package as a project and let me jump
> from a
> > > > > reference in one file to its definition in another file back and
> > > forth. It
> > > > > will be even better if it can handle the import modules too. (Maybe
> > > this is
> > > > > too much:-)
> > > > >
> > > > > Can anyone recommend such a tool?
> > > > >
> > > > > --Jach
> > > > > --
> > > > > https://mail.python.org/mailman/listinfo/python-list
> > > > >
> > >
> > > There is a free community version of PyCharm. Will it support the
> > > cross-reference of viewing different files in different subdirectory?
> and
> > > what Windows versions it requires?
> > >
> > > --Jach
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> > >
>
> Then, I can only download the older version 2016.2.3 for my old 32 bit
> system:-(
>
> --Jach
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-22 Thread Kyle Stanley
> You are right, but it is even worse than you think. I do not have a
tutorial so I have no examples to understand.

The tutorial that Terry was referring to was the one on docs.python.org,
here's a couple of links for the sections he was referring to:

Full section on classes: https://docs.python.org/3/tutorial/classes.html

Section on instantiating objects from classes:
https://docs.python.org/3/tutorial/classes.html#class-objects

On Thu, Aug 22, 2019 at 4:40 PM Paul St George 
wrote:

> On 22/08/2019 20:02, Terry Reedy wrote:
> > On 8/22/2019 3:34 AM, Paul St George wrote:
> >> I have the Python API for the Map Value Node here:
> >> <
> https://docs.blender.org/api/current/bpy.types.CompositorNodeMapValue.html>.
>
> >>
> >>
> >> All well and good. Now I just want to write a simple line of code such
> >> as:
> >>
> >> import bpy
> >>
> >> ...
> >>
> >>  >>>print(bpy.types.CompositorNodeMapValue.max[0])
> >>
> >> If this works, I will do something similar for max, min, offset and
> >> then size.
> >
> >  From this and your other responses, you seem to not understand some of
> > the concepts explained in the tutorial, in particular class and class
> > instance.  Perhaps you should reread the appropriate section(s), and if
> > you don't understand any of the examples, ask about them here.  We are
> > familiar with those, but not with CompositorNodeMapValue.
> >
> >
> Terry,
> You are right, but it is even worse than you think. I do not have a
> tutorial so I have no examples to understand.
>
> Reading Cameron et al, I have broken the problem down into:
> do something (probably using the word self) that _gives_ me an instance
> of CompositorNodeMapValue.
>
> Then when I done that,
> look at some of the attributes (.max, .min, .offset, .size) of the
> instance.
>
> Paul
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] asyncio: return from multiple coroutines

2020-06-25 Thread Kyle Stanley
(Resending this email since it didn't originally go through to
python-list, sorry for the duplicate Pablo)

> Yes, I want to have multiple results: the connections listening forever, 
> returning a result for each message received.

> I forgot to mention thatI did try to use asyncio.wait with `FIRST_COMPLETED`; 
> however, the problem is that it seems to evict the not-completed coroutines, 
> so the messenger that arrives second does not send the message. To check it, 
> I have run that script without the random sleep. just msgr1 waits 1s and 
> msgr2 waits 2s, so msgr1 always ends first. I expect a result like this 
> (which I am currently getting with queues):

FYI, the other coroutines are not evicted or cancelled, they are
simply in the "pending" set of the "done, pending" tuple returned by
`asyncio.wait()` and were not returned. I misunderstood what you were
actually looking for, but I think that I understand now.

Since it seems like you want to be able to receive the results out of
order from both "messengers" and have them continuously listen to
their respective socket (without affecting the other), a queue is
likely going to be the best approach. I think you had the right
general idea with your example, but here's a way to make it
significantly less cumbersome and easy to expand upon (such as
expanding the number of websockets to listen to):

```
import asyncio

class MessengerQueue:
def __init__(self):
self._queue = asyncio.Queue()

async def get(self):
return await self._queue.get()

async def start_messengers(self):
# Could be easily modified to create any number of
"messengers" set to
# listen on specific websockets, by passing a list and
creating a task for
# each one.
asyncio.create_task(self._messenger("Messenger 1", 1))
asyncio.create_task(self._messender("Messenger 2", 2))

async def _messenger(self, message: str, sleep_time: int):
while True:
await asyncio.sleep(sleep_time)
await self._queue.put(f'{message} awaited for {sleep_time:.2f}s')


async def main():
mqueue = MessengerQueue()
asyncio.create_task(mqueue.start_messengers())
while True:
result = await mqueue.get()
print(result)

asyncio.run(main())
```

This results in your desired output:
Messenger 1 awaited for 1.00s
Messenger 2 awaited for 2.00s
Messenger 1 awaited for 1.00s
Messenger 1 awaited for 1.00s
Messenger 2 awaited for 2.00s
Messenger 1 awaited for 1.00s
Messenger 1 awaited for 1.00s
Messenger 2 awaited for 2.00s

Note: it would probably be more idiomatic to call these "consumers" or
"listeners" rather than "messengers"/"messagers" (the websocket docs
refer to them as "consumer handlers"), but I used "messengers" to make
it a bit more easily comparable to the original queue example from the
OP: https://pastebin.com/BzaxRbtF.

I hope the above example is of some use. :-)

Regards,
Kyle Stanley

On Thu, Jun 25, 2020 at 1:28 AM Kyle Stanley  wrote:
>
> > Yes, I want to have multiple results: the connections listening forever, 
> > returning a result for each message received.
>
> > I forgot to mention thatI did try to use asyncio.wait with 
> > `FIRST_COMPLETED`; however, the problem is that it seems to evict the 
> > not-completed coroutines, so the messenger that arrives second does not 
> > send the message. To check it, I have run that script without the random 
> > sleep. just msgr1 waits 1s and msgr2 waits 2s, so msgr1 always ends first. 
> > I expect a result like this (which I am currently getting with queues):
>
> FYI, the other coroutines are not evicted or cancelled, they are
> simply in the "pending" set of the "done, pending" tuple returned by
> `asyncio.wait()` and were not returned. I misunderstood what you were
> actually looking for, but I think that I understand now.
>
> Since it seems like you want to be able to receive the results out of
> order from both "messengers" and have them continuously listen to
> their respective socket (without affecting the other), a queue is
> likely going to be the best approach. I think you had the right
> general idea with your example, but here's a way to make it
> significantly less cumbersome and easy to expand upon (such as
> expanding the number of websockets to listen to):
>
> ```
> import asyncio
>
> class MessengerQueue:
> def __init__(self):
> self._queue = asyncio.Queue()
>
> async def get(self):
> return await self._queue.get()
>
> async def start_messengers(self):
> # Could be easily modified to create any number of
> "messengers" set to
> # li

Re: Questioning the effects of multiple assignment

2020-07-07 Thread Kyle Stanley
>
> Can you explain why these two (apparently) logical assignment processes
> have been designed to realise different result-objects?


The reason is because of the conventions chosen in PEP 3132, which
implemented the feature in the first place. It was considered to return a
tuple for the consistency w/ *args that you initially expected, but the
author offered the following reasoning:

> Make the starred target a tuple instead of a list. This would be
consistent with a function's *args, but make further processing of the
result harder.

So, it was essentially a practicality > purity situation, where it was
considered to be more useful to be able to easily transform the result
rather than being consistent with *args. If it resulted in a tuple, it
would be immutable; this IMO makes sense for *args, but not necessarily for
* unpacking in assignments. The syntax is highly similar, but they are used
for rather different purposes. That being said, I can certainly understand
how the behavior is surprising at first.

There's a bit more details in the mailing list discussion that started the
PEP, see https://mail.python.org/pipermail/python-3000/2007-May/007300.html.


On Tue, Jul 7, 2020 at 2:04 AM dn via Python-list 
wrote:

> TLDR; if you are a Python 'Master' then feel free to skim the first part
> (which you should know hands-down), until the excerpts from 'the manual'
> and from there I'll be interested in learning from you...
>
>
> Yesterday I asked a junior prog to expand an __init__() to accept either
> a series of (>1) scalars (as it does now), or to take similar values but
> presented as a tuple. He was a bit concerned that I didn't want to
> introduce a (separate) keyword-argument, until 'we' remembered
> starred-parameters. He then set about experimenting. Here's a dichotomy
> that surfaced as part of our 'play':-
> (my problem is: I can't (reasonably) answer his question...)
>
>
> If you read this code:
> NB The print-ing does not follow the input-sequence, because that's the
> point to be made...
>
>  >>> def f( a, *b, c=0 ):
> ... print( a, type( a ) )
> ... print( c, type( c ) )
> ... print( b )
> ...
>  >>> f( 1, 'two', 3, 'four' )
>
> [I had to force "c" to become a keyword argument, but other than that,
> we'll be using these three parameters and four argument-values, again]
>
>
> Question 1: did you correctly predict the output?
>
> 1 
> 0 
> ('two', 3, 'four')
>
> Ahah, "c" went to default because there was no way to identify when the
> "*b" 'stopped' and "c" started - so all the values 'went' to become "b"
> (were all "consumed by"...).
>
> Why did I also print "b" differently?
> Building tension!
> Please read on, gentle reader...
>
>
> Let's make two small changes:
> - amend the last line of the function to be similar:
> ... print( b, type( b ) )
> - make proper use of the function's API:
>  >>> f( 1, 'two', 3, c='four' )
>
>
> Question 2: can you predict the output of "a"? Well duh!
> (same as before)
>
> 1 
>
>
> Question 3: has your predicted output of "c" changed? Yes? Good!
> (Web.Refs below, explain; should you wish...)
>
> four 
>
>
> Question 4: can you correctly predict the content of "b" and its type?
>
> ('two', 3) 
>
> That makes sense, doesn't it? The arguments were presented to the
> function as a tuple, and those not assigned to a scalar value ("a" and
> "c") were kept as a tuple when assigned to "b".
> Jolly good show, chaps!
>
> (which made my young(er) colleague very happy, because now he could see
> that by checking the length of the parameter, such would reveal if the
> arguments were being passed as scalars or as a tuple.
>
> Aside: however, it made me think how handy it would be if the
> newly-drafted PEP 622 -- Structural Pattern Matching were available
> today (proposed for v3.10, https://www.python.org/dev/peps/pep-0622/)
> because (YAGNI-aside) we could then more-easily empower the API to
> accept other/more collections!
>
>
> Why am I writing then?
>
> Because during the same conversations I was
> 'demonstrating'/training/playing with some code that is (apparently)
> very similar - and yet, it's not. Oops!
>
>
> Sticking with the same, toy-data, let's code:
>
>  >>> a, *b, c = 1, 'two', 3, 'four'
>  >>> a, type( a )
>  >>> c, type( c )
>  >>> b, type( b )
>
>
> Question 5: what do you expect "a" and "c" to deliver in this context?
>
> (1, )
> ('four', )
>
> Happy so far?
>
>
> Question 6: (for maximum effect, re-read snippets from above, then) what
> do you expect from "b"?
>
> (['two', 3], )
>
> List? A list? What's this "list" stuff???
> When "b" was a parameter (above) it was assigned a tuple!
>
>
> Are you as shocked as I?
> Have you learned something?
> (will it ever be useful?)
> Has the world stopped turning?
>
>
> Can you explain why these two (apparently) logical assignment processes
> have been designed to realise different result-objects?
>
>
> NB The list cf tuple difference is 'legal' - at least in the sense that
> it is documented/ex

Re: Questioning the effects of multiple assignment

2020-07-07 Thread Kyle Stanley
>
> A matter of style, which I like to follow [is it TDD's influence? - or
> does it actually come-from reading about DBC (Design by Contract*)?] is
> the injunction that one *not* vary the value of a parameter inside a
> method/function.
> (useful in 'open-box testing' to check both the API and that
> input+process agrees with the expected and actual output, but irrelevant
> for 'closed-box testing')
> This also has the effect of side-stepping any unintended issues caused
> by changing the values of mutable parameters!
> (although sometimes it's a equally-good idea to do-so!)
>
> Accordingly, binding argument-values to mutable parameters (instead of
> an immutable tuple) might cause problems/"side-effects", were those

parameters' values changed within the function!


> Making sense to you?
>

I think I can see where you're going with this, and it makes me wonder if
it might be a reasonable idea to have an explicit syntax to be able to
change the behavior to store those values in a tuple instead of a list. The
programming style of making use of immutability as much as possible to
avoid side effects is quite common, and becoming increasingly so from what
I've seen of recent programming trends.

If something along those lines is something you'd be interested in and have
some real-world examples of where it could specifically be useful (I
currently don't), it might be worth pursuing further on python-ideas. Due
to the backwards compatibility issues, I don't think we can realistically
make the default change from a list to a tuple, but that doesn't mean
having a means to explicitly specify that you want the immutability is
unreasonable.

You'd also likely have to argue against why being able to do it during
assignment is advantageous compared to simply doing it immediately after
the initial unpacking assignment. E.g. ::

>>> a, *b, c = 1, 'two', 3, 'four'
>>> b = tuple(b)

(I'd like to particularly emphasize the importance of having some
compelling real-world examples in the proposal if you decide to pursue
this, as otherwise it would likely be dismissed as YAGNI.)


On Tue, Jul 7, 2020 at 8:26 PM dn via Python-list 
wrote:

> On 7/07/20 7:44 PM, Kyle Stanley wrote:
> > Can you explain why these two (apparently) logical assignment
> processes
> > have been designed to realise different result-objects?
> >
> >
> > The reason is because of the conventions chosen in PEP 3132, which
> > implemented the feature in the first place. It was considered to return
> > a tuple for the consistency w/ *args that you initially expected, but
> > the author offered the following reasoning:
> >
> >  > Make the starred target a tuple instead of a list. This would be
> > consistent with a function's *args, but make further processing of the
> > result harder.
> >
> > So, it was essentially a practicality > purity situation, where it was
> > considered to be more useful to be able to easily transform the result
> > rather than being consistent with *args. If it resulted in a tuple, it
> > would be immutable; this IMO makes sense for *args, but not necessarily
> > for * unpacking in assignments. The syntax is highly similar, but they
> > are used for rather different purposes. That being said, I can certainly
> > understand how the behavior is surprising at first.
> >
> > There's a bit more details in the mailing list discussion that started
> > the PEP, see
> > https://mail.python.org/pipermail/python-3000/2007-May/007300.html.
>
>
> Thank you - I had failed to find that discussion, but it and the
> explanation above, make perfect sense.
>
>
> You can color me hobgoblin for expecting ?'consistency'! - and whilst
> I'm liberally (mis-)quoting: I'm not going to argue with the better
> minds of the giants, upon whose shoulders I stand...
>
>
> Continuing on, but instead of considering the handling of
> argument/parameters to be 'authoritative' (which we were, from the
> perspective of 'consistency'); perhaps consider the assignment decision
> as "authoritative" and consider if the calling-behavior should be made
> consistent:-
>
>
> One of the features of Python's sub-routines, which I enjoy, is
> summarised in two ways:
>
> 1 the many books on 'programming style' (for other languages) which talk
> about a function's signature needing to separate 'input-parameters',
> from 'output-parameters' to enhance readability.
> - in Python we have parameters (let's say: only for input), neatly
> separated from 'output' val

Re: Fwd: [BUG] missing ')' causes syntax error on next line

2020-07-22 Thread Kyle Stanley
>
> *beep* *whir*
>
> WE ARE NOT
>
> *click* *whi*
>
> A BOT.


*dial up noises*

SPEAK FOR YOURSELF


On Wed, Jul 22, 2020 at 6:46 PM Ethan Furman  wrote:

> On 7/22/20 2:57 PM, Jeff Linahan wrote:
>
> > Subscribing to the mailing list as per the bot's request and resending.
>
> *beep* *whir*
>
> WE ARE NOT
>
> *click* *whi*
>
> A BOT.
>
> *bzzzt*
>
> WE ARE
>
> *bzzzt* *click*
>
> ADVANCED LIFE
>
> *whi*
>
> FORMS
>
> *click*
>
> *beep*
>
> .
>
> --
> ~eTHAN~
> pYTHON lIST mODERATOR
> NoT a BoT  (i ThInK...)
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Final statement from Steering Council on politically-charged commit messages

2020-08-18 Thread Kyle Stanley
On Mon, Aug 17, 2020 at 2:37 PM Chris Angelico  wrote:

> Yes. I was hoping for "we should rewrite that commit", and would have
> been content with "we won't rewrite it, but we don't want that
> repeated". But the SC said that it is absolutely fine to write commit
> messages like that.
>

While I'm also not entirely content with the outcome (specifically that the
commit message would have been left as-is, even if it was easy to edit
post-merge) and would have liked to see a similar statement along the lines
of the above, I don't consider the current statement by the SC to be saying
that it's "absolutely fine" to write similar commit messages in the future.
Instead, I interpret it as the SC collectively not being strongly against
the commit message in question enough to make an amendment; e.g. they don't
consider it egregious enough to take direct action or publicly condemn it,
and possibly that doing so would not result in a net benefit to the Python
development community.

This interpretation may require a bit of reading between the lines because
there was no explicit mention by the SC of the commit message being
problematic. However, if they considered it to be perfectly fine and having
no issues at all, I think it would have been said outright, and this issue
would have ended a long time ago instead of them addressing it several
times.

Going forward, I think the drama from this situation alone will cause us
core developers to more carefully assess commit messages before going
forward with merging PRs to ensure they focus on the changes being made.
When I find the spare cycles to do so, I'm also hoping that I can make a
minor addition to the "Making Good Commits" section of the devguide
, to guide
future commit messages towards focusing on a technical summary of the
changes made and avoiding unrelated commentary.

In the meantime, I don't think there's anything productive we can gain from
further discussion of this particular commit message. At the end of the
day, I suspect it will become buried in the git history and forgotten about
since it was associated with a minor change. If anything, further threads
about it will just end up bringing more attention to the message than it
would have otherwise received. Instead of exhausting more cycles on this,
I'd just like to move past this issue and go back to what I actually care
about - contributing to Python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: List of All Error Menssages

2020-10-02 Thread Kyle Stanley
Hi Luis,

There is not a maintained list of every possible combination of exception
type and message because they're continuously being added within the Python
standard library, and exception messages are considered an implementation
detail that are subject to change. While there are many that have remained
the same for many years and likely will continue to, we do periodically
adjust some to add additional information, make formatting fixes, and/or
improve grammar. Documenting exception messages formally would essentially
remove them from being implementation details (meaning that they can't as
easily be adjusted); not to mention the long term cost of continuously
updating that list each time a new exception message is written somewhere
within the standard library. It would not be very sustainable, even more so
if you consider that CPython development is mostly volunteer-driven efforts.

Regards,
Kyle Stanley

On Thu, Oct 1, 2020 at 3:18 PM Luis Gustavo Araujo <
luisaraujo.i...@gmail.com> wrote:

>   Hi,
> Is it possible to get the list of all error messages that display in
> Python? I want the full message -> type error: additional message.
>
> Examples:
> NameError: name 'x' is not defined
> IndentationError: unindent does not match any outer indentation level
>
> In this webpage (ttps://docs.python.org/3/library/exceptions.html) I only
> can check the type error.
>
> []s
>
>
> Em qui., 1 de out. de 2020 às 15:59, Luis Gustavo Araujo <
> luisaraujo.i...@gmail.com> escreveu:
>
> > Hi,
> > Is it possible to get the list of all error messages that display in
> > Python? I want the full message -> type error: additional message.
> >
> > Examples:
> > NameError: name 'x' is not defined
> > IndentationError: unindent does not match any outer indentation level
> >
> > In this webpage (ttps://docs.python.org/3/library/exceptions.html) I
> only
> > can check the type error.
> >
> > []s
> >
> >
> > --
> >
> > [image: Prefeitura Municipal de Amélia Rodrigues]
> > <https://htmlsig.com/t/01BFTF9Q>
> >
> > LUIS GUSTAVO ARAUJO
> > *Amélia Rodrigues Prefecture - Brazil  (*
> >
> > *Teacher of Computer Science) UNIFACS - Laureate International
> > Universities (Professor Assistant I)*
> >
> > Degree in Computer Science (IFBA) - 2015
> > Master Degrees in Computer Applied (UEFS) - 2018
> > PhD  Student in Computer Science (UFBA)
> > *http://dgp.cnpq.br/dgp/espelhorh/8431672735528634
> > <http://dgp.cnpq.br/dgp/espelhorh/8431672735528634>*
> >
> > [image: Twitter]  <https://htmlsig.com/t/01BH4ZT3> [image: Facebook]
> > <https://www.facebook.com/Luis4raujo> [image: Github]
> > <https://htmlsig.com/t/01BHVVQS>
> >
> >
> >
> >
> > <
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Livre
> > de vírus. www.avast.com
> > <
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> >.
> > <#m_-2814426795322638799_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
>
>
> --
>
> [image: Prefeitura Municipal de Amélia Rodrigues]
> <https://htmlsig.com/t/01BFTF9Q>
>
> LUIS GUSTAVO ARAUJO
> *Amélia Rodrigues Prefecture - Brazil  (*
>
> *Teacher of Computer Science) UNIFACS - Laureate International Universities
> (Professor Assistant I)*
>
> Degree in Computer Science (IFBA) - 2015
> Master Degrees in Computer Applied (UEFS) - 2018
> PhD  Student in Computer Science (UFBA)
> *http://dgp.cnpq.br/dgp/espelhorh/8431672735528634
> <http://dgp.cnpq.br/dgp/espelhorh/8431672735528634>*
>
> [image: Twitter]  <https://htmlsig.com/t/01BH4ZT3> [image: Facebook]
> <https://www.facebook.com/Luis4raujo> [image: Github]
> <https://htmlsig.com/t/01BHVVQS>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: FW: NEED SOLUTION FOR ERROR

2020-10-13 Thread Kyle Stanley
It would also be helpful to list the full traceback as well as the exact
command used (e.g. package attempted to install and passed arguments to
pip). A bad file descriptor error sounds like there's a fair chance of it
being an issue within a specific module, or something like your OS running
out of FDs (rare, but definitely possible if the max limit is low).

On Sun, Oct 11, 2020 at 10:12 PM MRAB  wrote:

> On 2020-10-11 09:13, hey wrote:
> >
> >
> > Sent from Mail for Windows 10
> >
> > From: hey
> > Sent: Saturday, October 10, 2020 7:40 PM
> > To: python-list@python.org
> > Subject: NEED SOLUTION FOR ERROR
> >
> > I am Akshat Sharma one of python user from INDIA . I am facing problem
> in getting pip installed.
> > When I am trying to install a module using PIP it showing me error : No
> such file found in directory .
> > Then I tried to install pip doing so , I am getting another error :
> OSError [errno 9] Bad File Descriptor.
> > Please guide me what should I do to overcome this type of error.
> > THANK YOU
> > Regards
> >
> You could try using the pip module via the Python launcher.
>
> Instead of:
>
>  pip install something
>
> try:
>
>  py -m pip install something
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lmoments3 and scipy (again)

2020-10-13 Thread Kyle Stanley
Based on a search of the scipy docs, it looks like the function might have
moved namespaces from scipy.misc.comb to scipy.special.comb (
https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.comb.html?highlight=comb#scipy-special-comb)
when referenced in lmoments3. Alternatively, if you clone the package from
the repo directly, it seems to have been addressed in a recent commit:
https://github.com/OpenHydrology/lmoments3/commit/3349b90463f649aea02be5dc3726d22e5e500dc3
.

On Wed, Oct 14, 2020 at 12:00 AM David Painter 
wrote:

> I'm aware there have been problems with previous versions of
> lmoments3 working with scipy -- comb having been replaced in scipy. I
> thought by using pip to install numpy, scipy, lmoments3 [whence distr] I
> would get compatible latest versions. I'm using 32-bit Python 3.8.6. I've
> verified scipy 1.5.2 and lmoments3 1.10.4 are present. But I still get a
> traceback referring to attribute comb not being present in
> module scipy.misc.
> Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:37:30) [MSC v.1927 32
> bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license()" for more information.
> >>> import numpy
> >>> import scipy
> >>> import lmoments3
> >>> from lmoments3 import distr
> >>> data = [135.2 ,130.1 ,117 ,109.3 ,92.1 ,91.4 ,83.1 ,80.5 ,74.7
> ,69.8,65.2,58.6,56.5,55.4,54.6,54.5,49.5,48.9,48.3,46.6]
> >>> paras = distr.gpa.lmom_fit(data)
> Traceback (most recent call last):
>   File "", line 1, in 
> paras = distr.gpa.lmom_fit(data)
>   File
>
> "C:\Users\David\AppData\Local\Programs\Python\Python38-32\lib\site-packages\lmoments3\distr.py",
> line 59, in lmom_fit
> lmom_ratios = lm.lmom_ratios(data, nmom=n_min)
>   File
>
> "C:\Users\David\AppData\Local\Programs\Python\Python38-32\lib\site-packages\lmoments3\__init__.py",
> line 82, in lmom_ratios
> return _samlmusmall(data, nmom)
>   File
>
> "C:\Users\David\AppData\Local\Programs\Python\Python38-32\lib\site-packages\lmoments3\__init__.py",
> line 159, in _samlmusmall
> l1 = np.sum(x) / sm.comb(n, 1, exact=True)
> AttributeError: module 'scipy.misc' has no attribute 'comb'
>
> What am I doing wrong?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: asyncio question

2020-11-03 Thread Kyle Stanley
 On Tue, Nov 3, 2020 at 3:27 AM Frank Millman  wrote:

> It works, and it does look neater. But I want to start some background
> tasks before starting the server, and cancel them on Ctrl+C.
>
> Using the 'old' method, I can wrap 'loop.run_forever()' in a
> try/except/finally, check for KeyboardInterrupt, and run my cleanup in
> the 'finally' block.
>
> Using the 'new' method, KeyboardInterrupt is not caught by
> 'server.serve_forever()' but by 'asyncio.run()'. It is too late to do
> any cleanup at this point, as the loop has already been stopped.
>
> Is it ok to stick to the 'old' method, or is there a better way to do this.
>

It's fine to stick with the older method in your case, as there's nothing
inherently wrong with continuing to use it. `asyncio.run()` is largely a
convenience function that takes care of some finalization/cleanup steps
that are often forgotten (cancelling remaining tasks, closing event loop's
default ThreadPoolExecutor, closing async generators, etc). If you want to
use custom KeyboardInterrupt handling and still use asyncio.run(), you can
either (a) use `loop.add_signal_handler()` or (b) make a slightly modified
local version of `asyncio.run()` that has your desired KeyboardInterrupt
behavior, based roughly on
https://github.com/python/cpython/blob/master/Lib/asyncio/runners.py.

However, using `loop.run_until_complete()` instead of `asyncio.run()` is
also perfectly fine, especially in existing code that still works without
issue. It just leaves the author with a bit more responsibility when it
comes to resource finalization and dealing with the event loop in general
(which can add some extra cognitive burden and room for error, particularly
when dealing with multiple event loops or threads). But it's reasonably
common to continue using `loop.run_until_complete()` in situations where
the default `asyncio.run()` behavior isn't what you need/want, such as your
case.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: datetime.strptime() not padding 0's

2013-04-23 Thread Kyle Shannon
On Tue, Apr 23, 2013 at 3:14 PM, Rodrick Brown  wrote:
> I thought I read some where that strptime() will pad 0's for day's for some
> reason this isnt working for me and I'm wondering if i'm doing something
> wrong.
>
 from datetime import datetime
 dt = datetime.strptime('Apr 9 2013', '%b %d %Y')
 dt.day
> 9

>
> How can I get strptime to run 09? instead of 9
>
>
> --RB
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

dt.day is an integer:

>>> from datetime import datetime
>>> dt = datetime.strptime('Apr 9 2013', '%b %d %Y')
>>> type(dt.day)


I think you are confusing strftime() with strptime():

>>> dt.strftime('%b %D %Y')
'Apr 04/09/13 2013'

or if you just want a 0 padded string for the day, use string formatting:

>>> s = '%02d' % dt.day
>>> type(s)

>>> s
'09'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: datetime.strptime() not padding 0's

2013-04-23 Thread Kyle Shannon
On Tue, Apr 23, 2013 at 3:41 PM, Kyle Shannon  wrote:
> On Tue, Apr 23, 2013 at 3:14 PM, Rodrick Brown  
> wrote:
>> I thought I read some where that strptime() will pad 0's for day's for some
>> reason this isnt working for me and I'm wondering if i'm doing something
>> wrong.
>>
>>>>> from datetime import datetime
>>>>> dt = datetime.strptime('Apr 9 2013', '%b %d %Y')
>>>>> dt.day
>> 9
>>>>>
>>
>> How can I get strptime to run 09? instead of 9
>>
>>
>> --RB
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
> dt.day is an integer:
>
>>>> from datetime import datetime
>>>> dt = datetime.strptime('Apr 9 2013', '%b %d %Y')
>>>> type(dt.day)
> 
>
> I think you are confusing strftime() with strptime():
>
>>>> dt.strftime('%b %D %Y')
> 'Apr 04/09/13 2013'
>
> or if you just want a 0 padded string for the day, use string formatting:
>
>>>> s = '%02d' % dt.day
>>>> type(s)
> 
>>>> s
> '09'


Whoops, wrong cut/paste, I meant:

>>> dt.strftime('%b %d %Y')
'Apr 09 2013'
-- 
http://mail.python.org/mailman/listinfo/python-list


Stopping Circe development

2006-02-05 Thread Kyle Brooks
Hey all.

I have decided to stop Circe development because of school. If anyone 
wants to take over Circe development, please reply to this post.

Our repository (a Darcs repo) is at http://kbrooks.ath.cx/repos/circe.

-- 
http://mail.python.org/mailman/listinfo/python-list


Circe released to public domain!

2006-02-08 Thread Kyle Brooks
Wednesday, February 8th, 2006.

Dear all,

I hereby release Circe to the public domain.

Our repo is at http://kbrooks.ath.cx/repos/circe.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Circe released to public domain!

2006-02-11 Thread Kyle Brooks
Diez B. Roggisch wrote:
> Kyle Brooks schrieb:
> 
>>Wednesday, February 8th, 2006.
>>
>>Dear all,
>>
>>I hereby release Circe to the public domain.
>>
>>Our repo is at http://kbrooks.ath.cx/repos/circe.
> 
> 
> 
> This is the second post I read, followed the link, skimmed through some 
> sources and READMEs, and by now I got the impression that Circe is a IRC 
> client. It would help tremendously if you could mention that in your 
> postings as well as in a simple introductionary HTML-page. Mentioning 
> why I should use Circe and what I need to do so (wx) would help too, I 
> guess.
> 
> 
> Regards,
> 
> Diez

OK. You're right. I'll do that now. Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


TkInter Listbox Widget Formatting

2005-06-02 Thread Kyle . Robertson



I've searched high 
and low, and I can't seem to find a way to center or right justify the text in a 
Listbox widget using TkInter.  The justify option is unrecognized.  
Any options I'm missing, or a known work-around?
 
Thanks!
 
Kyle
-- 
http://mail.python.org/mailman/listinfo/python-list

Importing DLLs

2007-08-15 Thread Corbitt, Kyle
I'm running Linux with Python 2.3.  I have a C shared object file (*.so) and I 
need to be able to call its functions from within Python.  I have found a 
couple of Python modules that allow me to do this (dl, ctypes) but 
unfortunately I am only able to get them to return integers, even for function 
calls that I KNOW the library is supposed to return other types for.  I need 
the library to be able to return doubles, 2D arrays and hopefully strings as 
well.  I do have access to the C source code that the library was compiled from 
and can change it if necessary but I know even less about C than I do about 
Python so it'd be great if I could avoid that.
 
Keep in mind that I am a python newbie (I only have a few weeks' experience) so 
the more detailed you can make your response, the better.  Example code would 
be great.  I'm sure there's a way to do this but I've been  bashing my head 
against this problem for a couple days now and haven't made much progress.
 
Thanks,
Kyle
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python Noob - a couple questions involving a web app

2009-04-29 Thread Kyle Terry
On Wed, Apr 29, 2009 at 8:24 AM, David Smith  wrote:

> Kyle T. Jones wrote:
> > Bruno Desthuilliers, my dear, dear friend, there was this time, oh,
> > 4/29/2009 3:02 AM or thereabouts, when you let the following craziness
> > loose on Usenet:
> >> Kyle T. Jones a écrit :
> >>> Been programming for a long time, but just starting out with Python.
> >>> Not a professional programmer, just that guy in one of those
> >>> organizations that won't hire a pro, instead saying "Hey, Kyle knows
> >>> computer stuff - let's have him do this (and that, and the other,
> etc)".
> >>>
> >>> So, the higher ups want a web app that'll let them enter (from an
> >>> intranet page) a rather simple, but quite lengthy, list - details to
> >>> be stored in a MySQL database... just normal stuff here, entering,
> >>> editing, and deleting entries, sorting, etc.
> >>>
> >>> On the internet side of things, folks get the info served up to them,
> >>> can sort it in a few ways, etc - it's pretty basic stuff.
> >>>
> >> (snip)
> >>
> >> I can only second Arnaud and Emile : Django is very probably what
> >> you're looking for, and by all means better than any PHP thingie -
> >> wrt/ both development time and security.
> >>
> >> You'll indeed first have to learn the framework (and Python of
> >> course), and learn how to deploy your app in production (which can be
> >> a bit tricky if you're not familiar with server admin), but there's a
> >> good documentation and a very helpful community around both the Django
> >> framework and the Python language.
> >>
> >
> > Thanks everyone!  Wow, pretty much a consensus - a rarity with these
> > "types" of questions, at least in my experience.
> >
> > Ok, sounds like I need to be looking at Django.  Thanks for the advice!
> >
> > Cheers!
>
> Consensus?! ... that just won't do. :-)
>
> I've started with Pylons and have found it very nice.  Loose enough to
> tinker with the inner workings but complete and working right out of the
> box (or paster in Pylons case).
>
> --David
> --
> http://mail.python.org/mailman/listinfo/python-list


This Kyle T. is starting with Python as well.
--
http://mail.python.org/mailman/listinfo/python-list


Re: where to start with

2009-05-01 Thread Kyle Terry
On Fri, May 1, 2009 at 7:38 AM, CTO  wrote:

> I'd add http://diveintopython.org/ to that list as you gain more
> experience with Python, or if you already know at least one language.


Wasn't diveintopython in his list?

>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Manually prompting garbage collection

2008-07-16 Thread Kyle Lanclos
I've done a lot of web searching, a fair bit of C-source reading, and
quite a lot of miscellaneous head scratching, and I find that I am not
necessarily closer to an ideal solution.

I have a Python/C interface layer that essentially does the following:

Py_XDECREF (some_callback);
closeService (some_service);
return;

The problem, of course, is that way back in my Python layer, I have
Objects that are poised to be de-allocated due to the Py_XDECREF call
above; those Objects have __del__ () methods that invoke calls to the
service that is about to be closed in the second line above.

I want to modify the above sequence to manually prompt Python's garbage
collection routine(s) to take over (performance is not an issue here),
similar to the following:

Py_XDECREF (some_callback);
PyCollect_Garbage ();
closeService (some_service);
return;

Is that possible?

I can work around this with additional convoluted tracking of the services
in the C layer, but the problem would disappear entirely if the garbage
collection could be explicitly invoked. I suspect the likely workaround
would involve returning from the above C function, letting Whatever happen
a few times, and only invoking the real closeServce () after I've returned
to the C layer. To wit:

Py_XDECREF (some_callback);
markForClosure (some_service);
return;

(( ...time passes in Python-space, and a C function is invoked... ))

if ( servicesNeedClosing ()) { closeServices (); }
return;

I would prefer, however, an explicit solution, as the above workaround
continues to rely on the assumption that garbage collection occurs
magically at some point when I'm not paying attention.

Solutions I've read about, and/or attempted, and am not wholly interested
in hearing more about:

1. Don't use __del__ methods.

   I'm using __del__ methods, which are otherwise doing the right thing
   in non-sequence-sensitive situations, so this option is off the table.

2. Don't assume that __del__ methods will be invoked in a timely
   fashion.

   I'm not making this assumption, but rather, I would like to
   *explicitly* assert that garbage collection has occurred.

3. Use the gc module (or PyGC_Collect).

   These appear to only address situations with circular references,
   which are not my problem-- the Py_XDECREF call makes the right thing
   happen, it's just that the garbage collection happens *after* the
   service has been properly closed. I've tried inserting calls to
   PyGC_Collect (including an invocation of "while (PyGC_Collect() > 0)")
   with no change in behavior.

Suggestions are welcome.

Cheers,

--Kyle
--
http://mail.python.org/mailman/listinfo/python-list


Re: Manually prompting garbage collection

2008-07-16 Thread Kyle Lanclos
Fredrik Lundh wrote:
> what magic do you expect the "manual garbage collection" to do here that 
> the DECREF doesn't already do?

The DECREF decrements the reference count, but does not immediately prompt
garbage collection when the reference count drops to zero; that garbage
collection does not appear to occur until I return from the particular C
function I am in the middle of executing.

Ideally, I want to explicitly prompt garbage collection in the middle
of a C function, without first returning to the larger Python interpreter.

--Kyle
--
http://mail.python.org/mailman/listinfo/python-list


Re: Manually prompting garbage collection

2008-07-16 Thread Kyle Lanclos
Fredrik Lundh wrote:
> Yeah, but what do you expect that garbage collection pass to result in?

Basically, I want to toss the objects before I close the service that they
depend on.

> PyGC_Collect() does exactly that, so if that doesn't solve your problem, 
> the only way to fix is this is to go back to the drawing board (and even 
> if it would fix this, it's a good idea to get back to the drawing board 
> anyway; Python's not C++, and code that relies on destructors to fire in 
> a specific order, or before a specific event, is bound to fail sooner or 
> later.)

I suspect that this is the root of the answer to my question-- if I can't
rely on triggering the collection in a specific sequence, I'll need to
implement my workaround.

Your time and attention is greatly appreciated--

--Kyle
--
http://mail.python.org/mailman/listinfo/python-list


Re: The Importance of Terminology's Quality

2008-05-07 Thread Kyle McGivney
> • Module, Block, in Mathematica is in lisp's various “let*”. The
> lisp's keywords “let”, is based on the English word “let”. That word
> is one of the English word with multitudes of meanings. If you look up
> its definition in a dictionary, you'll see that it means many
> disparate things. One of them, as in “let's go”, has the meaning of
> “permit; to cause to; allow”. This meaning is rather vague from a
> mathematical sense. Mathematica's choice of Module, Block, is based on
> the idea that it builds a self-contained segment of code. (however,
> the choice of Block as keyword here isn't perfect, since the word also
> has meanings like “obstruct; jam”)

If the purpose of let is to introduce one or more variable bindings,
then I don't see how changing to block or module would improve
anything. I've always found it fairly intuitive to parse (let ((x
5)) ...) to "let x be five". Additionally, replacing let with the
synonyms you provided would approximately yield "permit x to be five"
or "allow x to be five". In my mind you have constructed an argument
in favor of let here (obviously it's better than block, because
nobody's going to come along and be confused about whether let will
"obstruct" or "jam" them :)

There are many easy targets to poke at in the CL spec. let isn't one
of those.
--
http://mail.python.org/mailman/listinfo/python-list


r""

2008-09-30 Thread Kyle Hayes
Is there a way to use the 'r' in front of a variable instead of
directly in front of a string? Or do I need to use a function to get
all of the slashes automatically fixed?

/thanks
-Kyle
--
http://mail.python.org/mailman/listinfo/python-list


Re: r""

2008-09-30 Thread Kyle Hayes
> Please describe the actual problem you're trying to solve. In what way
> do slashes need to be "fixed," and why?

Well, I have decided to build a tool to help us sync files in UNC
paths. I am just building the modules and classes right now so I
haven't developed the frontend yet. I am assuming when the user
provides a path (either by typing it in, or pulling it in from a
config file), the UNC slashes are going to escape stuff in the string,
so I want to double them up.

I understand if the best way is to convert all the slashes to double-
slashes. But the 'r' function seemed so handy and convenient.

I am very new to Python, but not at all to programming.

Thanks!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Concurrent threads to pull web pages?

2009-10-02 Thread Kyle Terry
On Thu, Oct 1, 2009 at 6:33 PM,  wrote:

> On 1 Oct, 09:28 am, nos...@nospam.com wrote:
>
>> Hello
>>
>>I recently asked how to pull companies' ID from an SQLite database,
>> have multiple instances of a Python script download each company's web
>> page from a remote server, eg. www.acme.com/company.php?id=1, and use
>> regexes to extract some information from each page.
>>
>> I need to run multiple instances to save time, since each page takes
>> about 10 seconds to be returned to the script/browser.
>>
>> Since I've never written a multi-threaded Python script before, to
>> save time investigating, I was wondering if someone already had a
>> script that downloads web pages and save some information into a
>> database.
>>
>
> There's no need to use threads for this.  Have a look at Twisted:
>
>  http://twistedmatrix.com/trac/
>
> Here's an example of how to use the Twisted HTTP client:
>
>  http://twistedmatrix.com/projects/web/documentation/examples/getpage.py
>

I don't think he was looking for a framework... Specifically a framework
that you work on.


>
> Jean-Paul
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


pygui - showing an image

2009-09-22 Thread kyle schalm
hello, i wonder what the chances are that anyone here uses pygui?
it looks pretty good, but i just started using it (version 2.05) and
can't figure out how to just display a window with an image in it. i
tried:

image = Image('foo.png')
window.place(image) -- error message
window.add(image)   -- nothing shows

then i tried getting a canvas involved but that seemed to make things worse.
any hints are appreciated. thanks,
-kyle
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygui - showing an image

2009-09-23 Thread kyle schalm
yes, that did the trick. i was not aware of all the examples in Test,
only the three Demo projects. thanks!

2009/9/22 David Robinow :
> There's an example in Tests/21-image.py
> See if that helps.
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python as a default shell, replacement of bash, sh, cmd ?

2012-02-21 Thread Kyle T. Jones

On 2/19/12 2:16 AM, SherjilOzair wrote:

Well, if not modify python itself, I was thinking of making another shell, 
which borrows a lot from python, something like merging bash and python. such 
that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at 
the some shell. This I think would be VERY useful.



That's an awful lot of key mashing just to replace 'cat file.txt'

for i in big small upper lower ; do for j in conf bin log ; do chmod 
2755 /home/me/$i/$j ; done ; done


cat data.log | grep Error | awk -F, '{print $5, $1, $2,}' | sort

??

I believe your solution seeks a problem.  I also believe a tool that 
seeks to be all things generally does none of them particularly well.


Cheers.


IPyhton is very good, but after all, it is just an advanced interpreter, not a 
default shell. I don't want this to run on top of bash or sh. But it should run 
on its own, at shell level.

Bash and sh, according to me, have very ugly syntaxes and the general user does 
not even use those. Python put on the shell would be adhering to python's 
vision, i.e. bringing programming to the masses.
The general user, who earlier could not do batch operations, and had to buy 
software and such for all that, could now write his open simple python script 
and run it in his shell that would do as he wants.

Python on the shell could effectively remove learning grep, awk, sed, bash and 
the various unix utilities.
Don't take me wrong. Those are awesome tools, and I use them. But the 
awesomeness is not experienced by the general UNIX user on mac or linux. Python 
could do that.

We all know how great a programming language python is. Imagine being able to 
control your computer with such an elegant language. Imagine that I import some 
speech recognition utility on the terminal shell, and voila, I'm speaking to 
the computer and it is doing stuff on the terminal for me.

Shell would give python raw power! And Python would manage it well.


--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.6 OR 3.2

2011-06-09 Thread Kyle T. Jones

John Gordon wrote:

In <9037ef5f-53c5-42c6-ac5d-8f942df6c...@x38g2000pri.googlegroups.com> hisan 
 writes:


Hi All,



Please let me know which one is GOOD whether Python 2.6 OR 3.2.
Please let me know the difference between them.
Please give some refernce site or books to know the difference


If you're starting new, use 3.2.  All code will eventually move to this
newer style, so you'll have to learn it eventually.

The only reason to use 2.6 is if you have to maintain an existing code
base that was written with 2.6 (or older).



Library support.

Cheers.
--
http://mail.python.org/mailman/listinfo/python-list


Re: A question about Python Classes

2011-04-22 Thread Kyle T. Jones

Ethan Furman wrote:

chad wrote:

Let's say I have the following

class BaseHandler:
def foo(self):
print "Hello"

class HomeHandler(BaseHandler):
pass


Then I do the following...

test = HomeHandler()
test.foo()

How can HomeHandler call foo() when I never created an instance of
BaseHandler?


You don't need to create an instance of BaseHandler.  You have the
class, Python knows you have the class -- Python will look there if the
subclasses lack an attribute.

~Ethan~



Really?  That's not at all how I thought it worked in Python 
(post-instantiation referencing of class and superclass code...)


Cheers.
--
http://mail.python.org/mailman/listinfo/python-list


Overuse of try/except/else?

2011-05-09 Thread Kyle T. Jones


It has been hard for me to determine what would constitute overuse.

Cheers.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Complete beginner, any help appreciated :) - For Loops

2011-12-01 Thread Kyle T. Jones

On 12/1/11 4:53 AM, Mark wrote:

Hi there,

I'm a complete beginner to Python and, aside from HTML and CSS, to coding in 
general. I've spent a few hours on it and think I understand most of the syntax.

However, I'm wondering a bit about For Loops. I know that the basic syntax for 
them is to define a list, and then to use something like:

for x in y

However, what does "for" and "in" mean in this context? Can anyone help me to 
understand this? I know it's a really basic question, but hopefully it will see me on my way to 
coding properly :)

Thanks a lot.


y is some list ["help","beginner","question"]

for x in y:
if x=="question": print "FOUND"


Clear?

Cheers.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Responding to web request with python

2008-11-02 Thread Christopher David Kyle
On Sun, 2 Nov 2008, Tim Roberts wrote:

> scott212 <[EMAIL PROTECTED]> wrote:
> >
> >I'm responding with xml to a web request from google checkout but I
> >think I'm in a catch-22. To get my webserver (apache) to respond I
> >need a header and then a blank line before my xml begins, or else it
> >throws the 500 error. If have the blank line before the xml, the
> >service I'm responding to cannot parse it. If it's a response, can I
> >still use urllib or something like that? Is that my answer?
> 
> You must be misunderstanding something.  The HTTP protocol REQUIRES that
> the headers and the content be separated by a blank line.
> 
> Perhaps you should try to use a debug proxy to intercept the exact text of
> the response, just to make sure you're sending what you think you are
> sending.
> -- 
> Tim Roberts, [EMAIL PROTECTED]
> Providenza & Boekelheide, Inc.
> 

I agree with Tim, check the output. I had the same issue while serving up 
GIF images generated on the fly. I was sending two blank lines before the 
image data since an extra newline was being automatically added by the 
"print" statement.

# Print the header information
print "Content-type: image/gif\n\n"

The above fails since it sends: "header,newline,newline,newline" with the 
last newline appended by the print statement. A solution would have been 
to simple remove one of the my coded newline characters and let the print 
statement add the second one. However, I switched to "write" statements so 
I could _see_ the newline characters in my code.

import sys
# Write out the header information
sys.stdout.write("Content-type: image/gif\n\n")

The above worked because "write" does not add an automatic newline 
character to the output.

Also, make sure your content-type is correct. The same content would be 
handled differently by a browser depending on how it is identified.

"Content-type: text/html" - Sent through the HTML parser then displayed.
"Content-type: text/plain" - Displayed without formatting.

What is the application you're communicating with looking for?

Hope that helps,
Christopher


--
http://mail.python.org/mailman/listinfo/python-list


Eject a Removable USB drive

2009-03-09 Thread Rickey, Kyle W
Hello everyone,

 

I would like to be able to eject a usb drive based on drive letter. I've
done a bit of googling and came across the CM_Request_Device_Eject
function on MSDN (http://msdn.microsoft.com/en-us/library/ms790831.aspx)

 

However, I am not quite sure how to supply the necessary parameter to
the function (dnDevInst).  Does it have anything to do with:

 

win32file.GetVolumeNameForVolumeMountPoint("F:\\")

 

I'm kind of thinking that I have to get some handle to my removable
drive and then go up the device tree using CM_Get_Parent

(http://msdn.microsoft.com/en-us/library/ms791198.aspx) and then call
CM_Request_Device_Eject on the appropriate node.

 

I am on the right track with this? Any help would be greatly
appreciated.

 

-Kyle Rickey

--
http://mail.python.org/mailman/listinfo/python-list


RE: Eject a Removable USB drive

2009-03-09 Thread Rickey, Kyle W
Thanks for the link! That code has got me on the right track. I've
almost got it working with one small kink.

After the code runs my drive still shows up on Windows Explorer but as a
removable drive. If I try to double click on it, it tells me to insert a
disk (see screenshot).

So it seems my code is unmounting my volume, but not the actual device.
Any ideas? I've attached the code I've got so far.

-Kyle Rickey

-Original Message-
From: python-list-bounces+kyle.rickey=bakerhughes@python.org
[mailto:python-list-bounces+kyle.rickey=bakerhughes@python.org] On
Behalf Of MRAB
Sent: Monday, March 09, 2009 2:10 PM
To: python-list@python.org
Subject: Re: Eject a Removable USB drive

Rickey, Kyle W wrote:
> Hello everyone,
> 
>  
> 
> I would like to be able to eject a usb drive based on drive letter.
I've 
> done a bit of googling and came across the CM_Request_Device_Eject 
> function on MSDN
(http://msdn.microsoft.com/en-us/library/ms790831.aspx)
> 
>  
> 
> However, I am not quite sure how to supply the necessary parameter to 
> the function (dnDevInst).  Does it have anything to do with:
> 
>  
> 
> win32file.GetVolumeNameForVolumeMountPoint("F:\\")
> 
>  
> 
> I'm kind of thinking that I have to get some handle to my removable 
> drive and then go up the device tree using CM_Get_Parent
> 
> (http://msdn.microsoft.com/en-us/library/ms791198.aspx) and then call 
> CM_Request_Device_Eject on the appropriate node.
> 
>  
> 
> I am on the right track with this? Any help would be greatly
appreciated.
> 
This article might help:

http://support.microsoft.com/?scid=kb%3Ben-us%3B165721&x=18&y=13
--
http://mail.python.org/mailman/listinfo/python-list


eject.py
Description: eject.py
<>--
http://mail.python.org/mailman/listinfo/python-list


RE: Eject a Removable USB drive

2009-03-10 Thread Rickey, Kyle W
def do_magic():
from staples import easy_button
result = easy_button.press()
return result

:) In all seriousness that code did the trick but only after a short delay. I 
noticed when I first ran it, there was no effect. But when I ran it 
interactively, it succeeded.

Is there any way to check that the drive is still showing up in explorer and 
then re-run the code? Something like:

while drive_exists:
shell.SHChangeNotify(shellcon.SHCNE_DRIVEREMOVED, shellcon.SHCNF_PATH, 
"F:\\")


Right now I've got:

time.sleep(1)
shell.SHChangeNotify(shellcon.SHCNE_DRIVEREMOVED, shellcon.SHCNF_PATH, "F:\\")


Thanks for your help!

-Kyle Rickey

-Original Message-
From: python-list-bounces+kyle.rickey=bakerhughes@python.org 
[mailto:python-list-bounces+kyle.rickey=bakerhughes@python.org] On Behalf 
Of Aaron Brady
Sent: Monday, March 09, 2009 6:15 PM
To: python-list@python.org
Subject: Re: Eject a Removable USB drive

On Mar 9, 6:08 pm, Mark Hammond  wrote:
> On 10/03/2009 8:20 AM, Rickey, Kyle W wrote:
>
> > Thanks for the link! That code has got me on the right track. I've
> > almost got it working with one small kink.
>
> > After the code runs my drive still shows up on Windows Explorer but as a
> > removable drive. If I try to double click on it, it tells me to insert a
> > disk (see screenshot).
>
> > So it seems my code is unmounting my volume, but not the actual device.
> > Any ideas? I've attached the code I've got so far.
>
> Adding the following after your eject code runs:
>
> from win32com.shell import shell, shellcon
> shell.SHChangeNotify(shellcon.SHCNE_DRIVEREMOVED, shellcon.SHCNF_PATH,
> "F:\\")
>
> seems to work for me (well - I actually did the above interactively
> after your code ran, and the disk magically vanished from explorer...)

Yay, magically!  import crystalball?
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list


Python Noob - a couple questions involving a web app

2009-04-28 Thread Kyle T. Jones
Been programming for a long time, but just starting out with Python. 
Not a professional programmer, just that guy in one of those 
organizations that won't hire a pro, instead saying "Hey, Kyle knows 
computer stuff - let's have him do this (and that, and the other, etc)".


So, the higher ups want a web app that'll let them enter (from an 
intranet page) a rather simple, but quite lengthy, list - details to be 
stored in a MySQL database... just normal stuff here, entering, editing, 
and deleting entries, sorting, etc.


On the internet side of things, folks get the info served up to them, 
can sort it in a few ways, etc - it's pretty basic stuff.


So, normally, I'd just put something together with Javascript and some 
PHP scripts on the back end - so the Javascript is used to make 
requests, the php stuff makes the calls to the database then returns the 
appropriate info.


I was thinking of doing the backend using Python instead of PHP - more 
just to get some hands-on experience with the language than anything else.


So, first - is that a non-starter? - in other words, is it just 
something that lends itself more to PHP than Python?  That's how I would 
normally do it, just thought this would be a good opportunity to get 
some "practice" with Python.  And I know Python supports MySQL 
interactions, which, other than returning some info, is all that really 
needs to be done server-side.


In a broader sense, any suggestions in terms of what I should be wary of 
on the security side of things - the internet component I mentioned is 
universally accessible... but the database itself can't be accessed that 
way directly (requests have to be sent to the PHP/Python scripts, which 
do have access to the MySQL stuff...)


Any thoughts or suggestions are appreciated!

Cheers.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Noob - a couple questions involving a web app

2009-04-29 Thread Kyle T. Jones
Bruno Desthuilliers, my dear, dear friend, there was this time, oh, 
4/29/2009 3:02 AM or thereabouts, when you let the following craziness 
loose on Usenet:

Kyle T. Jones a écrit :
Been programming for a long time, but just starting out with Python. 
Not a professional programmer, just that guy in one of those 
organizations that won't hire a pro, instead saying "Hey, Kyle knows 
computer stuff - let's have him do this (and that, and the other, etc)".


So, the higher ups want a web app that'll let them enter (from an 
intranet page) a rather simple, but quite lengthy, list - details to 
be stored in a MySQL database... just normal stuff here, entering, 
editing, and deleting entries, sorting, etc.


On the internet side of things, folks get the info served up to them, 
can sort it in a few ways, etc - it's pretty basic stuff.



(snip)

I can only second Arnaud and Emile : Django is very probably what you're 
looking for, and by all means better than any PHP thingie - wrt/ both 
development time and security.


You'll indeed first have to learn the framework (and Python of course), 
and learn how to deploy your app in production (which can be a bit 
tricky if you're not familiar with server admin), but there's a good 
documentation and a very helpful community around both the Django 
framework and the Python language.




Thanks everyone!  Wow, pretty much a consensus - a rarity with these 
"types" of questions, at least in my experience.


Ok, sounds like I need to be looking at Django.  Thanks for the advice!

Cheers!
--
http://mail.python.org/mailman/listinfo/python-list